@axiom-lattice/core 2.1.100 → 2.1.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -874,7 +874,7 @@ Output must be valid JSON in exactly this shape. Return ONLY the JSON, no other
874
874
  ${example}`;
875
875
  prompt = prompt + schemaInstruction;
876
876
  }
877
- return { messages: [new import_messages4.HumanMessage(prompt)] };
877
+ return { messages: [new import_messages5.HumanMessage(prompt)] };
878
878
  }
879
879
  function schemaToExample(schema6) {
880
880
  const example = schemaValueToExample(schema6);
@@ -1499,12 +1499,12 @@ function chunk(arr, size) {
1499
1499
  }
1500
1500
  return result;
1501
1501
  }
1502
- var import_langgraph12, import_messages4;
1502
+ var import_langgraph12, import_messages5;
1503
1503
  var init_utils = __esm({
1504
1504
  "src/workflow/utils.ts"() {
1505
1505
  "use strict";
1506
1506
  import_langgraph12 = require("@langchain/langgraph");
1507
- import_messages4 = require("@langchain/core/messages");
1507
+ import_messages5 = require("@langchain/core/messages");
1508
1508
  init_WorkflowAbortRegistry();
1509
1509
  init_parse_yaml();
1510
1510
  }
@@ -1634,7 +1634,7 @@ __export(index_exports, {
1634
1634
  ExportableEntityRegistry: () => ExportableEntityRegistry,
1635
1635
  FileSystemSkillStore: () => FileSystemSkillStore,
1636
1636
  FilesystemBackend: () => FilesystemBackend,
1637
- HumanMessage: () => import_messages6.HumanMessage,
1637
+ HumanMessage: () => import_messages7.HumanMessage,
1638
1638
  IdRemapper: () => IdRemapper,
1639
1639
  InMemoryA2AApiKeyStore: () => InMemoryA2AApiKeyStore,
1640
1640
  InMemoryAssistantStore: () => InMemoryAssistantStore,
@@ -1911,6 +1911,12 @@ var ModelLattice = class extends import_chat_models.BaseChatModel {
1911
1911
  async _generate(messages, options, runManager) {
1912
1912
  return this.llm._generate(messages, options, runManager);
1913
1913
  }
1914
+ /**
1915
+ * Whether the configured model supports vision/image inputs.
1916
+ */
1917
+ get supportsVision() {
1918
+ return this.config.supportsVision || false;
1919
+ }
1914
1920
  /**
1915
1921
  * 将工具绑定到模型
1916
1922
  * @param tools 工具列表
@@ -4479,11 +4485,17 @@ var InMemoryTaskStore = class {
4479
4485
  description: params.description,
4480
4486
  status: params.status || "pending",
4481
4487
  priority: params.priority || "medium",
4488
+ workspaceId: params.workspaceId,
4489
+ projectId: params.projectId,
4482
4490
  dueDate: params.dueDate,
4483
4491
  metadata: params.metadata,
4484
4492
  parentId: params.parentId,
4485
4493
  sourceId: params.sourceId,
4486
4494
  context: params.context,
4495
+ requireReview: params.requireReview ?? false,
4496
+ dependencies: params.dependencies,
4497
+ result: params.result,
4498
+ failureReason: params.failureReason,
4487
4499
  createdAt: now,
4488
4500
  updatedAt: now
4489
4501
  };
@@ -4509,6 +4521,8 @@ var InMemoryTaskStore = class {
4509
4521
  if (filter2.ownerId) results = results.filter((t) => t.ownerId === filter2.ownerId);
4510
4522
  if (filter2.status) results = results.filter((t) => t.status === filter2.status);
4511
4523
  if (filter2.priority) results = results.filter((t) => t.priority === filter2.priority);
4524
+ if (filter2.workspaceId) results = results.filter((t) => t.workspaceId === filter2.workspaceId);
4525
+ if (filter2.projectId) results = results.filter((t) => t.projectId === filter2.projectId);
4512
4526
  if (filter2.parentId) results = results.filter((t) => t.parentId === filter2.parentId);
4513
4527
  if (filter2.sourceId) results = results.filter((t) => t.sourceId === filter2.sourceId);
4514
4528
  if (filter2.metadata) {
@@ -4557,8 +4571,65 @@ var InMemoryTaskStore = class {
4557
4571
  }
4558
4572
  };
4559
4573
 
4560
- // src/store_lattice/InMemoryCollectionStore.ts
4574
+ // src/store_lattice/InMemoryTaskWorkItemStore.ts
4561
4575
  var import_uuid2 = require("uuid");
4576
+ var InMemoryTaskWorkItemStore = class {
4577
+ constructor() {
4578
+ this.store = /* @__PURE__ */ new Map();
4579
+ }
4580
+ /**
4581
+ * Create a new work item
4582
+ */
4583
+ async create(params) {
4584
+ const id = (0, import_uuid2.v4)();
4585
+ const item = {
4586
+ id,
4587
+ taskId: params.taskId,
4588
+ tenantId: params.tenantId,
4589
+ workspaceId: params.workspaceId,
4590
+ projectId: params.projectId,
4591
+ action: params.action,
4592
+ actor: params.actor,
4593
+ threadId: params.threadId,
4594
+ summary: params.summary,
4595
+ detail: params.detail,
4596
+ attempt: params.attempt,
4597
+ createdAt: /* @__PURE__ */ new Date()
4598
+ };
4599
+ if (!this.store.has(params.tenantId)) {
4600
+ this.store.set(params.tenantId, /* @__PURE__ */ new Map());
4601
+ }
4602
+ const tenantStore = this.store.get(params.tenantId);
4603
+ if (!tenantStore.has(params.taskId)) {
4604
+ tenantStore.set(params.taskId, []);
4605
+ }
4606
+ tenantStore.get(params.taskId).push(item);
4607
+ return item;
4608
+ }
4609
+ /**
4610
+ * List work items matching filter criteria
4611
+ */
4612
+ async list(filter2) {
4613
+ const tenantStore = this.store.get(filter2.tenantId);
4614
+ if (!tenantStore) return [];
4615
+ const items = tenantStore.get(filter2.taskId) || [];
4616
+ let result = [...items];
4617
+ if (filter2.action) {
4618
+ result = result.filter((item) => item.action === filter2.action);
4619
+ }
4620
+ result.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
4621
+ if (filter2.offset) {
4622
+ result = result.slice(filter2.offset);
4623
+ }
4624
+ if (filter2.limit) {
4625
+ result = result.slice(0, filter2.limit);
4626
+ }
4627
+ return result;
4628
+ }
4629
+ };
4630
+
4631
+ // src/store_lattice/InMemoryCollectionStore.ts
4632
+ var import_uuid3 = require("uuid");
4562
4633
  var InMemoryCollectionStore = class {
4563
4634
  constructor() {
4564
4635
  this.collections = /* @__PURE__ */ new Map();
@@ -4592,7 +4663,7 @@ var InMemoryCollectionStore = class {
4592
4663
  }
4593
4664
  const now = /* @__PURE__ */ new Date();
4594
4665
  const collection = {
4595
- id: (0, import_uuid2.v4)(),
4666
+ id: (0, import_uuid3.v4)(),
4596
4667
  tenantId: tenantId2,
4597
4668
  name: data.name,
4598
4669
  label: data.label,
@@ -4828,6 +4899,12 @@ storeLatticeManager.registerLattice(
4828
4899
  "task",
4829
4900
  defaultTaskStore
4830
4901
  );
4902
+ var defaultTaskWorkItemStore = new InMemoryTaskWorkItemStore();
4903
+ storeLatticeManager.registerLattice(
4904
+ "default",
4905
+ "taskWorkItem",
4906
+ defaultTaskWorkItemStore
4907
+ );
4831
4908
  var defaultCollectionStore = new InMemoryCollectionStore();
4832
4909
  storeLatticeManager.registerLattice(
4833
4910
  "default",
@@ -8909,7 +8986,7 @@ var createBrowserGetInfoTool = ({ vmIsolation }) => {
8909
8986
  };
8910
8987
 
8911
8988
  // src/index.ts
8912
- var import_messages6 = require("@langchain/core/messages");
8989
+ var import_messages7 = require("@langchain/core/messages");
8913
8990
 
8914
8991
  // src/agent_lattice/types.ts
8915
8992
  var import_protocols = require("@axiom-lattice/protocols");
@@ -9538,6 +9615,72 @@ var StateBackend = class {
9538
9615
  }
9539
9616
  };
9540
9617
 
9618
+ // src/deep_agent_new/backends/imageUtils.ts
9619
+ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
9620
+ ".png",
9621
+ ".jpg",
9622
+ ".jpeg",
9623
+ ".gif",
9624
+ ".webp",
9625
+ ".bmp",
9626
+ ".svg",
9627
+ ".ico",
9628
+ ".tiff",
9629
+ ".tif"
9630
+ ]);
9631
+ var MIME_MAP = {
9632
+ ".png": "image/png",
9633
+ ".jpg": "image/jpeg",
9634
+ ".jpeg": "image/jpeg",
9635
+ ".gif": "image/gif",
9636
+ ".webp": "image/webp",
9637
+ ".bmp": "image/bmp",
9638
+ ".svg": "image/svg+xml",
9639
+ ".ico": "image/x-icon",
9640
+ ".tiff": "image/tiff",
9641
+ ".tif": "image/tiff"
9642
+ };
9643
+ function isImageFile(filePath) {
9644
+ const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
9645
+ return IMAGE_EXTENSIONS.has(ext);
9646
+ }
9647
+ function detectMimeType(filePath) {
9648
+ const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
9649
+ return MIME_MAP[ext] || "application/octet-stream";
9650
+ }
9651
+ var MAX_IMAGE_SIZE = 50 * 1024 * 1024;
9652
+ function validateImageSize(sizeBytes) {
9653
+ if (sizeBytes > MAX_IMAGE_SIZE) {
9654
+ return `Image too large (${(sizeBytes / 1024 / 1024).toFixed(1)}MB). Maximum is 50MB.`;
9655
+ }
9656
+ return null;
9657
+ }
9658
+
9659
+ // src/deep_agent_new/backends/describeImage.ts
9660
+ var import_messages = require("@langchain/core/messages");
9661
+ async function describeImage(options) {
9662
+ const { modelKey, mimeType, base64, prompt } = options;
9663
+ const { client } = modelLatticeManager.getModelLattice(modelKey);
9664
+ if (!client.supportsVision) {
9665
+ throw new Error(`Model "${modelKey}" does not support vision.`);
9666
+ }
9667
+ const result = await client.invoke([
9668
+ new import_messages.HumanMessage({
9669
+ content: [
9670
+ {
9671
+ type: "text",
9672
+ text: prompt || "Please describe this image in detail."
9673
+ },
9674
+ {
9675
+ type: "image_url",
9676
+ image_url: { url: `data:${mimeType};base64,${base64}` }
9677
+ }
9678
+ ]
9679
+ })
9680
+ ]);
9681
+ return result.content || "";
9682
+ }
9683
+
9541
9684
  // src/deep_agent_new/middleware/fs.ts
9542
9685
  var FileDataSchema = import_v3.z.object({
9543
9686
  content: import_v3.z.array(import_v3.z.string()),
@@ -9596,7 +9739,7 @@ Path conventions:
9596
9739
  - glob: find files matching a pattern (e.g., "/project/**/*.py")
9597
9740
  - grep: search for text within files`;
9598
9741
  var LS_TOOL_DESCRIPTION = "List files and directories in a directory";
9599
- var READ_FILE_TOOL_DESCRIPTION = "Read the contents of a file";
9742
+ var READ_FILE_TOOL_DESCRIPTION = "Read the contents of a file. For image files (png, jpg, gif, webp, bmp, svg), returns a visual description when the current model supports vision. For unsupported models, returns an error suggesting to switch to a vision-capable model.";
9600
9743
  var WRITE_FILE_TOOL_DESCRIPTION = "Write content to a new file. Returns an error if the file already exists";
9601
9744
  var EDIT_FILE_TOOL_DESCRIPTION = "Edit a file by replacing a specific string with a new string";
9602
9745
  var GLOB_TOOL_DESCRIPTION = "Find files matching a glob pattern (e.g., '**/*.py' for all Python files)";
@@ -9649,6 +9792,38 @@ function createReadFileTool(backend, options) {
9649
9792
  };
9650
9793
  const resolvedBackend = await getBackend(backend, stateAndStore);
9651
9794
  const { file_path, offset = 0, limit = 2e3 } = input;
9795
+ if (isImageFile(file_path)) {
9796
+ const modelKey = runConfig?.modelConfig?.modelKey || "default";
9797
+ const { client } = modelLatticeManager.getModelLattice(modelKey);
9798
+ if (!client.supportsVision) {
9799
+ return `[\u56FE\u7247] ${file_path}
9800
+ \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`;
9801
+ }
9802
+ if (!resolvedBackend.readBinary) {
9803
+ return `[\u56FE\u7247] ${file_path}
9804
+ \u5F53\u524D\u540E\u7AEF\u4E0D\u652F\u6301\u4E8C\u8FDB\u5236\u8BFB\u53D6\uFF0C\u65E0\u6CD5\u5904\u7406\u56FE\u7247\u3002`;
9805
+ }
9806
+ try {
9807
+ const buffer2 = await resolvedBackend.readBinary(file_path);
9808
+ const sizeWarning = validateImageSize(buffer2.length);
9809
+ if (sizeWarning) {
9810
+ return `[\u56FE\u7247] ${file_path}
9811
+ ${sizeWarning}`;
9812
+ }
9813
+ const mimeType = detectMimeType(file_path);
9814
+ const description = await describeImage({
9815
+ modelKey,
9816
+ mimeType,
9817
+ base64: buffer2.toString("base64")
9818
+ });
9819
+ return `[\u56FE\u7247] ${file_path}\uFF08${mimeType}\uFF0C${(buffer2.length / 1024).toFixed(1)}KB\uFF09
9820
+
9821
+ ${description}`;
9822
+ } catch (error) {
9823
+ return `[\u56FE\u7247] ${file_path}
9824
+ \u8BFB\u53D6\u56FE\u7247\u5931\u8D25\uFF1A${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`;
9825
+ }
9826
+ }
9652
9827
  return await resolvedBackend.read(file_path, offset, limit);
9653
9828
  },
9654
9829
  {
@@ -10697,7 +10872,7 @@ var clawPlugin = {
10697
10872
 
10698
10873
  // src/middlewares/unknownToolHandlerMiddleware.ts
10699
10874
  var import_langchain44 = require("langchain");
10700
- var import_messages = require("@langchain/core/messages");
10875
+ var import_messages2 = require("@langchain/core/messages");
10701
10876
  function createUnknownToolHandlerMiddleware(config = {}) {
10702
10877
  const {
10703
10878
  strategy = "error",
@@ -10747,7 +10922,7 @@ Please select a valid tool from the list above.`
10747
10922
  toolCallId: toolCall.id,
10748
10923
  errorMessage: errorMessageTemplate(toolCall.name, availableToolNames)
10749
10924
  }));
10750
- const modifiedResponse = new import_messages.AIMessage({
10925
+ const modifiedResponse = new import_messages2.AIMessage({
10751
10926
  content: aiResponse.content,
10752
10927
  tool_calls: aiResponse.tool_calls,
10753
10928
  // Key: preserve all tool_calls, don't delete unknown
@@ -10778,7 +10953,7 @@ Please select a valid tool from the list above.`
10778
10953
  return;
10779
10954
  }
10780
10955
  const lastMessage = messages[messages.length - 1];
10781
- if (!import_messages.AIMessage.isInstance(lastMessage)) {
10956
+ if (!import_messages2.AIMessage.isInstance(lastMessage)) {
10782
10957
  return;
10783
10958
  }
10784
10959
  const unknownToolErrors = lastMessage.response_metadata?._unknownToolErrors;
@@ -10786,7 +10961,7 @@ Please select a valid tool from the list above.`
10786
10961
  return;
10787
10962
  }
10788
10963
  const errorToolMessages = unknownToolErrors.map(
10789
- (error) => new import_messages.ToolMessage({
10964
+ (error) => new import_messages2.ToolMessage({
10790
10965
  content: error.errorMessage,
10791
10966
  name: error.toolName,
10792
10967
  tool_call_id: error.toolCallId,
@@ -11242,19 +11417,13 @@ var SandboxFilesystem = class {
11242
11417
  throw new Error(`Error reading file '${filePath}': ${e.message}`);
11243
11418
  }
11244
11419
  }
11420
+ async readBinary(filePath) {
11421
+ return this.sandbox.file.downloadFile({ file: filePath });
11422
+ }
11245
11423
  async write(filePath, content) {
11246
11424
  try {
11247
11425
  await this.sandbox.file.writeFile(filePath, content);
11248
- return {
11249
- path: filePath,
11250
- filesUpdate: {
11251
- [filePath]: {
11252
- content: content.split("\n"),
11253
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
11254
- modified_at: (/* @__PURE__ */ new Date()).toISOString()
11255
- }
11256
- }
11257
- };
11426
+ return { path: filePath, filesUpdate: null };
11258
11427
  } catch (e) {
11259
11428
  throw new Error(`Error writing file '${filePath}': ${e.message}`);
11260
11429
  }
@@ -11268,10 +11437,7 @@ var SandboxFilesystem = class {
11268
11437
  new_str: newString,
11269
11438
  replace_mode: replaceAll ? "ALL" : "FIRST"
11270
11439
  });
11271
- return {
11272
- path: filePath,
11273
- filesUpdate: null
11274
- };
11440
+ return { path: filePath, filesUpdate: null };
11275
11441
  } catch (e) {
11276
11442
  throw new Error(`Error editing file '${filePath}': ${e.message}`);
11277
11443
  }
@@ -11368,13 +11534,13 @@ var ReActAgentGraphBuilder = class {
11368
11534
  };
11369
11535
 
11370
11536
  // src/deep_agent_new/agent.ts
11371
- var import_langchain52 = require("langchain");
11537
+ var import_langchain53 = require("langchain");
11372
11538
 
11373
11539
  // src/deep_agent_new/middleware/subagents.ts
11374
11540
  var import_v32 = require("zod/v3");
11375
- var import_langchain47 = require("langchain");
11541
+ var import_langchain48 = require("langchain");
11376
11542
  var import_langgraph7 = require("@langchain/langgraph");
11377
- var import_messages2 = require("@langchain/core/messages");
11543
+ var import_messages3 = require("@langchain/core/messages");
11378
11544
 
11379
11545
  // src/agent_worker/agent_worker_graph.ts
11380
11546
  var import_langgraph5 = require("@langchain/langgraph");
@@ -12101,7 +12267,7 @@ var buffer = new InMemoryChunkBuffer({
12101
12267
  registerChunkBuffer("default", buffer);
12102
12268
 
12103
12269
  // src/services/Agent.ts
12104
- var import_uuid3 = require("uuid");
12270
+ var import_uuid4 = require("uuid");
12105
12271
  var ThreadStatus2 = /* @__PURE__ */ ((ThreadStatus3) => {
12106
12272
  ThreadStatus3["IDLE"] = "idle";
12107
12273
  ThreadStatus3["BUSY"] = "busy";
@@ -12147,7 +12313,7 @@ var Agent = class {
12147
12313
  runConfig
12148
12314
  },
12149
12315
  configurable: {
12150
- run_id: (0, import_uuid3.v4)(),
12316
+ run_id: (0, import_uuid4.v4)(),
12151
12317
  ...runConfig,
12152
12318
  runConfig
12153
12319
  },
@@ -12220,7 +12386,7 @@ var Agent = class {
12220
12386
  runConfig
12221
12387
  },
12222
12388
  configurable: {
12223
- run_id: (0, import_uuid3.v4)(),
12389
+ run_id: (0, import_uuid4.v4)(),
12224
12390
  ...runConfig,
12225
12391
  runConfig
12226
12392
  // Inject runConfig for tools to access
@@ -12606,7 +12772,7 @@ var Agent = class {
12606
12772
  };
12607
12773
  }
12608
12774
  async invoke(queueMessage, signal) {
12609
- const messageId = (0, import_uuid3.v4)();
12775
+ const messageId = (0, import_uuid4.v4)();
12610
12776
  const input = {
12611
12777
  ...queueMessage.input,
12612
12778
  messages: [new import_langchain46.HumanMessage({ id: messageId, content: queueMessage.input.message })]
@@ -12625,7 +12791,7 @@ var Agent = class {
12625
12791
  * to avoid exposing internal annotation data.
12626
12792
  */
12627
12793
  async invokeWithState(queueMessage, signal) {
12628
- const messageId = (0, import_uuid3.v4)();
12794
+ const messageId = (0, import_uuid4.v4)();
12629
12795
  const input = {
12630
12796
  ...queueMessage.input,
12631
12797
  messages: [new import_langchain46.HumanMessage({ id: messageId, content: queueMessage.input.message })]
@@ -12641,7 +12807,7 @@ var Agent = class {
12641
12807
  {
12642
12808
  context: { runConfig },
12643
12809
  configurable: {
12644
- run_id: (0, import_uuid3.v4)(),
12810
+ run_id: (0, import_uuid4.v4)(),
12645
12811
  ...runConfig,
12646
12812
  runConfig
12647
12813
  },
@@ -12817,7 +12983,7 @@ var Agent = class {
12817
12983
  */
12818
12984
  async addMessage(queueMessage, mode) {
12819
12985
  const useMode = mode ?? this.queueMode.mode;
12820
- const messageId = queueMessage.input.id || (0, import_uuid3.v4)();
12986
+ const messageId = queueMessage.input.id || (0, import_uuid4.v4)();
12821
12987
  const messages = queueMessage.input.messages;
12822
12988
  const legacyMessage = queueMessage.input.message;
12823
12989
  if (!messages && !legacyMessage) {
@@ -13309,6 +13475,348 @@ var AgentInstanceManager = class _AgentInstanceManager {
13309
13475
  };
13310
13476
  var agentInstanceManager = AgentInstanceManager.getInstance();
13311
13477
 
13478
+ // src/middlewares/taskMiddleware.ts
13479
+ var import_langchain47 = require("langchain");
13480
+ var import_zod44 = require("zod");
13481
+ function getRunConfig(config) {
13482
+ const c = config;
13483
+ return c?.configurable?.runConfig ?? {};
13484
+ }
13485
+ function getTaskStore() {
13486
+ return getStoreLattice("default", "task").store;
13487
+ }
13488
+ var VALID_TRANSITIONS = {
13489
+ pending: ["in_progress", "cancelled"],
13490
+ in_progress: ["completed", "review", "failed", "interrupted", "cancelled"],
13491
+ review: ["completed", "in_progress", "cancelled"],
13492
+ failed: ["in_progress", "cancelled"],
13493
+ interrupted: ["in_progress", "cancelled"],
13494
+ completed: [],
13495
+ cancelled: []
13496
+ };
13497
+ function isValidTransition(from, to) {
13498
+ const allowed = VALID_TRANSITIONS[from];
13499
+ if (!allowed) return false;
13500
+ return allowed.includes(to);
13501
+ }
13502
+ function getTaskWorkItemStore() {
13503
+ return getStoreLattice("default", "taskWorkItem").store;
13504
+ }
13505
+ var manageTaskSchema = import_zod44.z.object({
13506
+ action: import_zod44.z.enum(["create", "list", "update", "delete"]).describe("Action to perform. Available: create, list, update, delete. To mark a task complete, use update with status='completed'"),
13507
+ id: import_zod44.z.string().optional().describe("Task ID (required for update and delete)"),
13508
+ title: import_zod44.z.string().optional().describe("Task title (required for create)"),
13509
+ description: import_zod44.z.string().optional().describe("Task description in Markdown"),
13510
+ priority: import_zod44.z.enum(["low", "medium", "high"]).optional().describe("Priority level"),
13511
+ status: import_zod44.z.enum(["pending", "in_progress", "review", "failed", "interrupted", "completed", "cancelled"]).optional().describe("Task status"),
13512
+ dueDate: import_zod44.z.string().optional().describe("Due date (ISO 8601 format)"),
13513
+ metadata: import_zod44.z.record(import_zod44.z.unknown()).optional().describe("Structured metadata (e.g. projectId, module)"),
13514
+ parentId: import_zod44.z.string().optional().describe("Parent task ID for grouping subtasks"),
13515
+ sourceId: import_zod44.z.string().optional().describe("Source session/thread ID"),
13516
+ context: import_zod44.z.record(import_zod44.z.unknown()).optional().describe("Additional context data"),
13517
+ ownerType: import_zod44.z.enum(["user", "agent"]).optional().describe("Owner type. Defaults to 'user' if omitted"),
13518
+ ownerId: import_zod44.z.string().optional().describe("Owner ID. Auto-filled from current user/agent if omitted"),
13519
+ requireReview: import_zod44.z.boolean().optional().describe("If true, completing sends task to 'review' status instead of 'completed'"),
13520
+ dependencies: import_zod44.z.array(import_zod44.z.string()).optional().describe("List of task IDs that must be completed before this task can start"),
13521
+ result: import_zod44.z.string().optional().describe("Result summary when task is completed"),
13522
+ failureReason: import_zod44.z.string().optional().describe("Reason for failure (use when status='failed')"),
13523
+ summary: import_zod44.z.string().optional().describe("Brief summary of the operation")
13524
+ });
13525
+ function createTaskMiddleware() {
13526
+ const handleManageTask = async (input, config) => {
13527
+ const rc = getRunConfig(config);
13528
+ const tenantId2 = rc.tenantId || "default";
13529
+ const workspaceId = rc.workspaceId;
13530
+ const projectId = rc.projectId;
13531
+ const ownerId = input.ownerId || (input.ownerType === "agent" ? rc.assistant_id : null) || rc.user_id;
13532
+ const store = getTaskStore();
13533
+ switch (input.action) {
13534
+ case "create": {
13535
+ if (!input.title) {
13536
+ return JSON.stringify({
13537
+ success: false,
13538
+ error: "title is required for create action",
13539
+ hint: "Provide a short, descriptive title for the task"
13540
+ });
13541
+ }
13542
+ const task = await store.create({
13543
+ tenantId: tenantId2,
13544
+ ownerType: input.ownerType || "user",
13545
+ ownerId,
13546
+ title: input.title,
13547
+ description: input.description,
13548
+ priority: input.priority || "medium",
13549
+ status: input.status || "pending",
13550
+ dueDate: input.dueDate,
13551
+ metadata: input.metadata,
13552
+ parentId: input.parentId,
13553
+ sourceId: input.sourceId,
13554
+ context: input.context,
13555
+ requireReview: input.requireReview,
13556
+ dependencies: input.dependencies,
13557
+ workspaceId,
13558
+ projectId
13559
+ });
13560
+ return JSON.stringify({ success: true, data: task });
13561
+ }
13562
+ case "list": {
13563
+ const filter2 = {
13564
+ tenantId: tenantId2,
13565
+ ownerType: input.ownerType,
13566
+ ownerId: input.ownerId,
13567
+ status: input.status,
13568
+ priority: input.priority,
13569
+ projectId
13570
+ };
13571
+ const tasks = await store.list(filter2);
13572
+ return JSON.stringify({ success: true, data: tasks, count: tasks.length });
13573
+ }
13574
+ case "update": {
13575
+ if (!input.id) {
13576
+ return JSON.stringify({
13577
+ success: false,
13578
+ error: "id is required for update action",
13579
+ hint: "Pass the task ID you want to update"
13580
+ });
13581
+ }
13582
+ const existing = await store.getById(tenantId2, input.id);
13583
+ if (!existing) {
13584
+ return JSON.stringify({
13585
+ success: false,
13586
+ error: `Task '${input.id}' not found`,
13587
+ hint: "Use list to see available tasks and their IDs"
13588
+ });
13589
+ }
13590
+ if (input.status) {
13591
+ if (!isValidTransition(existing.status, input.status)) {
13592
+ const allowed = VALID_TRANSITIONS[existing.status] || [];
13593
+ return JSON.stringify({
13594
+ success: false,
13595
+ error: `Cannot transition task from '${existing.status}' to '${input.status}'`,
13596
+ allowedTransitions: allowed,
13597
+ hint: `From '${existing.status}', valid transitions are: ${allowed.join(", ")}`
13598
+ });
13599
+ }
13600
+ }
13601
+ if (input.status === "in_progress" && existing.dependencies && existing.dependencies.length > 0) {
13602
+ const incompleteDeps = [];
13603
+ for (const depId of existing.dependencies) {
13604
+ const depTask = await store.getById(tenantId2, depId);
13605
+ if (!depTask || depTask.status !== "completed") {
13606
+ incompleteDeps.push(depId);
13607
+ }
13608
+ }
13609
+ if (incompleteDeps.length > 0) {
13610
+ return JSON.stringify({
13611
+ success: false,
13612
+ error: `Cannot start task '${input.id}': ${incompleteDeps.length} dependencies not completed`,
13613
+ blockedBy: incompleteDeps,
13614
+ hint: `These tasks must be completed first: ${incompleteDeps.join(", ")}`
13615
+ });
13616
+ }
13617
+ }
13618
+ let effectiveStatus = input.status;
13619
+ if (existing.requireReview && input.status === "completed" && existing.status === "in_progress") {
13620
+ effectiveStatus = "review";
13621
+ }
13622
+ const updates = {};
13623
+ const settableFields = [
13624
+ "title",
13625
+ "description",
13626
+ "priority",
13627
+ "dueDate",
13628
+ "metadata",
13629
+ "parentId",
13630
+ "sourceId",
13631
+ "context",
13632
+ "ownerType",
13633
+ "ownerId",
13634
+ "result",
13635
+ "failureReason",
13636
+ "requireReview",
13637
+ "dependencies"
13638
+ ];
13639
+ for (const field of settableFields) {
13640
+ if (input[field] !== void 0) {
13641
+ updates[field] = input[field];
13642
+ }
13643
+ }
13644
+ if (effectiveStatus !== void 0) {
13645
+ updates.status = effectiveStatus;
13646
+ }
13647
+ const updated = await store.update(tenantId2, input.id, updates);
13648
+ if (!updated) {
13649
+ return JSON.stringify({
13650
+ success: false,
13651
+ error: `Failed to update task '${input.id}'`,
13652
+ hint: "The task may have been deleted or the ID is incorrect"
13653
+ });
13654
+ }
13655
+ const actionMap = {
13656
+ pending: "pending",
13657
+ in_progress: "started",
13658
+ review: "submitted",
13659
+ failed: "failed",
13660
+ interrupted: "interrupted",
13661
+ completed: "completed",
13662
+ cancelled: "cancelled"
13663
+ };
13664
+ const workItemAction = effectiveStatus ? actionMap[effectiveStatus] || "updated" : "updated";
13665
+ const workItemSummary = input.summary || (effectiveStatus ? `Status changed to ${effectiveStatus}` : void 0);
13666
+ const workItemStore = getTaskWorkItemStore();
13667
+ await workItemStore.create({
13668
+ taskId: input.id,
13669
+ tenantId: tenantId2,
13670
+ action: workItemAction,
13671
+ actor: input.ownerType === "agent" ? `agent:${ownerId}` : `user:${ownerId}`,
13672
+ threadId: input.sourceId,
13673
+ summary: workItemSummary,
13674
+ detail: {
13675
+ ...input.result !== void 0 && { result: input.result },
13676
+ ...input.failureReason !== void 0 && { failureReason: input.failureReason }
13677
+ },
13678
+ workspaceId,
13679
+ projectId
13680
+ });
13681
+ return JSON.stringify({ success: true, data: updated });
13682
+ }
13683
+ case "delete": {
13684
+ if (!input.id) {
13685
+ return JSON.stringify({
13686
+ success: false,
13687
+ error: "id is required for delete action",
13688
+ hint: "Pass the task ID you want to delete"
13689
+ });
13690
+ }
13691
+ const deleted = await store.delete(tenantId2, input.id);
13692
+ if (!deleted) {
13693
+ return JSON.stringify({
13694
+ success: false,
13695
+ error: `Task '${input.id}' not found or could not be deleted`,
13696
+ hint: "Use list to verify the task exists"
13697
+ });
13698
+ }
13699
+ return JSON.stringify({ success: true, message: `Task '${input.id}' deleted` });
13700
+ }
13701
+ default:
13702
+ return JSON.stringify({
13703
+ success: false,
13704
+ error: `Unknown action '${input.action}'`,
13705
+ availableActions: ["create", "list", "update", "delete"],
13706
+ hint: "To mark a task complete, use action='update' with status='completed'"
13707
+ });
13708
+ }
13709
+ };
13710
+ return (0, import_langchain47.createMiddleware)({
13711
+ name: "TaskMiddleware",
13712
+ contextSchema,
13713
+ wrapModelCall: async (request, handler) => {
13714
+ const taskPrompt = `## Task Management
13715
+
13716
+ You can use the \`manage_task\` tool to create persistent tasks for user-visible work tracking.
13717
+
13718
+ ### When to create a task
13719
+ - The user explicitly asks you to track, manage, or follow up on work
13720
+ - The work spans multiple sessions or might need resumption later
13721
+ - The user needs to review or approve output before it is considered done
13722
+ - There are multiple independent work items the user wants visibility into
13723
+
13724
+ ### When NOT to create a task
13725
+ - One-shot lookups or simple Q&A ("what is X?", "search for Y")
13726
+ - Internal exploration steps you take to understand the problem (use \`write_todos\` for your execution plan instead)
13727
+ - Trivial single-step actions that complete in the same turn
13728
+ - Conversational or informational requests with no deliverable
13729
+
13730
+ ### Ownership defaults
13731
+ - No params: ownerType defaults to "user" with current user's ID
13732
+ - ownerType="agent": auto-fills ownerId from current agent (subtask for yourself)
13733
+ - Explicit ownerId: assign to a specific agent or user`;
13734
+ return handler({
13735
+ ...request,
13736
+ systemPrompt: taskPrompt + "\n\n" + (request.systemPrompt ?? "")
13737
+ });
13738
+ },
13739
+ tools: [
13740
+ (0, import_langchain47.tool)(
13741
+ handleManageTask,
13742
+ {
13743
+ name: "manage_task",
13744
+ description: `Manage persistent tasks. CRUD operations for user and agent tasks.
13745
+
13746
+ ## Owner defaults
13747
+ - No ownerType/ownerId: auto-assigned to current user
13748
+ - ownerType="agent" without ownerId: auto-assigned to current agent
13749
+ - Explicit ownerId: assign to a specific agent (cross-agent delegation)
13750
+
13751
+ ## Actions
13752
+ - create: Create a task (title required; priority/description/dueDate/metadata/parentId/context optional)
13753
+ - list: List tasks, filterable by ownerType/status/priority
13754
+ - update: Update a task (id required; pass only the fields to change)
13755
+ To mark complete: update with status='completed'
13756
+ To mark failed: update with status='failed', failureReason='...'
13757
+ Status transitions are validated \u2014 only allowed transitions will succeed.
13758
+ - delete: Delete a task (id required)`,
13759
+ schema: manageTaskSchema
13760
+ }
13761
+ )
13762
+ ]
13763
+ });
13764
+ }
13765
+ var taskPlugin = {
13766
+ meta: {
13767
+ type: "task",
13768
+ name: "Task Management",
13769
+ description: "Enables persistent task management with delegation and tracking",
13770
+ configSchema: {
13771
+ type: "object",
13772
+ title: "Task Management Configuration",
13773
+ description: "Zero-configuration task management",
13774
+ properties: {}
13775
+ },
13776
+ defaultConfig: {}
13777
+ },
13778
+ middleware: () => createTaskMiddleware(),
13779
+ skills: {
13780
+ "task-definition": `## Using manage_task
13781
+
13782
+ ### Task description format
13783
+
13784
+ When creating a task with manage_task, write the description in this Markdown structure:
13785
+
13786
+ ## Objective
13787
+ [One sentence \u2014 what result to achieve, as measurable as possible]
13788
+
13789
+ ## Acceptance Criteria
13790
+ - [ ] Criterion 1
13791
+ - [ ] Criterion 2
13792
+
13793
+ ## Deliverables
13794
+ - Deliverable description
13795
+
13796
+ Update the checklist as you work: change \`[ ]\` to \`[x]\` when a criterion is met.
13797
+
13798
+ ### Subtasks (parentId)
13799
+
13800
+ Use \`parentId\` to group related tasks under a parent. Create the parent task first, then create each subtask with \`parentId\` pointing to the parent.
13801
+
13802
+ ### Dependencies
13803
+
13804
+ 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.
13805
+
13806
+ ### requireReview
13807
+
13808
+ 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\`.
13809
+
13810
+ ### Reporting results
13811
+
13812
+ When a task is finished:
13813
+ - \`update(status: "completed", result: "summary of what was done")\`
13814
+ - If unable to complete: \`update(status: "failed", failureReason: "specific reason")\`
13815
+ - If blocked waiting for user input: \`update(status: "interrupted", summary: "what you need")\`
13816
+ - Use description updates to append progress notes between status changes.`
13817
+ }
13818
+ };
13819
+
13312
13820
  // src/deep_agent_new/middleware/subagents.ts
13313
13821
  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.";
13314
13822
  var EXCLUDED_STATE_KEYS = ["messages", "todos", "jumpTo"];
@@ -13470,7 +13978,7 @@ function returnCommandWithStateUpdate(result, toolCallId) {
13470
13978
  update: {
13471
13979
  ...stateUpdate,
13472
13980
  messages: [
13473
- new import_langchain47.ToolMessage({
13981
+ new import_langchain48.ToolMessage({
13474
13982
  content: lastMessage?.content || "Task Failed to complete",
13475
13983
  tool_call_id: toolCallId,
13476
13984
  name: "task"
@@ -13491,14 +13999,18 @@ function getSubagents(options) {
13491
13999
  const defaultSubagentMiddleware = defaultMiddleware || [];
13492
14000
  const agents = {};
13493
14001
  const subagentDescriptions = [];
14002
+ const hasTaskMiddleware = defaultSubagentMiddleware.some(
14003
+ (m) => m?.name === "TaskMiddleware"
14004
+ );
14005
+ const taskMiddleware = hasTaskMiddleware ? [] : [createTaskMiddleware()];
13494
14006
  if (generalPurposeAgent) {
13495
- const generalPurposeMiddleware = [...defaultSubagentMiddleware];
14007
+ const generalPurposeMiddleware = [...defaultSubagentMiddleware, ...taskMiddleware];
13496
14008
  if (defaultInterruptOn) {
13497
14009
  generalPurposeMiddleware.push(
13498
- (0, import_langchain47.humanInTheLoopMiddleware)({ interruptOn: defaultInterruptOn })
14010
+ (0, import_langchain48.humanInTheLoopMiddleware)({ interruptOn: defaultInterruptOn })
13499
14011
  );
13500
14012
  }
13501
- const generalPurposeSubagent = (0, import_langchain47.createAgent)({
14013
+ const generalPurposeSubagent = (0, import_langchain48.createAgent)({
13502
14014
  model: defaultModel,
13503
14015
  systemPrompt: DEFAULT_SUBAGENT_PROMPT,
13504
14016
  tools: defaultTools,
@@ -13518,11 +14030,11 @@ function getSubagents(options) {
13518
14030
  if ("runnable" in agentParams) {
13519
14031
  agents[agentParams.key] = agentParams.runnable;
13520
14032
  } else {
13521
- const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
14033
+ const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...taskMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware, ...taskMiddleware];
13522
14034
  const interruptOn = agentParams.interruptOn || defaultInterruptOn;
13523
14035
  if (interruptOn)
13524
- middleware.push((0, import_langchain47.humanInTheLoopMiddleware)({ interruptOn }));
13525
- agents[agentParams.key] = (0, import_langchain47.createAgent)({
14036
+ middleware.push((0, import_langchain48.humanInTheLoopMiddleware)({ interruptOn }));
14037
+ agents[agentParams.key] = (0, import_langchain48.createAgent)({
13526
14038
  model: agentParams.model ?? defaultModel,
13527
14039
  systemPrompt: agentParams.systemPrompt,
13528
14040
  tools: agentParams.tools ?? defaultTools,
@@ -13572,7 +14084,7 @@ function createTaskTool(options) {
13572
14084
  generalPurposeAgent
13573
14085
  });
13574
14086
  const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
13575
- return (0, import_langchain47.tool)(
14087
+ return (0, import_langchain48.tool)(
13576
14088
  async (input, config) => {
13577
14089
  const { description, subagent_type, async } = input;
13578
14090
  let assistant_id = subagent_type;
@@ -13602,7 +14114,17 @@ function createTaskTool(options) {
13602
14114
  }
13603
14115
  const currentState = (0, import_langgraph7.getCurrentTaskInput)();
13604
14116
  const subagentState = filterStateForSubagent(currentState);
13605
- subagentState.messages = [new import_messages2.HumanMessage({ content: description })];
14117
+ subagentState.messages = input.taskId ? [
14118
+ new import_messages3.HumanMessage({
14119
+ content: `${description}
14120
+
14121
+ ---
14122
+ You are executing a persistent task (ID: ${input.taskId}). Use manage_task.update to report your progress:
14123
+ - Set status to 'in_progress' when you start working
14124
+ - 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)
14125
+ - You can also update the description to append progress notes or update the acceptance criteria checklist.`
14126
+ })
14127
+ ] : [new import_messages3.HumanMessage({ content: description })];
13606
14128
  const subagent_thread_id = config.configurable?.thread_id + "____" + assistant_id + "_" + config.toolCall.id;
13607
14129
  if (async) {
13608
14130
  const tenantId2 = config.configurable?.runConfig?.tenantId;
@@ -13634,11 +14156,12 @@ function createTaskTool(options) {
13634
14156
  runConfig: {
13635
14157
  ...config.configurable?.runConfig,
13636
14158
  assistant_id,
13637
- thread_id: subagent_thread_id
14159
+ thread_id: subagent_thread_id,
14160
+ taskId: input.taskId
13638
14161
  },
13639
- main_thread_id: mainThreadId,
13640
14162
  main_tenant_id: tenantId2,
13641
- main_assistant_id: mainAssistantId
14163
+ main_assistant_id: mainAssistantId,
14164
+ main_thread_id: mainThreadId
13642
14165
  }, false).catch((err) => {
13643
14166
  console.error(`Failed to start async subagent ${subagent_thread_id}:`, err);
13644
14167
  });
@@ -13648,7 +14171,7 @@ function createTaskTool(options) {
13648
14171
  return new import_langgraph7.Command({
13649
14172
  update: {
13650
14173
  messages: [
13651
- new import_langchain47.ToolMessage({
14174
+ new import_langchain48.ToolMessage({
13652
14175
  content: `Async task started: ${subagent_thread_id}
13653
14176
  ${description}
13654
14177
  The result will be delivered as a notification when complete. Do not poll.`,
@@ -13666,7 +14189,8 @@ The result will be delivered as a notification when complete. Do not poll.`,
13666
14189
  runConfig: {
13667
14190
  ...config.configurable?.runConfig,
13668
14191
  assistant_id,
13669
- thread_id: subagent_thread_id
14192
+ thread_id: subagent_thread_id,
14193
+ taskId: input.taskId
13670
14194
  }
13671
14195
  });
13672
14196
  const result = workerResult.finalState?.values;
@@ -13681,7 +14205,7 @@ The result will be delivered as a notification when complete. Do not poll.`,
13681
14205
  return new import_langgraph7.Command({
13682
14206
  update: {
13683
14207
  messages: [
13684
- new import_langchain47.ToolMessage({
14208
+ new import_langchain48.ToolMessage({
13685
14209
  content: error instanceof Error ? error.message : "Task Failed to complete",
13686
14210
  tool_call_id: config.toolCall.id,
13687
14211
  name: "task"
@@ -13705,7 +14229,10 @@ The result will be delivered as a notification when complete. Do not poll.`,
13705
14229
  async: import_v32.z.boolean().default(false).describe(
13706
14230
  "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."
13707
14231
  )
13708
- } : {}
14232
+ } : {},
14233
+ taskId: import_v32.z.string().optional().describe(
14234
+ "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."
14235
+ )
13709
14236
  })
13710
14237
  }
13711
14238
  );
@@ -13721,7 +14248,7 @@ function getMainAgentFromConfig(config) {
13721
14248
  });
13722
14249
  }
13723
14250
  function createCheckAsyncTaskTool() {
13724
- return (0, import_langchain47.tool)(
14251
+ return (0, import_langchain48.tool)(
13725
14252
  async (input, config) => {
13726
14253
  const { task_id } = input;
13727
14254
  const mainAgent = getMainAgentFromConfig(config);
@@ -13788,7 +14315,7 @@ Description: ${cached.description}`;
13788
14315
  );
13789
14316
  }
13790
14317
  function createListAsyncTasksTool() {
13791
- return (0, import_langchain47.tool)(
14318
+ return (0, import_langchain48.tool)(
13792
14319
  async (_input, config) => {
13793
14320
  const mainAgent = getMainAgentFromConfig(config);
13794
14321
  if (!mainAgent) {
@@ -13839,7 +14366,7 @@ function createListAsyncTasksTool() {
13839
14366
  );
13840
14367
  }
13841
14368
  function createCancelAsyncTaskTool() {
13842
- return (0, import_langchain47.tool)(
14369
+ return (0, import_langchain48.tool)(
13843
14370
  async (input, config) => {
13844
14371
  const { task_id } = input;
13845
14372
  const mainAgent = getMainAgentFromConfig(config);
@@ -13915,7 +14442,7 @@ function createSubAgentMiddleware(options) {
13915
14442
  );
13916
14443
  }
13917
14444
  const effectiveSystemPrompt = allowAsync ? systemPrompt + getAsyncPromptText() : systemPrompt;
13918
- return (0, import_langchain47.createMiddleware)({
14445
+ return (0, import_langchain48.createMiddleware)({
13919
14446
  name: "subAgentMiddleware",
13920
14447
  tools: allTools,
13921
14448
  wrapModelCall: async (request, handler) => {
@@ -13935,9 +14462,9 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
13935
14462
  }
13936
14463
 
13937
14464
  // src/deep_agent_new/middleware/patch_tool_calls.ts
13938
- var import_langchain48 = require("langchain");
14465
+ var import_langchain49 = require("langchain");
13939
14466
  function createPatchToolCallsMiddleware() {
13940
- return (0, import_langchain48.createMiddleware)({
14467
+ return (0, import_langchain49.createMiddleware)({
13941
14468
  name: "patchToolCallsMiddleware",
13942
14469
  beforeAgent: async (state) => {
13943
14470
  const messages = state.messages;
@@ -13948,15 +14475,15 @@ function createPatchToolCallsMiddleware() {
13948
14475
  for (let i = 0; i < messages.length; i++) {
13949
14476
  const msg = messages[i];
13950
14477
  patchedMessages.push(msg);
13951
- if (import_langchain48.AIMessage.isInstance(msg) && msg.tool_calls != null) {
14478
+ if (import_langchain49.AIMessage.isInstance(msg) && msg.tool_calls != null) {
13952
14479
  for (const toolCall of msg.tool_calls) {
13953
14480
  const correspondingToolMsg = messages.slice(i).find(
13954
- (m) => import_langchain48.ToolMessage.isInstance(m) && m.tool_call_id === toolCall.id
14481
+ (m) => import_langchain49.ToolMessage.isInstance(m) && m.tool_call_id === toolCall.id
13955
14482
  );
13956
14483
  if (!correspondingToolMsg) {
13957
14484
  const toolMsg = `Tool call ${toolCall.name} with id ${toolCall.id} was cancelled - another message came in before it could be completed.`;
13958
14485
  patchedMessages.push(
13959
- new import_langchain48.ToolMessage({
14486
+ new import_langchain49.ToolMessage({
13960
14487
  content: toolMsg,
13961
14488
  name: toolCall.name,
13962
14489
  tool_call_id: toolCall.id
@@ -13978,8 +14505,8 @@ function createPatchToolCallsMiddleware() {
13978
14505
  }
13979
14506
 
13980
14507
  // src/deep_agent_new/middleware/date.ts
13981
- var import_langchain49 = require("langchain");
13982
- var import_zod44 = require("zod");
14508
+ var import_langchain50 = require("langchain");
14509
+ var import_zod45 = require("zod");
13983
14510
  function formatCurrentDate(timezone = "UTC") {
13984
14511
  const now = /* @__PURE__ */ new Date();
13985
14512
  let validTimezone = timezone;
@@ -14007,10 +14534,10 @@ function generateDateContext(timezone = "UTC") {
14007
14534
  function createDateMiddleware(options = {}) {
14008
14535
  const timezone = options.timezone || "UTC";
14009
14536
  const dateContext = generateDateContext(timezone);
14010
- return (0, import_langchain49.createMiddleware)({
14537
+ return (0, import_langchain50.createMiddleware)({
14011
14538
  name: "DateMiddleware",
14012
14539
  tools: [
14013
- (0, import_langchain49.tool)(
14540
+ (0, import_langchain50.tool)(
14014
14541
  async () => {
14015
14542
  const now = /* @__PURE__ */ new Date();
14016
14543
  let validTimezone = timezone;
@@ -14040,7 +14567,7 @@ function createDateMiddleware(options = {}) {
14040
14567
  {
14041
14568
  name: "get_current_date_time",
14042
14569
  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.",
14043
- schema: import_zod44.z.object({})
14570
+ schema: import_zod45.z.object({})
14044
14571
  }
14045
14572
  )
14046
14573
  ],
@@ -14105,9 +14632,9 @@ var datePlugin = {
14105
14632
  };
14106
14633
 
14107
14634
  // src/deep_agent_new/middleware/scheduler.ts
14108
- var import_langchain50 = require("langchain");
14109
- var import_zod45 = require("zod");
14110
- var import_uuid4 = require("uuid");
14635
+ var import_langchain51 = require("langchain");
14636
+ var import_zod46 = require("zod");
14637
+ var import_uuid5 = require("uuid");
14111
14638
  var import_protocols8 = require("@axiom-lattice/protocols");
14112
14639
 
14113
14640
  // src/schedule_lattice/ScheduleLatticeManager.ts
@@ -15102,7 +15629,7 @@ var getScheduleLattice = (key4) => scheduleLatticeManager.getScheduleLattice(key
15102
15629
  // src/deep_agent_new/middleware/scheduler.ts
15103
15630
  var SCHEDULE_LATTICE_KEY = "default";
15104
15631
  var AGENT_ADD_MESSAGE_TASK_TYPE = "agent.add_message";
15105
- function getRunConfig(config) {
15632
+ function getRunConfig2(config) {
15106
15633
  const configurable = config;
15107
15634
  return configurable?.configurable?.runConfig ?? {};
15108
15635
  }
@@ -15174,14 +15701,14 @@ function registerAgentAddMessageHandler() {
15174
15701
  function createSchedulerMiddleware(options = {}) {
15175
15702
  const defaultMaxRetries = options.defaultMaxRetries ?? 0;
15176
15703
  registerAgentAddMessageHandler();
15177
- return (0, import_langchain50.createMiddleware)({
15704
+ return (0, import_langchain51.createMiddleware)({
15178
15705
  name: "SchedulerMiddleware",
15179
15706
  tools: [
15180
- (0, import_langchain50.tool)(
15707
+ (0, import_langchain51.tool)(
15181
15708
  async (input, config) => {
15182
- const runConfig = getRunConfig(config);
15709
+ const runConfig = getRunConfig2(config);
15183
15710
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15184
- const taskId = (0, import_uuid4.v4)();
15711
+ const taskId = (0, import_uuid5.v4)();
15185
15712
  const executeAt = input.executeAt;
15186
15713
  const success = await scheduleLattice.client.scheduleOnce(
15187
15714
  taskId,
@@ -15205,18 +15732,18 @@ function createSchedulerMiddleware(options = {}) {
15205
15732
  {
15206
15733
  name: "schedule_at",
15207
15734
  description: "Schedule a system message for an absolute future timestamp",
15208
- schema: import_zod45.z.object({
15209
- executeAt: import_zod45.z.number(),
15210
- maxRetries: import_zod45.z.number().int().min(0).optional(),
15211
- message: import_zod45.z.string()
15735
+ schema: import_zod46.z.object({
15736
+ executeAt: import_zod46.z.number(),
15737
+ maxRetries: import_zod46.z.number().int().min(0).optional(),
15738
+ message: import_zod46.z.string()
15212
15739
  })
15213
15740
  }
15214
15741
  ),
15215
- (0, import_langchain50.tool)(
15742
+ (0, import_langchain51.tool)(
15216
15743
  async (input, config) => {
15217
- const runConfig = getRunConfig(config);
15744
+ const runConfig = getRunConfig2(config);
15218
15745
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15219
- const taskId = (0, import_uuid4.v4)();
15746
+ const taskId = (0, import_uuid5.v4)();
15220
15747
  const executeAt = Date.now() + input.delayMs;
15221
15748
  const success = await scheduleLattice.client.scheduleOnce(
15222
15749
  taskId,
@@ -15240,18 +15767,18 @@ function createSchedulerMiddleware(options = {}) {
15240
15767
  {
15241
15768
  name: "schedule_after",
15242
15769
  description: "Schedule a system message after a relative delay",
15243
- schema: import_zod45.z.object({
15244
- delayMs: import_zod45.z.number().positive(),
15245
- maxRetries: import_zod45.z.number().int().min(0).optional(),
15246
- message: import_zod45.z.string()
15770
+ schema: import_zod46.z.object({
15771
+ delayMs: import_zod46.z.number().positive(),
15772
+ maxRetries: import_zod46.z.number().int().min(0).optional(),
15773
+ message: import_zod46.z.string()
15247
15774
  })
15248
15775
  }
15249
15776
  ),
15250
- (0, import_langchain50.tool)(
15777
+ (0, import_langchain51.tool)(
15251
15778
  async (input, config) => {
15252
- const runConfig = getRunConfig(config);
15779
+ const runConfig = getRunConfig2(config);
15253
15780
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15254
- const taskId = (0, import_uuid4.v4)();
15781
+ const taskId = (0, import_uuid5.v4)();
15255
15782
  const success = await scheduleLattice.client.scheduleCron(
15256
15783
  taskId,
15257
15784
  AGENT_ADD_MESSAGE_TASK_TYPE,
@@ -15282,16 +15809,16 @@ function createSchedulerMiddleware(options = {}) {
15282
15809
  {
15283
15810
  name: "schedule_recurring",
15284
15811
  description: "Schedule a recurring system message with a cron expression",
15285
- schema: import_zod45.z.object({
15286
- cronExpression: import_zod45.z.string(),
15287
- maxRuns: import_zod45.z.number().int().positive().optional(),
15288
- expiresAt: import_zod45.z.number().optional(),
15289
- maxRetries: import_zod45.z.number().int().min(0).optional(),
15290
- message: import_zod45.z.string()
15812
+ schema: import_zod46.z.object({
15813
+ cronExpression: import_zod46.z.string(),
15814
+ maxRuns: import_zod46.z.number().int().positive().optional(),
15815
+ expiresAt: import_zod46.z.number().optional(),
15816
+ maxRetries: import_zod46.z.number().int().min(0).optional(),
15817
+ message: import_zod46.z.string()
15291
15818
  })
15292
15819
  }
15293
15820
  ),
15294
- (0, import_langchain50.tool)(
15821
+ (0, import_langchain51.tool)(
15295
15822
  async (input) => {
15296
15823
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15297
15824
  const success = await scheduleLattice.client.cancel(input.taskId);
@@ -15300,14 +15827,14 @@ function createSchedulerMiddleware(options = {}) {
15300
15827
  {
15301
15828
  name: "cancel_scheduled_task",
15302
15829
  description: "Cancel a scheduled task by task id",
15303
- schema: import_zod45.z.object({
15304
- taskId: import_zod45.z.string()
15830
+ schema: import_zod46.z.object({
15831
+ taskId: import_zod46.z.string()
15305
15832
  })
15306
15833
  }
15307
15834
  ),
15308
- (0, import_langchain50.tool)(
15835
+ (0, import_langchain51.tool)(
15309
15836
  async (input, config) => {
15310
- const runConfig = getRunConfig(config);
15837
+ const runConfig = getRunConfig2(config);
15311
15838
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15312
15839
  const storage = scheduleLattice.client.getStorage();
15313
15840
  if (!storage) {
@@ -15327,11 +15854,11 @@ function createSchedulerMiddleware(options = {}) {
15327
15854
  {
15328
15855
  name: "list_scheduled_tasks",
15329
15856
  description: "List scheduled tasks for the current agent context",
15330
- schema: import_zod45.z.object({
15331
- status: import_zod45.z.enum(["pending", "running", "completed", "failed", "cancelled", "paused"]).optional(),
15332
- executionType: import_zod45.z.enum(["once", "cron"]).optional(),
15333
- limit: import_zod45.z.number().int().positive().optional(),
15334
- offset: import_zod45.z.number().int().min(0).optional()
15857
+ schema: import_zod46.z.object({
15858
+ status: import_zod46.z.enum(["pending", "running", "completed", "failed", "cancelled", "paused"]).optional(),
15859
+ executionType: import_zod46.z.enum(["once", "cron"]).optional(),
15860
+ limit: import_zod46.z.number().int().positive().optional(),
15861
+ offset: import_zod46.z.number().int().min(0).optional()
15335
15862
  })
15336
15863
  }
15337
15864
  )
@@ -16472,8 +16999,8 @@ var MemoryBackend = class {
16472
16999
 
16473
17000
  // src/deep_agent_new/middleware/todos.ts
16474
17001
  var import_langgraph8 = require("@langchain/langgraph");
16475
- var import_zod46 = require("zod");
16476
- var import_langchain51 = require("langchain");
17002
+ var import_zod47 = require("zod");
17003
+ var import_langchain52 = require("langchain");
16477
17004
  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.
16478
17005
  It also helps the user understand the progress of the task and overall progress of their requests.
16479
17006
  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.
@@ -16700,20 +17227,20 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
16700
17227
  ## Important To-Do List Usage Notes to Remember
16701
17228
  - The \`write_todos\` tool should never be called multiple times in parallel.
16702
17229
  - 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.`;
16703
- var TodoStatus = import_zod46.z.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
16704
- var TodoSchema = import_zod46.z.object({
16705
- content: import_zod46.z.string().describe("Content of the todo item"),
17230
+ var TodoStatus = import_zod47.z.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
17231
+ var TodoSchema = import_zod47.z.object({
17232
+ content: import_zod47.z.string().describe("Content of the todo item"),
16706
17233
  status: TodoStatus
16707
17234
  });
16708
- var stateSchema = import_zod46.z.object({ todos: import_zod46.z.array(TodoSchema).default([]) });
17235
+ var stateSchema = import_zod47.z.object({ todos: import_zod47.z.array(TodoSchema).default([]) });
16709
17236
  function todoListMiddleware(options) {
16710
- const writeTodos = (0, import_langchain51.tool)(
17237
+ const writeTodos = (0, import_langchain52.tool)(
16711
17238
  ({ todos }, config) => {
16712
17239
  return new import_langgraph8.Command({
16713
17240
  update: {
16714
17241
  todos,
16715
17242
  messages: [
16716
- new import_langchain51.ToolMessage({
17243
+ new import_langchain52.ToolMessage({
16717
17244
  content: genUIMarkdown("todo_list", todos),
16718
17245
  tool_call_id: config.toolCall?.id
16719
17246
  })
@@ -16724,12 +17251,12 @@ function todoListMiddleware(options) {
16724
17251
  {
16725
17252
  name: "write_todos",
16726
17253
  description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
16727
- schema: import_zod46.z.object({
16728
- todos: import_zod46.z.array(TodoSchema).describe("List of todo items to update")
17254
+ schema: import_zod47.z.object({
17255
+ todos: import_zod47.z.array(TodoSchema).describe("List of todo items to update")
16729
17256
  })
16730
17257
  }
16731
17258
  );
16732
- return (0, import_langchain51.createMiddleware)({
17259
+ return (0, import_langchain52.createMiddleware)({
16733
17260
  name: "todoListMiddleware",
16734
17261
  stateSchema,
16735
17262
  tools: [writeTodos],
@@ -16781,13 +17308,13 @@ ${BASE_PROMPT}` : BASE_PROMPT;
16781
17308
  backend: filesystemBackend
16782
17309
  }),
16783
17310
  // Subagent middleware: Automatic conversation summarization when token limits are approached
16784
- (0, import_langchain52.summarizationMiddleware)({
17311
+ (0, import_langchain53.summarizationMiddleware)({
16785
17312
  model,
16786
17313
  trigger: { tokens: 17e4 },
16787
17314
  keep: { messages: 6 }
16788
17315
  }),
16789
17316
  // Subagent middleware: Anthropic prompt caching for improved performance
16790
- (0, import_langchain52.anthropicPromptCachingMiddleware)({
17317
+ (0, import_langchain53.anthropicPromptCachingMiddleware)({
16791
17318
  unsupportedModelBehavior: "ignore"
16792
17319
  }),
16793
17320
  // Subagent middleware: Patches tool calls for compatibility
@@ -16799,23 +17326,23 @@ ${BASE_PROMPT}` : BASE_PROMPT;
16799
17326
  generalPurposeAgent: true
16800
17327
  }),
16801
17328
  // Automatically summarizes conversation history when token limits are approached
16802
- (0, import_langchain52.summarizationMiddleware)({
17329
+ (0, import_langchain53.summarizationMiddleware)({
16803
17330
  model,
16804
17331
  trigger: { tokens: 17e4 },
16805
17332
  keep: { messages: 6 }
16806
17333
  }),
16807
17334
  // Enables Anthropic prompt caching for improved performance and reduced costs
16808
- (0, import_langchain52.anthropicPromptCachingMiddleware)({
17335
+ (0, import_langchain53.anthropicPromptCachingMiddleware)({
16809
17336
  unsupportedModelBehavior: "ignore"
16810
17337
  }),
16811
17338
  // Patches tool calls to ensure compatibility across different model providers
16812
17339
  createPatchToolCallsMiddleware()
16813
17340
  ];
16814
17341
  if (interruptOn) {
16815
- middleware.push((0, import_langchain52.humanInTheLoopMiddleware)({ interruptOn }));
17342
+ middleware.push((0, import_langchain53.humanInTheLoopMiddleware)({ interruptOn }));
16816
17343
  }
16817
17344
  middleware.push(...customMiddleware);
16818
- return (0, import_langchain52.createAgent)({
17345
+ return (0, import_langchain53.createAgent)({
16819
17346
  model,
16820
17347
  systemPrompt: finalSystemPrompt,
16821
17348
  tools,
@@ -16887,7 +17414,7 @@ init_MemoryLatticeManager();
16887
17414
 
16888
17415
  // src/agent_team/agent_team.ts
16889
17416
  var import_v35 = require("zod/v3");
16890
- var import_langchain55 = require("langchain");
17417
+ var import_langchain56 = require("langchain");
16891
17418
 
16892
17419
  // src/agent_team/types.ts
16893
17420
  var TaskStatus = /* @__PURE__ */ ((TaskStatus3) => {
@@ -17323,13 +17850,13 @@ var InMemoryMailboxStore = class {
17323
17850
 
17324
17851
  // src/agent_team/middleware/team.ts
17325
17852
  var import_v34 = require("zod/v3");
17326
- var import_langchain54 = require("langchain");
17853
+ var import_langchain55 = require("langchain");
17327
17854
  var import_langgraph10 = require("@langchain/langgraph");
17328
- var import_uuid5 = require("uuid");
17855
+ var import_uuid6 = require("uuid");
17329
17856
 
17330
17857
  // src/agent_team/middleware/teammate_tools.ts
17331
17858
  var import_v33 = require("zod/v3");
17332
- var import_langchain53 = require("langchain");
17859
+ var import_langchain54 = require("langchain");
17333
17860
  var import_langgraph9 = require("@langchain/langgraph");
17334
17861
 
17335
17862
  // src/agent_team/middleware/formatMessages.ts
@@ -17354,7 +17881,7 @@ ${meta}${body}`;
17354
17881
  // src/agent_team/middleware/teammate_tools.ts
17355
17882
  function createTeammateTools(options) {
17356
17883
  const { teamId, agentId, taskListStore, mailboxStore } = options;
17357
- const claimTaskTool = (0, import_langchain53.tool)(
17884
+ const claimTaskTool = (0, import_langchain54.tool)(
17358
17885
  async (input) => {
17359
17886
  const task = await taskListStore.claimTaskById(
17360
17887
  teamId,
@@ -17384,7 +17911,7 @@ function createTeammateTools(options) {
17384
17911
  })
17385
17912
  }
17386
17913
  );
17387
- const completeTaskTool = (0, import_langchain53.tool)(
17914
+ const completeTaskTool = (0, import_langchain54.tool)(
17388
17915
  async (input) => {
17389
17916
  const task = await taskListStore.completeTask(
17390
17917
  teamId,
@@ -17411,7 +17938,7 @@ function createTeammateTools(options) {
17411
17938
  })
17412
17939
  }
17413
17940
  );
17414
- const failTaskTool = (0, import_langchain53.tool)(
17941
+ const failTaskTool = (0, import_langchain54.tool)(
17415
17942
  async (input) => {
17416
17943
  const task = await taskListStore.failTask(
17417
17944
  teamId,
@@ -17438,7 +17965,7 @@ function createTeammateTools(options) {
17438
17965
  })
17439
17966
  }
17440
17967
  );
17441
- const sendMessageTool = (0, import_langchain53.tool)(
17968
+ const sendMessageTool = (0, import_langchain54.tool)(
17442
17969
  async (input) => {
17443
17970
  await mailboxStore.sendMessage(
17444
17971
  teamId,
@@ -17476,7 +18003,7 @@ function createTeammateTools(options) {
17476
18003
  read: msg.read
17477
18004
  }));
17478
18005
  };
17479
- const readMessagesTool = (0, import_langchain53.tool)(
18006
+ const readMessagesTool = (0, import_langchain54.tool)(
17480
18007
  async (input, config) => {
17481
18008
  const formatAndMarkAsRead = async (msgs2) => {
17482
18009
  for (const msg of msgs2) {
@@ -17488,7 +18015,7 @@ function createTeammateTools(options) {
17488
18015
  if (msgs.length > 0) {
17489
18016
  const formatted2 = await formatAndMarkAsRead(msgs);
17490
18017
  const relevantMsgs2 = await getRelevantMessagesForState();
17491
- const toolMessage2 = new import_langchain53.ToolMessage({
18018
+ const toolMessage2 = new import_langchain54.ToolMessage({
17492
18019
  content: formatted2,
17493
18020
  tool_call_id: config.toolCall?.id,
17494
18021
  name: "read_messages"
@@ -17513,7 +18040,7 @@ function createTeammateTools(options) {
17513
18040
  });
17514
18041
  const relevantMsgs = await getRelevantMessagesForState();
17515
18042
  if (msgs.length === 0) {
17516
- const toolMessage2 = new import_langchain53.ToolMessage({
18043
+ const toolMessage2 = new import_langchain54.ToolMessage({
17517
18044
  content: "No unread messages.",
17518
18045
  tool_call_id: config.toolCall?.id,
17519
18046
  name: "read_messages"
@@ -17523,7 +18050,7 @@ function createTeammateTools(options) {
17523
18050
  });
17524
18051
  }
17525
18052
  const formatted = await formatAndMarkAsRead(msgs);
17526
- const toolMessage = new import_langchain53.ToolMessage({
18053
+ const toolMessage = new import_langchain54.ToolMessage({
17527
18054
  content: formatted,
17528
18055
  tool_call_id: config.toolCall?.id,
17529
18056
  name: "read_messages"
@@ -17538,7 +18065,7 @@ function createTeammateTools(options) {
17538
18065
  schema: import_v33.z.object({})
17539
18066
  }
17540
18067
  );
17541
- const checkTasksTool = (0, import_langchain53.tool)(
18068
+ const checkTasksTool = (0, import_langchain54.tool)(
17542
18069
  async () => {
17543
18070
  const tasks = await taskListStore.getAllTasks(teamId);
17544
18071
  return formatTaskSummary(tasks);
@@ -17549,7 +18076,7 @@ function createTeammateTools(options) {
17549
18076
  schema: import_v33.z.object({})
17550
18077
  }
17551
18078
  );
17552
- const broadcastMessageTool = (0, import_langchain53.tool)(
18079
+ const broadcastMessageTool = (0, import_langchain54.tool)(
17553
18080
  async (input) => {
17554
18081
  const allAgents = await mailboxStore.getRegisteredAgents(teamId);
17555
18082
  const recipients = allAgents.filter((a) => a !== agentId);
@@ -17735,7 +18262,7 @@ You have access to these tools:
17735
18262
  - \`read_messages\`: Read messages from team_lead or teammates
17736
18263
  - \`check_tasks\`: Get current status of all tasks in the team`;
17737
18264
  const assistantId = getTeammateAssistantId(ctx.teamId, spec.name);
17738
- agent = (0, import_langchain54.createAgent)({
18265
+ agent = (0, import_langchain55.createAgent)({
17739
18266
  model: spec.model ?? ctx.defaultModel,
17740
18267
  systemPrompt: teammatePrompt,
17741
18268
  tools: allTools,
@@ -17804,19 +18331,19 @@ async function spawnTeammate(options) {
17804
18331
  function createTeamMiddleware(options) {
17805
18332
  const { teamConfig, taskListStore, mailboxStore, tenantId: tenantId2 } = options;
17806
18333
  const defaultModel = teamConfig.model ?? "claude-sonnet-4-5-20250929";
17807
- const createTeamTool = (0, import_langchain54.tool)(
18334
+ const createTeamTool = (0, import_langchain55.tool)(
17808
18335
  async (input, config) => {
17809
18336
  const state = (0, import_langgraph10.getCurrentTaskInput)();
17810
18337
  if (state?.team?.teamId) {
17811
18338
  const existingId = state.team.teamId;
17812
- const msg = new import_langchain54.ToolMessage({
18339
+ const msg = new import_langchain55.ToolMessage({
17813
18340
  content: `A team is already active (id: ${existingId}). Use this team_id for \`check_tasks\`, \`read_messages\`, \`add_tasks\`, \`send_message\`, \`assign_task\`, \`set_task_status\`, and \`set_task_dependencies\`. Do not call \`create_team\` again unless you need a fresh team for a new objective.`,
17814
18341
  tool_call_id: config.toolCall?.id,
17815
18342
  name: "create_team"
17816
18343
  });
17817
18344
  return msg;
17818
18345
  }
17819
- const teamId = (0, import_uuid5.v4)();
18346
+ const teamId = (0, import_uuid6.v4)();
17820
18347
  const createdTasks = await taskListStore.addTasks(
17821
18348
  teamId,
17822
18349
  input.tasks.map((t) => ({
@@ -17898,7 +18425,7 @@ Teammates are now working in the background. Keep calling \`check_tasks\` and \`
17898
18425
  \`\`\`json
17899
18426
  ${teamJson}
17900
18427
  \`\`\``;
17901
- const toolMessage = new import_langchain54.ToolMessage({
18428
+ const toolMessage = new import_langchain55.ToolMessage({
17902
18429
  content: summary,
17903
18430
  tool_call_id: config.toolCall?.id,
17904
18431
  name: "create_team"
@@ -17983,7 +18510,7 @@ After calling create_team, you MUST:
17983
18510
  if (state?.team?.teamId) return state.team.teamId;
17984
18511
  throw new Error("No team_id provided and no team in state. Call create_team first.");
17985
18512
  };
17986
- const addTasksTool = (0, import_langchain54.tool)(
18513
+ const addTasksTool = (0, import_langchain55.tool)(
17987
18514
  async (input, config) => {
17988
18515
  const teamId = resolveTeamId();
17989
18516
  const created = await taskListStore.addTasks(
@@ -17997,7 +18524,7 @@ After calling create_team, you MUST:
17997
18524
  }))
17998
18525
  );
17999
18526
  const summary = created.map((t) => `- ${t.id}: "${t.title}"`).join("\n");
18000
- return new import_langchain54.ToolMessage({
18527
+ return new import_langchain55.ToolMessage({
18001
18528
  content: `Added ${created.length} task(s) to team ${teamId}:
18002
18529
  ${summary}
18003
18530
  Sleeping teammates will wake up and claim these.`,
@@ -18048,20 +18575,20 @@ IMPORTANT: Assigning to a specific teammate
18048
18575
  })
18049
18576
  }
18050
18577
  );
18051
- const assignTaskTool = (0, import_langchain54.tool)(
18578
+ const assignTaskTool = (0, import_langchain55.tool)(
18052
18579
  async (input, config) => {
18053
18580
  const teamId = resolveTeamId();
18054
18581
  const task = await taskListStore.updateTask(teamId, input.task_id, {
18055
18582
  assignee: input.assignee
18056
18583
  });
18057
18584
  if (!task) {
18058
- return new import_langchain54.ToolMessage({
18585
+ return new import_langchain55.ToolMessage({
18059
18586
  content: `Task ${input.task_id} not found in team ${teamId}.`,
18060
18587
  tool_call_id: config.toolCall?.id,
18061
18588
  name: "assign_task"
18062
18589
  });
18063
18590
  }
18064
- return new import_langchain54.ToolMessage({
18591
+ return new import_langchain55.ToolMessage({
18065
18592
  content: `Task "${task.title}" (${task.id}) assigned to ${input.assignee}.`,
18066
18593
  tool_call_id: config.toolCall?.id,
18067
18594
  name: "assign_task"
@@ -18076,20 +18603,20 @@ IMPORTANT: Assigning to a specific teammate
18076
18603
  })
18077
18604
  }
18078
18605
  );
18079
- const setTaskStatusTool = (0, import_langchain54.tool)(
18606
+ const setTaskStatusTool = (0, import_langchain55.tool)(
18080
18607
  async (input, config) => {
18081
18608
  const teamId = resolveTeamId();
18082
18609
  const task = await taskListStore.updateTask(teamId, input.task_id, {
18083
18610
  status: input.status
18084
18611
  });
18085
18612
  if (!task) {
18086
- return new import_langchain54.ToolMessage({
18613
+ return new import_langchain55.ToolMessage({
18087
18614
  content: `Task ${input.task_id} not found in team ${teamId}.`,
18088
18615
  tool_call_id: config.toolCall?.id,
18089
18616
  name: "set_task_status"
18090
18617
  });
18091
18618
  }
18092
- return new import_langchain54.ToolMessage({
18619
+ return new import_langchain55.ToolMessage({
18093
18620
  content: `Task "${task.title}" (${task.id}) status set to ${input.status}.`,
18094
18621
  tool_call_id: config.toolCall?.id,
18095
18622
  name: "set_task_status"
@@ -18104,20 +18631,20 @@ IMPORTANT: Assigning to a specific teammate
18104
18631
  })
18105
18632
  }
18106
18633
  );
18107
- const setTaskDependenciesTool = (0, import_langchain54.tool)(
18634
+ const setTaskDependenciesTool = (0, import_langchain55.tool)(
18108
18635
  async (input, config) => {
18109
18636
  const teamId = resolveTeamId();
18110
18637
  const task = await taskListStore.updateTask(teamId, input.task_id, {
18111
18638
  dependencies: input.dependencies
18112
18639
  });
18113
18640
  if (!task) {
18114
- return new import_langchain54.ToolMessage({
18641
+ return new import_langchain55.ToolMessage({
18115
18642
  content: `Task ${input.task_id} not found in team ${teamId}.`,
18116
18643
  tool_call_id: config.toolCall?.id,
18117
18644
  name: "set_task_dependencies"
18118
18645
  });
18119
18646
  }
18120
- return new import_langchain54.ToolMessage({
18647
+ return new import_langchain55.ToolMessage({
18121
18648
  content: `Task "${task.title}" (${task.id}) dependencies set to [${input.dependencies.join(", ")}].`,
18122
18649
  tool_call_id: config.toolCall?.id,
18123
18650
  name: "set_task_dependencies"
@@ -18132,7 +18659,7 @@ IMPORTANT: Assigning to a specific teammate
18132
18659
  })
18133
18660
  }
18134
18661
  );
18135
- const checkTasksTool = (0, import_langchain54.tool)(
18662
+ const checkTasksTool = (0, import_langchain55.tool)(
18136
18663
  async (input, config) => {
18137
18664
  const teamId = resolveTeamId();
18138
18665
  const tasks = await taskListStore.getAllTasks(teamId);
@@ -18141,7 +18668,7 @@ IMPORTANT: Assigning to a specific teammate
18141
18668
  update: {
18142
18669
  tasks: tasksSnapshot,
18143
18670
  messages: [
18144
- new import_langchain54.ToolMessage({
18671
+ new import_langchain55.ToolMessage({
18145
18672
  content: formatTaskSummary(tasks),
18146
18673
  tool_call_id: config.toolCall?.id,
18147
18674
  name: "check_tasks"
@@ -18177,7 +18704,7 @@ Task Status Values:
18177
18704
  })
18178
18705
  }
18179
18706
  );
18180
- const sendMessageTool = (0, import_langchain54.tool)(
18707
+ const sendMessageTool = (0, import_langchain55.tool)(
18181
18708
  async (input, config) => {
18182
18709
  const teamId = resolveTeamId();
18183
18710
  await mailboxStore.sendMessage(
@@ -18187,7 +18714,7 @@ Task Status Values:
18187
18714
  input.content,
18188
18715
  "direct_message" /* DIRECT_MESSAGE */
18189
18716
  );
18190
- return new import_langchain54.ToolMessage({
18717
+ return new import_langchain55.ToolMessage({
18191
18718
  content: `Message sent to ${input.to}.`,
18192
18719
  tool_call_id: config.toolCall?.id,
18193
18720
  name: "send_message"
@@ -18202,7 +18729,7 @@ Task Status Values:
18202
18729
  })
18203
18730
  }
18204
18731
  );
18205
- const readMessagesTool = (0, import_langchain54.tool)(
18732
+ const readMessagesTool = (0, import_langchain55.tool)(
18206
18733
  async (input, config) => {
18207
18734
  const teamId = resolveTeamId();
18208
18735
  const formatAndMarkAsRead = async (msgs2) => {
@@ -18230,7 +18757,7 @@ Task Status Values:
18230
18757
  if (msgs.length > 0) {
18231
18758
  const formatted2 = await formatAndMarkAsRead(msgs);
18232
18759
  const allTeamMessages2 = await getAllTeamMessagesForState();
18233
- const toolMessage2 = new import_langchain54.ToolMessage({
18760
+ const toolMessage2 = new import_langchain55.ToolMessage({
18234
18761
  content: formatted2,
18235
18762
  tool_call_id: config.toolCall?.id,
18236
18763
  name: "read_messages"
@@ -18262,7 +18789,7 @@ Task Status Values:
18262
18789
  );
18263
18790
  const allTeamMessages = await getAllTeamMessagesForState();
18264
18791
  if (msgs.length === 0) {
18265
- const toolMessage2 = new import_langchain54.ToolMessage({
18792
+ const toolMessage2 = new import_langchain55.ToolMessage({
18266
18793
  content: "No unread messages from teammates.",
18267
18794
  tool_call_id: config.toolCall?.id,
18268
18795
  name: "read_messages"
@@ -18272,7 +18799,7 @@ Task Status Values:
18272
18799
  });
18273
18800
  }
18274
18801
  const formatted = await formatAndMarkAsRead(msgs);
18275
- const toolMessage = new import_langchain54.ToolMessage({
18802
+ const toolMessage = new import_langchain55.ToolMessage({
18276
18803
  content: formatted,
18277
18804
  tool_call_id: config.toolCall?.id,
18278
18805
  name: "read_messages"
@@ -18289,7 +18816,7 @@ Task Status Values:
18289
18816
  })
18290
18817
  }
18291
18818
  );
18292
- const disbandTeamTool = (0, import_langchain54.tool)(
18819
+ const disbandTeamTool = (0, import_langchain55.tool)(
18293
18820
  async (input, config) => {
18294
18821
  const teamId = resolveTeamId();
18295
18822
  await mailboxStore.broadcastMessage(
@@ -18299,7 +18826,7 @@ Task Status Values:
18299
18826
  "shutdown_request" /* SHUTDOWN_REQUEST */
18300
18827
  );
18301
18828
  await new Promise((r) => setTimeout(r, 2e3));
18302
- return new import_langchain54.ToolMessage({
18829
+ return new import_langchain55.ToolMessage({
18303
18830
  content: `Team ${teamId} has been disbanded. All teammates notified and resources cleaned up.`,
18304
18831
  tool_call_id: config.toolCall?.id,
18305
18832
  name: "disband_team"
@@ -18310,7 +18837,7 @@ Task Status Values:
18310
18837
  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."
18311
18838
  }
18312
18839
  );
18313
- const broadcastMessageTool = (0, import_langchain54.tool)(
18840
+ const broadcastMessageTool = (0, import_langchain55.tool)(
18314
18841
  async (input, config) => {
18315
18842
  const teamId = resolveTeamId();
18316
18843
  await mailboxStore.broadcastMessage(
@@ -18319,7 +18846,7 @@ Task Status Values:
18319
18846
  input.content,
18320
18847
  "broadcast" /* BROADCAST */
18321
18848
  );
18322
- return new import_langchain54.ToolMessage({
18849
+ return new import_langchain55.ToolMessage({
18323
18850
  content: `Broadcast message sent to all teammates.`,
18324
18851
  tool_call_id: config.toolCall?.id,
18325
18852
  name: "broadcast_message"
@@ -18333,7 +18860,7 @@ Task Status Values:
18333
18860
  })
18334
18861
  }
18335
18862
  );
18336
- return (0, import_langchain54.createMiddleware)({
18863
+ return (0, import_langchain55.createMiddleware)({
18337
18864
  name: "teamMiddleware",
18338
18865
  tools: [
18339
18866
  createTeamTool,
@@ -18442,7 +18969,7 @@ function createAgentTeam(config) {
18442
18969
  ];
18443
18970
  const systemPrompt = config.systemPrompt + "\n\n" + TEAM_LEAD_BASE_PROMPT;
18444
18971
  const stateSchema2 = createReactAgentSchema(TEAM_STATE_SCHEMA);
18445
- return (0, import_langchain55.createAgent)({
18972
+ return (0, import_langchain56.createAgent)({
18446
18973
  model: config.model ?? "claude-sonnet-4-5-20250929",
18447
18974
  systemPrompt,
18448
18975
  tools: [],
@@ -18511,10 +19038,10 @@ var TeamAgentGraphBuilder = class {
18511
19038
 
18512
19039
  // src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
18513
19040
  var import_langgraph11 = require("@langchain/langgraph");
18514
- var import_messages3 = require("@langchain/core/messages");
19041
+ var import_messages4 = require("@langchain/core/messages");
18515
19042
 
18516
19043
  // src/services/a2a-client.ts
18517
- var import_uuid6 = require("uuid");
19044
+ var import_uuid7 = require("uuid");
18518
19045
  var A2ARemoteError = class extends Error {
18519
19046
  constructor(message, statusCode, body) {
18520
19047
  super(message);
@@ -18561,7 +19088,7 @@ var A2ARemoteClient = class {
18561
19088
  */
18562
19089
  async sendMessage(text) {
18563
19090
  await this.resolve();
18564
- const taskId = (0, import_uuid6.v4)();
19091
+ const taskId = (0, import_uuid7.v4)();
18565
19092
  const body = JSON.stringify({
18566
19093
  jsonrpc: "2.0",
18567
19094
  method: "tasks/send",
@@ -18687,7 +19214,7 @@ var RemoteAgentGraphBuilder = class {
18687
19214
  if (!text) {
18688
19215
  return {
18689
19216
  messages: [
18690
- new import_messages3.AIMessage("No text input provided to remote agent.")
19217
+ new import_messages4.AIMessage("No text input provided to remote agent.")
18691
19218
  ]
18692
19219
  };
18693
19220
  }
@@ -18698,13 +19225,13 @@ User request:
18698
19225
  ${text}` : text;
18699
19226
  const response = await client.sendMessage(fullPrompt);
18700
19227
  return {
18701
- messages: [new import_messages3.AIMessage(response)]
19228
+ messages: [new import_messages4.AIMessage(response)]
18702
19229
  };
18703
19230
  } catch (error) {
18704
19231
  const msg = error.message ?? String(error);
18705
19232
  return {
18706
19233
  messages: [
18707
- new import_messages3.AIMessage(`Remote A2A agent error: ${msg}`)
19234
+ new import_messages4.AIMessage(`Remote A2A agent error: ${msg}`)
18708
19235
  ]
18709
19236
  };
18710
19237
  }
@@ -18731,7 +19258,7 @@ function extractLastHumanMessage(messages) {
18731
19258
  }
18732
19259
 
18733
19260
  // src/agent_lattice/builders/WorkflowAgentGraphBuilder.ts
18734
- var import_langchain56 = require("langchain");
19261
+ var import_langchain57 = require("langchain");
18735
19262
  init_MemoryLatticeManager();
18736
19263
  var import_protocols10 = require("@axiom-lattice/protocols");
18737
19264
  init_compile();
@@ -18796,7 +19323,7 @@ var WorkflowAgentGraphBuilder = class {
18796
19323
  const noWrapMiddlewares = stripWrapModelCallHook(middlewares);
18797
19324
  const noWrapAskMiddlewares = stripWrapModelCallHook(askMiddlewares);
18798
19325
  console.log(`[WF BUILDER] building default agent | toolCount=${tools.length} | middlewareCount=${middlewares.length}`);
18799
- const defaultAgent = (0, import_langchain56.createAgent)({
19326
+ const defaultAgent = (0, import_langchain57.createAgent)({
18800
19327
  model: params.model,
18801
19328
  tools,
18802
19329
  systemPrompt: buildStepSystemPrompt(false, params.prompt),
@@ -18816,7 +19343,7 @@ var WorkflowAgentGraphBuilder = class {
18816
19343
  console.log(`[WF BUILDER] resolveAgent: cacheKey=${key4.slice(0, 80)}... | cached=${agentCache.has(key4)}`);
18817
19344
  if (!agentCache.has(key4)) {
18818
19345
  console.log(`[WF BUILDER] creating ${isAsk ? "ask" : "agent"} with responseFormat`);
18819
- const agent = (0, import_langchain56.createAgent)({
19346
+ const agent = (0, import_langchain57.createAgent)({
18820
19347
  model: params.model,
18821
19348
  tools,
18822
19349
  systemPrompt: buildStepSystemPrompt(isAsk, params.prompt),
@@ -18832,7 +19359,7 @@ var WorkflowAgentGraphBuilder = class {
18832
19359
  const key4 = "ask:default";
18833
19360
  if (!agentCache.has(key4)) {
18834
19361
  console.log(`[WF BUILDER] creating ask default agent`);
18835
- const agent = (0, import_langchain56.createAgent)({
19362
+ const agent = (0, import_langchain57.createAgent)({
18836
19363
  model: params.model,
18837
19364
  tools,
18838
19365
  systemPrompt: buildStepSystemPrompt(true, params.prompt),
@@ -19351,6 +19878,22 @@ async function configureStores(stores, options = {}) {
19351
19878
  storeLatticeManager.registerLattice("default", t, store);
19352
19879
  }
19353
19880
  }
19881
+ if (options.discoverPlugins) {
19882
+ const pluginTypes = PluginRegistry.list();
19883
+ for (const pluginType of pluginTypes) {
19884
+ const plugin = PluginRegistry.get(pluginType);
19885
+ if (!plugin?.stores) continue;
19886
+ for (const [storeType, storeOrFactory] of Object.entries(plugin.stores)) {
19887
+ const store = typeof storeOrFactory === "function" ? storeOrFactory() : storeOrFactory;
19888
+ await initAndRegister(store, localDisposables);
19889
+ const t = storeType;
19890
+ if (storeLatticeManager.hasLattice("default", t)) {
19891
+ storeLatticeManager.removeLattice("default", t);
19892
+ }
19893
+ storeLatticeManager.registerLattice("default", t, store);
19894
+ }
19895
+ }
19896
+ }
19354
19897
  if (options.autoDisposeStores) {
19355
19898
  registerSignalCleanup();
19356
19899
  _disposables.push(...localDisposables);
@@ -19495,7 +20038,7 @@ description: Create new skills, modify and improve existing skills. Use this ski
19495
20038
  license: MIT
19496
20039
  metadata:
19497
20040
  category: meta
19498
- version: "2.0"
20041
+ version: "3.0"
19499
20042
  ---
19500
20043
 
19501
20044
  # Skill Creator
@@ -19594,6 +20137,160 @@ Instructional content for the agent.
19594
20137
 
19595
20138
  ---
19596
20139
 
20140
+ ## subSkills: Building the Skill Graph
20141
+
20142
+ \`subSkills\` is how skills reference each other. It forms a graph \u2014
20143
+ visualized in the Skills view as connected nodes.
20144
+
20145
+ ### What subSkills Means
20146
+
20147
+ It declares: "this skill is conceptually composed of these sub-skills."
20148
+ It does NOT mean the agent automatically loads them. The agent reads the
20149
+ body and decides what to load next.
20150
+
20151
+ ### When to Use subSkills
20152
+
20153
+ **YES \u2014 split into subSkills when another task would independently
20154
+ reference that piece.** The test:
20155
+
20156
+ > "Will a future learning task about a DIFFERENT document type
20157
+ > need to reference this?"
20158
+
20159
+ For example:
20160
+ - \`engine-selection\` \u2192 YES, PO extraction AND invoice extraction both need it
20161
+ - \`sap-bp-validation\` \u2192 YES, multiple tasks validate BP through SAP
20162
+ - \`po-bp-extraction\` \u2192 NO, nobody extracts BP without extracting the whole PO
20163
+
20164
+ **NO \u2014 keep in one file when the steps are a single pipeline that's
20165
+ always used together.** Field extraction, validation, and formatting
20166
+ for one document type belong in one skill file.
20167
+
20168
+ ### Examples
20169
+
20170
+ Good (shared skills split out):
20171
+ \`\`\`yaml
20172
+ ---
20173
+ name: po-extraction
20174
+ description: Extract BP, items, notes from PO PDFs with SAP validation
20175
+ subSkills:
20176
+ - engine-selection # Shared \u2014 also used by invoice-extraction
20177
+ ---
20178
+ # Body describes the full PO extraction flow:
20179
+ # 1. Use [[engine-selection]] to pick best parser
20180
+ # 2. Find BP in document header
20181
+ # 3. Parse items table
20182
+ # ...
20183
+
20184
+ ---
20185
+ name: engine-selection
20186
+ description: Choose the best parsing engine based on document type
20187
+ ---
20188
+ # Body describes decision logic with confidence scores
20189
+ \`\`\`
20190
+
20191
+ Bad (over-split \u2014 these are never used independently):
20192
+ \`\`\`yaml
20193
+ ---
20194
+ name: po-bp-extraction
20195
+ description: Extract BP field from PO
20196
+ subSkills: []
20197
+ ---
20198
+ # This is always used with items-extraction and notes-extraction.
20199
+ # They should be one skill: po-extraction
20200
+ \`\`\`
20201
+
20202
+ ### Growing the Graph
20203
+
20204
+ Skills are discovered incrementally. When a learning task produces
20205
+ new knowledge:
20206
+
20207
+ 1. \`ls /root/.agents/knowledge/\` to see what already exists
20208
+ 2. If a reusable piece already exists \u2192 reference it via subSkills
20209
+ 3. If a reusable piece doesn't exist \u2192 create it, then reference it
20210
+ 4. If it's not reusable \u2192 keep it in the parent skill's body
20211
+
20212
+ The graph grows naturally \u2014 each new learning task adds nodes
20213
+ and edges by creating skills and declaring subSkills.
20214
+
20215
+ ---
20216
+
20217
+ ## Verifying subSkills Are Correct
20218
+
20219
+ After writing the body, check consistency between frontmatter and content.
20220
+ You MUST run these checks before finalizing the skill.
20221
+
20222
+ ### Self-Check Rules
20223
+
20224
+ **For each entry in subSkills:**
20225
+ Find where in the body it's actually referenced. If you can't find it \u2014
20226
+ either the body is missing the reference, or the subSkill shouldn't
20227
+ be there.
20228
+
20229
+ **For each skill referenced in the body:**
20230
+ Check that it appears in subSkills. If the body references a skill
20231
+ but subSkills doesn't list it \u2014 add it.
20232
+
20233
+ ### Automated Consistency Check
20234
+
20235
+ Since body references use \`[[skill-name]]\` format, you can verify
20236
+ automatically:
20237
+
20238
+ \`\`\`bash
20239
+ # Extract all skill references from body
20240
+ grep -oE '\\[\\[[^]]+\\]\\]' /root/.agents/skills/{skill-name}/SKILL.md \\
20241
+ | sed 's/\\[\\[//;s/\\]\\]//' | sort -u
20242
+
20243
+ # Then compare with the subSkills list in frontmatter.
20244
+ # Every [[ref]] in body should have a corresponding subSkills entry.
20245
+ # Every subSkills entry should appear as [[ref]] somewhere in body.
20246
+ \`\`\`
20247
+
20248
+ ### Quick Checklist Before Writing
20249
+
20250
+ 1. List all subSkills in frontmatter
20251
+ 2. grep the body for each name using \`[[name]]\` format \u2014 does it appear?
20252
+ 3. grep the body for \`[[...]]\` patterns \u2014 are they all in subSkills?
20253
+ 4. Mismatches \u2192 fix either the body or the frontmatter
20254
+ 5. Remove any subSkills entry that's never referenced in the body
20255
+
20256
+ ---
20257
+
20258
+ ## Referencing Other Skills in the Body
20259
+
20260
+ When the body instructs the agent to consult another skill,
20261
+ use the \`[[skill-name]]\` format:
20262
+
20263
+ \`\`\`markdown
20264
+ ## Procedure
20265
+
20266
+ 1. First, use [[engine-selection]] to pick the best parsing engine
20267
+ 2. Load [[sap-bp-validation]] to verify the extracted Business Partner
20268
+ 3. For edge cases, refer to [[ocr-fallback]]
20269
+
20270
+ ## Dependencies
20271
+
20272
+ This skill depends on:
20273
+ - [[engine-selection]] \u2014 chooses the parsing engine
20274
+ - [[sap-bp-validation]] \u2014 validates BP codes against SAP
20275
+ \`\`\`
20276
+
20277
+ ### Why [[wiki-links]]
20278
+
20279
+ - **Visually distinct** \u2014 clearly not regular text
20280
+ - **Grepable** \u2014 \`grep -o '\\[\\[.*?\\]\\]'\` extracts all references
20281
+ - **Verifiable** \u2014 the consistency check against subSkills can be automated
20282
+ - **Human-readable** \u2014 anyone reading the SKILL.md knows this is a skill reference
20283
+
20284
+ ### Rules
20285
+ - Always use the exact skill name (kebab-case) inside \`[[]]\`
20286
+ - Before writing, check each referenced skill:
20287
+ - If it exists \u2014 reference it directly
20288
+ - If it doesn't exist \u2014 create it first, then reference it in the parent
20289
+ - Every \`[[ref]]\` in the body must have a corresponding \`subSkills\` entry
20290
+ - Every \`subSkills\` entry must appear as \`[[ref]]\` somewhere in the body
20291
+
20292
+ ---
20293
+
19597
20294
  ## Writing Guide
19598
20295
 
19599
20296
  ### The Description Field
@@ -19644,6 +20341,7 @@ A well-written skill body typically includes:
19644
20341
  - **Guidelines**: Rules, constraints, quality standards, and the WHY behind them
19645
20342
  - **Scenarios**: 2-3 common scenarios with concrete examples of inputs and expected outputs
19646
20343
  - **Edge cases**: What to do when things go wrong, when data is missing, etc.
20344
+ - **Skill references**: Use \`[[skill-name]]\` to reference other skills \u2014 see the subSkills section above
19647
20345
 
19648
20346
  ---
19649
20347
 
@@ -19651,10 +20349,11 @@ A well-written skill body typically includes:
19651
20349
 
19652
20350
  After writing the draft, test it:
19653
20351
 
19654
- 1. **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?"
19655
- 2. **Run the skill** against each test prompt to see what the agent produces
19656
- 3. **Review outputs with the user**: evaluate both qualitatively (does the output look right?) and quantitatively (did it follow the workflow? use the right tools?)
19657
- 4. **Collect feedback**: What worked? What didn't? What surprised the user?
20352
+ 1. **Run the consistency check** from the Verifying subSkills section \u2014 fix any mismatches
20353
+ 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?"
20354
+ 3. **Run the skill** against each test prompt to see what the agent produces
20355
+ 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?)
20356
+ 5. **Collect feedback**: What worked? What didn't? What surprised the user?
19658
20357
 
19659
20358
  ### Improving the Skill
19660
20359
 
@@ -19690,10 +20389,11 @@ The agent sees skills as a list of name + description pairs. It decides whether
19690
20389
  ## Step 6: Package and Present
19691
20390
 
19692
20391
  When the skill is ready:
19693
- 1. Verify the SKILL.md is at \`/root/.agents/skills/{skill-name}/SKILL.md\` with correct frontmatter
19694
- 2. Confirm all resource files are in place under \`resources/\`
19695
- 3. Tell the user the skill is ready and available at its path
19696
- 4. Remind them that the skill will now appear in the available skills list for any agent using the skill system
20392
+ 1. Run the subSkills consistency check one final time
20393
+ 2. Verify the SKILL.md is at \`/root/.agents/skills/{skill-name}/SKILL.md\` with correct frontmatter
20394
+ 3. Confirm all resource files are in place under \`resources/\`
20395
+ 4. Tell the user the skill is ready and available at its path
20396
+ 5. Remind them that the skill will now appear in the available skills list for any agent using the skill system
19697
20397
 
19698
20398
  ## Updating Existing Skills
19699
20399
 
@@ -19702,7 +20402,8 @@ When the user wants to improve an existing skill:
19702
20402
  2. Understand what it currently does and where it falls short
19703
20403
  3. Follow the same interview \u2192 draft \u2192 test \u2192 iterate loop
19704
20404
  4. **Preserve the original name** \u2014 the directory name and \`name\` frontmatter field should stay the same
19705
- 5. Write the updated version back to the same path
20405
+ 5. Run the subSkills consistency check after making changes
20406
+ 6. Write the updated version back to the same path
19706
20407
 
19707
20408
  ---
19708
20409
 
@@ -19736,6 +20437,8 @@ metadata:
19736
20437
 
19737
20438
  **You** (write): Create \`/root/.agents/skills/csv-analyzer/SKILL.md\`
19738
20439
 
20440
+ **You** (verify): Run the subSkills consistency check \u2014 no subSkills, no \`[[refs]]\`, all good.
20441
+
19739
20442
  **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."
19740
20443
 
19741
20444
  Then iterate based on what the user says.
@@ -20795,8 +21498,8 @@ var InMemoryMenuStore = class {
20795
21498
  };
20796
21499
 
20797
21500
  // src/agent_lattice/agentArchitectTools.ts
20798
- var import_zod47 = __toESM(require("zod"));
20799
- var import_uuid7 = require("uuid");
21501
+ var import_zod48 = __toESM(require("zod"));
21502
+ var import_uuid8 = require("uuid");
20800
21503
  var import_protocols12 = require("@axiom-lattice/protocols");
20801
21504
  function getTenantId(exeConfig) {
20802
21505
  const runConfig = exeConfig?.configurable?.runConfig || {};
@@ -20825,7 +21528,7 @@ registerToolLattice(
20825
21528
  {
20826
21529
  name: "list_agents",
20827
21530
  description: "List all agents for the current workspace. Returns a summary with id, name, description, and type for each agent.",
20828
- schema: import_zod47.default.object({})
21531
+ schema: import_zod48.default.object({})
20829
21532
  },
20830
21533
  async (_input, exeConfig) => {
20831
21534
  try {
@@ -20852,8 +21555,8 @@ registerToolLattice(
20852
21555
  {
20853
21556
  name: "get_agent",
20854
21557
  description: "Get the full configuration of a specific agent by its ID. Returns the complete AgentConfig including prompt, middleware, tools, and sub-agents.",
20855
- schema: import_zod47.default.object({
20856
- id: import_zod47.default.string().describe("The agent ID to retrieve")
21558
+ schema: import_zod48.default.object({
21559
+ id: import_zod48.default.string().describe("The agent ID to retrieve")
20857
21560
  })
20858
21561
  },
20859
21562
  async (input, exeConfig) => {
@@ -20870,24 +21573,24 @@ registerToolLattice(
20870
21573
  }
20871
21574
  }
20872
21575
  );
20873
- var middlewareConfigSchema = import_zod47.default.object({
20874
- id: import_zod47.default.string(),
20875
- type: import_zod47.default.string(),
20876
- name: import_zod47.default.string(),
20877
- description: import_zod47.default.string(),
20878
- enabled: import_zod47.default.boolean(),
20879
- config: import_zod47.default.record(import_zod47.default.any()).optional()
21576
+ var middlewareConfigSchema = import_zod48.default.object({
21577
+ id: import_zod48.default.string(),
21578
+ type: import_zod48.default.string(),
21579
+ name: import_zod48.default.string(),
21580
+ description: import_zod48.default.string(),
21581
+ enabled: import_zod48.default.boolean(),
21582
+ config: import_zod48.default.record(import_zod48.default.any()).optional()
20880
21583
  });
20881
- var createAgentSchema = import_zod47.default.object({
20882
- name: import_zod47.default.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')."),
20883
- description: import_zod47.default.string().optional().describe("Short description"),
20884
- type: import_zod47.default.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."),
20885
- prompt: import_zod47.default.string().describe("System prompt for the agent"),
20886
- tools: import_zod47.default.array(import_zod47.default.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."),
20887
- middleware: import_zod47.default.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: {}."),
20888
- subAgents: import_zod47.default.array(import_zod47.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
20889
- internalSubAgents: import_zod47.default.array(import_zod47.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
20890
- modelKey: import_zod47.default.string().optional().describe("Model key to use")
21584
+ var createAgentSchema = import_zod48.default.object({
21585
+ name: import_zod48.default.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')."),
21586
+ description: import_zod48.default.string().optional().describe("Short description"),
21587
+ type: import_zod48.default.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."),
21588
+ prompt: import_zod48.default.string().describe("System prompt for the agent"),
21589
+ tools: import_zod48.default.array(import_zod48.default.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."),
21590
+ middleware: import_zod48.default.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: {}."),
21591
+ subAgents: import_zod48.default.array(import_zod48.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
21592
+ internalSubAgents: import_zod48.default.array(import_zod48.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
21593
+ modelKey: import_zod48.default.string().optional().describe("Model key to use")
20891
21594
  });
20892
21595
  registerToolLattice(
20893
21596
  "create_agent",
@@ -20925,14 +21628,14 @@ registerToolLattice(
20925
21628
  }
20926
21629
  }
20927
21630
  );
20928
- var createWorkflowSchema = import_zod47.default.object({
20929
- name: import_zod47.default.string().describe("Display name for the workflow agent"),
20930
- description: import_zod47.default.string().optional().describe("Short description"),
20931
- skillLoaded: import_zod47.default.literal(true).describe("MUST be true. Set after loading the 'create-workflow' skill."),
20932
- yaml: import_zod47.default.string().describe("The YAML workflow definition in linear DSL format (steps execute top-to-bottom, use parallel: for concurrency)"),
20933
- tools: import_zod47.default.array(import_zod47.default.string()).optional().describe("Tool keys for the workflow agent"),
20934
- middleware: import_zod47.default.array(middlewareConfigSchema).optional().describe("Middleware configs"),
20935
- modelKey: import_zod47.default.string().optional().describe("Model key")
21631
+ var createWorkflowSchema = import_zod48.default.object({
21632
+ name: import_zod48.default.string().describe("Display name for the workflow agent"),
21633
+ description: import_zod48.default.string().optional().describe("Short description"),
21634
+ skillLoaded: import_zod48.default.literal(true).describe("MUST be true. Set after loading the 'create-workflow' skill."),
21635
+ yaml: import_zod48.default.string().describe("The YAML workflow definition in linear DSL format (steps execute top-to-bottom, use parallel: for concurrency)"),
21636
+ tools: import_zod48.default.array(import_zod48.default.string()).optional().describe("Tool keys for the workflow agent"),
21637
+ middleware: import_zod48.default.array(middlewareConfigSchema).optional().describe("Middleware configs"),
21638
+ modelKey: import_zod48.default.string().optional().describe("Model key")
20936
21639
  });
20937
21640
  registerToolLattice(
20938
21641
  "create_workflow",
@@ -20981,8 +21684,8 @@ registerToolLattice(
20981
21684
  {
20982
21685
  name: "validate_workflow",
20983
21686
  description: "Validate a workflow agent's DSL for correctness by compiling it.",
20984
- schema: import_zod47.default.object({
20985
- id: import_zod47.default.string().describe("The workflow agent ID to validate")
21687
+ schema: import_zod48.default.object({
21688
+ id: import_zod48.default.string().describe("The workflow agent ID to validate")
20986
21689
  })
20987
21690
  },
20988
21691
  async (input, exeConfig) => {
@@ -21079,14 +21782,14 @@ registerToolLattice(
21079
21782
  }
21080
21783
  }
21081
21784
  );
21082
- var updateWorkflowSchema = import_zod47.default.object({
21083
- id: import_zod47.default.string().describe("The workflow agent ID to update"),
21084
- name: import_zod47.default.string().optional().describe("New display name"),
21085
- description: import_zod47.default.string().optional().describe("New description"),
21086
- yaml: import_zod47.default.string().optional().describe("Replacement YAML workflow DSL. Omit to keep existing."),
21087
- tools: import_zod47.default.array(import_zod47.default.string()).optional().describe("Replacement tool keys"),
21088
- middleware: import_zod47.default.array(middlewareConfigSchema).optional().describe("Replacement middleware configs"),
21089
- modelKey: import_zod47.default.string().optional().describe("Replacement model key")
21785
+ var updateWorkflowSchema = import_zod48.default.object({
21786
+ id: import_zod48.default.string().describe("The workflow agent ID to update"),
21787
+ name: import_zod48.default.string().optional().describe("New display name"),
21788
+ description: import_zod48.default.string().optional().describe("New description"),
21789
+ yaml: import_zod48.default.string().optional().describe("Replacement YAML workflow DSL. Omit to keep existing."),
21790
+ tools: import_zod48.default.array(import_zod48.default.string()).optional().describe("Replacement tool keys"),
21791
+ middleware: import_zod48.default.array(middlewareConfigSchema).optional().describe("Replacement middleware configs"),
21792
+ modelKey: import_zod48.default.string().optional().describe("Replacement model key")
21090
21793
  });
21091
21794
  registerToolLattice(
21092
21795
  "update_workflow",
@@ -21147,18 +21850,18 @@ registerToolLattice(
21147
21850
  }
21148
21851
  }
21149
21852
  );
21150
- var updateAgentSchema = import_zod47.default.object({
21151
- id: import_zod47.default.string().describe("The agent ID to update"),
21152
- config: import_zod47.default.object({
21153
- name: import_zod47.default.string().optional().describe("New display name for the agent"),
21154
- description: import_zod47.default.string().optional().describe("New short description"),
21155
- type: import_zod47.default.enum(["react", "deep_agent"]).optional().describe("Agent type"),
21156
- prompt: import_zod47.default.string().optional().describe("New system prompt for the agent"),
21157
- tools: import_zod47.default.array(import_zod47.default.string()).optional().describe("Tool keys to assign to this agent. These are registered tool names (strings), NOT middleware objects."),
21158
- middleware: import_zod47.default.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: {}."),
21159
- subAgents: import_zod47.default.array(import_zod47.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
21160
- internalSubAgents: import_zod47.default.array(import_zod47.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
21161
- modelKey: import_zod47.default.string().optional().describe("Model key to use")
21853
+ var updateAgentSchema = import_zod48.default.object({
21854
+ id: import_zod48.default.string().describe("The agent ID to update"),
21855
+ config: import_zod48.default.object({
21856
+ name: import_zod48.default.string().optional().describe("New display name for the agent"),
21857
+ description: import_zod48.default.string().optional().describe("New short description"),
21858
+ type: import_zod48.default.enum(["react", "deep_agent"]).optional().describe("Agent type"),
21859
+ prompt: import_zod48.default.string().optional().describe("New system prompt for the agent"),
21860
+ tools: import_zod48.default.array(import_zod48.default.string()).optional().describe("Tool keys to assign to this agent. These are registered tool names (strings), NOT middleware objects."),
21861
+ middleware: import_zod48.default.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: {}."),
21862
+ subAgents: import_zod48.default.array(import_zod48.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
21863
+ internalSubAgents: import_zod48.default.array(import_zod48.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
21864
+ modelKey: import_zod48.default.string().optional().describe("Model key to use")
21162
21865
  }).describe("Configuration fields to update. Only include the fields you want to change.")
21163
21866
  });
21164
21867
  registerToolLattice(
@@ -21196,8 +21899,8 @@ registerToolLattice(
21196
21899
  {
21197
21900
  name: "delete_agent",
21198
21901
  description: "Permanently delete an agent by its ID. This action cannot be undone.",
21199
- schema: import_zod47.default.object({
21200
- id: import_zod47.default.string().describe("The agent ID to delete")
21902
+ schema: import_zod48.default.object({
21903
+ id: import_zod48.default.string().describe("The agent ID to delete")
21201
21904
  })
21202
21905
  },
21203
21906
  async (input, exeConfig) => {
@@ -21223,7 +21926,7 @@ registerToolLattice(
21223
21926
  {
21224
21927
  name: "list_tools",
21225
21928
  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.",
21226
- schema: import_zod47.default.object({})
21929
+ schema: import_zod48.default.object({})
21227
21930
  },
21228
21931
  async (_input, _exeConfig) => {
21229
21932
  try {
@@ -21245,9 +21948,9 @@ registerToolLattice(
21245
21948
  {
21246
21949
  name: "invoke_agent",
21247
21950
  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).",
21248
- schema: import_zod47.default.object({
21249
- id: import_zod47.default.string().describe("The agent ID to invoke"),
21250
- message: import_zod47.default.string().describe("The test message to send to the agent")
21951
+ schema: import_zod48.default.object({
21952
+ id: import_zod48.default.string().describe("The agent ID to invoke"),
21953
+ message: import_zod48.default.string().describe("The test message to send to the agent")
21251
21954
  })
21252
21955
  },
21253
21956
  async (input, exeConfig) => {
@@ -21262,7 +21965,7 @@ registerToolLattice(
21262
21965
  if (!existing) {
21263
21966
  return JSON.stringify({ error: `Agent '${id}' not found` });
21264
21967
  }
21265
- const threadId = (0, import_uuid7.v4)();
21968
+ const threadId = (0, import_uuid8.v4)();
21266
21969
  const agent = new Agent({
21267
21970
  tenant_id: tenantId2,
21268
21971
  assistant_id: id,
@@ -21283,7 +21986,7 @@ registerToolLattice(
21283
21986
  {
21284
21987
  name: "list_middleware_types",
21285
21988
  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",
21286
- schema: import_zod47.default.object({})
21989
+ schema: import_zod48.default.object({})
21287
21990
  },
21288
21991
  async () => {
21289
21992
  const metas = PluginRegistry.listMeta();
@@ -21295,8 +21998,8 @@ registerToolLattice(
21295
21998
  {
21296
21999
  name: "list_connections",
21297
22000
  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, ... }] } }",
21298
- schema: import_zod47.default.object({
21299
- type: import_zod47.default.string().describe("\u63D2\u4EF6\u7C7B\u578B\u6807\u8BC6\uFF0C\u5982 'erp'\u3002\u4ECE list_middleware_types \u7684\u8FD4\u56DE\u4E2D\u83B7\u53D6")
22001
+ schema: import_zod48.default.object({
22002
+ type: import_zod48.default.string().describe("\u63D2\u4EF6\u7C7B\u578B\u6807\u8BC6\uFF0C\u5982 'erp'\u3002\u4ECE list_middleware_types \u7684\u8FD4\u56DE\u4E2D\u83B7\u53D6")
21300
22003
  }),
21301
22004
  needUserApprove: false
21302
22005
  },
@@ -21877,6 +22580,20 @@ function ensureBuiltinAgentsForTenant(tenantId2) {
21877
22580
  }
21878
22581
  }
21879
22582
 
22583
+ // src/agent_lattice/pluginAgents.ts
22584
+ function ensurePluginAgentsForTenant(tenantId2) {
22585
+ const pluginTypes = PluginRegistry.list();
22586
+ for (const pluginType of pluginTypes) {
22587
+ const plugin = PluginRegistry.get(pluginType);
22588
+ if (!plugin?.agents) continue;
22589
+ for (const [key4, config] of Object.entries(plugin.agents)) {
22590
+ if (!agentLatticeManager.hasWithTenant(tenantId2, key4)) {
22591
+ agentLatticeManager.registerLatticeWithTenant(tenantId2, config);
22592
+ }
22593
+ }
22594
+ }
22595
+ }
22596
+
21880
22597
  // src/agent_lattice/AgentLatticeManager.ts
21881
22598
  function assistantToConfig(assistant) {
21882
22599
  const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? { ...assistant.graphDefinition } : {};
@@ -22075,6 +22792,7 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
22075
22792
  */
22076
22793
  async initializeStoredAssistantsForTenant(tenantId2) {
22077
22794
  ensureBuiltinAgentsForTenant(tenantId2);
22795
+ ensurePluginAgentsForTenant(tenantId2);
22078
22796
  try {
22079
22797
  const storeLattice = getStoreLattice("default", "assistant");
22080
22798
  const assistants = await storeLattice.store.getAllAssistants(tenantId2);
@@ -25254,8 +25972,8 @@ function clearEvalRunService() {
25254
25972
  }
25255
25973
 
25256
25974
  // src/eval_lattice/LatticeEval.ts
25257
- var import_messages5 = require("@langchain/core/messages");
25258
- var import_uuid8 = require("uuid");
25975
+ var import_messages6 = require("@langchain/core/messages");
25976
+ var import_uuid9 = require("uuid");
25259
25977
  var _LatticeEval = class _LatticeEval {
25260
25978
  constructor(config = {}) {
25261
25979
  this.inMemoryLogs = [];
@@ -25395,7 +26113,7 @@ var _LatticeEval = class _LatticeEval {
25395
26113
  }
25396
26114
  async evaluateCase(evalCase) {
25397
26115
  const startedAt = Date.now();
25398
- const threadId = `${evalCase.caseId}||${(0, import_uuid8.v4)()}`;
26116
+ const threadId = `${evalCase.caseId}||${(0, import_uuid9.v4)()}`;
25399
26117
  this.inMemoryLogs = [];
25400
26118
  this.lastThreadId = threadId;
25401
26119
  this.lastJudgeThreadId = void 0;
@@ -25537,7 +26255,7 @@ ${rubricsSection}
25537
26255
 
25538
26256
  \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`;
25539
26257
  this.lastTestPrompt = testPrompt;
25540
- const judgeThreadId = (0, import_uuid8.v4)();
26258
+ const judgeThreadId = (0, import_uuid9.v4)();
25541
26259
  this.lastJudgeThreadId = judgeThreadId;
25542
26260
  const judgeAgentKey = this.config.judge_agent_key || "LatticeTest";
25543
26261
  const judgeTenantId = this.config.tenant_id || "default";
@@ -25545,7 +26263,7 @@ ${rubricsSection}
25545
26263
  const judgeAgent = await getAgentClient(judgeTenantId, judgeAgentKey);
25546
26264
  const testResponse = await judgeAgent.invoke(
25547
26265
  {
25548
- messages: [new import_messages5.HumanMessage(testPrompt)]
26266
+ messages: [new import_messages6.HumanMessage(testPrompt)]
25549
26267
  },
25550
26268
  {
25551
26269
  configurable: {
@@ -26137,15 +26855,15 @@ function clearEncryptionKeyCache() {
26137
26855
  }
26138
26856
 
26139
26857
  // src/middlewares/skillMiddleware.ts
26140
- var import_langchain59 = require("langchain");
26858
+ var import_langchain60 = require("langchain");
26141
26859
 
26142
26860
  // src/tool_lattice/skill/load_skills.ts
26143
- var import_zod48 = __toESM(require("zod"));
26144
- var import_langchain57 = require("langchain");
26145
-
26146
- // src/tool_lattice/skill/load_skill_content.ts
26147
26861
  var import_zod49 = __toESM(require("zod"));
26148
26862
  var import_langchain58 = require("langchain");
26863
+
26864
+ // src/tool_lattice/skill/load_skill_content.ts
26865
+ var import_zod50 = __toESM(require("zod"));
26866
+ var import_langchain59 = require("langchain");
26149
26867
  var LOAD_SKILL_CONTENT_DESCRIPTION = `
26150
26868
  Execute a skill within the main conversation
26151
26869
 
@@ -26183,7 +26901,7 @@ function getSandboxFromExeConfig(_exe_config) {
26183
26901
  });
26184
26902
  }
26185
26903
  var createLoadSkillContentTool = (pluginSkillContents) => {
26186
- return (0, import_langchain58.tool)(
26904
+ return (0, import_langchain59.tool)(
26187
26905
  async (input, _exe_config) => {
26188
26906
  try {
26189
26907
  if (pluginSkillContents?.[input.skill_name]) {
@@ -26232,8 +26950,8 @@ var createLoadSkillContentTool = (pluginSkillContents) => {
26232
26950
  {
26233
26951
  name: "skill",
26234
26952
  description: LOAD_SKILL_CONTENT_DESCRIPTION,
26235
- schema: import_zod49.default.object({
26236
- skill_name: import_zod49.default.string().describe("The name of the skill to load")
26953
+ schema: import_zod50.default.object({
26954
+ skill_name: import_zod50.default.string().describe("The name of the skill to load")
26237
26955
  })
26238
26956
  }
26239
26957
  );
@@ -26247,7 +26965,7 @@ function createSkillMiddleware(params = {}) {
26247
26965
  } = params;
26248
26966
  const skills = params.skills;
26249
26967
  let latestSkills = [];
26250
- return (0, import_langchain59.createMiddleware)({
26968
+ return (0, import_langchain60.createMiddleware)({
26251
26969
  name: "skillMiddleware",
26252
26970
  contextSchema,
26253
26971
  tools: [
@@ -26379,17 +27097,17 @@ var skillPlugin = {
26379
27097
  };
26380
27098
 
26381
27099
  // src/middlewares/collectionMiddleware.ts
26382
- var import_langchain70 = require("langchain");
27100
+ var import_langchain71 = require("langchain");
26383
27101
 
26384
27102
  // src/tool_lattice/collection/list_collections.ts
26385
- var import_zod50 = __toESM(require("zod"));
26386
- var import_langchain60 = require("langchain");
27103
+ var import_zod51 = __toESM(require("zod"));
27104
+ var import_langchain61 = require("langchain");
26387
27105
  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.`;
26388
27106
  var createListCollectionsTool = ({
26389
27107
  collectionKeys,
26390
27108
  connectAll
26391
27109
  }) => {
26392
- return (0, import_langchain60.tool)(
27110
+ return (0, import_langchain61.tool)(
26393
27111
  async (_input, _exeConfig) => {
26394
27112
  try {
26395
27113
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26423,23 +27141,23 @@ var createListCollectionsTool = ({
26423
27141
  {
26424
27142
  name: "list_collections",
26425
27143
  description: LIST_COLLECTIONS_DESCRIPTION,
26426
- schema: import_zod50.default.object({})
27144
+ schema: import_zod51.default.object({})
26427
27145
  }
26428
27146
  );
26429
27147
  };
26430
27148
 
26431
27149
  // src/tool_lattice/collection/search_collection.ts
26432
- var import_zod51 = __toESM(require("zod"));
26433
- var import_langchain61 = require("langchain");
27150
+ var import_zod52 = __toESM(require("zod"));
27151
+ var import_langchain62 = require("langchain");
26434
27152
  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.`;
26435
- var searchSchema = import_zod51.default.object({
26436
- collection: import_zod51.default.string().describe("The collection name to search in"),
26437
- query: import_zod51.default.string().describe("The search query text"),
26438
- filter: import_zod51.default.record(import_zod51.default.unknown()).optional().describe("Metadata filter conditions"),
26439
- top_k: import_zod51.default.number().optional().default(5).describe("Number of results to return")
27153
+ var searchSchema = import_zod52.default.object({
27154
+ collection: import_zod52.default.string().describe("The collection name to search in"),
27155
+ query: import_zod52.default.string().describe("The search query text"),
27156
+ filter: import_zod52.default.record(import_zod52.default.unknown()).optional().describe("Metadata filter conditions"),
27157
+ top_k: import_zod52.default.number().optional().default(5).describe("Number of results to return")
26440
27158
  });
26441
27159
  var createSearchCollectionTool = () => {
26442
- return (0, import_langchain61.tool)(
27160
+ return (0, import_langchain62.tool)(
26443
27161
  async (input, _exeConfig) => {
26444
27162
  try {
26445
27163
  const { collection, query, filter: filter2, top_k } = input;
@@ -26489,10 +27207,10 @@ var createSearchCollectionTool = () => {
26489
27207
  };
26490
27208
 
26491
27209
  // src/tool_lattice/collection/get_collection.ts
26492
- var import_zod52 = __toESM(require("zod"));
26493
- var import_langchain62 = require("langchain");
27210
+ var import_zod53 = __toESM(require("zod"));
27211
+ var import_langchain63 = require("langchain");
26494
27212
  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.`;
26495
- var createGetCollectionTool = () => (0, import_langchain62.tool)(
27213
+ var createGetCollectionTool = () => (0, import_langchain63.tool)(
26496
27214
  async (input, _exeConfig) => {
26497
27215
  try {
26498
27216
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26515,24 +27233,24 @@ Embedding: ${c.embeddingKey}${fieldsDesc}`;
26515
27233
  return `Error: ${error.message}`;
26516
27234
  }
26517
27235
  },
26518
- { name: "get_collection", description: GET_COLLECTION_DESCRIPTION, schema: import_zod52.default.object({ name: import_zod52.default.string().describe("Collection name") }) }
27236
+ { name: "get_collection", description: GET_COLLECTION_DESCRIPTION, schema: import_zod53.default.object({ name: import_zod53.default.string().describe("Collection name") }) }
26519
27237
  );
26520
27238
 
26521
27239
  // src/tool_lattice/collection/create_collection.ts
26522
- var import_zod53 = __toESM(require("zod"));
26523
- var import_langchain63 = require("langchain");
26524
- var createSchema = import_zod53.default.object({
26525
- name: import_zod53.default.string().describe("Collection name (lowercase, underscores only)"),
26526
- label: import_zod53.default.string().describe("Display name"),
26527
- embeddingKey: import_zod53.default.string().describe("Embedding model key"),
26528
- fields: import_zod53.default.array(import_zod53.default.object({
26529
- key: import_zod53.default.string().describe("Field key name"),
26530
- type: import_zod53.default.enum(["string", "number", "enum"]).describe("Field data type"),
26531
- enumValues: import_zod53.default.array(import_zod53.default.string()).optional().describe("Valid values for enum type"),
26532
- required: import_zod53.default.boolean().optional().default(false).describe("Whether field is required")
27240
+ var import_zod54 = __toESM(require("zod"));
27241
+ var import_langchain64 = require("langchain");
27242
+ var createSchema = import_zod54.default.object({
27243
+ name: import_zod54.default.string().describe("Collection name (lowercase, underscores only)"),
27244
+ label: import_zod54.default.string().describe("Display name"),
27245
+ embeddingKey: import_zod54.default.string().describe("Embedding model key"),
27246
+ fields: import_zod54.default.array(import_zod54.default.object({
27247
+ key: import_zod54.default.string().describe("Field key name"),
27248
+ type: import_zod54.default.enum(["string", "number", "enum"]).describe("Field data type"),
27249
+ enumValues: import_zod54.default.array(import_zod54.default.string()).optional().describe("Valid values for enum type"),
27250
+ required: import_zod54.default.boolean().optional().default(false).describe("Whether field is required")
26533
27251
  })).optional().describe("Custom field definitions for entries in this collection")
26534
27252
  });
26535
- var createCreateCollectionTool = () => (0, import_langchain63.tool)(
27253
+ var createCreateCollectionTool = () => (0, import_langchain64.tool)(
26536
27254
  async (input, _exeConfig) => {
26537
27255
  try {
26538
27256
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26557,20 +27275,20 @@ var createCreateCollectionTool = () => (0, import_langchain63.tool)(
26557
27275
  );
26558
27276
 
26559
27277
  // src/tool_lattice/collection/update_collection.ts
26560
- var import_zod54 = __toESM(require("zod"));
26561
- var import_langchain64 = require("langchain");
26562
- var schema = import_zod54.default.object({
26563
- name: import_zod54.default.string().describe("Collection name"),
26564
- label: import_zod54.default.string().optional().describe("New display name"),
26565
- embeddingKey: import_zod54.default.string().optional().describe("New embedding model key"),
26566
- fields: import_zod54.default.array(import_zod54.default.object({
26567
- key: import_zod54.default.string().describe("Field key name"),
26568
- type: import_zod54.default.enum(["string", "number", "enum"]).describe("Field data type"),
26569
- enumValues: import_zod54.default.array(import_zod54.default.string()).optional().describe("Valid values for enum type"),
26570
- required: import_zod54.default.boolean().optional().default(false).describe("Whether field is required")
27278
+ var import_zod55 = __toESM(require("zod"));
27279
+ var import_langchain65 = require("langchain");
27280
+ var schema = import_zod55.default.object({
27281
+ name: import_zod55.default.string().describe("Collection name"),
27282
+ label: import_zod55.default.string().optional().describe("New display name"),
27283
+ embeddingKey: import_zod55.default.string().optional().describe("New embedding model key"),
27284
+ fields: import_zod55.default.array(import_zod55.default.object({
27285
+ key: import_zod55.default.string().describe("Field key name"),
27286
+ type: import_zod55.default.enum(["string", "number", "enum"]).describe("Field data type"),
27287
+ enumValues: import_zod55.default.array(import_zod55.default.string()).optional().describe("Valid values for enum type"),
27288
+ required: import_zod55.default.boolean().optional().default(false).describe("Whether field is required")
26571
27289
  })).optional().describe("Custom field definitions for entries (replaces existing schema)")
26572
27290
  });
26573
- var createUpdateCollectionTool = () => (0, import_langchain64.tool)(
27291
+ var createUpdateCollectionTool = () => (0, import_langchain65.tool)(
26574
27292
  async (input, _exeConfig) => {
26575
27293
  try {
26576
27294
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26589,9 +27307,9 @@ var createUpdateCollectionTool = () => (0, import_langchain64.tool)(
26589
27307
  );
26590
27308
 
26591
27309
  // src/tool_lattice/collection/delete_collection.ts
26592
- var import_zod55 = __toESM(require("zod"));
26593
- var import_langchain65 = require("langchain");
26594
- var createDeleteCollectionTool = () => (0, import_langchain65.tool)(
27310
+ var import_zod56 = __toESM(require("zod"));
27311
+ var import_langchain66 = require("langchain");
27312
+ var createDeleteCollectionTool = () => (0, import_langchain66.tool)(
26595
27313
  async (input, _exeConfig) => {
26596
27314
  try {
26597
27315
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26601,19 +27319,19 @@ var createDeleteCollectionTool = () => (0, import_langchain65.tool)(
26601
27319
  return `Error: ${e.message}`;
26602
27320
  }
26603
27321
  },
26604
- { name: "delete_collection", description: `Delete a collection and all its entries. This cannot be undone.`, schema: import_zod55.default.object({ name: import_zod55.default.string().describe("Collection name") }) }
27322
+ { name: "delete_collection", description: `Delete a collection and all its entries. This cannot be undone.`, schema: import_zod56.default.object({ name: import_zod56.default.string().describe("Collection name") }) }
26605
27323
  );
26606
27324
 
26607
27325
  // src/tool_lattice/collection/list_entries.ts
26608
- var import_zod56 = __toESM(require("zod"));
26609
- var import_langchain66 = require("langchain");
26610
- var schema2 = import_zod56.default.object({
26611
- collection: import_zod56.default.string().describe("Collection name")
27326
+ var import_zod57 = __toESM(require("zod"));
27327
+ var import_langchain67 = require("langchain");
27328
+ var schema2 = import_zod57.default.object({
27329
+ collection: import_zod57.default.string().describe("Collection name")
26612
27330
  });
26613
27331
  function buildKey2(tenantId2, name) {
26614
27332
  return `${tenantId2}:${name}`;
26615
27333
  }
26616
- var createListEntriesTool = () => (0, import_langchain66.tool)(
27334
+ var createListEntriesTool = () => (0, import_langchain67.tool)(
26617
27335
  async (input, _exeConfig) => {
26618
27336
  try {
26619
27337
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26640,24 +27358,24 @@ var createListEntriesTool = () => (0, import_langchain66.tool)(
26640
27358
  );
26641
27359
 
26642
27360
  // src/tool_lattice/collection/add_entry.ts
26643
- var import_zod57 = __toESM(require("zod"));
26644
- var import_langchain67 = require("langchain");
27361
+ var import_zod58 = __toESM(require("zod"));
27362
+ var import_langchain68 = require("langchain");
26645
27363
  var import_documents = require("@langchain/core/documents");
26646
- var import_uuid9 = require("uuid");
26647
- var schema3 = import_zod57.default.object({
26648
- collection: import_zod57.default.string().describe("Collection name"),
26649
- content: import_zod57.default.string().describe("Entry content text"),
26650
- metadata: import_zod57.default.record(import_zod57.default.unknown()).optional().describe("Metadata fields matching the collection schema")
27364
+ var import_uuid10 = require("uuid");
27365
+ var schema3 = import_zod58.default.object({
27366
+ collection: import_zod58.default.string().describe("Collection name"),
27367
+ content: import_zod58.default.string().describe("Entry content text"),
27368
+ metadata: import_zod58.default.record(import_zod58.default.unknown()).optional().describe("Metadata fields matching the collection schema")
26651
27369
  });
26652
27370
  function key(t, n) {
26653
27371
  return `${t}:${n}`;
26654
27372
  }
26655
- var createAddEntryTool = () => (0, import_langchain67.tool)(
27373
+ var createAddEntryTool = () => (0, import_langchain68.tool)(
26656
27374
  async (input, _exeConfig) => {
26657
27375
  try {
26658
27376
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
26659
27377
  const vs = vectorStoreLatticeManager.getVectorStoreClient(key(tenantId2, input.collection));
26660
- const id = (0, import_uuid9.v4)();
27378
+ const id = (0, import_uuid10.v4)();
26661
27379
  await vs.addDocuments([new import_documents.Document({
26662
27380
  pageContent: input.content,
26663
27381
  metadata: { _id: id, _created_at: (/* @__PURE__ */ new Date()).toISOString(), ...input.metadata || {} }
@@ -26671,18 +27389,18 @@ var createAddEntryTool = () => (0, import_langchain67.tool)(
26671
27389
  );
26672
27390
 
26673
27391
  // src/tool_lattice/collection/update_entry.ts
26674
- var import_zod58 = __toESM(require("zod"));
26675
- var import_langchain68 = require("langchain");
26676
- var schema4 = import_zod58.default.object({
26677
- collection: import_zod58.default.string().describe("Collection name"),
26678
- entryId: import_zod58.default.string().describe("Entry ID to update"),
26679
- content: import_zod58.default.string().optional().describe("New content"),
26680
- metadata: import_zod58.default.record(import_zod58.default.unknown()).optional().describe("New metadata")
27392
+ var import_zod59 = __toESM(require("zod"));
27393
+ var import_langchain69 = require("langchain");
27394
+ var schema4 = import_zod59.default.object({
27395
+ collection: import_zod59.default.string().describe("Collection name"),
27396
+ entryId: import_zod59.default.string().describe("Entry ID to update"),
27397
+ content: import_zod59.default.string().optional().describe("New content"),
27398
+ metadata: import_zod59.default.record(import_zod59.default.unknown()).optional().describe("New metadata")
26681
27399
  });
26682
27400
  function key2(t, n) {
26683
27401
  return `${t}:${n}`;
26684
27402
  }
26685
- var createUpdateEntryTool = () => (0, import_langchain68.tool)(
27403
+ var createUpdateEntryTool = () => (0, import_langchain69.tool)(
26686
27404
  async (input, _exeConfig) => {
26687
27405
  try {
26688
27406
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26701,16 +27419,16 @@ var createUpdateEntryTool = () => (0, import_langchain68.tool)(
26701
27419
  );
26702
27420
 
26703
27421
  // src/tool_lattice/collection/delete_entry.ts
26704
- var import_zod59 = __toESM(require("zod"));
26705
- var import_langchain69 = require("langchain");
26706
- var schema5 = import_zod59.default.object({
26707
- collection: import_zod59.default.string().describe("Collection name"),
26708
- entryId: import_zod59.default.string().describe("Entry ID to delete")
27422
+ var import_zod60 = __toESM(require("zod"));
27423
+ var import_langchain70 = require("langchain");
27424
+ var schema5 = import_zod60.default.object({
27425
+ collection: import_zod60.default.string().describe("Collection name"),
27426
+ entryId: import_zod60.default.string().describe("Entry ID to delete")
26709
27427
  });
26710
27428
  function key3(t, n) {
26711
27429
  return `${t}:${n}`;
26712
27430
  }
26713
- var createDeleteEntryTool = () => (0, import_langchain69.tool)(
27431
+ var createDeleteEntryTool = () => (0, import_langchain70.tool)(
26714
27432
  async (input, _exeConfig) => {
26715
27433
  try {
26716
27434
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26728,7 +27446,7 @@ var createDeleteEntryTool = () => (0, import_langchain69.tool)(
26728
27446
  function createCollectionMiddleware(params) {
26729
27447
  const { collectionKeys, connectAll } = params;
26730
27448
  if (!connectAll && (!collectionKeys || collectionKeys.length === 0)) {
26731
- return (0, import_langchain70.createMiddleware)({
27449
+ return (0, import_langchain71.createMiddleware)({
26732
27450
  name: "collectionMiddleware",
26733
27451
  contextSchema,
26734
27452
  tools: [
@@ -26738,7 +27456,7 @@ function createCollectionMiddleware(params) {
26738
27456
  });
26739
27457
  }
26740
27458
  const listToolParams = { collectionKeys, connectAll };
26741
- return (0, import_langchain70.createMiddleware)({
27459
+ return (0, import_langchain71.createMiddleware)({
26742
27460
  name: "collectionMiddleware",
26743
27461
  contextSchema,
26744
27462
  tools: [
@@ -26799,24 +27517,24 @@ var collectionPlugin = {
26799
27517
  };
26800
27518
 
26801
27519
  // src/middlewares/askUserClarifyMiddleware.ts
26802
- var import_langchain72 = require("langchain");
27520
+ var import_langchain73 = require("langchain");
26803
27521
  var import_langgraph14 = require("@langchain/langgraph");
26804
27522
 
26805
27523
  // src/tool_lattice/ask_user_to_clarify/index.ts
26806
- var import_langchain71 = require("langchain");
26807
- var import_zod60 = __toESM(require("zod"));
26808
- var questionSchema = import_zod60.default.object({
26809
- question: import_zod60.default.string().describe("The question text to ask the user"),
26810
- options: import_zod60.default.array(import_zod60.default.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."),
26811
- type: import_zod60.default.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."),
26812
- required: import_zod60.default.boolean().optional().default(false).describe("Whether this question must be answered"),
26813
- allowOther: import_zod60.default.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.")
27524
+ var import_langchain72 = require("langchain");
27525
+ var import_zod61 = __toESM(require("zod"));
27526
+ var questionSchema = import_zod61.default.object({
27527
+ question: import_zod61.default.string().describe("The question text to ask the user"),
27528
+ options: import_zod61.default.array(import_zod61.default.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."),
27529
+ type: import_zod61.default.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."),
27530
+ required: import_zod61.default.boolean().optional().default(false).describe("Whether this question must be answered"),
27531
+ allowOther: import_zod61.default.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.")
26814
27532
  });
26815
- var inputSchema = import_zod60.default.object({
26816
- questions: import_zod60.default.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.")
27533
+ var inputSchema = import_zod61.default.object({
27534
+ questions: import_zod61.default.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.")
26817
27535
  });
26818
27536
  function createAskUserToClarifyTool() {
26819
- return (0, import_langchain71.tool)(
27537
+ return (0, import_langchain72.tool)(
26820
27538
  async (input) => {
26821
27539
  return JSON.stringify(input);
26822
27540
  },
@@ -26830,7 +27548,7 @@ function createAskUserToClarifyTool() {
26830
27548
 
26831
27549
  // src/middlewares/askUserClarifyMiddleware.ts
26832
27550
  function createAskUserClarifyMiddleware() {
26833
- return (0, import_langchain72.createMiddleware)({
27551
+ return (0, import_langchain73.createMiddleware)({
26834
27552
  name: "AskUserClarifyMiddleware",
26835
27553
  tools: [createAskUserToClarifyTool()],
26836
27554
  wrapToolCall: async (request, handler) => {
@@ -26844,7 +27562,7 @@ function createAskUserClarifyMiddleware() {
26844
27562
  throw error;
26845
27563
  }
26846
27564
  console.error(`Error executing tool "${toolName}":`, error);
26847
- return new import_langchain72.ToolMessage({
27565
+ return new import_langchain73.ToolMessage({
26848
27566
  content: `Error executing tool: ${error instanceof Error ? error.message : "Unknown error"}`,
26849
27567
  tool_call_id: toolCall?.id,
26850
27568
  name: toolName
@@ -26853,7 +27571,7 @@ function createAskUserClarifyMiddleware() {
26853
27571
  }
26854
27572
  const parsed = inputSchema.safeParse(toolCall?.args);
26855
27573
  if (!parsed.success) {
26856
- return new import_langchain72.ToolMessage({
27574
+ return new import_langchain73.ToolMessage({
26857
27575
  content: `Invalid clarify tool arguments: ${parsed.error.message}`,
26858
27576
  tool_call_id: toolCall?.id,
26859
27577
  name: toolName
@@ -26873,7 +27591,7 @@ function createAskUserClarifyMiddleware() {
26873
27591
  const result = await (0, import_langgraph14.interrupt)(md);
26874
27592
  const response = result.data;
26875
27593
  if (!response?.answers || response.answers.length === 0) {
26876
- return new import_langchain72.ToolMessage({
27594
+ return new import_langchain73.ToolMessage({
26877
27595
  content: "No clarification questions were answered.",
26878
27596
  tool_call_id: toolCall?.id,
26879
27597
  name: toolName
@@ -26883,7 +27601,7 @@ function createAskUserClarifyMiddleware() {
26883
27601
  (answer) => (answer.selectedOptions?.length ?? 0) > 0 || answer.otherText && answer.otherText.trim() !== "" || answer.filePath && answer.filePath.trim() !== ""
26884
27602
  );
26885
27603
  if (answeredQuestions.length === 0) {
26886
- return new import_langchain72.ToolMessage({
27604
+ return new import_langchain73.ToolMessage({
26887
27605
  content: "No clarification questions were answered.",
26888
27606
  tool_call_id: toolCall?.id,
26889
27607
  name: toolName
@@ -26913,7 +27631,7 @@ function createAskUserClarifyMiddleware() {
26913
27631
  }
26914
27632
  lines.push("");
26915
27633
  }
26916
- return new import_langchain72.ToolMessage({
27634
+ return new import_langchain73.ToolMessage({
26917
27635
  content: lines.join("\n"),
26918
27636
  tool_call_id: toolCall?.id,
26919
27637
  name: toolName
@@ -26938,11 +27656,11 @@ var askUserClarifyPlugin = {
26938
27656
  };
26939
27657
 
26940
27658
  // src/middlewares/widgetMiddleware.ts
26941
- var import_langchain75 = require("langchain");
27659
+ var import_langchain76 = require("langchain");
26942
27660
 
26943
27661
  // src/tool_lattice/widget/loadGuidelines.ts
26944
- var import_langchain73 = require("langchain");
26945
- var import_zod61 = require("zod");
27662
+ var import_langchain74 = require("langchain");
27663
+ var import_zod62 = require("zod");
26946
27664
 
26947
27665
  // src/middlewares/guidelines/index.ts
26948
27666
  var CORE = `# Imagine \u2014 Visual Creation Suite
@@ -27733,13 +28451,13 @@ function getGuidelines(modules) {
27733
28451
  var AVAILABLE_MODULES = Object.keys(MODULE_SECTIONS);
27734
28452
 
27735
28453
  // src/tool_lattice/widget/loadGuidelines.ts
27736
- var LoadGuidelinesInputSchema = import_zod61.z.object({
27737
- modules: import_zod61.z.array(import_zod61.z.string()).describe(
28454
+ var LoadGuidelinesInputSchema = import_zod62.z.object({
28455
+ modules: import_zod62.z.array(import_zod62.z.string()).describe(
27738
28456
  "Which design modules to load. Choose all that apply. Available modules: [" + AVAILABLE_MODULES.join(",") + "]"
27739
28457
  )
27740
28458
  });
27741
28459
  function createLoadGuidelinesTool() {
27742
- return (0, import_langchain73.tool)(
28460
+ return (0, import_langchain74.tool)(
27743
28461
  async (input) => {
27744
28462
  const result = getGuidelines(input.modules);
27745
28463
  return result;
@@ -27753,8 +28471,8 @@ function createLoadGuidelinesTool() {
27753
28471
  }
27754
28472
 
27755
28473
  // src/tool_lattice/widget/showWidget.ts
27756
- var import_langchain74 = require("langchain");
27757
- var import_zod62 = require("zod");
28474
+ var import_langchain75 = require("langchain");
28475
+ var import_zod63 = require("zod");
27758
28476
  function containsForbiddenTags(code) {
27759
28477
  const forbiddenPatterns = [
27760
28478
  /<!DOCTYPE/i,
@@ -27776,20 +28494,20 @@ function validateWidgetCode(code) {
27776
28494
  }
27777
28495
  return { valid: true };
27778
28496
  }
27779
- var ShowWidgetInputSchema = import_zod62.z.object({
27780
- i_have_seen_guidelines: import_zod62.z.boolean().describe(
28497
+ var ShowWidgetInputSchema = import_zod63.z.object({
28498
+ i_have_seen_guidelines: import_zod63.z.boolean().describe(
27781
28499
  "Must be true. Confirm you have called load_guidelines first."
27782
28500
  ),
27783
- title: import_zod62.z.string().describe("Title displayed above the widget"),
27784
- loading_messages: import_zod62.z.array(import_zod62.z.string()).optional().describe(
28501
+ title: import_zod63.z.string().describe("Title displayed above the widget"),
28502
+ loading_messages: import_zod63.z.array(import_zod63.z.string()).optional().describe(
27785
28503
  "1-4 short strings shown while the widget renders"
27786
28504
  ),
27787
- widget_code: import_zod62.z.string().describe(
28505
+ widget_code: import_zod63.z.string().describe(
27788
28506
  "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."
27789
28507
  )
27790
28508
  });
27791
28509
  function createShowWidgetTool() {
27792
- return (0, import_langchain74.tool)(
28510
+ return (0, import_langchain75.tool)(
27793
28511
  async (input) => {
27794
28512
  if (!input.i_have_seen_guidelines) {
27795
28513
  return "Error: You must call load_guidelines before using show_widget. Set i_have_seen_guidelines to true only after loading guidelines.";
@@ -27820,7 +28538,7 @@ function createWidgetMiddleware() {
27820
28538
  createLoadGuidelinesTool(),
27821
28539
  createShowWidgetTool()
27822
28540
  ];
27823
- return (0, import_langchain75.createMiddleware)({
28541
+ return (0, import_langchain76.createMiddleware)({
27824
28542
  name: "widgetMiddleware",
27825
28543
  contextSchema,
27826
28544
  tools
@@ -27842,157 +28560,10 @@ var widgetPlugin = {
27842
28560
  middleware: () => createWidgetMiddleware()
27843
28561
  };
27844
28562
 
27845
- // src/middlewares/taskMiddleware.ts
27846
- var import_langchain76 = require("langchain");
27847
- var import_zod63 = require("zod");
27848
- function getRunConfig2(config) {
27849
- const c = config;
27850
- return c?.configurable?.runConfig ?? {};
27851
- }
27852
- function getTaskStore() {
27853
- return getStoreLattice("default", "task").store;
27854
- }
27855
- var manageTaskSchema = import_zod63.z.object({
27856
- action: import_zod63.z.enum(["create", "list", "update", "delete", "complete"]).describe("\u64CD\u4F5C\u7C7B\u578B"),
27857
- id: import_zod63.z.string().optional().describe("\u4EFB\u52A1 ID (update/delete/complete \u5FC5\u586B)"),
27858
- title: import_zod63.z.string().optional().describe("\u4EFB\u52A1\u6807\u9898 (create \u5FC5\u586B)"),
27859
- description: import_zod63.z.string().optional().describe("\u4EFB\u52A1\u63CF\u8FF0"),
27860
- priority: import_zod63.z.enum(["low", "medium", "high"]).optional().describe("\u4F18\u5148\u7EA7"),
27861
- status: import_zod63.z.enum(["pending", "in_progress", "completed", "cancelled"]).optional().describe("\u72B6\u6001"),
27862
- dueDate: import_zod63.z.string().optional().describe("\u622A\u6B62\u65E5\u671F (ISO 8601)"),
27863
- metadata: import_zod63.z.record(import_zod63.z.unknown()).optional().describe("\u7ED3\u6784\u5316\u5143\u6570\u636E (projectId, module \u7B49)"),
27864
- parentId: import_zod63.z.string().optional().describe("\u7236\u4EFB\u52A1 ID (\u5B50\u4EFB\u52A1\u5173\u8054)"),
27865
- sourceId: import_zod63.z.string().optional().describe("\u6765\u6E90\u4F1A\u8BDD/thread ID"),
27866
- context: import_zod63.z.record(import_zod63.z.unknown()).optional().describe("\u9644\u52A0\u4E0A\u4E0B\u6587"),
27867
- ownerType: import_zod63.z.enum(["user", "agent"]).optional().describe("\u6240\u6709\u8005\u7C7B\u578B\uFF0C\u4E0D\u4F20\u9ED8\u8BA4\u4E3A user"),
27868
- ownerId: import_zod63.z.string().optional().describe("\u6240\u6709\u8005 ID\uFF0C\u4E0D\u4F20\u81EA\u52A8\u53D6\u5F53\u524D\u7528\u6237/Agent")
27869
- });
27870
- function createTaskMiddleware() {
27871
- return (0, import_langchain76.createMiddleware)({
27872
- name: "TaskMiddleware",
27873
- contextSchema,
27874
- wrapModelCall: async (request, handler) => {
27875
- const taskPrompt = `## \u4EFB\u52A1\u7BA1\u7406\u80FD\u529B
27876
- \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
27877
- - \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)
27878
- - ownerType="agent": \u4E3A\u81EA\u5DF1\u521B\u5EFA\u6267\u884C\u5B50\u4EFB\u52A1 (ownerId \u81EA\u52A8\u53D6\u5F53\u524D Agent)
27879
- - \u663E\u5F0F\u4F20 ownerId: \u4E3A\u6307\u5B9A agent/user \u521B\u5EFA\u4EFB\u52A1\uFF08\u62D3\u6251\u573A\u666F\uFF09`;
27880
- return handler({
27881
- ...request,
27882
- systemPrompt: taskPrompt + "\n\n" + (request.systemPrompt ?? "")
27883
- });
27884
- },
27885
- tools: [
27886
- (0, import_langchain76.tool)(
27887
- async (input, config) => {
27888
- const rc = getRunConfig2(config);
27889
- const tenantId2 = rc.tenantId || "default";
27890
- const ownerId = input.ownerId || (input.ownerType === "agent" ? rc.assistant_id : null) || rc.user_id;
27891
- const store = getTaskStore();
27892
- switch (input.action) {
27893
- case "create": {
27894
- if (!input.title) {
27895
- return JSON.stringify({ success: false, error: "create requires title" });
27896
- }
27897
- const task = await store.create({
27898
- tenantId: tenantId2,
27899
- ownerType: input.ownerType || "user",
27900
- ownerId,
27901
- title: input.title,
27902
- description: input.description,
27903
- priority: input.priority || "medium",
27904
- status: input.status || "pending",
27905
- dueDate: input.dueDate,
27906
- metadata: input.metadata,
27907
- parentId: input.parentId,
27908
- sourceId: input.sourceId,
27909
- context: input.context
27910
- });
27911
- return JSON.stringify({ success: true, data: task });
27912
- }
27913
- case "list": {
27914
- const tasks = await store.list({
27915
- tenantId: tenantId2,
27916
- ownerType: input.ownerType,
27917
- ownerId: input.ownerId,
27918
- status: input.status,
27919
- priority: input.priority
27920
- });
27921
- return JSON.stringify({ success: true, data: tasks, count: tasks.length });
27922
- }
27923
- case "update": {
27924
- if (!input.id) {
27925
- return JSON.stringify({ success: false, error: "update requires id" });
27926
- }
27927
- const { action, ...updates } = input;
27928
- const updated = await store.update(tenantId2, input.id, updates);
27929
- if (!updated) {
27930
- return JSON.stringify({ success: false, error: "Task not found" });
27931
- }
27932
- return JSON.stringify({ success: true, data: updated });
27933
- }
27934
- case "delete": {
27935
- if (!input.id) {
27936
- return JSON.stringify({ success: false, error: "delete requires id" });
27937
- }
27938
- const deleted = await store.delete(tenantId2, input.id);
27939
- return JSON.stringify({ success: deleted, message: deleted ? "Task deleted" : "Task not found" });
27940
- }
27941
- case "complete": {
27942
- if (!input.id) {
27943
- return JSON.stringify({ success: false, error: "complete requires id" });
27944
- }
27945
- const updated = await store.update(tenantId2, input.id, { status: "completed" });
27946
- if (!updated) {
27947
- return JSON.stringify({ success: false, error: "Task not found" });
27948
- }
27949
- return JSON.stringify({ success: true, data: updated });
27950
- }
27951
- default:
27952
- return JSON.stringify({ success: false, error: `Unknown action: ${input.action}` });
27953
- }
27954
- },
27955
- {
27956
- name: "manage_task",
27957
- description: `\u7BA1\u7406\u6301\u4E45\u5316\u4EFB\u52A1\u7CFB\u7EDF\u3002CRUD \u64CD\u4F5C\u7528\u6237\u548C Agent \u7684\u4EFB\u52A1\u3002
27958
-
27959
- ## ownerType \u548C ownerId \u7684\u9ED8\u8BA4\u903B\u8F91
27960
- - \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)
27961
- - \u4F20 ownerType="agent" \u4E0D\u4F20 ownerId: \u7CFB\u7EDF\u81EA\u52A8\u4E3A\u5F53\u524D Agent \u521B\u5EFA\u5B50\u4EFB\u52A1
27962
- - \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
27963
-
27964
- ## Actions
27965
- - create: \u521B\u5EFA\u4EFB\u52A1 (title \u5FC5\u586B, priority/description/dueDate/metadata/parentId/context \u53EF\u9009)
27966
- - list: \u5217\u51FA\u4EFB\u52A1\uFF0C\u53EF\u6309 ownerType/status/priority \u8FC7\u6EE4
27967
- - update: \u66F4\u65B0\u4EFB\u52A1 (id \u5FC5\u586B\uFF0C\u53EA\u4F20\u8981\u6539\u7684\u5B57\u6BB5)
27968
- - delete: \u5220\u9664\u4EFB\u52A1 (id \u5FC5\u586B)
27969
- - complete: \u5FEB\u901F\u6807\u8BB0\u5B8C\u6210 (id \u5FC5\u586B)`,
27970
- schema: manageTaskSchema
27971
- }
27972
- )
27973
- ]
27974
- });
27975
- }
27976
- var taskPlugin = {
27977
- meta: {
27978
- type: "task",
27979
- name: "Task Management",
27980
- description: "Enables persistent task management with delegation and tracking",
27981
- configSchema: {
27982
- type: "object",
27983
- title: "Task Management Configuration",
27984
- description: "Zero-configuration task management",
27985
- properties: {}
27986
- },
27987
- defaultConfig: {}
27988
- },
27989
- middleware: () => createTaskMiddleware()
27990
- };
27991
-
27992
28563
  // src/middlewares/evalMiddleware.ts
27993
28564
  var import_langchain77 = require("langchain");
27994
28565
  var import_zod64 = require("zod");
27995
- var import_uuid10 = require("uuid");
28566
+ var import_uuid11 = require("uuid");
27996
28567
 
27997
28568
  // src/middlewares/evalSkills.ts
27998
28569
  var EVAL_SKILLS = {
@@ -28206,7 +28777,7 @@ function createManageEvalTool() {
28206
28777
  let data;
28207
28778
  switch (input.action) {
28208
28779
  case "create_project":
28209
- data = await store.createProject(tid, (0, import_uuid10.v4)(), {
28780
+ data = await store.createProject(tid, (0, import_uuid11.v4)(), {
28210
28781
  name: input.name,
28211
28782
  description: input.description,
28212
28783
  judgeModelConfig: { modelKey: input.judgeModelKey },
@@ -28230,7 +28801,7 @@ function createManageEvalTool() {
28230
28801
  break;
28231
28802
  }
28232
28803
  case "create_suite":
28233
- data = await store.createSuite(tid, input.projectId, (0, import_uuid10.v4)(), { name: input.name });
28804
+ data = await store.createSuite(tid, input.projectId, (0, import_uuid11.v4)(), { name: input.name });
28234
28805
  break;
28235
28806
  case "update_suite":
28236
28807
  data = await store.updateSuite(tid, input.suiteId, { name: input.name });
@@ -28240,7 +28811,7 @@ function createManageEvalTool() {
28240
28811
  data = true;
28241
28812
  break;
28242
28813
  case "create_case":
28243
- data = await store.createCase(tid, input.suiteId, (0, import_uuid10.v4)(), {
28814
+ data = await store.createCase(tid, input.suiteId, (0, import_uuid11.v4)(), {
28244
28815
  inputMessage: input.inputMessage,
28245
28816
  inputFiles: input.inputFiles,
28246
28817
  steps: input.steps,