@axiom-lattice/core 2.1.100 → 2.1.103
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 +143 -2
- package/dist/index.d.ts +143 -2
- package/dist/index.js +1438 -588
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1465 -625
- 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,306 @@ 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/audioUtils.ts
|
|
7819
|
+
var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
7820
|
+
".webm",
|
|
7821
|
+
".wav",
|
|
7822
|
+
".mp3",
|
|
7823
|
+
".m4a",
|
|
7824
|
+
".ogg",
|
|
7825
|
+
".flac",
|
|
7826
|
+
".aac",
|
|
7827
|
+
".wma",
|
|
7828
|
+
".opus",
|
|
7829
|
+
".amr"
|
|
7830
|
+
]);
|
|
7831
|
+
function isAudioFile(filePath) {
|
|
7832
|
+
const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
|
|
7833
|
+
return AUDIO_EXTENSIONS.has(ext);
|
|
7834
|
+
}
|
|
7835
|
+
function detectAudioFormat(filePath) {
|
|
7836
|
+
return filePath.toLowerCase().slice(filePath.lastIndexOf(".") + 1);
|
|
7837
|
+
}
|
|
7838
|
+
var MAX_AUDIO_SIZE = 25 * 1024 * 1024;
|
|
7839
|
+
function validateAudioSize(sizeBytes) {
|
|
7840
|
+
if (sizeBytes > MAX_AUDIO_SIZE) {
|
|
7841
|
+
return `Audio file too large (${(sizeBytes / 1024 / 1024).toFixed(1)}MB). Maximum is 25MB.`;
|
|
7842
|
+
}
|
|
7843
|
+
return null;
|
|
7844
|
+
}
|
|
7845
|
+
|
|
7846
|
+
// src/deep_agent_new/backends/describeImage.ts
|
|
7847
|
+
import { HumanMessage } from "@langchain/core/messages";
|
|
7848
|
+
async function describeImage(options) {
|
|
7849
|
+
const { modelKey, mimeType, base64, prompt } = options;
|
|
7850
|
+
const { client } = modelLatticeManager.getModelLattice(modelKey);
|
|
7851
|
+
if (!client.supportsVision) {
|
|
7852
|
+
throw new Error(`Model "${modelKey}" does not support vision.`);
|
|
7853
|
+
}
|
|
7854
|
+
const result = await client.invoke([
|
|
7855
|
+
new HumanMessage({
|
|
7856
|
+
content: [
|
|
7857
|
+
{
|
|
7858
|
+
type: "text",
|
|
7859
|
+
text: prompt || "Please describe this image in detail."
|
|
7860
|
+
},
|
|
7861
|
+
{
|
|
7862
|
+
type: "image_url",
|
|
7863
|
+
image_url: { url: `data:${mimeType};base64,${base64}` }
|
|
7864
|
+
}
|
|
7865
|
+
]
|
|
7866
|
+
})
|
|
7867
|
+
]);
|
|
7868
|
+
return result.content || "";
|
|
7869
|
+
}
|
|
7870
|
+
|
|
7871
|
+
// src/stt_model_lattice/STTModelLattice.ts
|
|
7872
|
+
import { OpenAIClient, toFile } from "@langchain/openai";
|
|
7873
|
+
var STTModelLattice = class {
|
|
7874
|
+
constructor(key4, config) {
|
|
7875
|
+
this.key = key4;
|
|
7876
|
+
this.config = config;
|
|
7877
|
+
this.client = this;
|
|
7878
|
+
const apiKey = config.apiKey || (config.apiKeyEnvName ? process.env[config.apiKeyEnvName] : void 0) || process.env.OPENAI_API_KEY || "";
|
|
7879
|
+
if (!apiKey) {
|
|
7880
|
+
throw new Error("No API key configured for STT. Set apiKey, apiKeyEnvName, or OPENAI_API_KEY.");
|
|
7881
|
+
}
|
|
7882
|
+
this.openaiClient = new OpenAIClient({
|
|
7883
|
+
apiKey,
|
|
7884
|
+
baseURL: config.baseURL,
|
|
7885
|
+
timeout: config.timeout || 3e4
|
|
7886
|
+
});
|
|
7887
|
+
}
|
|
7888
|
+
/**
|
|
7889
|
+
* Transcribe audio buffer to text.
|
|
7890
|
+
* Routes to whisper or chat API mode based on config.
|
|
7891
|
+
*/
|
|
7892
|
+
async transcribe(audio, format) {
|
|
7893
|
+
const mode = this.config.apiMode || "whisper";
|
|
7894
|
+
if (mode === "chat") {
|
|
7895
|
+
return this.transcribeViaChat(audio, format);
|
|
7896
|
+
}
|
|
7897
|
+
return this.transcribeViaWhisper(audio, format);
|
|
7898
|
+
}
|
|
7899
|
+
/**
|
|
7900
|
+
* Transcribe via OpenAI /v1/audio/transcriptions endpoint (multipart).
|
|
7901
|
+
*/
|
|
7902
|
+
async transcribeViaWhisper(audio, format) {
|
|
7903
|
+
const mimeType = formatToMimeType(format);
|
|
7904
|
+
const file = typeof File !== "undefined" ? new File([audio], `audio.${format}`, { type: mimeType }) : await toFile(audio, `audio.${format}`, { type: mimeType });
|
|
7905
|
+
const extra = this.config.extra || {};
|
|
7906
|
+
const response = await this.openaiClient.audio.transcriptions.create({
|
|
7907
|
+
file,
|
|
7908
|
+
model: this.config.model || "whisper-1",
|
|
7909
|
+
response_format: "verbose_json",
|
|
7910
|
+
...extra
|
|
7911
|
+
});
|
|
7912
|
+
const result = response;
|
|
7913
|
+
return {
|
|
7914
|
+
text: result.text,
|
|
7915
|
+
segments: result.segments?.map((s) => ({
|
|
7916
|
+
start: s.start,
|
|
7917
|
+
end: s.end,
|
|
7918
|
+
text: s.text
|
|
7919
|
+
})),
|
|
7920
|
+
confidence: result.segments ? result.segments.reduce((sum, s) => sum + Math.exp(s.avg_logprob ?? -Infinity), 0) / result.segments.length : void 0
|
|
7921
|
+
};
|
|
7922
|
+
}
|
|
7923
|
+
/**
|
|
7924
|
+
* Transcribe via OpenAI /v1/chat/completions with input_audio.
|
|
7925
|
+
* Used by Qwen3-ASR-Flash and similar audio-via-chat models.
|
|
7926
|
+
*/
|
|
7927
|
+
async transcribeViaChat(audio, format) {
|
|
7928
|
+
const mimeType = formatToMimeType(format);
|
|
7929
|
+
const dataUri = `data:${mimeType};base64,${audio.toString("base64")}`;
|
|
7930
|
+
const extra = this.config.extra || {};
|
|
7931
|
+
const response = await this.openaiClient.chat.completions.create({
|
|
7932
|
+
model: this.config.model || "qwen3-asr-flash",
|
|
7933
|
+
messages: [
|
|
7934
|
+
{
|
|
7935
|
+
role: "user",
|
|
7936
|
+
content: [
|
|
7937
|
+
{
|
|
7938
|
+
type: "input_audio",
|
|
7939
|
+
input_audio: {
|
|
7940
|
+
data: dataUri,
|
|
7941
|
+
format
|
|
7942
|
+
}
|
|
7943
|
+
}
|
|
7944
|
+
]
|
|
7945
|
+
}
|
|
7946
|
+
],
|
|
7947
|
+
...extra
|
|
7948
|
+
});
|
|
7949
|
+
const result = response;
|
|
7950
|
+
const text = result.choices?.[0]?.message?.content || "";
|
|
7951
|
+
return { text };
|
|
7952
|
+
}
|
|
7953
|
+
};
|
|
7954
|
+
function formatToMimeType(format) {
|
|
7955
|
+
const mimeTypes = {
|
|
7956
|
+
webm: "audio/webm",
|
|
7957
|
+
wav: "audio/wav",
|
|
7958
|
+
mp3: "audio/mpeg",
|
|
7959
|
+
m4a: "audio/mp4",
|
|
7960
|
+
ogg: "audio/ogg",
|
|
7961
|
+
flac: "audio/flac",
|
|
7962
|
+
aac: "audio/aac"
|
|
7963
|
+
};
|
|
7964
|
+
const lower = format.toLowerCase();
|
|
7965
|
+
if (!mimeTypes[lower]) {
|
|
7966
|
+
console.warn(`Unknown STT audio format "${format}", falling back to audio/webm`);
|
|
7967
|
+
}
|
|
7968
|
+
return mimeTypes[lower] || "audio/webm";
|
|
7969
|
+
}
|
|
7970
|
+
|
|
7971
|
+
// src/stt_model_lattice/STTModelLatticeManager.ts
|
|
7972
|
+
var STTModelLatticeManager = class _STTModelLatticeManager extends BaseLatticeManager {
|
|
7973
|
+
static getInstance() {
|
|
7974
|
+
if (!_STTModelLatticeManager._instance) {
|
|
7975
|
+
_STTModelLatticeManager._instance = new _STTModelLatticeManager();
|
|
7976
|
+
}
|
|
7977
|
+
return _STTModelLatticeManager._instance;
|
|
7978
|
+
}
|
|
7979
|
+
getLatticeType() {
|
|
7980
|
+
return "stt";
|
|
7981
|
+
}
|
|
7982
|
+
/**
|
|
7983
|
+
* Register an STT model lattice.
|
|
7984
|
+
* @param key - Lattice key name
|
|
7985
|
+
* @param config - STT provider configuration
|
|
7986
|
+
*/
|
|
7987
|
+
registerLattice(key4, config) {
|
|
7988
|
+
const client = new STTModelLattice(key4, config);
|
|
7989
|
+
const label = config.model || key4;
|
|
7990
|
+
const sttLattice = {
|
|
7991
|
+
key: key4,
|
|
7992
|
+
client,
|
|
7993
|
+
config,
|
|
7994
|
+
label
|
|
7995
|
+
};
|
|
7996
|
+
this.register(key4, sttLattice);
|
|
7997
|
+
}
|
|
7998
|
+
/**
|
|
7999
|
+
* Get an STT model lattice by key.
|
|
8000
|
+
*/
|
|
8001
|
+
getSTTModelLattice(key4) {
|
|
8002
|
+
const lattice = this.get(key4);
|
|
8003
|
+
if (!lattice) {
|
|
8004
|
+
throw new Error(`STTModelLattice "${key4}" not found`);
|
|
8005
|
+
}
|
|
8006
|
+
return lattice;
|
|
8007
|
+
}
|
|
8008
|
+
/**
|
|
8009
|
+
* Get STT client instance by key (default tenant).
|
|
8010
|
+
*/
|
|
8011
|
+
getSTTClient(key4) {
|
|
8012
|
+
return this.getSTTModelLattice(key4).client;
|
|
8013
|
+
}
|
|
8014
|
+
/**
|
|
8015
|
+
* Get STT client instance by key and tenant.
|
|
8016
|
+
* @param tenantId - Tenant ID for isolation
|
|
8017
|
+
* @param key - Lattice key name
|
|
8018
|
+
*/
|
|
8019
|
+
getSTTClientWithTenant(tenantId2, key4) {
|
|
8020
|
+
let lattice = this.getWithTenant(tenantId2, key4);
|
|
8021
|
+
if (!lattice && tenantId2 !== "default") {
|
|
8022
|
+
lattice = this.getWithTenant("default", key4);
|
|
8023
|
+
}
|
|
8024
|
+
if (!lattice) {
|
|
8025
|
+
throw new Error(`STTModelLattice "${key4}" not found for tenant "${tenantId2}"`);
|
|
8026
|
+
}
|
|
8027
|
+
return lattice.client;
|
|
8028
|
+
}
|
|
8029
|
+
/**
|
|
8030
|
+
* Get all registered STT models as info list.
|
|
8031
|
+
*/
|
|
8032
|
+
getAllSTTModelInfo() {
|
|
8033
|
+
return this.getAllLattices().map((l) => ({
|
|
8034
|
+
key: l.key,
|
|
8035
|
+
label: l.label,
|
|
8036
|
+
provider: l.config.provider || "openai-compatible",
|
|
8037
|
+
model: l.config.model || "unknown"
|
|
8038
|
+
}));
|
|
8039
|
+
}
|
|
8040
|
+
getAllLattices() {
|
|
8041
|
+
return this.getAll();
|
|
8042
|
+
}
|
|
8043
|
+
hasLattice(key4) {
|
|
8044
|
+
return this.has(key4);
|
|
8045
|
+
}
|
|
8046
|
+
removeLattice(key4) {
|
|
8047
|
+
return this.remove(key4);
|
|
8048
|
+
}
|
|
8049
|
+
clearLattices() {
|
|
8050
|
+
this.clear();
|
|
8051
|
+
}
|
|
8052
|
+
getLatticeCount() {
|
|
8053
|
+
return this.count();
|
|
8054
|
+
}
|
|
8055
|
+
getLatticeKeys() {
|
|
8056
|
+
return this.keys();
|
|
8057
|
+
}
|
|
8058
|
+
};
|
|
8059
|
+
var sttModelLatticeManager = STTModelLatticeManager.getInstance();
|
|
8060
|
+
var registerSTTModelLattice = (key4, config) => sttModelLatticeManager.registerLattice(key4, config);
|
|
8061
|
+
var getSTTModelLattice = (key4) => sttModelLatticeManager.getSTTModelLattice(key4);
|
|
8062
|
+
var getSTTClient = (key4) => sttModelLatticeManager.getSTTClient(key4);
|
|
8063
|
+
var getSTTClientWithTenant = (tenantId2, key4) => sttModelLatticeManager.getSTTClientWithTenant(tenantId2, key4);
|
|
8064
|
+
|
|
8065
|
+
// src/deep_agent_new/backends/transcribeAudio.ts
|
|
8066
|
+
async function transcribeAudio(options) {
|
|
8067
|
+
const { audioBuffer, format } = options;
|
|
8068
|
+
if (!sttModelLatticeManager.hasLattice("default")) {
|
|
8069
|
+
throw new Error(
|
|
8070
|
+
"No default STT model registered. Use registerSTTModelLattice('default', { ... }) first."
|
|
8071
|
+
);
|
|
8072
|
+
}
|
|
8073
|
+
const client = sttModelLatticeManager.getSTTClient("default");
|
|
8074
|
+
return await client.transcribe(audioBuffer, format);
|
|
8075
|
+
}
|
|
8076
|
+
|
|
7700
8077
|
// src/deep_agent_new/middleware/fs.ts
|
|
7701
8078
|
var FileDataSchema = z310.object({
|
|
7702
8079
|
content: z310.array(z310.string()),
|
|
@@ -7755,7 +8132,7 @@ Path conventions:
|
|
|
7755
8132
|
- glob: find files matching a pattern (e.g., "/project/**/*.py")
|
|
7756
8133
|
- grep: search for text within files`;
|
|
7757
8134
|
var LS_TOOL_DESCRIPTION = "List files and directories in a directory";
|
|
7758
|
-
var READ_FILE_TOOL_DESCRIPTION = "Read the contents of a file";
|
|
8135
|
+
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; otherwise returns an error suggesting a vision-capable model. For audio files (webm, wav, mp3, m4a, ogg, flac, aac, wma, opus, amr), transcribes the content using the default STT model; if none is registered, returns an error with registration instructions.";
|
|
7759
8136
|
var WRITE_FILE_TOOL_DESCRIPTION = "Write content to a new file. Returns an error if the file already exists";
|
|
7760
8137
|
var EDIT_FILE_TOOL_DESCRIPTION = "Edit a file by replacing a specific string with a new string";
|
|
7761
8138
|
var GLOB_TOOL_DESCRIPTION = "Find files matching a glob pattern (e.g., '**/*.py' for all Python files)";
|
|
@@ -7808,6 +8185,66 @@ function createReadFileTool(backend, options) {
|
|
|
7808
8185
|
};
|
|
7809
8186
|
const resolvedBackend = await getBackend(backend, stateAndStore);
|
|
7810
8187
|
const { file_path, offset = 0, limit = 2e3 } = input;
|
|
8188
|
+
if (isImageFile(file_path)) {
|
|
8189
|
+
const modelKey = runConfig?.modelConfig?.modelKey || "default";
|
|
8190
|
+
const { client } = modelLatticeManager.getModelLattice(modelKey);
|
|
8191
|
+
if (!client.supportsVision) {
|
|
8192
|
+
return `[\u56FE\u7247] ${file_path}
|
|
8193
|
+
\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`;
|
|
8194
|
+
}
|
|
8195
|
+
if (!resolvedBackend.readBinary) {
|
|
8196
|
+
return `[\u56FE\u7247] ${file_path}
|
|
8197
|
+
\u5F53\u524D\u540E\u7AEF\u4E0D\u652F\u6301\u4E8C\u8FDB\u5236\u8BFB\u53D6\uFF0C\u65E0\u6CD5\u5904\u7406\u56FE\u7247\u3002`;
|
|
8198
|
+
}
|
|
8199
|
+
try {
|
|
8200
|
+
const buffer2 = await resolvedBackend.readBinary(file_path);
|
|
8201
|
+
const sizeWarning = validateImageSize(buffer2.length);
|
|
8202
|
+
if (sizeWarning) {
|
|
8203
|
+
return `[\u56FE\u7247] ${file_path}
|
|
8204
|
+
${sizeWarning}`;
|
|
8205
|
+
}
|
|
8206
|
+
const mimeType = detectMimeType(file_path);
|
|
8207
|
+
const description = await describeImage({
|
|
8208
|
+
modelKey,
|
|
8209
|
+
mimeType,
|
|
8210
|
+
base64: buffer2.toString("base64")
|
|
8211
|
+
});
|
|
8212
|
+
return `[\u56FE\u7247] ${file_path}\uFF08${mimeType}\uFF0C${(buffer2.length / 1024).toFixed(1)}KB\uFF09
|
|
8213
|
+
|
|
8214
|
+
${description}`;
|
|
8215
|
+
} catch (error) {
|
|
8216
|
+
return `[\u56FE\u7247] ${file_path}
|
|
8217
|
+
\u8BFB\u53D6\u56FE\u7247\u5931\u8D25\uFF1A${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`;
|
|
8218
|
+
}
|
|
8219
|
+
}
|
|
8220
|
+
if (isAudioFile(file_path)) {
|
|
8221
|
+
if (!resolvedBackend.readBinary) {
|
|
8222
|
+
return `[Audio] ${file_path}
|
|
8223
|
+
The current backend does not support binary reading, unable to process audio.`;
|
|
8224
|
+
}
|
|
8225
|
+
try {
|
|
8226
|
+
const buffer2 = await resolvedBackend.readBinary(file_path);
|
|
8227
|
+
const sizeWarning = validateAudioSize(buffer2.length);
|
|
8228
|
+
if (sizeWarning) {
|
|
8229
|
+
return `[Audio] ${file_path}
|
|
8230
|
+
${sizeWarning}`;
|
|
8231
|
+
}
|
|
8232
|
+
const format = detectAudioFormat(file_path);
|
|
8233
|
+
const result = await transcribeAudio({ audioBuffer: buffer2, format });
|
|
8234
|
+
let output = `[Audio] ${file_path} (${format}, ${(buffer2.length / 1024).toFixed(1)}KB)`;
|
|
8235
|
+
if (result.confidence !== void 0) {
|
|
8236
|
+
output += `
|
|
8237
|
+
Confidence: ${(result.confidence * 100).toFixed(1)}%`;
|
|
8238
|
+
}
|
|
8239
|
+
output += `
|
|
8240
|
+
|
|
8241
|
+
${result.text}`;
|
|
8242
|
+
return output;
|
|
8243
|
+
} catch (error) {
|
|
8244
|
+
return `[Audio] ${file_path}
|
|
8245
|
+
Audio transcription failed: ${error instanceof Error ? error.message : "Unknown error"}`;
|
|
8246
|
+
}
|
|
8247
|
+
}
|
|
7811
8248
|
return await resolvedBackend.read(file_path, offset, limit);
|
|
7812
8249
|
},
|
|
7813
8250
|
{
|
|
@@ -9401,19 +9838,13 @@ var SandboxFilesystem = class {
|
|
|
9401
9838
|
throw new Error(`Error reading file '${filePath}': ${e.message}`);
|
|
9402
9839
|
}
|
|
9403
9840
|
}
|
|
9841
|
+
async readBinary(filePath) {
|
|
9842
|
+
return this.sandbox.file.downloadFile({ file: filePath });
|
|
9843
|
+
}
|
|
9404
9844
|
async write(filePath, content) {
|
|
9405
9845
|
try {
|
|
9406
9846
|
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
|
-
};
|
|
9847
|
+
return { path: filePath, filesUpdate: null };
|
|
9417
9848
|
} catch (e) {
|
|
9418
9849
|
throw new Error(`Error writing file '${filePath}': ${e.message}`);
|
|
9419
9850
|
}
|
|
@@ -9427,10 +9858,7 @@ var SandboxFilesystem = class {
|
|
|
9427
9858
|
new_str: newString,
|
|
9428
9859
|
replace_mode: replaceAll ? "ALL" : "FIRST"
|
|
9429
9860
|
});
|
|
9430
|
-
return {
|
|
9431
|
-
path: filePath,
|
|
9432
|
-
filesUpdate: null
|
|
9433
|
-
};
|
|
9861
|
+
return { path: filePath, filesUpdate: null };
|
|
9434
9862
|
} catch (e) {
|
|
9435
9863
|
throw new Error(`Error editing file '${filePath}': ${e.message}`);
|
|
9436
9864
|
}
|
|
@@ -9535,16 +9963,16 @@ import {
|
|
|
9535
9963
|
} from "langchain";
|
|
9536
9964
|
|
|
9537
9965
|
// src/deep_agent_new/middleware/subagents.ts
|
|
9538
|
-
import { z as
|
|
9966
|
+
import { z as z43 } from "zod/v3";
|
|
9539
9967
|
import {
|
|
9540
|
-
createMiddleware as
|
|
9968
|
+
createMiddleware as createMiddleware10,
|
|
9541
9969
|
createAgent as createAgent2,
|
|
9542
|
-
tool as
|
|
9970
|
+
tool as tool40,
|
|
9543
9971
|
ToolMessage as ToolMessage3,
|
|
9544
9972
|
humanInTheLoopMiddleware
|
|
9545
9973
|
} from "langchain";
|
|
9546
9974
|
import { Command as Command3, getCurrentTaskInput as getCurrentTaskInput2, GraphInterrupt as GraphInterrupt2 } from "@langchain/langgraph";
|
|
9547
|
-
import { HumanMessage as
|
|
9975
|
+
import { HumanMessage as HumanMessage3 } from "@langchain/core/messages";
|
|
9548
9976
|
|
|
9549
9977
|
// src/agent_worker/agent_worker_graph.ts
|
|
9550
9978
|
import {
|
|
@@ -9960,7 +10388,7 @@ var QueueMode = /* @__PURE__ */ ((QueueMode2) => {
|
|
|
9960
10388
|
|
|
9961
10389
|
// src/services/Agent.ts
|
|
9962
10390
|
import { Command as Command2 } from "@langchain/langgraph";
|
|
9963
|
-
import { HumanMessage, filterMessages } from "langchain";
|
|
10391
|
+
import { HumanMessage as HumanMessage2, filterMessages } from "langchain";
|
|
9964
10392
|
|
|
9965
10393
|
// src/chunk_buffer_lattice/ChunkBuffer.ts
|
|
9966
10394
|
var ChunkBuffer = class {
|
|
@@ -10277,7 +10705,7 @@ var buffer = new InMemoryChunkBuffer({
|
|
|
10277
10705
|
registerChunkBuffer("default", buffer);
|
|
10278
10706
|
|
|
10279
10707
|
// src/services/Agent.ts
|
|
10280
|
-
import { v4 } from "uuid";
|
|
10708
|
+
import { v4 as v42 } from "uuid";
|
|
10281
10709
|
var ThreadStatus2 = /* @__PURE__ */ ((ThreadStatus3) => {
|
|
10282
10710
|
ThreadStatus3["IDLE"] = "idle";
|
|
10283
10711
|
ThreadStatus3["BUSY"] = "busy";
|
|
@@ -10323,7 +10751,7 @@ var Agent = class {
|
|
|
10323
10751
|
runConfig
|
|
10324
10752
|
},
|
|
10325
10753
|
configurable: {
|
|
10326
|
-
run_id:
|
|
10754
|
+
run_id: v42(),
|
|
10327
10755
|
...runConfig,
|
|
10328
10756
|
runConfig
|
|
10329
10757
|
},
|
|
@@ -10396,7 +10824,7 @@ var Agent = class {
|
|
|
10396
10824
|
runConfig
|
|
10397
10825
|
},
|
|
10398
10826
|
configurable: {
|
|
10399
|
-
run_id:
|
|
10827
|
+
run_id: v42(),
|
|
10400
10828
|
...runConfig,
|
|
10401
10829
|
runConfig
|
|
10402
10830
|
// Inject runConfig for tools to access
|
|
@@ -10460,7 +10888,7 @@ var Agent = class {
|
|
|
10460
10888
|
});
|
|
10461
10889
|
const humanContent = p.content;
|
|
10462
10890
|
const input = {
|
|
10463
|
-
messages: [new
|
|
10891
|
+
messages: [new HumanMessage2({ id: humanContent.id, content: humanContent.message })]
|
|
10464
10892
|
};
|
|
10465
10893
|
if (files) {
|
|
10466
10894
|
input.files = files;
|
|
@@ -10534,7 +10962,7 @@ var Agent = class {
|
|
|
10534
10962
|
remainingPendings.forEach((p) => {
|
|
10535
10963
|
this.queueStore?.markProcessing(p.id);
|
|
10536
10964
|
const humanContent = p.content;
|
|
10537
|
-
userMessages.push(new
|
|
10965
|
+
userMessages.push(new HumanMessage2({ id: humanContent.id, content: humanContent.message }));
|
|
10538
10966
|
this.publish("message:started", {
|
|
10539
10967
|
type: "message:started",
|
|
10540
10968
|
messageId: humanContent.id,
|
|
@@ -10614,7 +11042,7 @@ var Agent = class {
|
|
|
10614
11042
|
if (signal?.aborted) break;
|
|
10615
11043
|
await this.queueStore?.markProcessing(p.id);
|
|
10616
11044
|
const humanContent = p.content;
|
|
10617
|
-
const message = new
|
|
11045
|
+
const message = new HumanMessage2({ id: humanContent.id, content: humanContent.message });
|
|
10618
11046
|
const startTime = Date.now();
|
|
10619
11047
|
this.publish("message:started", {
|
|
10620
11048
|
type: "message:started",
|
|
@@ -10782,10 +11210,10 @@ var Agent = class {
|
|
|
10782
11210
|
};
|
|
10783
11211
|
}
|
|
10784
11212
|
async invoke(queueMessage, signal) {
|
|
10785
|
-
const messageId =
|
|
11213
|
+
const messageId = v42();
|
|
10786
11214
|
const input = {
|
|
10787
11215
|
...queueMessage.input,
|
|
10788
|
-
messages: [new
|
|
11216
|
+
messages: [new HumanMessage2({ id: messageId, content: queueMessage.input.message })]
|
|
10789
11217
|
};
|
|
10790
11218
|
const inputMessage = { ...queueMessage, input };
|
|
10791
11219
|
return this.agentExecutor(inputMessage, signal);
|
|
@@ -10801,10 +11229,10 @@ var Agent = class {
|
|
|
10801
11229
|
* to avoid exposing internal annotation data.
|
|
10802
11230
|
*/
|
|
10803
11231
|
async invokeWithState(queueMessage, signal) {
|
|
10804
|
-
const messageId =
|
|
11232
|
+
const messageId = v42();
|
|
10805
11233
|
const input = {
|
|
10806
11234
|
...queueMessage.input,
|
|
10807
|
-
messages: [new
|
|
11235
|
+
messages: [new HumanMessage2({ id: messageId, content: queueMessage.input.message })]
|
|
10808
11236
|
};
|
|
10809
11237
|
const inputMessage = { ...queueMessage, input };
|
|
10810
11238
|
const { runnable_agent, runConfig } = await this.getLatticeClientAndRuntimeConfig(inputMessage.custom_run_config);
|
|
@@ -10817,7 +11245,7 @@ var Agent = class {
|
|
|
10817
11245
|
{
|
|
10818
11246
|
context: { runConfig },
|
|
10819
11247
|
configurable: {
|
|
10820
|
-
run_id:
|
|
11248
|
+
run_id: v42(),
|
|
10821
11249
|
...runConfig,
|
|
10822
11250
|
runConfig
|
|
10823
11251
|
},
|
|
@@ -10993,7 +11421,7 @@ var Agent = class {
|
|
|
10993
11421
|
*/
|
|
10994
11422
|
async addMessage(queueMessage, mode) {
|
|
10995
11423
|
const useMode = mode ?? this.queueMode.mode;
|
|
10996
|
-
const messageId = queueMessage.input.id ||
|
|
11424
|
+
const messageId = queueMessage.input.id || v42();
|
|
10997
11425
|
const messages = queueMessage.input.messages;
|
|
10998
11426
|
const legacyMessage = queueMessage.input.message;
|
|
10999
11427
|
if (!messages && !legacyMessage) {
|
|
@@ -11485,86 +11913,428 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
11485
11913
|
};
|
|
11486
11914
|
var agentInstanceManager = AgentInstanceManager.getInstance();
|
|
11487
11915
|
|
|
11488
|
-
// src/
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
return
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
"
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11916
|
+
// src/middlewares/taskMiddleware.ts
|
|
11917
|
+
import { createMiddleware as createMiddleware9, tool as tool39 } from "langchain";
|
|
11918
|
+
import { z as z42 } from "zod";
|
|
11919
|
+
function getRunConfig(config) {
|
|
11920
|
+
const c = config;
|
|
11921
|
+
return c?.configurable?.runConfig ?? {};
|
|
11922
|
+
}
|
|
11923
|
+
function getTaskStore() {
|
|
11924
|
+
return getStoreLattice("default", "task").store;
|
|
11925
|
+
}
|
|
11926
|
+
var VALID_TRANSITIONS = {
|
|
11927
|
+
pending: ["in_progress", "cancelled"],
|
|
11928
|
+
in_progress: ["completed", "review", "failed", "interrupted", "cancelled"],
|
|
11929
|
+
review: ["completed", "in_progress", "cancelled"],
|
|
11930
|
+
failed: ["in_progress", "cancelled"],
|
|
11931
|
+
interrupted: ["in_progress", "cancelled"],
|
|
11932
|
+
completed: [],
|
|
11933
|
+
cancelled: []
|
|
11934
|
+
};
|
|
11935
|
+
function isValidTransition(from, to) {
|
|
11936
|
+
const allowed = VALID_TRANSITIONS[from];
|
|
11937
|
+
if (!allowed) return false;
|
|
11938
|
+
return allowed.includes(to);
|
|
11939
|
+
}
|
|
11940
|
+
function getTaskWorkItemStore() {
|
|
11941
|
+
return getStoreLattice("default", "taskWorkItem").store;
|
|
11942
|
+
}
|
|
11943
|
+
var manageTaskSchema = z42.object({
|
|
11944
|
+
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'"),
|
|
11945
|
+
id: z42.string().optional().describe("Task ID (required for update and delete)"),
|
|
11946
|
+
title: z42.string().optional().describe("Task title (required for create)"),
|
|
11947
|
+
description: z42.string().optional().describe("Task description in Markdown"),
|
|
11948
|
+
priority: z42.enum(["low", "medium", "high"]).optional().describe("Priority level"),
|
|
11949
|
+
status: z42.enum(["pending", "in_progress", "review", "failed", "interrupted", "completed", "cancelled"]).optional().describe("Task status"),
|
|
11950
|
+
dueDate: z42.string().optional().describe("Due date (ISO 8601 format)"),
|
|
11951
|
+
metadata: z42.record(z42.unknown()).optional().describe("Structured metadata (e.g. projectId, module)"),
|
|
11952
|
+
parentId: z42.string().optional().describe("Parent task ID for grouping subtasks"),
|
|
11953
|
+
sourceId: z42.string().optional().describe("Source session/thread ID"),
|
|
11954
|
+
context: z42.record(z42.unknown()).optional().describe("Additional context data"),
|
|
11955
|
+
ownerType: z42.enum(["user", "agent"]).optional().describe("Owner type. Defaults to 'user' if omitted"),
|
|
11956
|
+
ownerId: z42.string().optional().describe("Owner ID. Auto-filled from current user/agent if omitted"),
|
|
11957
|
+
requireReview: z42.boolean().optional().describe("If true, completing sends task to 'review' status instead of 'completed'"),
|
|
11958
|
+
dependencies: z42.array(z42.string()).optional().describe("List of task IDs that must be completed before this task can start"),
|
|
11959
|
+
result: z42.string().optional().describe("Result summary when task is completed"),
|
|
11960
|
+
failureReason: z42.string().optional().describe("Reason for failure (use when status='failed')"),
|
|
11961
|
+
summary: z42.string().optional().describe("Brief summary of the operation")
|
|
11962
|
+
});
|
|
11963
|
+
function createTaskMiddleware() {
|
|
11964
|
+
const handleManageTask = async (input, config) => {
|
|
11965
|
+
const rc = getRunConfig(config);
|
|
11966
|
+
const tenantId2 = rc.tenantId || "default";
|
|
11967
|
+
const workspaceId = rc.workspaceId;
|
|
11968
|
+
const projectId = rc.projectId;
|
|
11969
|
+
const ownerId = input.ownerId || (input.ownerType === "agent" ? rc.assistant_id : null) || rc.user_id;
|
|
11970
|
+
const store = getTaskStore();
|
|
11971
|
+
switch (input.action) {
|
|
11972
|
+
case "create": {
|
|
11973
|
+
if (!input.title) {
|
|
11974
|
+
return JSON.stringify({
|
|
11975
|
+
success: false,
|
|
11976
|
+
error: "title is required for create action",
|
|
11977
|
+
hint: "Provide a short, descriptive title for the task"
|
|
11978
|
+
});
|
|
11979
|
+
}
|
|
11980
|
+
const task = await store.create({
|
|
11981
|
+
tenantId: tenantId2,
|
|
11982
|
+
ownerType: input.ownerType || "user",
|
|
11983
|
+
ownerId,
|
|
11984
|
+
title: input.title,
|
|
11985
|
+
description: input.description,
|
|
11986
|
+
priority: input.priority || "medium",
|
|
11987
|
+
status: input.status || "pending",
|
|
11988
|
+
dueDate: input.dueDate,
|
|
11989
|
+
metadata: input.metadata,
|
|
11990
|
+
parentId: input.parentId,
|
|
11991
|
+
sourceId: input.sourceId,
|
|
11992
|
+
context: input.context,
|
|
11993
|
+
requireReview: input.requireReview,
|
|
11994
|
+
dependencies: input.dependencies,
|
|
11995
|
+
workspaceId,
|
|
11996
|
+
projectId
|
|
11997
|
+
});
|
|
11998
|
+
return JSON.stringify({ success: true, data: task });
|
|
11999
|
+
}
|
|
12000
|
+
case "list": {
|
|
12001
|
+
const filter2 = {
|
|
12002
|
+
tenantId: tenantId2,
|
|
12003
|
+
ownerType: input.ownerType,
|
|
12004
|
+
ownerId: input.ownerId,
|
|
12005
|
+
status: input.status,
|
|
12006
|
+
priority: input.priority,
|
|
12007
|
+
projectId
|
|
12008
|
+
};
|
|
12009
|
+
const tasks = await store.list(filter2);
|
|
12010
|
+
return JSON.stringify({ success: true, data: tasks, count: tasks.length });
|
|
12011
|
+
}
|
|
12012
|
+
case "update": {
|
|
12013
|
+
if (!input.id) {
|
|
12014
|
+
return JSON.stringify({
|
|
12015
|
+
success: false,
|
|
12016
|
+
error: "id is required for update action",
|
|
12017
|
+
hint: "Pass the task ID you want to update"
|
|
12018
|
+
});
|
|
12019
|
+
}
|
|
12020
|
+
const existing = await store.getById(tenantId2, input.id);
|
|
12021
|
+
if (!existing) {
|
|
12022
|
+
return JSON.stringify({
|
|
12023
|
+
success: false,
|
|
12024
|
+
error: `Task '${input.id}' not found`,
|
|
12025
|
+
hint: "Use list to see available tasks and their IDs"
|
|
12026
|
+
});
|
|
12027
|
+
}
|
|
12028
|
+
if (input.status) {
|
|
12029
|
+
if (!isValidTransition(existing.status, input.status)) {
|
|
12030
|
+
const allowed = VALID_TRANSITIONS[existing.status] || [];
|
|
12031
|
+
return JSON.stringify({
|
|
12032
|
+
success: false,
|
|
12033
|
+
error: `Cannot transition task from '${existing.status}' to '${input.status}'`,
|
|
12034
|
+
allowedTransitions: allowed,
|
|
12035
|
+
hint: `From '${existing.status}', valid transitions are: ${allowed.join(", ")}`
|
|
12036
|
+
});
|
|
12037
|
+
}
|
|
12038
|
+
}
|
|
12039
|
+
if (input.status === "in_progress" && existing.dependencies && existing.dependencies.length > 0) {
|
|
12040
|
+
const incompleteDeps = [];
|
|
12041
|
+
for (const depId of existing.dependencies) {
|
|
12042
|
+
const depTask = await store.getById(tenantId2, depId);
|
|
12043
|
+
if (!depTask || depTask.status !== "completed") {
|
|
12044
|
+
incompleteDeps.push(depId);
|
|
12045
|
+
}
|
|
12046
|
+
}
|
|
12047
|
+
if (incompleteDeps.length > 0) {
|
|
12048
|
+
return JSON.stringify({
|
|
12049
|
+
success: false,
|
|
12050
|
+
error: `Cannot start task '${input.id}': ${incompleteDeps.length} dependencies not completed`,
|
|
12051
|
+
blockedBy: incompleteDeps,
|
|
12052
|
+
hint: `These tasks must be completed first: ${incompleteDeps.join(", ")}`
|
|
12053
|
+
});
|
|
12054
|
+
}
|
|
12055
|
+
}
|
|
12056
|
+
let effectiveStatus = input.status;
|
|
12057
|
+
if (existing.requireReview && input.status === "completed" && existing.status === "in_progress") {
|
|
12058
|
+
effectiveStatus = "review";
|
|
12059
|
+
}
|
|
12060
|
+
const updates = {};
|
|
12061
|
+
const settableFields = [
|
|
12062
|
+
"title",
|
|
12063
|
+
"description",
|
|
12064
|
+
"priority",
|
|
12065
|
+
"dueDate",
|
|
12066
|
+
"metadata",
|
|
12067
|
+
"parentId",
|
|
12068
|
+
"sourceId",
|
|
12069
|
+
"context",
|
|
12070
|
+
"ownerType",
|
|
12071
|
+
"ownerId",
|
|
12072
|
+
"result",
|
|
12073
|
+
"failureReason",
|
|
12074
|
+
"requireReview",
|
|
12075
|
+
"dependencies"
|
|
12076
|
+
];
|
|
12077
|
+
for (const field of settableFields) {
|
|
12078
|
+
if (input[field] !== void 0) {
|
|
12079
|
+
updates[field] = input[field];
|
|
12080
|
+
}
|
|
12081
|
+
}
|
|
12082
|
+
if (effectiveStatus !== void 0) {
|
|
12083
|
+
updates.status = effectiveStatus;
|
|
12084
|
+
}
|
|
12085
|
+
const updated = await store.update(tenantId2, input.id, updates);
|
|
12086
|
+
if (!updated) {
|
|
12087
|
+
return JSON.stringify({
|
|
12088
|
+
success: false,
|
|
12089
|
+
error: `Failed to update task '${input.id}'`,
|
|
12090
|
+
hint: "The task may have been deleted or the ID is incorrect"
|
|
12091
|
+
});
|
|
12092
|
+
}
|
|
12093
|
+
const actionMap = {
|
|
12094
|
+
pending: "pending",
|
|
12095
|
+
in_progress: "started",
|
|
12096
|
+
review: "submitted",
|
|
12097
|
+
failed: "failed",
|
|
12098
|
+
interrupted: "interrupted",
|
|
12099
|
+
completed: "completed",
|
|
12100
|
+
cancelled: "cancelled"
|
|
12101
|
+
};
|
|
12102
|
+
const workItemAction = effectiveStatus ? actionMap[effectiveStatus] || "updated" : "updated";
|
|
12103
|
+
const workItemSummary = input.summary || (effectiveStatus ? `Status changed to ${effectiveStatus}` : void 0);
|
|
12104
|
+
const workItemStore = getTaskWorkItemStore();
|
|
12105
|
+
await workItemStore.create({
|
|
12106
|
+
taskId: input.id,
|
|
12107
|
+
tenantId: tenantId2,
|
|
12108
|
+
action: workItemAction,
|
|
12109
|
+
actor: input.ownerType === "agent" ? `agent:${ownerId}` : `user:${ownerId}`,
|
|
12110
|
+
threadId: input.sourceId,
|
|
12111
|
+
summary: workItemSummary,
|
|
12112
|
+
detail: {
|
|
12113
|
+
...input.result !== void 0 && { result: input.result },
|
|
12114
|
+
...input.failureReason !== void 0 && { failureReason: input.failureReason }
|
|
12115
|
+
},
|
|
12116
|
+
workspaceId,
|
|
12117
|
+
projectId
|
|
12118
|
+
});
|
|
12119
|
+
return JSON.stringify({ success: true, data: updated });
|
|
12120
|
+
}
|
|
12121
|
+
case "delete": {
|
|
12122
|
+
if (!input.id) {
|
|
12123
|
+
return JSON.stringify({
|
|
12124
|
+
success: false,
|
|
12125
|
+
error: "id is required for delete action",
|
|
12126
|
+
hint: "Pass the task ID you want to delete"
|
|
12127
|
+
});
|
|
12128
|
+
}
|
|
12129
|
+
const deleted = await store.delete(tenantId2, input.id);
|
|
12130
|
+
if (!deleted) {
|
|
12131
|
+
return JSON.stringify({
|
|
12132
|
+
success: false,
|
|
12133
|
+
error: `Task '${input.id}' not found or could not be deleted`,
|
|
12134
|
+
hint: "Use list to verify the task exists"
|
|
12135
|
+
});
|
|
12136
|
+
}
|
|
12137
|
+
return JSON.stringify({ success: true, message: `Task '${input.id}' deleted` });
|
|
12138
|
+
}
|
|
12139
|
+
default:
|
|
12140
|
+
return JSON.stringify({
|
|
12141
|
+
success: false,
|
|
12142
|
+
error: `Unknown action '${input.action}'`,
|
|
12143
|
+
availableActions: ["create", "list", "update", "delete"],
|
|
12144
|
+
hint: "To mark a task complete, use action='update' with status='completed'"
|
|
12145
|
+
});
|
|
12146
|
+
}
|
|
12147
|
+
};
|
|
12148
|
+
return createMiddleware9({
|
|
12149
|
+
name: "TaskMiddleware",
|
|
12150
|
+
contextSchema,
|
|
12151
|
+
wrapModelCall: async (request, handler) => {
|
|
12152
|
+
const taskPrompt = `## Task Management
|
|
12153
|
+
|
|
12154
|
+
You can use the \`manage_task\` tool to create persistent tasks for user-visible work tracking.
|
|
12155
|
+
|
|
12156
|
+
### When to create a task
|
|
12157
|
+
- The user explicitly asks you to track, manage, or follow up on work
|
|
12158
|
+
- The work spans multiple sessions or might need resumption later
|
|
12159
|
+
- The user needs to review or approve output before it is considered done
|
|
12160
|
+
- There are multiple independent work items the user wants visibility into
|
|
12161
|
+
|
|
12162
|
+
### When NOT to create a task
|
|
12163
|
+
- One-shot lookups or simple Q&A ("what is X?", "search for Y")
|
|
12164
|
+
- Internal exploration steps you take to understand the problem (use \`write_todos\` for your execution plan instead)
|
|
12165
|
+
- Trivial single-step actions that complete in the same turn
|
|
12166
|
+
- Conversational or informational requests with no deliverable
|
|
12167
|
+
|
|
12168
|
+
### Ownership defaults
|
|
12169
|
+
- No params: ownerType defaults to "user" with current user's ID
|
|
12170
|
+
- ownerType="agent": auto-fills ownerId from current agent (subtask for yourself)
|
|
12171
|
+
- Explicit ownerId: assign to a specific agent or user`;
|
|
12172
|
+
return handler({
|
|
12173
|
+
...request,
|
|
12174
|
+
systemPrompt: taskPrompt + "\n\n" + (request.systemPrompt ?? "")
|
|
12175
|
+
});
|
|
12176
|
+
},
|
|
12177
|
+
tools: [
|
|
12178
|
+
tool39(
|
|
12179
|
+
handleManageTask,
|
|
12180
|
+
{
|
|
12181
|
+
name: "manage_task",
|
|
12182
|
+
description: `Manage persistent tasks. CRUD operations for user and agent tasks.
|
|
12183
|
+
|
|
12184
|
+
## Owner defaults
|
|
12185
|
+
- No ownerType/ownerId: auto-assigned to current user
|
|
12186
|
+
- ownerType="agent" without ownerId: auto-assigned to current agent
|
|
12187
|
+
- Explicit ownerId: assign to a specific agent (cross-agent delegation)
|
|
12188
|
+
|
|
12189
|
+
## Actions
|
|
12190
|
+
- create: Create a task (title required; priority/description/dueDate/metadata/parentId/context optional)
|
|
12191
|
+
- list: List tasks, filterable by ownerType/status/priority
|
|
12192
|
+
- update: Update a task (id required; pass only the fields to change)
|
|
12193
|
+
To mark complete: update with status='completed'
|
|
12194
|
+
To mark failed: update with status='failed', failureReason='...'
|
|
12195
|
+
Status transitions are validated \u2014 only allowed transitions will succeed.
|
|
12196
|
+
- delete: Delete a task (id required)`,
|
|
12197
|
+
schema: manageTaskSchema
|
|
12198
|
+
}
|
|
12199
|
+
)
|
|
12200
|
+
]
|
|
12201
|
+
});
|
|
12202
|
+
}
|
|
12203
|
+
var taskPlugin = {
|
|
12204
|
+
meta: {
|
|
12205
|
+
type: "task",
|
|
12206
|
+
name: "Task Management",
|
|
12207
|
+
description: "Enables persistent task management with delegation and tracking",
|
|
12208
|
+
configSchema: {
|
|
12209
|
+
type: "object",
|
|
12210
|
+
title: "Task Management Configuration",
|
|
12211
|
+
description: "Zero-configuration task management",
|
|
12212
|
+
properties: {}
|
|
12213
|
+
},
|
|
12214
|
+
defaultConfig: {}
|
|
12215
|
+
},
|
|
12216
|
+
middleware: () => createTaskMiddleware(),
|
|
12217
|
+
skills: {
|
|
12218
|
+
"task-definition": `## Using manage_task
|
|
12219
|
+
|
|
12220
|
+
### Task description format
|
|
12221
|
+
|
|
12222
|
+
When creating a task with manage_task, write the description in this Markdown structure:
|
|
12223
|
+
|
|
12224
|
+
## Objective
|
|
12225
|
+
[One sentence \u2014 what result to achieve, as measurable as possible]
|
|
12226
|
+
|
|
12227
|
+
## Acceptance Criteria
|
|
12228
|
+
- [ ] Criterion 1
|
|
12229
|
+
- [ ] Criterion 2
|
|
12230
|
+
|
|
12231
|
+
## Deliverables
|
|
12232
|
+
- Deliverable description
|
|
12233
|
+
|
|
12234
|
+
Update the checklist as you work: change \`[ ]\` to \`[x]\` when a criterion is met.
|
|
12235
|
+
|
|
12236
|
+
### Subtasks (parentId)
|
|
12237
|
+
|
|
12238
|
+
Use \`parentId\` to group related tasks under a parent. Create the parent task first, then create each subtask with \`parentId\` pointing to the parent.
|
|
12239
|
+
|
|
12240
|
+
### Dependencies
|
|
12241
|
+
|
|
12242
|
+
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.
|
|
12243
|
+
|
|
12244
|
+
### requireReview
|
|
12245
|
+
|
|
12246
|
+
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\`.
|
|
12247
|
+
|
|
12248
|
+
### Reporting results
|
|
12249
|
+
|
|
12250
|
+
When a task is finished:
|
|
12251
|
+
- \`update(status: "completed", result: "summary of what was done")\`
|
|
12252
|
+
- If unable to complete: \`update(status: "failed", failureReason: "specific reason")\`
|
|
12253
|
+
- If blocked waiting for user input: \`update(status: "interrupted", summary: "what you need")\`
|
|
12254
|
+
- Use description updates to append progress notes between status changes.`
|
|
12255
|
+
}
|
|
12256
|
+
};
|
|
12257
|
+
|
|
12258
|
+
// src/deep_agent_new/middleware/subagents.ts
|
|
12259
|
+
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.";
|
|
12260
|
+
var EXCLUDED_STATE_KEYS = ["messages", "todos", "jumpTo"];
|
|
12261
|
+
var DEFAULT_GENERAL_PURPOSE_DESCRIPTION = "General-purpose agent for researching complex questions, searching for files and content, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you. This agent has access to all tools as the main agent.";
|
|
12262
|
+
function getTaskToolDescription(subagentDescriptions) {
|
|
12263
|
+
return subagentDescriptions.length > 0 ? `
|
|
12264
|
+
Launch an ephemeral subagent to handle complex, multi-step independent tasks with isolated context windows.
|
|
12265
|
+
|
|
12266
|
+
Available agent types and the tools they have access to:
|
|
12267
|
+
${subagentDescriptions.join("\n")}
|
|
12268
|
+
|
|
12269
|
+
When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
|
|
12270
|
+
|
|
12271
|
+
## Usage notes:
|
|
12272
|
+
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
12273
|
+
2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
|
|
12274
|
+
3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
|
|
12275
|
+
4. The agent's outputs should generally be trusted
|
|
12276
|
+
5. Clearly tell the agent whether you expect it to create content, perform analysis, or just do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent
|
|
12277
|
+
6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
|
|
12278
|
+
7. When only the general-purpose agent is provided, you should use it for all tasks. It is great for isolating context and token usage, and completing specific, complex tasks, as it has all the same capabilities as the main agent.
|
|
12279
|
+
|
|
12280
|
+
### Example usage of the general-purpose agent:
|
|
12281
|
+
|
|
12282
|
+
<example_agent_descriptions>
|
|
12283
|
+
"general-purpose": use this agent for general purpose tasks, it has access to all tools as the main agent.
|
|
12284
|
+
</example_agent_descriptions>
|
|
12285
|
+
|
|
12286
|
+
<example>
|
|
12287
|
+
User: "I want to conduct research on the accomplishments of Lebron James, Michael Jordan, and Kobe Bryant, and then compare them."
|
|
12288
|
+
Assistant: *Uses the task tool in parallel to conduct isolated research on each of the three players*
|
|
12289
|
+
Assistant: *Synthesizes the results of the three isolated research tasks and responds to the User*
|
|
12290
|
+
<commentary>
|
|
12291
|
+
Research is a complex, multi-step task in it of itself.
|
|
12292
|
+
The research of each individual player is not dependent on the research of the other players.
|
|
12293
|
+
The assistant uses the task tool to break down the complex objective into three isolated tasks.
|
|
12294
|
+
Each research task only needs to worry about context and tokens about one player, then returns synthesized information about each player as the Tool Result.
|
|
12295
|
+
This means each research task can dive deep and spend tokens and context deeply researching each player, but the final result is synthesized information, and saves us tokens in the long run when comparing the players to each other.
|
|
12296
|
+
</commentary>
|
|
12297
|
+
</example>
|
|
12298
|
+
|
|
12299
|
+
<example>
|
|
12300
|
+
User: "Analyze a single large code repository for security vulnerabilities and generate a report."
|
|
12301
|
+
Assistant: *Launches a single \`task\` subagent for the repository analysis*
|
|
12302
|
+
Assistant: *Receives report and integrates results into final summary*
|
|
12303
|
+
<commentary>
|
|
12304
|
+
Subagent is used to isolate a large, context-heavy task, even though there is only one. This prevents the main thread from being overloaded with details.
|
|
12305
|
+
If the user then asks followup questions, we have a concise report to reference instead of the entire history of analysis and tool calls, which is good and saves us time and money.
|
|
12306
|
+
</commentary>
|
|
12307
|
+
</example>
|
|
12308
|
+
|
|
12309
|
+
<example>
|
|
12310
|
+
User: "Schedule two meetings for me and prepare agendas for each."
|
|
12311
|
+
Assistant: *Calls the task tool in parallel to launch two \`task\` subagents (one per meeting) to prepare agendas*
|
|
12312
|
+
Assistant: *Returns final schedules and agendas*
|
|
12313
|
+
<commentary>
|
|
12314
|
+
Tasks are simple individually, but subagents help silo agenda preparation.
|
|
12315
|
+
Each subagent only needs to worry about the agenda for one meeting.
|
|
12316
|
+
</commentary>
|
|
12317
|
+
</example>
|
|
12318
|
+
|
|
12319
|
+
<example>
|
|
12320
|
+
User: "I want to order a pizza from Dominos, order a burger from McDonald's, and order a salad from Subway."
|
|
12321
|
+
Assistant: *Calls tools directly in parallel to order a pizza from Dominos, a burger from McDonald's, and a salad from Subway*
|
|
12322
|
+
<commentary>
|
|
12323
|
+
The assistant did not use the task tool because the objective is super simple and clear and only requires a few trivial tool calls.
|
|
12324
|
+
It is better to just complete the task directly and NOT use the \`task\`tool.
|
|
12325
|
+
</commentary>
|
|
12326
|
+
</example>
|
|
12327
|
+
|
|
12328
|
+
### Example usage with custom agents:
|
|
12329
|
+
|
|
12330
|
+
<example_agent_descriptions>
|
|
12331
|
+
"content-reviewer": use this agent after you are done creating significant content or documents
|
|
12332
|
+
"greeting-responder": use this agent when to respond to user greetings with a friendly joke
|
|
12333
|
+
"research-analyst": use this agent to conduct thorough research on complex topics
|
|
12334
|
+
</example_agent_description>
|
|
12335
|
+
|
|
12336
|
+
<example>
|
|
12337
|
+
user: "Please write a function that checks if a number is prime"
|
|
11568
12338
|
assistant: Sure let me write a function that checks if a number is prime
|
|
11569
12339
|
assistant: First let me use the Write tool to write a function that checks if a number is prime
|
|
11570
12340
|
assistant: I'm going to use the Write tool to write the following code:
|
|
@@ -11667,8 +12437,12 @@ function getSubagents(options) {
|
|
|
11667
12437
|
const defaultSubagentMiddleware = defaultMiddleware || [];
|
|
11668
12438
|
const agents = {};
|
|
11669
12439
|
const subagentDescriptions = [];
|
|
12440
|
+
const hasTaskMiddleware = defaultSubagentMiddleware.some(
|
|
12441
|
+
(m) => m?.name === "TaskMiddleware"
|
|
12442
|
+
);
|
|
12443
|
+
const taskMiddleware = hasTaskMiddleware ? [] : [createTaskMiddleware()];
|
|
11670
12444
|
if (generalPurposeAgent) {
|
|
11671
|
-
const generalPurposeMiddleware = [...defaultSubagentMiddleware];
|
|
12445
|
+
const generalPurposeMiddleware = [...defaultSubagentMiddleware, ...taskMiddleware];
|
|
11672
12446
|
if (defaultInterruptOn) {
|
|
11673
12447
|
generalPurposeMiddleware.push(
|
|
11674
12448
|
humanInTheLoopMiddleware({ interruptOn: defaultInterruptOn })
|
|
@@ -11694,7 +12468,7 @@ function getSubagents(options) {
|
|
|
11694
12468
|
if ("runnable" in agentParams) {
|
|
11695
12469
|
agents[agentParams.key] = agentParams.runnable;
|
|
11696
12470
|
} else {
|
|
11697
|
-
const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
|
|
12471
|
+
const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...taskMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware, ...taskMiddleware];
|
|
11698
12472
|
const interruptOn = agentParams.interruptOn || defaultInterruptOn;
|
|
11699
12473
|
if (interruptOn)
|
|
11700
12474
|
middleware.push(humanInTheLoopMiddleware({ interruptOn }));
|
|
@@ -11748,7 +12522,7 @@ function createTaskTool(options) {
|
|
|
11748
12522
|
generalPurposeAgent
|
|
11749
12523
|
});
|
|
11750
12524
|
const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
|
|
11751
|
-
return
|
|
12525
|
+
return tool40(
|
|
11752
12526
|
async (input, config) => {
|
|
11753
12527
|
const { description, subagent_type, async } = input;
|
|
11754
12528
|
let assistant_id = subagent_type;
|
|
@@ -11778,7 +12552,17 @@ function createTaskTool(options) {
|
|
|
11778
12552
|
}
|
|
11779
12553
|
const currentState = getCurrentTaskInput2();
|
|
11780
12554
|
const subagentState = filterStateForSubagent(currentState);
|
|
11781
|
-
subagentState.messages =
|
|
12555
|
+
subagentState.messages = input.taskId ? [
|
|
12556
|
+
new HumanMessage3({
|
|
12557
|
+
content: `${description}
|
|
12558
|
+
|
|
12559
|
+
---
|
|
12560
|
+
You are executing a persistent task (ID: ${input.taskId}). Use manage_task.update to report your progress:
|
|
12561
|
+
- Set status to 'in_progress' when you start working
|
|
12562
|
+
- 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)
|
|
12563
|
+
- You can also update the description to append progress notes or update the acceptance criteria checklist.`
|
|
12564
|
+
})
|
|
12565
|
+
] : [new HumanMessage3({ content: description })];
|
|
11782
12566
|
const subagent_thread_id = config.configurable?.thread_id + "____" + assistant_id + "_" + config.toolCall.id;
|
|
11783
12567
|
if (async) {
|
|
11784
12568
|
const tenantId2 = config.configurable?.runConfig?.tenantId;
|
|
@@ -11810,11 +12594,12 @@ function createTaskTool(options) {
|
|
|
11810
12594
|
runConfig: {
|
|
11811
12595
|
...config.configurable?.runConfig,
|
|
11812
12596
|
assistant_id,
|
|
11813
|
-
thread_id: subagent_thread_id
|
|
12597
|
+
thread_id: subagent_thread_id,
|
|
12598
|
+
taskId: input.taskId
|
|
11814
12599
|
},
|
|
11815
|
-
main_thread_id: mainThreadId,
|
|
11816
12600
|
main_tenant_id: tenantId2,
|
|
11817
|
-
main_assistant_id: mainAssistantId
|
|
12601
|
+
main_assistant_id: mainAssistantId,
|
|
12602
|
+
main_thread_id: mainThreadId
|
|
11818
12603
|
}, false).catch((err) => {
|
|
11819
12604
|
console.error(`Failed to start async subagent ${subagent_thread_id}:`, err);
|
|
11820
12605
|
});
|
|
@@ -11842,7 +12627,8 @@ The result will be delivered as a notification when complete. Do not poll.`,
|
|
|
11842
12627
|
runConfig: {
|
|
11843
12628
|
...config.configurable?.runConfig,
|
|
11844
12629
|
assistant_id,
|
|
11845
|
-
thread_id: subagent_thread_id
|
|
12630
|
+
thread_id: subagent_thread_id,
|
|
12631
|
+
taskId: input.taskId
|
|
11846
12632
|
}
|
|
11847
12633
|
});
|
|
11848
12634
|
const result = workerResult.finalState?.values;
|
|
@@ -11870,18 +12656,21 @@ The result will be delivered as a notification when complete. Do not poll.`,
|
|
|
11870
12656
|
{
|
|
11871
12657
|
name: "task",
|
|
11872
12658
|
description: finalTaskDescription,
|
|
11873
|
-
schema:
|
|
11874
|
-
description:
|
|
11875
|
-
subagent_type:
|
|
12659
|
+
schema: z43.object({
|
|
12660
|
+
description: z43.string().describe("The task to execute with the selected agent"),
|
|
12661
|
+
subagent_type: z43.string().describe(
|
|
11876
12662
|
`Name of the agent to use. Available: ${Object.keys(
|
|
11877
12663
|
subagentGraphs
|
|
11878
12664
|
).join(", ")}`
|
|
11879
12665
|
),
|
|
11880
12666
|
...allowAsync ? {
|
|
11881
|
-
async:
|
|
12667
|
+
async: z43.boolean().default(false).describe(
|
|
11882
12668
|
"When true, runs the task in the background and returns immediately. Use for independent tasks that can run in parallel. The result is delivered as a notification when complete. Use check_async_task or list_async_tasks to monitor progress."
|
|
11883
12669
|
)
|
|
11884
|
-
} : {}
|
|
12670
|
+
} : {},
|
|
12671
|
+
taskId: z43.string().optional().describe(
|
|
12672
|
+
"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."
|
|
12673
|
+
)
|
|
11885
12674
|
})
|
|
11886
12675
|
}
|
|
11887
12676
|
);
|
|
@@ -11897,7 +12686,7 @@ function getMainAgentFromConfig(config) {
|
|
|
11897
12686
|
});
|
|
11898
12687
|
}
|
|
11899
12688
|
function createCheckAsyncTaskTool() {
|
|
11900
|
-
return
|
|
12689
|
+
return tool40(
|
|
11901
12690
|
async (input, config) => {
|
|
11902
12691
|
const { task_id } = input;
|
|
11903
12692
|
const mainAgent = getMainAgentFromConfig(config);
|
|
@@ -11957,14 +12746,14 @@ Description: ${cached.description}`;
|
|
|
11957
12746
|
{
|
|
11958
12747
|
name: "check_async_task",
|
|
11959
12748
|
description: "Get the current status and result of an async background task. Use this to check if a previously launched async task has completed.",
|
|
11960
|
-
schema:
|
|
11961
|
-
task_id:
|
|
12749
|
+
schema: z43.object({
|
|
12750
|
+
task_id: z43.string().describe("The task ID returned when the async task was started")
|
|
11962
12751
|
})
|
|
11963
12752
|
}
|
|
11964
12753
|
);
|
|
11965
12754
|
}
|
|
11966
12755
|
function createListAsyncTasksTool() {
|
|
11967
|
-
return
|
|
12756
|
+
return tool40(
|
|
11968
12757
|
async (_input, config) => {
|
|
11969
12758
|
const mainAgent = getMainAgentFromConfig(config);
|
|
11970
12759
|
if (!mainAgent) {
|
|
@@ -12010,12 +12799,12 @@ function createListAsyncTasksTool() {
|
|
|
12010
12799
|
{
|
|
12011
12800
|
name: "list_async_tasks",
|
|
12012
12801
|
description: "List all async background tasks with their current status. Use this before reporting task status to the user. Statuses in conversation history may be stale.",
|
|
12013
|
-
schema:
|
|
12802
|
+
schema: z43.object({})
|
|
12014
12803
|
}
|
|
12015
12804
|
);
|
|
12016
12805
|
}
|
|
12017
12806
|
function createCancelAsyncTaskTool() {
|
|
12018
|
-
return
|
|
12807
|
+
return tool40(
|
|
12019
12808
|
async (input, config) => {
|
|
12020
12809
|
const { task_id } = input;
|
|
12021
12810
|
const mainAgent = getMainAgentFromConfig(config);
|
|
@@ -12054,8 +12843,8 @@ function createCancelAsyncTaskTool() {
|
|
|
12054
12843
|
{
|
|
12055
12844
|
name: "cancel_async_task",
|
|
12056
12845
|
description: "Cancel a running async background task.",
|
|
12057
|
-
schema:
|
|
12058
|
-
task_id:
|
|
12846
|
+
schema: z43.object({
|
|
12847
|
+
task_id: z43.string().describe("The task ID to cancel")
|
|
12059
12848
|
})
|
|
12060
12849
|
}
|
|
12061
12850
|
);
|
|
@@ -12091,7 +12880,7 @@ function createSubAgentMiddleware(options) {
|
|
|
12091
12880
|
);
|
|
12092
12881
|
}
|
|
12093
12882
|
const effectiveSystemPrompt = allowAsync ? systemPrompt + getAsyncPromptText() : systemPrompt;
|
|
12094
|
-
return
|
|
12883
|
+
return createMiddleware10({
|
|
12095
12884
|
name: "subAgentMiddleware",
|
|
12096
12885
|
tools: allTools,
|
|
12097
12886
|
wrapModelCall: async (request, handler) => {
|
|
@@ -12112,12 +12901,12 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
|
|
|
12112
12901
|
|
|
12113
12902
|
// src/deep_agent_new/middleware/patch_tool_calls.ts
|
|
12114
12903
|
import {
|
|
12115
|
-
createMiddleware as
|
|
12904
|
+
createMiddleware as createMiddleware11,
|
|
12116
12905
|
ToolMessage as ToolMessage4,
|
|
12117
12906
|
AIMessage as AIMessage2
|
|
12118
12907
|
} from "langchain";
|
|
12119
12908
|
function createPatchToolCallsMiddleware() {
|
|
12120
|
-
return
|
|
12909
|
+
return createMiddleware11({
|
|
12121
12910
|
name: "patchToolCallsMiddleware",
|
|
12122
12911
|
beforeAgent: async (state) => {
|
|
12123
12912
|
const messages = state.messages;
|
|
@@ -12158,8 +12947,8 @@ function createPatchToolCallsMiddleware() {
|
|
|
12158
12947
|
}
|
|
12159
12948
|
|
|
12160
12949
|
// src/deep_agent_new/middleware/date.ts
|
|
12161
|
-
import { createMiddleware as
|
|
12162
|
-
import { z as
|
|
12950
|
+
import { createMiddleware as createMiddleware12, tool as tool41 } from "langchain";
|
|
12951
|
+
import { z as z44 } from "zod";
|
|
12163
12952
|
function formatCurrentDate(timezone = "UTC") {
|
|
12164
12953
|
const now = /* @__PURE__ */ new Date();
|
|
12165
12954
|
let validTimezone = timezone;
|
|
@@ -12187,10 +12976,10 @@ function generateDateContext(timezone = "UTC") {
|
|
|
12187
12976
|
function createDateMiddleware(options = {}) {
|
|
12188
12977
|
const timezone = options.timezone || "UTC";
|
|
12189
12978
|
const dateContext = generateDateContext(timezone);
|
|
12190
|
-
return
|
|
12979
|
+
return createMiddleware12({
|
|
12191
12980
|
name: "DateMiddleware",
|
|
12192
12981
|
tools: [
|
|
12193
|
-
|
|
12982
|
+
tool41(
|
|
12194
12983
|
async () => {
|
|
12195
12984
|
const now = /* @__PURE__ */ new Date();
|
|
12196
12985
|
let validTimezone = timezone;
|
|
@@ -12220,7 +13009,7 @@ function createDateMiddleware(options = {}) {
|
|
|
12220
13009
|
{
|
|
12221
13010
|
name: "get_current_date_time",
|
|
12222
13011
|
description: "Get the exact current date and time at the moment of invocation. Use this when the user asks about the current time (e.g., 'what time is it', '\u51E0\u70B9\u4E86', '\u73B0\u5728\u51E0\u70B9'), or when you need to know the precise time for scheduling, deadlines, or time-sensitive operations.",
|
|
12223
|
-
schema:
|
|
13012
|
+
schema: z44.object({})
|
|
12224
13013
|
}
|
|
12225
13014
|
)
|
|
12226
13015
|
],
|
|
@@ -12285,8 +13074,8 @@ var datePlugin = {
|
|
|
12285
13074
|
};
|
|
12286
13075
|
|
|
12287
13076
|
// src/deep_agent_new/middleware/scheduler.ts
|
|
12288
|
-
import { tool as
|
|
12289
|
-
import { z as
|
|
13077
|
+
import { tool as tool42, createMiddleware as createMiddleware13 } from "langchain";
|
|
13078
|
+
import { z as z45 } from "zod";
|
|
12290
13079
|
import { v4 as uuidv43 } from "uuid";
|
|
12291
13080
|
import { ScheduledTaskStatus as ScheduledTaskStatus3, ScheduleExecutionType as ScheduleExecutionType3 } from "@axiom-lattice/protocols";
|
|
12292
13081
|
|
|
@@ -13288,7 +14077,7 @@ var getScheduleLattice = (key4) => scheduleLatticeManager.getScheduleLattice(key
|
|
|
13288
14077
|
// src/deep_agent_new/middleware/scheduler.ts
|
|
13289
14078
|
var SCHEDULE_LATTICE_KEY = "default";
|
|
13290
14079
|
var AGENT_ADD_MESSAGE_TASK_TYPE = "agent.add_message";
|
|
13291
|
-
function
|
|
14080
|
+
function getRunConfig2(config) {
|
|
13292
14081
|
const configurable = config;
|
|
13293
14082
|
return configurable?.configurable?.runConfig ?? {};
|
|
13294
14083
|
}
|
|
@@ -13360,12 +14149,12 @@ function registerAgentAddMessageHandler() {
|
|
|
13360
14149
|
function createSchedulerMiddleware(options = {}) {
|
|
13361
14150
|
const defaultMaxRetries = options.defaultMaxRetries ?? 0;
|
|
13362
14151
|
registerAgentAddMessageHandler();
|
|
13363
|
-
return
|
|
14152
|
+
return createMiddleware13({
|
|
13364
14153
|
name: "SchedulerMiddleware",
|
|
13365
14154
|
tools: [
|
|
13366
|
-
|
|
14155
|
+
tool42(
|
|
13367
14156
|
async (input, config) => {
|
|
13368
|
-
const runConfig =
|
|
14157
|
+
const runConfig = getRunConfig2(config);
|
|
13369
14158
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13370
14159
|
const taskId = uuidv43();
|
|
13371
14160
|
const executeAt = input.executeAt;
|
|
@@ -13391,16 +14180,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13391
14180
|
{
|
|
13392
14181
|
name: "schedule_at",
|
|
13393
14182
|
description: "Schedule a system message for an absolute future timestamp",
|
|
13394
|
-
schema:
|
|
13395
|
-
executeAt:
|
|
13396
|
-
maxRetries:
|
|
13397
|
-
message:
|
|
14183
|
+
schema: z45.object({
|
|
14184
|
+
executeAt: z45.number(),
|
|
14185
|
+
maxRetries: z45.number().int().min(0).optional(),
|
|
14186
|
+
message: z45.string()
|
|
13398
14187
|
})
|
|
13399
14188
|
}
|
|
13400
14189
|
),
|
|
13401
|
-
|
|
14190
|
+
tool42(
|
|
13402
14191
|
async (input, config) => {
|
|
13403
|
-
const runConfig =
|
|
14192
|
+
const runConfig = getRunConfig2(config);
|
|
13404
14193
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13405
14194
|
const taskId = uuidv43();
|
|
13406
14195
|
const executeAt = Date.now() + input.delayMs;
|
|
@@ -13426,16 +14215,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13426
14215
|
{
|
|
13427
14216
|
name: "schedule_after",
|
|
13428
14217
|
description: "Schedule a system message after a relative delay",
|
|
13429
|
-
schema:
|
|
13430
|
-
delayMs:
|
|
13431
|
-
maxRetries:
|
|
13432
|
-
message:
|
|
14218
|
+
schema: z45.object({
|
|
14219
|
+
delayMs: z45.number().positive(),
|
|
14220
|
+
maxRetries: z45.number().int().min(0).optional(),
|
|
14221
|
+
message: z45.string()
|
|
13433
14222
|
})
|
|
13434
14223
|
}
|
|
13435
14224
|
),
|
|
13436
|
-
|
|
14225
|
+
tool42(
|
|
13437
14226
|
async (input, config) => {
|
|
13438
|
-
const runConfig =
|
|
14227
|
+
const runConfig = getRunConfig2(config);
|
|
13439
14228
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13440
14229
|
const taskId = uuidv43();
|
|
13441
14230
|
const success = await scheduleLattice.client.scheduleCron(
|
|
@@ -13468,16 +14257,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13468
14257
|
{
|
|
13469
14258
|
name: "schedule_recurring",
|
|
13470
14259
|
description: "Schedule a recurring system message with a cron expression",
|
|
13471
|
-
schema:
|
|
13472
|
-
cronExpression:
|
|
13473
|
-
maxRuns:
|
|
13474
|
-
expiresAt:
|
|
13475
|
-
maxRetries:
|
|
13476
|
-
message:
|
|
14260
|
+
schema: z45.object({
|
|
14261
|
+
cronExpression: z45.string(),
|
|
14262
|
+
maxRuns: z45.number().int().positive().optional(),
|
|
14263
|
+
expiresAt: z45.number().optional(),
|
|
14264
|
+
maxRetries: z45.number().int().min(0).optional(),
|
|
14265
|
+
message: z45.string()
|
|
13477
14266
|
})
|
|
13478
14267
|
}
|
|
13479
14268
|
),
|
|
13480
|
-
|
|
14269
|
+
tool42(
|
|
13481
14270
|
async (input) => {
|
|
13482
14271
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13483
14272
|
const success = await scheduleLattice.client.cancel(input.taskId);
|
|
@@ -13486,14 +14275,14 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13486
14275
|
{
|
|
13487
14276
|
name: "cancel_scheduled_task",
|
|
13488
14277
|
description: "Cancel a scheduled task by task id",
|
|
13489
|
-
schema:
|
|
13490
|
-
taskId:
|
|
14278
|
+
schema: z45.object({
|
|
14279
|
+
taskId: z45.string()
|
|
13491
14280
|
})
|
|
13492
14281
|
}
|
|
13493
14282
|
),
|
|
13494
|
-
|
|
14283
|
+
tool42(
|
|
13495
14284
|
async (input, config) => {
|
|
13496
|
-
const runConfig =
|
|
14285
|
+
const runConfig = getRunConfig2(config);
|
|
13497
14286
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13498
14287
|
const storage = scheduleLattice.client.getStorage();
|
|
13499
14288
|
if (!storage) {
|
|
@@ -13513,11 +14302,11 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13513
14302
|
{
|
|
13514
14303
|
name: "list_scheduled_tasks",
|
|
13515
14304
|
description: "List scheduled tasks for the current agent context",
|
|
13516
|
-
schema:
|
|
13517
|
-
status:
|
|
13518
|
-
executionType:
|
|
13519
|
-
limit:
|
|
13520
|
-
offset:
|
|
14305
|
+
schema: z45.object({
|
|
14306
|
+
status: z45.enum(["pending", "running", "completed", "failed", "cancelled", "paused"]).optional(),
|
|
14307
|
+
executionType: z45.enum(["once", "cron"]).optional(),
|
|
14308
|
+
limit: z45.number().int().positive().optional(),
|
|
14309
|
+
offset: z45.number().int().min(0).optional()
|
|
13521
14310
|
})
|
|
13522
14311
|
}
|
|
13523
14312
|
)
|
|
@@ -14658,8 +15447,8 @@ var MemoryBackend = class {
|
|
|
14658
15447
|
|
|
14659
15448
|
// src/deep_agent_new/middleware/todos.ts
|
|
14660
15449
|
import { Command as Command4 } from "@langchain/langgraph";
|
|
14661
|
-
import { z as
|
|
14662
|
-
import { createMiddleware as
|
|
15450
|
+
import { z as z46 } from "zod";
|
|
15451
|
+
import { createMiddleware as createMiddleware14, tool as tool43, ToolMessage as ToolMessage5 } from "langchain";
|
|
14663
15452
|
var WRITE_TODOS_DESCRIPTION = `Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
14664
15453
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
14665
15454
|
Only use this tool if you think it will be helpful in staying organized. If the user's request is trivial and takes less than 3 steps, it is better to NOT use this tool and just do the taks directly.
|
|
@@ -14886,14 +15675,14 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
|
|
|
14886
15675
|
## Important To-Do List Usage Notes to Remember
|
|
14887
15676
|
- The \`write_todos\` tool should never be called multiple times in parallel.
|
|
14888
15677
|
- Don't be afraid to revise the To-Do list as you go. New information may reveal new tasks that need to be done, or old tasks that are irrelevant.`;
|
|
14889
|
-
var TodoStatus =
|
|
14890
|
-
var TodoSchema =
|
|
14891
|
-
content:
|
|
15678
|
+
var TodoStatus = z46.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
|
|
15679
|
+
var TodoSchema = z46.object({
|
|
15680
|
+
content: z46.string().describe("Content of the todo item"),
|
|
14892
15681
|
status: TodoStatus
|
|
14893
15682
|
});
|
|
14894
|
-
var stateSchema =
|
|
15683
|
+
var stateSchema = z46.object({ todos: z46.array(TodoSchema).default([]) });
|
|
14895
15684
|
function todoListMiddleware(options) {
|
|
14896
|
-
const writeTodos =
|
|
15685
|
+
const writeTodos = tool43(
|
|
14897
15686
|
({ todos }, config) => {
|
|
14898
15687
|
return new Command4({
|
|
14899
15688
|
update: {
|
|
@@ -14910,12 +15699,12 @@ function todoListMiddleware(options) {
|
|
|
14910
15699
|
{
|
|
14911
15700
|
name: "write_todos",
|
|
14912
15701
|
description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
|
|
14913
|
-
schema:
|
|
14914
|
-
todos:
|
|
15702
|
+
schema: z46.object({
|
|
15703
|
+
todos: z46.array(TodoSchema).describe("List of todo items to update")
|
|
14915
15704
|
})
|
|
14916
15705
|
}
|
|
14917
15706
|
);
|
|
14918
|
-
return
|
|
15707
|
+
return createMiddleware14({
|
|
14919
15708
|
name: "todoListMiddleware",
|
|
14920
15709
|
stateSchema,
|
|
14921
15710
|
tools: [writeTodos],
|
|
@@ -15068,7 +15857,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
15068
15857
|
};
|
|
15069
15858
|
|
|
15070
15859
|
// src/agent_team/agent_team.ts
|
|
15071
|
-
import { z as
|
|
15860
|
+
import { z as z49 } from "zod/v3";
|
|
15072
15861
|
import { createAgent as createAgent5 } from "langchain";
|
|
15073
15862
|
|
|
15074
15863
|
// src/agent_team/types.ts
|
|
@@ -15504,14 +16293,14 @@ var InMemoryMailboxStore = class {
|
|
|
15504
16293
|
};
|
|
15505
16294
|
|
|
15506
16295
|
// src/agent_team/middleware/team.ts
|
|
15507
|
-
import { z as
|
|
15508
|
-
import { createMiddleware as
|
|
16296
|
+
import { z as z48 } from "zod/v3";
|
|
16297
|
+
import { createMiddleware as createMiddleware15, createAgent as createAgent4, tool as tool45, ToolMessage as ToolMessage7 } from "langchain";
|
|
15509
16298
|
import { Command as Command6, getCurrentTaskInput as getCurrentTaskInput3 } from "@langchain/langgraph";
|
|
15510
16299
|
import { v4 as uuidv44 } from "uuid";
|
|
15511
16300
|
|
|
15512
16301
|
// src/agent_team/middleware/teammate_tools.ts
|
|
15513
|
-
import { z as
|
|
15514
|
-
import { tool as
|
|
16302
|
+
import { z as z47 } from "zod/v3";
|
|
16303
|
+
import { tool as tool44, ToolMessage as ToolMessage6 } from "langchain";
|
|
15515
16304
|
import { Command as Command5 } from "@langchain/langgraph";
|
|
15516
16305
|
|
|
15517
16306
|
// src/agent_team/middleware/formatMessages.ts
|
|
@@ -15536,7 +16325,7 @@ ${meta}${body}`;
|
|
|
15536
16325
|
// src/agent_team/middleware/teammate_tools.ts
|
|
15537
16326
|
function createTeammateTools(options) {
|
|
15538
16327
|
const { teamId, agentId, taskListStore, mailboxStore } = options;
|
|
15539
|
-
const claimTaskTool =
|
|
16328
|
+
const claimTaskTool = tool44(
|
|
15540
16329
|
async (input) => {
|
|
15541
16330
|
const task = await taskListStore.claimTaskById(
|
|
15542
16331
|
teamId,
|
|
@@ -15561,12 +16350,12 @@ function createTeammateTools(options) {
|
|
|
15561
16350
|
{
|
|
15562
16351
|
name: "claim_task",
|
|
15563
16352
|
description: "Pick a task to work on by task_id. Use check_tasks first to see all tasks; then call this with the task_id you choose. The task's assignee is set to you and you should focus on that task until you complete_task or fail_task it.",
|
|
15564
|
-
schema:
|
|
15565
|
-
task_id:
|
|
16353
|
+
schema: z47.object({
|
|
16354
|
+
task_id: z47.string().describe("ID of the task to claim (e.g. task-01). Use check_tasks to see IDs.")
|
|
15566
16355
|
})
|
|
15567
16356
|
}
|
|
15568
16357
|
);
|
|
15569
|
-
const completeTaskTool =
|
|
16358
|
+
const completeTaskTool = tool44(
|
|
15570
16359
|
async (input) => {
|
|
15571
16360
|
const task = await taskListStore.completeTask(
|
|
15572
16361
|
teamId,
|
|
@@ -15587,13 +16376,13 @@ function createTeammateTools(options) {
|
|
|
15587
16376
|
{
|
|
15588
16377
|
name: "complete_task",
|
|
15589
16378
|
description: "Mark a claimed task as completed with a result summary. Call this after you have finished working on a task.",
|
|
15590
|
-
schema:
|
|
15591
|
-
task_id:
|
|
15592
|
-
result:
|
|
16379
|
+
schema: z47.object({
|
|
16380
|
+
task_id: z47.string().describe("ID of the task to complete"),
|
|
16381
|
+
result: z47.string().describe("Summary of the task result")
|
|
15593
16382
|
})
|
|
15594
16383
|
}
|
|
15595
16384
|
);
|
|
15596
|
-
const failTaskTool =
|
|
16385
|
+
const failTaskTool = tool44(
|
|
15597
16386
|
async (input) => {
|
|
15598
16387
|
const task = await taskListStore.failTask(
|
|
15599
16388
|
teamId,
|
|
@@ -15614,13 +16403,13 @@ function createTeammateTools(options) {
|
|
|
15614
16403
|
{
|
|
15615
16404
|
name: "fail_task",
|
|
15616
16405
|
description: "Mark a claimed task as failed with an error description. Call this if you cannot complete the task.",
|
|
15617
|
-
schema:
|
|
15618
|
-
task_id:
|
|
15619
|
-
error:
|
|
16406
|
+
schema: z47.object({
|
|
16407
|
+
task_id: z47.string().describe("ID of the task to fail"),
|
|
16408
|
+
error: z47.string().describe("Description of why the task failed")
|
|
15620
16409
|
})
|
|
15621
16410
|
}
|
|
15622
16411
|
);
|
|
15623
|
-
const sendMessageTool =
|
|
16412
|
+
const sendMessageTool = tool44(
|
|
15624
16413
|
async (input) => {
|
|
15625
16414
|
await mailboxStore.sendMessage(
|
|
15626
16415
|
teamId,
|
|
@@ -15634,11 +16423,11 @@ function createTeammateTools(options) {
|
|
|
15634
16423
|
{
|
|
15635
16424
|
name: "send_message",
|
|
15636
16425
|
description: 'Send a message to the team lead or another teammate via the mailbox. Use "team_lead" to message the team lead. Use this to report discoveries, request guidance, or suggest new tasks.',
|
|
15637
|
-
schema:
|
|
15638
|
-
to:
|
|
16426
|
+
schema: z47.object({
|
|
16427
|
+
to: z47.string().describe(
|
|
15639
16428
|
'Recipient agent name (e.g. "team_lead" or a teammate name)'
|
|
15640
16429
|
),
|
|
15641
|
-
content:
|
|
16430
|
+
content: z47.string().describe("Message content")
|
|
15642
16431
|
})
|
|
15643
16432
|
}
|
|
15644
16433
|
);
|
|
@@ -15658,7 +16447,7 @@ function createTeammateTools(options) {
|
|
|
15658
16447
|
read: msg.read
|
|
15659
16448
|
}));
|
|
15660
16449
|
};
|
|
15661
|
-
const readMessagesTool =
|
|
16450
|
+
const readMessagesTool = tool44(
|
|
15662
16451
|
async (input, config) => {
|
|
15663
16452
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
15664
16453
|
for (const msg of msgs2) {
|
|
@@ -15717,10 +16506,10 @@ function createTeammateTools(options) {
|
|
|
15717
16506
|
{
|
|
15718
16507
|
name: "read_messages",
|
|
15719
16508
|
description: "Read unread messages from the mailbox. Returns immediately if messages exist, otherwise waits for up to 3 minutes for new messages.",
|
|
15720
|
-
schema:
|
|
16509
|
+
schema: z47.object({})
|
|
15721
16510
|
}
|
|
15722
16511
|
);
|
|
15723
|
-
const checkTasksTool =
|
|
16512
|
+
const checkTasksTool = tool44(
|
|
15724
16513
|
async () => {
|
|
15725
16514
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
15726
16515
|
return formatTaskSummary(tasks);
|
|
@@ -15728,10 +16517,10 @@ function createTeammateTools(options) {
|
|
|
15728
16517
|
{
|
|
15729
16518
|
name: "check_tasks",
|
|
15730
16519
|
description: "Use this tool to get the current status of all tasks in a team. This is your primary way to monitor task progress.",
|
|
15731
|
-
schema:
|
|
16520
|
+
schema: z47.object({})
|
|
15732
16521
|
}
|
|
15733
16522
|
);
|
|
15734
|
-
const broadcastMessageTool =
|
|
16523
|
+
const broadcastMessageTool = tool44(
|
|
15735
16524
|
async (input) => {
|
|
15736
16525
|
const allAgents = await mailboxStore.getRegisteredAgents(teamId);
|
|
15737
16526
|
const recipients = allAgents.filter((a) => a !== agentId);
|
|
@@ -15750,8 +16539,8 @@ function createTeammateTools(options) {
|
|
|
15750
16539
|
{
|
|
15751
16540
|
name: "broadcast_message",
|
|
15752
16541
|
description: "Send a message to everyone in the team except yourself. Use this to share updates or information with all teammates and the team lead at once.",
|
|
15753
|
-
schema:
|
|
15754
|
-
content:
|
|
16542
|
+
schema: z47.object({
|
|
16543
|
+
content: z47.string().describe("Message content to broadcast to others")
|
|
15755
16544
|
})
|
|
15756
16545
|
}
|
|
15757
16546
|
);
|
|
@@ -15985,7 +16774,7 @@ async function spawnTeammate(options) {
|
|
|
15985
16774
|
function createTeamMiddleware(options) {
|
|
15986
16775
|
const { teamConfig, taskListStore, mailboxStore, tenantId: tenantId2 } = options;
|
|
15987
16776
|
const defaultModel = teamConfig.model ?? "claude-sonnet-4-5-20250929";
|
|
15988
|
-
const createTeamTool =
|
|
16777
|
+
const createTeamTool = tool45(
|
|
15989
16778
|
async (input, config) => {
|
|
15990
16779
|
const state = getCurrentTaskInput3();
|
|
15991
16780
|
if (state?.team?.teamId) {
|
|
@@ -16140,20 +16929,20 @@ After calling create_team, you MUST:
|
|
|
16140
16929
|
2. When messages indicate task changes, call check_tasks to get full task status
|
|
16141
16930
|
3. Continue until all tasks show "completed" or "failed"
|
|
16142
16931
|
4. Do NOT assume tasks are done - always verify with check_tasks`,
|
|
16143
|
-
schema:
|
|
16144
|
-
tasks:
|
|
16145
|
-
|
|
16146
|
-
id:
|
|
16147
|
-
title:
|
|
16148
|
-
description:
|
|
16149
|
-
dependencies:
|
|
16932
|
+
schema: z48.object({
|
|
16933
|
+
tasks: z48.array(
|
|
16934
|
+
z48.object({
|
|
16935
|
+
id: z48.string().describe("Task ID in format task-01, task-02, etc."),
|
|
16936
|
+
title: z48.string().describe("Short task title"),
|
|
16937
|
+
description: z48.string().describe("Detailed task description - what exactly needs to be done"),
|
|
16938
|
+
dependencies: z48.array(z48.string()).optional().default([]).describe('Array of task IDs that must complete before this task (e.g. ["task-01"])')
|
|
16150
16939
|
})
|
|
16151
16940
|
).describe("List of tasks for teammates to work on. Each task needs unique ID (task-01, task-02, etc.)."),
|
|
16152
|
-
teammates:
|
|
16153
|
-
|
|
16154
|
-
name:
|
|
16155
|
-
role:
|
|
16156
|
-
description:
|
|
16941
|
+
teammates: z48.array(
|
|
16942
|
+
z48.object({
|
|
16943
|
+
name: z48.string().describe("Teammate name (must match a pre-configured teammate type)"),
|
|
16944
|
+
role: z48.string().describe("Role category (e.g. researcher, writer, coder, reviewer)"),
|
|
16945
|
+
description: z48.string().describe("What this teammate will focus on - specific instructions for their work")
|
|
16157
16946
|
})
|
|
16158
16947
|
).describe("Teammate agents to create. Each should have a clear role and focus.")
|
|
16159
16948
|
})
|
|
@@ -16164,7 +16953,7 @@ After calling create_team, you MUST:
|
|
|
16164
16953
|
if (state?.team?.teamId) return state.team.teamId;
|
|
16165
16954
|
throw new Error("No team_id provided and no team in state. Call create_team first.");
|
|
16166
16955
|
};
|
|
16167
|
-
const addTasksTool =
|
|
16956
|
+
const addTasksTool = tool45(
|
|
16168
16957
|
async (input, config) => {
|
|
16169
16958
|
const teamId = resolveTeamId();
|
|
16170
16959
|
const created = await taskListStore.addTasks(
|
|
@@ -16216,20 +17005,20 @@ IMPORTANT: Dependencies
|
|
|
16216
17005
|
|
|
16217
17006
|
IMPORTANT: Assigning to a specific teammate
|
|
16218
17007
|
- When you need a particular teammate to do the work, set assignee to that teammate's name (e.g. assignee: "researcher"). They can then claim or see the task as assigned to them.`,
|
|
16219
|
-
schema:
|
|
16220
|
-
tasks:
|
|
16221
|
-
|
|
16222
|
-
id:
|
|
16223
|
-
title:
|
|
16224
|
-
description:
|
|
16225
|
-
assignee:
|
|
16226
|
-
dependencies:
|
|
17008
|
+
schema: z48.object({
|
|
17009
|
+
tasks: z48.array(
|
|
17010
|
+
z48.object({
|
|
17011
|
+
id: z48.string().describe("Task ID in format task-01, task-02, etc. Must be unique."),
|
|
17012
|
+
title: z48.string().describe("Short task title"),
|
|
17013
|
+
description: z48.string().describe("Detailed task description - what needs to be done"),
|
|
17014
|
+
assignee: z48.string().optional().describe("Teammate name to assign this task to (use when you need that person to do the work)"),
|
|
17015
|
+
dependencies: z48.array(z48.string()).optional().default([]).describe("Array of task IDs that must complete before this task")
|
|
16227
17016
|
})
|
|
16228
17017
|
).describe("New tasks to add to the team")
|
|
16229
17018
|
})
|
|
16230
17019
|
}
|
|
16231
17020
|
);
|
|
16232
|
-
const assignTaskTool =
|
|
17021
|
+
const assignTaskTool = tool45(
|
|
16233
17022
|
async (input, config) => {
|
|
16234
17023
|
const teamId = resolveTeamId();
|
|
16235
17024
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16251,13 +17040,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16251
17040
|
{
|
|
16252
17041
|
name: "assign_task",
|
|
16253
17042
|
description: "Assign a task to a specific teammate. Use when you need to reassign work to a different teammate. Omit team_id to use the active team from state.",
|
|
16254
|
-
schema:
|
|
16255
|
-
task_id:
|
|
16256
|
-
assignee:
|
|
17043
|
+
schema: z48.object({
|
|
17044
|
+
task_id: z48.string().describe("Task ID to assign"),
|
|
17045
|
+
assignee: z48.string().describe("Teammate name to assign this task to")
|
|
16257
17046
|
})
|
|
16258
17047
|
}
|
|
16259
17048
|
);
|
|
16260
|
-
const setTaskStatusTool =
|
|
17049
|
+
const setTaskStatusTool = tool45(
|
|
16261
17050
|
async (input, config) => {
|
|
16262
17051
|
const teamId = resolveTeamId();
|
|
16263
17052
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16279,13 +17068,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16279
17068
|
{
|
|
16280
17069
|
name: "set_task_status",
|
|
16281
17070
|
description: "Set a task's status. Use to reopen a task (set to pending), mark as failed, or correct status. Values: pending, claimed, in_progress, completed, failed. Omit team_id to use the active team from state.",
|
|
16282
|
-
schema:
|
|
16283
|
-
task_id:
|
|
16284
|
-
status:
|
|
17071
|
+
schema: z48.object({
|
|
17072
|
+
task_id: z48.string().describe("Task ID to update"),
|
|
17073
|
+
status: z48.enum(["pending", "claimed", "in_progress", "completed", "failed"]).describe("New status for the task")
|
|
16285
17074
|
})
|
|
16286
17075
|
}
|
|
16287
17076
|
);
|
|
16288
|
-
const setTaskDependenciesTool =
|
|
17077
|
+
const setTaskDependenciesTool = tool45(
|
|
16289
17078
|
async (input, config) => {
|
|
16290
17079
|
const teamId = resolveTeamId();
|
|
16291
17080
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16307,13 +17096,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16307
17096
|
{
|
|
16308
17097
|
name: "set_task_dependencies",
|
|
16309
17098
|
description: 'Set which task IDs must complete before this task can be claimed. Pass an array of task IDs (e.g. ["task-01", "task-02"]). Use to fix task order or add/remove dependencies. Omit team_id to use the active team from state.',
|
|
16310
|
-
schema:
|
|
16311
|
-
task_id:
|
|
16312
|
-
dependencies:
|
|
17099
|
+
schema: z48.object({
|
|
17100
|
+
task_id: z48.string().describe("Task ID to update"),
|
|
17101
|
+
dependencies: z48.array(z48.string()).describe("Task IDs that must complete before this task can be claimed")
|
|
16313
17102
|
})
|
|
16314
17103
|
}
|
|
16315
17104
|
);
|
|
16316
|
-
const checkTasksTool =
|
|
17105
|
+
const checkTasksTool = tool45(
|
|
16317
17106
|
async (input, config) => {
|
|
16318
17107
|
const teamId = resolveTeamId();
|
|
16319
17108
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
@@ -16353,12 +17142,12 @@ Task Status Values:
|
|
|
16353
17142
|
- in_progress: Teammate is actively working on this task
|
|
16354
17143
|
- completed: Task finished successfully
|
|
16355
17144
|
- failed: Task encountered an error`,
|
|
16356
|
-
schema:
|
|
16357
|
-
team_id:
|
|
17145
|
+
schema: z48.object({
|
|
17146
|
+
team_id: z48.string().optional().describe("Team ID (omit to use active team)")
|
|
16358
17147
|
})
|
|
16359
17148
|
}
|
|
16360
17149
|
);
|
|
16361
|
-
const sendMessageTool =
|
|
17150
|
+
const sendMessageTool = tool45(
|
|
16362
17151
|
async (input, config) => {
|
|
16363
17152
|
const teamId = resolveTeamId();
|
|
16364
17153
|
await mailboxStore.sendMessage(
|
|
@@ -16377,13 +17166,13 @@ Task Status Values:
|
|
|
16377
17166
|
{
|
|
16378
17167
|
name: "send_message",
|
|
16379
17168
|
description: "Send a message to a specific teammate in the team. Omit team_id to use the active team from state.",
|
|
16380
|
-
schema:
|
|
16381
|
-
to:
|
|
16382
|
-
content:
|
|
17169
|
+
schema: z48.object({
|
|
17170
|
+
to: z48.string().describe("Recipient teammate name"),
|
|
17171
|
+
content: z48.string().describe("Message content")
|
|
16383
17172
|
})
|
|
16384
17173
|
}
|
|
16385
17174
|
);
|
|
16386
|
-
const readMessagesTool =
|
|
17175
|
+
const readMessagesTool = tool45(
|
|
16387
17176
|
async (input, config) => {
|
|
16388
17177
|
const teamId = resolveTeamId();
|
|
16389
17178
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
@@ -16465,12 +17254,12 @@ Task Status Values:
|
|
|
16465
17254
|
{
|
|
16466
17255
|
name: "read_messages",
|
|
16467
17256
|
description: "Read unread messages from teammates. Returns immediately if messages exist, otherwise waits for up to 3 minutes for new messages.",
|
|
16468
|
-
schema:
|
|
16469
|
-
team_id:
|
|
17257
|
+
schema: z48.object({
|
|
17258
|
+
team_id: z48.string().optional().describe("Team ID (omit to use active team)")
|
|
16470
17259
|
})
|
|
16471
17260
|
}
|
|
16472
17261
|
);
|
|
16473
|
-
const disbandTeamTool =
|
|
17262
|
+
const disbandTeamTool = tool45(
|
|
16474
17263
|
async (input, config) => {
|
|
16475
17264
|
const teamId = resolveTeamId();
|
|
16476
17265
|
await mailboxStore.broadcastMessage(
|
|
@@ -16491,7 +17280,7 @@ Task Status Values:
|
|
|
16491
17280
|
description: "Disband a team when all work is done. Before calling: (1) Call check_tasks to verify no tasks are still pending/in_progress; (2) if any are, discuss with the team via read_messages and broadcast_message/send_message whether to continue or stop/cancel them; (3) only after alignment (all tasks completed/failed or explicitly stopped), then call this tool. This will: 1) Send a shutdown message to all teammates, 2) Wait briefly for them to clean up, 3) Clear all tasks and messages. Omit team_id to use the active team from state."
|
|
16492
17281
|
}
|
|
16493
17282
|
);
|
|
16494
|
-
const broadcastMessageTool =
|
|
17283
|
+
const broadcastMessageTool = tool45(
|
|
16495
17284
|
async (input, config) => {
|
|
16496
17285
|
const teamId = resolveTeamId();
|
|
16497
17286
|
await mailboxStore.broadcastMessage(
|
|
@@ -16509,12 +17298,12 @@ Task Status Values:
|
|
|
16509
17298
|
{
|
|
16510
17299
|
name: "broadcast_message",
|
|
16511
17300
|
description: "Send a message to all teammates at once. Use this to communicate with everyone in the team. Omit team_id to use the active team from state.",
|
|
16512
|
-
schema:
|
|
16513
|
-
content:
|
|
17301
|
+
schema: z48.object({
|
|
17302
|
+
content: z48.string().describe("Message content to broadcast to all teammates")
|
|
16514
17303
|
})
|
|
16515
17304
|
}
|
|
16516
17305
|
);
|
|
16517
|
-
return
|
|
17306
|
+
return createMiddleware15({
|
|
16518
17307
|
name: "teamMiddleware",
|
|
16519
17308
|
tools: [
|
|
16520
17309
|
createTeamTool,
|
|
@@ -16542,37 +17331,37 @@ ${TEAM_SYSTEM_PROMPT}` : TEAM_SYSTEM_PROMPT;
|
|
|
16542
17331
|
}
|
|
16543
17332
|
|
|
16544
17333
|
// src/agent_team/agent_team.ts
|
|
16545
|
-
var TeammateInfoSchema =
|
|
16546
|
-
name:
|
|
16547
|
-
role:
|
|
16548
|
-
description:
|
|
17334
|
+
var TeammateInfoSchema = z49.object({
|
|
17335
|
+
name: z49.string().describe("Teammate name"),
|
|
17336
|
+
role: z49.string().describe("Role category (e.g. research, writing, review)"),
|
|
17337
|
+
description: z49.string().describe("What this teammate focuses on")
|
|
16549
17338
|
});
|
|
16550
|
-
var TeamTaskInfoSchema =
|
|
16551
|
-
id:
|
|
16552
|
-
title:
|
|
16553
|
-
description:
|
|
16554
|
-
status:
|
|
17339
|
+
var TeamTaskInfoSchema = z49.object({
|
|
17340
|
+
id: z49.string(),
|
|
17341
|
+
title: z49.string(),
|
|
17342
|
+
description: z49.string(),
|
|
17343
|
+
status: z49.string().optional()
|
|
16555
17344
|
});
|
|
16556
|
-
var MailboxMessageSchema =
|
|
16557
|
-
id:
|
|
16558
|
-
from:
|
|
16559
|
-
to:
|
|
16560
|
-
content:
|
|
16561
|
-
timestamp:
|
|
16562
|
-
type:
|
|
16563
|
-
read:
|
|
17345
|
+
var MailboxMessageSchema = z49.object({
|
|
17346
|
+
id: z49.string().describe("Unique message identifier"),
|
|
17347
|
+
from: z49.string().describe("Sender agent name"),
|
|
17348
|
+
to: z49.string().describe("Recipient agent name"),
|
|
17349
|
+
content: z49.string().describe("Message content"),
|
|
17350
|
+
timestamp: z49.string().describe("ISO timestamp when the message was sent"),
|
|
17351
|
+
type: z49.nativeEnum(MessageType).describe("Message type"),
|
|
17352
|
+
read: z49.boolean().describe("Whether the recipient has read this message")
|
|
16564
17353
|
});
|
|
16565
|
-
var TeamInfoSchema =
|
|
16566
|
-
teamId:
|
|
16567
|
-
teamLeadId:
|
|
16568
|
-
teammates:
|
|
16569
|
-
tasks:
|
|
16570
|
-
createdAt:
|
|
17354
|
+
var TeamInfoSchema = z49.object({
|
|
17355
|
+
teamId: z49.string().describe("Unique team identifier"),
|
|
17356
|
+
teamLeadId: z49.string().default("team_lead").describe("Team lead agent ID"),
|
|
17357
|
+
teammates: z49.array(TeammateInfoSchema).describe("Active teammates in this team"),
|
|
17358
|
+
tasks: z49.array(TeamTaskInfoSchema).optional().describe("Initial tasks snapshot"),
|
|
17359
|
+
createdAt: z49.string().optional().describe("ISO timestamp when team was created")
|
|
16571
17360
|
});
|
|
16572
|
-
var TEAM_STATE_SCHEMA =
|
|
17361
|
+
var TEAM_STATE_SCHEMA = z49.object({
|
|
16573
17362
|
team: TeamInfoSchema.optional().describe("Team info: teamId, teamLeadId, teammates, tasks. Set when create_team succeeds."),
|
|
16574
|
-
tasks:
|
|
16575
|
-
team_mailbox:
|
|
17363
|
+
tasks: z49.array(TeamTaskInfoSchema).optional().describe("Current tasks snapshot from check_tasks. Updated on each check."),
|
|
17364
|
+
team_mailbox: z49.array(MailboxMessageSchema).optional().describe("All team mailbox messages for display")
|
|
16576
17365
|
});
|
|
16577
17366
|
var TEAM_LEAD_BASE_PROMPT = `You are a team lead that coordinates a team of specialized agents. In order to complete the objective that the user asks of you, you will need to:
|
|
16578
17367
|
|
|
@@ -16695,7 +17484,7 @@ import { StateGraph as StateGraph2, MessagesAnnotation } from "@langchain/langgr
|
|
|
16695
17484
|
import { AIMessage as AIMessage3 } from "@langchain/core/messages";
|
|
16696
17485
|
|
|
16697
17486
|
// src/services/a2a-client.ts
|
|
16698
|
-
import { v4 as
|
|
17487
|
+
import { v4 as v43 } from "uuid";
|
|
16699
17488
|
var A2ARemoteError = class extends Error {
|
|
16700
17489
|
constructor(message, statusCode, body) {
|
|
16701
17490
|
super(message);
|
|
@@ -16742,7 +17531,7 @@ var A2ARemoteClient = class {
|
|
|
16742
17531
|
*/
|
|
16743
17532
|
async sendMessage(text) {
|
|
16744
17533
|
await this.resolve();
|
|
16745
|
-
const taskId =
|
|
17534
|
+
const taskId = v43();
|
|
16746
17535
|
const body = JSON.stringify({
|
|
16747
17536
|
jsonrpc: "2.0",
|
|
16748
17537
|
method: "tasks/send",
|
|
@@ -17528,6 +18317,22 @@ async function configureStores(stores, options = {}) {
|
|
|
17528
18317
|
storeLatticeManager.registerLattice("default", t, store);
|
|
17529
18318
|
}
|
|
17530
18319
|
}
|
|
18320
|
+
if (options.discoverPlugins) {
|
|
18321
|
+
const pluginTypes = PluginRegistry.list();
|
|
18322
|
+
for (const pluginType of pluginTypes) {
|
|
18323
|
+
const plugin = PluginRegistry.get(pluginType);
|
|
18324
|
+
if (!plugin?.stores) continue;
|
|
18325
|
+
for (const [storeType, storeOrFactory] of Object.entries(plugin.stores)) {
|
|
18326
|
+
const store = typeof storeOrFactory === "function" ? storeOrFactory() : storeOrFactory;
|
|
18327
|
+
await initAndRegister(store, localDisposables);
|
|
18328
|
+
const t = storeType;
|
|
18329
|
+
if (storeLatticeManager.hasLattice("default", t)) {
|
|
18330
|
+
storeLatticeManager.removeLattice("default", t);
|
|
18331
|
+
}
|
|
18332
|
+
storeLatticeManager.registerLattice("default", t, store);
|
|
18333
|
+
}
|
|
18334
|
+
}
|
|
18335
|
+
}
|
|
17531
18336
|
if (options.autoDisposeStores) {
|
|
17532
18337
|
registerSignalCleanup();
|
|
17533
18338
|
_disposables.push(...localDisposables);
|
|
@@ -17672,7 +18477,7 @@ description: Create new skills, modify and improve existing skills. Use this ski
|
|
|
17672
18477
|
license: MIT
|
|
17673
18478
|
metadata:
|
|
17674
18479
|
category: meta
|
|
17675
|
-
version: "
|
|
18480
|
+
version: "3.0"
|
|
17676
18481
|
---
|
|
17677
18482
|
|
|
17678
18483
|
# Skill Creator
|
|
@@ -17771,6 +18576,160 @@ Instructional content for the agent.
|
|
|
17771
18576
|
|
|
17772
18577
|
---
|
|
17773
18578
|
|
|
18579
|
+
## subSkills: Building the Skill Graph
|
|
18580
|
+
|
|
18581
|
+
\`subSkills\` is how skills reference each other. It forms a graph \u2014
|
|
18582
|
+
visualized in the Skills view as connected nodes.
|
|
18583
|
+
|
|
18584
|
+
### What subSkills Means
|
|
18585
|
+
|
|
18586
|
+
It declares: "this skill is conceptually composed of these sub-skills."
|
|
18587
|
+
It does NOT mean the agent automatically loads them. The agent reads the
|
|
18588
|
+
body and decides what to load next.
|
|
18589
|
+
|
|
18590
|
+
### When to Use subSkills
|
|
18591
|
+
|
|
18592
|
+
**YES \u2014 split into subSkills when another task would independently
|
|
18593
|
+
reference that piece.** The test:
|
|
18594
|
+
|
|
18595
|
+
> "Will a future learning task about a DIFFERENT document type
|
|
18596
|
+
> need to reference this?"
|
|
18597
|
+
|
|
18598
|
+
For example:
|
|
18599
|
+
- \`engine-selection\` \u2192 YES, PO extraction AND invoice extraction both need it
|
|
18600
|
+
- \`sap-bp-validation\` \u2192 YES, multiple tasks validate BP through SAP
|
|
18601
|
+
- \`po-bp-extraction\` \u2192 NO, nobody extracts BP without extracting the whole PO
|
|
18602
|
+
|
|
18603
|
+
**NO \u2014 keep in one file when the steps are a single pipeline that's
|
|
18604
|
+
always used together.** Field extraction, validation, and formatting
|
|
18605
|
+
for one document type belong in one skill file.
|
|
18606
|
+
|
|
18607
|
+
### Examples
|
|
18608
|
+
|
|
18609
|
+
Good (shared skills split out):
|
|
18610
|
+
\`\`\`yaml
|
|
18611
|
+
---
|
|
18612
|
+
name: po-extraction
|
|
18613
|
+
description: Extract BP, items, notes from PO PDFs with SAP validation
|
|
18614
|
+
subSkills:
|
|
18615
|
+
- engine-selection # Shared \u2014 also used by invoice-extraction
|
|
18616
|
+
---
|
|
18617
|
+
# Body describes the full PO extraction flow:
|
|
18618
|
+
# 1. Use [[engine-selection]] to pick best parser
|
|
18619
|
+
# 2. Find BP in document header
|
|
18620
|
+
# 3. Parse items table
|
|
18621
|
+
# ...
|
|
18622
|
+
|
|
18623
|
+
---
|
|
18624
|
+
name: engine-selection
|
|
18625
|
+
description: Choose the best parsing engine based on document type
|
|
18626
|
+
---
|
|
18627
|
+
# Body describes decision logic with confidence scores
|
|
18628
|
+
\`\`\`
|
|
18629
|
+
|
|
18630
|
+
Bad (over-split \u2014 these are never used independently):
|
|
18631
|
+
\`\`\`yaml
|
|
18632
|
+
---
|
|
18633
|
+
name: po-bp-extraction
|
|
18634
|
+
description: Extract BP field from PO
|
|
18635
|
+
subSkills: []
|
|
18636
|
+
---
|
|
18637
|
+
# This is always used with items-extraction and notes-extraction.
|
|
18638
|
+
# They should be one skill: po-extraction
|
|
18639
|
+
\`\`\`
|
|
18640
|
+
|
|
18641
|
+
### Growing the Graph
|
|
18642
|
+
|
|
18643
|
+
Skills are discovered incrementally. When a learning task produces
|
|
18644
|
+
new knowledge:
|
|
18645
|
+
|
|
18646
|
+
1. \`ls /root/.agents/knowledge/\` to see what already exists
|
|
18647
|
+
2. If a reusable piece already exists \u2192 reference it via subSkills
|
|
18648
|
+
3. If a reusable piece doesn't exist \u2192 create it, then reference it
|
|
18649
|
+
4. If it's not reusable \u2192 keep it in the parent skill's body
|
|
18650
|
+
|
|
18651
|
+
The graph grows naturally \u2014 each new learning task adds nodes
|
|
18652
|
+
and edges by creating skills and declaring subSkills.
|
|
18653
|
+
|
|
18654
|
+
---
|
|
18655
|
+
|
|
18656
|
+
## Verifying subSkills Are Correct
|
|
18657
|
+
|
|
18658
|
+
After writing the body, check consistency between frontmatter and content.
|
|
18659
|
+
You MUST run these checks before finalizing the skill.
|
|
18660
|
+
|
|
18661
|
+
### Self-Check Rules
|
|
18662
|
+
|
|
18663
|
+
**For each entry in subSkills:**
|
|
18664
|
+
Find where in the body it's actually referenced. If you can't find it \u2014
|
|
18665
|
+
either the body is missing the reference, or the subSkill shouldn't
|
|
18666
|
+
be there.
|
|
18667
|
+
|
|
18668
|
+
**For each skill referenced in the body:**
|
|
18669
|
+
Check that it appears in subSkills. If the body references a skill
|
|
18670
|
+
but subSkills doesn't list it \u2014 add it.
|
|
18671
|
+
|
|
18672
|
+
### Automated Consistency Check
|
|
18673
|
+
|
|
18674
|
+
Since body references use \`[[skill-name]]\` format, you can verify
|
|
18675
|
+
automatically:
|
|
18676
|
+
|
|
18677
|
+
\`\`\`bash
|
|
18678
|
+
# Extract all skill references from body
|
|
18679
|
+
grep -oE '\\[\\[[^]]+\\]\\]' /root/.agents/skills/{skill-name}/SKILL.md \\
|
|
18680
|
+
| sed 's/\\[\\[//;s/\\]\\]//' | sort -u
|
|
18681
|
+
|
|
18682
|
+
# Then compare with the subSkills list in frontmatter.
|
|
18683
|
+
# Every [[ref]] in body should have a corresponding subSkills entry.
|
|
18684
|
+
# Every subSkills entry should appear as [[ref]] somewhere in body.
|
|
18685
|
+
\`\`\`
|
|
18686
|
+
|
|
18687
|
+
### Quick Checklist Before Writing
|
|
18688
|
+
|
|
18689
|
+
1. List all subSkills in frontmatter
|
|
18690
|
+
2. grep the body for each name using \`[[name]]\` format \u2014 does it appear?
|
|
18691
|
+
3. grep the body for \`[[...]]\` patterns \u2014 are they all in subSkills?
|
|
18692
|
+
4. Mismatches \u2192 fix either the body or the frontmatter
|
|
18693
|
+
5. Remove any subSkills entry that's never referenced in the body
|
|
18694
|
+
|
|
18695
|
+
---
|
|
18696
|
+
|
|
18697
|
+
## Referencing Other Skills in the Body
|
|
18698
|
+
|
|
18699
|
+
When the body instructs the agent to consult another skill,
|
|
18700
|
+
use the \`[[skill-name]]\` format:
|
|
18701
|
+
|
|
18702
|
+
\`\`\`markdown
|
|
18703
|
+
## Procedure
|
|
18704
|
+
|
|
18705
|
+
1. First, use [[engine-selection]] to pick the best parsing engine
|
|
18706
|
+
2. Load [[sap-bp-validation]] to verify the extracted Business Partner
|
|
18707
|
+
3. For edge cases, refer to [[ocr-fallback]]
|
|
18708
|
+
|
|
18709
|
+
## Dependencies
|
|
18710
|
+
|
|
18711
|
+
This skill depends on:
|
|
18712
|
+
- [[engine-selection]] \u2014 chooses the parsing engine
|
|
18713
|
+
- [[sap-bp-validation]] \u2014 validates BP codes against SAP
|
|
18714
|
+
\`\`\`
|
|
18715
|
+
|
|
18716
|
+
### Why [[wiki-links]]
|
|
18717
|
+
|
|
18718
|
+
- **Visually distinct** \u2014 clearly not regular text
|
|
18719
|
+
- **Grepable** \u2014 \`grep -o '\\[\\[.*?\\]\\]'\` extracts all references
|
|
18720
|
+
- **Verifiable** \u2014 the consistency check against subSkills can be automated
|
|
18721
|
+
- **Human-readable** \u2014 anyone reading the SKILL.md knows this is a skill reference
|
|
18722
|
+
|
|
18723
|
+
### Rules
|
|
18724
|
+
- Always use the exact skill name (kebab-case) inside \`[[]]\`
|
|
18725
|
+
- Before writing, check each referenced skill:
|
|
18726
|
+
- If it exists \u2014 reference it directly
|
|
18727
|
+
- If it doesn't exist \u2014 create it first, then reference it in the parent
|
|
18728
|
+
- Every \`[[ref]]\` in the body must have a corresponding \`subSkills\` entry
|
|
18729
|
+
- Every \`subSkills\` entry must appear as \`[[ref]]\` somewhere in the body
|
|
18730
|
+
|
|
18731
|
+
---
|
|
18732
|
+
|
|
17774
18733
|
## Writing Guide
|
|
17775
18734
|
|
|
17776
18735
|
### The Description Field
|
|
@@ -17821,6 +18780,7 @@ A well-written skill body typically includes:
|
|
|
17821
18780
|
- **Guidelines**: Rules, constraints, quality standards, and the WHY behind them
|
|
17822
18781
|
- **Scenarios**: 2-3 common scenarios with concrete examples of inputs and expected outputs
|
|
17823
18782
|
- **Edge cases**: What to do when things go wrong, when data is missing, etc.
|
|
18783
|
+
- **Skill references**: Use \`[[skill-name]]\` to reference other skills \u2014 see the subSkills section above
|
|
17824
18784
|
|
|
17825
18785
|
---
|
|
17826
18786
|
|
|
@@ -17828,10 +18788,11 @@ A well-written skill body typically includes:
|
|
|
17828
18788
|
|
|
17829
18789
|
After writing the draft, test it:
|
|
17830
18790
|
|
|
17831
|
-
1. **
|
|
17832
|
-
2. **
|
|
17833
|
-
3. **
|
|
17834
|
-
4. **
|
|
18791
|
+
1. **Run the consistency check** from the Verifying subSkills section \u2014 fix any mismatches
|
|
18792
|
+
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?"
|
|
18793
|
+
3. **Run the skill** against each test prompt to see what the agent produces
|
|
18794
|
+
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?)
|
|
18795
|
+
5. **Collect feedback**: What worked? What didn't? What surprised the user?
|
|
17835
18796
|
|
|
17836
18797
|
### Improving the Skill
|
|
17837
18798
|
|
|
@@ -17867,10 +18828,11 @@ The agent sees skills as a list of name + description pairs. It decides whether
|
|
|
17867
18828
|
## Step 6: Package and Present
|
|
17868
18829
|
|
|
17869
18830
|
When the skill is ready:
|
|
17870
|
-
1.
|
|
17871
|
-
2.
|
|
17872
|
-
3.
|
|
17873
|
-
4.
|
|
18831
|
+
1. Run the subSkills consistency check one final time
|
|
18832
|
+
2. Verify the SKILL.md is at \`/root/.agents/skills/{skill-name}/SKILL.md\` with correct frontmatter
|
|
18833
|
+
3. Confirm all resource files are in place under \`resources/\`
|
|
18834
|
+
4. Tell the user the skill is ready and available at its path
|
|
18835
|
+
5. Remind them that the skill will now appear in the available skills list for any agent using the skill system
|
|
17874
18836
|
|
|
17875
18837
|
## Updating Existing Skills
|
|
17876
18838
|
|
|
@@ -17879,7 +18841,8 @@ When the user wants to improve an existing skill:
|
|
|
17879
18841
|
2. Understand what it currently does and where it falls short
|
|
17880
18842
|
3. Follow the same interview \u2192 draft \u2192 test \u2192 iterate loop
|
|
17881
18843
|
4. **Preserve the original name** \u2014 the directory name and \`name\` frontmatter field should stay the same
|
|
17882
|
-
5.
|
|
18844
|
+
5. Run the subSkills consistency check after making changes
|
|
18845
|
+
6. Write the updated version back to the same path
|
|
17883
18846
|
|
|
17884
18847
|
---
|
|
17885
18848
|
|
|
@@ -17913,6 +18876,8 @@ metadata:
|
|
|
17913
18876
|
|
|
17914
18877
|
**You** (write): Create \`/root/.agents/skills/csv-analyzer/SKILL.md\`
|
|
17915
18878
|
|
|
18879
|
+
**You** (verify): Run the subSkills consistency check \u2014 no subSkills, no \`[[refs]]\`, all good.
|
|
18880
|
+
|
|
17916
18881
|
**You** (test): "Here are 3 test cases \u2014 'summarize this sales CSV', 'filter rows where region is West', 'show monthly revenue trends'. Let me run these and we'll review."
|
|
17917
18882
|
|
|
17918
18883
|
Then iterate based on what the user says.
|
|
@@ -18972,8 +19937,8 @@ var InMemoryMenuStore = class {
|
|
|
18972
19937
|
};
|
|
18973
19938
|
|
|
18974
19939
|
// src/agent_lattice/agentArchitectTools.ts
|
|
18975
|
-
import
|
|
18976
|
-
import { v4 as
|
|
19940
|
+
import z50 from "zod";
|
|
19941
|
+
import { v4 as v44 } from "uuid";
|
|
18977
19942
|
import { AgentType as AgentType3 } from "@axiom-lattice/protocols";
|
|
18978
19943
|
function getTenantId(exeConfig) {
|
|
18979
19944
|
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
@@ -19002,7 +19967,7 @@ registerToolLattice(
|
|
|
19002
19967
|
{
|
|
19003
19968
|
name: "list_agents",
|
|
19004
19969
|
description: "List all agents for the current workspace. Returns a summary with id, name, description, and type for each agent.",
|
|
19005
|
-
schema:
|
|
19970
|
+
schema: z50.object({})
|
|
19006
19971
|
},
|
|
19007
19972
|
async (_input, exeConfig) => {
|
|
19008
19973
|
try {
|
|
@@ -19029,8 +19994,8 @@ registerToolLattice(
|
|
|
19029
19994
|
{
|
|
19030
19995
|
name: "get_agent",
|
|
19031
19996
|
description: "Get the full configuration of a specific agent by its ID. Returns the complete AgentConfig including prompt, middleware, tools, and sub-agents.",
|
|
19032
|
-
schema:
|
|
19033
|
-
id:
|
|
19997
|
+
schema: z50.object({
|
|
19998
|
+
id: z50.string().describe("The agent ID to retrieve")
|
|
19034
19999
|
})
|
|
19035
20000
|
},
|
|
19036
20001
|
async (input, exeConfig) => {
|
|
@@ -19047,24 +20012,24 @@ registerToolLattice(
|
|
|
19047
20012
|
}
|
|
19048
20013
|
}
|
|
19049
20014
|
);
|
|
19050
|
-
var middlewareConfigSchema =
|
|
19051
|
-
id:
|
|
19052
|
-
type:
|
|
19053
|
-
name:
|
|
19054
|
-
description:
|
|
19055
|
-
enabled:
|
|
19056
|
-
config:
|
|
20015
|
+
var middlewareConfigSchema = z50.object({
|
|
20016
|
+
id: z50.string(),
|
|
20017
|
+
type: z50.string(),
|
|
20018
|
+
name: z50.string(),
|
|
20019
|
+
description: z50.string(),
|
|
20020
|
+
enabled: z50.boolean(),
|
|
20021
|
+
config: z50.record(z50.any()).optional()
|
|
19057
20022
|
});
|
|
19058
|
-
var createAgentSchema =
|
|
19059
|
-
name:
|
|
19060
|
-
description:
|
|
19061
|
-
type:
|
|
19062
|
-
prompt:
|
|
19063
|
-
tools:
|
|
19064
|
-
middleware:
|
|
19065
|
-
subAgents:
|
|
19066
|
-
internalSubAgents:
|
|
19067
|
-
modelKey:
|
|
20023
|
+
var createAgentSchema = z50.object({
|
|
20024
|
+
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')."),
|
|
20025
|
+
description: z50.string().optional().describe("Short description"),
|
|
20026
|
+
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."),
|
|
20027
|
+
prompt: z50.string().describe("System prompt for the agent"),
|
|
20028
|
+
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."),
|
|
20029
|
+
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: {}."),
|
|
20030
|
+
subAgents: z50.array(z50.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
|
|
20031
|
+
internalSubAgents: z50.array(z50.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
|
|
20032
|
+
modelKey: z50.string().optional().describe("Model key to use")
|
|
19068
20033
|
});
|
|
19069
20034
|
registerToolLattice(
|
|
19070
20035
|
"create_agent",
|
|
@@ -19102,14 +20067,14 @@ registerToolLattice(
|
|
|
19102
20067
|
}
|
|
19103
20068
|
}
|
|
19104
20069
|
);
|
|
19105
|
-
var createWorkflowSchema =
|
|
19106
|
-
name:
|
|
19107
|
-
description:
|
|
19108
|
-
skillLoaded:
|
|
19109
|
-
yaml:
|
|
19110
|
-
tools:
|
|
19111
|
-
middleware:
|
|
19112
|
-
modelKey:
|
|
20070
|
+
var createWorkflowSchema = z50.object({
|
|
20071
|
+
name: z50.string().describe("Display name for the workflow agent"),
|
|
20072
|
+
description: z50.string().optional().describe("Short description"),
|
|
20073
|
+
skillLoaded: z50.literal(true).describe("MUST be true. Set after loading the 'create-workflow' skill."),
|
|
20074
|
+
yaml: z50.string().describe("The YAML workflow definition in linear DSL format (steps execute top-to-bottom, use parallel: for concurrency)"),
|
|
20075
|
+
tools: z50.array(z50.string()).optional().describe("Tool keys for the workflow agent"),
|
|
20076
|
+
middleware: z50.array(middlewareConfigSchema).optional().describe("Middleware configs"),
|
|
20077
|
+
modelKey: z50.string().optional().describe("Model key")
|
|
19113
20078
|
});
|
|
19114
20079
|
registerToolLattice(
|
|
19115
20080
|
"create_workflow",
|
|
@@ -19158,8 +20123,8 @@ registerToolLattice(
|
|
|
19158
20123
|
{
|
|
19159
20124
|
name: "validate_workflow",
|
|
19160
20125
|
description: "Validate a workflow agent's DSL for correctness by compiling it.",
|
|
19161
|
-
schema:
|
|
19162
|
-
id:
|
|
20126
|
+
schema: z50.object({
|
|
20127
|
+
id: z50.string().describe("The workflow agent ID to validate")
|
|
19163
20128
|
})
|
|
19164
20129
|
},
|
|
19165
20130
|
async (input, exeConfig) => {
|
|
@@ -19256,14 +20221,14 @@ registerToolLattice(
|
|
|
19256
20221
|
}
|
|
19257
20222
|
}
|
|
19258
20223
|
);
|
|
19259
|
-
var updateWorkflowSchema =
|
|
19260
|
-
id:
|
|
19261
|
-
name:
|
|
19262
|
-
description:
|
|
19263
|
-
yaml:
|
|
19264
|
-
tools:
|
|
19265
|
-
middleware:
|
|
19266
|
-
modelKey:
|
|
20224
|
+
var updateWorkflowSchema = z50.object({
|
|
20225
|
+
id: z50.string().describe("The workflow agent ID to update"),
|
|
20226
|
+
name: z50.string().optional().describe("New display name"),
|
|
20227
|
+
description: z50.string().optional().describe("New description"),
|
|
20228
|
+
yaml: z50.string().optional().describe("Replacement YAML workflow DSL. Omit to keep existing."),
|
|
20229
|
+
tools: z50.array(z50.string()).optional().describe("Replacement tool keys"),
|
|
20230
|
+
middleware: z50.array(middlewareConfigSchema).optional().describe("Replacement middleware configs"),
|
|
20231
|
+
modelKey: z50.string().optional().describe("Replacement model key")
|
|
19267
20232
|
});
|
|
19268
20233
|
registerToolLattice(
|
|
19269
20234
|
"update_workflow",
|
|
@@ -19324,18 +20289,18 @@ registerToolLattice(
|
|
|
19324
20289
|
}
|
|
19325
20290
|
}
|
|
19326
20291
|
);
|
|
19327
|
-
var updateAgentSchema =
|
|
19328
|
-
id:
|
|
19329
|
-
config:
|
|
19330
|
-
name:
|
|
19331
|
-
description:
|
|
19332
|
-
type:
|
|
19333
|
-
prompt:
|
|
19334
|
-
tools:
|
|
19335
|
-
middleware:
|
|
19336
|
-
subAgents:
|
|
19337
|
-
internalSubAgents:
|
|
19338
|
-
modelKey:
|
|
20292
|
+
var updateAgentSchema = z50.object({
|
|
20293
|
+
id: z50.string().describe("The agent ID to update"),
|
|
20294
|
+
config: z50.object({
|
|
20295
|
+
name: z50.string().optional().describe("New display name for the agent"),
|
|
20296
|
+
description: z50.string().optional().describe("New short description"),
|
|
20297
|
+
type: z50.enum(["react", "deep_agent"]).optional().describe("Agent type"),
|
|
20298
|
+
prompt: z50.string().optional().describe("New system prompt for the agent"),
|
|
20299
|
+
tools: z50.array(z50.string()).optional().describe("Tool keys to assign to this agent. These are registered tool names (strings), NOT middleware objects."),
|
|
20300
|
+
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: {}."),
|
|
20301
|
+
subAgents: z50.array(z50.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
|
|
20302
|
+
internalSubAgents: z50.array(z50.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
|
|
20303
|
+
modelKey: z50.string().optional().describe("Model key to use")
|
|
19339
20304
|
}).describe("Configuration fields to update. Only include the fields you want to change.")
|
|
19340
20305
|
});
|
|
19341
20306
|
registerToolLattice(
|
|
@@ -19373,8 +20338,8 @@ registerToolLattice(
|
|
|
19373
20338
|
{
|
|
19374
20339
|
name: "delete_agent",
|
|
19375
20340
|
description: "Permanently delete an agent by its ID. This action cannot be undone.",
|
|
19376
|
-
schema:
|
|
19377
|
-
id:
|
|
20341
|
+
schema: z50.object({
|
|
20342
|
+
id: z50.string().describe("The agent ID to delete")
|
|
19378
20343
|
})
|
|
19379
20344
|
},
|
|
19380
20345
|
async (input, exeConfig) => {
|
|
@@ -19400,7 +20365,7 @@ registerToolLattice(
|
|
|
19400
20365
|
{
|
|
19401
20366
|
name: "list_tools",
|
|
19402
20367
|
description: "List all available tools that can be assigned to agents. Returns each tool's name (use this string value in the 'tools' array), description, and whether it requires user approval. The tool names from this list are what you pass as strings in the 'tools' field of create_agent or update_agent.",
|
|
19403
|
-
schema:
|
|
20368
|
+
schema: z50.object({})
|
|
19404
20369
|
},
|
|
19405
20370
|
async (_input, _exeConfig) => {
|
|
19406
20371
|
try {
|
|
@@ -19422,9 +20387,9 @@ registerToolLattice(
|
|
|
19422
20387
|
{
|
|
19423
20388
|
name: "invoke_agent",
|
|
19424
20389
|
description: "Invoke an agent with a test message and return its response. Use this to verify an agent works correctly after creating or modifying it. The agent must be compiled (already created and valid).",
|
|
19425
|
-
schema:
|
|
19426
|
-
id:
|
|
19427
|
-
message:
|
|
20390
|
+
schema: z50.object({
|
|
20391
|
+
id: z50.string().describe("The agent ID to invoke"),
|
|
20392
|
+
message: z50.string().describe("The test message to send to the agent")
|
|
19428
20393
|
})
|
|
19429
20394
|
},
|
|
19430
20395
|
async (input, exeConfig) => {
|
|
@@ -19439,7 +20404,7 @@ registerToolLattice(
|
|
|
19439
20404
|
if (!existing) {
|
|
19440
20405
|
return JSON.stringify({ error: `Agent '${id}' not found` });
|
|
19441
20406
|
}
|
|
19442
|
-
const threadId =
|
|
20407
|
+
const threadId = v44();
|
|
19443
20408
|
const agent = new Agent({
|
|
19444
20409
|
tenant_id: tenantId2,
|
|
19445
20410
|
assistant_id: id,
|
|
@@ -19460,7 +20425,7 @@ registerToolLattice(
|
|
|
19460
20425
|
{
|
|
19461
20426
|
name: "list_middleware_types",
|
|
19462
20427
|
description: "\u5217\u51FA\u5F53\u524D\u7CFB\u7EDF\u4E2D\u6240\u6709\u53EF\u7528\u7684\u4E2D\u95F4\u4EF6\u7C7B\u578B\uFF08Middlewares\uFF09\uFF0C\u5305\u62EC\u5185\u7F6E\u548C\u81EA\u5B9A\u4E49\u63D2\u4EF6\u3002\u8FD4\u56DE\u6BCF\u4E2A\u4E2D\u95F4\u4EF6\u7684 type\u3001name\u3001description\u3001tools \u6E05\u5355\uFF08\u652F\u6301 allowedTools \u8FC7\u6EE4\uFF09\u3001configSchema\uFF08\u914D\u7F6E\u9762\u677F\u9700\u8981\u54EA\u4E9B\u5B57\u6BB5\uFF09\u548C connectionSchema\uFF08\u662F\u5426\u652F\u6301\u8FDE\u63A5\u6D4B\u8BD5\u548C\u8D44\u6E90\u53D1\u73B0\uFF09\u3002\n\n\u4F7F\u7528\u573A\u666F\uFF1A\n1. \u5728\u521B\u5EFA agent \u524D\uFF0C\u5148\u8C03\u6B64\u5DE5\u5177\u4E86\u89E3\u6709\u54EA\u4E9B\u4E2D\u95F4\u4EF6\u53EF\u914D\u7F6E\n2. \u6839\u636E configSchema \u51B3\u5B9A\u9700\u8981\u63D0\u4F9B\u54EA\u4E9B\u914D\u7F6E\u5B57\u6BB5\uFF08\u5982 databaseKeys\u3001connections \u7B49\uFF09\n3. \u5982\u679C\u67D0\u4E2A\u4E2D\u95F4\u4EF6\u7684 connectionSchema \u5B58\u5728\uFF0C\u8BF4\u660E\u5B83\u662F\u8FDE\u63A5\u578B\u4E2D\u95F4\u4EF6\uFF0C\u9700\u8981\u518D\u8C03 list_connections \u83B7\u53D6\u53EF\u7528\u8FDE\u63A5\n4. \u7528\u8FD4\u56DE\u7684 type \u5B57\u6BB5\u6784\u5EFA middleware \u6570\u7EC4\u4F20\u7ED9 create_agent / update_agent",
|
|
19463
|
-
schema:
|
|
20428
|
+
schema: z50.object({})
|
|
19464
20429
|
},
|
|
19465
20430
|
async () => {
|
|
19466
20431
|
const metas = PluginRegistry.listMeta();
|
|
@@ -19472,8 +20437,8 @@ registerToolLattice(
|
|
|
19472
20437
|
{
|
|
19473
20438
|
name: "list_connections",
|
|
19474
20439
|
description: "\u5217\u51FA\u6307\u5B9A\u63D2\u4EF6\u7C7B\u578B\u7684\u6240\u6709\u5DF2\u914D\u7F6E\u8FDE\u63A5\u3002\u7528\u4E8E\u67E5\u8BE2\u6709\u54EA\u4E9B\u53EF\u7528\u7684\u8FDE\u63A5\u5B9E\u4F8B\uFF08\u5982 'sap-prod', 'sap-dev'\uFF09\uFF0C\u65B9\u4FBF\u5728 agent \u914D\u7F6E\u4E2D\u9009\u62E9\u5177\u4F53\u8FDE\u63A5\u3002\n\n\u4F7F\u7528\u573A\u666F\uFF1A\n1. \u5148\u8C03 list_middleware_types \u786E\u5B9A\u67D0\u4E2A\u4E2D\u95F4\u4EF6\u662F\u8FDE\u63A5\u578B\uFF08\u6709 connectionSchema\uFF09\n2. \u8C03\u6B64\u5DE5\u5177\u4F20\u5165 type\uFF08\u5982 'erp'\uFF09\uFF0C\u83B7\u53D6\u8BE5\u7C7B\u578B\u4E0B\u5DF2\u914D\u597D\u7684\u8FDE\u63A5\u5217\u8868\n3. \u5728 create_agent \u7684 middleware[i].config.connections \u4E2D\u586B\u5165\u5BF9\u5E94\u7684 key \u503C\n\n\u8FD4\u56DE\u683C\u5F0F\uFF1A{ success: true, data: { records: [{ key, name, ... }] } }",
|
|
19475
|
-
schema:
|
|
19476
|
-
type:
|
|
20440
|
+
schema: z50.object({
|
|
20441
|
+
type: z50.string().describe("\u63D2\u4EF6\u7C7B\u578B\u6807\u8BC6\uFF0C\u5982 'erp'\u3002\u4ECE list_middleware_types \u7684\u8FD4\u56DE\u4E2D\u83B7\u53D6")
|
|
19477
20442
|
}),
|
|
19478
20443
|
needUserApprove: false
|
|
19479
20444
|
},
|
|
@@ -20054,6 +21019,20 @@ function ensureBuiltinAgentsForTenant(tenantId2) {
|
|
|
20054
21019
|
}
|
|
20055
21020
|
}
|
|
20056
21021
|
|
|
21022
|
+
// src/agent_lattice/pluginAgents.ts
|
|
21023
|
+
function ensurePluginAgentsForTenant(tenantId2) {
|
|
21024
|
+
const pluginTypes = PluginRegistry.list();
|
|
21025
|
+
for (const pluginType of pluginTypes) {
|
|
21026
|
+
const plugin = PluginRegistry.get(pluginType);
|
|
21027
|
+
if (!plugin?.agents) continue;
|
|
21028
|
+
for (const [key4, config] of Object.entries(plugin.agents)) {
|
|
21029
|
+
if (!agentLatticeManager.hasWithTenant(tenantId2, key4)) {
|
|
21030
|
+
agentLatticeManager.registerLatticeWithTenant(tenantId2, config);
|
|
21031
|
+
}
|
|
21032
|
+
}
|
|
21033
|
+
}
|
|
21034
|
+
}
|
|
21035
|
+
|
|
20057
21036
|
// src/agent_lattice/AgentLatticeManager.ts
|
|
20058
21037
|
function assistantToConfig(assistant) {
|
|
20059
21038
|
const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? { ...assistant.graphDefinition } : {};
|
|
@@ -20252,6 +21231,7 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
20252
21231
|
*/
|
|
20253
21232
|
async initializeStoredAssistantsForTenant(tenantId2) {
|
|
20254
21233
|
ensureBuiltinAgentsForTenant(tenantId2);
|
|
21234
|
+
ensurePluginAgentsForTenant(tenantId2);
|
|
20255
21235
|
try {
|
|
20256
21236
|
const storeLattice = getStoreLattice("default", "assistant");
|
|
20257
21237
|
const assistants = await storeLattice.store.getAllAssistants(tenantId2);
|
|
@@ -23426,8 +24406,8 @@ function clearEvalRunService() {
|
|
|
23426
24406
|
}
|
|
23427
24407
|
|
|
23428
24408
|
// src/eval_lattice/LatticeEval.ts
|
|
23429
|
-
import { HumanMessage as
|
|
23430
|
-
import { v4 as
|
|
24409
|
+
import { HumanMessage as HumanMessage4 } from "@langchain/core/messages";
|
|
24410
|
+
import { v4 as v45 } from "uuid";
|
|
23431
24411
|
var _LatticeEval = class _LatticeEval {
|
|
23432
24412
|
constructor(config = {}) {
|
|
23433
24413
|
this.inMemoryLogs = [];
|
|
@@ -23567,7 +24547,7 @@ var _LatticeEval = class _LatticeEval {
|
|
|
23567
24547
|
}
|
|
23568
24548
|
async evaluateCase(evalCase) {
|
|
23569
24549
|
const startedAt = Date.now();
|
|
23570
|
-
const threadId = `${evalCase.caseId}||${
|
|
24550
|
+
const threadId = `${evalCase.caseId}||${v45()}`;
|
|
23571
24551
|
this.inMemoryLogs = [];
|
|
23572
24552
|
this.lastThreadId = threadId;
|
|
23573
24553
|
this.lastJudgeThreadId = void 0;
|
|
@@ -23709,7 +24689,7 @@ ${rubricsSection}
|
|
|
23709
24689
|
|
|
23710
24690
|
\u6CE8\u610F\uFF1A\u5982\u679C final_score >= 80 \u4E14\u6CA1\u6709\u81F4\u547D\u6027\u9519\u8BEF\uFF0Cpass \u5E94\u4E3A true\uFF1B\u5426\u5219\u4E3A false\u3002`;
|
|
23711
24691
|
this.lastTestPrompt = testPrompt;
|
|
23712
|
-
const judgeThreadId =
|
|
24692
|
+
const judgeThreadId = v45();
|
|
23713
24693
|
this.lastJudgeThreadId = judgeThreadId;
|
|
23714
24694
|
const judgeAgentKey = this.config.judge_agent_key || "LatticeTest";
|
|
23715
24695
|
const judgeTenantId = this.config.tenant_id || "default";
|
|
@@ -23717,7 +24697,7 @@ ${rubricsSection}
|
|
|
23717
24697
|
const judgeAgent = await getAgentClient(judgeTenantId, judgeAgentKey);
|
|
23718
24698
|
const testResponse = await judgeAgent.invoke(
|
|
23719
24699
|
{
|
|
23720
|
-
messages: [new
|
|
24700
|
+
messages: [new HumanMessage4(testPrompt)]
|
|
23721
24701
|
},
|
|
23722
24702
|
{
|
|
23723
24703
|
configurable: {
|
|
@@ -24309,15 +25289,15 @@ function clearEncryptionKeyCache() {
|
|
|
24309
25289
|
}
|
|
24310
25290
|
|
|
24311
25291
|
// src/middlewares/skillMiddleware.ts
|
|
24312
|
-
import { createMiddleware as
|
|
25292
|
+
import { createMiddleware as createMiddleware16 } from "langchain";
|
|
24313
25293
|
|
|
24314
25294
|
// src/tool_lattice/skill/load_skills.ts
|
|
24315
|
-
import z50 from "zod";
|
|
24316
|
-
import { tool as tool45 } from "langchain";
|
|
24317
|
-
|
|
24318
|
-
// src/tool_lattice/skill/load_skill_content.ts
|
|
24319
25295
|
import z51 from "zod";
|
|
24320
25296
|
import { tool as tool46 } from "langchain";
|
|
25297
|
+
|
|
25298
|
+
// src/tool_lattice/skill/load_skill_content.ts
|
|
25299
|
+
import z52 from "zod";
|
|
25300
|
+
import { tool as tool47 } from "langchain";
|
|
24321
25301
|
var LOAD_SKILL_CONTENT_DESCRIPTION = `
|
|
24322
25302
|
Execute a skill within the main conversation
|
|
24323
25303
|
|
|
@@ -24355,7 +25335,7 @@ function getSandboxFromExeConfig(_exe_config) {
|
|
|
24355
25335
|
});
|
|
24356
25336
|
}
|
|
24357
25337
|
var createLoadSkillContentTool = (pluginSkillContents) => {
|
|
24358
|
-
return
|
|
25338
|
+
return tool47(
|
|
24359
25339
|
async (input, _exe_config) => {
|
|
24360
25340
|
try {
|
|
24361
25341
|
if (pluginSkillContents?.[input.skill_name]) {
|
|
@@ -24404,8 +25384,8 @@ var createLoadSkillContentTool = (pluginSkillContents) => {
|
|
|
24404
25384
|
{
|
|
24405
25385
|
name: "skill",
|
|
24406
25386
|
description: LOAD_SKILL_CONTENT_DESCRIPTION,
|
|
24407
|
-
schema:
|
|
24408
|
-
skill_name:
|
|
25387
|
+
schema: z52.object({
|
|
25388
|
+
skill_name: z52.string().describe("The name of the skill to load")
|
|
24409
25389
|
})
|
|
24410
25390
|
}
|
|
24411
25391
|
);
|
|
@@ -24419,7 +25399,7 @@ function createSkillMiddleware(params = {}) {
|
|
|
24419
25399
|
} = params;
|
|
24420
25400
|
const skills = params.skills;
|
|
24421
25401
|
let latestSkills = [];
|
|
24422
|
-
return
|
|
25402
|
+
return createMiddleware16({
|
|
24423
25403
|
name: "skillMiddleware",
|
|
24424
25404
|
contextSchema,
|
|
24425
25405
|
tools: [
|
|
@@ -24551,17 +25531,17 @@ var skillPlugin = {
|
|
|
24551
25531
|
};
|
|
24552
25532
|
|
|
24553
25533
|
// src/middlewares/collectionMiddleware.ts
|
|
24554
|
-
import { createMiddleware as
|
|
25534
|
+
import { createMiddleware as createMiddleware17 } from "langchain";
|
|
24555
25535
|
|
|
24556
25536
|
// src/tool_lattice/collection/list_collections.ts
|
|
24557
|
-
import
|
|
24558
|
-
import { tool as
|
|
25537
|
+
import z53 from "zod";
|
|
25538
|
+
import { tool as tool48 } from "langchain";
|
|
24559
25539
|
var LIST_COLLECTIONS_DESCRIPTION = `List all available collections for the current tenant. Returns collection names, labels, and field definitions (including field types and enum values). Use this tool to discover what collections are available before searching.`;
|
|
24560
25540
|
var createListCollectionsTool = ({
|
|
24561
25541
|
collectionKeys,
|
|
24562
25542
|
connectAll
|
|
24563
25543
|
}) => {
|
|
24564
|
-
return
|
|
25544
|
+
return tool48(
|
|
24565
25545
|
async (_input, _exeConfig) => {
|
|
24566
25546
|
try {
|
|
24567
25547
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24595,23 +25575,23 @@ var createListCollectionsTool = ({
|
|
|
24595
25575
|
{
|
|
24596
25576
|
name: "list_collections",
|
|
24597
25577
|
description: LIST_COLLECTIONS_DESCRIPTION,
|
|
24598
|
-
schema:
|
|
25578
|
+
schema: z53.object({})
|
|
24599
25579
|
}
|
|
24600
25580
|
);
|
|
24601
25581
|
};
|
|
24602
25582
|
|
|
24603
25583
|
// src/tool_lattice/collection/search_collection.ts
|
|
24604
|
-
import
|
|
24605
|
-
import { tool as
|
|
25584
|
+
import z54 from "zod";
|
|
25585
|
+
import { tool as tool49 } from "langchain";
|
|
24606
25586
|
var SEARCH_COLLECTION_DESCRIPTION = `Search for content within a specific collection using semantic (vector) similarity. Use the 'filter' parameter to narrow results by metadata fields (e.g., {"category": "cardiovascular"}). Returns the most relevant content entries with similarity scores.`;
|
|
24607
|
-
var searchSchema =
|
|
24608
|
-
collection:
|
|
24609
|
-
query:
|
|
24610
|
-
filter:
|
|
24611
|
-
top_k:
|
|
25587
|
+
var searchSchema = z54.object({
|
|
25588
|
+
collection: z54.string().describe("The collection name to search in"),
|
|
25589
|
+
query: z54.string().describe("The search query text"),
|
|
25590
|
+
filter: z54.record(z54.unknown()).optional().describe("Metadata filter conditions"),
|
|
25591
|
+
top_k: z54.number().optional().default(5).describe("Number of results to return")
|
|
24612
25592
|
});
|
|
24613
25593
|
var createSearchCollectionTool = () => {
|
|
24614
|
-
return
|
|
25594
|
+
return tool49(
|
|
24615
25595
|
async (input, _exeConfig) => {
|
|
24616
25596
|
try {
|
|
24617
25597
|
const { collection, query, filter: filter2, top_k } = input;
|
|
@@ -24661,10 +25641,10 @@ var createSearchCollectionTool = () => {
|
|
|
24661
25641
|
};
|
|
24662
25642
|
|
|
24663
25643
|
// src/tool_lattice/collection/get_collection.ts
|
|
24664
|
-
import
|
|
24665
|
-
import { tool as
|
|
25644
|
+
import z55 from "zod";
|
|
25645
|
+
import { tool as tool50 } from "langchain";
|
|
24666
25646
|
var GET_COLLECTION_DESCRIPTION = `Get a collection's full definition including its custom fields schema. Use this to discover what metadata fields are available before adding entries.`;
|
|
24667
|
-
var createGetCollectionTool = () =>
|
|
25647
|
+
var createGetCollectionTool = () => tool50(
|
|
24668
25648
|
async (input, _exeConfig) => {
|
|
24669
25649
|
try {
|
|
24670
25650
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24687,24 +25667,24 @@ Embedding: ${c.embeddingKey}${fieldsDesc}`;
|
|
|
24687
25667
|
return `Error: ${error.message}`;
|
|
24688
25668
|
}
|
|
24689
25669
|
},
|
|
24690
|
-
{ name: "get_collection", description: GET_COLLECTION_DESCRIPTION, schema:
|
|
25670
|
+
{ name: "get_collection", description: GET_COLLECTION_DESCRIPTION, schema: z55.object({ name: z55.string().describe("Collection name") }) }
|
|
24691
25671
|
);
|
|
24692
25672
|
|
|
24693
25673
|
// src/tool_lattice/collection/create_collection.ts
|
|
24694
|
-
import
|
|
24695
|
-
import { tool as
|
|
24696
|
-
var createSchema =
|
|
24697
|
-
name:
|
|
24698
|
-
label:
|
|
24699
|
-
embeddingKey:
|
|
24700
|
-
fields:
|
|
24701
|
-
key:
|
|
24702
|
-
type:
|
|
24703
|
-
enumValues:
|
|
24704
|
-
required:
|
|
25674
|
+
import z56 from "zod";
|
|
25675
|
+
import { tool as tool51 } from "langchain";
|
|
25676
|
+
var createSchema = z56.object({
|
|
25677
|
+
name: z56.string().describe("Collection name (lowercase, underscores only)"),
|
|
25678
|
+
label: z56.string().describe("Display name"),
|
|
25679
|
+
embeddingKey: z56.string().describe("Embedding model key"),
|
|
25680
|
+
fields: z56.array(z56.object({
|
|
25681
|
+
key: z56.string().describe("Field key name"),
|
|
25682
|
+
type: z56.enum(["string", "number", "enum"]).describe("Field data type"),
|
|
25683
|
+
enumValues: z56.array(z56.string()).optional().describe("Valid values for enum type"),
|
|
25684
|
+
required: z56.boolean().optional().default(false).describe("Whether field is required")
|
|
24705
25685
|
})).optional().describe("Custom field definitions for entries in this collection")
|
|
24706
25686
|
});
|
|
24707
|
-
var createCreateCollectionTool = () =>
|
|
25687
|
+
var createCreateCollectionTool = () => tool51(
|
|
24708
25688
|
async (input, _exeConfig) => {
|
|
24709
25689
|
try {
|
|
24710
25690
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24729,20 +25709,20 @@ var createCreateCollectionTool = () => tool50(
|
|
|
24729
25709
|
);
|
|
24730
25710
|
|
|
24731
25711
|
// src/tool_lattice/collection/update_collection.ts
|
|
24732
|
-
import
|
|
24733
|
-
import { tool as
|
|
24734
|
-
var schema =
|
|
24735
|
-
name:
|
|
24736
|
-
label:
|
|
24737
|
-
embeddingKey:
|
|
24738
|
-
fields:
|
|
24739
|
-
key:
|
|
24740
|
-
type:
|
|
24741
|
-
enumValues:
|
|
24742
|
-
required:
|
|
25712
|
+
import z57 from "zod";
|
|
25713
|
+
import { tool as tool52 } from "langchain";
|
|
25714
|
+
var schema = z57.object({
|
|
25715
|
+
name: z57.string().describe("Collection name"),
|
|
25716
|
+
label: z57.string().optional().describe("New display name"),
|
|
25717
|
+
embeddingKey: z57.string().optional().describe("New embedding model key"),
|
|
25718
|
+
fields: z57.array(z57.object({
|
|
25719
|
+
key: z57.string().describe("Field key name"),
|
|
25720
|
+
type: z57.enum(["string", "number", "enum"]).describe("Field data type"),
|
|
25721
|
+
enumValues: z57.array(z57.string()).optional().describe("Valid values for enum type"),
|
|
25722
|
+
required: z57.boolean().optional().default(false).describe("Whether field is required")
|
|
24743
25723
|
})).optional().describe("Custom field definitions for entries (replaces existing schema)")
|
|
24744
25724
|
});
|
|
24745
|
-
var createUpdateCollectionTool = () =>
|
|
25725
|
+
var createUpdateCollectionTool = () => tool52(
|
|
24746
25726
|
async (input, _exeConfig) => {
|
|
24747
25727
|
try {
|
|
24748
25728
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24761,9 +25741,9 @@ var createUpdateCollectionTool = () => tool51(
|
|
|
24761
25741
|
);
|
|
24762
25742
|
|
|
24763
25743
|
// src/tool_lattice/collection/delete_collection.ts
|
|
24764
|
-
import
|
|
24765
|
-
import { tool as
|
|
24766
|
-
var createDeleteCollectionTool = () =>
|
|
25744
|
+
import z58 from "zod";
|
|
25745
|
+
import { tool as tool53 } from "langchain";
|
|
25746
|
+
var createDeleteCollectionTool = () => tool53(
|
|
24767
25747
|
async (input, _exeConfig) => {
|
|
24768
25748
|
try {
|
|
24769
25749
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24773,19 +25753,19 @@ var createDeleteCollectionTool = () => tool52(
|
|
|
24773
25753
|
return `Error: ${e.message}`;
|
|
24774
25754
|
}
|
|
24775
25755
|
},
|
|
24776
|
-
{ name: "delete_collection", description: `Delete a collection and all its entries. This cannot be undone.`, schema:
|
|
25756
|
+
{ name: "delete_collection", description: `Delete a collection and all its entries. This cannot be undone.`, schema: z58.object({ name: z58.string().describe("Collection name") }) }
|
|
24777
25757
|
);
|
|
24778
25758
|
|
|
24779
25759
|
// src/tool_lattice/collection/list_entries.ts
|
|
24780
|
-
import
|
|
24781
|
-
import { tool as
|
|
24782
|
-
var schema2 =
|
|
24783
|
-
collection:
|
|
25760
|
+
import z59 from "zod";
|
|
25761
|
+
import { tool as tool54 } from "langchain";
|
|
25762
|
+
var schema2 = z59.object({
|
|
25763
|
+
collection: z59.string().describe("Collection name")
|
|
24784
25764
|
});
|
|
24785
25765
|
function buildKey2(tenantId2, name) {
|
|
24786
25766
|
return `${tenantId2}:${name}`;
|
|
24787
25767
|
}
|
|
24788
|
-
var createListEntriesTool = () =>
|
|
25768
|
+
var createListEntriesTool = () => tool54(
|
|
24789
25769
|
async (input, _exeConfig) => {
|
|
24790
25770
|
try {
|
|
24791
25771
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24812,19 +25792,19 @@ var createListEntriesTool = () => tool53(
|
|
|
24812
25792
|
);
|
|
24813
25793
|
|
|
24814
25794
|
// src/tool_lattice/collection/add_entry.ts
|
|
24815
|
-
import
|
|
24816
|
-
import { tool as
|
|
25795
|
+
import z60 from "zod";
|
|
25796
|
+
import { tool as tool55 } from "langchain";
|
|
24817
25797
|
import { Document } from "@langchain/core/documents";
|
|
24818
25798
|
import { v4 as uuidv45 } from "uuid";
|
|
24819
|
-
var schema3 =
|
|
24820
|
-
collection:
|
|
24821
|
-
content:
|
|
24822
|
-
metadata:
|
|
25799
|
+
var schema3 = z60.object({
|
|
25800
|
+
collection: z60.string().describe("Collection name"),
|
|
25801
|
+
content: z60.string().describe("Entry content text"),
|
|
25802
|
+
metadata: z60.record(z60.unknown()).optional().describe("Metadata fields matching the collection schema")
|
|
24823
25803
|
});
|
|
24824
25804
|
function key(t, n) {
|
|
24825
25805
|
return `${t}:${n}`;
|
|
24826
25806
|
}
|
|
24827
|
-
var createAddEntryTool = () =>
|
|
25807
|
+
var createAddEntryTool = () => tool55(
|
|
24828
25808
|
async (input, _exeConfig) => {
|
|
24829
25809
|
try {
|
|
24830
25810
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24843,18 +25823,18 @@ var createAddEntryTool = () => tool54(
|
|
|
24843
25823
|
);
|
|
24844
25824
|
|
|
24845
25825
|
// src/tool_lattice/collection/update_entry.ts
|
|
24846
|
-
import
|
|
24847
|
-
import { tool as
|
|
24848
|
-
var schema4 =
|
|
24849
|
-
collection:
|
|
24850
|
-
entryId:
|
|
24851
|
-
content:
|
|
24852
|
-
metadata:
|
|
25826
|
+
import z61 from "zod";
|
|
25827
|
+
import { tool as tool56 } from "langchain";
|
|
25828
|
+
var schema4 = z61.object({
|
|
25829
|
+
collection: z61.string().describe("Collection name"),
|
|
25830
|
+
entryId: z61.string().describe("Entry ID to update"),
|
|
25831
|
+
content: z61.string().optional().describe("New content"),
|
|
25832
|
+
metadata: z61.record(z61.unknown()).optional().describe("New metadata")
|
|
24853
25833
|
});
|
|
24854
25834
|
function key2(t, n) {
|
|
24855
25835
|
return `${t}:${n}`;
|
|
24856
25836
|
}
|
|
24857
|
-
var createUpdateEntryTool = () =>
|
|
25837
|
+
var createUpdateEntryTool = () => tool56(
|
|
24858
25838
|
async (input, _exeConfig) => {
|
|
24859
25839
|
try {
|
|
24860
25840
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24873,16 +25853,16 @@ var createUpdateEntryTool = () => tool55(
|
|
|
24873
25853
|
);
|
|
24874
25854
|
|
|
24875
25855
|
// src/tool_lattice/collection/delete_entry.ts
|
|
24876
|
-
import
|
|
24877
|
-
import { tool as
|
|
24878
|
-
var schema5 =
|
|
24879
|
-
collection:
|
|
24880
|
-
entryId:
|
|
25856
|
+
import z62 from "zod";
|
|
25857
|
+
import { tool as tool57 } from "langchain";
|
|
25858
|
+
var schema5 = z62.object({
|
|
25859
|
+
collection: z62.string().describe("Collection name"),
|
|
25860
|
+
entryId: z62.string().describe("Entry ID to delete")
|
|
24881
25861
|
});
|
|
24882
25862
|
function key3(t, n) {
|
|
24883
25863
|
return `${t}:${n}`;
|
|
24884
25864
|
}
|
|
24885
|
-
var createDeleteEntryTool = () =>
|
|
25865
|
+
var createDeleteEntryTool = () => tool57(
|
|
24886
25866
|
async (input, _exeConfig) => {
|
|
24887
25867
|
try {
|
|
24888
25868
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24900,7 +25880,7 @@ var createDeleteEntryTool = () => tool56(
|
|
|
24900
25880
|
function createCollectionMiddleware(params) {
|
|
24901
25881
|
const { collectionKeys, connectAll } = params;
|
|
24902
25882
|
if (!connectAll && (!collectionKeys || collectionKeys.length === 0)) {
|
|
24903
|
-
return
|
|
25883
|
+
return createMiddleware17({
|
|
24904
25884
|
name: "collectionMiddleware",
|
|
24905
25885
|
contextSchema,
|
|
24906
25886
|
tools: [
|
|
@@ -24910,7 +25890,7 @@ function createCollectionMiddleware(params) {
|
|
|
24910
25890
|
});
|
|
24911
25891
|
}
|
|
24912
25892
|
const listToolParams = { collectionKeys, connectAll };
|
|
24913
|
-
return
|
|
25893
|
+
return createMiddleware17({
|
|
24914
25894
|
name: "collectionMiddleware",
|
|
24915
25895
|
contextSchema,
|
|
24916
25896
|
tools: [
|
|
@@ -24971,24 +25951,24 @@ var collectionPlugin = {
|
|
|
24971
25951
|
};
|
|
24972
25952
|
|
|
24973
25953
|
// src/middlewares/askUserClarifyMiddleware.ts
|
|
24974
|
-
import { createMiddleware as
|
|
25954
|
+
import { createMiddleware as createMiddleware18, ToolMessage as ToolMessage8 } from "langchain";
|
|
24975
25955
|
import { GraphInterrupt as GraphInterrupt3, interrupt as interrupt3 } from "@langchain/langgraph";
|
|
24976
25956
|
|
|
24977
25957
|
// src/tool_lattice/ask_user_to_clarify/index.ts
|
|
24978
|
-
import { tool as
|
|
24979
|
-
import
|
|
24980
|
-
var questionSchema =
|
|
24981
|
-
question:
|
|
24982
|
-
options:
|
|
24983
|
-
type:
|
|
24984
|
-
required:
|
|
24985
|
-
allowOther:
|
|
25958
|
+
import { tool as tool58 } from "langchain";
|
|
25959
|
+
import z63 from "zod";
|
|
25960
|
+
var questionSchema = z63.object({
|
|
25961
|
+
question: z63.string().describe("The question text to ask the user"),
|
|
25962
|
+
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."),
|
|
25963
|
+
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."),
|
|
25964
|
+
required: z63.boolean().optional().default(false).describe("Whether this question must be answered"),
|
|
25965
|
+
allowOther: z63.boolean().optional().default(true).describe("Set to true to append an 'Other' checkbox with a free-text input field. Works with 'single' and 'multiple' types. Use for open-ended answers or when the options cannot cover all possibilities. Not applicable for 'input' or 'file_upload' types.")
|
|
24986
25966
|
});
|
|
24987
|
-
var inputSchema =
|
|
24988
|
-
questions:
|
|
25967
|
+
var inputSchema = z63.object({
|
|
25968
|
+
questions: z63.array(questionSchema).min(1, "At least one question is required").describe("A structured sequence of clarification questions. Use these to gather missing parameters or disambiguate user intent before proceeding.")
|
|
24989
25969
|
});
|
|
24990
25970
|
function createAskUserToClarifyTool() {
|
|
24991
|
-
return
|
|
25971
|
+
return tool58(
|
|
24992
25972
|
async (input) => {
|
|
24993
25973
|
return JSON.stringify(input);
|
|
24994
25974
|
},
|
|
@@ -25002,7 +25982,7 @@ function createAskUserToClarifyTool() {
|
|
|
25002
25982
|
|
|
25003
25983
|
// src/middlewares/askUserClarifyMiddleware.ts
|
|
25004
25984
|
function createAskUserClarifyMiddleware() {
|
|
25005
|
-
return
|
|
25985
|
+
return createMiddleware18({
|
|
25006
25986
|
name: "AskUserClarifyMiddleware",
|
|
25007
25987
|
tools: [createAskUserToClarifyTool()],
|
|
25008
25988
|
wrapToolCall: async (request, handler) => {
|
|
@@ -25110,11 +26090,11 @@ var askUserClarifyPlugin = {
|
|
|
25110
26090
|
};
|
|
25111
26091
|
|
|
25112
26092
|
// src/middlewares/widgetMiddleware.ts
|
|
25113
|
-
import { createMiddleware as
|
|
26093
|
+
import { createMiddleware as createMiddleware19 } from "langchain";
|
|
25114
26094
|
|
|
25115
26095
|
// src/tool_lattice/widget/loadGuidelines.ts
|
|
25116
|
-
import { tool as
|
|
25117
|
-
import { z as
|
|
26096
|
+
import { tool as tool59 } from "langchain";
|
|
26097
|
+
import { z as z64 } from "zod";
|
|
25118
26098
|
|
|
25119
26099
|
// src/middlewares/guidelines/index.ts
|
|
25120
26100
|
var CORE = `# Imagine \u2014 Visual Creation Suite
|
|
@@ -25905,13 +26885,13 @@ function getGuidelines(modules) {
|
|
|
25905
26885
|
var AVAILABLE_MODULES = Object.keys(MODULE_SECTIONS);
|
|
25906
26886
|
|
|
25907
26887
|
// src/tool_lattice/widget/loadGuidelines.ts
|
|
25908
|
-
var LoadGuidelinesInputSchema =
|
|
25909
|
-
modules:
|
|
26888
|
+
var LoadGuidelinesInputSchema = z64.object({
|
|
26889
|
+
modules: z64.array(z64.string()).describe(
|
|
25910
26890
|
"Which design modules to load. Choose all that apply. Available modules: [" + AVAILABLE_MODULES.join(",") + "]"
|
|
25911
26891
|
)
|
|
25912
26892
|
});
|
|
25913
26893
|
function createLoadGuidelinesTool() {
|
|
25914
|
-
return
|
|
26894
|
+
return tool59(
|
|
25915
26895
|
async (input) => {
|
|
25916
26896
|
const result = getGuidelines(input.modules);
|
|
25917
26897
|
return result;
|
|
@@ -25925,8 +26905,8 @@ function createLoadGuidelinesTool() {
|
|
|
25925
26905
|
}
|
|
25926
26906
|
|
|
25927
26907
|
// src/tool_lattice/widget/showWidget.ts
|
|
25928
|
-
import { tool as
|
|
25929
|
-
import { z as
|
|
26908
|
+
import { tool as tool60 } from "langchain";
|
|
26909
|
+
import { z as z65 } from "zod";
|
|
25930
26910
|
function containsForbiddenTags(code) {
|
|
25931
26911
|
const forbiddenPatterns = [
|
|
25932
26912
|
/<!DOCTYPE/i,
|
|
@@ -25948,20 +26928,20 @@ function validateWidgetCode(code) {
|
|
|
25948
26928
|
}
|
|
25949
26929
|
return { valid: true };
|
|
25950
26930
|
}
|
|
25951
|
-
var ShowWidgetInputSchema =
|
|
25952
|
-
i_have_seen_guidelines:
|
|
26931
|
+
var ShowWidgetInputSchema = z65.object({
|
|
26932
|
+
i_have_seen_guidelines: z65.boolean().describe(
|
|
25953
26933
|
"Must be true. Confirm you have called load_guidelines first."
|
|
25954
26934
|
),
|
|
25955
|
-
title:
|
|
25956
|
-
loading_messages:
|
|
26935
|
+
title: z65.string().describe("Title displayed above the widget"),
|
|
26936
|
+
loading_messages: z65.array(z65.string()).optional().describe(
|
|
25957
26937
|
"1-4 short strings shown while the widget renders"
|
|
25958
26938
|
),
|
|
25959
|
-
widget_code:
|
|
26939
|
+
widget_code: z65.string().describe(
|
|
25960
26940
|
"HTML fragment to render. Rules: 1. No DOCTYPE, <html>, <head>, or <body> tags. 2. Order: <style> block first, then HTML content, then <script> last. 3. Use only CSS variables for colors (e.g. var(--color-accent)). 4. No gradients, shadows, or blur effects. For SVG: start directly with <svg> tag."
|
|
25961
26941
|
)
|
|
25962
26942
|
});
|
|
25963
26943
|
function createShowWidgetTool() {
|
|
25964
|
-
return
|
|
26944
|
+
return tool60(
|
|
25965
26945
|
async (input) => {
|
|
25966
26946
|
if (!input.i_have_seen_guidelines) {
|
|
25967
26947
|
return "Error: You must call load_guidelines before using show_widget. Set i_have_seen_guidelines to true only after loading guidelines.";
|
|
@@ -25992,7 +26972,7 @@ function createWidgetMiddleware() {
|
|
|
25992
26972
|
createLoadGuidelinesTool(),
|
|
25993
26973
|
createShowWidgetTool()
|
|
25994
26974
|
];
|
|
25995
|
-
return
|
|
26975
|
+
return createMiddleware19({
|
|
25996
26976
|
name: "widgetMiddleware",
|
|
25997
26977
|
contextSchema,
|
|
25998
26978
|
tools
|
|
@@ -26014,153 +26994,6 @@ var widgetPlugin = {
|
|
|
26014
26994
|
middleware: () => createWidgetMiddleware()
|
|
26015
26995
|
};
|
|
26016
26996
|
|
|
26017
|
-
// src/middlewares/taskMiddleware.ts
|
|
26018
|
-
import { createMiddleware as createMiddleware19, tool as tool60 } from "langchain";
|
|
26019
|
-
import { z as z65 } from "zod";
|
|
26020
|
-
function getRunConfig2(config) {
|
|
26021
|
-
const c = config;
|
|
26022
|
-
return c?.configurable?.runConfig ?? {};
|
|
26023
|
-
}
|
|
26024
|
-
function getTaskStore() {
|
|
26025
|
-
return getStoreLattice("default", "task").store;
|
|
26026
|
-
}
|
|
26027
|
-
var manageTaskSchema = z65.object({
|
|
26028
|
-
action: z65.enum(["create", "list", "update", "delete", "complete"]).describe("\u64CD\u4F5C\u7C7B\u578B"),
|
|
26029
|
-
id: z65.string().optional().describe("\u4EFB\u52A1 ID (update/delete/complete \u5FC5\u586B)"),
|
|
26030
|
-
title: z65.string().optional().describe("\u4EFB\u52A1\u6807\u9898 (create \u5FC5\u586B)"),
|
|
26031
|
-
description: z65.string().optional().describe("\u4EFB\u52A1\u63CF\u8FF0"),
|
|
26032
|
-
priority: z65.enum(["low", "medium", "high"]).optional().describe("\u4F18\u5148\u7EA7"),
|
|
26033
|
-
status: z65.enum(["pending", "in_progress", "completed", "cancelled"]).optional().describe("\u72B6\u6001"),
|
|
26034
|
-
dueDate: z65.string().optional().describe("\u622A\u6B62\u65E5\u671F (ISO 8601)"),
|
|
26035
|
-
metadata: z65.record(z65.unknown()).optional().describe("\u7ED3\u6784\u5316\u5143\u6570\u636E (projectId, module \u7B49)"),
|
|
26036
|
-
parentId: z65.string().optional().describe("\u7236\u4EFB\u52A1 ID (\u5B50\u4EFB\u52A1\u5173\u8054)"),
|
|
26037
|
-
sourceId: z65.string().optional().describe("\u6765\u6E90\u4F1A\u8BDD/thread ID"),
|
|
26038
|
-
context: z65.record(z65.unknown()).optional().describe("\u9644\u52A0\u4E0A\u4E0B\u6587"),
|
|
26039
|
-
ownerType: z65.enum(["user", "agent"]).optional().describe("\u6240\u6709\u8005\u7C7B\u578B\uFF0C\u4E0D\u4F20\u9ED8\u8BA4\u4E3A user"),
|
|
26040
|
-
ownerId: z65.string().optional().describe("\u6240\u6709\u8005 ID\uFF0C\u4E0D\u4F20\u81EA\u52A8\u53D6\u5F53\u524D\u7528\u6237/Agent")
|
|
26041
|
-
});
|
|
26042
|
-
function createTaskMiddleware() {
|
|
26043
|
-
return createMiddleware19({
|
|
26044
|
-
name: "TaskMiddleware",
|
|
26045
|
-
contextSchema,
|
|
26046
|
-
wrapModelCall: async (request, handler) => {
|
|
26047
|
-
const taskPrompt = `## \u4EFB\u52A1\u7BA1\u7406\u80FD\u529B
|
|
26048
|
-
\u4F60\u53EF\u4EE5\u901A\u8FC7 manage_task \u5DE5\u5177\u7BA1\u7406\u6301\u4E45\u5316\u4EFB\u52A1\u3002ownerType \u548C ownerId \u7684\u9ED8\u8BA4\u884C\u4E3A\uFF1A
|
|
26049
|
-
- \u4E0D\u4F20\u53C2\u6570: \u9ED8\u8BA4\u4E3A\u5F53\u524D\u7528\u6237\u521B\u5EFA\u4EFB\u52A1 (ownerType="user", ownerId \u81EA\u52A8\u53D6\u5F53\u524D\u7528\u6237)
|
|
26050
|
-
- ownerType="agent": \u4E3A\u81EA\u5DF1\u521B\u5EFA\u6267\u884C\u5B50\u4EFB\u52A1 (ownerId \u81EA\u52A8\u53D6\u5F53\u524D Agent)
|
|
26051
|
-
- \u663E\u5F0F\u4F20 ownerId: \u4E3A\u6307\u5B9A agent/user \u521B\u5EFA\u4EFB\u52A1\uFF08\u62D3\u6251\u573A\u666F\uFF09`;
|
|
26052
|
-
return handler({
|
|
26053
|
-
...request,
|
|
26054
|
-
systemPrompt: taskPrompt + "\n\n" + (request.systemPrompt ?? "")
|
|
26055
|
-
});
|
|
26056
|
-
},
|
|
26057
|
-
tools: [
|
|
26058
|
-
tool60(
|
|
26059
|
-
async (input, config) => {
|
|
26060
|
-
const rc = getRunConfig2(config);
|
|
26061
|
-
const tenantId2 = rc.tenantId || "default";
|
|
26062
|
-
const ownerId = input.ownerId || (input.ownerType === "agent" ? rc.assistant_id : null) || rc.user_id;
|
|
26063
|
-
const store = getTaskStore();
|
|
26064
|
-
switch (input.action) {
|
|
26065
|
-
case "create": {
|
|
26066
|
-
if (!input.title) {
|
|
26067
|
-
return JSON.stringify({ success: false, error: "create requires title" });
|
|
26068
|
-
}
|
|
26069
|
-
const task = await store.create({
|
|
26070
|
-
tenantId: tenantId2,
|
|
26071
|
-
ownerType: input.ownerType || "user",
|
|
26072
|
-
ownerId,
|
|
26073
|
-
title: input.title,
|
|
26074
|
-
description: input.description,
|
|
26075
|
-
priority: input.priority || "medium",
|
|
26076
|
-
status: input.status || "pending",
|
|
26077
|
-
dueDate: input.dueDate,
|
|
26078
|
-
metadata: input.metadata,
|
|
26079
|
-
parentId: input.parentId,
|
|
26080
|
-
sourceId: input.sourceId,
|
|
26081
|
-
context: input.context
|
|
26082
|
-
});
|
|
26083
|
-
return JSON.stringify({ success: true, data: task });
|
|
26084
|
-
}
|
|
26085
|
-
case "list": {
|
|
26086
|
-
const tasks = await store.list({
|
|
26087
|
-
tenantId: tenantId2,
|
|
26088
|
-
ownerType: input.ownerType,
|
|
26089
|
-
ownerId: input.ownerId,
|
|
26090
|
-
status: input.status,
|
|
26091
|
-
priority: input.priority
|
|
26092
|
-
});
|
|
26093
|
-
return JSON.stringify({ success: true, data: tasks, count: tasks.length });
|
|
26094
|
-
}
|
|
26095
|
-
case "update": {
|
|
26096
|
-
if (!input.id) {
|
|
26097
|
-
return JSON.stringify({ success: false, error: "update requires id" });
|
|
26098
|
-
}
|
|
26099
|
-
const { action, ...updates } = input;
|
|
26100
|
-
const updated = await store.update(tenantId2, input.id, updates);
|
|
26101
|
-
if (!updated) {
|
|
26102
|
-
return JSON.stringify({ success: false, error: "Task not found" });
|
|
26103
|
-
}
|
|
26104
|
-
return JSON.stringify({ success: true, data: updated });
|
|
26105
|
-
}
|
|
26106
|
-
case "delete": {
|
|
26107
|
-
if (!input.id) {
|
|
26108
|
-
return JSON.stringify({ success: false, error: "delete requires id" });
|
|
26109
|
-
}
|
|
26110
|
-
const deleted = await store.delete(tenantId2, input.id);
|
|
26111
|
-
return JSON.stringify({ success: deleted, message: deleted ? "Task deleted" : "Task not found" });
|
|
26112
|
-
}
|
|
26113
|
-
case "complete": {
|
|
26114
|
-
if (!input.id) {
|
|
26115
|
-
return JSON.stringify({ success: false, error: "complete requires id" });
|
|
26116
|
-
}
|
|
26117
|
-
const updated = await store.update(tenantId2, input.id, { status: "completed" });
|
|
26118
|
-
if (!updated) {
|
|
26119
|
-
return JSON.stringify({ success: false, error: "Task not found" });
|
|
26120
|
-
}
|
|
26121
|
-
return JSON.stringify({ success: true, data: updated });
|
|
26122
|
-
}
|
|
26123
|
-
default:
|
|
26124
|
-
return JSON.stringify({ success: false, error: `Unknown action: ${input.action}` });
|
|
26125
|
-
}
|
|
26126
|
-
},
|
|
26127
|
-
{
|
|
26128
|
-
name: "manage_task",
|
|
26129
|
-
description: `\u7BA1\u7406\u6301\u4E45\u5316\u4EFB\u52A1\u7CFB\u7EDF\u3002CRUD \u64CD\u4F5C\u7528\u6237\u548C Agent \u7684\u4EFB\u52A1\u3002
|
|
26130
|
-
|
|
26131
|
-
## ownerType \u548C ownerId \u7684\u9ED8\u8BA4\u903B\u8F91
|
|
26132
|
-
- \u4E0D\u4F20 ownerType \u548C ownerId: \u7CFB\u7EDF\u81EA\u52A8\u4E3A\u5F53\u524D\u7528\u6237\u521B\u5EFA\u4EFB\u52A1 (ownerType="user", ownerId \u53D6\u81EA\u5F53\u524D\u767B\u5F55\u7528\u6237)
|
|
26133
|
-
- \u4F20 ownerType="agent" \u4E0D\u4F20 ownerId: \u7CFB\u7EDF\u81EA\u52A8\u4E3A\u5F53\u524D Agent \u521B\u5EFA\u5B50\u4EFB\u52A1
|
|
26134
|
-
- \u663E\u5F0F\u4F20 ownerId: \u7CFB\u7EDF\u4F7F\u7528\u4F60\u6307\u5B9A\u7684 ID\uFF0C\u53EF\u8DE8 Agent \u6D3E\u53D1\u4EFB\u52A1\uFF08\u62D3\u6251\u573A\u666F\uFF09
|
|
26135
|
-
|
|
26136
|
-
## Actions
|
|
26137
|
-
- create: \u521B\u5EFA\u4EFB\u52A1 (title \u5FC5\u586B, priority/description/dueDate/metadata/parentId/context \u53EF\u9009)
|
|
26138
|
-
- list: \u5217\u51FA\u4EFB\u52A1\uFF0C\u53EF\u6309 ownerType/status/priority \u8FC7\u6EE4
|
|
26139
|
-
- update: \u66F4\u65B0\u4EFB\u52A1 (id \u5FC5\u586B\uFF0C\u53EA\u4F20\u8981\u6539\u7684\u5B57\u6BB5)
|
|
26140
|
-
- delete: \u5220\u9664\u4EFB\u52A1 (id \u5FC5\u586B)
|
|
26141
|
-
- complete: \u5FEB\u901F\u6807\u8BB0\u5B8C\u6210 (id \u5FC5\u586B)`,
|
|
26142
|
-
schema: manageTaskSchema
|
|
26143
|
-
}
|
|
26144
|
-
)
|
|
26145
|
-
]
|
|
26146
|
-
});
|
|
26147
|
-
}
|
|
26148
|
-
var taskPlugin = {
|
|
26149
|
-
meta: {
|
|
26150
|
-
type: "task",
|
|
26151
|
-
name: "Task Management",
|
|
26152
|
-
description: "Enables persistent task management with delegation and tracking",
|
|
26153
|
-
configSchema: {
|
|
26154
|
-
type: "object",
|
|
26155
|
-
title: "Task Management Configuration",
|
|
26156
|
-
description: "Zero-configuration task management",
|
|
26157
|
-
properties: {}
|
|
26158
|
-
},
|
|
26159
|
-
defaultConfig: {}
|
|
26160
|
-
},
|
|
26161
|
-
middleware: () => createTaskMiddleware()
|
|
26162
|
-
};
|
|
26163
|
-
|
|
26164
26997
|
// src/middlewares/evalMiddleware.ts
|
|
26165
26998
|
import { createMiddleware as createMiddleware20, tool as tool61 } from "langchain";
|
|
26166
26999
|
import { z as z66 } from "zod";
|
|
@@ -26974,7 +27807,7 @@ export {
|
|
|
26974
27807
|
ExportableEntityRegistry,
|
|
26975
27808
|
FileSystemSkillStore,
|
|
26976
27809
|
FilesystemBackend,
|
|
26977
|
-
|
|
27810
|
+
HumanMessage5 as HumanMessage,
|
|
26978
27811
|
IdRemapper,
|
|
26979
27812
|
InMemoryA2AApiKeyStore,
|
|
26980
27813
|
InMemoryAssistantStore,
|
|
@@ -27023,6 +27856,8 @@ export {
|
|
|
27023
27856
|
QueueMode,
|
|
27024
27857
|
RemoteSandboxInstance,
|
|
27025
27858
|
RemoteSandboxProvider,
|
|
27859
|
+
STTModelLattice,
|
|
27860
|
+
STTModelLatticeManager,
|
|
27026
27861
|
SandboxFilesystem,
|
|
27027
27862
|
SandboxLatticeManager,
|
|
27028
27863
|
SandboxSkillStore,
|
|
@@ -27128,6 +27963,9 @@ export {
|
|
|
27128
27963
|
getNextCronTime,
|
|
27129
27964
|
getOrCreateCollectionVectorStore,
|
|
27130
27965
|
getQueueLattice,
|
|
27966
|
+
getSTTClient,
|
|
27967
|
+
getSTTClientWithTenant,
|
|
27968
|
+
getSTTModelLattice,
|
|
27131
27969
|
getSandBoxManager,
|
|
27132
27970
|
getScheduleLattice,
|
|
27133
27971
|
getStoreLattice,
|
|
@@ -27171,6 +28009,7 @@ export {
|
|
|
27171
28009
|
registerLoggerLattice,
|
|
27172
28010
|
registerModelLattice,
|
|
27173
28011
|
registerQueueLattice,
|
|
28012
|
+
registerSTTModelLattice,
|
|
27174
28013
|
registerSandboxProviderType,
|
|
27175
28014
|
registerScheduleLattice,
|
|
27176
28015
|
registerStoreLattice,
|
|
@@ -27192,6 +28031,7 @@ export {
|
|
|
27192
28031
|
skillLatticeManager,
|
|
27193
28032
|
sqlDatabaseManager,
|
|
27194
28033
|
storeLatticeManager,
|
|
28034
|
+
sttModelLatticeManager,
|
|
27195
28035
|
toJsonSchema,
|
|
27196
28036
|
toSafeStateExpr,
|
|
27197
28037
|
toolLatticeManager,
|