@axiom-lattice/core 2.1.99 → 2.1.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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
  }
@@ -1626,13 +1626,16 @@ __export(index_exports, {
1626
1626
  DaytonaInstance: () => DaytonaInstance,
1627
1627
  DaytonaProvider: () => DaytonaProvider,
1628
1628
  DefaultScheduleClient: () => DefaultScheduleClient,
1629
+ DependencyResolver: () => DependencyResolver,
1629
1630
  E2BInstance: () => E2BInstance,
1630
1631
  E2BProvider: () => E2BProvider,
1631
1632
  EMPTY_CONTENT_WARNING: () => EMPTY_CONTENT_WARNING,
1632
1633
  EmbeddingsLatticeManager: () => EmbeddingsLatticeManager,
1634
+ ExportableEntityRegistry: () => ExportableEntityRegistry,
1633
1635
  FileSystemSkillStore: () => FileSystemSkillStore,
1634
1636
  FilesystemBackend: () => FilesystemBackend,
1635
- HumanMessage: () => import_messages6.HumanMessage,
1637
+ HumanMessage: () => import_messages7.HumanMessage,
1638
+ IdRemapper: () => IdRemapper,
1636
1639
  InMemoryA2AApiKeyStore: () => InMemoryA2AApiKeyStore,
1637
1640
  InMemoryAssistantStore: () => InMemoryAssistantStore,
1638
1641
  InMemoryBindingStore: () => InMemoryBindingStore,
@@ -1908,6 +1911,12 @@ var ModelLattice = class extends import_chat_models.BaseChatModel {
1908
1911
  async _generate(messages, options, runManager) {
1909
1912
  return this.llm._generate(messages, options, runManager);
1910
1913
  }
1914
+ /**
1915
+ * Whether the configured model supports vision/image inputs.
1916
+ */
1917
+ get supportsVision() {
1918
+ return this.config.supportsVision || false;
1919
+ }
1911
1920
  /**
1912
1921
  * 将工具绑定到模型
1913
1922
  * @param tools 工具列表
@@ -4476,11 +4485,17 @@ var InMemoryTaskStore = class {
4476
4485
  description: params.description,
4477
4486
  status: params.status || "pending",
4478
4487
  priority: params.priority || "medium",
4488
+ workspaceId: params.workspaceId,
4489
+ projectId: params.projectId,
4479
4490
  dueDate: params.dueDate,
4480
4491
  metadata: params.metadata,
4481
4492
  parentId: params.parentId,
4482
4493
  sourceId: params.sourceId,
4483
4494
  context: params.context,
4495
+ requireReview: params.requireReview ?? false,
4496
+ dependencies: params.dependencies,
4497
+ result: params.result,
4498
+ failureReason: params.failureReason,
4484
4499
  createdAt: now,
4485
4500
  updatedAt: now
4486
4501
  };
@@ -4506,6 +4521,8 @@ var InMemoryTaskStore = class {
4506
4521
  if (filter2.ownerId) results = results.filter((t) => t.ownerId === filter2.ownerId);
4507
4522
  if (filter2.status) results = results.filter((t) => t.status === filter2.status);
4508
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);
4509
4526
  if (filter2.parentId) results = results.filter((t) => t.parentId === filter2.parentId);
4510
4527
  if (filter2.sourceId) results = results.filter((t) => t.sourceId === filter2.sourceId);
4511
4528
  if (filter2.metadata) {
@@ -4554,8 +4571,65 @@ var InMemoryTaskStore = class {
4554
4571
  }
4555
4572
  };
4556
4573
 
4557
- // src/store_lattice/InMemoryCollectionStore.ts
4574
+ // src/store_lattice/InMemoryTaskWorkItemStore.ts
4558
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");
4559
4633
  var InMemoryCollectionStore = class {
4560
4634
  constructor() {
4561
4635
  this.collections = /* @__PURE__ */ new Map();
@@ -4589,7 +4663,7 @@ var InMemoryCollectionStore = class {
4589
4663
  }
4590
4664
  const now = /* @__PURE__ */ new Date();
4591
4665
  const collection = {
4592
- id: (0, import_uuid2.v4)(),
4666
+ id: (0, import_uuid3.v4)(),
4593
4667
  tenantId: tenantId2,
4594
4668
  name: data.name,
4595
4669
  label: data.label,
@@ -4825,6 +4899,12 @@ storeLatticeManager.registerLattice(
4825
4899
  "task",
4826
4900
  defaultTaskStore
4827
4901
  );
4902
+ var defaultTaskWorkItemStore = new InMemoryTaskWorkItemStore();
4903
+ storeLatticeManager.registerLattice(
4904
+ "default",
4905
+ "taskWorkItem",
4906
+ defaultTaskWorkItemStore
4907
+ );
4828
4908
  var defaultCollectionStore = new InMemoryCollectionStore();
4829
4909
  storeLatticeManager.registerLattice(
4830
4910
  "default",
@@ -8906,7 +8986,7 @@ var createBrowserGetInfoTool = ({ vmIsolation }) => {
8906
8986
  };
8907
8987
 
8908
8988
  // src/index.ts
8909
- var import_messages6 = require("@langchain/core/messages");
8989
+ var import_messages7 = require("@langchain/core/messages");
8910
8990
 
8911
8991
  // src/agent_lattice/types.ts
8912
8992
  var import_protocols = require("@axiom-lattice/protocols");
@@ -9535,6 +9615,72 @@ var StateBackend = class {
9535
9615
  }
9536
9616
  };
9537
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
+
9538
9684
  // src/deep_agent_new/middleware/fs.ts
9539
9685
  var FileDataSchema = import_v3.z.object({
9540
9686
  content: import_v3.z.array(import_v3.z.string()),
@@ -9593,7 +9739,7 @@ Path conventions:
9593
9739
  - glob: find files matching a pattern (e.g., "/project/**/*.py")
9594
9740
  - grep: search for text within files`;
9595
9741
  var LS_TOOL_DESCRIPTION = "List files and directories in a directory";
9596
- 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.";
9597
9743
  var WRITE_FILE_TOOL_DESCRIPTION = "Write content to a new file. Returns an error if the file already exists";
9598
9744
  var EDIT_FILE_TOOL_DESCRIPTION = "Edit a file by replacing a specific string with a new string";
9599
9745
  var GLOB_TOOL_DESCRIPTION = "Find files matching a glob pattern (e.g., '**/*.py' for all Python files)";
@@ -9646,6 +9792,38 @@ function createReadFileTool(backend, options) {
9646
9792
  };
9647
9793
  const resolvedBackend = await getBackend(backend, stateAndStore);
9648
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
+ }
9649
9827
  return await resolvedBackend.read(file_path, offset, limit);
9650
9828
  },
9651
9829
  {
@@ -10694,7 +10872,7 @@ var clawPlugin = {
10694
10872
 
10695
10873
  // src/middlewares/unknownToolHandlerMiddleware.ts
10696
10874
  var import_langchain44 = require("langchain");
10697
- var import_messages = require("@langchain/core/messages");
10875
+ var import_messages2 = require("@langchain/core/messages");
10698
10876
  function createUnknownToolHandlerMiddleware(config = {}) {
10699
10877
  const {
10700
10878
  strategy = "error",
@@ -10744,7 +10922,7 @@ Please select a valid tool from the list above.`
10744
10922
  toolCallId: toolCall.id,
10745
10923
  errorMessage: errorMessageTemplate(toolCall.name, availableToolNames)
10746
10924
  }));
10747
- const modifiedResponse = new import_messages.AIMessage({
10925
+ const modifiedResponse = new import_messages2.AIMessage({
10748
10926
  content: aiResponse.content,
10749
10927
  tool_calls: aiResponse.tool_calls,
10750
10928
  // Key: preserve all tool_calls, don't delete unknown
@@ -10775,7 +10953,7 @@ Please select a valid tool from the list above.`
10775
10953
  return;
10776
10954
  }
10777
10955
  const lastMessage = messages[messages.length - 1];
10778
- if (!import_messages.AIMessage.isInstance(lastMessage)) {
10956
+ if (!import_messages2.AIMessage.isInstance(lastMessage)) {
10779
10957
  return;
10780
10958
  }
10781
10959
  const unknownToolErrors = lastMessage.response_metadata?._unknownToolErrors;
@@ -10783,7 +10961,7 @@ Please select a valid tool from the list above.`
10783
10961
  return;
10784
10962
  }
10785
10963
  const errorToolMessages = unknownToolErrors.map(
10786
- (error) => new import_messages.ToolMessage({
10964
+ (error) => new import_messages2.ToolMessage({
10787
10965
  content: error.errorMessage,
10788
10966
  name: error.toolName,
10789
10967
  tool_call_id: error.toolCallId,
@@ -11239,19 +11417,13 @@ var SandboxFilesystem = class {
11239
11417
  throw new Error(`Error reading file '${filePath}': ${e.message}`);
11240
11418
  }
11241
11419
  }
11420
+ async readBinary(filePath) {
11421
+ return this.sandbox.file.downloadFile({ file: filePath });
11422
+ }
11242
11423
  async write(filePath, content) {
11243
11424
  try {
11244
11425
  await this.sandbox.file.writeFile(filePath, content);
11245
- return {
11246
- path: filePath,
11247
- filesUpdate: {
11248
- [filePath]: {
11249
- content: content.split("\n"),
11250
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
11251
- modified_at: (/* @__PURE__ */ new Date()).toISOString()
11252
- }
11253
- }
11254
- };
11426
+ return { path: filePath, filesUpdate: null };
11255
11427
  } catch (e) {
11256
11428
  throw new Error(`Error writing file '${filePath}': ${e.message}`);
11257
11429
  }
@@ -11265,10 +11437,7 @@ var SandboxFilesystem = class {
11265
11437
  new_str: newString,
11266
11438
  replace_mode: replaceAll ? "ALL" : "FIRST"
11267
11439
  });
11268
- return {
11269
- path: filePath,
11270
- filesUpdate: null
11271
- };
11440
+ return { path: filePath, filesUpdate: null };
11272
11441
  } catch (e) {
11273
11442
  throw new Error(`Error editing file '${filePath}': ${e.message}`);
11274
11443
  }
@@ -11365,13 +11534,13 @@ var ReActAgentGraphBuilder = class {
11365
11534
  };
11366
11535
 
11367
11536
  // src/deep_agent_new/agent.ts
11368
- var import_langchain52 = require("langchain");
11537
+ var import_langchain53 = require("langchain");
11369
11538
 
11370
11539
  // src/deep_agent_new/middleware/subagents.ts
11371
11540
  var import_v32 = require("zod/v3");
11372
- var import_langchain47 = require("langchain");
11541
+ var import_langchain48 = require("langchain");
11373
11542
  var import_langgraph7 = require("@langchain/langgraph");
11374
- var import_messages2 = require("@langchain/core/messages");
11543
+ var import_messages3 = require("@langchain/core/messages");
11375
11544
 
11376
11545
  // src/agent_worker/agent_worker_graph.ts
11377
11546
  var import_langgraph5 = require("@langchain/langgraph");
@@ -12004,17 +12173,18 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
12004
12173
  import_protocols4.MessageChunkTypes.THREAD_IDLE
12005
12174
  ];
12006
12175
  const typesToStop = stopTypes ?? defaultStopTypes;
12007
- let startYieldChunk = false;
12008
- console.log("start from messageId", messageId);
12176
+ let startIndex = 0;
12177
+ for (let i = buffer2.chunks.length - 1; i >= 0; i--) {
12178
+ if (buffer2.chunks[i].data?.id === messageId) {
12179
+ startIndex = i;
12180
+ break;
12181
+ }
12182
+ }
12183
+ const stopSet = new Set(typesToStop);
12009
12184
  const filtered$ = buffer2.chunks$.pipe(
12010
12185
  (0, import_rxjs.observeOn)(import_rxjs.asyncScheduler),
12011
- // 1. 从指定 messageId 开始
12012
- (0, import_operators.filter)((chunk2) => {
12013
- if (chunk2.data?.id === messageId) startYieldChunk = true;
12014
- return startYieldChunk;
12015
- }),
12016
- // 2. 包含指定的停止类型,但收到后停止
12017
- (0, import_operators.takeWhile)((chunk2) => !typesToStop.includes(chunk2.type), true)
12186
+ (0, import_operators.skip)(startIndex),
12187
+ (0, import_operators.takeWhile)((chunk2) => !stopSet.has(chunk2.type), true)
12018
12188
  );
12019
12189
  yield* (0, import_rxjs_for_await.eachValueFrom)(filtered$);
12020
12190
  }
@@ -12097,7 +12267,7 @@ var buffer = new InMemoryChunkBuffer({
12097
12267
  registerChunkBuffer("default", buffer);
12098
12268
 
12099
12269
  // src/services/Agent.ts
12100
- var import_uuid3 = require("uuid");
12270
+ var import_uuid4 = require("uuid");
12101
12271
  var ThreadStatus2 = /* @__PURE__ */ ((ThreadStatus3) => {
12102
12272
  ThreadStatus3["IDLE"] = "idle";
12103
12273
  ThreadStatus3["BUSY"] = "busy";
@@ -12143,7 +12313,7 @@ var Agent = class {
12143
12313
  runConfig
12144
12314
  },
12145
12315
  configurable: {
12146
- run_id: (0, import_uuid3.v4)(),
12316
+ run_id: (0, import_uuid4.v4)(),
12147
12317
  ...runConfig,
12148
12318
  runConfig
12149
12319
  },
@@ -12216,7 +12386,7 @@ var Agent = class {
12216
12386
  runConfig
12217
12387
  },
12218
12388
  configurable: {
12219
- run_id: (0, import_uuid3.v4)(),
12389
+ run_id: (0, import_uuid4.v4)(),
12220
12390
  ...runConfig,
12221
12391
  runConfig
12222
12392
  // Inject runConfig for tools to access
@@ -12602,7 +12772,7 @@ var Agent = class {
12602
12772
  };
12603
12773
  }
12604
12774
  async invoke(queueMessage, signal) {
12605
- const messageId = (0, import_uuid3.v4)();
12775
+ const messageId = (0, import_uuid4.v4)();
12606
12776
  const input = {
12607
12777
  ...queueMessage.input,
12608
12778
  messages: [new import_langchain46.HumanMessage({ id: messageId, content: queueMessage.input.message })]
@@ -12621,7 +12791,7 @@ var Agent = class {
12621
12791
  * to avoid exposing internal annotation data.
12622
12792
  */
12623
12793
  async invokeWithState(queueMessage, signal) {
12624
- const messageId = (0, import_uuid3.v4)();
12794
+ const messageId = (0, import_uuid4.v4)();
12625
12795
  const input = {
12626
12796
  ...queueMessage.input,
12627
12797
  messages: [new import_langchain46.HumanMessage({ id: messageId, content: queueMessage.input.message })]
@@ -12637,7 +12807,7 @@ var Agent = class {
12637
12807
  {
12638
12808
  context: { runConfig },
12639
12809
  configurable: {
12640
- run_id: (0, import_uuid3.v4)(),
12810
+ run_id: (0, import_uuid4.v4)(),
12641
12811
  ...runConfig,
12642
12812
  runConfig
12643
12813
  },
@@ -12813,7 +12983,7 @@ var Agent = class {
12813
12983
  */
12814
12984
  async addMessage(queueMessage, mode) {
12815
12985
  const useMode = mode ?? this.queueMode.mode;
12816
- const messageId = queueMessage.input.id || (0, import_uuid3.v4)();
12986
+ const messageId = queueMessage.input.id || (0, import_uuid4.v4)();
12817
12987
  const messages = queueMessage.input.messages;
12818
12988
  const legacyMessage = queueMessage.input.message;
12819
12989
  if (!messages && !legacyMessage) {
@@ -13305,6 +13475,348 @@ var AgentInstanceManager = class _AgentInstanceManager {
13305
13475
  };
13306
13476
  var agentInstanceManager = AgentInstanceManager.getInstance();
13307
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
+
13308
13820
  // src/deep_agent_new/middleware/subagents.ts
13309
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.";
13310
13822
  var EXCLUDED_STATE_KEYS = ["messages", "todos", "jumpTo"];
@@ -13466,7 +13978,7 @@ function returnCommandWithStateUpdate(result, toolCallId) {
13466
13978
  update: {
13467
13979
  ...stateUpdate,
13468
13980
  messages: [
13469
- new import_langchain47.ToolMessage({
13981
+ new import_langchain48.ToolMessage({
13470
13982
  content: lastMessage?.content || "Task Failed to complete",
13471
13983
  tool_call_id: toolCallId,
13472
13984
  name: "task"
@@ -13487,14 +13999,18 @@ function getSubagents(options) {
13487
13999
  const defaultSubagentMiddleware = defaultMiddleware || [];
13488
14000
  const agents = {};
13489
14001
  const subagentDescriptions = [];
14002
+ const hasTaskMiddleware = defaultSubagentMiddleware.some(
14003
+ (m) => m?.name === "TaskMiddleware"
14004
+ );
14005
+ const taskMiddleware = hasTaskMiddleware ? [] : [createTaskMiddleware()];
13490
14006
  if (generalPurposeAgent) {
13491
- const generalPurposeMiddleware = [...defaultSubagentMiddleware];
14007
+ const generalPurposeMiddleware = [...defaultSubagentMiddleware, ...taskMiddleware];
13492
14008
  if (defaultInterruptOn) {
13493
14009
  generalPurposeMiddleware.push(
13494
- (0, import_langchain47.humanInTheLoopMiddleware)({ interruptOn: defaultInterruptOn })
14010
+ (0, import_langchain48.humanInTheLoopMiddleware)({ interruptOn: defaultInterruptOn })
13495
14011
  );
13496
14012
  }
13497
- const generalPurposeSubagent = (0, import_langchain47.createAgent)({
14013
+ const generalPurposeSubagent = (0, import_langchain48.createAgent)({
13498
14014
  model: defaultModel,
13499
14015
  systemPrompt: DEFAULT_SUBAGENT_PROMPT,
13500
14016
  tools: defaultTools,
@@ -13514,11 +14030,11 @@ function getSubagents(options) {
13514
14030
  if ("runnable" in agentParams) {
13515
14031
  agents[agentParams.key] = agentParams.runnable;
13516
14032
  } else {
13517
- const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
14033
+ const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...taskMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware, ...taskMiddleware];
13518
14034
  const interruptOn = agentParams.interruptOn || defaultInterruptOn;
13519
14035
  if (interruptOn)
13520
- middleware.push((0, import_langchain47.humanInTheLoopMiddleware)({ interruptOn }));
13521
- agents[agentParams.key] = (0, import_langchain47.createAgent)({
14036
+ middleware.push((0, import_langchain48.humanInTheLoopMiddleware)({ interruptOn }));
14037
+ agents[agentParams.key] = (0, import_langchain48.createAgent)({
13522
14038
  model: agentParams.model ?? defaultModel,
13523
14039
  systemPrompt: agentParams.systemPrompt,
13524
14040
  tools: agentParams.tools ?? defaultTools,
@@ -13568,7 +14084,7 @@ function createTaskTool(options) {
13568
14084
  generalPurposeAgent
13569
14085
  });
13570
14086
  const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
13571
- return (0, import_langchain47.tool)(
14087
+ return (0, import_langchain48.tool)(
13572
14088
  async (input, config) => {
13573
14089
  const { description, subagent_type, async } = input;
13574
14090
  let assistant_id = subagent_type;
@@ -13598,7 +14114,17 @@ function createTaskTool(options) {
13598
14114
  }
13599
14115
  const currentState = (0, import_langgraph7.getCurrentTaskInput)();
13600
14116
  const subagentState = filterStateForSubagent(currentState);
13601
- 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 })];
13602
14128
  const subagent_thread_id = config.configurable?.thread_id + "____" + assistant_id + "_" + config.toolCall.id;
13603
14129
  if (async) {
13604
14130
  const tenantId2 = config.configurable?.runConfig?.tenantId;
@@ -13630,11 +14156,12 @@ function createTaskTool(options) {
13630
14156
  runConfig: {
13631
14157
  ...config.configurable?.runConfig,
13632
14158
  assistant_id,
13633
- thread_id: subagent_thread_id
14159
+ thread_id: subagent_thread_id,
14160
+ taskId: input.taskId
13634
14161
  },
13635
- main_thread_id: mainThreadId,
13636
14162
  main_tenant_id: tenantId2,
13637
- main_assistant_id: mainAssistantId
14163
+ main_assistant_id: mainAssistantId,
14164
+ main_thread_id: mainThreadId
13638
14165
  }, false).catch((err) => {
13639
14166
  console.error(`Failed to start async subagent ${subagent_thread_id}:`, err);
13640
14167
  });
@@ -13644,7 +14171,7 @@ function createTaskTool(options) {
13644
14171
  return new import_langgraph7.Command({
13645
14172
  update: {
13646
14173
  messages: [
13647
- new import_langchain47.ToolMessage({
14174
+ new import_langchain48.ToolMessage({
13648
14175
  content: `Async task started: ${subagent_thread_id}
13649
14176
  ${description}
13650
14177
  The result will be delivered as a notification when complete. Do not poll.`,
@@ -13662,7 +14189,8 @@ The result will be delivered as a notification when complete. Do not poll.`,
13662
14189
  runConfig: {
13663
14190
  ...config.configurable?.runConfig,
13664
14191
  assistant_id,
13665
- thread_id: subagent_thread_id
14192
+ thread_id: subagent_thread_id,
14193
+ taskId: input.taskId
13666
14194
  }
13667
14195
  });
13668
14196
  const result = workerResult.finalState?.values;
@@ -13677,7 +14205,7 @@ The result will be delivered as a notification when complete. Do not poll.`,
13677
14205
  return new import_langgraph7.Command({
13678
14206
  update: {
13679
14207
  messages: [
13680
- new import_langchain47.ToolMessage({
14208
+ new import_langchain48.ToolMessage({
13681
14209
  content: error instanceof Error ? error.message : "Task Failed to complete",
13682
14210
  tool_call_id: config.toolCall.id,
13683
14211
  name: "task"
@@ -13701,7 +14229,10 @@ The result will be delivered as a notification when complete. Do not poll.`,
13701
14229
  async: import_v32.z.boolean().default(false).describe(
13702
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."
13703
14231
  )
13704
- } : {}
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
+ )
13705
14236
  })
13706
14237
  }
13707
14238
  );
@@ -13717,7 +14248,7 @@ function getMainAgentFromConfig(config) {
13717
14248
  });
13718
14249
  }
13719
14250
  function createCheckAsyncTaskTool() {
13720
- return (0, import_langchain47.tool)(
14251
+ return (0, import_langchain48.tool)(
13721
14252
  async (input, config) => {
13722
14253
  const { task_id } = input;
13723
14254
  const mainAgent = getMainAgentFromConfig(config);
@@ -13784,7 +14315,7 @@ Description: ${cached.description}`;
13784
14315
  );
13785
14316
  }
13786
14317
  function createListAsyncTasksTool() {
13787
- return (0, import_langchain47.tool)(
14318
+ return (0, import_langchain48.tool)(
13788
14319
  async (_input, config) => {
13789
14320
  const mainAgent = getMainAgentFromConfig(config);
13790
14321
  if (!mainAgent) {
@@ -13835,7 +14366,7 @@ function createListAsyncTasksTool() {
13835
14366
  );
13836
14367
  }
13837
14368
  function createCancelAsyncTaskTool() {
13838
- return (0, import_langchain47.tool)(
14369
+ return (0, import_langchain48.tool)(
13839
14370
  async (input, config) => {
13840
14371
  const { task_id } = input;
13841
14372
  const mainAgent = getMainAgentFromConfig(config);
@@ -13911,7 +14442,7 @@ function createSubAgentMiddleware(options) {
13911
14442
  );
13912
14443
  }
13913
14444
  const effectiveSystemPrompt = allowAsync ? systemPrompt + getAsyncPromptText() : systemPrompt;
13914
- return (0, import_langchain47.createMiddleware)({
14445
+ return (0, import_langchain48.createMiddleware)({
13915
14446
  name: "subAgentMiddleware",
13916
14447
  tools: allTools,
13917
14448
  wrapModelCall: async (request, handler) => {
@@ -13931,9 +14462,9 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
13931
14462
  }
13932
14463
 
13933
14464
  // src/deep_agent_new/middleware/patch_tool_calls.ts
13934
- var import_langchain48 = require("langchain");
14465
+ var import_langchain49 = require("langchain");
13935
14466
  function createPatchToolCallsMiddleware() {
13936
- return (0, import_langchain48.createMiddleware)({
14467
+ return (0, import_langchain49.createMiddleware)({
13937
14468
  name: "patchToolCallsMiddleware",
13938
14469
  beforeAgent: async (state) => {
13939
14470
  const messages = state.messages;
@@ -13944,15 +14475,15 @@ function createPatchToolCallsMiddleware() {
13944
14475
  for (let i = 0; i < messages.length; i++) {
13945
14476
  const msg = messages[i];
13946
14477
  patchedMessages.push(msg);
13947
- if (import_langchain48.AIMessage.isInstance(msg) && msg.tool_calls != null) {
14478
+ if (import_langchain49.AIMessage.isInstance(msg) && msg.tool_calls != null) {
13948
14479
  for (const toolCall of msg.tool_calls) {
13949
14480
  const correspondingToolMsg = messages.slice(i).find(
13950
- (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
13951
14482
  );
13952
14483
  if (!correspondingToolMsg) {
13953
14484
  const toolMsg = `Tool call ${toolCall.name} with id ${toolCall.id} was cancelled - another message came in before it could be completed.`;
13954
14485
  patchedMessages.push(
13955
- new import_langchain48.ToolMessage({
14486
+ new import_langchain49.ToolMessage({
13956
14487
  content: toolMsg,
13957
14488
  name: toolCall.name,
13958
14489
  tool_call_id: toolCall.id
@@ -13974,8 +14505,8 @@ function createPatchToolCallsMiddleware() {
13974
14505
  }
13975
14506
 
13976
14507
  // src/deep_agent_new/middleware/date.ts
13977
- var import_langchain49 = require("langchain");
13978
- var import_zod44 = require("zod");
14508
+ var import_langchain50 = require("langchain");
14509
+ var import_zod45 = require("zod");
13979
14510
  function formatCurrentDate(timezone = "UTC") {
13980
14511
  const now = /* @__PURE__ */ new Date();
13981
14512
  let validTimezone = timezone;
@@ -14003,10 +14534,10 @@ function generateDateContext(timezone = "UTC") {
14003
14534
  function createDateMiddleware(options = {}) {
14004
14535
  const timezone = options.timezone || "UTC";
14005
14536
  const dateContext = generateDateContext(timezone);
14006
- return (0, import_langchain49.createMiddleware)({
14537
+ return (0, import_langchain50.createMiddleware)({
14007
14538
  name: "DateMiddleware",
14008
14539
  tools: [
14009
- (0, import_langchain49.tool)(
14540
+ (0, import_langchain50.tool)(
14010
14541
  async () => {
14011
14542
  const now = /* @__PURE__ */ new Date();
14012
14543
  let validTimezone = timezone;
@@ -14036,7 +14567,7 @@ function createDateMiddleware(options = {}) {
14036
14567
  {
14037
14568
  name: "get_current_date_time",
14038
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.",
14039
- schema: import_zod44.z.object({})
14570
+ schema: import_zod45.z.object({})
14040
14571
  }
14041
14572
  )
14042
14573
  ],
@@ -14101,9 +14632,9 @@ var datePlugin = {
14101
14632
  };
14102
14633
 
14103
14634
  // src/deep_agent_new/middleware/scheduler.ts
14104
- var import_langchain50 = require("langchain");
14105
- var import_zod45 = require("zod");
14106
- var import_uuid4 = require("uuid");
14635
+ var import_langchain51 = require("langchain");
14636
+ var import_zod46 = require("zod");
14637
+ var import_uuid5 = require("uuid");
14107
14638
  var import_protocols8 = require("@axiom-lattice/protocols");
14108
14639
 
14109
14640
  // src/schedule_lattice/ScheduleLatticeManager.ts
@@ -15098,7 +15629,7 @@ var getScheduleLattice = (key4) => scheduleLatticeManager.getScheduleLattice(key
15098
15629
  // src/deep_agent_new/middleware/scheduler.ts
15099
15630
  var SCHEDULE_LATTICE_KEY = "default";
15100
15631
  var AGENT_ADD_MESSAGE_TASK_TYPE = "agent.add_message";
15101
- function getRunConfig(config) {
15632
+ function getRunConfig2(config) {
15102
15633
  const configurable = config;
15103
15634
  return configurable?.configurable?.runConfig ?? {};
15104
15635
  }
@@ -15170,14 +15701,14 @@ function registerAgentAddMessageHandler() {
15170
15701
  function createSchedulerMiddleware(options = {}) {
15171
15702
  const defaultMaxRetries = options.defaultMaxRetries ?? 0;
15172
15703
  registerAgentAddMessageHandler();
15173
- return (0, import_langchain50.createMiddleware)({
15704
+ return (0, import_langchain51.createMiddleware)({
15174
15705
  name: "SchedulerMiddleware",
15175
15706
  tools: [
15176
- (0, import_langchain50.tool)(
15707
+ (0, import_langchain51.tool)(
15177
15708
  async (input, config) => {
15178
- const runConfig = getRunConfig(config);
15709
+ const runConfig = getRunConfig2(config);
15179
15710
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15180
- const taskId = (0, import_uuid4.v4)();
15711
+ const taskId = (0, import_uuid5.v4)();
15181
15712
  const executeAt = input.executeAt;
15182
15713
  const success = await scheduleLattice.client.scheduleOnce(
15183
15714
  taskId,
@@ -15201,18 +15732,18 @@ function createSchedulerMiddleware(options = {}) {
15201
15732
  {
15202
15733
  name: "schedule_at",
15203
15734
  description: "Schedule a system message for an absolute future timestamp",
15204
- schema: import_zod45.z.object({
15205
- executeAt: import_zod45.z.number(),
15206
- maxRetries: import_zod45.z.number().int().min(0).optional(),
15207
- 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()
15208
15739
  })
15209
15740
  }
15210
15741
  ),
15211
- (0, import_langchain50.tool)(
15742
+ (0, import_langchain51.tool)(
15212
15743
  async (input, config) => {
15213
- const runConfig = getRunConfig(config);
15744
+ const runConfig = getRunConfig2(config);
15214
15745
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15215
- const taskId = (0, import_uuid4.v4)();
15746
+ const taskId = (0, import_uuid5.v4)();
15216
15747
  const executeAt = Date.now() + input.delayMs;
15217
15748
  const success = await scheduleLattice.client.scheduleOnce(
15218
15749
  taskId,
@@ -15236,18 +15767,18 @@ function createSchedulerMiddleware(options = {}) {
15236
15767
  {
15237
15768
  name: "schedule_after",
15238
15769
  description: "Schedule a system message after a relative delay",
15239
- schema: import_zod45.z.object({
15240
- delayMs: import_zod45.z.number().positive(),
15241
- maxRetries: import_zod45.z.number().int().min(0).optional(),
15242
- 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()
15243
15774
  })
15244
15775
  }
15245
15776
  ),
15246
- (0, import_langchain50.tool)(
15777
+ (0, import_langchain51.tool)(
15247
15778
  async (input, config) => {
15248
- const runConfig = getRunConfig(config);
15779
+ const runConfig = getRunConfig2(config);
15249
15780
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15250
- const taskId = (0, import_uuid4.v4)();
15781
+ const taskId = (0, import_uuid5.v4)();
15251
15782
  const success = await scheduleLattice.client.scheduleCron(
15252
15783
  taskId,
15253
15784
  AGENT_ADD_MESSAGE_TASK_TYPE,
@@ -15278,16 +15809,16 @@ function createSchedulerMiddleware(options = {}) {
15278
15809
  {
15279
15810
  name: "schedule_recurring",
15280
15811
  description: "Schedule a recurring system message with a cron expression",
15281
- schema: import_zod45.z.object({
15282
- cronExpression: import_zod45.z.string(),
15283
- maxRuns: import_zod45.z.number().int().positive().optional(),
15284
- expiresAt: import_zod45.z.number().optional(),
15285
- maxRetries: import_zod45.z.number().int().min(0).optional(),
15286
- 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()
15287
15818
  })
15288
15819
  }
15289
15820
  ),
15290
- (0, import_langchain50.tool)(
15821
+ (0, import_langchain51.tool)(
15291
15822
  async (input) => {
15292
15823
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15293
15824
  const success = await scheduleLattice.client.cancel(input.taskId);
@@ -15296,14 +15827,14 @@ function createSchedulerMiddleware(options = {}) {
15296
15827
  {
15297
15828
  name: "cancel_scheduled_task",
15298
15829
  description: "Cancel a scheduled task by task id",
15299
- schema: import_zod45.z.object({
15300
- taskId: import_zod45.z.string()
15830
+ schema: import_zod46.z.object({
15831
+ taskId: import_zod46.z.string()
15301
15832
  })
15302
15833
  }
15303
15834
  ),
15304
- (0, import_langchain50.tool)(
15835
+ (0, import_langchain51.tool)(
15305
15836
  async (input, config) => {
15306
- const runConfig = getRunConfig(config);
15837
+ const runConfig = getRunConfig2(config);
15307
15838
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
15308
15839
  const storage = scheduleLattice.client.getStorage();
15309
15840
  if (!storage) {
@@ -15323,11 +15854,11 @@ function createSchedulerMiddleware(options = {}) {
15323
15854
  {
15324
15855
  name: "list_scheduled_tasks",
15325
15856
  description: "List scheduled tasks for the current agent context",
15326
- schema: import_zod45.z.object({
15327
- status: import_zod45.z.enum(["pending", "running", "completed", "failed", "cancelled", "paused"]).optional(),
15328
- executionType: import_zod45.z.enum(["once", "cron"]).optional(),
15329
- limit: import_zod45.z.number().int().positive().optional(),
15330
- 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()
15331
15862
  })
15332
15863
  }
15333
15864
  )
@@ -16468,8 +16999,8 @@ var MemoryBackend = class {
16468
16999
 
16469
17000
  // src/deep_agent_new/middleware/todos.ts
16470
17001
  var import_langgraph8 = require("@langchain/langgraph");
16471
- var import_zod46 = require("zod");
16472
- var import_langchain51 = require("langchain");
17002
+ var import_zod47 = require("zod");
17003
+ var import_langchain52 = require("langchain");
16473
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.
16474
17005
  It also helps the user understand the progress of the task and overall progress of their requests.
16475
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.
@@ -16696,20 +17227,20 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
16696
17227
  ## Important To-Do List Usage Notes to Remember
16697
17228
  - The \`write_todos\` tool should never be called multiple times in parallel.
16698
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.`;
16699
- var TodoStatus = import_zod46.z.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
16700
- var TodoSchema = import_zod46.z.object({
16701
- 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"),
16702
17233
  status: TodoStatus
16703
17234
  });
16704
- 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([]) });
16705
17236
  function todoListMiddleware(options) {
16706
- const writeTodos = (0, import_langchain51.tool)(
17237
+ const writeTodos = (0, import_langchain52.tool)(
16707
17238
  ({ todos }, config) => {
16708
17239
  return new import_langgraph8.Command({
16709
17240
  update: {
16710
17241
  todos,
16711
17242
  messages: [
16712
- new import_langchain51.ToolMessage({
17243
+ new import_langchain52.ToolMessage({
16713
17244
  content: genUIMarkdown("todo_list", todos),
16714
17245
  tool_call_id: config.toolCall?.id
16715
17246
  })
@@ -16720,12 +17251,12 @@ function todoListMiddleware(options) {
16720
17251
  {
16721
17252
  name: "write_todos",
16722
17253
  description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
16723
- schema: import_zod46.z.object({
16724
- 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")
16725
17256
  })
16726
17257
  }
16727
17258
  );
16728
- return (0, import_langchain51.createMiddleware)({
17259
+ return (0, import_langchain52.createMiddleware)({
16729
17260
  name: "todoListMiddleware",
16730
17261
  stateSchema,
16731
17262
  tools: [writeTodos],
@@ -16777,13 +17308,13 @@ ${BASE_PROMPT}` : BASE_PROMPT;
16777
17308
  backend: filesystemBackend
16778
17309
  }),
16779
17310
  // Subagent middleware: Automatic conversation summarization when token limits are approached
16780
- (0, import_langchain52.summarizationMiddleware)({
17311
+ (0, import_langchain53.summarizationMiddleware)({
16781
17312
  model,
16782
17313
  trigger: { tokens: 17e4 },
16783
17314
  keep: { messages: 6 }
16784
17315
  }),
16785
17316
  // Subagent middleware: Anthropic prompt caching for improved performance
16786
- (0, import_langchain52.anthropicPromptCachingMiddleware)({
17317
+ (0, import_langchain53.anthropicPromptCachingMiddleware)({
16787
17318
  unsupportedModelBehavior: "ignore"
16788
17319
  }),
16789
17320
  // Subagent middleware: Patches tool calls for compatibility
@@ -16795,23 +17326,23 @@ ${BASE_PROMPT}` : BASE_PROMPT;
16795
17326
  generalPurposeAgent: true
16796
17327
  }),
16797
17328
  // Automatically summarizes conversation history when token limits are approached
16798
- (0, import_langchain52.summarizationMiddleware)({
17329
+ (0, import_langchain53.summarizationMiddleware)({
16799
17330
  model,
16800
17331
  trigger: { tokens: 17e4 },
16801
17332
  keep: { messages: 6 }
16802
17333
  }),
16803
17334
  // Enables Anthropic prompt caching for improved performance and reduced costs
16804
- (0, import_langchain52.anthropicPromptCachingMiddleware)({
17335
+ (0, import_langchain53.anthropicPromptCachingMiddleware)({
16805
17336
  unsupportedModelBehavior: "ignore"
16806
17337
  }),
16807
17338
  // Patches tool calls to ensure compatibility across different model providers
16808
17339
  createPatchToolCallsMiddleware()
16809
17340
  ];
16810
17341
  if (interruptOn) {
16811
- middleware.push((0, import_langchain52.humanInTheLoopMiddleware)({ interruptOn }));
17342
+ middleware.push((0, import_langchain53.humanInTheLoopMiddleware)({ interruptOn }));
16812
17343
  }
16813
17344
  middleware.push(...customMiddleware);
16814
- return (0, import_langchain52.createAgent)({
17345
+ return (0, import_langchain53.createAgent)({
16815
17346
  model,
16816
17347
  systemPrompt: finalSystemPrompt,
16817
17348
  tools,
@@ -16883,7 +17414,7 @@ init_MemoryLatticeManager();
16883
17414
 
16884
17415
  // src/agent_team/agent_team.ts
16885
17416
  var import_v35 = require("zod/v3");
16886
- var import_langchain55 = require("langchain");
17417
+ var import_langchain56 = require("langchain");
16887
17418
 
16888
17419
  // src/agent_team/types.ts
16889
17420
  var TaskStatus = /* @__PURE__ */ ((TaskStatus3) => {
@@ -17319,13 +17850,13 @@ var InMemoryMailboxStore = class {
17319
17850
 
17320
17851
  // src/agent_team/middleware/team.ts
17321
17852
  var import_v34 = require("zod/v3");
17322
- var import_langchain54 = require("langchain");
17853
+ var import_langchain55 = require("langchain");
17323
17854
  var import_langgraph10 = require("@langchain/langgraph");
17324
- var import_uuid5 = require("uuid");
17855
+ var import_uuid6 = require("uuid");
17325
17856
 
17326
17857
  // src/agent_team/middleware/teammate_tools.ts
17327
17858
  var import_v33 = require("zod/v3");
17328
- var import_langchain53 = require("langchain");
17859
+ var import_langchain54 = require("langchain");
17329
17860
  var import_langgraph9 = require("@langchain/langgraph");
17330
17861
 
17331
17862
  // src/agent_team/middleware/formatMessages.ts
@@ -17350,7 +17881,7 @@ ${meta}${body}`;
17350
17881
  // src/agent_team/middleware/teammate_tools.ts
17351
17882
  function createTeammateTools(options) {
17352
17883
  const { teamId, agentId, taskListStore, mailboxStore } = options;
17353
- const claimTaskTool = (0, import_langchain53.tool)(
17884
+ const claimTaskTool = (0, import_langchain54.tool)(
17354
17885
  async (input) => {
17355
17886
  const task = await taskListStore.claimTaskById(
17356
17887
  teamId,
@@ -17380,7 +17911,7 @@ function createTeammateTools(options) {
17380
17911
  })
17381
17912
  }
17382
17913
  );
17383
- const completeTaskTool = (0, import_langchain53.tool)(
17914
+ const completeTaskTool = (0, import_langchain54.tool)(
17384
17915
  async (input) => {
17385
17916
  const task = await taskListStore.completeTask(
17386
17917
  teamId,
@@ -17407,7 +17938,7 @@ function createTeammateTools(options) {
17407
17938
  })
17408
17939
  }
17409
17940
  );
17410
- const failTaskTool = (0, import_langchain53.tool)(
17941
+ const failTaskTool = (0, import_langchain54.tool)(
17411
17942
  async (input) => {
17412
17943
  const task = await taskListStore.failTask(
17413
17944
  teamId,
@@ -17434,7 +17965,7 @@ function createTeammateTools(options) {
17434
17965
  })
17435
17966
  }
17436
17967
  );
17437
- const sendMessageTool = (0, import_langchain53.tool)(
17968
+ const sendMessageTool = (0, import_langchain54.tool)(
17438
17969
  async (input) => {
17439
17970
  await mailboxStore.sendMessage(
17440
17971
  teamId,
@@ -17472,7 +18003,7 @@ function createTeammateTools(options) {
17472
18003
  read: msg.read
17473
18004
  }));
17474
18005
  };
17475
- const readMessagesTool = (0, import_langchain53.tool)(
18006
+ const readMessagesTool = (0, import_langchain54.tool)(
17476
18007
  async (input, config) => {
17477
18008
  const formatAndMarkAsRead = async (msgs2) => {
17478
18009
  for (const msg of msgs2) {
@@ -17484,7 +18015,7 @@ function createTeammateTools(options) {
17484
18015
  if (msgs.length > 0) {
17485
18016
  const formatted2 = await formatAndMarkAsRead(msgs);
17486
18017
  const relevantMsgs2 = await getRelevantMessagesForState();
17487
- const toolMessage2 = new import_langchain53.ToolMessage({
18018
+ const toolMessage2 = new import_langchain54.ToolMessage({
17488
18019
  content: formatted2,
17489
18020
  tool_call_id: config.toolCall?.id,
17490
18021
  name: "read_messages"
@@ -17509,7 +18040,7 @@ function createTeammateTools(options) {
17509
18040
  });
17510
18041
  const relevantMsgs = await getRelevantMessagesForState();
17511
18042
  if (msgs.length === 0) {
17512
- const toolMessage2 = new import_langchain53.ToolMessage({
18043
+ const toolMessage2 = new import_langchain54.ToolMessage({
17513
18044
  content: "No unread messages.",
17514
18045
  tool_call_id: config.toolCall?.id,
17515
18046
  name: "read_messages"
@@ -17519,7 +18050,7 @@ function createTeammateTools(options) {
17519
18050
  });
17520
18051
  }
17521
18052
  const formatted = await formatAndMarkAsRead(msgs);
17522
- const toolMessage = new import_langchain53.ToolMessage({
18053
+ const toolMessage = new import_langchain54.ToolMessage({
17523
18054
  content: formatted,
17524
18055
  tool_call_id: config.toolCall?.id,
17525
18056
  name: "read_messages"
@@ -17534,7 +18065,7 @@ function createTeammateTools(options) {
17534
18065
  schema: import_v33.z.object({})
17535
18066
  }
17536
18067
  );
17537
- const checkTasksTool = (0, import_langchain53.tool)(
18068
+ const checkTasksTool = (0, import_langchain54.tool)(
17538
18069
  async () => {
17539
18070
  const tasks = await taskListStore.getAllTasks(teamId);
17540
18071
  return formatTaskSummary(tasks);
@@ -17545,7 +18076,7 @@ function createTeammateTools(options) {
17545
18076
  schema: import_v33.z.object({})
17546
18077
  }
17547
18078
  );
17548
- const broadcastMessageTool = (0, import_langchain53.tool)(
18079
+ const broadcastMessageTool = (0, import_langchain54.tool)(
17549
18080
  async (input) => {
17550
18081
  const allAgents = await mailboxStore.getRegisteredAgents(teamId);
17551
18082
  const recipients = allAgents.filter((a) => a !== agentId);
@@ -17731,7 +18262,7 @@ You have access to these tools:
17731
18262
  - \`read_messages\`: Read messages from team_lead or teammates
17732
18263
  - \`check_tasks\`: Get current status of all tasks in the team`;
17733
18264
  const assistantId = getTeammateAssistantId(ctx.teamId, spec.name);
17734
- agent = (0, import_langchain54.createAgent)({
18265
+ agent = (0, import_langchain55.createAgent)({
17735
18266
  model: spec.model ?? ctx.defaultModel,
17736
18267
  systemPrompt: teammatePrompt,
17737
18268
  tools: allTools,
@@ -17800,19 +18331,19 @@ async function spawnTeammate(options) {
17800
18331
  function createTeamMiddleware(options) {
17801
18332
  const { teamConfig, taskListStore, mailboxStore, tenantId: tenantId2 } = options;
17802
18333
  const defaultModel = teamConfig.model ?? "claude-sonnet-4-5-20250929";
17803
- const createTeamTool = (0, import_langchain54.tool)(
18334
+ const createTeamTool = (0, import_langchain55.tool)(
17804
18335
  async (input, config) => {
17805
18336
  const state = (0, import_langgraph10.getCurrentTaskInput)();
17806
18337
  if (state?.team?.teamId) {
17807
18338
  const existingId = state.team.teamId;
17808
- const msg = new import_langchain54.ToolMessage({
18339
+ const msg = new import_langchain55.ToolMessage({
17809
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.`,
17810
18341
  tool_call_id: config.toolCall?.id,
17811
18342
  name: "create_team"
17812
18343
  });
17813
18344
  return msg;
17814
18345
  }
17815
- const teamId = (0, import_uuid5.v4)();
18346
+ const teamId = (0, import_uuid6.v4)();
17816
18347
  const createdTasks = await taskListStore.addTasks(
17817
18348
  teamId,
17818
18349
  input.tasks.map((t) => ({
@@ -17894,7 +18425,7 @@ Teammates are now working in the background. Keep calling \`check_tasks\` and \`
17894
18425
  \`\`\`json
17895
18426
  ${teamJson}
17896
18427
  \`\`\``;
17897
- const toolMessage = new import_langchain54.ToolMessage({
18428
+ const toolMessage = new import_langchain55.ToolMessage({
17898
18429
  content: summary,
17899
18430
  tool_call_id: config.toolCall?.id,
17900
18431
  name: "create_team"
@@ -17979,7 +18510,7 @@ After calling create_team, you MUST:
17979
18510
  if (state?.team?.teamId) return state.team.teamId;
17980
18511
  throw new Error("No team_id provided and no team in state. Call create_team first.");
17981
18512
  };
17982
- const addTasksTool = (0, import_langchain54.tool)(
18513
+ const addTasksTool = (0, import_langchain55.tool)(
17983
18514
  async (input, config) => {
17984
18515
  const teamId = resolveTeamId();
17985
18516
  const created = await taskListStore.addTasks(
@@ -17993,7 +18524,7 @@ After calling create_team, you MUST:
17993
18524
  }))
17994
18525
  );
17995
18526
  const summary = created.map((t) => `- ${t.id}: "${t.title}"`).join("\n");
17996
- return new import_langchain54.ToolMessage({
18527
+ return new import_langchain55.ToolMessage({
17997
18528
  content: `Added ${created.length} task(s) to team ${teamId}:
17998
18529
  ${summary}
17999
18530
  Sleeping teammates will wake up and claim these.`,
@@ -18044,20 +18575,20 @@ IMPORTANT: Assigning to a specific teammate
18044
18575
  })
18045
18576
  }
18046
18577
  );
18047
- const assignTaskTool = (0, import_langchain54.tool)(
18578
+ const assignTaskTool = (0, import_langchain55.tool)(
18048
18579
  async (input, config) => {
18049
18580
  const teamId = resolveTeamId();
18050
18581
  const task = await taskListStore.updateTask(teamId, input.task_id, {
18051
18582
  assignee: input.assignee
18052
18583
  });
18053
18584
  if (!task) {
18054
- return new import_langchain54.ToolMessage({
18585
+ return new import_langchain55.ToolMessage({
18055
18586
  content: `Task ${input.task_id} not found in team ${teamId}.`,
18056
18587
  tool_call_id: config.toolCall?.id,
18057
18588
  name: "assign_task"
18058
18589
  });
18059
18590
  }
18060
- return new import_langchain54.ToolMessage({
18591
+ return new import_langchain55.ToolMessage({
18061
18592
  content: `Task "${task.title}" (${task.id}) assigned to ${input.assignee}.`,
18062
18593
  tool_call_id: config.toolCall?.id,
18063
18594
  name: "assign_task"
@@ -18072,20 +18603,20 @@ IMPORTANT: Assigning to a specific teammate
18072
18603
  })
18073
18604
  }
18074
18605
  );
18075
- const setTaskStatusTool = (0, import_langchain54.tool)(
18606
+ const setTaskStatusTool = (0, import_langchain55.tool)(
18076
18607
  async (input, config) => {
18077
18608
  const teamId = resolveTeamId();
18078
18609
  const task = await taskListStore.updateTask(teamId, input.task_id, {
18079
18610
  status: input.status
18080
18611
  });
18081
18612
  if (!task) {
18082
- return new import_langchain54.ToolMessage({
18613
+ return new import_langchain55.ToolMessage({
18083
18614
  content: `Task ${input.task_id} not found in team ${teamId}.`,
18084
18615
  tool_call_id: config.toolCall?.id,
18085
18616
  name: "set_task_status"
18086
18617
  });
18087
18618
  }
18088
- return new import_langchain54.ToolMessage({
18619
+ return new import_langchain55.ToolMessage({
18089
18620
  content: `Task "${task.title}" (${task.id}) status set to ${input.status}.`,
18090
18621
  tool_call_id: config.toolCall?.id,
18091
18622
  name: "set_task_status"
@@ -18100,20 +18631,20 @@ IMPORTANT: Assigning to a specific teammate
18100
18631
  })
18101
18632
  }
18102
18633
  );
18103
- const setTaskDependenciesTool = (0, import_langchain54.tool)(
18634
+ const setTaskDependenciesTool = (0, import_langchain55.tool)(
18104
18635
  async (input, config) => {
18105
18636
  const teamId = resolveTeamId();
18106
18637
  const task = await taskListStore.updateTask(teamId, input.task_id, {
18107
18638
  dependencies: input.dependencies
18108
18639
  });
18109
18640
  if (!task) {
18110
- return new import_langchain54.ToolMessage({
18641
+ return new import_langchain55.ToolMessage({
18111
18642
  content: `Task ${input.task_id} not found in team ${teamId}.`,
18112
18643
  tool_call_id: config.toolCall?.id,
18113
18644
  name: "set_task_dependencies"
18114
18645
  });
18115
18646
  }
18116
- return new import_langchain54.ToolMessage({
18647
+ return new import_langchain55.ToolMessage({
18117
18648
  content: `Task "${task.title}" (${task.id}) dependencies set to [${input.dependencies.join(", ")}].`,
18118
18649
  tool_call_id: config.toolCall?.id,
18119
18650
  name: "set_task_dependencies"
@@ -18128,7 +18659,7 @@ IMPORTANT: Assigning to a specific teammate
18128
18659
  })
18129
18660
  }
18130
18661
  );
18131
- const checkTasksTool = (0, import_langchain54.tool)(
18662
+ const checkTasksTool = (0, import_langchain55.tool)(
18132
18663
  async (input, config) => {
18133
18664
  const teamId = resolveTeamId();
18134
18665
  const tasks = await taskListStore.getAllTasks(teamId);
@@ -18137,7 +18668,7 @@ IMPORTANT: Assigning to a specific teammate
18137
18668
  update: {
18138
18669
  tasks: tasksSnapshot,
18139
18670
  messages: [
18140
- new import_langchain54.ToolMessage({
18671
+ new import_langchain55.ToolMessage({
18141
18672
  content: formatTaskSummary(tasks),
18142
18673
  tool_call_id: config.toolCall?.id,
18143
18674
  name: "check_tasks"
@@ -18173,7 +18704,7 @@ Task Status Values:
18173
18704
  })
18174
18705
  }
18175
18706
  );
18176
- const sendMessageTool = (0, import_langchain54.tool)(
18707
+ const sendMessageTool = (0, import_langchain55.tool)(
18177
18708
  async (input, config) => {
18178
18709
  const teamId = resolveTeamId();
18179
18710
  await mailboxStore.sendMessage(
@@ -18183,7 +18714,7 @@ Task Status Values:
18183
18714
  input.content,
18184
18715
  "direct_message" /* DIRECT_MESSAGE */
18185
18716
  );
18186
- return new import_langchain54.ToolMessage({
18717
+ return new import_langchain55.ToolMessage({
18187
18718
  content: `Message sent to ${input.to}.`,
18188
18719
  tool_call_id: config.toolCall?.id,
18189
18720
  name: "send_message"
@@ -18198,7 +18729,7 @@ Task Status Values:
18198
18729
  })
18199
18730
  }
18200
18731
  );
18201
- const readMessagesTool = (0, import_langchain54.tool)(
18732
+ const readMessagesTool = (0, import_langchain55.tool)(
18202
18733
  async (input, config) => {
18203
18734
  const teamId = resolveTeamId();
18204
18735
  const formatAndMarkAsRead = async (msgs2) => {
@@ -18226,7 +18757,7 @@ Task Status Values:
18226
18757
  if (msgs.length > 0) {
18227
18758
  const formatted2 = await formatAndMarkAsRead(msgs);
18228
18759
  const allTeamMessages2 = await getAllTeamMessagesForState();
18229
- const toolMessage2 = new import_langchain54.ToolMessage({
18760
+ const toolMessage2 = new import_langchain55.ToolMessage({
18230
18761
  content: formatted2,
18231
18762
  tool_call_id: config.toolCall?.id,
18232
18763
  name: "read_messages"
@@ -18258,7 +18789,7 @@ Task Status Values:
18258
18789
  );
18259
18790
  const allTeamMessages = await getAllTeamMessagesForState();
18260
18791
  if (msgs.length === 0) {
18261
- const toolMessage2 = new import_langchain54.ToolMessage({
18792
+ const toolMessage2 = new import_langchain55.ToolMessage({
18262
18793
  content: "No unread messages from teammates.",
18263
18794
  tool_call_id: config.toolCall?.id,
18264
18795
  name: "read_messages"
@@ -18268,7 +18799,7 @@ Task Status Values:
18268
18799
  });
18269
18800
  }
18270
18801
  const formatted = await formatAndMarkAsRead(msgs);
18271
- const toolMessage = new import_langchain54.ToolMessage({
18802
+ const toolMessage = new import_langchain55.ToolMessage({
18272
18803
  content: formatted,
18273
18804
  tool_call_id: config.toolCall?.id,
18274
18805
  name: "read_messages"
@@ -18285,7 +18816,7 @@ Task Status Values:
18285
18816
  })
18286
18817
  }
18287
18818
  );
18288
- const disbandTeamTool = (0, import_langchain54.tool)(
18819
+ const disbandTeamTool = (0, import_langchain55.tool)(
18289
18820
  async (input, config) => {
18290
18821
  const teamId = resolveTeamId();
18291
18822
  await mailboxStore.broadcastMessage(
@@ -18295,7 +18826,7 @@ Task Status Values:
18295
18826
  "shutdown_request" /* SHUTDOWN_REQUEST */
18296
18827
  );
18297
18828
  await new Promise((r) => setTimeout(r, 2e3));
18298
- return new import_langchain54.ToolMessage({
18829
+ return new import_langchain55.ToolMessage({
18299
18830
  content: `Team ${teamId} has been disbanded. All teammates notified and resources cleaned up.`,
18300
18831
  tool_call_id: config.toolCall?.id,
18301
18832
  name: "disband_team"
@@ -18306,7 +18837,7 @@ Task Status Values:
18306
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."
18307
18838
  }
18308
18839
  );
18309
- const broadcastMessageTool = (0, import_langchain54.tool)(
18840
+ const broadcastMessageTool = (0, import_langchain55.tool)(
18310
18841
  async (input, config) => {
18311
18842
  const teamId = resolveTeamId();
18312
18843
  await mailboxStore.broadcastMessage(
@@ -18315,7 +18846,7 @@ Task Status Values:
18315
18846
  input.content,
18316
18847
  "broadcast" /* BROADCAST */
18317
18848
  );
18318
- return new import_langchain54.ToolMessage({
18849
+ return new import_langchain55.ToolMessage({
18319
18850
  content: `Broadcast message sent to all teammates.`,
18320
18851
  tool_call_id: config.toolCall?.id,
18321
18852
  name: "broadcast_message"
@@ -18329,7 +18860,7 @@ Task Status Values:
18329
18860
  })
18330
18861
  }
18331
18862
  );
18332
- return (0, import_langchain54.createMiddleware)({
18863
+ return (0, import_langchain55.createMiddleware)({
18333
18864
  name: "teamMiddleware",
18334
18865
  tools: [
18335
18866
  createTeamTool,
@@ -18438,7 +18969,7 @@ function createAgentTeam(config) {
18438
18969
  ];
18439
18970
  const systemPrompt = config.systemPrompt + "\n\n" + TEAM_LEAD_BASE_PROMPT;
18440
18971
  const stateSchema2 = createReactAgentSchema(TEAM_STATE_SCHEMA);
18441
- return (0, import_langchain55.createAgent)({
18972
+ return (0, import_langchain56.createAgent)({
18442
18973
  model: config.model ?? "claude-sonnet-4-5-20250929",
18443
18974
  systemPrompt,
18444
18975
  tools: [],
@@ -18507,10 +19038,10 @@ var TeamAgentGraphBuilder = class {
18507
19038
 
18508
19039
  // src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
18509
19040
  var import_langgraph11 = require("@langchain/langgraph");
18510
- var import_messages3 = require("@langchain/core/messages");
19041
+ var import_messages4 = require("@langchain/core/messages");
18511
19042
 
18512
19043
  // src/services/a2a-client.ts
18513
- var import_uuid6 = require("uuid");
19044
+ var import_uuid7 = require("uuid");
18514
19045
  var A2ARemoteError = class extends Error {
18515
19046
  constructor(message, statusCode, body) {
18516
19047
  super(message);
@@ -18557,7 +19088,7 @@ var A2ARemoteClient = class {
18557
19088
  */
18558
19089
  async sendMessage(text) {
18559
19090
  await this.resolve();
18560
- const taskId = (0, import_uuid6.v4)();
19091
+ const taskId = (0, import_uuid7.v4)();
18561
19092
  const body = JSON.stringify({
18562
19093
  jsonrpc: "2.0",
18563
19094
  method: "tasks/send",
@@ -18683,7 +19214,7 @@ var RemoteAgentGraphBuilder = class {
18683
19214
  if (!text) {
18684
19215
  return {
18685
19216
  messages: [
18686
- new import_messages3.AIMessage("No text input provided to remote agent.")
19217
+ new import_messages4.AIMessage("No text input provided to remote agent.")
18687
19218
  ]
18688
19219
  };
18689
19220
  }
@@ -18694,13 +19225,13 @@ User request:
18694
19225
  ${text}` : text;
18695
19226
  const response = await client.sendMessage(fullPrompt);
18696
19227
  return {
18697
- messages: [new import_messages3.AIMessage(response)]
19228
+ messages: [new import_messages4.AIMessage(response)]
18698
19229
  };
18699
19230
  } catch (error) {
18700
19231
  const msg = error.message ?? String(error);
18701
19232
  return {
18702
19233
  messages: [
18703
- new import_messages3.AIMessage(`Remote A2A agent error: ${msg}`)
19234
+ new import_messages4.AIMessage(`Remote A2A agent error: ${msg}`)
18704
19235
  ]
18705
19236
  };
18706
19237
  }
@@ -18727,7 +19258,7 @@ function extractLastHumanMessage(messages) {
18727
19258
  }
18728
19259
 
18729
19260
  // src/agent_lattice/builders/WorkflowAgentGraphBuilder.ts
18730
- var import_langchain56 = require("langchain");
19261
+ var import_langchain57 = require("langchain");
18731
19262
  init_MemoryLatticeManager();
18732
19263
  var import_protocols10 = require("@axiom-lattice/protocols");
18733
19264
  init_compile();
@@ -18792,7 +19323,7 @@ var WorkflowAgentGraphBuilder = class {
18792
19323
  const noWrapMiddlewares = stripWrapModelCallHook(middlewares);
18793
19324
  const noWrapAskMiddlewares = stripWrapModelCallHook(askMiddlewares);
18794
19325
  console.log(`[WF BUILDER] building default agent | toolCount=${tools.length} | middlewareCount=${middlewares.length}`);
18795
- const defaultAgent = (0, import_langchain56.createAgent)({
19326
+ const defaultAgent = (0, import_langchain57.createAgent)({
18796
19327
  model: params.model,
18797
19328
  tools,
18798
19329
  systemPrompt: buildStepSystemPrompt(false, params.prompt),
@@ -18812,7 +19343,7 @@ var WorkflowAgentGraphBuilder = class {
18812
19343
  console.log(`[WF BUILDER] resolveAgent: cacheKey=${key4.slice(0, 80)}... | cached=${agentCache.has(key4)}`);
18813
19344
  if (!agentCache.has(key4)) {
18814
19345
  console.log(`[WF BUILDER] creating ${isAsk ? "ask" : "agent"} with responseFormat`);
18815
- const agent = (0, import_langchain56.createAgent)({
19346
+ const agent = (0, import_langchain57.createAgent)({
18816
19347
  model: params.model,
18817
19348
  tools,
18818
19349
  systemPrompt: buildStepSystemPrompt(isAsk, params.prompt),
@@ -18828,7 +19359,7 @@ var WorkflowAgentGraphBuilder = class {
18828
19359
  const key4 = "ask:default";
18829
19360
  if (!agentCache.has(key4)) {
18830
19361
  console.log(`[WF BUILDER] creating ask default agent`);
18831
- const agent = (0, import_langchain56.createAgent)({
19362
+ const agent = (0, import_langchain57.createAgent)({
18832
19363
  model: params.model,
18833
19364
  tools,
18834
19365
  systemPrompt: buildStepSystemPrompt(true, params.prompt),
@@ -19347,6 +19878,22 @@ async function configureStores(stores, options = {}) {
19347
19878
  storeLatticeManager.registerLattice("default", t, store);
19348
19879
  }
19349
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
+ }
19350
19897
  if (options.autoDisposeStores) {
19351
19898
  registerSignalCleanup();
19352
19899
  _disposables.push(...localDisposables);
@@ -19491,7 +20038,7 @@ description: Create new skills, modify and improve existing skills. Use this ski
19491
20038
  license: MIT
19492
20039
  metadata:
19493
20040
  category: meta
19494
- version: "2.0"
20041
+ version: "3.0"
19495
20042
  ---
19496
20043
 
19497
20044
  # Skill Creator
@@ -19590,6 +20137,160 @@ Instructional content for the agent.
19590
20137
 
19591
20138
  ---
19592
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
+
19593
20294
  ## Writing Guide
19594
20295
 
19595
20296
  ### The Description Field
@@ -19640,6 +20341,7 @@ A well-written skill body typically includes:
19640
20341
  - **Guidelines**: Rules, constraints, quality standards, and the WHY behind them
19641
20342
  - **Scenarios**: 2-3 common scenarios with concrete examples of inputs and expected outputs
19642
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
19643
20345
 
19644
20346
  ---
19645
20347
 
@@ -19647,10 +20349,11 @@ A well-written skill body typically includes:
19647
20349
 
19648
20350
  After writing the draft, test it:
19649
20351
 
19650
- 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?"
19651
- 2. **Run the skill** against each test prompt to see what the agent produces
19652
- 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?)
19653
- 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?
19654
20357
 
19655
20358
  ### Improving the Skill
19656
20359
 
@@ -19686,10 +20389,11 @@ The agent sees skills as a list of name + description pairs. It decides whether
19686
20389
  ## Step 6: Package and Present
19687
20390
 
19688
20391
  When the skill is ready:
19689
- 1. Verify the SKILL.md is at \`/root/.agents/skills/{skill-name}/SKILL.md\` with correct frontmatter
19690
- 2. Confirm all resource files are in place under \`resources/\`
19691
- 3. Tell the user the skill is ready and available at its path
19692
- 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
19693
20397
 
19694
20398
  ## Updating Existing Skills
19695
20399
 
@@ -19698,7 +20402,8 @@ When the user wants to improve an existing skill:
19698
20402
  2. Understand what it currently does and where it falls short
19699
20403
  3. Follow the same interview \u2192 draft \u2192 test \u2192 iterate loop
19700
20404
  4. **Preserve the original name** \u2014 the directory name and \`name\` frontmatter field should stay the same
19701
- 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
19702
20407
 
19703
20408
  ---
19704
20409
 
@@ -19732,6 +20437,8 @@ metadata:
19732
20437
 
19733
20438
  **You** (write): Create \`/root/.agents/skills/csv-analyzer/SKILL.md\`
19734
20439
 
20440
+ **You** (verify): Run the subSkills consistency check \u2014 no subSkills, no \`[[refs]]\`, all good.
20441
+
19735
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."
19736
20443
 
19737
20444
  Then iterate based on what the user says.
@@ -20791,8 +21498,8 @@ var InMemoryMenuStore = class {
20791
21498
  };
20792
21499
 
20793
21500
  // src/agent_lattice/agentArchitectTools.ts
20794
- var import_zod47 = __toESM(require("zod"));
20795
- var import_uuid7 = require("uuid");
21501
+ var import_zod48 = __toESM(require("zod"));
21502
+ var import_uuid8 = require("uuid");
20796
21503
  var import_protocols12 = require("@axiom-lattice/protocols");
20797
21504
  function getTenantId(exeConfig) {
20798
21505
  const runConfig = exeConfig?.configurable?.runConfig || {};
@@ -20821,7 +21528,7 @@ registerToolLattice(
20821
21528
  {
20822
21529
  name: "list_agents",
20823
21530
  description: "List all agents for the current workspace. Returns a summary with id, name, description, and type for each agent.",
20824
- schema: import_zod47.default.object({})
21531
+ schema: import_zod48.default.object({})
20825
21532
  },
20826
21533
  async (_input, exeConfig) => {
20827
21534
  try {
@@ -20848,8 +21555,8 @@ registerToolLattice(
20848
21555
  {
20849
21556
  name: "get_agent",
20850
21557
  description: "Get the full configuration of a specific agent by its ID. Returns the complete AgentConfig including prompt, middleware, tools, and sub-agents.",
20851
- schema: import_zod47.default.object({
20852
- 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")
20853
21560
  })
20854
21561
  },
20855
21562
  async (input, exeConfig) => {
@@ -20866,24 +21573,24 @@ registerToolLattice(
20866
21573
  }
20867
21574
  }
20868
21575
  );
20869
- var middlewareConfigSchema = import_zod47.default.object({
20870
- id: import_zod47.default.string(),
20871
- type: import_zod47.default.string(),
20872
- name: import_zod47.default.string(),
20873
- description: import_zod47.default.string(),
20874
- enabled: import_zod47.default.boolean(),
20875
- 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()
20876
21583
  });
20877
- var createAgentSchema = import_zod47.default.object({
20878
- 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')."),
20879
- description: import_zod47.default.string().optional().describe("Short description"),
20880
- 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."),
20881
- prompt: import_zod47.default.string().describe("System prompt for the agent"),
20882
- 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."),
20883
- 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: {}."),
20884
- subAgents: import_zod47.default.array(import_zod47.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
20885
- internalSubAgents: import_zod47.default.array(import_zod47.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
20886
- 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")
20887
21594
  });
20888
21595
  registerToolLattice(
20889
21596
  "create_agent",
@@ -20921,14 +21628,14 @@ registerToolLattice(
20921
21628
  }
20922
21629
  }
20923
21630
  );
20924
- var createWorkflowSchema = import_zod47.default.object({
20925
- name: import_zod47.default.string().describe("Display name for the workflow agent"),
20926
- description: import_zod47.default.string().optional().describe("Short description"),
20927
- skillLoaded: import_zod47.default.literal(true).describe("MUST be true. Set after loading the 'create-workflow' skill."),
20928
- yaml: import_zod47.default.string().describe("The YAML workflow definition in linear DSL format (steps execute top-to-bottom, use parallel: for concurrency)"),
20929
- tools: import_zod47.default.array(import_zod47.default.string()).optional().describe("Tool keys for the workflow agent"),
20930
- middleware: import_zod47.default.array(middlewareConfigSchema).optional().describe("Middleware configs"),
20931
- 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")
20932
21639
  });
20933
21640
  registerToolLattice(
20934
21641
  "create_workflow",
@@ -20977,8 +21684,8 @@ registerToolLattice(
20977
21684
  {
20978
21685
  name: "validate_workflow",
20979
21686
  description: "Validate a workflow agent's DSL for correctness by compiling it.",
20980
- schema: import_zod47.default.object({
20981
- 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")
20982
21689
  })
20983
21690
  },
20984
21691
  async (input, exeConfig) => {
@@ -21075,14 +21782,14 @@ registerToolLattice(
21075
21782
  }
21076
21783
  }
21077
21784
  );
21078
- var updateWorkflowSchema = import_zod47.default.object({
21079
- id: import_zod47.default.string().describe("The workflow agent ID to update"),
21080
- name: import_zod47.default.string().optional().describe("New display name"),
21081
- description: import_zod47.default.string().optional().describe("New description"),
21082
- yaml: import_zod47.default.string().optional().describe("Replacement YAML workflow DSL. Omit to keep existing."),
21083
- tools: import_zod47.default.array(import_zod47.default.string()).optional().describe("Replacement tool keys"),
21084
- middleware: import_zod47.default.array(middlewareConfigSchema).optional().describe("Replacement middleware configs"),
21085
- 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")
21086
21793
  });
21087
21794
  registerToolLattice(
21088
21795
  "update_workflow",
@@ -21143,18 +21850,18 @@ registerToolLattice(
21143
21850
  }
21144
21851
  }
21145
21852
  );
21146
- var updateAgentSchema = import_zod47.default.object({
21147
- id: import_zod47.default.string().describe("The agent ID to update"),
21148
- config: import_zod47.default.object({
21149
- name: import_zod47.default.string().optional().describe("New display name for the agent"),
21150
- description: import_zod47.default.string().optional().describe("New short description"),
21151
- type: import_zod47.default.enum(["react", "deep_agent"]).optional().describe("Agent type"),
21152
- prompt: import_zod47.default.string().optional().describe("New system prompt for the agent"),
21153
- 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."),
21154
- 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: {}."),
21155
- subAgents: import_zod47.default.array(import_zod47.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
21156
- internalSubAgents: import_zod47.default.array(import_zod47.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
21157
- 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")
21158
21865
  }).describe("Configuration fields to update. Only include the fields you want to change.")
21159
21866
  });
21160
21867
  registerToolLattice(
@@ -21192,8 +21899,8 @@ registerToolLattice(
21192
21899
  {
21193
21900
  name: "delete_agent",
21194
21901
  description: "Permanently delete an agent by its ID. This action cannot be undone.",
21195
- schema: import_zod47.default.object({
21196
- 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")
21197
21904
  })
21198
21905
  },
21199
21906
  async (input, exeConfig) => {
@@ -21219,7 +21926,7 @@ registerToolLattice(
21219
21926
  {
21220
21927
  name: "list_tools",
21221
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.",
21222
- schema: import_zod47.default.object({})
21929
+ schema: import_zod48.default.object({})
21223
21930
  },
21224
21931
  async (_input, _exeConfig) => {
21225
21932
  try {
@@ -21241,9 +21948,9 @@ registerToolLattice(
21241
21948
  {
21242
21949
  name: "invoke_agent",
21243
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).",
21244
- schema: import_zod47.default.object({
21245
- id: import_zod47.default.string().describe("The agent ID to invoke"),
21246
- 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")
21247
21954
  })
21248
21955
  },
21249
21956
  async (input, exeConfig) => {
@@ -21258,7 +21965,7 @@ registerToolLattice(
21258
21965
  if (!existing) {
21259
21966
  return JSON.stringify({ error: `Agent '${id}' not found` });
21260
21967
  }
21261
- const threadId = (0, import_uuid7.v4)();
21968
+ const threadId = (0, import_uuid8.v4)();
21262
21969
  const agent = new Agent({
21263
21970
  tenant_id: tenantId2,
21264
21971
  assistant_id: id,
@@ -21279,7 +21986,7 @@ registerToolLattice(
21279
21986
  {
21280
21987
  name: "list_middleware_types",
21281
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",
21282
- schema: import_zod47.default.object({})
21989
+ schema: import_zod48.default.object({})
21283
21990
  },
21284
21991
  async () => {
21285
21992
  const metas = PluginRegistry.listMeta();
@@ -21291,8 +21998,8 @@ registerToolLattice(
21291
21998
  {
21292
21999
  name: "list_connections",
21293
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, ... }] } }",
21294
- schema: import_zod47.default.object({
21295
- 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")
21296
22003
  }),
21297
22004
  needUserApprove: false
21298
22005
  },
@@ -21873,6 +22580,20 @@ function ensureBuiltinAgentsForTenant(tenantId2) {
21873
22580
  }
21874
22581
  }
21875
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
+
21876
22597
  // src/agent_lattice/AgentLatticeManager.ts
21877
22598
  function assistantToConfig(assistant) {
21878
22599
  const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? { ...assistant.graphDefinition } : {};
@@ -22071,6 +22792,7 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
22071
22792
  */
22072
22793
  async initializeStoredAssistantsForTenant(tenantId2) {
22073
22794
  ensureBuiltinAgentsForTenant(tenantId2);
22795
+ ensurePluginAgentsForTenant(tenantId2);
22074
22796
  try {
22075
22797
  const storeLattice = getStoreLattice("default", "assistant");
22076
22798
  const assistants = await storeLattice.store.getAllAssistants(tenantId2);
@@ -25250,8 +25972,8 @@ function clearEvalRunService() {
25250
25972
  }
25251
25973
 
25252
25974
  // src/eval_lattice/LatticeEval.ts
25253
- var import_messages5 = require("@langchain/core/messages");
25254
- var import_uuid8 = require("uuid");
25975
+ var import_messages6 = require("@langchain/core/messages");
25976
+ var import_uuid9 = require("uuid");
25255
25977
  var _LatticeEval = class _LatticeEval {
25256
25978
  constructor(config = {}) {
25257
25979
  this.inMemoryLogs = [];
@@ -25391,7 +26113,7 @@ var _LatticeEval = class _LatticeEval {
25391
26113
  }
25392
26114
  async evaluateCase(evalCase) {
25393
26115
  const startedAt = Date.now();
25394
- const threadId = `${evalCase.caseId}||${(0, import_uuid8.v4)()}`;
26116
+ const threadId = `${evalCase.caseId}||${(0, import_uuid9.v4)()}`;
25395
26117
  this.inMemoryLogs = [];
25396
26118
  this.lastThreadId = threadId;
25397
26119
  this.lastJudgeThreadId = void 0;
@@ -25533,7 +26255,7 @@ ${rubricsSection}
25533
26255
 
25534
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`;
25535
26257
  this.lastTestPrompt = testPrompt;
25536
- const judgeThreadId = (0, import_uuid8.v4)();
26258
+ const judgeThreadId = (0, import_uuid9.v4)();
25537
26259
  this.lastJudgeThreadId = judgeThreadId;
25538
26260
  const judgeAgentKey = this.config.judge_agent_key || "LatticeTest";
25539
26261
  const judgeTenantId = this.config.tenant_id || "default";
@@ -25541,7 +26263,7 @@ ${rubricsSection}
25541
26263
  const judgeAgent = await getAgentClient(judgeTenantId, judgeAgentKey);
25542
26264
  const testResponse = await judgeAgent.invoke(
25543
26265
  {
25544
- messages: [new import_messages5.HumanMessage(testPrompt)]
26266
+ messages: [new import_messages6.HumanMessage(testPrompt)]
25545
26267
  },
25546
26268
  {
25547
26269
  configurable: {
@@ -26133,15 +26855,15 @@ function clearEncryptionKeyCache() {
26133
26855
  }
26134
26856
 
26135
26857
  // src/middlewares/skillMiddleware.ts
26136
- var import_langchain59 = require("langchain");
26858
+ var import_langchain60 = require("langchain");
26137
26859
 
26138
26860
  // src/tool_lattice/skill/load_skills.ts
26139
- var import_zod48 = __toESM(require("zod"));
26140
- var import_langchain57 = require("langchain");
26141
-
26142
- // src/tool_lattice/skill/load_skill_content.ts
26143
26861
  var import_zod49 = __toESM(require("zod"));
26144
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");
26145
26867
  var LOAD_SKILL_CONTENT_DESCRIPTION = `
26146
26868
  Execute a skill within the main conversation
26147
26869
 
@@ -26179,7 +26901,7 @@ function getSandboxFromExeConfig(_exe_config) {
26179
26901
  });
26180
26902
  }
26181
26903
  var createLoadSkillContentTool = (pluginSkillContents) => {
26182
- return (0, import_langchain58.tool)(
26904
+ return (0, import_langchain59.tool)(
26183
26905
  async (input, _exe_config) => {
26184
26906
  try {
26185
26907
  if (pluginSkillContents?.[input.skill_name]) {
@@ -26228,8 +26950,8 @@ var createLoadSkillContentTool = (pluginSkillContents) => {
26228
26950
  {
26229
26951
  name: "skill",
26230
26952
  description: LOAD_SKILL_CONTENT_DESCRIPTION,
26231
- schema: import_zod49.default.object({
26232
- 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")
26233
26955
  })
26234
26956
  }
26235
26957
  );
@@ -26243,7 +26965,7 @@ function createSkillMiddleware(params = {}) {
26243
26965
  } = params;
26244
26966
  const skills = params.skills;
26245
26967
  let latestSkills = [];
26246
- return (0, import_langchain59.createMiddleware)({
26968
+ return (0, import_langchain60.createMiddleware)({
26247
26969
  name: "skillMiddleware",
26248
26970
  contextSchema,
26249
26971
  tools: [
@@ -26375,17 +27097,17 @@ var skillPlugin = {
26375
27097
  };
26376
27098
 
26377
27099
  // src/middlewares/collectionMiddleware.ts
26378
- var import_langchain70 = require("langchain");
27100
+ var import_langchain71 = require("langchain");
26379
27101
 
26380
27102
  // src/tool_lattice/collection/list_collections.ts
26381
- var import_zod50 = __toESM(require("zod"));
26382
- var import_langchain60 = require("langchain");
27103
+ var import_zod51 = __toESM(require("zod"));
27104
+ var import_langchain61 = require("langchain");
26383
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.`;
26384
27106
  var createListCollectionsTool = ({
26385
27107
  collectionKeys,
26386
27108
  connectAll
26387
27109
  }) => {
26388
- return (0, import_langchain60.tool)(
27110
+ return (0, import_langchain61.tool)(
26389
27111
  async (_input, _exeConfig) => {
26390
27112
  try {
26391
27113
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26419,23 +27141,23 @@ var createListCollectionsTool = ({
26419
27141
  {
26420
27142
  name: "list_collections",
26421
27143
  description: LIST_COLLECTIONS_DESCRIPTION,
26422
- schema: import_zod50.default.object({})
27144
+ schema: import_zod51.default.object({})
26423
27145
  }
26424
27146
  );
26425
27147
  };
26426
27148
 
26427
27149
  // src/tool_lattice/collection/search_collection.ts
26428
- var import_zod51 = __toESM(require("zod"));
26429
- var import_langchain61 = require("langchain");
27150
+ var import_zod52 = __toESM(require("zod"));
27151
+ var import_langchain62 = require("langchain");
26430
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.`;
26431
- var searchSchema = import_zod51.default.object({
26432
- collection: import_zod51.default.string().describe("The collection name to search in"),
26433
- query: import_zod51.default.string().describe("The search query text"),
26434
- filter: import_zod51.default.record(import_zod51.default.unknown()).optional().describe("Metadata filter conditions"),
26435
- 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")
26436
27158
  });
26437
27159
  var createSearchCollectionTool = () => {
26438
- return (0, import_langchain61.tool)(
27160
+ return (0, import_langchain62.tool)(
26439
27161
  async (input, _exeConfig) => {
26440
27162
  try {
26441
27163
  const { collection, query, filter: filter2, top_k } = input;
@@ -26485,10 +27207,10 @@ var createSearchCollectionTool = () => {
26485
27207
  };
26486
27208
 
26487
27209
  // src/tool_lattice/collection/get_collection.ts
26488
- var import_zod52 = __toESM(require("zod"));
26489
- var import_langchain62 = require("langchain");
27210
+ var import_zod53 = __toESM(require("zod"));
27211
+ var import_langchain63 = require("langchain");
26490
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.`;
26491
- var createGetCollectionTool = () => (0, import_langchain62.tool)(
27213
+ var createGetCollectionTool = () => (0, import_langchain63.tool)(
26492
27214
  async (input, _exeConfig) => {
26493
27215
  try {
26494
27216
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26511,24 +27233,24 @@ Embedding: ${c.embeddingKey}${fieldsDesc}`;
26511
27233
  return `Error: ${error.message}`;
26512
27234
  }
26513
27235
  },
26514
- { 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") }) }
26515
27237
  );
26516
27238
 
26517
27239
  // src/tool_lattice/collection/create_collection.ts
26518
- var import_zod53 = __toESM(require("zod"));
26519
- var import_langchain63 = require("langchain");
26520
- var createSchema = import_zod53.default.object({
26521
- name: import_zod53.default.string().describe("Collection name (lowercase, underscores only)"),
26522
- label: import_zod53.default.string().describe("Display name"),
26523
- embeddingKey: import_zod53.default.string().describe("Embedding model key"),
26524
- fields: import_zod53.default.array(import_zod53.default.object({
26525
- key: import_zod53.default.string().describe("Field key name"),
26526
- type: import_zod53.default.enum(["string", "number", "enum"]).describe("Field data type"),
26527
- enumValues: import_zod53.default.array(import_zod53.default.string()).optional().describe("Valid values for enum type"),
26528
- 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")
26529
27251
  })).optional().describe("Custom field definitions for entries in this collection")
26530
27252
  });
26531
- var createCreateCollectionTool = () => (0, import_langchain63.tool)(
27253
+ var createCreateCollectionTool = () => (0, import_langchain64.tool)(
26532
27254
  async (input, _exeConfig) => {
26533
27255
  try {
26534
27256
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26553,20 +27275,20 @@ var createCreateCollectionTool = () => (0, import_langchain63.tool)(
26553
27275
  );
26554
27276
 
26555
27277
  // src/tool_lattice/collection/update_collection.ts
26556
- var import_zod54 = __toESM(require("zod"));
26557
- var import_langchain64 = require("langchain");
26558
- var schema = import_zod54.default.object({
26559
- name: import_zod54.default.string().describe("Collection name"),
26560
- label: import_zod54.default.string().optional().describe("New display name"),
26561
- embeddingKey: import_zod54.default.string().optional().describe("New embedding model key"),
26562
- fields: import_zod54.default.array(import_zod54.default.object({
26563
- key: import_zod54.default.string().describe("Field key name"),
26564
- type: import_zod54.default.enum(["string", "number", "enum"]).describe("Field data type"),
26565
- enumValues: import_zod54.default.array(import_zod54.default.string()).optional().describe("Valid values for enum type"),
26566
- 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")
26567
27289
  })).optional().describe("Custom field definitions for entries (replaces existing schema)")
26568
27290
  });
26569
- var createUpdateCollectionTool = () => (0, import_langchain64.tool)(
27291
+ var createUpdateCollectionTool = () => (0, import_langchain65.tool)(
26570
27292
  async (input, _exeConfig) => {
26571
27293
  try {
26572
27294
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26585,9 +27307,9 @@ var createUpdateCollectionTool = () => (0, import_langchain64.tool)(
26585
27307
  );
26586
27308
 
26587
27309
  // src/tool_lattice/collection/delete_collection.ts
26588
- var import_zod55 = __toESM(require("zod"));
26589
- var import_langchain65 = require("langchain");
26590
- 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)(
26591
27313
  async (input, _exeConfig) => {
26592
27314
  try {
26593
27315
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26597,19 +27319,19 @@ var createDeleteCollectionTool = () => (0, import_langchain65.tool)(
26597
27319
  return `Error: ${e.message}`;
26598
27320
  }
26599
27321
  },
26600
- { 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") }) }
26601
27323
  );
26602
27324
 
26603
27325
  // src/tool_lattice/collection/list_entries.ts
26604
- var import_zod56 = __toESM(require("zod"));
26605
- var import_langchain66 = require("langchain");
26606
- var schema2 = import_zod56.default.object({
26607
- 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")
26608
27330
  });
26609
27331
  function buildKey2(tenantId2, name) {
26610
27332
  return `${tenantId2}:${name}`;
26611
27333
  }
26612
- var createListEntriesTool = () => (0, import_langchain66.tool)(
27334
+ var createListEntriesTool = () => (0, import_langchain67.tool)(
26613
27335
  async (input, _exeConfig) => {
26614
27336
  try {
26615
27337
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26636,24 +27358,24 @@ var createListEntriesTool = () => (0, import_langchain66.tool)(
26636
27358
  );
26637
27359
 
26638
27360
  // src/tool_lattice/collection/add_entry.ts
26639
- var import_zod57 = __toESM(require("zod"));
26640
- var import_langchain67 = require("langchain");
27361
+ var import_zod58 = __toESM(require("zod"));
27362
+ var import_langchain68 = require("langchain");
26641
27363
  var import_documents = require("@langchain/core/documents");
26642
- var import_uuid9 = require("uuid");
26643
- var schema3 = import_zod57.default.object({
26644
- collection: import_zod57.default.string().describe("Collection name"),
26645
- content: import_zod57.default.string().describe("Entry content text"),
26646
- 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")
26647
27369
  });
26648
27370
  function key(t, n) {
26649
27371
  return `${t}:${n}`;
26650
27372
  }
26651
- var createAddEntryTool = () => (0, import_langchain67.tool)(
27373
+ var createAddEntryTool = () => (0, import_langchain68.tool)(
26652
27374
  async (input, _exeConfig) => {
26653
27375
  try {
26654
27376
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
26655
27377
  const vs = vectorStoreLatticeManager.getVectorStoreClient(key(tenantId2, input.collection));
26656
- const id = (0, import_uuid9.v4)();
27378
+ const id = (0, import_uuid10.v4)();
26657
27379
  await vs.addDocuments([new import_documents.Document({
26658
27380
  pageContent: input.content,
26659
27381
  metadata: { _id: id, _created_at: (/* @__PURE__ */ new Date()).toISOString(), ...input.metadata || {} }
@@ -26667,18 +27389,18 @@ var createAddEntryTool = () => (0, import_langchain67.tool)(
26667
27389
  );
26668
27390
 
26669
27391
  // src/tool_lattice/collection/update_entry.ts
26670
- var import_zod58 = __toESM(require("zod"));
26671
- var import_langchain68 = require("langchain");
26672
- var schema4 = import_zod58.default.object({
26673
- collection: import_zod58.default.string().describe("Collection name"),
26674
- entryId: import_zod58.default.string().describe("Entry ID to update"),
26675
- content: import_zod58.default.string().optional().describe("New content"),
26676
- 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")
26677
27399
  });
26678
27400
  function key2(t, n) {
26679
27401
  return `${t}:${n}`;
26680
27402
  }
26681
- var createUpdateEntryTool = () => (0, import_langchain68.tool)(
27403
+ var createUpdateEntryTool = () => (0, import_langchain69.tool)(
26682
27404
  async (input, _exeConfig) => {
26683
27405
  try {
26684
27406
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26697,16 +27419,16 @@ var createUpdateEntryTool = () => (0, import_langchain68.tool)(
26697
27419
  );
26698
27420
 
26699
27421
  // src/tool_lattice/collection/delete_entry.ts
26700
- var import_zod59 = __toESM(require("zod"));
26701
- var import_langchain69 = require("langchain");
26702
- var schema5 = import_zod59.default.object({
26703
- collection: import_zod59.default.string().describe("Collection name"),
26704
- 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")
26705
27427
  });
26706
27428
  function key3(t, n) {
26707
27429
  return `${t}:${n}`;
26708
27430
  }
26709
- var createDeleteEntryTool = () => (0, import_langchain69.tool)(
27431
+ var createDeleteEntryTool = () => (0, import_langchain70.tool)(
26710
27432
  async (input, _exeConfig) => {
26711
27433
  try {
26712
27434
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -26724,7 +27446,7 @@ var createDeleteEntryTool = () => (0, import_langchain69.tool)(
26724
27446
  function createCollectionMiddleware(params) {
26725
27447
  const { collectionKeys, connectAll } = params;
26726
27448
  if (!connectAll && (!collectionKeys || collectionKeys.length === 0)) {
26727
- return (0, import_langchain70.createMiddleware)({
27449
+ return (0, import_langchain71.createMiddleware)({
26728
27450
  name: "collectionMiddleware",
26729
27451
  contextSchema,
26730
27452
  tools: [
@@ -26734,7 +27456,7 @@ function createCollectionMiddleware(params) {
26734
27456
  });
26735
27457
  }
26736
27458
  const listToolParams = { collectionKeys, connectAll };
26737
- return (0, import_langchain70.createMiddleware)({
27459
+ return (0, import_langchain71.createMiddleware)({
26738
27460
  name: "collectionMiddleware",
26739
27461
  contextSchema,
26740
27462
  tools: [
@@ -26795,24 +27517,24 @@ var collectionPlugin = {
26795
27517
  };
26796
27518
 
26797
27519
  // src/middlewares/askUserClarifyMiddleware.ts
26798
- var import_langchain72 = require("langchain");
27520
+ var import_langchain73 = require("langchain");
26799
27521
  var import_langgraph14 = require("@langchain/langgraph");
26800
27522
 
26801
27523
  // src/tool_lattice/ask_user_to_clarify/index.ts
26802
- var import_langchain71 = require("langchain");
26803
- var import_zod60 = __toESM(require("zod"));
26804
- var questionSchema = import_zod60.default.object({
26805
- question: import_zod60.default.string().describe("The question text to ask the user"),
26806
- 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."),
26807
- 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."),
26808
- required: import_zod60.default.boolean().optional().default(false).describe("Whether this question must be answered"),
26809
- 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.")
26810
27532
  });
26811
- var inputSchema = import_zod60.default.object({
26812
- 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.")
26813
27535
  });
26814
27536
  function createAskUserToClarifyTool() {
26815
- return (0, import_langchain71.tool)(
27537
+ return (0, import_langchain72.tool)(
26816
27538
  async (input) => {
26817
27539
  return JSON.stringify(input);
26818
27540
  },
@@ -26826,7 +27548,7 @@ function createAskUserToClarifyTool() {
26826
27548
 
26827
27549
  // src/middlewares/askUserClarifyMiddleware.ts
26828
27550
  function createAskUserClarifyMiddleware() {
26829
- return (0, import_langchain72.createMiddleware)({
27551
+ return (0, import_langchain73.createMiddleware)({
26830
27552
  name: "AskUserClarifyMiddleware",
26831
27553
  tools: [createAskUserToClarifyTool()],
26832
27554
  wrapToolCall: async (request, handler) => {
@@ -26840,7 +27562,7 @@ function createAskUserClarifyMiddleware() {
26840
27562
  throw error;
26841
27563
  }
26842
27564
  console.error(`Error executing tool "${toolName}":`, error);
26843
- return new import_langchain72.ToolMessage({
27565
+ return new import_langchain73.ToolMessage({
26844
27566
  content: `Error executing tool: ${error instanceof Error ? error.message : "Unknown error"}`,
26845
27567
  tool_call_id: toolCall?.id,
26846
27568
  name: toolName
@@ -26849,7 +27571,7 @@ function createAskUserClarifyMiddleware() {
26849
27571
  }
26850
27572
  const parsed = inputSchema.safeParse(toolCall?.args);
26851
27573
  if (!parsed.success) {
26852
- return new import_langchain72.ToolMessage({
27574
+ return new import_langchain73.ToolMessage({
26853
27575
  content: `Invalid clarify tool arguments: ${parsed.error.message}`,
26854
27576
  tool_call_id: toolCall?.id,
26855
27577
  name: toolName
@@ -26869,7 +27591,7 @@ function createAskUserClarifyMiddleware() {
26869
27591
  const result = await (0, import_langgraph14.interrupt)(md);
26870
27592
  const response = result.data;
26871
27593
  if (!response?.answers || response.answers.length === 0) {
26872
- return new import_langchain72.ToolMessage({
27594
+ return new import_langchain73.ToolMessage({
26873
27595
  content: "No clarification questions were answered.",
26874
27596
  tool_call_id: toolCall?.id,
26875
27597
  name: toolName
@@ -26879,7 +27601,7 @@ function createAskUserClarifyMiddleware() {
26879
27601
  (answer) => (answer.selectedOptions?.length ?? 0) > 0 || answer.otherText && answer.otherText.trim() !== "" || answer.filePath && answer.filePath.trim() !== ""
26880
27602
  );
26881
27603
  if (answeredQuestions.length === 0) {
26882
- return new import_langchain72.ToolMessage({
27604
+ return new import_langchain73.ToolMessage({
26883
27605
  content: "No clarification questions were answered.",
26884
27606
  tool_call_id: toolCall?.id,
26885
27607
  name: toolName
@@ -26909,7 +27631,7 @@ function createAskUserClarifyMiddleware() {
26909
27631
  }
26910
27632
  lines.push("");
26911
27633
  }
26912
- return new import_langchain72.ToolMessage({
27634
+ return new import_langchain73.ToolMessage({
26913
27635
  content: lines.join("\n"),
26914
27636
  tool_call_id: toolCall?.id,
26915
27637
  name: toolName
@@ -26934,11 +27656,11 @@ var askUserClarifyPlugin = {
26934
27656
  };
26935
27657
 
26936
27658
  // src/middlewares/widgetMiddleware.ts
26937
- var import_langchain75 = require("langchain");
27659
+ var import_langchain76 = require("langchain");
26938
27660
 
26939
27661
  // src/tool_lattice/widget/loadGuidelines.ts
26940
- var import_langchain73 = require("langchain");
26941
- var import_zod61 = require("zod");
27662
+ var import_langchain74 = require("langchain");
27663
+ var import_zod62 = require("zod");
26942
27664
 
26943
27665
  // src/middlewares/guidelines/index.ts
26944
27666
  var CORE = `# Imagine \u2014 Visual Creation Suite
@@ -27729,13 +28451,13 @@ function getGuidelines(modules) {
27729
28451
  var AVAILABLE_MODULES = Object.keys(MODULE_SECTIONS);
27730
28452
 
27731
28453
  // src/tool_lattice/widget/loadGuidelines.ts
27732
- var LoadGuidelinesInputSchema = import_zod61.z.object({
27733
- 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(
27734
28456
  "Which design modules to load. Choose all that apply. Available modules: [" + AVAILABLE_MODULES.join(",") + "]"
27735
28457
  )
27736
28458
  });
27737
28459
  function createLoadGuidelinesTool() {
27738
- return (0, import_langchain73.tool)(
28460
+ return (0, import_langchain74.tool)(
27739
28461
  async (input) => {
27740
28462
  const result = getGuidelines(input.modules);
27741
28463
  return result;
@@ -27749,8 +28471,8 @@ function createLoadGuidelinesTool() {
27749
28471
  }
27750
28472
 
27751
28473
  // src/tool_lattice/widget/showWidget.ts
27752
- var import_langchain74 = require("langchain");
27753
- var import_zod62 = require("zod");
28474
+ var import_langchain75 = require("langchain");
28475
+ var import_zod63 = require("zod");
27754
28476
  function containsForbiddenTags(code) {
27755
28477
  const forbiddenPatterns = [
27756
28478
  /<!DOCTYPE/i,
@@ -27772,20 +28494,20 @@ function validateWidgetCode(code) {
27772
28494
  }
27773
28495
  return { valid: true };
27774
28496
  }
27775
- var ShowWidgetInputSchema = import_zod62.z.object({
27776
- 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(
27777
28499
  "Must be true. Confirm you have called load_guidelines first."
27778
28500
  ),
27779
- title: import_zod62.z.string().describe("Title displayed above the widget"),
27780
- 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(
27781
28503
  "1-4 short strings shown while the widget renders"
27782
28504
  ),
27783
- widget_code: import_zod62.z.string().describe(
28505
+ widget_code: import_zod63.z.string().describe(
27784
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."
27785
28507
  )
27786
28508
  });
27787
28509
  function createShowWidgetTool() {
27788
- return (0, import_langchain74.tool)(
28510
+ return (0, import_langchain75.tool)(
27789
28511
  async (input) => {
27790
28512
  if (!input.i_have_seen_guidelines) {
27791
28513
  return "Error: You must call load_guidelines before using show_widget. Set i_have_seen_guidelines to true only after loading guidelines.";
@@ -27816,7 +28538,7 @@ function createWidgetMiddleware() {
27816
28538
  createLoadGuidelinesTool(),
27817
28539
  createShowWidgetTool()
27818
28540
  ];
27819
- return (0, import_langchain75.createMiddleware)({
28541
+ return (0, import_langchain76.createMiddleware)({
27820
28542
  name: "widgetMiddleware",
27821
28543
  contextSchema,
27822
28544
  tools
@@ -27838,157 +28560,10 @@ var widgetPlugin = {
27838
28560
  middleware: () => createWidgetMiddleware()
27839
28561
  };
27840
28562
 
27841
- // src/middlewares/taskMiddleware.ts
27842
- var import_langchain76 = require("langchain");
27843
- var import_zod63 = require("zod");
27844
- function getRunConfig2(config) {
27845
- const c = config;
27846
- return c?.configurable?.runConfig ?? {};
27847
- }
27848
- function getTaskStore() {
27849
- return getStoreLattice("default", "task").store;
27850
- }
27851
- var manageTaskSchema = import_zod63.z.object({
27852
- action: import_zod63.z.enum(["create", "list", "update", "delete", "complete"]).describe("\u64CD\u4F5C\u7C7B\u578B"),
27853
- id: import_zod63.z.string().optional().describe("\u4EFB\u52A1 ID (update/delete/complete \u5FC5\u586B)"),
27854
- title: import_zod63.z.string().optional().describe("\u4EFB\u52A1\u6807\u9898 (create \u5FC5\u586B)"),
27855
- description: import_zod63.z.string().optional().describe("\u4EFB\u52A1\u63CF\u8FF0"),
27856
- priority: import_zod63.z.enum(["low", "medium", "high"]).optional().describe("\u4F18\u5148\u7EA7"),
27857
- status: import_zod63.z.enum(["pending", "in_progress", "completed", "cancelled"]).optional().describe("\u72B6\u6001"),
27858
- dueDate: import_zod63.z.string().optional().describe("\u622A\u6B62\u65E5\u671F (ISO 8601)"),
27859
- metadata: import_zod63.z.record(import_zod63.z.unknown()).optional().describe("\u7ED3\u6784\u5316\u5143\u6570\u636E (projectId, module \u7B49)"),
27860
- parentId: import_zod63.z.string().optional().describe("\u7236\u4EFB\u52A1 ID (\u5B50\u4EFB\u52A1\u5173\u8054)"),
27861
- sourceId: import_zod63.z.string().optional().describe("\u6765\u6E90\u4F1A\u8BDD/thread ID"),
27862
- context: import_zod63.z.record(import_zod63.z.unknown()).optional().describe("\u9644\u52A0\u4E0A\u4E0B\u6587"),
27863
- ownerType: import_zod63.z.enum(["user", "agent"]).optional().describe("\u6240\u6709\u8005\u7C7B\u578B\uFF0C\u4E0D\u4F20\u9ED8\u8BA4\u4E3A user"),
27864
- ownerId: import_zod63.z.string().optional().describe("\u6240\u6709\u8005 ID\uFF0C\u4E0D\u4F20\u81EA\u52A8\u53D6\u5F53\u524D\u7528\u6237/Agent")
27865
- });
27866
- function createTaskMiddleware() {
27867
- return (0, import_langchain76.createMiddleware)({
27868
- name: "TaskMiddleware",
27869
- contextSchema,
27870
- wrapModelCall: async (request, handler) => {
27871
- const taskPrompt = `## \u4EFB\u52A1\u7BA1\u7406\u80FD\u529B
27872
- \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
27873
- - \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)
27874
- - ownerType="agent": \u4E3A\u81EA\u5DF1\u521B\u5EFA\u6267\u884C\u5B50\u4EFB\u52A1 (ownerId \u81EA\u52A8\u53D6\u5F53\u524D Agent)
27875
- - \u663E\u5F0F\u4F20 ownerId: \u4E3A\u6307\u5B9A agent/user \u521B\u5EFA\u4EFB\u52A1\uFF08\u62D3\u6251\u573A\u666F\uFF09`;
27876
- return handler({
27877
- ...request,
27878
- systemPrompt: taskPrompt + "\n\n" + (request.systemPrompt ?? "")
27879
- });
27880
- },
27881
- tools: [
27882
- (0, import_langchain76.tool)(
27883
- async (input, config) => {
27884
- const rc = getRunConfig2(config);
27885
- const tenantId2 = rc.tenantId || "default";
27886
- const ownerId = input.ownerId || (input.ownerType === "agent" ? rc.assistant_id : null) || rc.user_id;
27887
- const store = getTaskStore();
27888
- switch (input.action) {
27889
- case "create": {
27890
- if (!input.title) {
27891
- return JSON.stringify({ success: false, error: "create requires title" });
27892
- }
27893
- const task = await store.create({
27894
- tenantId: tenantId2,
27895
- ownerType: input.ownerType || "user",
27896
- ownerId,
27897
- title: input.title,
27898
- description: input.description,
27899
- priority: input.priority || "medium",
27900
- status: input.status || "pending",
27901
- dueDate: input.dueDate,
27902
- metadata: input.metadata,
27903
- parentId: input.parentId,
27904
- sourceId: input.sourceId,
27905
- context: input.context
27906
- });
27907
- return JSON.stringify({ success: true, data: task });
27908
- }
27909
- case "list": {
27910
- const tasks = await store.list({
27911
- tenantId: tenantId2,
27912
- ownerType: input.ownerType,
27913
- ownerId: input.ownerId,
27914
- status: input.status,
27915
- priority: input.priority
27916
- });
27917
- return JSON.stringify({ success: true, data: tasks, count: tasks.length });
27918
- }
27919
- case "update": {
27920
- if (!input.id) {
27921
- return JSON.stringify({ success: false, error: "update requires id" });
27922
- }
27923
- const { action, ...updates } = input;
27924
- const updated = await store.update(tenantId2, input.id, updates);
27925
- if (!updated) {
27926
- return JSON.stringify({ success: false, error: "Task not found" });
27927
- }
27928
- return JSON.stringify({ success: true, data: updated });
27929
- }
27930
- case "delete": {
27931
- if (!input.id) {
27932
- return JSON.stringify({ success: false, error: "delete requires id" });
27933
- }
27934
- const deleted = await store.delete(tenantId2, input.id);
27935
- return JSON.stringify({ success: deleted, message: deleted ? "Task deleted" : "Task not found" });
27936
- }
27937
- case "complete": {
27938
- if (!input.id) {
27939
- return JSON.stringify({ success: false, error: "complete requires id" });
27940
- }
27941
- const updated = await store.update(tenantId2, input.id, { status: "completed" });
27942
- if (!updated) {
27943
- return JSON.stringify({ success: false, error: "Task not found" });
27944
- }
27945
- return JSON.stringify({ success: true, data: updated });
27946
- }
27947
- default:
27948
- return JSON.stringify({ success: false, error: `Unknown action: ${input.action}` });
27949
- }
27950
- },
27951
- {
27952
- name: "manage_task",
27953
- description: `\u7BA1\u7406\u6301\u4E45\u5316\u4EFB\u52A1\u7CFB\u7EDF\u3002CRUD \u64CD\u4F5C\u7528\u6237\u548C Agent \u7684\u4EFB\u52A1\u3002
27954
-
27955
- ## ownerType \u548C ownerId \u7684\u9ED8\u8BA4\u903B\u8F91
27956
- - \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)
27957
- - \u4F20 ownerType="agent" \u4E0D\u4F20 ownerId: \u7CFB\u7EDF\u81EA\u52A8\u4E3A\u5F53\u524D Agent \u521B\u5EFA\u5B50\u4EFB\u52A1
27958
- - \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
27959
-
27960
- ## Actions
27961
- - create: \u521B\u5EFA\u4EFB\u52A1 (title \u5FC5\u586B, priority/description/dueDate/metadata/parentId/context \u53EF\u9009)
27962
- - list: \u5217\u51FA\u4EFB\u52A1\uFF0C\u53EF\u6309 ownerType/status/priority \u8FC7\u6EE4
27963
- - update: \u66F4\u65B0\u4EFB\u52A1 (id \u5FC5\u586B\uFF0C\u53EA\u4F20\u8981\u6539\u7684\u5B57\u6BB5)
27964
- - delete: \u5220\u9664\u4EFB\u52A1 (id \u5FC5\u586B)
27965
- - complete: \u5FEB\u901F\u6807\u8BB0\u5B8C\u6210 (id \u5FC5\u586B)`,
27966
- schema: manageTaskSchema
27967
- }
27968
- )
27969
- ]
27970
- });
27971
- }
27972
- var taskPlugin = {
27973
- meta: {
27974
- type: "task",
27975
- name: "Task Management",
27976
- description: "Enables persistent task management with delegation and tracking",
27977
- configSchema: {
27978
- type: "object",
27979
- title: "Task Management Configuration",
27980
- description: "Zero-configuration task management",
27981
- properties: {}
27982
- },
27983
- defaultConfig: {}
27984
- },
27985
- middleware: () => createTaskMiddleware()
27986
- };
27987
-
27988
28563
  // src/middlewares/evalMiddleware.ts
27989
28564
  var import_langchain77 = require("langchain");
27990
28565
  var import_zod64 = require("zod");
27991
- var import_uuid10 = require("uuid");
28566
+ var import_uuid11 = require("uuid");
27992
28567
 
27993
28568
  // src/middlewares/evalSkills.ts
27994
28569
  var EVAL_SKILLS = {
@@ -28202,7 +28777,7 @@ function createManageEvalTool() {
28202
28777
  let data;
28203
28778
  switch (input.action) {
28204
28779
  case "create_project":
28205
- data = await store.createProject(tid, (0, import_uuid10.v4)(), {
28780
+ data = await store.createProject(tid, (0, import_uuid11.v4)(), {
28206
28781
  name: input.name,
28207
28782
  description: input.description,
28208
28783
  judgeModelConfig: { modelKey: input.judgeModelKey },
@@ -28226,7 +28801,7 @@ function createManageEvalTool() {
28226
28801
  break;
28227
28802
  }
28228
28803
  case "create_suite":
28229
- 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 });
28230
28805
  break;
28231
28806
  case "update_suite":
28232
28807
  data = await store.updateSuite(tid, input.suiteId, { name: input.name });
@@ -28236,7 +28811,7 @@ function createManageEvalTool() {
28236
28811
  data = true;
28237
28812
  break;
28238
28813
  case "create_case":
28239
- data = await store.createCase(tid, input.suiteId, (0, import_uuid10.v4)(), {
28814
+ data = await store.createCase(tid, input.suiteId, (0, import_uuid11.v4)(), {
28240
28815
  inputMessage: input.inputMessage,
28241
28816
  inputFiles: input.inputFiles,
28242
28817
  steps: input.steps,
@@ -28551,6 +29126,230 @@ var PersonalAssistantConfig = class {
28551
29126
  };
28552
29127
  PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
28553
29128
 
29129
+ // src/export_import/ExportableEntityRegistry.ts
29130
+ var ExportableEntityRegistry = class _ExportableEntityRegistry {
29131
+ constructor() {
29132
+ this.definitions = /* @__PURE__ */ new Map();
29133
+ }
29134
+ /**
29135
+ * Returns the singleton registry instance, creating it if necessary.
29136
+ *
29137
+ * @returns The singleton {@link ExportableEntityRegistry} instance.
29138
+ */
29139
+ static getInstance() {
29140
+ if (!_ExportableEntityRegistry.instance) {
29141
+ _ExportableEntityRegistry.instance = new _ExportableEntityRegistry();
29142
+ }
29143
+ return _ExportableEntityRegistry.instance;
29144
+ }
29145
+ /**
29146
+ * Registers an exportable entity type definition.
29147
+ *
29148
+ * @param def - The entity definition to register.
29149
+ *
29150
+ * @throws If an entity type with the same `entityType` is already registered.
29151
+ */
29152
+ register(def) {
29153
+ if (this.definitions.has(def.entityType)) {
29154
+ throw new Error(
29155
+ `Exportable entity type "${def.entityType}" is already registered`
29156
+ );
29157
+ }
29158
+ this.definitions.set(def.entityType, def);
29159
+ }
29160
+ /**
29161
+ * Retrieves a registered entity definition by type name.
29162
+ *
29163
+ * @param entityType - The entity type identifier (e.g. `'skill'`, `'agent'`).
29164
+ *
29165
+ * @returns The registered {@link ExportableEntityDefinition}.
29166
+ *
29167
+ * @throws If no definition is registered for the given type.
29168
+ */
29169
+ get(entityType) {
29170
+ const def = this.definitions.get(entityType);
29171
+ if (!def) {
29172
+ throw new Error(`Exportable entity type "${entityType}" not found`);
29173
+ }
29174
+ return def;
29175
+ }
29176
+ /**
29177
+ * Returns lightweight metadata for all registered types (for the frontend).
29178
+ *
29179
+ * @returns An array of {@link ExportableTypeInfo} objects.
29180
+ */
29181
+ listTypes() {
29182
+ return [...this.definitions.values()].map((d) => ({
29183
+ entityType: d.entityType,
29184
+ label: d.label,
29185
+ category: d.category,
29186
+ dependsOn: d.dependsOn,
29187
+ cascadeParents: d.cascadeParents
29188
+ }));
29189
+ }
29190
+ /**
29191
+ * Returns all registered entity definitions.
29192
+ *
29193
+ * @returns An array of all registered {@link ExportableEntityDefinition} objects.
29194
+ */
29195
+ getAll() {
29196
+ return [...this.definitions.values()];
29197
+ }
29198
+ /**
29199
+ * Removes a registered entity type definition.
29200
+ *
29201
+ * @param entityType - The entity type identifier to remove.
29202
+ */
29203
+ unregister(entityType) {
29204
+ this.definitions.delete(entityType);
29205
+ }
29206
+ };
29207
+
29208
+ // src/export_import/DependencyResolver.ts
29209
+ var DependencyResolver = class {
29210
+ /**
29211
+ * Topological sort of entity types based on their {@link ExportableEntityDefinition.dependsOn}
29212
+ * declarations. Entities with no dependencies come first.
29213
+ *
29214
+ * @param defs - All registered exportable entity definitions.
29215
+ * @returns Entity type names in dependency-first order.
29216
+ */
29217
+ static resolveOrder(defs) {
29218
+ const typeMap = new Map(defs.map((d) => [d.entityType, d]));
29219
+ const visited = /* @__PURE__ */ new Set();
29220
+ const result = [];
29221
+ function visit(type) {
29222
+ if (visited.has(type)) return;
29223
+ visited.add(type);
29224
+ const def = typeMap.get(type);
29225
+ if (def) {
29226
+ for (const dep of def.dependsOn) {
29227
+ if (typeMap.has(dep)) {
29228
+ visit(dep);
29229
+ }
29230
+ }
29231
+ }
29232
+ result.push(type);
29233
+ }
29234
+ for (const def of defs) {
29235
+ visit(def.entityType);
29236
+ }
29237
+ return result;
29238
+ }
29239
+ /**
29240
+ * Given a set of selected entity types, expand to include all CASCADE
29241
+ * parents. Only walks **upward** (parents), never downward (children).
29242
+ *
29243
+ * @param defs - All registered exportable entity definitions.
29244
+ * @param selected - Entity type names the user explicitly chose.
29245
+ * @returns The original selection plus every reachable cascade parent.
29246
+ */
29247
+ static expandCascade(defs, selected) {
29248
+ const typeMap = new Map(defs.map((d) => [d.entityType, d]));
29249
+ const result = new Set(selected);
29250
+ let changed = true;
29251
+ while (changed) {
29252
+ changed = false;
29253
+ for (const type of [...result]) {
29254
+ const def = typeMap.get(type);
29255
+ if (def) {
29256
+ for (const parent of def.cascadeParents) {
29257
+ if (!result.has(parent)) {
29258
+ result.add(parent);
29259
+ changed = true;
29260
+ }
29261
+ }
29262
+ }
29263
+ }
29264
+ }
29265
+ return [...result];
29266
+ }
29267
+ /**
29268
+ * Compute which required dependencies are missing from the selected types.
29269
+ *
29270
+ * Only considers dependencies that are themselves registered as exportable
29271
+ * entity types. Unregistered dependencies (e.g. `Workspace`, `Project` —
29272
+ * infrastructure types) are silently excluded.
29273
+ *
29274
+ * @param defs - All registered exportable entity definitions.
29275
+ * @param selected - Entity type names the user has selected.
29276
+ * @returns The list of entity types that must also be selected (or
29277
+ * auto-included).
29278
+ */
29279
+ static computeDependencies(defs, selected) {
29280
+ const typeMap = new Map(defs.map((d) => [d.entityType, d]));
29281
+ const selectedSet = new Set(selected);
29282
+ const missing = /* @__PURE__ */ new Set();
29283
+ function collectMissing(type) {
29284
+ if (selectedSet.has(type)) return;
29285
+ const def = typeMap.get(type);
29286
+ if (!def) return;
29287
+ missing.add(type);
29288
+ for (const dep of def.dependsOn) {
29289
+ collectMissing(dep);
29290
+ }
29291
+ }
29292
+ for (const type of selected) {
29293
+ const def = typeMap.get(type);
29294
+ if (def) {
29295
+ for (const dep of def.dependsOn) {
29296
+ collectMissing(dep);
29297
+ }
29298
+ }
29299
+ }
29300
+ return { missing: [...missing] };
29301
+ }
29302
+ };
29303
+
29304
+ // src/export_import/IdRemapper.ts
29305
+ var REF_PATTERN = /^@(\w+)\/(.+)$/;
29306
+ var IdRemapper = class {
29307
+ constructor(idMap) {
29308
+ this.idMap = idMap;
29309
+ }
29310
+ /**
29311
+ * Deep-traverse an object/array and replace all @type/exportId string values
29312
+ * with their corresponding real IDs from the idMap.
29313
+ * Values not matching the @type/exportId pattern are returned unchanged.
29314
+ */
29315
+ remapReferences(value) {
29316
+ if (value === null || value === void 0) return value;
29317
+ if (typeof value === "string") {
29318
+ const match = value.match(REF_PATTERN);
29319
+ if (match) {
29320
+ const exportId = match[2];
29321
+ if (this.idMap[exportId] !== void 0) {
29322
+ return this.idMap[exportId];
29323
+ }
29324
+ }
29325
+ return value;
29326
+ }
29327
+ if (Array.isArray(value)) {
29328
+ return value.map((item) => this.remapReferences(item));
29329
+ }
29330
+ if (typeof value === "object") {
29331
+ const result = {};
29332
+ for (const [key4, val] of Object.entries(value)) {
29333
+ result[key4] = this.remapReferences(val);
29334
+ }
29335
+ return result;
29336
+ }
29337
+ return value;
29338
+ }
29339
+ /**
29340
+ * Replace raw skill IDs in an agent's graphDefinition.skillIds array.
29341
+ * This handles the implicit agent->skill reference that uses raw skill IDs
29342
+ * (not @type/exportId format). Agents reference skills by their string ID.
29343
+ */
29344
+ remapSkillIds(graphDefinition, skillRemap) {
29345
+ const cloned = structuredClone(graphDefinition);
29346
+ if (Array.isArray(cloned.skillIds)) {
29347
+ cloned.skillIds = cloned.skillIds.map((id) => skillRemap[id] ?? id);
29348
+ }
29349
+ return cloned;
29350
+ }
29351
+ };
29352
+
28554
29353
  // src/index.ts
28555
29354
  registerBuiltinPlugins();
28556
29355
  // Annotate the CommonJS export names for ESM import in node:
@@ -28574,13 +29373,16 @@ registerBuiltinPlugins();
28574
29373
  DaytonaInstance,
28575
29374
  DaytonaProvider,
28576
29375
  DefaultScheduleClient,
29376
+ DependencyResolver,
28577
29377
  E2BInstance,
28578
29378
  E2BProvider,
28579
29379
  EMPTY_CONTENT_WARNING,
28580
29380
  EmbeddingsLatticeManager,
29381
+ ExportableEntityRegistry,
28581
29382
  FileSystemSkillStore,
28582
29383
  FilesystemBackend,
28583
29384
  HumanMessage,
29385
+ IdRemapper,
28584
29386
  InMemoryA2AApiKeyStore,
28585
29387
  InMemoryAssistantStore,
28586
29388
  InMemoryBindingStore,