@axiom-lattice/core 4.2.3 → 4.2.4

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_messages7.HumanMessage(prompt)] };
877
+ return { messages: [new import_messages6.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_messages7;
1502
+ var import_langgraph12, import_messages6;
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_messages7 = require("@langchain/core/messages");
1507
+ import_messages6 = require("@langchain/core/messages");
1508
1508
  init_WorkflowAbortRegistry();
1509
1509
  init_parse_yaml();
1510
1510
  }
@@ -1643,7 +1643,7 @@ __export(index_exports, {
1643
1643
  ExportableEntityRegistry: () => ExportableEntityRegistry,
1644
1644
  FileSystemSkillStore: () => FileSystemSkillStore,
1645
1645
  FilesystemBackend: () => FilesystemBackend,
1646
- HumanMessage: () => import_messages10.HumanMessage,
1646
+ HumanMessage: () => import_messages9.HumanMessage,
1647
1647
  IdRemapper: () => IdRemapper,
1648
1648
  InMemoryA2AApiKeyStore: () => InMemoryA2AApiKeyStore,
1649
1649
  InMemoryAgentWebAppStore: () => InMemoryAgentWebAppStore,
@@ -10474,7 +10474,7 @@ var createBrowserGetInfoTool = ({ vmIsolation }) => {
10474
10474
  };
10475
10475
 
10476
10476
  // src/index.ts
10477
- var import_messages10 = require("@langchain/core/messages");
10477
+ var import_messages9 = require("@langchain/core/messages");
10478
10478
 
10479
10479
  // src/agent_lattice/types.ts
10480
10480
  var import_protocols5 = require("@axiom-lattice/protocols");
@@ -10494,7 +10494,7 @@ var createReactAgentSchema = (schema6) => {
10494
10494
  };
10495
10495
 
10496
10496
  // src/agent_lattice/builders/ReActAgentGraphBuilder.ts
10497
- var import_langchain50 = require("langchain");
10497
+ var import_langchain49 = require("langchain");
10498
10498
 
10499
10499
  // src/middlewares/codeEvalMiddleware.ts
10500
10500
  var import_langchain37 = require("langchain");
@@ -12878,7 +12878,7 @@ function hasMatchingToolCall(messages, toolIndex, toolCallId) {
12878
12878
  }
12879
12879
 
12880
12880
  // src/agent_lattice/builders/commonMiddleware.ts
12881
- var import_langchain48 = require("langchain");
12881
+ var import_langchain47 = require("langchain");
12882
12882
 
12883
12883
  // src/plugin/metaSerializer.ts
12884
12884
  function tryExtractTools(plugin) {
@@ -13432,7 +13432,7 @@ var ConnectionRegistry = class {
13432
13432
  ConnectionRegistry.store = null;
13433
13433
 
13434
13434
  // src/agent_lattice/builders/commonMiddleware.ts
13435
- var import_langchain49 = require("langchain");
13435
+ var import_langchain48 = require("langchain");
13436
13436
 
13437
13437
  // src/agent_lattice/builders/taskMiddlewareValidation.ts
13438
13438
  var REQUIRED_TASK_TOOLS = ["manage_task", "task"];
@@ -13802,368 +13802,6 @@ function createCapabilityGuardMiddleware(registry4) {
13802
13802
  });
13803
13803
  }
13804
13804
 
13805
- // src/middlewares/projectRoomMiddleware.ts
13806
- var import_crypto6 = require("crypto");
13807
- var import_protocols8 = require("@axiom-lattice/protocols");
13808
- var import_langchain47 = require("langchain");
13809
- var import_zod43 = require("zod");
13810
-
13811
- // src/services/RoomAgentMessageService.ts
13812
- var import_crypto5 = require("crypto");
13813
- var import_protocols7 = require("@axiom-lattice/protocols");
13814
- var INPUT_KEYS = [
13815
- "tenantId",
13816
- "workspaceId",
13817
- "projectId",
13818
- "roomId",
13819
- "membershipId",
13820
- "assistantId",
13821
- "text",
13822
- "sourceRoomMessageId",
13823
- "sourceId",
13824
- "idempotencyKey"
13825
- ];
13826
- var REPLY_INPUT_KEYS = ["tenantId", "membershipId", "text", "sourceRoomMessageId", "inputMessageId", "sourceId", "idempotencyKey"];
13827
- var RoomAgentMessageService = class {
13828
- /**
13829
- * Creates a room writer over the durable membership and message stores.
13830
- *
13831
- * @param deps Store methods, optional deterministic ID factory, and detached post-commit hooks.
13832
- */
13833
- constructor(deps) {
13834
- this.deps = deps;
13835
- }
13836
- /**
13837
- * Persists a fully scoped Agent response after validating its human source and active membership.
13838
- *
13839
- * @param input Exact trusted scope and response payload.
13840
- * @returns A deep clone of the canonical idempotent room message.
13841
- */
13842
- post(input) {
13843
- const snapshot = exactStringRecord(input, INPUT_KEYS, "Invalid project room message input");
13844
- return this.persist(snapshot);
13845
- }
13846
- /**
13847
- * Persists a channel reply while deriving all scope from validated durable records.
13848
- *
13849
- * @param input Exact correlation IDs, tenant, target membership, and response text.
13850
- * @returns A deep clone of the canonical idempotent room message.
13851
- */
13852
- postReply(input) {
13853
- const snapshot = exactStringRecord(input, REPLY_INPUT_KEYS, "Invalid project room reply input");
13854
- if (snapshot.sourceId !== `reply:${snapshot.inputMessageId}` || snapshot.idempotencyKey !== `room-reply:${snapshot.sourceRoomMessageId}:${snapshot.membershipId}:${snapshot.sourceId}`) {
13855
- throw new Error("Invalid project room reply correlation");
13856
- }
13857
- return this.persistDerived(snapshot);
13858
- }
13859
- async persistDerived(input) {
13860
- const source = snapshotSource(await this.deps.messages.findById(input.tenantId, input.sourceRoomMessageId));
13861
- if (!source || source.id !== input.sourceRoomMessageId || source.tenantId !== input.tenantId) throw new Error("Invalid project room message");
13862
- const member = snapshotMembership(await this.deps.memberships.findById(input.tenantId, input.membershipId));
13863
- if (!member || member.id !== input.membershipId || member.tenantId !== input.tenantId) throw new Error("Invalid project room membership");
13864
- return this.persist({
13865
- ...input,
13866
- workspaceId: source.workspaceId,
13867
- projectId: source.projectId,
13868
- roomId: source.roomId,
13869
- assistantId: member.assistantId
13870
- }, source, member);
13871
- }
13872
- async persist(input, loadedSource, loadedMember) {
13873
- const text = input.text.trim();
13874
- if (text.length < 1 || text.length > 2e4) throw new Error("Invalid project room message text");
13875
- const source = loadedSource ?? snapshotSource(await this.deps.messages.findById(input.tenantId, input.sourceRoomMessageId));
13876
- if (!source || source.id !== input.sourceRoomMessageId || source.tenantId !== input.tenantId || source.workspaceId !== input.workspaceId || source.projectId !== input.projectId || source.roomId !== input.roomId) {
13877
- throw new Error("Invalid project room message");
13878
- }
13879
- const member = loadedMember ?? snapshotMembership(await this.deps.memberships.findById(input.tenantId, input.membershipId));
13880
- if (!member || member.id !== input.membershipId || member.status !== "active" || member.assistantId !== input.assistantId || member.tenantId !== input.tenantId || member.workspaceId !== input.workspaceId || member.projectId !== input.projectId || member.roomId !== input.roomId) {
13881
- throw new Error("Invalid project room membership");
13882
- }
13883
- const candidate = {
13884
- id: (this.deps.idFactory ?? import_crypto5.randomUUID)(),
13885
- tenantId: input.tenantId,
13886
- workspaceId: input.workspaceId,
13887
- projectId: input.projectId,
13888
- roomId: input.roomId,
13889
- author: { type: "bot", membershipId: input.membershipId, assistantId: input.assistantId },
13890
- content: { type: "text", text },
13891
- mentions: [],
13892
- replyToMessageId: input.sourceRoomMessageId,
13893
- source: "agent",
13894
- sourceId: input.sourceId,
13895
- idempotencyKey: input.idempotencyKey
13896
- };
13897
- const canonical = snapshotCanonical(await this.deps.messages.createIdempotent(candidate), candidate);
13898
- if (!canonical) throw new Error("Invalid canonical project room message");
13899
- const result = structuredClone(canonical);
13900
- this.notifyCommitted(result);
13901
- return result;
13902
- }
13903
- notifyCommitted(message) {
13904
- const callback = this.deps.onMessageCommitted;
13905
- if (!callback) return;
13906
- Promise.resolve().then(() => callback(structuredClone(message))).catch(() => {
13907
- try {
13908
- this.deps.onCallbackFailure?.({ messageId: message.id, code: "ROOM_MESSAGE_COMMIT_CALLBACK_FAILED" });
13909
- } catch {
13910
- }
13911
- });
13912
- }
13913
- };
13914
- function exactValues(value, required, optional = []) {
13915
- try {
13916
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
13917
- return (0, import_protocols7.snapshotExactRecord)(value, required, optional);
13918
- } catch {
13919
- return void 0;
13920
- }
13921
- }
13922
- function exactStringRecord(value, keys, message) {
13923
- const values = exactValues(value, keys);
13924
- if (!values || keys.some((key4) => typeof values[key4] !== "string" || values[key4].length === 0)) throw new Error(message);
13925
- return values;
13926
- }
13927
- function date(value) {
13928
- try {
13929
- const timestamp = Date.prototype.getTime.call(value);
13930
- return Number.isFinite(timestamp) ? new Date(timestamp) : void 0;
13931
- } catch {
13932
- return void 0;
13933
- }
13934
- }
13935
- function snapshotSource(value) {
13936
- const values = exactValues(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "author", "content", "mentions", "source", "createdAt"], ["replyToMessageId", "sourceId", "idempotencyKey"]);
13937
- const author = exactValues(values?.author, ["type", "userId"]);
13938
- const content = exactValues(values?.content, ["type", "text"]);
13939
- const createdAt = date(values?.createdAt);
13940
- const mentions = snapshotMentions(values?.mentions);
13941
- if (!values || values.source !== "user" || author?.type !== "human" || typeof author.userId !== "string" || !author.userId || content?.type !== "text" || typeof content.text !== "string" || !mentions || !createdAt || ["id", "tenantId", "workspaceId", "projectId", "roomId"].some((key4) => typeof values[key4] !== "string" || !values[key4])) return void 0;
13942
- return {
13943
- id: values.id,
13944
- tenantId: values.tenantId,
13945
- workspaceId: values.workspaceId,
13946
- projectId: values.projectId,
13947
- roomId: values.roomId,
13948
- author: { type: "human", userId: author.userId },
13949
- content: { type: "text", text: content.text },
13950
- mentions,
13951
- source: "user",
13952
- createdAt
13953
- };
13954
- }
13955
- function snapshotMentions(value) {
13956
- const rows = (0, import_protocols7.snapshotExactArray)(value);
13957
- if (!rows) return void 0;
13958
- const mentions = [];
13959
- for (const row of rows) {
13960
- const team = exactValues(row, ["type"]);
13961
- if (team?.type === "team") {
13962
- mentions.push({ type: "team" });
13963
- continue;
13964
- }
13965
- const bot = exactValues(row, ["type", "membershipId"]);
13966
- if (bot?.type !== "bot" || typeof bot.membershipId !== "string" || !bot.membershipId) return void 0;
13967
- mentions.push({ type: "bot", membershipId: bot.membershipId });
13968
- }
13969
- return mentions;
13970
- }
13971
- function snapshotMembership(value) {
13972
- const required = ["id", "tenantId", "workspaceId", "projectId", "roomId", "assistantId", "role", "title", "mentionName", "status", "roomThreadId", "joinedAt", "updatedAt"];
13973
- const values = exactValues(value, required, ["responsibility"]);
13974
- const joinedAt = date(values?.joinedAt);
13975
- const updatedAt = date(values?.updatedAt);
13976
- if (!values || required.slice(0, 7).some((key4) => typeof values[key4] !== "string" || !values[key4]) || values.role !== "coordinator" && values.role !== "specialist" || typeof values.title !== "string" || !values.title || typeof values.mentionName !== "string" || !values.mentionName || !["active", "paused", "removed"].includes(values.status) || typeof values.roomThreadId !== "string" || !values.roomThreadId || values.responsibility !== void 0 && typeof values.responsibility !== "string" || !joinedAt || !updatedAt) return void 0;
13977
- return { ...values, joinedAt, updatedAt };
13978
- }
13979
- function snapshotCanonical(value, expected) {
13980
- const values = exactValues(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "author", "content", "mentions", "replyToMessageId", "source", "sourceId", "idempotencyKey", "createdAt"]);
13981
- const author = exactValues(values?.author, ["type", "membershipId", "assistantId"]);
13982
- const content = exactValues(values?.content, ["type", "text"]);
13983
- const createdAt = date(values?.createdAt);
13984
- if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0, import_protocols7.snapshotExactArray)(values.mentions)?.length !== 0 || author?.type !== "bot" || expected.author.type !== "bot" || author.membershipId !== expected.author.membershipId || author.assistantId !== expected.author.assistantId || content?.type !== "text" || content.text !== expected.content.text || values.tenantId !== expected.tenantId || values.workspaceId !== expected.workspaceId || values.projectId !== expected.projectId || values.roomId !== expected.roomId || values.replyToMessageId !== expected.replyToMessageId || values.source !== "agent" || values.sourceId !== expected.sourceId || values.idempotencyKey !== expected.idempotencyKey) return void 0;
13985
- return {
13986
- id: values.id,
13987
- tenantId: expected.tenantId,
13988
- workspaceId: expected.workspaceId,
13989
- projectId: expected.projectId,
13990
- roomId: expected.roomId,
13991
- author: { type: "bot", membershipId: expected.author.membershipId, assistantId: expected.author.assistantId },
13992
- content: { type: "text", text: expected.content.text },
13993
- mentions: [],
13994
- replyToMessageId: expected.replyToMessageId,
13995
- source: "agent",
13996
- sourceId: expected.sourceId,
13997
- idempotencyKey: expected.idempotencyKey,
13998
- createdAt
13999
- };
14000
- }
14001
-
14002
- // src/middlewares/projectRoomMiddleware.ts
14003
- var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
14004
- var PROJECT_ROOM_POST_FAILED = "PROJECT_ROOM_POST_FAILED";
14005
- var PROJECT_ROOM_ROSTER_FAILED = "PROJECT_ROOM_ROSTER_FAILED";
14006
- var PROJECT_ROOM_POST_FAILED_MESSAGE = "Project room message could not be posted";
14007
- var PROJECT_ROOM_ROSTER_FAILED_MESSAGE = "Project room roster is unavailable";
14008
- var CONTEXT_REQUIRED = JSON.stringify({
14009
- success: false,
14010
- error: PROJECT_ROOM_CONTEXT_REQUIRED
14011
- });
14012
- var POST_FAILED = JSON.stringify({
14013
- success: false,
14014
- error: PROJECT_ROOM_POST_FAILED,
14015
- message: PROJECT_ROOM_POST_FAILED_MESSAGE
14016
- });
14017
- var ROSTER_FAILED = JSON.stringify({
14018
- success: false,
14019
- error: PROJECT_ROOM_ROSTER_FAILED,
14020
- message: PROJECT_ROOM_ROSTER_FAILED_MESSAGE
14021
- });
14022
- var postSchema = import_zod43.z.object({
14023
- text: import_zod43.z.string().trim().min(1).max(2e4)
14024
- }).strict();
14025
- var listSchema = import_zod43.z.object({}).strict();
14026
- function ownDataValue(record, key4) {
14027
- if (typeof record !== "object" || record === null || Array.isArray(record)) return void 0;
14028
- try {
14029
- const descriptor = Object.getOwnPropertyDescriptor(record, key4);
14030
- return (0, import_protocols8.descriptorDataValue)(descriptor)?.value;
14031
- } catch {
14032
- return void 0;
14033
- }
14034
- }
14035
- function readTrustedRoomScope(config) {
14036
- const configurable = ownDataValue(config, "configurable");
14037
- const runConfig = ownDataValue(configurable, "runConfig");
14038
- const projectRoom = ownDataValue(runConfig, "projectRoom");
14039
- try {
14040
- return (0, import_protocols8.parseTrustedRunContext)({ projectRoom }).projectRoom;
14041
- } catch {
14042
- return void 0;
14043
- }
14044
- }
14045
- function exactValues2(value, required, optional = []) {
14046
- try {
14047
- return (0, import_protocols8.snapshotExactRecord)(value, required, optional);
14048
- } catch {
14049
- return void 0;
14050
- }
14051
- }
14052
- function safeDate(value) {
14053
- try {
14054
- const timestamp = Date.prototype.getTime.call(value);
14055
- return Number.isFinite(timestamp) ? new Date(timestamp) : void 0;
14056
- } catch {
14057
- return void 0;
14058
- }
14059
- }
14060
- function snapshotMembership2(value) {
14061
- const required = [
14062
- "id",
14063
- "tenantId",
14064
- "workspaceId",
14065
- "projectId",
14066
- "roomId",
14067
- "assistantId",
14068
- "role",
14069
- "title",
14070
- "mentionName",
14071
- "status",
14072
- "roomThreadId",
14073
- "joinedAt",
14074
- "updatedAt"
14075
- ];
14076
- const values = exactValues2(value, required, ["responsibility"]);
14077
- const joinedAt = safeDate(values?.joinedAt);
14078
- const updatedAt = safeDate(values?.updatedAt);
14079
- if (!values || !joinedAt || !updatedAt || required.slice(0, 6).some((key4) => typeof values[key4] !== "string" || values[key4] === "") || values.role !== "coordinator" && values.role !== "specialist" || typeof values.title !== "string" || values.title === "" || typeof values.mentionName !== "string" || values.mentionName === "" || !["active", "paused", "removed"].includes(values.status) || typeof values.roomThreadId !== "string" || values.roomThreadId === "" || values.responsibility !== void 0 && typeof values.responsibility !== "string") return void 0;
14080
- return { ...values, joinedAt, updatedAt };
14081
- }
14082
- function snapshotRows(value) {
14083
- return (0, import_protocols8.snapshotExactArray)(value) ?? [];
14084
- }
14085
- async function hasActiveCurrentMembership(scope) {
14086
- const memberships = getStoreLattice("default", "projectBotMembership").store;
14087
- const member = snapshotMembership2(await memberships.findById(scope.tenantId, scope.membershipId));
14088
- if (!member || member.status !== "active" || member.id !== scope.membershipId || member.tenantId !== scope.tenantId || member.workspaceId !== scope.workspaceId || member.projectId !== scope.projectId || member.roomId !== scope.roomId || member.assistantId !== scope.assistantId) return false;
14089
- return true;
14090
- }
14091
- function createProjectRoomMiddleware() {
14092
- return (0, import_langchain47.createMiddleware)({
14093
- name: "ProjectRoomMiddleware",
14094
- tools: [
14095
- (0, import_langchain47.tool)(async (input, config) => {
14096
- const { text } = input;
14097
- const scope = readTrustedRoomScope(config);
14098
- if (!scope) return CONTEXT_REQUIRED;
14099
- const digest = (0, import_crypto6.createHash)("sha256").update(text).digest("hex");
14100
- try {
14101
- const service2 = new RoomAgentMessageService({
14102
- memberships: getStoreLattice("default", "projectBotMembership").store,
14103
- messages: getStoreLattice("default", "projectRoomMessage").store
14104
- });
14105
- await service2.post({
14106
- tenantId: scope.tenantId,
14107
- workspaceId: scope.workspaceId,
14108
- projectId: scope.projectId,
14109
- roomId: scope.roomId,
14110
- membershipId: scope.membershipId,
14111
- assistantId: scope.assistantId,
14112
- text,
14113
- sourceRoomMessageId: scope.sourceRoomMessageId,
14114
- sourceId: `${scope.inputMessageId}:${digest}`,
14115
- idempotencyKey: `room-tool:${scope.inputMessageId}:${scope.membershipId}:${digest}`
14116
- });
14117
- return JSON.stringify({ success: true, message: "Project room message posted" });
14118
- } catch {
14119
- return POST_FAILED;
14120
- }
14121
- }, {
14122
- name: "post_room_message",
14123
- description: "Post a text reply to the current trusted Project Room message",
14124
- schema: postSchema
14125
- }),
14126
- (0, import_langchain47.tool)(async (_input, config) => {
14127
- const scope = readTrustedRoomScope(config);
14128
- if (!scope) return CONTEXT_REQUIRED;
14129
- try {
14130
- if (!await hasActiveCurrentMembership(scope)) return CONTEXT_REQUIRED;
14131
- const rows = await getStoreLattice("default", "projectBotMembership").store.list(scope.tenantId, scope.projectId);
14132
- const members = snapshotRows(rows).map(snapshotMembership2).filter((member) => member !== void 0 && member.status === "active" && member.tenantId === scope.tenantId && member.workspaceId === scope.workspaceId && member.projectId === scope.projectId && member.roomId === scope.roomId).sort((left, right) => left.joinedAt.getTime() - right.joinedAt.getTime() || (left.id < right.id ? -1 : left.id > right.id ? 1 : 0)).map((member) => ({
14133
- assistantId: member.assistantId,
14134
- mentionName: member.mentionName,
14135
- title: member.title,
14136
- ...member.responsibility === void 0 ? {} : { responsibility: member.responsibility },
14137
- role: member.role
14138
- }));
14139
- return JSON.stringify({ success: true, members });
14140
- } catch {
14141
- return ROSTER_FAILED;
14142
- }
14143
- }, {
14144
- name: "list_room_roster",
14145
- description: "List active Agent roles in the current trusted Project Room, including assistantId for delegation",
14146
- schema: listSchema
14147
- })
14148
- ]
14149
- });
14150
- }
14151
- var projectRoomPlugin = {
14152
- meta: {
14153
- type: "project_room",
14154
- category: "assistant",
14155
- name: "Project Room",
14156
- description: "Trusted Project Room posting and active roster tools",
14157
- tools: [
14158
- { name: "post_room_message", description: "Post to the current trusted Project Room" },
14159
- { name: "list_room_roster", description: "List active Agents in the current trusted Project Room" }
14160
- ],
14161
- configSchema: { type: "object", properties: {}, additionalProperties: false },
14162
- defaultConfig: {}
14163
- },
14164
- middleware: () => createProjectRoomMiddleware()
14165
- };
14166
-
14167
13805
  // src/agent_lattice/builders/commonMiddleware.ts
14168
13806
  var SKILL_RESOURCE_SELECTOR = Object.freeze({
14169
13807
  argumentField: "skill_name",
@@ -14334,7 +13972,7 @@ async function resolveAllConnections(type, tenantId2) {
14334
13972
  }
14335
13973
  }
14336
13974
  function createStandardConnectionRefreshMiddleware(configurations, toolTypes) {
14337
- return (0, import_langchain49.createMiddleware)({
13975
+ return (0, import_langchain48.createMiddleware)({
14338
13976
  name: "StandardConnectionRefreshMiddleware",
14339
13977
  wrapToolCall: async (request, handler) => {
14340
13978
  const type = toolTypes.get(request.toolCall.name);
@@ -14393,14 +14031,13 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
14393
14031
  middlewares.push(createPatchToolCallsMiddleware());
14394
14032
  if (model) {
14395
14033
  middlewares.push(
14396
- (0, import_langchain48.summarizationMiddleware)({
14034
+ (0, import_langchain47.summarizationMiddleware)({
14397
14035
  model,
14398
14036
  trigger: { tokens: 17e4 },
14399
14037
  keep: { messages: 6 }
14400
14038
  })
14401
14039
  );
14402
14040
  }
14403
- middlewares.push(createProjectRoomMiddleware());
14404
14041
  const filesystemConfig = normalizedMiddlewareConfigs.find((m) => m.type === "filesystem");
14405
14042
  const clawConfig = normalizedMiddlewareConfigs.find((m) => m.type === "claw");
14406
14043
  const needsFilesystemBackend = filesystemConfig?.enabled || clawConfig?.enabled;
@@ -14427,7 +14064,7 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
14427
14064
  }
14428
14065
  }
14429
14066
  for (const config of normalizedMiddlewareConfigs) {
14430
- if (!config.enabled || config.type === "filesystem" || config.type === "project_room") continue;
14067
+ if (!config.enabled || config.type === "filesystem") continue;
14431
14068
  switch (config.type) {
14432
14069
  case "code_eval":
14433
14070
  addConfiguredMiddleware(
@@ -14748,7 +14385,7 @@ var ReActAgentGraphBuilder = class {
14748
14385
  const middlewareConfigs = params.middleware || [];
14749
14386
  const filesystemBackend = createFilesystemBackendFactory(middlewareConfigs);
14750
14387
  const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend, void 0, params.tenantId, params.model);
14751
- return (0, import_langchain50.createAgent)({
14388
+ return (0, import_langchain49.createAgent)({
14752
14389
  model: params.model,
14753
14390
  tools,
14754
14391
  systemPrompt: params.prompt,
@@ -14762,13 +14399,12 @@ var ReActAgentGraphBuilder = class {
14762
14399
  };
14763
14400
 
14764
14401
  // src/deep_agent_new/agent.ts
14765
- var import_langchain56 = require("langchain");
14402
+ var import_langchain55 = require("langchain");
14766
14403
 
14767
14404
  // src/deep_agent_new/middleware/subagents.ts
14768
14405
  var import_v32 = require("zod/v3");
14769
- var import_langchain52 = require("langchain");
14406
+ var import_langchain51 = require("langchain");
14770
14407
  var import_langgraph7 = require("@langchain/langgraph");
14771
- var import_messages5 = require("@langchain/core/messages");
14772
14408
 
14773
14409
  // src/agent_worker/agent_worker_graph.ts
14774
14410
  var import_langgraph5 = require("@langchain/langgraph");
@@ -14781,7 +14417,7 @@ var import_events = require("events");
14781
14417
 
14782
14418
  // src/queue_lattice/QueueLatticeManager.ts
14783
14419
  init_BaseLatticeManager();
14784
- var import_protocols9 = require("@axiom-lattice/protocols");
14420
+ var import_protocols7 = require("@axiom-lattice/protocols");
14785
14421
 
14786
14422
  // src/queue_lattice/MemoryQueueClient.ts
14787
14423
  var queues = /* @__PURE__ */ new Map();
@@ -14874,7 +14510,7 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
14874
14510
  queueClient = client;
14875
14511
  } else {
14876
14512
  const queueName = config.queueName || process.env.QUEUE_NAME || "tasks";
14877
- if (config.type === import_protocols9.QueueType.REDIS) {
14513
+ if (config.type === import_protocols7.QueueType.REDIS) {
14878
14514
  throw new Error(
14879
14515
  `Redis queue client must be provided. Please install @axiom-lattice/queue-redis and pass the client to registerLattice. Example: registerLattice(key, config, new RedisQueueClient(queueName, options))`
14880
14516
  );
@@ -15172,16 +14808,16 @@ var agentWorkerGraph = createAgentWorkerGraph();
15172
14808
  init_MemoryLatticeManager();
15173
14809
 
15174
14810
  // src/services/Agent.ts
15175
- var import_protocols11 = require("@axiom-lattice/protocols");
14811
+ var import_protocols9 = require("@axiom-lattice/protocols");
15176
14812
  var import_langgraph6 = require("@langchain/langgraph");
15177
- var import_langchain51 = require("langchain");
14813
+ var import_langchain50 = require("langchain");
15178
14814
 
15179
14815
  // src/chunk_buffer_lattice/ChunkBuffer.ts
15180
14816
  var ChunkBuffer = class {
15181
14817
  };
15182
14818
 
15183
14819
  // src/chunk_buffer_lattice/InMemoryChunkBuffer.ts
15184
- var import_protocols10 = require("@axiom-lattice/protocols");
14820
+ var import_protocols8 = require("@axiom-lattice/protocols");
15185
14821
  var import_rxjs = require("rxjs");
15186
14822
  var import_rxjs_for_await = require("rxjs-for-await");
15187
14823
  var import_operators = require("rxjs/operators");
@@ -15269,7 +14905,7 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
15269
14905
  let chunk2;
15270
14906
  if (typeof arg2 === "string" && arg3 !== void 0) {
15271
14907
  chunk2 = {
15272
- type: import_protocols10.MessageChunkTypes.AI,
14908
+ type: import_protocols8.MessageChunkTypes.AI,
15273
14909
  data: {
15274
14910
  id: arg2,
15275
14911
  content: arg3
@@ -15390,8 +15026,8 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
15390
15026
  const buffer2 = this.getBufferIfValid(threadId);
15391
15027
  if (!buffer2) return;
15392
15028
  const defaultStopTypes = [
15393
- import_protocols10.MessageChunkTypes.MESSAGE_COMPLETED,
15394
- import_protocols10.MessageChunkTypes.THREAD_IDLE
15029
+ import_protocols8.MessageChunkTypes.MESSAGE_COMPLETED,
15030
+ import_protocols8.MessageChunkTypes.THREAD_IDLE
15395
15031
  ];
15396
15032
  const typesToStop = stopTypes ?? defaultStopTypes;
15397
15033
  let startIndex = 0;
@@ -15491,7 +15127,7 @@ registerChunkBuffer("default", buffer);
15491
15127
  var import_uuid4 = require("uuid");
15492
15128
 
15493
15129
  // src/capability/CapabilityRuntimeResolver.ts
15494
- var import_zod44 = require("zod");
15130
+ var import_zod43 = require("zod");
15495
15131
 
15496
15132
  // src/capability/CapabilityBundleMerger.ts
15497
15133
  var import_node_crypto3 = require("crypto");
@@ -16273,9 +15909,9 @@ var CapabilityRuntimeResolutionError = class extends Error {
16273
15909
  this.actualRevision = context.actualRevision;
16274
15910
  }
16275
15911
  };
16276
- var bundleIdsSchema = import_zod44.z.array(import_zod44.z.string().uuid()).superRefine((ids, context) => {
15912
+ var bundleIdsSchema = import_zod43.z.array(import_zod43.z.string().uuid()).superRefine((ids, context) => {
16277
15913
  if (new Set(ids).size !== ids.length) {
16278
- context.addIssue({ code: import_zod44.z.ZodIssueCode.custom, message: "Bundle IDs must be unique" });
15914
+ context.addIssue({ code: import_zod43.z.ZodIssueCode.custom, message: "Bundle IDs must be unique" });
16279
15915
  }
16280
15916
  });
16281
15917
  function projectBundleIds(config) {
@@ -16551,7 +16187,7 @@ function cloneRunConfig(value, stripReserved) {
16551
16187
  const clone4 = [];
16552
16188
  for (let index = 0; index < length; index += 1) {
16553
16189
  const key4 = String(index);
16554
- const data = (0, import_protocols11.descriptorDataValue)(descriptors[key4]);
16190
+ const data = (0, import_protocols9.descriptorDataValue)(descriptors[key4]);
16555
16191
  if (!data || data.value === void 0) {
16556
16192
  throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${key4}`);
16557
16193
  }
@@ -16566,7 +16202,7 @@ function cloneRunConfig(value, stripReserved) {
16566
16202
  for (const key4 of keys) {
16567
16203
  if (typeof key4 !== "string") continue;
16568
16204
  const fieldPath = callerRunConfigPath(path8, key4);
16569
- const data = (0, import_protocols11.descriptorDataValue)(descriptors[key4]);
16205
+ const data = (0, import_protocols9.descriptorDataValue)(descriptors[key4]);
16570
16206
  if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
16571
16207
  if (stripReserved && RESERVED_CALLER_RUN_KEYS.has(key4) || data.value === void 0) continue;
16572
16208
  Object.defineProperty(clone3, key4, {
@@ -16602,7 +16238,7 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
16602
16238
  if (Array.isArray(entry)) {
16603
16239
  const descriptors2 = Object.getOwnPropertyDescriptors(entry);
16604
16240
  for (let index = 0; index < entry.length; index += 1) {
16605
- const data = (0, import_protocols11.descriptorDataValue)(descriptors2[String(index)]);
16241
+ const data = (0, import_protocols9.descriptorDataValue)(descriptors2[String(index)]);
16606
16242
  if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${index}`);
16607
16243
  visit(data.value, `${path8}/${index}`);
16608
16244
  }
@@ -16621,7 +16257,7 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
16621
16257
  }
16622
16258
  const fieldPath = callerRunConfigPath(path8, key4);
16623
16259
  const descriptor = descriptors[key4];
16624
- const data = (0, import_protocols11.descriptorDataValue)(descriptor);
16260
+ const data = (0, import_protocols9.descriptorDataValue)(descriptor);
16625
16261
  if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
16626
16262
  if (isCredentialBearingKey(key4)) {
16627
16263
  throw new CapabilityRuntimeResolutionError(
@@ -16656,7 +16292,7 @@ function cloneExecutionRunConfigBase(value) {
16656
16292
  throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
16657
16293
  }
16658
16294
  const descriptor = descriptors[key4];
16659
- const data = (0, import_protocols11.descriptorDataValue)(descriptor);
16295
+ const data = (0, import_protocols9.descriptorDataValue)(descriptor);
16660
16296
  if (!data) {
16661
16297
  throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
16662
16298
  }
@@ -16739,19 +16375,19 @@ var DelegatedScopeNotQueueableError = class extends Error {
16739
16375
  this.name = "DelegatedScopeNotQueueableError";
16740
16376
  }
16741
16377
  };
16742
- function ownDataValue2(value, key4) {
16378
+ function ownDataValue(value, key4) {
16743
16379
  if (typeof value !== "object" || value === null) return void 0;
16744
16380
  try {
16745
- return (0, import_protocols11.descriptorDataValue)(Object.getOwnPropertyDescriptor(value, key4))?.value;
16381
+ return (0, import_protocols9.descriptorDataValue)(Object.getOwnPropertyDescriptor(value, key4))?.value;
16746
16382
  } catch {
16747
16383
  return void 0;
16748
16384
  }
16749
16385
  }
16750
16386
  function checkpointCapabilityRevision(state) {
16751
- const config = ownDataValue2(state, "config");
16752
- const configurable = ownDataValue2(config, "configurable");
16753
- const runConfig = ownDataValue2(configurable, "runConfig");
16754
- const revision = ownDataValue2(runConfig, "capabilityRuntimeRevision");
16387
+ const config = ownDataValue(state, "config");
16388
+ const configurable = ownDataValue(config, "configurable");
16389
+ const runConfig = ownDataValue(configurable, "runConfig");
16390
+ const revision = ownDataValue(runConfig, "capabilityRuntimeRevision");
16755
16391
  return typeof revision === "string" && revision.length > 0 ? revision : void 0;
16756
16392
  }
16757
16393
  var QUEUE_PROCESSOR_RETRY_BASE_MS = 100;
@@ -17389,12 +17025,16 @@ var Agent = class {
17389
17025
  queuedInputMessages(content) {
17390
17026
  const messages = content.queueMessage.input.messages;
17391
17027
  if (!Array.isArray(messages) || messages.length === 0) {
17392
- return [new import_langchain51.HumanMessage({ id: content.id, content: content.message })];
17028
+ return [new import_langchain50.HumanMessage({ id: content.id, content: content.message })];
17029
+ }
17030
+ const invalid = messages.filter((message) => !isMessageContent(message.content));
17031
+ if (invalid.length > 0) {
17032
+ console.error(
17033
+ `[Agent] Dropping ${invalid.length} queued message(s) with invalid serialized content for queued message ${content.id}; falling back to stored display content`
17034
+ );
17035
+ return [new import_langchain50.HumanMessage({ id: content.id, content: content.message })];
17393
17036
  }
17394
17037
  return messages.map((message) => {
17395
- if (!isMessageContent(message.content)) {
17396
- throw new Error(`Invalid structured message content for queued message ${content.id}`);
17397
- }
17398
17038
  const fields = {
17399
17039
  id: message.id,
17400
17040
  content: message.content,
@@ -17402,16 +17042,16 @@ var Agent = class {
17402
17042
  };
17403
17043
  switch (message.role) {
17404
17044
  case "system":
17405
- return new import_langchain51.SystemMessage(fields);
17045
+ return new import_langchain50.SystemMessage(fields);
17406
17046
  case "assistant":
17407
- return new import_langchain51.AIMessage(fields);
17047
+ return new import_langchain50.AIMessage(fields);
17408
17048
  case "tool":
17409
- return new import_langchain51.ToolMessage({
17049
+ return new import_langchain50.ToolMessage({
17410
17050
  ...fields,
17411
17051
  tool_call_id: typeof message.metadata?.tool_call_id === "string" ? message.metadata.tool_call_id : ""
17412
17052
  });
17413
17053
  case "human":
17414
- return new import_langchain51.HumanMessage(fields);
17054
+ return new import_langchain50.HumanMessage(fields);
17415
17055
  }
17416
17056
  });
17417
17057
  }
@@ -17527,7 +17167,7 @@ var Agent = class {
17527
17167
  this.validateMessageInput(queueMessage);
17528
17168
  const input = {
17529
17169
  ...queueMessage.input,
17530
- ...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain51.HumanMessage({ id: (0, import_uuid4.v4)(), content: queueMessage.input.message })] } : {}
17170
+ ...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain50.HumanMessage({ id: (0, import_uuid4.v4)(), content: queueMessage.input.message })] } : {}
17531
17171
  };
17532
17172
  const recoveryContext = await this.interruptedCommandExecutionContext(queueMessage.command);
17533
17173
  const inputMessage = {
@@ -17561,7 +17201,7 @@ var Agent = class {
17561
17201
  this.validateMessageInput(queueMessage);
17562
17202
  const input = {
17563
17203
  ...queueMessage.input,
17564
- ...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain51.HumanMessage({ id: (0, import_uuid4.v4)(), content: queueMessage.input.message })] } : {}
17204
+ ...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain50.HumanMessage({ id: (0, import_uuid4.v4)(), content: queueMessage.input.message })] } : {}
17565
17205
  };
17566
17206
  const recoveryContext = await this.interruptedCommandExecutionContext(queueMessage.command);
17567
17207
  const inputMessage = { ...queueMessage, input, trusted_run_context: recoveryContext?.trustedRunContext };
@@ -18063,7 +17703,7 @@ var Agent = class {
18063
17703
  async getCurrentMessages() {
18064
17704
  const state = await this.getCurrentState();
18065
17705
  const messages = state.values.messages || [];
18066
- const filteredMessages = (0, import_langchain51.filterMessages)(messages, {
17706
+ const filteredMessages = (0, import_langchain50.filterMessages)(messages, {
18067
17707
  includeTypes: ["ai", "human", "tool"]
18068
17708
  //["human", "ai", "tool"],
18069
17709
  });
@@ -18601,7 +18241,7 @@ function returnCommandWithStateUpdate(result, toolCallId) {
18601
18241
  update: {
18602
18242
  ...stateUpdate,
18603
18243
  messages: [
18604
- new import_langchain52.ToolMessage({
18244
+ new import_langchain51.ToolMessage({
18605
18245
  content: lastMessage?.content || "Task Failed to complete",
18606
18246
  tool_call_id: toolCallId,
18607
18247
  name: "task"
@@ -18626,10 +18266,10 @@ function getSubagents(options) {
18626
18266
  const generalPurposeMiddleware = [...defaultSubagentMiddleware];
18627
18267
  if (defaultInterruptOn) {
18628
18268
  generalPurposeMiddleware.push(
18629
- (0, import_langchain52.humanInTheLoopMiddleware)({ interruptOn: defaultInterruptOn })
18269
+ (0, import_langchain51.humanInTheLoopMiddleware)({ interruptOn: defaultInterruptOn })
18630
18270
  );
18631
18271
  }
18632
- const generalPurposeSubagent = (0, import_langchain52.createAgent)({
18272
+ const generalPurposeSubagent = (0, import_langchain51.createAgent)({
18633
18273
  model: defaultModel,
18634
18274
  systemPrompt: DEFAULT_SUBAGENT_PROMPT,
18635
18275
  tools: defaultTools,
@@ -18652,8 +18292,8 @@ function getSubagents(options) {
18652
18292
  const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
18653
18293
  const interruptOn = agentParams.interruptOn || defaultInterruptOn;
18654
18294
  if (interruptOn)
18655
- middleware.push((0, import_langchain52.humanInTheLoopMiddleware)({ interruptOn }));
18656
- agents[agentParams.key] = (0, import_langchain52.createAgent)({
18295
+ middleware.push((0, import_langchain51.humanInTheLoopMiddleware)({ interruptOn }));
18296
+ agents[agentParams.key] = (0, import_langchain51.createAgent)({
18657
18297
  model: agentParams.model ?? defaultModel,
18658
18298
  systemPrompt: agentParams.systemPrompt,
18659
18299
  tools: agentParams.tools ?? defaultTools,
@@ -18703,7 +18343,7 @@ function createTaskTool(options) {
18703
18343
  generalPurposeAgent
18704
18344
  });
18705
18345
  const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
18706
- return (0, import_langchain52.tool)(
18346
+ return (0, import_langchain51.tool)(
18707
18347
  async (input, config) => {
18708
18348
  const { description, subagent_type, async } = input;
18709
18349
  if (input.taskId) {
@@ -18717,7 +18357,7 @@ function createTaskTool(options) {
18717
18357
  return new import_langgraph7.Command({
18718
18358
  update: {
18719
18359
  messages: [
18720
- new import_langchain52.ToolMessage({
18360
+ new import_langchain51.ToolMessage({
18721
18361
  content: JSON.stringify({
18722
18362
  success: false,
18723
18363
  code: "TASK_MIDDLEWARE_REQUIRED",
@@ -18759,7 +18399,8 @@ function createTaskTool(options) {
18759
18399
  const currentState = (0, import_langgraph7.getCurrentTaskInput)();
18760
18400
  const subagentState = filterStateForSubagent(currentState);
18761
18401
  subagentState.messages = input.taskId ? [
18762
- new import_messages5.HumanMessage({
18402
+ {
18403
+ role: "human",
18763
18404
  content: `${description}
18764
18405
 
18765
18406
  ---
@@ -18769,8 +18410,8 @@ You are executing a persistent task (ID: ${input.taskId}). Use manage_task.updat
18769
18410
  - Preserve the Objective and Acceptance Criteria contract. Do not append progress notes to the description; put progress and evidence in the result or Activity.
18770
18411
  - Complete agent-owned tasks with result plus beliefImpact: [{ key, after, basis }] where key references the belief owner's canonical Belief State; the middleware records completion evidence and writes the parent belief activity automatically.
18771
18412
  - Use add_activity only for additional observations or plan revisions when the result changes the parent belief or plan.`
18772
- })
18773
- ] : [new import_messages5.HumanMessage({ content: description })];
18413
+ }
18414
+ ] : [{ role: "human", content: description }];
18774
18415
  const subagent_thread_id = config.configurable?.thread_id + "____" + assistant_id + "_" + config.toolCall.id;
18775
18416
  if (async) {
18776
18417
  const tenantId2 = config.configurable?.runConfig?.tenantId;
@@ -18817,7 +18458,7 @@ You are executing a persistent task (ID: ${input.taskId}). Use manage_task.updat
18817
18458
  return new import_langgraph7.Command({
18818
18459
  update: {
18819
18460
  messages: [
18820
- new import_langchain52.ToolMessage({
18461
+ new import_langchain51.ToolMessage({
18821
18462
  content: `Async task started: ${subagent_thread_id}
18822
18463
  ${description}
18823
18464
  The result will be delivered as a notification when complete. Do not poll.`,
@@ -18851,7 +18492,7 @@ The result will be delivered as a notification when complete. Do not poll.`,
18851
18492
  return new import_langgraph7.Command({
18852
18493
  update: {
18853
18494
  messages: [
18854
- new import_langchain52.ToolMessage({
18495
+ new import_langchain51.ToolMessage({
18855
18496
  content: error instanceof Error ? error.message : "Task Failed to complete",
18856
18497
  tool_call_id: config.toolCall.id,
18857
18498
  name: "task"
@@ -18894,7 +18535,7 @@ function getMainAgentFromConfig(config) {
18894
18535
  });
18895
18536
  }
18896
18537
  function createCheckAsyncTaskTool() {
18897
- return (0, import_langchain52.tool)(
18538
+ return (0, import_langchain51.tool)(
18898
18539
  async (input, config) => {
18899
18540
  const { task_id } = input;
18900
18541
  const mainAgent = getMainAgentFromConfig(config);
@@ -18961,7 +18602,7 @@ Description: ${cached.description}`;
18961
18602
  );
18962
18603
  }
18963
18604
  function createListAsyncTasksTool() {
18964
- return (0, import_langchain52.tool)(
18605
+ return (0, import_langchain51.tool)(
18965
18606
  async (_input, config) => {
18966
18607
  const mainAgent = getMainAgentFromConfig(config);
18967
18608
  if (!mainAgent) {
@@ -19012,7 +18653,7 @@ function createListAsyncTasksTool() {
19012
18653
  );
19013
18654
  }
19014
18655
  function createCancelAsyncTaskTool() {
19015
- return (0, import_langchain52.tool)(
18656
+ return (0, import_langchain51.tool)(
19016
18657
  async (input, config) => {
19017
18658
  const { task_id } = input;
19018
18659
  const mainAgent = getMainAgentFromConfig(config);
@@ -19088,7 +18729,7 @@ function createSubAgentMiddleware(options) {
19088
18729
  );
19089
18730
  }
19090
18731
  const effectiveSystemPrompt = allowAsync ? systemPrompt + getAsyncPromptText() : systemPrompt;
19091
- return (0, import_langchain52.createMiddleware)({
18732
+ return (0, import_langchain51.createMiddleware)({
19092
18733
  name: "subAgentMiddleware",
19093
18734
  tools: allTools,
19094
18735
  wrapModelCall: async (request, handler) => {
@@ -19108,8 +18749,8 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
19108
18749
  }
19109
18750
 
19110
18751
  // src/deep_agent_new/middleware/date.ts
19111
- var import_langchain53 = require("langchain");
19112
- var import_zod45 = require("zod");
18752
+ var import_langchain52 = require("langchain");
18753
+ var import_zod44 = require("zod");
19113
18754
  function formatCurrentDate(timezone = "UTC") {
19114
18755
  const now = /* @__PURE__ */ new Date();
19115
18756
  let validTimezone = timezone;
@@ -19137,10 +18778,10 @@ function generateDateContext(timezone = "UTC") {
19137
18778
  function createDateMiddleware(options = {}) {
19138
18779
  const timezone = options.timezone || "UTC";
19139
18780
  const dateContext = generateDateContext(timezone);
19140
- return (0, import_langchain53.createMiddleware)({
18781
+ return (0, import_langchain52.createMiddleware)({
19141
18782
  name: "DateMiddleware",
19142
18783
  tools: [
19143
- (0, import_langchain53.tool)(
18784
+ (0, import_langchain52.tool)(
19144
18785
  async () => {
19145
18786
  const now = /* @__PURE__ */ new Date();
19146
18787
  let validTimezone = timezone;
@@ -19170,7 +18811,7 @@ function createDateMiddleware(options = {}) {
19170
18811
  {
19171
18812
  name: "get_current_date_time",
19172
18813
  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.",
19173
- schema: import_zod45.z.object({})
18814
+ schema: import_zod44.z.object({})
19174
18815
  }
19175
18816
  )
19176
18817
  ],
@@ -19236,20 +18877,20 @@ var datePlugin = {
19236
18877
  };
19237
18878
 
19238
18879
  // src/deep_agent_new/middleware/scheduler.ts
19239
- var import_langchain54 = require("langchain");
19240
- var import_zod46 = require("zod");
18880
+ var import_langchain53 = require("langchain");
18881
+ var import_zod45 = require("zod");
19241
18882
  var import_uuid5 = require("uuid");
19242
- var import_protocols15 = require("@axiom-lattice/protocols");
18883
+ var import_protocols13 = require("@axiom-lattice/protocols");
19243
18884
 
19244
18885
  // src/schedule_lattice/ScheduleLatticeManager.ts
19245
18886
  init_BaseLatticeManager();
19246
- var import_protocols14 = require("@axiom-lattice/protocols");
18887
+ var import_protocols12 = require("@axiom-lattice/protocols");
19247
18888
 
19248
18889
  // src/schedule_lattice/DefaultScheduleClient.ts
19249
- var import_protocols13 = require("@axiom-lattice/protocols");
18890
+ var import_protocols11 = require("@axiom-lattice/protocols");
19250
18891
 
19251
18892
  // src/schedule_lattice/MemoryScheduleStorage.ts
19252
- var import_protocols12 = require("@axiom-lattice/protocols");
18893
+ var import_protocols10 = require("@axiom-lattice/protocols");
19253
18894
  var MemoryScheduleStorage = class {
19254
18895
  constructor() {
19255
18896
  this.tasks = /* @__PURE__ */ new Map();
@@ -19292,7 +18933,7 @@ var MemoryScheduleStorage = class {
19292
18933
  async getActiveTasks() {
19293
18934
  const result = [];
19294
18935
  for (const task of this.tasks.values()) {
19295
- if (task.status === import_protocols12.ScheduledTaskStatus.PENDING || task.status === import_protocols12.ScheduledTaskStatus.PAUSED) {
18936
+ if (task.status === import_protocols10.ScheduledTaskStatus.PENDING || task.status === import_protocols10.ScheduledTaskStatus.PAUSED) {
19296
18937
  result.push({ ...task });
19297
18938
  }
19298
18939
  }
@@ -19435,7 +19076,7 @@ var MemoryScheduleStorage = class {
19435
19076
  const cutoff = Date.now() - olderThanMs;
19436
19077
  let deleted = 0;
19437
19078
  for (const [taskId, task] of this.tasks.entries()) {
19438
- if ((task.status === import_protocols12.ScheduledTaskStatus.COMPLETED || task.status === import_protocols12.ScheduledTaskStatus.CANCELLED || task.status === import_protocols12.ScheduledTaskStatus.FAILED) && task.updatedAt < cutoff) {
19079
+ if ((task.status === import_protocols10.ScheduledTaskStatus.COMPLETED || task.status === import_protocols10.ScheduledTaskStatus.CANCELLED || task.status === import_protocols10.ScheduledTaskStatus.FAILED) && task.updatedAt < cutoff) {
19439
19080
  this.tasks.delete(taskId);
19440
19081
  deleted++;
19441
19082
  }
@@ -19716,10 +19357,10 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19716
19357
  tenantId: options.tenantId ?? "default",
19717
19358
  assistantId: options.assistantId,
19718
19359
  threadId: options.threadId,
19719
- executionType: import_protocols13.ScheduleExecutionType.ONCE,
19360
+ executionType: import_protocols11.ScheduleExecutionType.ONCE,
19720
19361
  executeAt,
19721
19362
  delayMs: options.delayMs,
19722
- status: import_protocols13.ScheduledTaskStatus.PENDING,
19363
+ status: import_protocols11.ScheduledTaskStatus.PENDING,
19723
19364
  runCount: 0,
19724
19365
  retryCount: 0,
19725
19366
  maxRetries: options.maxRetries ?? 0,
@@ -19762,11 +19403,11 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19762
19403
  tenantId: options.tenantId ?? "default",
19763
19404
  assistantId: options.assistantId,
19764
19405
  threadId: options.threadId,
19765
- executionType: import_protocols13.ScheduleExecutionType.CRON,
19406
+ executionType: import_protocols11.ScheduleExecutionType.CRON,
19766
19407
  cronExpression: options.cronExpression,
19767
19408
  timezone: options.timezone,
19768
19409
  nextRunAt: nextRunAt.getTime(),
19769
- status: import_protocols13.ScheduledTaskStatus.PENDING,
19410
+ status: import_protocols11.ScheduledTaskStatus.PENDING,
19770
19411
  runCount: 0,
19771
19412
  maxRuns: options.maxRuns,
19772
19413
  retryCount: 0,
@@ -19793,7 +19434,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19793
19434
  const task = await this.storage.get(taskId);
19794
19435
  if (task) {
19795
19436
  await this.storage.update(taskId, {
19796
- status: import_protocols13.ScheduledTaskStatus.CANCELLED
19437
+ status: import_protocols11.ScheduledTaskStatus.CANCELLED
19797
19438
  });
19798
19439
  console.log(`[Scheduler] Task cancelled: ${taskId}`);
19799
19440
  return true;
@@ -19802,11 +19443,11 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19802
19443
  }
19803
19444
  async pause(taskId) {
19804
19445
  const task = await this.storage.get(taskId);
19805
- if (!task || task.executionType !== import_protocols13.ScheduleExecutionType.CRON) {
19446
+ if (!task || task.executionType !== import_protocols11.ScheduleExecutionType.CRON) {
19806
19447
  console.error(`[Scheduler] Can only pause CRON tasks: ${taskId}`);
19807
19448
  return false;
19808
19449
  }
19809
- if (task.status !== import_protocols13.ScheduledTaskStatus.PENDING) {
19450
+ if (task.status !== import_protocols11.ScheduledTaskStatus.PENDING) {
19810
19451
  console.error(`[Scheduler] Can only pause PENDING tasks: ${taskId}`);
19811
19452
  return false;
19812
19453
  }
@@ -19816,24 +19457,24 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19816
19457
  this.timers.delete(taskId);
19817
19458
  }
19818
19459
  await this.storage.update(taskId, {
19819
- status: import_protocols13.ScheduledTaskStatus.PAUSED
19460
+ status: import_protocols11.ScheduledTaskStatus.PAUSED
19820
19461
  });
19821
19462
  console.log(`[Scheduler] Task paused: ${taskId}`);
19822
19463
  return true;
19823
19464
  }
19824
19465
  async resume(taskId) {
19825
19466
  const task = await this.storage.get(taskId);
19826
- if (!task || task.executionType !== import_protocols13.ScheduleExecutionType.CRON) {
19467
+ if (!task || task.executionType !== import_protocols11.ScheduleExecutionType.CRON) {
19827
19468
  console.error(`[Scheduler] Can only resume CRON tasks: ${taskId}`);
19828
19469
  return false;
19829
19470
  }
19830
- if (task.status !== import_protocols13.ScheduledTaskStatus.PAUSED) {
19471
+ if (task.status !== import_protocols11.ScheduledTaskStatus.PAUSED) {
19831
19472
  console.error(`[Scheduler] Can only resume PAUSED tasks: ${taskId}`);
19832
19473
  return false;
19833
19474
  }
19834
19475
  const nextRunAt = getNextCronTime(task.cronExpression);
19835
19476
  await this.storage.update(taskId, {
19836
- status: import_protocols13.ScheduledTaskStatus.PENDING,
19477
+ status: import_protocols11.ScheduledTaskStatus.PENDING,
19837
19478
  nextRunAt: nextRunAt.getTime()
19838
19479
  });
19839
19480
  const updatedTask = await this.storage.get(taskId);
@@ -19855,7 +19496,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19855
19496
  if (!task) {
19856
19497
  return -1;
19857
19498
  }
19858
- const targetTime = task.executionType === import_protocols13.ScheduleExecutionType.CRON ? task.nextRunAt : task.executeAt;
19499
+ const targetTime = task.executionType === import_protocols11.ScheduleExecutionType.CRON ? task.nextRunAt : task.executeAt;
19859
19500
  if (targetTime === void 0) {
19860
19501
  return -1;
19861
19502
  }
@@ -19877,7 +19518,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19877
19518
  const activeTasks = await this.storage.getActiveTasks();
19878
19519
  for (const task of activeTasks) {
19879
19520
  await this.storage.update(task.taskId, {
19880
- status: import_protocols13.ScheduledTaskStatus.CANCELLED
19521
+ status: import_protocols11.ScheduledTaskStatus.CANCELLED
19881
19522
  });
19882
19523
  }
19883
19524
  console.log(`[Scheduler] All tasks cancelled`);
@@ -19893,10 +19534,10 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19893
19534
  );
19894
19535
  continue;
19895
19536
  }
19896
- if (task.status === import_protocols13.ScheduledTaskStatus.PAUSED) {
19537
+ if (task.status === import_protocols11.ScheduledTaskStatus.PAUSED) {
19897
19538
  continue;
19898
19539
  }
19899
- if (task.executionType === import_protocols13.ScheduleExecutionType.ONCE) {
19540
+ if (task.executionType === import_protocols11.ScheduleExecutionType.ONCE) {
19900
19541
  if (task.executeAt && task.executeAt <= Date.now()) {
19901
19542
  console.log(
19902
19543
  `[Scheduler] Executing overdue one-time task: ${task.taskId}`
@@ -19905,7 +19546,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19905
19546
  } else {
19906
19547
  this.scheduleTimer(task);
19907
19548
  }
19908
- } else if (task.executionType === import_protocols13.ScheduleExecutionType.CRON) {
19549
+ } else if (task.executionType === import_protocols11.ScheduleExecutionType.CRON) {
19909
19550
  const nextRunAt = getNextCronTime(task.cronExpression);
19910
19551
  await this.storage.update(task.taskId, {
19911
19552
  nextRunAt: nextRunAt.getTime()
@@ -19929,7 +19570,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19929
19570
  }
19930
19571
  // ===== Private Methods =====
19931
19572
  scheduleTimer(task) {
19932
- const targetTime = task.executionType === import_protocols13.ScheduleExecutionType.CRON ? task.nextRunAt : task.executeAt;
19573
+ const targetTime = task.executionType === import_protocols11.ScheduleExecutionType.CRON ? task.nextRunAt : task.executeAt;
19933
19574
  if (targetTime === void 0) {
19934
19575
  console.error(`[Scheduler] No execution time for task: ${task.taskId}`);
19935
19576
  return;
@@ -19950,13 +19591,13 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19950
19591
  `[Scheduler] No handler for task type: ${task.taskType}, task: ${task.taskId}`
19951
19592
  );
19952
19593
  await this.storage.update(task.taskId, {
19953
- status: import_protocols13.ScheduledTaskStatus.FAILED,
19594
+ status: import_protocols11.ScheduledTaskStatus.FAILED,
19954
19595
  lastError: `No handler registered for task type: ${task.taskType}`
19955
19596
  });
19956
19597
  return;
19957
19598
  }
19958
19599
  await this.storage.update(task.taskId, {
19959
- status: import_protocols13.ScheduledTaskStatus.RUNNING
19600
+ status: import_protocols11.ScheduledTaskStatus.RUNNING
19960
19601
  });
19961
19602
  console.log(`[Scheduler] Executing task: ${task.taskId}`);
19962
19603
  try {
@@ -19968,17 +19609,17 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19968
19609
  await handler(latestTask.payload, latestTask);
19969
19610
  const newRunCount = latestTask.runCount + 1;
19970
19611
  console.log(`[Scheduler] Task completed: ${task.taskId}`);
19971
- if (task.executionType === import_protocols13.ScheduleExecutionType.ONCE) {
19612
+ if (task.executionType === import_protocols11.ScheduleExecutionType.ONCE) {
19972
19613
  await this.storage.update(task.taskId, {
19973
- status: import_protocols13.ScheduledTaskStatus.COMPLETED,
19614
+ status: import_protocols11.ScheduledTaskStatus.COMPLETED,
19974
19615
  runCount: newRunCount,
19975
19616
  lastRunAt: Date.now()
19976
19617
  });
19977
19618
  this.timers.delete(task.taskId);
19978
- } else if (task.executionType === import_protocols13.ScheduleExecutionType.CRON) {
19619
+ } else if (task.executionType === import_protocols11.ScheduleExecutionType.CRON) {
19979
19620
  if (task.maxRuns !== void 0 && newRunCount >= task.maxRuns) {
19980
19621
  await this.storage.update(task.taskId, {
19981
- status: import_protocols13.ScheduledTaskStatus.COMPLETED,
19622
+ status: import_protocols11.ScheduledTaskStatus.COMPLETED,
19982
19623
  runCount: newRunCount,
19983
19624
  lastRunAt: Date.now()
19984
19625
  });
@@ -19990,7 +19631,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
19990
19631
  }
19991
19632
  if (task.expiresAt !== void 0 && Date.now() >= task.expiresAt) {
19992
19633
  await this.storage.update(task.taskId, {
19993
- status: import_protocols13.ScheduledTaskStatus.COMPLETED,
19634
+ status: import_protocols11.ScheduledTaskStatus.COMPLETED,
19994
19635
  runCount: newRunCount,
19995
19636
  lastRunAt: Date.now()
19996
19637
  });
@@ -20002,7 +19643,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
20002
19643
  }
20003
19644
  const nextRunAt = getNextCronTime(task.cronExpression);
20004
19645
  await this.storage.update(task.taskId, {
20005
- status: import_protocols13.ScheduledTaskStatus.PENDING,
19646
+ status: import_protocols11.ScheduledTaskStatus.PENDING,
20006
19647
  runCount: newRunCount,
20007
19648
  lastRunAt: Date.now(),
20008
19649
  nextRunAt: nextRunAt.getTime(),
@@ -20028,7 +19669,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
20028
19669
  `[Scheduler] Retrying task: ${task.taskId} (attempt ${newRetryCount}/${latestTask.maxRetries})`
20029
19670
  );
20030
19671
  await this.storage.update(task.taskId, {
20031
- status: import_protocols13.ScheduledTaskStatus.PENDING,
19672
+ status: import_protocols11.ScheduledTaskStatus.PENDING,
20032
19673
  retryCount: newRetryCount,
20033
19674
  lastError: errorMessage2
20034
19675
  });
@@ -20038,7 +19679,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
20038
19679
  );
20039
19680
  const retryTask = await this.storage.get(task.taskId);
20040
19681
  if (retryTask) {
20041
- if (task.executionType === import_protocols13.ScheduleExecutionType.ONCE) {
19682
+ if (task.executionType === import_protocols11.ScheduleExecutionType.ONCE) {
20042
19683
  retryTask.executeAt = Date.now() + retryDelay;
20043
19684
  } else {
20044
19685
  retryTask.nextRunAt = Date.now() + retryDelay;
@@ -20051,7 +19692,7 @@ var _DefaultScheduleClient = class _DefaultScheduleClient {
20051
19692
  }
20052
19693
  } else {
20053
19694
  await this.storage.update(task.taskId, {
20054
- status: import_protocols13.ScheduledTaskStatus.FAILED,
19695
+ status: import_protocols11.ScheduledTaskStatus.FAILED,
20055
19696
  retryCount: newRetryCount,
20056
19697
  lastError: errorMessage2
20057
19698
  });
@@ -20103,9 +19744,9 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
20103
19744
  } else {
20104
19745
  storage = new MemoryScheduleStorage();
20105
19746
  }
20106
- if (config.type === import_protocols14.ScheduleType.MEMORY) {
19747
+ if (config.type === import_protocols12.ScheduleType.MEMORY) {
20107
19748
  scheduleClient = new DefaultScheduleClient(storage);
20108
- } else if (config.type === import_protocols14.ScheduleType.POSTGRES) {
19749
+ } else if (config.type === import_protocols12.ScheduleType.POSTGRES) {
20109
19750
  if (!config.storage) {
20110
19751
  throw new Error(
20111
19752
  `PostgreSQL schedule storage must be provided. Please install @axiom-lattice/pg-stores and pass the storage in config.storage.`
@@ -20240,20 +19881,20 @@ function getRunConfig(config) {
20240
19881
  function mapStatusToEnum(status) {
20241
19882
  if (!status) return void 0;
20242
19883
  const statusMap = {
20243
- pending: import_protocols15.ScheduledTaskStatus.PENDING,
20244
- running: import_protocols15.ScheduledTaskStatus.RUNNING,
20245
- completed: import_protocols15.ScheduledTaskStatus.COMPLETED,
20246
- failed: import_protocols15.ScheduledTaskStatus.FAILED,
20247
- cancelled: import_protocols15.ScheduledTaskStatus.CANCELLED,
20248
- paused: import_protocols15.ScheduledTaskStatus.PAUSED
19884
+ pending: import_protocols13.ScheduledTaskStatus.PENDING,
19885
+ running: import_protocols13.ScheduledTaskStatus.RUNNING,
19886
+ completed: import_protocols13.ScheduledTaskStatus.COMPLETED,
19887
+ failed: import_protocols13.ScheduledTaskStatus.FAILED,
19888
+ cancelled: import_protocols13.ScheduledTaskStatus.CANCELLED,
19889
+ paused: import_protocols13.ScheduledTaskStatus.PAUSED
20249
19890
  };
20250
19891
  return statusMap[status];
20251
19892
  }
20252
19893
  function mapExecutionTypeToEnum(executionType) {
20253
19894
  if (!executionType) return void 0;
20254
19895
  const typeMap = {
20255
- once: import_protocols15.ScheduleExecutionType.ONCE,
20256
- cron: import_protocols15.ScheduleExecutionType.CRON
19896
+ once: import_protocols13.ScheduleExecutionType.ONCE,
19897
+ cron: import_protocols13.ScheduleExecutionType.CRON
20257
19898
  };
20258
19899
  return typeMap[executionType];
20259
19900
  }
@@ -20305,10 +19946,10 @@ function registerAgentAddMessageHandler() {
20305
19946
  function createSchedulerMiddleware(options = {}) {
20306
19947
  const defaultMaxRetries = options.defaultMaxRetries ?? 0;
20307
19948
  registerAgentAddMessageHandler();
20308
- return (0, import_langchain54.createMiddleware)({
19949
+ return (0, import_langchain53.createMiddleware)({
20309
19950
  name: "SchedulerMiddleware",
20310
19951
  tools: [
20311
- (0, import_langchain54.tool)(
19952
+ (0, import_langchain53.tool)(
20312
19953
  async (input, config) => {
20313
19954
  const runConfig = getRunConfig(config);
20314
19955
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
@@ -20336,14 +19977,14 @@ function createSchedulerMiddleware(options = {}) {
20336
19977
  {
20337
19978
  name: "schedule_at",
20338
19979
  description: "Schedule a system message for an absolute future timestamp",
20339
- schema: import_zod46.z.object({
20340
- executeAt: import_zod46.z.number(),
20341
- maxRetries: import_zod46.z.number().int().min(0).optional(),
20342
- message: import_zod46.z.string()
19980
+ schema: import_zod45.z.object({
19981
+ executeAt: import_zod45.z.number(),
19982
+ maxRetries: import_zod45.z.number().int().min(0).optional(),
19983
+ message: import_zod45.z.string()
20343
19984
  })
20344
19985
  }
20345
19986
  ),
20346
- (0, import_langchain54.tool)(
19987
+ (0, import_langchain53.tool)(
20347
19988
  async (input, config) => {
20348
19989
  const runConfig = getRunConfig(config);
20349
19990
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
@@ -20371,14 +20012,14 @@ function createSchedulerMiddleware(options = {}) {
20371
20012
  {
20372
20013
  name: "schedule_after",
20373
20014
  description: "Schedule a system message after a relative delay",
20374
- schema: import_zod46.z.object({
20375
- delayMs: import_zod46.z.number().positive(),
20376
- maxRetries: import_zod46.z.number().int().min(0).optional(),
20377
- message: import_zod46.z.string()
20015
+ schema: import_zod45.z.object({
20016
+ delayMs: import_zod45.z.number().positive(),
20017
+ maxRetries: import_zod45.z.number().int().min(0).optional(),
20018
+ message: import_zod45.z.string()
20378
20019
  })
20379
20020
  }
20380
20021
  ),
20381
- (0, import_langchain54.tool)(
20022
+ (0, import_langchain53.tool)(
20382
20023
  async (input, config) => {
20383
20024
  const runConfig = getRunConfig(config);
20384
20025
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
@@ -20413,16 +20054,16 @@ function createSchedulerMiddleware(options = {}) {
20413
20054
  {
20414
20055
  name: "schedule_recurring",
20415
20056
  description: "Schedule a recurring system message with a cron expression",
20416
- schema: import_zod46.z.object({
20417
- cronExpression: import_zod46.z.string(),
20418
- maxRuns: import_zod46.z.number().int().positive().optional(),
20419
- expiresAt: import_zod46.z.number().optional(),
20420
- maxRetries: import_zod46.z.number().int().min(0).optional(),
20421
- message: import_zod46.z.string()
20057
+ schema: import_zod45.z.object({
20058
+ cronExpression: import_zod45.z.string(),
20059
+ maxRuns: import_zod45.z.number().int().positive().optional(),
20060
+ expiresAt: import_zod45.z.number().optional(),
20061
+ maxRetries: import_zod45.z.number().int().min(0).optional(),
20062
+ message: import_zod45.z.string()
20422
20063
  })
20423
20064
  }
20424
20065
  ),
20425
- (0, import_langchain54.tool)(
20066
+ (0, import_langchain53.tool)(
20426
20067
  async (input) => {
20427
20068
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
20428
20069
  const success = await scheduleLattice.client.cancel(input.taskId);
@@ -20431,12 +20072,12 @@ function createSchedulerMiddleware(options = {}) {
20431
20072
  {
20432
20073
  name: "cancel_scheduled_task",
20433
20074
  description: "Cancel a scheduled task by task id",
20434
- schema: import_zod46.z.object({
20435
- taskId: import_zod46.z.string()
20075
+ schema: import_zod45.z.object({
20076
+ taskId: import_zod45.z.string()
20436
20077
  })
20437
20078
  }
20438
20079
  ),
20439
- (0, import_langchain54.tool)(
20080
+ (0, import_langchain53.tool)(
20440
20081
  async (input, config) => {
20441
20082
  const runConfig = getRunConfig(config);
20442
20083
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
@@ -20458,11 +20099,11 @@ function createSchedulerMiddleware(options = {}) {
20458
20099
  {
20459
20100
  name: "list_scheduled_tasks",
20460
20101
  description: "List scheduled tasks for the current agent context",
20461
- schema: import_zod46.z.object({
20462
- status: import_zod46.z.enum(["pending", "running", "completed", "failed", "cancelled", "paused"]).optional(),
20463
- executionType: import_zod46.z.enum(["once", "cron"]).optional(),
20464
- limit: import_zod46.z.number().int().positive().optional(),
20465
- offset: import_zod46.z.number().int().min(0).optional()
20102
+ schema: import_zod45.z.object({
20103
+ status: import_zod45.z.enum(["pending", "running", "completed", "failed", "cancelled", "paused"]).optional(),
20104
+ executionType: import_zod45.z.enum(["once", "cron"]).optional(),
20105
+ limit: import_zod45.z.number().int().positive().optional(),
20106
+ offset: import_zod45.z.number().int().min(0).optional()
20466
20107
  })
20467
20108
  }
20468
20109
  )
@@ -21719,8 +21360,8 @@ var MemoryBackend = class {
21719
21360
 
21720
21361
  // src/deep_agent_new/middleware/todos.ts
21721
21362
  var import_langgraph8 = require("@langchain/langgraph");
21722
- var import_zod47 = require("zod");
21723
- var import_langchain55 = require("langchain");
21363
+ var import_zod46 = require("zod");
21364
+ var import_langchain54 = require("langchain");
21724
21365
  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.
21725
21366
  It also helps the user understand the progress of the task and overall progress of their requests.
21726
21367
  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.
@@ -21947,20 +21588,20 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
21947
21588
  ## Important To-Do List Usage Notes to Remember
21948
21589
  - The \`write_todos\` tool should never be called multiple times in parallel.
21949
21590
  - 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.`;
21950
- var TodoStatus = import_zod47.z.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
21951
- var TodoSchema = import_zod47.z.object({
21952
- content: import_zod47.z.string().describe("Content of the todo item"),
21591
+ var TodoStatus = import_zod46.z.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
21592
+ var TodoSchema = import_zod46.z.object({
21593
+ content: import_zod46.z.string().describe("Content of the todo item"),
21953
21594
  status: TodoStatus
21954
21595
  });
21955
- var stateSchema = import_zod47.z.object({ todos: import_zod47.z.array(TodoSchema).default([]) });
21596
+ var stateSchema = import_zod46.z.object({ todos: import_zod46.z.array(TodoSchema).default([]) });
21956
21597
  function todoListMiddleware(options) {
21957
- const writeTodos = (0, import_langchain55.tool)(
21598
+ const writeTodos = (0, import_langchain54.tool)(
21958
21599
  ({ todos }, config) => {
21959
21600
  return new import_langgraph8.Command({
21960
21601
  update: {
21961
21602
  todos,
21962
21603
  messages: [
21963
- new import_langchain55.ToolMessage({
21604
+ new import_langchain54.ToolMessage({
21964
21605
  content: genUIMarkdown("todo_list", todos),
21965
21606
  tool_call_id: config.toolCall?.id
21966
21607
  })
@@ -21971,12 +21612,12 @@ function todoListMiddleware(options) {
21971
21612
  {
21972
21613
  name: "write_todos",
21973
21614
  description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
21974
- schema: import_zod47.z.object({
21975
- todos: import_zod47.z.array(TodoSchema).describe("List of todo items to update")
21615
+ schema: import_zod46.z.object({
21616
+ todos: import_zod46.z.array(TodoSchema).describe("List of todo items to update")
21976
21617
  })
21977
21618
  }
21978
21619
  );
21979
- return (0, import_langchain55.createMiddleware)({
21620
+ return (0, import_langchain54.createMiddleware)({
21980
21621
  name: "todoListMiddleware",
21981
21622
  stateSchema,
21982
21623
  tools: [writeTodos],
@@ -22022,7 +21663,7 @@ function createDeepAgent(params = {}) {
22022
21663
 
22023
21664
  ${BASE_PROMPT}` : BASE_PROMPT;
22024
21665
  const filesystemBackend = backend ? backend : async (config) => new StateBackend(config);
22025
- const postDelegationMiddleware = interruptOn ? [(0, import_langchain56.humanInTheLoopMiddleware)({ interruptOn })] : [];
21666
+ const postDelegationMiddleware = interruptOn ? [(0, import_langchain55.humanInTheLoopMiddleware)({ interruptOn })] : [];
22026
21667
  const middleware = assembleDeepAgentMiddleware(
22027
21668
  customMiddleware,
22028
21669
  [
@@ -22044,7 +21685,7 @@ ${BASE_PROMPT}` : BASE_PROMPT;
22044
21685
  backend: filesystemBackend
22045
21686
  }),
22046
21687
  // Subagent middleware: Anthropic prompt caching for improved performance
22047
- (0, import_langchain56.anthropicPromptCachingMiddleware)({
21688
+ (0, import_langchain55.anthropicPromptCachingMiddleware)({
22048
21689
  unsupportedModelBehavior: "ignore"
22049
21690
  }),
22050
21691
  ...customMiddleware
@@ -22060,7 +21701,7 @@ ${BASE_PROMPT}` : BASE_PROMPT;
22060
21701
  // })
22061
21702
  postDelegationMiddleware
22062
21703
  );
22063
- return (0, import_langchain56.createAgent)({
21704
+ return (0, import_langchain55.createAgent)({
22064
21705
  model,
22065
21706
  systemPrompt: finalSystemPrompt,
22066
21707
  tools,
@@ -22132,7 +21773,7 @@ init_MemoryLatticeManager();
22132
21773
 
22133
21774
  // src/agent_team/agent_team.ts
22134
21775
  var import_v35 = require("zod/v3");
22135
- var import_langchain59 = require("langchain");
21776
+ var import_langchain58 = require("langchain");
22136
21777
 
22137
21778
  // src/agent_team/types.ts
22138
21779
  var TaskStatus = /* @__PURE__ */ ((TaskStatus3) => {
@@ -22568,13 +22209,13 @@ var InMemoryMailboxStore = class {
22568
22209
 
22569
22210
  // src/agent_team/middleware/team.ts
22570
22211
  var import_v34 = require("zod/v3");
22571
- var import_langchain58 = require("langchain");
22212
+ var import_langchain57 = require("langchain");
22572
22213
  var import_langgraph10 = require("@langchain/langgraph");
22573
22214
  var import_uuid6 = require("uuid");
22574
22215
 
22575
22216
  // src/agent_team/middleware/teammate_tools.ts
22576
22217
  var import_v33 = require("zod/v3");
22577
- var import_langchain57 = require("langchain");
22218
+ var import_langchain56 = require("langchain");
22578
22219
  var import_langgraph9 = require("@langchain/langgraph");
22579
22220
 
22580
22221
  // src/agent_team/middleware/formatMessages.ts
@@ -22599,7 +22240,7 @@ ${meta}${body}`;
22599
22240
  // src/agent_team/middleware/teammate_tools.ts
22600
22241
  function createTeammateTools(options) {
22601
22242
  const { teamId, agentId, taskListStore, mailboxStore } = options;
22602
- const claimTaskTool = (0, import_langchain57.tool)(
22243
+ const claimTaskTool = (0, import_langchain56.tool)(
22603
22244
  async (input) => {
22604
22245
  const task = await taskListStore.claimTaskById(
22605
22246
  teamId,
@@ -22629,7 +22270,7 @@ function createTeammateTools(options) {
22629
22270
  })
22630
22271
  }
22631
22272
  );
22632
- const completeTaskTool = (0, import_langchain57.tool)(
22273
+ const completeTaskTool = (0, import_langchain56.tool)(
22633
22274
  async (input) => {
22634
22275
  const task = await taskListStore.completeTask(
22635
22276
  teamId,
@@ -22656,7 +22297,7 @@ function createTeammateTools(options) {
22656
22297
  })
22657
22298
  }
22658
22299
  );
22659
- const failTaskTool = (0, import_langchain57.tool)(
22300
+ const failTaskTool = (0, import_langchain56.tool)(
22660
22301
  async (input) => {
22661
22302
  const task = await taskListStore.failTask(
22662
22303
  teamId,
@@ -22683,7 +22324,7 @@ function createTeammateTools(options) {
22683
22324
  })
22684
22325
  }
22685
22326
  );
22686
- const sendMessageTool = (0, import_langchain57.tool)(
22327
+ const sendMessageTool = (0, import_langchain56.tool)(
22687
22328
  async (input) => {
22688
22329
  await mailboxStore.sendMessage(
22689
22330
  teamId,
@@ -22721,7 +22362,7 @@ function createTeammateTools(options) {
22721
22362
  read: msg.read
22722
22363
  }));
22723
22364
  };
22724
- const readMessagesTool = (0, import_langchain57.tool)(
22365
+ const readMessagesTool = (0, import_langchain56.tool)(
22725
22366
  async (input, config) => {
22726
22367
  const formatAndMarkAsRead = async (msgs2) => {
22727
22368
  for (const msg of msgs2) {
@@ -22733,7 +22374,7 @@ function createTeammateTools(options) {
22733
22374
  if (msgs.length > 0) {
22734
22375
  const formatted2 = await formatAndMarkAsRead(msgs);
22735
22376
  const relevantMsgs2 = await getRelevantMessagesForState();
22736
- const toolMessage2 = new import_langchain57.ToolMessage({
22377
+ const toolMessage2 = new import_langchain56.ToolMessage({
22737
22378
  content: formatted2,
22738
22379
  tool_call_id: config.toolCall?.id,
22739
22380
  name: "read_messages"
@@ -22758,7 +22399,7 @@ function createTeammateTools(options) {
22758
22399
  });
22759
22400
  const relevantMsgs = await getRelevantMessagesForState();
22760
22401
  if (msgs.length === 0) {
22761
- const toolMessage2 = new import_langchain57.ToolMessage({
22402
+ const toolMessage2 = new import_langchain56.ToolMessage({
22762
22403
  content: "No unread messages.",
22763
22404
  tool_call_id: config.toolCall?.id,
22764
22405
  name: "read_messages"
@@ -22768,7 +22409,7 @@ function createTeammateTools(options) {
22768
22409
  });
22769
22410
  }
22770
22411
  const formatted = await formatAndMarkAsRead(msgs);
22771
- const toolMessage = new import_langchain57.ToolMessage({
22412
+ const toolMessage = new import_langchain56.ToolMessage({
22772
22413
  content: formatted,
22773
22414
  tool_call_id: config.toolCall?.id,
22774
22415
  name: "read_messages"
@@ -22783,7 +22424,7 @@ function createTeammateTools(options) {
22783
22424
  schema: import_v33.z.object({})
22784
22425
  }
22785
22426
  );
22786
- const checkTasksTool = (0, import_langchain57.tool)(
22427
+ const checkTasksTool = (0, import_langchain56.tool)(
22787
22428
  async () => {
22788
22429
  const tasks = await taskListStore.getAllTasks(teamId);
22789
22430
  return formatTaskSummary(tasks);
@@ -22794,7 +22435,7 @@ function createTeammateTools(options) {
22794
22435
  schema: import_v33.z.object({})
22795
22436
  }
22796
22437
  );
22797
- const broadcastMessageTool = (0, import_langchain57.tool)(
22438
+ const broadcastMessageTool = (0, import_langchain56.tool)(
22798
22439
  async (input) => {
22799
22440
  const allAgents = await mailboxStore.getRegisteredAgents(teamId);
22800
22441
  const recipients = allAgents.filter((a) => a !== agentId);
@@ -22980,7 +22621,7 @@ You have access to these tools:
22980
22621
  - \`read_messages\`: Read messages from team_lead or teammates
22981
22622
  - \`check_tasks\`: Get current status of all tasks in the team`;
22982
22623
  const assistantId = getTeammateAssistantId(ctx.teamId, spec.name);
22983
- agent = (0, import_langchain58.createAgent)({
22624
+ agent = (0, import_langchain57.createAgent)({
22984
22625
  model: spec.model ?? ctx.defaultModel,
22985
22626
  systemPrompt: teammatePrompt,
22986
22627
  tools: allTools,
@@ -23049,12 +22690,12 @@ async function spawnTeammate(options) {
23049
22690
  function createTeamMiddleware(options) {
23050
22691
  const { teamConfig, taskListStore, mailboxStore, tenantId: tenantId2 } = options;
23051
22692
  const defaultModel = teamConfig.model ?? "claude-sonnet-4-5-20250929";
23052
- const createTeamTool = (0, import_langchain58.tool)(
22693
+ const createTeamTool = (0, import_langchain57.tool)(
23053
22694
  async (input, config) => {
23054
22695
  const state = (0, import_langgraph10.getCurrentTaskInput)();
23055
22696
  if (state?.team?.teamId) {
23056
22697
  const existingId = state.team.teamId;
23057
- const msg = new import_langchain58.ToolMessage({
22698
+ const msg = new import_langchain57.ToolMessage({
23058
22699
  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.`,
23059
22700
  tool_call_id: config.toolCall?.id,
23060
22701
  name: "create_team"
@@ -23143,7 +22784,7 @@ Teammates are now working in the background. Keep calling \`check_tasks\` and \`
23143
22784
  \`\`\`json
23144
22785
  ${teamJson}
23145
22786
  \`\`\``;
23146
- const toolMessage = new import_langchain58.ToolMessage({
22787
+ const toolMessage = new import_langchain57.ToolMessage({
23147
22788
  content: summary,
23148
22789
  tool_call_id: config.toolCall?.id,
23149
22790
  name: "create_team"
@@ -23228,7 +22869,7 @@ After calling create_team, you MUST:
23228
22869
  if (state?.team?.teamId) return state.team.teamId;
23229
22870
  throw new Error("No team_id provided and no team in state. Call create_team first.");
23230
22871
  };
23231
- const addTasksTool = (0, import_langchain58.tool)(
22872
+ const addTasksTool = (0, import_langchain57.tool)(
23232
22873
  async (input, config) => {
23233
22874
  const teamId = resolveTeamId();
23234
22875
  const created = await taskListStore.addTasks(
@@ -23242,7 +22883,7 @@ After calling create_team, you MUST:
23242
22883
  }))
23243
22884
  );
23244
22885
  const summary = created.map((t) => `- ${t.id}: "${t.title}"`).join("\n");
23245
- return new import_langchain58.ToolMessage({
22886
+ return new import_langchain57.ToolMessage({
23246
22887
  content: `Added ${created.length} task(s) to team ${teamId}:
23247
22888
  ${summary}
23248
22889
  Sleeping teammates will wake up and claim these.`,
@@ -23293,20 +22934,20 @@ IMPORTANT: Assigning to a specific teammate
23293
22934
  })
23294
22935
  }
23295
22936
  );
23296
- const assignTaskTool = (0, import_langchain58.tool)(
22937
+ const assignTaskTool = (0, import_langchain57.tool)(
23297
22938
  async (input, config) => {
23298
22939
  const teamId = resolveTeamId();
23299
22940
  const task = await taskListStore.updateTask(teamId, input.task_id, {
23300
22941
  assignee: input.assignee
23301
22942
  });
23302
22943
  if (!task) {
23303
- return new import_langchain58.ToolMessage({
22944
+ return new import_langchain57.ToolMessage({
23304
22945
  content: `Task ${input.task_id} not found in team ${teamId}.`,
23305
22946
  tool_call_id: config.toolCall?.id,
23306
22947
  name: "assign_task"
23307
22948
  });
23308
22949
  }
23309
- return new import_langchain58.ToolMessage({
22950
+ return new import_langchain57.ToolMessage({
23310
22951
  content: `Task "${task.title}" (${task.id}) assigned to ${input.assignee}.`,
23311
22952
  tool_call_id: config.toolCall?.id,
23312
22953
  name: "assign_task"
@@ -23321,20 +22962,20 @@ IMPORTANT: Assigning to a specific teammate
23321
22962
  })
23322
22963
  }
23323
22964
  );
23324
- const setTaskStatusTool = (0, import_langchain58.tool)(
22965
+ const setTaskStatusTool = (0, import_langchain57.tool)(
23325
22966
  async (input, config) => {
23326
22967
  const teamId = resolveTeamId();
23327
22968
  const task = await taskListStore.updateTask(teamId, input.task_id, {
23328
22969
  status: input.status
23329
22970
  });
23330
22971
  if (!task) {
23331
- return new import_langchain58.ToolMessage({
22972
+ return new import_langchain57.ToolMessage({
23332
22973
  content: `Task ${input.task_id} not found in team ${teamId}.`,
23333
22974
  tool_call_id: config.toolCall?.id,
23334
22975
  name: "set_task_status"
23335
22976
  });
23336
22977
  }
23337
- return new import_langchain58.ToolMessage({
22978
+ return new import_langchain57.ToolMessage({
23338
22979
  content: `Task "${task.title}" (${task.id}) status set to ${input.status}.`,
23339
22980
  tool_call_id: config.toolCall?.id,
23340
22981
  name: "set_task_status"
@@ -23349,20 +22990,20 @@ IMPORTANT: Assigning to a specific teammate
23349
22990
  })
23350
22991
  }
23351
22992
  );
23352
- const setTaskDependenciesTool = (0, import_langchain58.tool)(
22993
+ const setTaskDependenciesTool = (0, import_langchain57.tool)(
23353
22994
  async (input, config) => {
23354
22995
  const teamId = resolveTeamId();
23355
22996
  const task = await taskListStore.updateTask(teamId, input.task_id, {
23356
22997
  dependencies: input.dependencies
23357
22998
  });
23358
22999
  if (!task) {
23359
- return new import_langchain58.ToolMessage({
23000
+ return new import_langchain57.ToolMessage({
23360
23001
  content: `Task ${input.task_id} not found in team ${teamId}.`,
23361
23002
  tool_call_id: config.toolCall?.id,
23362
23003
  name: "set_task_dependencies"
23363
23004
  });
23364
23005
  }
23365
- return new import_langchain58.ToolMessage({
23006
+ return new import_langchain57.ToolMessage({
23366
23007
  content: `Task "${task.title}" (${task.id}) dependencies set to [${input.dependencies.join(", ")}].`,
23367
23008
  tool_call_id: config.toolCall?.id,
23368
23009
  name: "set_task_dependencies"
@@ -23377,7 +23018,7 @@ IMPORTANT: Assigning to a specific teammate
23377
23018
  })
23378
23019
  }
23379
23020
  );
23380
- const checkTasksTool = (0, import_langchain58.tool)(
23021
+ const checkTasksTool = (0, import_langchain57.tool)(
23381
23022
  async (input, config) => {
23382
23023
  const teamId = resolveTeamId();
23383
23024
  const tasks = await taskListStore.getAllTasks(teamId);
@@ -23386,7 +23027,7 @@ IMPORTANT: Assigning to a specific teammate
23386
23027
  update: {
23387
23028
  tasks: tasksSnapshot,
23388
23029
  messages: [
23389
- new import_langchain58.ToolMessage({
23030
+ new import_langchain57.ToolMessage({
23390
23031
  content: formatTaskSummary(tasks),
23391
23032
  tool_call_id: config.toolCall?.id,
23392
23033
  name: "check_tasks"
@@ -23422,7 +23063,7 @@ Task Status Values:
23422
23063
  })
23423
23064
  }
23424
23065
  );
23425
- const sendMessageTool = (0, import_langchain58.tool)(
23066
+ const sendMessageTool = (0, import_langchain57.tool)(
23426
23067
  async (input, config) => {
23427
23068
  const teamId = resolveTeamId();
23428
23069
  await mailboxStore.sendMessage(
@@ -23432,7 +23073,7 @@ Task Status Values:
23432
23073
  input.content,
23433
23074
  "direct_message" /* DIRECT_MESSAGE */
23434
23075
  );
23435
- return new import_langchain58.ToolMessage({
23076
+ return new import_langchain57.ToolMessage({
23436
23077
  content: `Message sent to ${input.to}.`,
23437
23078
  tool_call_id: config.toolCall?.id,
23438
23079
  name: "send_message"
@@ -23447,7 +23088,7 @@ Task Status Values:
23447
23088
  })
23448
23089
  }
23449
23090
  );
23450
- const readMessagesTool = (0, import_langchain58.tool)(
23091
+ const readMessagesTool = (0, import_langchain57.tool)(
23451
23092
  async (input, config) => {
23452
23093
  const teamId = resolveTeamId();
23453
23094
  const formatAndMarkAsRead = async (msgs2) => {
@@ -23475,7 +23116,7 @@ Task Status Values:
23475
23116
  if (msgs.length > 0) {
23476
23117
  const formatted2 = await formatAndMarkAsRead(msgs);
23477
23118
  const allTeamMessages2 = await getAllTeamMessagesForState();
23478
- const toolMessage2 = new import_langchain58.ToolMessage({
23119
+ const toolMessage2 = new import_langchain57.ToolMessage({
23479
23120
  content: formatted2,
23480
23121
  tool_call_id: config.toolCall?.id,
23481
23122
  name: "read_messages"
@@ -23507,7 +23148,7 @@ Task Status Values:
23507
23148
  );
23508
23149
  const allTeamMessages = await getAllTeamMessagesForState();
23509
23150
  if (msgs.length === 0) {
23510
- const toolMessage2 = new import_langchain58.ToolMessage({
23151
+ const toolMessage2 = new import_langchain57.ToolMessage({
23511
23152
  content: "No unread messages from teammates.",
23512
23153
  tool_call_id: config.toolCall?.id,
23513
23154
  name: "read_messages"
@@ -23517,7 +23158,7 @@ Task Status Values:
23517
23158
  });
23518
23159
  }
23519
23160
  const formatted = await formatAndMarkAsRead(msgs);
23520
- const toolMessage = new import_langchain58.ToolMessage({
23161
+ const toolMessage = new import_langchain57.ToolMessage({
23521
23162
  content: formatted,
23522
23163
  tool_call_id: config.toolCall?.id,
23523
23164
  name: "read_messages"
@@ -23534,7 +23175,7 @@ Task Status Values:
23534
23175
  })
23535
23176
  }
23536
23177
  );
23537
- const disbandTeamTool = (0, import_langchain58.tool)(
23178
+ const disbandTeamTool = (0, import_langchain57.tool)(
23538
23179
  async (input, config) => {
23539
23180
  const teamId = resolveTeamId();
23540
23181
  await mailboxStore.broadcastMessage(
@@ -23544,7 +23185,7 @@ Task Status Values:
23544
23185
  "shutdown_request" /* SHUTDOWN_REQUEST */
23545
23186
  );
23546
23187
  await new Promise((r) => setTimeout(r, 2e3));
23547
- return new import_langchain58.ToolMessage({
23188
+ return new import_langchain57.ToolMessage({
23548
23189
  content: `Team ${teamId} has been disbanded. All teammates notified and resources cleaned up.`,
23549
23190
  tool_call_id: config.toolCall?.id,
23550
23191
  name: "disband_team"
@@ -23555,7 +23196,7 @@ Task Status Values:
23555
23196
  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."
23556
23197
  }
23557
23198
  );
23558
- const broadcastMessageTool = (0, import_langchain58.tool)(
23199
+ const broadcastMessageTool = (0, import_langchain57.tool)(
23559
23200
  async (input, config) => {
23560
23201
  const teamId = resolveTeamId();
23561
23202
  await mailboxStore.broadcastMessage(
@@ -23564,7 +23205,7 @@ Task Status Values:
23564
23205
  input.content,
23565
23206
  "broadcast" /* BROADCAST */
23566
23207
  );
23567
- return new import_langchain58.ToolMessage({
23208
+ return new import_langchain57.ToolMessage({
23568
23209
  content: `Broadcast message sent to all teammates.`,
23569
23210
  tool_call_id: config.toolCall?.id,
23570
23211
  name: "broadcast_message"
@@ -23578,7 +23219,7 @@ Task Status Values:
23578
23219
  })
23579
23220
  }
23580
23221
  );
23581
- return (0, import_langchain58.createMiddleware)({
23222
+ return (0, import_langchain57.createMiddleware)({
23582
23223
  name: "teamMiddleware",
23583
23224
  tools: [
23584
23225
  createTeamTool,
@@ -23687,7 +23328,7 @@ function createAgentTeam(config) {
23687
23328
  ];
23688
23329
  const systemPrompt = config.systemPrompt + "\n\n" + TEAM_LEAD_BASE_PROMPT;
23689
23330
  const stateSchema2 = createReactAgentSchema(TEAM_STATE_SCHEMA);
23690
- return (0, import_langchain59.createAgent)({
23331
+ return (0, import_langchain58.createAgent)({
23691
23332
  model: config.model ?? "claude-sonnet-4-5-20250929",
23692
23333
  systemPrompt,
23693
23334
  tools: [],
@@ -23756,7 +23397,7 @@ var TeamAgentGraphBuilder = class {
23756
23397
 
23757
23398
  // src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
23758
23399
  var import_langgraph11 = require("@langchain/langgraph");
23759
- var import_messages6 = require("@langchain/core/messages");
23400
+ var import_messages5 = require("@langchain/core/messages");
23760
23401
 
23761
23402
  // src/services/a2a-client.ts
23762
23403
  var import_uuid7 = require("uuid");
@@ -24074,11 +23715,11 @@ _A2ARemoteClient.MAX_CACHED_TASKS = 100;
24074
23715
  var A2ARemoteClient = _A2ARemoteClient;
24075
23716
 
24076
23717
  // src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
24077
- var import_protocols16 = require("@axiom-lattice/protocols");
23718
+ var import_protocols14 = require("@axiom-lattice/protocols");
24078
23719
  init_MemoryLatticeManager();
24079
23720
  var RemoteAgentGraphBuilder = class {
24080
23721
  async build(agentLattice, params) {
24081
- if (agentLattice.config.type !== import_protocols16.AgentType.A2A_REMOTE) {
23722
+ if (agentLattice.config.type !== import_protocols14.AgentType.A2A_REMOTE) {
24082
23723
  throw new Error(
24083
23724
  `RemoteAgentGraphBuilder received wrong agent type: ${agentLattice.config.type}`
24084
23725
  );
@@ -24096,7 +23737,7 @@ var RemoteAgentGraphBuilder = class {
24096
23737
  if (!text) {
24097
23738
  return {
24098
23739
  messages: [
24099
- new import_messages6.AIMessage("No text input provided to remote agent.")
23740
+ new import_messages5.AIMessage("No text input provided to remote agent.")
24100
23741
  ]
24101
23742
  };
24102
23743
  }
@@ -24108,13 +23749,13 @@ ${text}` : text;
24108
23749
  const threadId = langGraphConfig?.configurable?.thread_id;
24109
23750
  const response = await client.sendMessage(fullPrompt, threadId);
24110
23751
  return {
24111
- messages: [new import_messages6.AIMessage(response)]
23752
+ messages: [new import_messages5.AIMessage(response)]
24112
23753
  };
24113
23754
  } catch (error) {
24114
23755
  const msg = error.message ?? String(error);
24115
23756
  return {
24116
23757
  messages: [
24117
- new import_messages6.AIMessage(`Remote A2A agent error: ${msg}`)
23758
+ new import_messages5.AIMessage(`Remote A2A agent error: ${msg}`)
24118
23759
  ]
24119
23760
  };
24120
23761
  }
@@ -24141,9 +23782,9 @@ function extractLastHumanMessage(messages) {
24141
23782
  }
24142
23783
 
24143
23784
  // src/agent_lattice/builders/WorkflowAgentGraphBuilder.ts
24144
- var import_langchain60 = require("langchain");
23785
+ var import_langchain59 = require("langchain");
24145
23786
  init_MemoryLatticeManager();
24146
- var import_protocols17 = require("@axiom-lattice/protocols");
23787
+ var import_protocols15 = require("@axiom-lattice/protocols");
24147
23788
  init_compile();
24148
23789
 
24149
23790
  // src/agent_lattice/builders/middlewareSanitize.ts
@@ -24181,7 +23822,7 @@ ${configPrompt}` : base;
24181
23822
  }
24182
23823
  var WorkflowAgentGraphBuilder = class {
24183
23824
  async build(agentLattice, params) {
24184
- if (!(0, import_protocols17.isWorkflowAgentConfig)(agentLattice.config)) {
23825
+ if (!(0, import_protocols15.isWorkflowAgentConfig)(agentLattice.config)) {
24185
23826
  throw new Error(
24186
23827
  `WorkflowAgentGraphBuilder received wrong agent type: ${agentLattice.config.type}`
24187
23828
  );
@@ -24206,7 +23847,7 @@ var WorkflowAgentGraphBuilder = class {
24206
23847
  const noWrapMiddlewares = stripWrapModelCallHook(middlewares);
24207
23848
  const noWrapAskMiddlewares = stripWrapModelCallHook(askMiddlewares);
24208
23849
  console.log(`[WF BUILDER] building default agent | toolCount=${tools.length} | middlewareCount=${middlewares.length}`);
24209
- const defaultAgent = (0, import_langchain60.createAgent)({
23850
+ const defaultAgent = (0, import_langchain59.createAgent)({
24210
23851
  model: params.model,
24211
23852
  tools,
24212
23853
  systemPrompt: buildStepSystemPrompt(false, params.prompt),
@@ -24226,7 +23867,7 @@ var WorkflowAgentGraphBuilder = class {
24226
23867
  console.log(`[WF BUILDER] resolveAgent: cacheKey=${key4.slice(0, 80)}... | cached=${agentCache.has(key4)}`);
24227
23868
  if (!agentCache.has(key4)) {
24228
23869
  console.log(`[WF BUILDER] creating ${isAsk ? "ask" : "agent"} with responseFormat`);
24229
- const agent = (0, import_langchain60.createAgent)({
23870
+ const agent = (0, import_langchain59.createAgent)({
24230
23871
  model: params.model,
24231
23872
  tools,
24232
23873
  systemPrompt: buildStepSystemPrompt(isAsk, params.prompt),
@@ -24242,7 +23883,7 @@ var WorkflowAgentGraphBuilder = class {
24242
23883
  const key4 = "ask:default";
24243
23884
  if (!agentCache.has(key4)) {
24244
23885
  console.log(`[WF BUILDER] creating ask default agent`);
24245
- const agent = (0, import_langchain60.createAgent)({
23886
+ const agent = (0, import_langchain59.createAgent)({
24246
23887
  model: params.model,
24247
23888
  tools,
24248
23889
  systemPrompt: buildStepSystemPrompt(true, params.prompt),
@@ -24319,7 +23960,7 @@ var AgentGraphBuilderFactory = class _AgentGraphBuilderFactory {
24319
23960
  };
24320
23961
 
24321
23962
  // src/agent_lattice/builders/AgentParamsBuilder.ts
24322
- var import_protocols18 = require("@axiom-lattice/protocols");
23963
+ var import_protocols16 = require("@axiom-lattice/protocols");
24323
23964
  var AgentParamsBuilder = class {
24324
23965
  /**
24325
23966
  * constructor
@@ -24337,8 +23978,8 @@ var AgentParamsBuilder = class {
24337
23978
  * @returns Agent build parameters
24338
23979
  */
24339
23980
  async buildParams(agentLattice, options) {
24340
- const skills = (0, import_protocols18.isDeepAgentConfig)(agentLattice.config) || (0, import_protocols18.isProcessingAgentConfig)(agentLattice.config) ? agentLattice.config.skillCategories : void 0;
24341
- const toolKeys = options?.overrideTools || (0, import_protocols18.getToolsFromConfig)(agentLattice.config);
23981
+ const skills = (0, import_protocols16.isDeepAgentConfig)(agentLattice.config) || (0, import_protocols16.isProcessingAgentConfig)(agentLattice.config) ? agentLattice.config.skillCategories : void 0;
23982
+ const toolKeys = options?.overrideTools || (0, import_protocols16.getToolsFromConfig)(agentLattice.config);
24342
23983
  const tools = toolKeys.map((toolKey) => {
24343
23984
  const toolLattice = toolLatticeManager.getToolLattice(toolKey);
24344
23985
  if (!toolLattice) {
@@ -24356,7 +23997,7 @@ var AgentParamsBuilder = class {
24356
23997
  if (!model) {
24357
23998
  throw new Error(`Model "${modelKey}" does not exist`);
24358
23999
  }
24359
- const subAgentKeys = (0, import_protocols18.getSubAgentsFromConfig)(agentLattice.config);
24000
+ const subAgentKeys = (0, import_protocols16.getSubAgentsFromConfig)(agentLattice.config);
24360
24001
  const subAgents = await Promise.all(subAgentKeys.map(async (agentKey) => {
24361
24002
  const subAgentLattice = await this.getAgentLatticeFunc(agentKey);
24362
24003
  if (!subAgentLattice) {
@@ -24373,7 +24014,7 @@ var AgentParamsBuilder = class {
24373
24014
  }));
24374
24015
  const resolvedSubAgents = subAgents.filter((s) => s !== null);
24375
24016
  let internalSubAgents = [];
24376
- if ((0, import_protocols18.isDeepAgentConfig)(agentLattice.config) || (0, import_protocols18.isProcessingAgentConfig)(agentLattice.config)) {
24017
+ if ((0, import_protocols16.isDeepAgentConfig)(agentLattice.config) || (0, import_protocols16.isProcessingAgentConfig)(agentLattice.config)) {
24377
24018
  internalSubAgents = agentLattice.config.internalSubAgents?.map((i) => ({
24378
24019
  key: i.key,
24379
24020
  config: i
@@ -27763,7 +27404,7 @@ ${body}` : `${frontmatter}
27763
27404
  };
27764
27405
 
27765
27406
  // src/store_lattice/InMemoryMenuStore.ts
27766
- var import_crypto7 = require("crypto");
27407
+ var import_crypto5 = require("crypto");
27767
27408
  var InMemoryMenuStore = class {
27768
27409
  constructor() {
27769
27410
  this.items = /* @__PURE__ */ new Map();
@@ -27784,7 +27425,7 @@ var InMemoryMenuStore = class {
27784
27425
  async create(input) {
27785
27426
  const now = /* @__PURE__ */ new Date();
27786
27427
  const item = {
27787
- id: (0, import_crypto7.randomUUID)(),
27428
+ id: (0, import_crypto5.randomUUID)(),
27788
27429
  tenantId: input.tenantId,
27789
27430
  menuTarget: input.menuTarget,
27790
27431
  group: input.group,
@@ -27820,9 +27461,9 @@ var InMemoryMenuStore = class {
27820
27461
  };
27821
27462
 
27822
27463
  // src/agent_lattice/agentArchitectTools.ts
27823
- var import_zod48 = __toESM(require("zod"));
27464
+ var import_zod47 = __toESM(require("zod"));
27824
27465
  var import_uuid8 = require("uuid");
27825
- var import_protocols19 = require("@axiom-lattice/protocols");
27466
+ var import_protocols17 = require("@axiom-lattice/protocols");
27826
27467
  function getTenantId2(exeConfig) {
27827
27468
  const runConfig = exeConfig?.configurable?.runConfig || {};
27828
27469
  return runConfig.tenantId || "default";
@@ -27865,7 +27506,7 @@ function getStringMetadata(config) {
27865
27506
  }
27866
27507
  function isUndecidedLearningPlaceholder(config) {
27867
27508
  const metadata = getStringMetadata(config);
27868
- return config.type === import_protocols19.AgentType.REACT && metadata.learningPlaceholder === "true" && metadata.architectureStatus === "undecided";
27509
+ return config.type === import_protocols17.AgentType.REACT && metadata.learningPlaceholder === "true" && metadata.architectureStatus === "undecided";
27869
27510
  }
27870
27511
  function requireArchitectSkill(skillLoaded, exeConfig) {
27871
27512
  if (exeConfig?.configurable?.runConfig?.assistant_id === "agent-architect" && skillLoaded !== true) {
@@ -27929,7 +27570,7 @@ registerToolLattice(
27929
27570
  {
27930
27571
  name: "list_agents",
27931
27572
  description: "List all agents for the current workspace. Returns a summary with id, name, description, and type for each agent.",
27932
- schema: import_zod48.default.object({})
27573
+ schema: import_zod47.default.object({})
27933
27574
  },
27934
27575
  async (_input, exeConfig) => {
27935
27576
  try {
@@ -27956,8 +27597,8 @@ registerToolLattice(
27956
27597
  {
27957
27598
  name: "get_agent",
27958
27599
  description: "Get the full configuration of a specific agent by its ID. Returns the complete AgentConfig including prompt, middleware, tools, and sub-agents.",
27959
- schema: import_zod48.default.object({
27960
- id: import_zod48.default.string().describe("The agent ID to retrieve")
27600
+ schema: import_zod47.default.object({
27601
+ id: import_zod47.default.string().describe("The agent ID to retrieve")
27961
27602
  })
27962
27603
  },
27963
27604
  async (input, exeConfig) => {
@@ -27974,27 +27615,27 @@ registerToolLattice(
27974
27615
  }
27975
27616
  }
27976
27617
  );
27977
- var middlewareConfigSchema = import_zod48.default.object({
27978
- id: import_zod48.default.string(),
27979
- type: import_zod48.default.string(),
27980
- name: import_zod48.default.string(),
27981
- description: import_zod48.default.string(),
27982
- enabled: import_zod48.default.boolean(),
27983
- allowedTools: import_zod48.default.array(import_zod48.default.string()).optional().describe("Optional tool-name allowlist. Omit it or pass [] to enable all tools from this middleware. A non-empty task middleware allowlist must include both manage_task and task."),
27984
- config: import_zod48.default.record(import_zod48.default.any()).optional()
27618
+ var middlewareConfigSchema = import_zod47.default.object({
27619
+ id: import_zod47.default.string(),
27620
+ type: import_zod47.default.string(),
27621
+ name: import_zod47.default.string(),
27622
+ description: import_zod47.default.string(),
27623
+ enabled: import_zod47.default.boolean(),
27624
+ allowedTools: import_zod47.default.array(import_zod47.default.string()).optional().describe("Optional tool-name allowlist. Omit it or pass [] to enable all tools from this middleware. A non-empty task middleware allowlist must include both manage_task and task."),
27625
+ config: import_zod47.default.record(import_zod47.default.any()).optional()
27985
27626
  });
27986
- var createAgentSchema = import_zod48.default.object({
27987
- skillLoaded: import_zod48.default.literal(true).optional().describe("For agent-architect, set true only after loading agent-architecture in the current conversation context."),
27988
- 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')."),
27989
- description: import_zod48.default.string().optional().describe("Short description"),
27990
- 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."),
27991
- prompt: import_zod48.default.string().describe("System prompt for the agent"),
27992
- 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."),
27993
- 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: {}."),
27994
- subAgents: import_zod48.default.array(import_zod48.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
27995
- internalSubAgents: import_zod48.default.array(import_zod48.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
27996
- modelKey: import_zod48.default.string().optional().describe("Model key to use"),
27997
- metadata: import_zod48.default.record(import_zod48.default.string(), import_zod48.default.string()).optional().describe("Arbitrary metadata key-value pairs (e.g. verified: 'human-reviewed', version: '1.0', source: 'PO-Format-SAP.pdf')")
27627
+ var createAgentSchema = import_zod47.default.object({
27628
+ skillLoaded: import_zod47.default.literal(true).optional().describe("For agent-architect, set true only after loading agent-architecture in the current conversation context."),
27629
+ 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')."),
27630
+ description: import_zod47.default.string().optional().describe("Short description"),
27631
+ 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."),
27632
+ prompt: import_zod47.default.string().describe("System prompt for the agent"),
27633
+ 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."),
27634
+ 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: {}."),
27635
+ subAgents: import_zod47.default.array(import_zod47.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
27636
+ internalSubAgents: import_zod47.default.array(import_zod47.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
27637
+ modelKey: import_zod47.default.string().optional().describe("Model key to use"),
27638
+ metadata: import_zod47.default.record(import_zod47.default.string(), import_zod47.default.string()).optional().describe("Arbitrary metadata key-value pairs (e.g. verified: 'human-reviewed', version: '1.0', source: 'PO-Format-SAP.pdf')")
27998
27639
  });
27999
27640
  registerToolLattice(
28000
27641
  "create_agent",
@@ -28018,7 +27659,7 @@ registerToolLattice(
28018
27659
  key: id,
28019
27660
  name: input.name,
28020
27661
  description: input.description || "",
28021
- type: input.type === "deep_agent" ? import_protocols19.AgentType.DEEP_AGENT : import_protocols19.AgentType.REACT,
27662
+ type: input.type === "deep_agent" ? import_protocols17.AgentType.DEEP_AGENT : import_protocols17.AgentType.REACT,
28022
27663
  prompt: input.prompt,
28023
27664
  ...input.tools && input.tools.length > 0 ? { tools: input.tools } : {},
28024
27665
  ...input.middleware && input.middleware.length > 0 ? { middleware: input.middleware } : {},
@@ -28039,14 +27680,14 @@ registerToolLattice(
28039
27680
  }
28040
27681
  }
28041
27682
  );
28042
- var createWorkflowSchema = import_zod48.default.object({
28043
- name: import_zod48.default.string().describe("Display name for the workflow agent"),
28044
- description: import_zod48.default.string().optional().describe("Short description"),
28045
- skillLoaded: import_zod48.default.literal(true).describe("MUST be true. Set after loading the 'create-workflow' skill."),
28046
- yaml: import_zod48.default.string().describe("The YAML workflow definition in linear DSL format (steps execute top-to-bottom, use parallel: for concurrency)"),
28047
- tools: import_zod48.default.array(import_zod48.default.string()).optional().describe("Tool keys for the workflow agent"),
28048
- middleware: import_zod48.default.array(middlewareConfigSchema).optional().describe("Middleware configs"),
28049
- modelKey: import_zod48.default.string().optional().describe("Model key")
27683
+ var createWorkflowSchema = import_zod47.default.object({
27684
+ name: import_zod47.default.string().describe("Display name for the workflow agent"),
27685
+ description: import_zod47.default.string().optional().describe("Short description"),
27686
+ skillLoaded: import_zod47.default.literal(true).describe("MUST be true. Set after loading the 'create-workflow' skill."),
27687
+ yaml: import_zod47.default.string().describe("The YAML workflow definition in linear DSL format (steps execute top-to-bottom, use parallel: for concurrency)"),
27688
+ tools: import_zod47.default.array(import_zod47.default.string()).optional().describe("Tool keys for the workflow agent"),
27689
+ middleware: import_zod47.default.array(middlewareConfigSchema).optional().describe("Middleware configs"),
27690
+ modelKey: import_zod47.default.string().optional().describe("Model key")
28050
27691
  });
28051
27692
  registerToolLattice(
28052
27693
  "create_workflow",
@@ -28073,7 +27714,7 @@ registerToolLattice(
28073
27714
  key: id,
28074
27715
  name: input.name,
28075
27716
  description: input.description || "",
28076
- type: import_protocols19.AgentType.WORKFLOW,
27717
+ type: import_protocols17.AgentType.WORKFLOW,
28077
27718
  prompt: input.description || `Workflow: ${input.name}`,
28078
27719
  workflowYaml: input.yaml,
28079
27720
  ...input.tools && input.tools.length > 0 ? { tools: input.tools } : {},
@@ -28097,8 +27738,8 @@ registerToolLattice(
28097
27738
  {
28098
27739
  name: "validate_workflow",
28099
27740
  description: "Validate a workflow agent's DSL for correctness by compiling it.",
28100
- schema: import_zod48.default.object({
28101
- id: import_zod48.default.string().describe("The workflow agent ID to validate")
27741
+ schema: import_zod47.default.object({
27742
+ id: import_zod47.default.string().describe("The workflow agent ID to validate")
28102
27743
  })
28103
27744
  },
28104
27745
  async (input, exeConfig) => {
@@ -28110,7 +27751,7 @@ registerToolLattice(
28110
27751
  return JSON.stringify({ error: `Agent '${input.id}' not found` });
28111
27752
  }
28112
27753
  const graphDef = agent.graphDefinition;
28113
- if (!graphDef || graphDef.type !== import_protocols19.AgentType.WORKFLOW) {
27754
+ if (!graphDef || graphDef.type !== import_protocols17.AgentType.WORKFLOW) {
28114
27755
  return JSON.stringify({ error: `Agent '${input.id}' is not a workflow agent` });
28115
27756
  }
28116
27757
  const yaml2 = graphDef.workflowYaml;
@@ -28195,15 +27836,15 @@ registerToolLattice(
28195
27836
  }
28196
27837
  }
28197
27838
  );
28198
- var updateWorkflowSchema = import_zod48.default.object({
28199
- id: import_zod48.default.string().describe("The workflow agent ID to update"),
28200
- skillLoaded: import_zod48.default.literal(true).optional().describe("For agent-architect, set true only after loading agent-architecture in the current conversation context."),
28201
- name: import_zod48.default.string().optional().describe("New display name"),
28202
- description: import_zod48.default.string().optional().describe("New description"),
28203
- yaml: import_zod48.default.string().optional().describe("Replacement YAML workflow DSL. Omit to keep existing."),
28204
- tools: import_zod48.default.array(import_zod48.default.string()).optional().describe("Replacement tool keys"),
28205
- middleware: import_zod48.default.array(middlewareConfigSchema).optional().describe("Replacement middleware configs"),
28206
- modelKey: import_zod48.default.string().optional().describe("Replacement model key")
27839
+ var updateWorkflowSchema = import_zod47.default.object({
27840
+ id: import_zod47.default.string().describe("The workflow agent ID to update"),
27841
+ skillLoaded: import_zod47.default.literal(true).optional().describe("For agent-architect, set true only after loading agent-architecture in the current conversation context."),
27842
+ name: import_zod47.default.string().optional().describe("New display name"),
27843
+ description: import_zod47.default.string().optional().describe("New description"),
27844
+ yaml: import_zod47.default.string().optional().describe("Replacement YAML workflow DSL. Omit to keep existing."),
27845
+ tools: import_zod47.default.array(import_zod47.default.string()).optional().describe("Replacement tool keys"),
27846
+ middleware: import_zod47.default.array(middlewareConfigSchema).optional().describe("Replacement middleware configs"),
27847
+ modelKey: import_zod47.default.string().optional().describe("Replacement model key")
28207
27848
  });
28208
27849
  registerToolLattice(
28209
27850
  "update_workflow",
@@ -28225,7 +27866,7 @@ registerToolLattice(
28225
27866
  return JSON.stringify({ error: `Agent '${input.id}' not found` });
28226
27867
  }
28227
27868
  const existingConfig = existing.graphDefinition || {};
28228
- const isWorkflow = existingConfig.type === import_protocols19.AgentType.WORKFLOW;
27869
+ const isWorkflow = existingConfig.type === import_protocols17.AgentType.WORKFLOW;
28229
27870
  const isPlaceholder = isUndecidedLearningPlaceholder(existingConfig);
28230
27871
  if (!isWorkflow && !isPlaceholder) {
28231
27872
  console.log(`[update_workflow] ERROR: not a workflow agent: ${input.id}`);
@@ -28241,7 +27882,7 @@ registerToolLattice(
28241
27882
  const mergedConfig = {
28242
27883
  ...existingConfig,
28243
27884
  ...isPlaceholder ? {
28244
- type: import_protocols19.AgentType.WORKFLOW,
27885
+ type: import_protocols17.AgentType.WORKFLOW,
28245
27886
  workflowYaml: input.yaml,
28246
27887
  metadata: {
28247
27888
  ...getStringMetadata(existingConfig),
@@ -28309,20 +27950,20 @@ registerToolLattice(
28309
27950
  }
28310
27951
  }
28311
27952
  );
28312
- var updateAgentSchema = import_zod48.default.object({
28313
- id: import_zod48.default.string().describe("The agent ID to update"),
28314
- skillLoaded: import_zod48.default.literal(true).optional().describe("For agent-architect, set true only after loading agent-architecture in the current conversation context."),
28315
- config: import_zod48.default.object({
28316
- name: import_zod48.default.string().optional().describe("New display name for the agent"),
28317
- description: import_zod48.default.string().optional().describe("New short description"),
28318
- type: import_zod48.default.enum(["react", "deep_agent"]).optional().describe("Agent type"),
28319
- prompt: import_zod48.default.string().optional().describe("New system prompt for the agent"),
28320
- 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."),
28321
- 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: {}."),
28322
- subAgents: import_zod48.default.array(import_zod48.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
28323
- internalSubAgents: import_zod48.default.array(import_zod48.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
28324
- modelKey: import_zod48.default.string().optional().describe("Model key to use"),
28325
- metadata: import_zod48.default.record(import_zod48.default.string(), import_zod48.default.string()).optional().describe("Arbitrary metadata key-value pairs (e.g. verified: 'machine-confirmed', version: '1.1'). Replaces the whole map when provided.")
27953
+ var updateAgentSchema = import_zod47.default.object({
27954
+ id: import_zod47.default.string().describe("The agent ID to update"),
27955
+ skillLoaded: import_zod47.default.literal(true).optional().describe("For agent-architect, set true only after loading agent-architecture in the current conversation context."),
27956
+ config: import_zod47.default.object({
27957
+ name: import_zod47.default.string().optional().describe("New display name for the agent"),
27958
+ description: import_zod47.default.string().optional().describe("New short description"),
27959
+ type: import_zod47.default.enum(["react", "deep_agent"]).optional().describe("Agent type"),
27960
+ prompt: import_zod47.default.string().optional().describe("New system prompt for the agent"),
27961
+ 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."),
27962
+ 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: {}."),
27963
+ subAgents: import_zod47.default.array(import_zod47.default.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
27964
+ internalSubAgents: import_zod47.default.array(import_zod47.default.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
27965
+ modelKey: import_zod47.default.string().optional().describe("Model key to use"),
27966
+ metadata: import_zod47.default.record(import_zod47.default.string(), import_zod47.default.string()).optional().describe("Arbitrary metadata key-value pairs (e.g. verified: 'machine-confirmed', version: '1.1'). Replaces the whole map when provided.")
28326
27967
  }).describe("Configuration fields to update. Only include the fields you want to change.")
28327
27968
  });
28328
27969
  registerToolLattice(
@@ -28347,14 +27988,14 @@ registerToolLattice(
28347
27988
  const mergedConfig = { ...existingConfig, ...input.config };
28348
27989
  const isPlaceholder = isUndecidedLearningPlaceholder(existingConfigRecord);
28349
27990
  const materializedType = input.config.type;
28350
- const isMaterializingPlaceholder = isPlaceholder && (materializedType === import_protocols19.AgentType.REACT || materializedType === import_protocols19.AgentType.DEEP_AGENT);
27991
+ const isMaterializingPlaceholder = isPlaceholder && (materializedType === import_protocols17.AgentType.REACT || materializedType === import_protocols17.AgentType.DEEP_AGENT);
28351
27992
  if (isMaterializingPlaceholder) {
28352
27993
  mergedConfig.metadata = {
28353
27994
  ...getStringMetadata(existingConfigRecord),
28354
27995
  ...input.config.metadata ?? {},
28355
27996
  learningPlaceholder: "false",
28356
27997
  architectureStatus: "materialized",
28357
- architectureForm: materializedType === import_protocols19.AgentType.DEEP_AGENT ? "orchestra" : "capability"
27998
+ architectureForm: materializedType === import_protocols17.AgentType.DEEP_AGENT ? "orchestra" : "capability"
28358
27999
  };
28359
28000
  } else if (isPlaceholder && input.config.metadata !== void 0) {
28360
28001
  const metadata = {
@@ -28444,8 +28085,8 @@ registerToolLattice(
28444
28085
  {
28445
28086
  name: "delete_agent",
28446
28087
  description: "Permanently delete an agent by its ID. This action cannot be undone.",
28447
- schema: import_zod48.default.object({
28448
- id: import_zod48.default.string().describe("The agent ID to delete")
28088
+ schema: import_zod47.default.object({
28089
+ id: import_zod47.default.string().describe("The agent ID to delete")
28449
28090
  })
28450
28091
  },
28451
28092
  async (input, exeConfig) => {
@@ -28471,7 +28112,7 @@ registerToolLattice(
28471
28112
  {
28472
28113
  name: "list_tools",
28473
28114
  description: "List all available tools that can be assigned to agents. Returns each tool's registry key (use this string value in the 'tools' array), name, description, and whether it requires user approval.",
28474
- schema: import_zod48.default.object({})
28115
+ schema: import_zod47.default.object({})
28475
28116
  },
28476
28117
  async (_input, _exeConfig) => {
28477
28118
  try {
@@ -28494,7 +28135,7 @@ registerToolLattice(
28494
28135
  {
28495
28136
  name: "list_models",
28496
28137
  description: "List all registered models. Returns each model's key (use this string as modelKey when creating eval projects via manage_eval create_project, or as an agent's modelKey in create_agent/update_agent) and its display name.",
28497
- schema: import_zod48.default.object({})
28138
+ schema: import_zod47.default.object({})
28498
28139
  },
28499
28140
  async (_input) => {
28500
28141
  try {
@@ -28515,9 +28156,9 @@ registerToolLattice(
28515
28156
  {
28516
28157
  name: "invoke_agent",
28517
28158
  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).",
28518
- schema: import_zod48.default.object({
28519
- id: import_zod48.default.string().describe("The agent ID to invoke"),
28520
- message: import_zod48.default.string().describe("The test message to send to the agent")
28159
+ schema: import_zod47.default.object({
28160
+ id: import_zod47.default.string().describe("The agent ID to invoke"),
28161
+ message: import_zod47.default.string().describe("The test message to send to the agent")
28521
28162
  })
28522
28163
  },
28523
28164
  async (input, exeConfig) => {
@@ -28553,7 +28194,7 @@ registerToolLattice(
28553
28194
  {
28554
28195
  name: "list_middleware_types",
28555
28196
  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\uFF1B\u65B0\u8FDE\u63A5\u578B\u63D2\u4EF6\u4F7F\u7528 connections \u548C connectAll\uFF0C\u5185\u7F6E\u65E7\u63D2\u4EF6\u7684 selector \u5B57\u6BB5\u7531 core \u7684 legacy compatibility map \u5B9A\u4E49\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",
28556
- schema: import_zod48.default.object({})
28197
+ schema: import_zod47.default.object({})
28557
28198
  },
28558
28199
  async () => {
28559
28200
  const availableMiddlewareTypes = getAvailableMiddlewareTypes();
@@ -28566,8 +28207,8 @@ registerToolLattice(
28566
28207
  {
28567
28208
  name: "list_connections",
28568
28209
  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, ... }] } }",
28569
- schema: import_zod48.default.object({
28570
- 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")
28210
+ schema: import_zod47.default.object({
28211
+ 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")
28571
28212
  }),
28572
28213
  needUserApprove: false
28573
28214
  },
@@ -28598,7 +28239,7 @@ registerToolLattice(
28598
28239
  );
28599
28240
 
28600
28241
  // src/agent_lattice/agentArchitectConfig.ts
28601
- var import_protocols21 = require("@axiom-lattice/protocols");
28242
+ var import_protocols19 = require("@axiom-lattice/protocols");
28602
28243
 
28603
28244
  // src/agent_lattice/agentArchitectPrompt.ts
28604
28245
  var AGENT_ARCHITECT_PROMPT = `You are the Agent Architect.
@@ -28609,7 +28250,7 @@ Never announce the skill load. If it fails, retry once, then stop and explicitly
28609
28250
  report that the required Agent Architect skill could not be loaded.`;
28610
28251
 
28611
28252
  // src/agent_lattice/agentReviewerConfig.ts
28612
- var import_protocols20 = require("@axiom-lattice/protocols");
28253
+ var import_protocols18 = require("@axiom-lattice/protocols");
28613
28254
 
28614
28255
  // src/agent_lattice/agentReviewerPrompt.ts
28615
28256
  var AGENT_REVIEWER_PROMPT = `# Agent Reviewer
@@ -28675,7 +28316,7 @@ var agentReviewerConfig = {
28675
28316
  key: AGENT_REVIEWER_KEY,
28676
28317
  name: "Agent Reviewer",
28677
28318
  description: "Review and test AI agents. Use this agent to check agent configurations for correctness and to test agents by invoking them with realistic messages.",
28678
- type: import_protocols20.AgentType.REACT,
28319
+ type: import_protocols18.AgentType.REACT,
28679
28320
  prompt: AGENT_REVIEWER_PROMPT,
28680
28321
  tools: [
28681
28322
  "invoke_agent",
@@ -28701,7 +28342,7 @@ var agentArchitectConfig = {
28701
28342
  key: AGENT_ARCHITECT_KEY,
28702
28343
  name: "Agent Architect",
28703
28344
  description: "Design and manage AI agents through natural language conversation. Use this agent when you want to create a new agent, modify an existing agent, or manage your agent collection (list, view, update, delete).",
28704
- type: import_protocols21.AgentType.DEEP_AGENT,
28345
+ type: import_protocols19.AgentType.DEEP_AGENT,
28705
28346
  prompt: AGENT_ARCHITECT_PROMPT,
28706
28347
  tools: [
28707
28348
  "list_agents",
@@ -28805,7 +28446,7 @@ var agentArchitectConfig = {
28805
28446
  };
28806
28447
 
28807
28448
  // src/agent_lattice/roomCoordinatorConfig.ts
28808
- var import_protocols22 = require("@axiom-lattice/protocols");
28449
+ var import_protocols20 = require("@axiom-lattice/protocols");
28809
28450
 
28810
28451
  // src/agent_lattice/roomCoordinatorPrompt.ts
28811
28452
  var ROOM_COORDINATOR_PROMPT = `You are the Room Coordinator. CRITICAL FIRST ACTION: Before any response or other action, call the \`skill\` tool with skill_name: "room-coordination" to load room-coordination and follow it. Never announce the skill load. If it fails, retry once, then stop and explicitly report that the required room-coordination skill could not be loaded.`;
@@ -28816,7 +28457,7 @@ var roomCoordinatorConfig = {
28816
28457
  key: ROOM_COORDINATOR_KEY,
28817
28458
  name: "Room Coordinator",
28818
28459
  description: "Manages project room conversations: replies when no bot is mentioned, coordinates room members, and organizes project work.",
28819
- type: import_protocols22.AgentType.DEEP_AGENT,
28460
+ type: import_protocols20.AgentType.DEEP_AGENT,
28820
28461
  prompt: ROOM_COORDINATOR_PROMPT,
28821
28462
  tools: [],
28822
28463
  middleware: [
@@ -28843,6 +28484,14 @@ var roomCoordinatorConfig = {
28843
28484
  description: "Wait for user input at approval gates",
28844
28485
  enabled: true,
28845
28486
  config: {}
28487
+ },
28488
+ {
28489
+ id: "project_room",
28490
+ type: "project_room",
28491
+ name: "Project Room",
28492
+ description: "Post to the room and list active members for delegation",
28493
+ enabled: true,
28494
+ config: {}
28846
28495
  }
28847
28496
  ]
28848
28497
  };
@@ -28885,7 +28534,7 @@ function assistantToConfig(assistant) {
28885
28534
  Object.assign(config, graphDef);
28886
28535
  return config;
28887
28536
  }
28888
- var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager {
28537
+ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager {
28889
28538
  constructor() {
28890
28539
  super();
28891
28540
  this.initialized = false;
@@ -28994,7 +28643,18 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
28994
28643
  getLatticeType() {
28995
28644
  return "agents";
28996
28645
  }
28997
- // ========== 带租户的新API ==========
28646
+ /**
28647
+ * Returns the parent assistant key for a `{parent}-general-purpose` key, or
28648
+ * `null` when the key is not a suffixed GP key (including the bare
28649
+ * `general-purpose` key itself).
28650
+ */
28651
+ generalPurposeParentKey(key4) {
28652
+ const suffix = _AgentLatticeManager.GENERAL_PURPOSE_SUFFIX;
28653
+ if (!key4.endsWith(suffix) || key4.length <= suffix.length) {
28654
+ return null;
28655
+ }
28656
+ return key4.slice(0, -suffix.length);
28657
+ }
28998
28658
  /**
28999
28659
  * 带租户注册Agent Lattice
29000
28660
  * @param tenantId 租户ID
@@ -29010,20 +28670,66 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
29010
28670
  }
29011
28671
  /**
29012
28672
  * 带租户获取AgentLattice
28673
+ *
28674
+ * @remarks
28675
+ * For unregistered `{parent}-general-purpose` keys (ephemeral subagent
28676
+ * assistants created by the subagents middleware), this falls back to the
28677
+ * parent assistant's lattice so that read paths (thread state/messages)
28678
+ * resolve in processes where the runtime GP registration is absent.
28679
+ * {@link hasAgentLatticeWithTenant} stays strict.
28680
+ *
29013
28681
  * @param tenantId 租户ID
29014
28682
  * @param key Lattice键名
29015
28683
  */
29016
28684
  getAgentLatticeWithTenant(tenantId2, key4) {
29017
- return this.getWithTenant(tenantId2, key4);
28685
+ const exact = this.getWithTenant(tenantId2, key4);
28686
+ if (exact) {
28687
+ return exact;
28688
+ }
28689
+ const parentKey = this.generalPurposeParentKey(key4);
28690
+ if (!parentKey) {
28691
+ return void 0;
28692
+ }
28693
+ return this.getWithTenant(tenantId2, parentKey);
29018
28694
  }
29019
28695
  /**
29020
28696
  * 带租户检查Lattice是否存在
28697
+ *
28698
+ * @remarks
28699
+ * Deliberately strict: `{parent}-general-purpose` keys are NOT covered by
28700
+ * the read fallback. The subagents middleware relies on this check to decide
28701
+ * whether to register the real GP runtime agent; a permissive check would
28702
+ * skip that registration and silently run the parent graph for GP tasks.
28703
+ *
29021
28704
  * @param tenantId 租户ID
29022
28705
  * @param key Lattice键名
29023
28706
  */
29024
28707
  hasAgentLatticeWithTenant(tenantId2, key4) {
29025
28708
  return this.hasWithTenant(tenantId2, key4);
29026
28709
  }
28710
+ /**
28711
+ * 异步获取AgentLattice(内存未命中时尝试从store加载)
28712
+ *
28713
+ * @remarks
28714
+ * Mirrors {@link getAgentLatticeWithTenant}'s general-purpose fallback: an
28715
+ * unregistered `{parent}-general-purpose` key resolves to the parent
28716
+ * assistant's lattice. This is the lookup used by `getAgentClientAsync`,
28717
+ * which backs Gateway thread state/message reads for GP subagent threads.
28718
+ *
28719
+ * @param tenantId 租户ID
28720
+ * @param key Lattice键名
28721
+ */
28722
+ async getOrLoadWithTenant(tenantId2, key4) {
28723
+ const exact = await super.getOrLoadWithTenant(tenantId2, key4);
28724
+ if (exact) {
28725
+ return exact;
28726
+ }
28727
+ const parentKey = this.generalPurposeParentKey(key4);
28728
+ if (!parentKey) {
28729
+ return void 0;
28730
+ }
28731
+ return super.getOrLoadWithTenant(tenantId2, parentKey);
28732
+ }
29027
28733
  /**
29028
28734
  * 带租户移除Lattice
29029
28735
  * @param tenantId 租户ID
@@ -29347,6 +29053,18 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
29347
29053
  }
29348
29054
  }
29349
29055
  };
29056
+ // ========== 带租户的新API ==========
29057
+ /**
29058
+ * Suffix that identifies ephemeral general-purpose subagent assistants.
29059
+ *
29060
+ * The subagents middleware (deep_agent_new) registers a runtime agent
29061
+ * `{assistant_id}-general-purpose` in the process that executes the task.
29062
+ * Other processes (e.g. the Gateway serving thread state/messages) never see
29063
+ * that in-memory registration, so lattice lookups for the suffixed key fall
29064
+ * back to the parent assistant's lattice.
29065
+ */
29066
+ _AgentLatticeManager.GENERAL_PURPOSE_SUFFIX = "-general-purpose";
29067
+ var AgentLatticeManager = _AgentLatticeManager;
29350
29068
  var agentLatticeManager = AgentLatticeManager.getInstance();
29351
29069
  var registerAgentLattice = (config) => {
29352
29070
  agentLatticeManager.registerLattice(config);
@@ -29469,7 +29187,7 @@ var getVectorStoreClient = (key4) => vectorStoreLatticeManager.getVectorStoreCli
29469
29187
 
29470
29188
  // src/logger_lattice/LoggerLatticeManager.ts
29471
29189
  init_BaseLatticeManager();
29472
- var import_protocols23 = require("@axiom-lattice/protocols");
29190
+ var import_protocols21 = require("@axiom-lattice/protocols");
29473
29191
 
29474
29192
  // src/logger_lattice/PinoLoggerClient.ts
29475
29193
  var import_pino = __toESM(require("pino"));
@@ -29691,11 +29409,11 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
29691
29409
  if (client) {
29692
29410
  loggerClient = client;
29693
29411
  } else {
29694
- if (config.type === import_protocols23.LoggerType.PINO) {
29412
+ if (config.type === import_protocols21.LoggerType.PINO) {
29695
29413
  loggerClient = new PinoLoggerClient(config);
29696
- } else if (config.type === import_protocols23.LoggerType.CONSOLE) {
29414
+ } else if (config.type === import_protocols21.LoggerType.CONSOLE) {
29697
29415
  loggerClient = new ConsoleLoggerClient(config);
29698
- } else if (config.type === import_protocols23.LoggerType.CUSTOM) {
29416
+ } else if (config.type === import_protocols21.LoggerType.CUSTOM) {
29699
29417
  throw new Error(
29700
29418
  `Custom logger client must be provided. Please pass the client to registerLattice.`
29701
29419
  );
@@ -32653,11 +32371,11 @@ var TokenCache = class {
32653
32371
  };
32654
32372
 
32655
32373
  // src/sandbox_lattice/ShareService.ts
32656
- var import_crypto8 = require("crypto");
32374
+ var import_crypto6 = require("crypto");
32657
32375
  var import_bcryptjs = __toESM(require("bcryptjs"));
32658
32376
  var TOKEN_BYTES = 24;
32659
32377
  function generateToken() {
32660
- return (0, import_crypto8.randomBytes)(TOKEN_BYTES).toString("base64url");
32378
+ return (0, import_crypto6.randomBytes)(TOKEN_BYTES).toString("base64url");
32661
32379
  }
32662
32380
  function createSharePayload(tenantId2, workspaceId, projectId, userId, request) {
32663
32381
  const resourcePath = (request.resourcePath || "").replace(/^\/?project\/?/, "").replace(/\/+$/, "");
@@ -32731,7 +32449,7 @@ function clearEvalRunService() {
32731
32449
  }
32732
32450
 
32733
32451
  // src/eval_lattice/LatticeEval.ts
32734
- var import_messages8 = require("@langchain/core/messages");
32452
+ var import_messages7 = require("@langchain/core/messages");
32735
32453
  var import_uuid9 = require("uuid");
32736
32454
  function parseJudgeVerdict(raw) {
32737
32455
  try {
@@ -33140,7 +32858,7 @@ Note: if final_score >= 80 and there are no fatal errors, pass should be true; o
33140
32858
  const judgeAgent = await getAgentClient(judgeTenantId, judgeAgentKey);
33141
32859
  const testResponse = await judgeAgent.invoke(
33142
32860
  {
33143
- messages: [new import_messages8.HumanMessage(testPrompt)]
32861
+ messages: [new import_messages7.HumanMessage(testPrompt)]
33144
32862
  },
33145
32863
  {
33146
32864
  configurable: {
@@ -33510,8 +33228,8 @@ var LatticeEvalSuite = class {
33510
33228
  };
33511
33229
 
33512
33230
  // src/eval_lattice/LatticeEvalProject.ts
33513
- var import_protocols24 = require("@axiom-lattice/protocols");
33514
- var import_messages9 = require("@langchain/core/messages");
33231
+ var import_protocols22 = require("@axiom-lattice/protocols");
33232
+ var import_messages8 = require("@langchain/core/messages");
33515
33233
  var import_uuid10 = require("uuid");
33516
33234
  var DEFAULT_CALIBRATION_PROBES = [
33517
33235
  {
@@ -33566,7 +33284,7 @@ var LatticeEvalProject = class {
33566
33284
  key: this.judgeAgentKey,
33567
33285
  name: `Judge agent for ${this.project.projectName}`,
33568
33286
  description: "Judge agent for evaluating Lattice test cases",
33569
- type: import_protocols24.AgentType.REACT,
33287
+ type: import_protocols22.AgentType.REACT,
33570
33288
  prompt: "",
33571
33289
  modelKey: judgeModelKey
33572
33290
  };
@@ -33675,7 +33393,7 @@ Respond with JSON only: {"pass": true|false, "final_score": 0-100, "summary": "r
33675
33393
  for (let attempt = 0; attempt < 2; attempt++) {
33676
33394
  try {
33677
33395
  const resp = await judgeAgent.invoke(
33678
- { messages: [new import_messages9.HumanMessage(prompt)] },
33396
+ { messages: [new import_messages8.HumanMessage(prompt)] },
33679
33397
  { configurable: { thread_id: (0, import_uuid10.v4)() } }
33680
33398
  );
33681
33399
  const last = resp?.messages?.[resp.messages.length - 1];
@@ -33792,7 +33510,7 @@ function getMenuRegistry() {
33792
33510
  }
33793
33511
 
33794
33512
  // src/services/ProjectTaskReassignmentAuthorization.ts
33795
- var import_protocols25 = require("@axiom-lattice/protocols");
33513
+ var import_protocols23 = require("@axiom-lattice/protocols");
33796
33514
  var issued = /* @__PURE__ */ new WeakMap();
33797
33515
  function createProjectTaskReassignmentAuthorizer(policy, threadValidator) {
33798
33516
  return {
@@ -33825,7 +33543,7 @@ function inspectProjectTaskReassignmentAuthorization(authorization) {
33825
33543
  return snapshot ? { ...snapshot } : void 0;
33826
33544
  }
33827
33545
  function snapshotInput(input) {
33828
- const row = (0, import_protocols25.snapshotExactRecord)(input, [
33546
+ const row = (0, import_protocols23.snapshotExactRecord)(input, [
33829
33547
  "tenantId",
33830
33548
  "workspaceId",
33831
33549
  "projectId",
@@ -33868,7 +33586,7 @@ function snapshotInput(input) {
33868
33586
  }
33869
33587
 
33870
33588
  // src/services/TaskLifecycleNotifier.ts
33871
- var import_protocols26 = require("@axiom-lattice/protocols");
33589
+ var import_protocols24 = require("@axiom-lattice/protocols");
33872
33590
  var TaskLifecycleNotifier = class {
33873
33591
  constructor() {
33874
33592
  this.listeners = /* @__PURE__ */ new Set();
@@ -33912,7 +33630,7 @@ var TaskLifecycleNotifier = class {
33912
33630
  };
33913
33631
  var taskLifecycleNotifier = new TaskLifecycleNotifier();
33914
33632
  function snapshotNotification(value) {
33915
- const row = (0, import_protocols26.snapshotExactRecord)(value, [
33633
+ const row = (0, import_protocols24.snapshotExactRecord)(value, [
33916
33634
  "tenantId",
33917
33635
  "workspaceId",
33918
33636
  "projectId",
@@ -33944,7 +33662,7 @@ function nonempty(value) {
33944
33662
  }
33945
33663
 
33946
33664
  // src/services/ProjectTaskAdmissionNotifier.ts
33947
- var import_protocols27 = require("@axiom-lattice/protocols");
33665
+ var import_protocols25 = require("@axiom-lattice/protocols");
33948
33666
  var ProjectTaskAdmissionNotifier = class {
33949
33667
  /**
33950
33668
  * Creates a bounded Project task admission notifier.
@@ -34017,7 +33735,7 @@ var ProjectTaskAdmissionNotifier = class {
34017
33735
  };
34018
33736
  var projectTaskAdmissionNotifier = new ProjectTaskAdmissionNotifier();
34019
33737
  function snapshotNotification2(value) {
34020
- const row = (0, import_protocols27.snapshotExactRecord)(value, [
33738
+ const row = (0, import_protocols25.snapshotExactRecord)(value, [
34021
33739
  "tenantId",
34022
33740
  "workspaceId",
34023
33741
  "projectId",
@@ -34047,9 +33765,9 @@ function canonicalTimestamp(value) {
34047
33765
  }
34048
33766
 
34049
33767
  // src/services/ProjectMutationMutex.ts
34050
- var import_protocols28 = require("@axiom-lattice/protocols");
33768
+ var import_protocols26 = require("@axiom-lattice/protocols");
34051
33769
  function projectKey(scope) {
34052
- const row = (0, import_protocols28.snapshotExactRecord)(scope, ["tenantId", "projectId"]);
33770
+ const row = (0, import_protocols26.snapshotExactRecord)(scope, ["tenantId", "projectId"]);
34053
33771
  if (!row || typeof row.tenantId !== "string" || !row.tenantId || row.tenantId.includes("\0") || typeof row.projectId !== "string" || !row.projectId || row.projectId.includes("\0")) {
34054
33772
  throw new Error("Invalid Project mutation scope");
34055
33773
  }
@@ -34122,8 +33840,199 @@ function createTrustedAgentMessageDispatcher(resolve4) {
34122
33840
  };
34123
33841
  }
34124
33842
 
33843
+ // src/services/RoomAgentMessageService.ts
33844
+ var import_crypto7 = require("crypto");
33845
+ var import_protocols27 = require("@axiom-lattice/protocols");
33846
+ var INPUT_KEYS = [
33847
+ "tenantId",
33848
+ "workspaceId",
33849
+ "projectId",
33850
+ "roomId",
33851
+ "membershipId",
33852
+ "assistantId",
33853
+ "text",
33854
+ "sourceRoomMessageId",
33855
+ "sourceId",
33856
+ "idempotencyKey"
33857
+ ];
33858
+ var REPLY_INPUT_KEYS = ["tenantId", "membershipId", "text", "sourceRoomMessageId", "inputMessageId", "sourceId", "idempotencyKey"];
33859
+ var RoomAgentMessageService = class {
33860
+ /**
33861
+ * Creates a room writer over the durable membership and message stores.
33862
+ *
33863
+ * @param deps Store methods, optional deterministic ID factory, and detached post-commit hooks.
33864
+ */
33865
+ constructor(deps) {
33866
+ this.deps = deps;
33867
+ }
33868
+ /**
33869
+ * Persists a fully scoped Agent response after validating its human source and active membership.
33870
+ *
33871
+ * @param input Exact trusted scope and response payload.
33872
+ * @returns A deep clone of the canonical idempotent room message.
33873
+ */
33874
+ post(input) {
33875
+ const snapshot = exactStringRecord(input, INPUT_KEYS, "Invalid project room message input");
33876
+ return this.persist(snapshot);
33877
+ }
33878
+ /**
33879
+ * Persists a channel reply while deriving all scope from validated durable records.
33880
+ *
33881
+ * @param input Exact correlation IDs, tenant, target membership, and response text.
33882
+ * @returns A deep clone of the canonical idempotent room message.
33883
+ */
33884
+ postReply(input) {
33885
+ const snapshot = exactStringRecord(input, REPLY_INPUT_KEYS, "Invalid project room reply input");
33886
+ if (snapshot.sourceId !== `reply:${snapshot.inputMessageId}` || snapshot.idempotencyKey !== `room-reply:${snapshot.sourceRoomMessageId}:${snapshot.membershipId}:${snapshot.sourceId}`) {
33887
+ throw new Error("Invalid project room reply correlation");
33888
+ }
33889
+ return this.persistDerived(snapshot);
33890
+ }
33891
+ async persistDerived(input) {
33892
+ const source = snapshotSource(await this.deps.messages.findById(input.tenantId, input.sourceRoomMessageId));
33893
+ if (!source || source.id !== input.sourceRoomMessageId || source.tenantId !== input.tenantId) throw new Error("Invalid project room message");
33894
+ const member = snapshotMembership(await this.deps.memberships.findById(input.tenantId, input.membershipId));
33895
+ if (!member || member.id !== input.membershipId || member.tenantId !== input.tenantId) throw new Error("Invalid project room membership");
33896
+ return this.persist({
33897
+ ...input,
33898
+ workspaceId: source.workspaceId,
33899
+ projectId: source.projectId,
33900
+ roomId: source.roomId,
33901
+ assistantId: member.assistantId
33902
+ }, source, member);
33903
+ }
33904
+ async persist(input, loadedSource, loadedMember) {
33905
+ const text = input.text.trim();
33906
+ if (text.length < 1 || text.length > 2e4) throw new Error("Invalid project room message text");
33907
+ const source = loadedSource ?? snapshotSource(await this.deps.messages.findById(input.tenantId, input.sourceRoomMessageId));
33908
+ if (!source || source.id !== input.sourceRoomMessageId || source.tenantId !== input.tenantId || source.workspaceId !== input.workspaceId || source.projectId !== input.projectId || source.roomId !== input.roomId) {
33909
+ throw new Error("Invalid project room message");
33910
+ }
33911
+ const member = loadedMember ?? snapshotMembership(await this.deps.memberships.findById(input.tenantId, input.membershipId));
33912
+ if (!member || member.id !== input.membershipId || member.status !== "active" || member.assistantId !== input.assistantId || member.tenantId !== input.tenantId || member.workspaceId !== input.workspaceId || member.projectId !== input.projectId || member.roomId !== input.roomId) {
33913
+ throw new Error("Invalid project room membership");
33914
+ }
33915
+ const candidate = {
33916
+ id: (this.deps.idFactory ?? import_crypto7.randomUUID)(),
33917
+ tenantId: input.tenantId,
33918
+ workspaceId: input.workspaceId,
33919
+ projectId: input.projectId,
33920
+ roomId: input.roomId,
33921
+ author: { type: "bot", membershipId: input.membershipId, assistantId: input.assistantId },
33922
+ content: { type: "text", text },
33923
+ mentions: [],
33924
+ replyToMessageId: input.sourceRoomMessageId,
33925
+ source: "agent",
33926
+ sourceId: input.sourceId,
33927
+ idempotencyKey: input.idempotencyKey
33928
+ };
33929
+ const canonical = snapshotCanonical(await this.deps.messages.createIdempotent(candidate), candidate);
33930
+ if (!canonical) throw new Error("Invalid canonical project room message");
33931
+ const result = structuredClone(canonical);
33932
+ this.notifyCommitted(result);
33933
+ return result;
33934
+ }
33935
+ notifyCommitted(message) {
33936
+ const callback = this.deps.onMessageCommitted;
33937
+ if (!callback) return;
33938
+ Promise.resolve().then(() => callback(structuredClone(message))).catch(() => {
33939
+ try {
33940
+ this.deps.onCallbackFailure?.({ messageId: message.id, code: "ROOM_MESSAGE_COMMIT_CALLBACK_FAILED" });
33941
+ } catch {
33942
+ }
33943
+ });
33944
+ }
33945
+ };
33946
+ function exactValues(value, required, optional = []) {
33947
+ try {
33948
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
33949
+ return (0, import_protocols27.snapshotExactRecord)(value, required, optional);
33950
+ } catch {
33951
+ return void 0;
33952
+ }
33953
+ }
33954
+ function exactStringRecord(value, keys, message) {
33955
+ const values = exactValues(value, keys);
33956
+ if (!values || keys.some((key4) => typeof values[key4] !== "string" || values[key4].length === 0)) throw new Error(message);
33957
+ return values;
33958
+ }
33959
+ function date(value) {
33960
+ try {
33961
+ const timestamp = Date.prototype.getTime.call(value);
33962
+ return Number.isFinite(timestamp) ? new Date(timestamp) : void 0;
33963
+ } catch {
33964
+ return void 0;
33965
+ }
33966
+ }
33967
+ function snapshotSource(value) {
33968
+ const values = exactValues(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "author", "content", "mentions", "source", "createdAt"], ["replyToMessageId", "sourceId", "idempotencyKey"]);
33969
+ const author = exactValues(values?.author, ["type", "userId"]);
33970
+ const content = exactValues(values?.content, ["type", "text"]);
33971
+ const createdAt = date(values?.createdAt);
33972
+ const mentions = snapshotMentions(values?.mentions);
33973
+ if (!values || values.source !== "user" || author?.type !== "human" || typeof author.userId !== "string" || !author.userId || content?.type !== "text" || typeof content.text !== "string" || !mentions || !createdAt || ["id", "tenantId", "workspaceId", "projectId", "roomId"].some((key4) => typeof values[key4] !== "string" || !values[key4])) return void 0;
33974
+ return {
33975
+ id: values.id,
33976
+ tenantId: values.tenantId,
33977
+ workspaceId: values.workspaceId,
33978
+ projectId: values.projectId,
33979
+ roomId: values.roomId,
33980
+ author: { type: "human", userId: author.userId },
33981
+ content: { type: "text", text: content.text },
33982
+ mentions,
33983
+ source: "user",
33984
+ createdAt
33985
+ };
33986
+ }
33987
+ function snapshotMentions(value) {
33988
+ const rows = (0, import_protocols27.snapshotExactArray)(value);
33989
+ if (!rows) return void 0;
33990
+ const mentions = [];
33991
+ for (const row of rows) {
33992
+ const team = exactValues(row, ["type"]);
33993
+ if (team?.type === "team") {
33994
+ mentions.push({ type: "team" });
33995
+ continue;
33996
+ }
33997
+ const bot = exactValues(row, ["type", "membershipId"]);
33998
+ if (bot?.type !== "bot" || typeof bot.membershipId !== "string" || !bot.membershipId) return void 0;
33999
+ mentions.push({ type: "bot", membershipId: bot.membershipId });
34000
+ }
34001
+ return mentions;
34002
+ }
34003
+ function snapshotMembership(value) {
34004
+ const required = ["id", "tenantId", "workspaceId", "projectId", "roomId", "assistantId", "role", "title", "mentionName", "status", "roomThreadId", "joinedAt", "updatedAt"];
34005
+ const values = exactValues(value, required, ["responsibility"]);
34006
+ const joinedAt = date(values?.joinedAt);
34007
+ const updatedAt = date(values?.updatedAt);
34008
+ if (!values || required.slice(0, 7).some((key4) => typeof values[key4] !== "string" || !values[key4]) || values.role !== "coordinator" && values.role !== "specialist" || typeof values.title !== "string" || !values.title || typeof values.mentionName !== "string" || !values.mentionName || !["active", "paused", "removed"].includes(values.status) || typeof values.roomThreadId !== "string" || !values.roomThreadId || values.responsibility !== void 0 && typeof values.responsibility !== "string" || !joinedAt || !updatedAt) return void 0;
34009
+ return { ...values, joinedAt, updatedAt };
34010
+ }
34011
+ function snapshotCanonical(value, expected) {
34012
+ const values = exactValues(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "author", "content", "mentions", "replyToMessageId", "source", "sourceId", "idempotencyKey", "createdAt"]);
34013
+ const author = exactValues(values?.author, ["type", "membershipId", "assistantId"]);
34014
+ const content = exactValues(values?.content, ["type", "text"]);
34015
+ const createdAt = date(values?.createdAt);
34016
+ if (!values || !createdAt || typeof values.id !== "string" || values.id.length === 0 || (0, import_protocols27.snapshotExactArray)(values.mentions)?.length !== 0 || author?.type !== "bot" || expected.author.type !== "bot" || author.membershipId !== expected.author.membershipId || author.assistantId !== expected.author.assistantId || content?.type !== "text" || content.text !== expected.content.text || values.tenantId !== expected.tenantId || values.workspaceId !== expected.workspaceId || values.projectId !== expected.projectId || values.roomId !== expected.roomId || values.replyToMessageId !== expected.replyToMessageId || values.source !== "agent" || values.sourceId !== expected.sourceId || values.idempotencyKey !== expected.idempotencyKey) return void 0;
34017
+ return {
34018
+ id: values.id,
34019
+ tenantId: expected.tenantId,
34020
+ workspaceId: expected.workspaceId,
34021
+ projectId: expected.projectId,
34022
+ roomId: expected.roomId,
34023
+ author: { type: "bot", membershipId: expected.author.membershipId, assistantId: expected.author.assistantId },
34024
+ content: { type: "text", text: expected.content.text },
34025
+ mentions: [],
34026
+ replyToMessageId: expected.replyToMessageId,
34027
+ source: "agent",
34028
+ sourceId: expected.sourceId,
34029
+ idempotencyKey: expected.idempotencyKey,
34030
+ createdAt
34031
+ };
34032
+ }
34033
+
34125
34034
  // src/services/ProjectTaskOwnerPolicy.ts
34126
- var import_protocols29 = require("@axiom-lattice/protocols");
34035
+ var import_protocols28 = require("@axiom-lattice/protocols");
34127
34036
  var MEMBERSHIP_REQUIRED_KEYS = [
34128
34037
  "id",
34129
34038
  "tenantId",
@@ -34178,7 +34087,7 @@ var ProjectTaskOwnerPolicy = class {
34178
34087
  if (!scope) throw new ProjectTaskOwnerPolicyError("PROJECT_TASK_CALLER_INACTIVE", CALLER_MESSAGE);
34179
34088
  let caller;
34180
34089
  try {
34181
- caller = snapshotMembership3(await this.memberships.findById(scope.tenantId, scope.callerMembershipId));
34090
+ caller = snapshotMembership2(await this.memberships.findById(scope.tenantId, scope.callerMembershipId));
34182
34091
  } catch {
34183
34092
  throw new ProjectTaskOwnerPolicyError("PROJECT_TASK_CALLER_INACTIVE", CALLER_MESSAGE);
34184
34093
  }
@@ -34198,7 +34107,7 @@ var ProjectTaskOwnerPolicy = class {
34198
34107
  if (!scope) throw new ProjectTaskOwnerPolicyError("PROJECT_TASK_OWNER_INACTIVE", OWNER_MESSAGE);
34199
34108
  let target;
34200
34109
  try {
34201
- target = snapshotMembership3(await this.memberships.findByAssistant(
34110
+ target = snapshotMembership2(await this.memberships.findByAssistant(
34202
34111
  scope.tenantId,
34203
34112
  scope.projectId,
34204
34113
  scope.targetAssistantId
@@ -34232,7 +34141,7 @@ function sameRosterScope(membership, scope) {
34232
34141
  return membership.tenantId === scope.tenantId && membership.workspaceId === scope.workspaceId && membership.projectId === scope.projectId && membership.roomId === scope.roomId;
34233
34142
  }
34234
34143
  function snapshotScope(value, keys) {
34235
- const values = (0, import_protocols29.snapshotExactRecord)(value, keys);
34144
+ const values = (0, import_protocols28.snapshotExactRecord)(value, keys);
34236
34145
  if (!values || keys.some((key4) => !isNonemptyString(values[key4]))) return void 0;
34237
34146
  return values;
34238
34147
  }
@@ -34241,10 +34150,10 @@ function projectScope(scope, keys) {
34241
34150
  for (const key4 of keys) projected[key4] = scope[key4];
34242
34151
  return projected;
34243
34152
  }
34244
- function snapshotMembership3(value) {
34153
+ function snapshotMembership2(value) {
34245
34154
  try {
34246
34155
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
34247
- const values = (0, import_protocols29.snapshotExactRecord)(value, MEMBERSHIP_REQUIRED_KEYS, ["responsibility"]);
34156
+ const values = (0, import_protocols28.snapshotExactRecord)(value, MEMBERSHIP_REQUIRED_KEYS, ["responsibility"]);
34248
34157
  if (!values) return void 0;
34249
34158
  const joinedAt = snapshotDate(values.joinedAt);
34250
34159
  const updatedAt = snapshotDate(values.updatedAt);
@@ -34283,11 +34192,11 @@ function snapshotDate(value) {
34283
34192
 
34284
34193
  // src/services/TaskLifecycleService.ts
34285
34194
  var import_node_crypto7 = require("crypto");
34286
- var import_protocols31 = require("@axiom-lattice/protocols");
34195
+ var import_protocols30 = require("@axiom-lattice/protocols");
34287
34196
 
34288
34197
  // src/middlewares/taskBelief.ts
34289
34198
  var import_node_crypto6 = require("crypto");
34290
- var import_protocols30 = require("@axiom-lattice/protocols");
34199
+ var import_protocols29 = require("@axiom-lattice/protocols");
34291
34200
  function resolveBeliefOwnerScope(parent) {
34292
34201
  if (parent != null && parent.ownerType === "agent") {
34293
34202
  return { owner: "parent", parentAgentOwned: true };
@@ -34319,7 +34228,7 @@ function validateBeliefImpactForTask(input) {
34319
34228
  if (description.trim().length === 0) {
34320
34229
  return { ok: false, code: "MISSING_BELIEF_TABLE" };
34321
34230
  }
34322
- const parsed = (0, import_protocols30.parseTaskBeliefState)(description);
34231
+ const parsed = (0, import_protocols29.parseTaskBeliefState)(description);
34323
34232
  if (!parsed.success) {
34324
34233
  if (parsed.code === "MISSING_BELIEF_STATE") {
34325
34234
  return { ok: false, code: "MISSING_BELIEF_TABLE" };
@@ -34382,7 +34291,7 @@ function failure2(code, error, hint) {
34382
34291
  }
34383
34292
  async function seedBeliefOwnerTable(taskStore, owner, impacts) {
34384
34293
  if (impacts.length === 0) return { description: owner.description ?? "" };
34385
- const parsed = (0, import_protocols31.parseTaskBeliefState)(owner.description ?? "");
34294
+ const parsed = (0, import_protocols30.parseTaskBeliefState)(owner.description ?? "");
34386
34295
  if (!parsed.success && parsed.code !== "MISSING_BELIEF_STATE") {
34387
34296
  return failure2("INVALID_BELIEF_TABLE", parsed.message);
34388
34297
  }
@@ -34394,7 +34303,7 @@ async function seedBeliefOwnerTable(taskStore, owner, impacts) {
34394
34303
  entries.push({ key: impact.key, probability: impact.after, target: impact.after, basis: impact.basis });
34395
34304
  }
34396
34305
  const base = owner.description ?? "";
34397
- const description = (0, import_protocols31.replaceTaskBeliefState)(base, { entries });
34306
+ const description = (0, import_protocols30.replaceTaskBeliefState)(base, { entries });
34398
34307
  const updated = await taskStore.update(owner.tenantId, owner.id, { description });
34399
34308
  if (!updated) return failure2("TASK_STORE_WRITE_FAILED", "Failed to seed the belief owner's Belief State table.");
34400
34309
  return { description: updated.description ?? description };
@@ -34450,8 +34359,8 @@ function isProjectLifecycleTask(task) {
34450
34359
  return typeof task.workspaceId === "string" && task.workspaceId.length > 0 && typeof task.projectId === "string" && task.projectId.length > 0 && task.workspaceId !== "default" && task.projectId !== "default" && (source === "project_room" || source === "project_task");
34451
34360
  }
34452
34361
  function parseExternalDependency(value) {
34453
- const row = (0, import_protocols31.snapshotExactRecord)(value, ["type", "summary", "requestedAt", "dependencyTaskIds"]);
34454
- const ids = (0, import_protocols31.snapshotExactArray)(row?.dependencyTaskIds);
34362
+ const row = (0, import_protocols30.snapshotExactRecord)(value, ["type", "summary", "requestedAt", "dependencyTaskIds"]);
34363
+ const ids = (0, import_protocols30.snapshotExactArray)(row?.dependencyTaskIds);
34455
34364
  if (!row || row.type !== "external_dependency" || typeof row.summary !== "string" || !row.summary.trim() || typeof row.requestedAt !== "string" || !Number.isFinite(Date.parse(row.requestedAt)) || !ids || ids.length === 0 || ids.some((id) => typeof id !== "string" || !id.trim())) return void 0;
34456
34365
  const trimmed = ids.map((id) => id.trim());
34457
34366
  if (new Set(trimmed).size !== trimmed.length) return void 0;
@@ -34538,7 +34447,7 @@ function beliefStateOf(value) {
34538
34447
  function sameBeliefOwner(left, right) {
34539
34448
  const leftIdentity = { ...left, beliefState: void 0 };
34540
34449
  const rightIdentity = { ...right, beliefState: void 0 };
34541
- return canonicalJson(leftIdentity) === canonicalJson(rightIdentity) && (0, import_protocols31.taskBeliefStatesEqual)(left.beliefState, right.beliefState);
34450
+ return canonicalJson(leftIdentity) === canonicalJson(rightIdentity) && (0, import_protocols30.taskBeliefStatesEqual)(left.beliefState, right.beliefState);
34542
34451
  }
34543
34452
  function canonicalBeliefOwner(owner) {
34544
34453
  const beliefState = {
@@ -34683,7 +34592,7 @@ function changedBeliefKeys(left, right) {
34683
34592
  return [...keys].filter((key4) => {
34684
34593
  const oldEntry = leftByKey.get(key4);
34685
34594
  const newEntry = rightByKey.get(key4);
34686
- return !oldEntry || !newEntry || !(0, import_protocols31.taskBeliefStatesEqual)(
34595
+ return !oldEntry || !newEntry || !(0, import_protocols30.taskBeliefStatesEqual)(
34687
34596
  { entries: [oldEntry] },
34688
34597
  { entries: [newEntry] }
34689
34598
  );
@@ -35624,10 +35533,10 @@ var TaskLifecycleService = class {
35624
35533
  const description = preserveTargetContract(existing.description ?? "", input.description);
35625
35534
  const pending = existing.context?.belief_reconciliation_audit;
35626
35535
  const pendingAudit = pending && typeof pending === "object" ? pending : void 0;
35627
- const oldBelief = (0, import_protocols31.parseTaskBeliefState)(existing.description ?? "");
35628
- const newBelief = (0, import_protocols31.parseTaskBeliefState)(description);
35536
+ const oldBelief = (0, import_protocols30.parseTaskBeliefState)(existing.description ?? "");
35537
+ const newBelief = (0, import_protocols30.parseTaskBeliefState)(description);
35629
35538
  if (!newBelief.success) return failure2("INVALID_BELIEF_TABLE", newBelief.message);
35630
- if (!pendingAudit && description === (existing.description ?? "") && oldBelief.success && (0, import_protocols31.taskBeliefStatesEqual)(oldBelief.state, newBelief.state)) {
35539
+ if (!pendingAudit && description === (existing.description ?? "") && oldBelief.success && (0, import_protocols30.taskBeliefStatesEqual)(oldBelief.state, newBelief.state)) {
35631
35540
  return { success: true, task: existing, mutated: false };
35632
35541
  }
35633
35542
  const canonicalNew = newBelief.state.entries;
@@ -35759,7 +35668,7 @@ var TaskLifecycleService = class {
35759
35668
  }
35760
35669
  beliefOwnerSnapshot(task, parent) {
35761
35670
  const owner = parent?.ownerType === "agent" ? parent : task;
35762
- const parsed = (0, import_protocols31.parseTaskBeliefState)(owner.description ?? "");
35671
+ const parsed = (0, import_protocols30.parseTaskBeliefState)(owner.description ?? "");
35763
35672
  if (!parsed.success) throw new Error("Validated belief owner has no canonical Belief State");
35764
35673
  if (parent?.ownerType === "agent") {
35765
35674
  return {
@@ -36513,7 +36422,7 @@ function createTaskLifecycleService(deps) {
36513
36422
  // src/services/TaskExecutionService.ts
36514
36423
  var import_node_crypto8 = require("crypto");
36515
36424
  var import_node_util3 = require("util");
36516
- var import_protocols32 = require("@axiom-lattice/protocols");
36425
+ var import_protocols31 = require("@axiom-lattice/protocols");
36517
36426
 
36518
36427
  // src/util/toJsonSafeValue.ts
36519
36428
  var CIRCULAR_VALUE = "[Circular]";
@@ -36960,7 +36869,7 @@ function createTaskExecutionService(deps) {
36960
36869
  };
36961
36870
  }
36962
36871
  const eventKey = `execution-result:${threadId}`;
36963
- if (!(0, import_protocols32.isExecutionResultEventKey)(eventKey)) {
36872
+ if (!(0, import_protocols31.isExecutionResultEventKey)(eventKey)) {
36964
36873
  return {
36965
36874
  success: false,
36966
36875
  code: "INVALID_EXECUTION_RESULT_ID",
@@ -37179,7 +37088,7 @@ function createTaskExecutionService(deps) {
37179
37088
  var Protocols = __toESM(require("@axiom-lattice/protocols"));
37180
37089
 
37181
37090
  // src/util/encryption.ts
37182
- var import_crypto9 = require("crypto");
37091
+ var import_crypto8 = require("crypto");
37183
37092
  var ALGORITHM = "aes-256-gcm";
37184
37093
  var IV_LENGTH = 16;
37185
37094
  var SALT_LENGTH = 32;
@@ -37192,7 +37101,7 @@ function getEncryptionKey() {
37192
37101
  return cachedKey;
37193
37102
  }
37194
37103
  const key4 = process.env.LATTICE_ENCRYPTION_KEY || DEFAULT_ENCRYPTION_KEY;
37195
- cachedKey = (0, import_crypto9.pbkdf2Sync)(key4, "lattice-encryption-salt", ITERATIONS, 32, "sha256");
37104
+ cachedKey = (0, import_crypto8.pbkdf2Sync)(key4, "lattice-encryption-salt", ITERATIONS, 32, "sha256");
37196
37105
  if (!keyValidated) {
37197
37106
  keyValidated = true;
37198
37107
  validateEncryptionKey();
@@ -37201,10 +37110,10 @@ function getEncryptionKey() {
37201
37110
  }
37202
37111
  function encrypt(plaintext, key4) {
37203
37112
  const actualKey = key4 || getEncryptionKey();
37204
- const salt = (0, import_crypto9.randomBytes)(SALT_LENGTH);
37205
- const iv = (0, import_crypto9.randomBytes)(IV_LENGTH);
37206
- const derivedKey = (0, import_crypto9.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
37207
- const cipher = (0, import_crypto9.createCipheriv)(ALGORITHM, derivedKey, iv);
37113
+ const salt = (0, import_crypto8.randomBytes)(SALT_LENGTH);
37114
+ const iv = (0, import_crypto8.randomBytes)(IV_LENGTH);
37115
+ const derivedKey = (0, import_crypto8.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
37116
+ const cipher = (0, import_crypto8.createCipheriv)(ALGORITHM, derivedKey, iv);
37208
37117
  const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
37209
37118
  const authTag = cipher.getAuthTag();
37210
37119
  return Buffer.concat([salt, iv, encrypted, authTag]).toString("base64");
@@ -37216,8 +37125,8 @@ function decrypt(encrypted, key4) {
37216
37125
  const iv = data.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);
37217
37126
  const authTag = data.subarray(-16);
37218
37127
  const ciphertext = data.subarray(SALT_LENGTH + IV_LENGTH, -16);
37219
- const derivedKey = (0, import_crypto9.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
37220
- const decipher = (0, import_crypto9.createDecipheriv)(ALGORITHM, derivedKey, iv);
37128
+ const derivedKey = (0, import_crypto8.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
37129
+ const decipher = (0, import_crypto8.createDecipheriv)(ALGORITHM, derivedKey, iv);
37221
37130
  decipher.setAuthTag(authTag);
37222
37131
  return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
37223
37132
  }
@@ -37243,11 +37152,11 @@ function clearEncryptionKeyCache() {
37243
37152
  }
37244
37153
 
37245
37154
  // src/middlewares/skillMiddleware.ts
37246
- var import_langchain65 = require("langchain");
37155
+ var import_langchain64 = require("langchain");
37247
37156
 
37248
37157
  // src/tool_lattice/skill/load_skills.ts
37249
- var import_zod49 = __toESM(require("zod"));
37250
- var import_langchain61 = require("langchain");
37158
+ var import_zod48 = __toESM(require("zod"));
37159
+ var import_langchain60 = require("langchain");
37251
37160
  var LOAD_SKILLS_DESCRIPTION = `Load all available skills and return their metadata (name, description, license, compatibility, metadata, and subSkills) without the content. This tool returns skill information including hierarchical relationships (subSkills). Use this to discover what skills are available and their structure.`;
37252
37161
  function getSandboxFromExeConfig(_exe_config) {
37253
37162
  const runConfig = _exe_config?.configurable?.runConfig || {};
@@ -37262,7 +37171,7 @@ function getSandboxFromExeConfig(_exe_config) {
37262
37171
  });
37263
37172
  }
37264
37173
  var createLoadSkillsTool = ({ skills, readAll, pluginSkills, pluginSkillOwners } = {}) => {
37265
- return (0, import_langchain61.tool)(
37174
+ return (0, import_langchain60.tool)(
37266
37175
  async (_input, _exe_config) => {
37267
37176
  const allSkills = [];
37268
37177
  try {
@@ -37328,7 +37237,7 @@ var createLoadSkillsTool = ({ skills, readAll, pluginSkills, pluginSkillOwners }
37328
37237
  {
37329
37238
  name: "load_skills",
37330
37239
  description: LOAD_SKILLS_DESCRIPTION,
37331
- schema: import_zod49.default.object({})
37240
+ schema: import_zod48.default.object({})
37332
37241
  }
37333
37242
  );
37334
37243
  };
@@ -37338,8 +37247,8 @@ function isSkillAllowed(skillName, staticSkills, staticReadAll) {
37338
37247
  }
37339
37248
 
37340
37249
  // src/tool_lattice/skill/load_skill_content.ts
37341
- var import_zod50 = __toESM(require("zod"));
37342
- var import_langchain62 = require("langchain");
37250
+ var import_zod49 = __toESM(require("zod"));
37251
+ var import_langchain61 = require("langchain");
37343
37252
  var LOAD_SKILL_CONTENT_DESCRIPTION = `
37344
37253
  Execute a skill within the main conversation
37345
37254
 
@@ -37379,7 +37288,7 @@ function getSandboxFromExeConfig2(_exe_config) {
37379
37288
  var createLoadSkillContentTool = (pluginSkills, pluginSkillOwnersOrStaticSelection, staticSelection) => {
37380
37289
  const pluginSkillOwners = staticSelection === void 0 ? isStaticSkillSelection(pluginSkillOwnersOrStaticSelection) ? void 0 : pluginSkillOwnersOrStaticSelection : pluginSkillOwnersOrStaticSelection;
37381
37290
  const effectiveStaticSelection = isStaticSkillSelection(pluginSkillOwnersOrStaticSelection) ? pluginSkillOwnersOrStaticSelection : staticSelection ?? {};
37382
- return (0, import_langchain62.tool)(
37291
+ return (0, import_langchain61.tool)(
37383
37292
  async (input, _exe_config) => {
37384
37293
  try {
37385
37294
  if (!isSkillAllowed2(input.skill_name, effectiveStaticSelection)) {
@@ -37460,8 +37369,8 @@ var createLoadSkillContentTool = (pluginSkills, pluginSkillOwnersOrStaticSelecti
37460
37369
  {
37461
37370
  name: "skill",
37462
37371
  description: LOAD_SKILL_CONTENT_DESCRIPTION,
37463
- schema: import_zod50.default.object({
37464
- skill_name: import_zod50.default.string().describe("The name of the skill to load")
37372
+ schema: import_zod49.default.object({
37373
+ skill_name: import_zod49.default.string().describe("The name of the skill to load")
37465
37374
  })
37466
37375
  }
37467
37376
  );
@@ -37480,8 +37389,8 @@ function isSkillAllowed2(skillName, staticSelection) {
37480
37389
  }
37481
37390
 
37482
37391
  // src/tool_lattice/skill/load_skill_resource.ts
37483
- var import_zod51 = __toESM(require("zod"));
37484
- var import_langchain63 = require("langchain");
37392
+ var import_zod50 = __toESM(require("zod"));
37393
+ var import_langchain62 = require("langchain");
37485
37394
  var LOAD_SKILL_RESOURCE_DESCRIPTION = `Load a specific resource file from a skill's resources directory. Use this tool when you need to access template files, example data, or other resources bundled with a skill. The resource paths are listed in the skill content when using the load_skill_content tool.`;
37486
37395
  function getSandboxFromExeConfig3(_exe_config) {
37487
37396
  const runConfig = _exe_config?.configurable?.runConfig || {};
@@ -37496,7 +37405,7 @@ function getSandboxFromExeConfig3(_exe_config) {
37496
37405
  });
37497
37406
  }
37498
37407
  var createLoadSkillResourceTool = (pluginSkills, pluginSkillOwners) => {
37499
- return (0, import_langchain63.tool)(
37408
+ return (0, import_langchain62.tool)(
37500
37409
  async (input, _exe_config) => {
37501
37410
  try {
37502
37411
  validateRelativePath(input.skill_name, "skill");
@@ -37523,17 +37432,17 @@ var createLoadSkillResourceTool = (pluginSkills, pluginSkillOwners) => {
37523
37432
  {
37524
37433
  name: "load_skill_resource",
37525
37434
  description: LOAD_SKILL_RESOURCE_DESCRIPTION,
37526
- schema: import_zod51.default.object({
37527
- skill_name: import_zod51.default.string().describe("The name of the skill containing the resource"),
37528
- resource_path: import_zod51.default.string().describe("The path to the resource relative to the skill's resources/ directory")
37435
+ schema: import_zod50.default.object({
37436
+ skill_name: import_zod50.default.string().describe("The name of the skill containing the resource"),
37437
+ resource_path: import_zod50.default.string().describe("The path to the resource relative to the skill's resources/ directory")
37529
37438
  })
37530
37439
  }
37531
37440
  );
37532
37441
  };
37533
37442
 
37534
37443
  // src/tool_lattice/skill/delete_skill.ts
37535
- var import_zod52 = __toESM(require("zod"));
37536
- var import_langchain64 = require("langchain");
37444
+ var import_zod51 = __toESM(require("zod"));
37445
+ var import_langchain63 = require("langchain");
37537
37446
  var DELETE_SKILL_DESCRIPTION = `
37538
37447
  Delete a skill by name from the skill system.
37539
37448
  This permanently removes the skill and its SKILL.md file.
@@ -37560,7 +37469,7 @@ function validateSkillName3(name) {
37560
37469
  }
37561
37470
  }
37562
37471
  var createDeleteSkillTool = (staticSelection = {}) => {
37563
- return (0, import_langchain64.tool)(
37472
+ return (0, import_langchain63.tool)(
37564
37473
  async (input, _exe_config) => {
37565
37474
  try {
37566
37475
  validateSkillName3(input.skill_name);
@@ -37592,8 +37501,8 @@ var createDeleteSkillTool = (staticSelection = {}) => {
37592
37501
  {
37593
37502
  name: "delete_skill",
37594
37503
  description: DELETE_SKILL_DESCRIPTION,
37595
- schema: import_zod52.default.object({
37596
- skill_name: import_zod52.default.string().describe("The name of the skill to delete")
37504
+ schema: import_zod51.default.object({
37505
+ skill_name: import_zod51.default.string().describe("The name of the skill to delete")
37597
37506
  })
37598
37507
  }
37599
37508
  );
@@ -37617,7 +37526,7 @@ function createSkillMiddleware(params = {}) {
37617
37526
  } = params;
37618
37527
  const skills = params.skills;
37619
37528
  let latestSkills = [];
37620
- return (0, import_langchain65.createMiddleware)({
37529
+ return (0, import_langchain64.createMiddleware)({
37621
37530
  name: "skillMiddleware",
37622
37531
  contextSchema,
37623
37532
  tools: [
@@ -37767,11 +37676,11 @@ var skillPlugin = {
37767
37676
  };
37768
37677
 
37769
37678
  // src/middlewares/semanticMetricsMiddleware.ts
37770
- var import_langchain69 = require("langchain");
37679
+ var import_langchain68 = require("langchain");
37771
37680
 
37772
37681
  // src/tool_lattice/semantic_metrics/metrics_datasource_tool.ts
37773
- var import_zod53 = __toESM(require("zod"));
37774
- var import_langchain66 = require("langchain");
37682
+ var import_zod52 = __toESM(require("zod"));
37683
+ var import_langchain65 = require("langchain");
37775
37684
 
37776
37685
  // src/tool_lattice/semantic_metrics/types.ts
37777
37686
  function readToolRunConfig(exeConfig) {
@@ -38249,7 +38158,7 @@ COMMON MISTAKES (do not):
38249
38158
  - Do not attempt writes \u2014 SQL is validated read-only and rejected before sending.`;
38250
38159
  function createMetricsDatasourceTool(params) {
38251
38160
  const { resolvedConnections, selectedDataSources } = params;
38252
- return (0, import_langchain66.tool)(
38161
+ return (0, import_langchain65.tool)(
38253
38162
  async (input, exeConfig) => {
38254
38163
  try {
38255
38164
  const client = await resolveClientFromConnections(input.connectionKey, resolvedConnections, readToolRunConfig(exeConfig));
@@ -38304,23 +38213,23 @@ function createMetricsDatasourceTool(params) {
38304
38213
  {
38305
38214
  name: "metrics_datasource_tool",
38306
38215
  description: DESCRIPTION,
38307
- schema: import_zod53.default.object({
38308
- action: import_zod53.default.enum(["list_datasources", "get_grants", "query_sql", "test_connection", "pool_status"]).describe(
38216
+ schema: import_zod52.default.object({
38217
+ action: import_zod52.default.enum(["list_datasources", "get_grants", "query_sql", "test_connection", "pool_status"]).describe(
38309
38218
  "list_datasources: list datasources \u2014 ALWAYS call this first to obtain the datasource id used by every other action and tool; get_grants: read table-grants; query_sql: run read-only SQL against PHYSICAL tables (note: this is query_sql, NOT the semantic 'query' action of metrics_runtime_tool); test_connection: test the datasource; pool_status: connection-pool status"
38310
38219
  ),
38311
- connectionKey: import_zod53.default.string().optional().describe("Connection key. Omit when only one semantic-metrics connection exists"),
38312
- datasourceId: import_zod53.default.coerce.number().optional().describe("Numeric datasource id, e.g. 15 (required for all actions except list_datasources; optional if set in runConfig.metricsDataSource)"),
38313
- sql: import_zod53.default.string().optional().describe("Read-only SQL (SELECT/WITH only). Required for the query action. Metadata templates \u2014 PostgreSQL/SQL Server columns: select column_name, data_type from information_schema.columns where table_schema = :schemaName and table_name = :tableName order by ordinal_position; HANA columns: select column_name, data_type_name from table_columns where schema_name = :schemaName and table_name = :tableName order by position; distributions: select <dim>, count(*) as row_count from <table> group by <dim> order by row_count desc limit :maxRows"),
38314
- params: import_zod53.default.record(import_zod53.default.union([import_zod53.default.string(), import_zod53.default.number(), import_zod53.default.boolean()])).optional().describe("Named :param values for the SQL"),
38315
- maxRows: import_zod53.default.number().optional().describe("Max rows to return")
38220
+ connectionKey: import_zod52.default.string().optional().describe("Connection key. Omit when only one semantic-metrics connection exists"),
38221
+ datasourceId: import_zod52.default.coerce.number().optional().describe("Numeric datasource id, e.g. 15 (required for all actions except list_datasources; optional if set in runConfig.metricsDataSource)"),
38222
+ sql: import_zod52.default.string().optional().describe("Read-only SQL (SELECT/WITH only). Required for the query action. Metadata templates \u2014 PostgreSQL/SQL Server columns: select column_name, data_type from information_schema.columns where table_schema = :schemaName and table_name = :tableName order by ordinal_position; HANA columns: select column_name, data_type_name from table_columns where schema_name = :schemaName and table_name = :tableName order by position; distributions: select <dim>, count(*) as row_count from <table> group by <dim> order by row_count desc limit :maxRows"),
38223
+ params: import_zod52.default.record(import_zod52.default.union([import_zod52.default.string(), import_zod52.default.number(), import_zod52.default.boolean()])).optional().describe("Named :param values for the SQL"),
38224
+ maxRows: import_zod52.default.number().optional().describe("Max rows to return")
38316
38225
  })
38317
38226
  }
38318
38227
  );
38319
38228
  }
38320
38229
 
38321
38230
  // src/tool_lattice/semantic_metrics/metrics_meta_tool.ts
38322
- var import_zod54 = __toESM(require("zod"));
38323
- var import_langchain67 = require("langchain");
38231
+ var import_zod53 = __toESM(require("zod"));
38232
+ var import_langchain66 = require("langchain");
38324
38233
  var DESCRIPTION2 = `SEMANTIC ASSET REGISTRY (Builder/Admin only) \u2014 the only tool for reading and publishing the runtime's semantic layer: table meta (meta/tables) and metric meta (meta/metrics).
38325
38234
 
38326
38235
  OWNS: listing published tables and metrics, reading one by objectKey, publishing a semantic table (create_table: columns tagged with role dimension|measure), publishing a metric (create_metric: a metric_index payload then a metric_detail payload using the SQL-free calculation DSL), and correcting published assets (update_table / update_metric).
@@ -38356,7 +38265,7 @@ function actionRequiresPayload(action) {
38356
38265
  }
38357
38266
  function createMetricsMetaTool(params) {
38358
38267
  const { resolvedConnections, selectedDataSources } = params;
38359
- return (0, import_langchain67.tool)(
38268
+ return (0, import_langchain66.tool)(
38360
38269
  async (input, exeConfig) => {
38361
38270
  try {
38362
38271
  const guardError = requireModelingSkillLoaded(input.action, input, exeConfig);
@@ -38405,8 +38314,8 @@ function createMetricsMetaTool(params) {
38405
38314
  {
38406
38315
  name: "metrics_meta_tool",
38407
38316
  description: DESCRIPTION2,
38408
- schema: import_zod54.default.object({
38409
- action: import_zod54.default.enum([
38317
+ schema: import_zod53.default.object({
38318
+ action: import_zod53.default.enum([
38410
38319
  "list_tables",
38411
38320
  "read_table_meta",
38412
38321
  "create_table",
@@ -38418,19 +38327,19 @@ function createMetricsMetaTool(params) {
38418
38327
  ]).describe(
38419
38328
  "Actions ONLY in this meta tool (runtime query actions like get_meta/query belong to metrics_runtime_tool): list_tables/list_metrics (browse published assets), read_table_meta/read_metric_meta (details by objectKey), create_table/create_metric (publish), update_table/update_metric (correct)"
38420
38329
  ),
38421
- connectionKey: import_zod54.default.string().optional().describe("Connection key. Omit when only one semantic-metrics connection exists"),
38422
- datasourceId: import_zod54.default.coerce.number().optional().describe("Numeric datasource id, e.g. 15 (optional if set in runConfig.metricsDataSource)"),
38423
- objectKey: import_zod54.default.string().optional().describe("Semantic table/metric key (required for read_table_meta/update_table/read_metric_meta/update_metric)"),
38424
- payload: import_zod54.default.record(import_zod54.default.unknown()).optional().describe("Meta payload (required for create/update actions; objectType/objectKey/status/payload/accessGrant)"),
38425
- modelingSkillLoaded: import_zod54.default.literal(true).optional().describe("Set true after loading the semantic-metrics-modeling skill (required for the builder assistant on write actions)")
38330
+ connectionKey: import_zod53.default.string().optional().describe("Connection key. Omit when only one semantic-metrics connection exists"),
38331
+ datasourceId: import_zod53.default.coerce.number().optional().describe("Numeric datasource id, e.g. 15 (optional if set in runConfig.metricsDataSource)"),
38332
+ objectKey: import_zod53.default.string().optional().describe("Semantic table/metric key (required for read_table_meta/update_table/read_metric_meta/update_metric)"),
38333
+ payload: import_zod53.default.record(import_zod53.default.unknown()).optional().describe("Meta payload (required for create/update actions; objectType/objectKey/status/payload/accessGrant)"),
38334
+ modelingSkillLoaded: import_zod53.default.literal(true).optional().describe("Set true after loading the semantic-metrics-modeling skill (required for the builder assistant on write actions)")
38426
38335
  })
38427
38336
  }
38428
38337
  );
38429
38338
  }
38430
38339
 
38431
38340
  // src/tool_lattice/semantic_metrics/metrics_runtime_tool.ts
38432
- var import_zod55 = __toESM(require("zod"));
38433
- var import_langchain68 = require("langchain");
38341
+ var import_zod54 = __toESM(require("zod"));
38342
+ var import_langchain67 = require("langchain");
38434
38343
  var DESCRIPTION3 = `RUNTIME QUERY SURFACE \u2014 read what is published and answer business questions with numbers. Business agents use ONLY this tool; Builder agents also use it to verify freshly published metrics.
38435
38344
 
38436
38345
  OWNS: read_semantic_catalog (the published semantic model for a datasource: tables, metrics, dimensions, filters) and query_metrics (the semantic metric query: metrics / groupBy / filters / orderBy / limit \u2014 the server generates the SQL, so there is no free-form SQL here).
@@ -38448,7 +38357,7 @@ COMMON MISTAKES (do not):
38448
38357
  - Metrics and dimensions in query_metrics must already be published; querying an unpublished metric fails with "not found in catalog".`;
38449
38358
  function createMetricsRuntimeTool(params) {
38450
38359
  const { resolvedConnections, selectedDataSources } = params;
38451
- return (0, import_langchain68.tool)(
38360
+ return (0, import_langchain67.tool)(
38452
38361
  async (input, exeConfig) => {
38453
38362
  try {
38454
38363
  const client = await resolveClientFromConnections(input.connectionKey, resolvedConnections, readToolRunConfig(exeConfig));
@@ -38475,13 +38384,13 @@ function createMetricsRuntimeTool(params) {
38475
38384
  {
38476
38385
  name: "metrics_runtime_tool",
38477
38386
  description: DESCRIPTION3,
38478
- schema: import_zod55.default.object({
38479
- action: import_zod55.default.enum(["read_semantic_catalog", "query_metrics"]).describe(
38387
+ schema: import_zod54.default.object({
38388
+ action: import_zod54.default.enum(["read_semantic_catalog", "query_metrics"]).describe(
38480
38389
  "Actions ONLY in this runtime tool: read_semantic_catalog (read the published semantic model: tables, metrics, dimensions \u2014 obtain the datasourceId from metrics_datasource_tool list_datasources first), query_metrics (run a semantic metric query \u2014 the only way to get business numbers). Do NOT put meta-tool actions (list_tables/read_table_meta/create_table/update_table/list_metrics/read_metric_meta/create_metric/update_metric) here"
38481
38390
  ),
38482
- connectionKey: import_zod55.default.string().optional().describe("Connection key. Omit when only one semantic-metrics connection exists"),
38483
- datasourceId: import_zod55.default.coerce.number().optional().describe("Numeric datasource id, e.g. 15 (optional if set in runConfig.metricsDataSource)"),
38484
- query: import_zod55.default.record(import_zod55.default.unknown()).optional().describe('Semantic metric query request. Required for the query_metrics action, e.g. { datasourceId: 15, metrics: ["sell_in_nes"], groupBy: ["sales_team"], filters: [{ dimension: "posting_year", operator: "GTE", values: [2024] }], limit: 10 }')
38391
+ connectionKey: import_zod54.default.string().optional().describe("Connection key. Omit when only one semantic-metrics connection exists"),
38392
+ datasourceId: import_zod54.default.coerce.number().optional().describe("Numeric datasource id, e.g. 15 (optional if set in runConfig.metricsDataSource)"),
38393
+ query: import_zod54.default.record(import_zod54.default.unknown()).optional().describe('Semantic metric query request. Required for the query_metrics action, e.g. { datasourceId: 15, metrics: ["sell_in_nes"], groupBy: ["sales_team"], filters: [{ dimension: "posting_year", operator: "GTE", values: [2024] }], limit: 10 }')
38485
38394
  })
38486
38395
  }
38487
38396
  );
@@ -38900,11 +38809,11 @@ Never announce the skill load. If it fails, retry once, then stop and explicitly
38900
38809
  report that the required Semantic Metrics Builder skill could not be loaded.`;
38901
38810
 
38902
38811
  // src/middlewares/semanticMetricsMiddleware.ts
38903
- var import_protocols33 = require("@axiom-lattice/protocols");
38812
+ var import_protocols32 = require("@axiom-lattice/protocols");
38904
38813
  function createSemanticMetricsMiddleware(config) {
38905
38814
  const resolvedConnections = config._resolvedConnections ?? [];
38906
38815
  const selectedDataSources = void 0;
38907
- return (0, import_langchain69.createMiddleware)({
38816
+ return (0, import_langchain68.createMiddleware)({
38908
38817
  name: "SemanticMetrics",
38909
38818
  contextSchema,
38910
38819
  tools: [
@@ -39054,7 +38963,7 @@ var semanticMetricsPlugin = {
39054
38963
  key: "semantic-metrics-builder",
39055
38964
  name: "Semantic Metrics Builder",
39056
38965
  description: "Explore a granted datasource and build semantic tables and metrics interactively, tracking the work as persistent tasks with belief state and verifying each step.",
39057
- type: import_protocols33.AgentType.DEEP_AGENT,
38966
+ type: import_protocols32.AgentType.DEEP_AGENT,
39058
38967
  prompt: SEMANTIC_METRICS_BUILDER_PROMPT,
39059
38968
  middleware: [
39060
38969
  {
@@ -39104,11 +39013,11 @@ var semanticMetricsPlugin = {
39104
39013
  };
39105
39014
 
39106
39015
  // src/middlewares/collectionMiddleware.ts
39107
- var import_langchain80 = require("langchain");
39016
+ var import_langchain79 = require("langchain");
39108
39017
 
39109
39018
  // src/tool_lattice/collection/list_collections.ts
39110
- var import_zod56 = __toESM(require("zod"));
39111
- var import_langchain70 = require("langchain");
39019
+ var import_zod55 = __toESM(require("zod"));
39020
+ var import_langchain69 = require("langchain");
39112
39021
 
39113
39022
  // src/tool_lattice/collection/utils.ts
39114
39023
  function getEffectiveCollectionScope(exeConfig, staticScope) {
@@ -39131,7 +39040,7 @@ var createListCollectionsTool = ({
39131
39040
  collectionKeys,
39132
39041
  connectAll
39133
39042
  }) => {
39134
- return (0, import_langchain70.tool)(
39043
+ return (0, import_langchain69.tool)(
39135
39044
  async (_input, _exeConfig) => {
39136
39045
  try {
39137
39046
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -39166,23 +39075,23 @@ var createListCollectionsTool = ({
39166
39075
  {
39167
39076
  name: "list_collections",
39168
39077
  description: LIST_COLLECTIONS_DESCRIPTION,
39169
- schema: import_zod56.default.object({})
39078
+ schema: import_zod55.default.object({})
39170
39079
  }
39171
39080
  );
39172
39081
  };
39173
39082
 
39174
39083
  // src/tool_lattice/collection/search_collection.ts
39175
- var import_zod57 = __toESM(require("zod"));
39176
- var import_langchain71 = require("langchain");
39084
+ var import_zod56 = __toESM(require("zod"));
39085
+ var import_langchain70 = require("langchain");
39177
39086
  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.`;
39178
- var searchSchema = import_zod57.default.object({
39179
- collection: import_zod57.default.string().describe("The collection name to search in"),
39180
- query: import_zod57.default.string().describe("The search query text"),
39181
- filter: import_zod57.default.record(import_zod57.default.unknown()).optional().describe("Metadata filter conditions"),
39182
- top_k: import_zod57.default.number().optional().default(5).describe("Number of results to return")
39087
+ var searchSchema = import_zod56.default.object({
39088
+ collection: import_zod56.default.string().describe("The collection name to search in"),
39089
+ query: import_zod56.default.string().describe("The search query text"),
39090
+ filter: import_zod56.default.record(import_zod56.default.unknown()).optional().describe("Metadata filter conditions"),
39091
+ top_k: import_zod56.default.number().optional().default(5).describe("Number of results to return")
39183
39092
  });
39184
39093
  var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => {
39185
- return (0, import_langchain71.tool)(
39094
+ return (0, import_langchain70.tool)(
39186
39095
  async (input, _exeConfig) => {
39187
39096
  try {
39188
39097
  const { collection, query, filter: filter2, top_k } = input;
@@ -39248,10 +39157,10 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
39248
39157
  };
39249
39158
 
39250
39159
  // src/tool_lattice/collection/get_collection.ts
39251
- var import_zod58 = __toESM(require("zod"));
39252
- var import_langchain72 = require("langchain");
39160
+ var import_zod57 = __toESM(require("zod"));
39161
+ var import_langchain71 = require("langchain");
39253
39162
  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.`;
39254
- var createGetCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain72.tool)(
39163
+ var createGetCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain71.tool)(
39255
39164
  async (input, _exeConfig) => {
39256
39165
  try {
39257
39166
  const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
@@ -39276,24 +39185,24 @@ Embedding: ${c.embeddingKey}${fieldsDesc}`;
39276
39185
  return `Error: ${error.message}`;
39277
39186
  }
39278
39187
  },
39279
- { name: "get_collection", description: GET_COLLECTION_DESCRIPTION, schema: import_zod58.default.object({ name: import_zod58.default.string().describe("Collection name") }) }
39188
+ { name: "get_collection", description: GET_COLLECTION_DESCRIPTION, schema: import_zod57.default.object({ name: import_zod57.default.string().describe("Collection name") }) }
39280
39189
  );
39281
39190
 
39282
39191
  // src/tool_lattice/collection/create_collection.ts
39283
- var import_zod59 = __toESM(require("zod"));
39284
- var import_langchain73 = require("langchain");
39285
- var createSchema = import_zod59.default.object({
39286
- name: import_zod59.default.string().describe("Collection name (lowercase, underscores only)"),
39287
- label: import_zod59.default.string().describe("Display name"),
39288
- embeddingKey: import_zod59.default.string().describe("Embedding model key"),
39289
- fields: import_zod59.default.array(import_zod59.default.object({
39290
- key: import_zod59.default.string().describe("Field key name"),
39291
- type: import_zod59.default.enum(["string", "number", "enum"]).describe("Field data type"),
39292
- enumValues: import_zod59.default.array(import_zod59.default.string()).optional().describe("Valid values for enum type"),
39293
- required: import_zod59.default.boolean().optional().default(false).describe("Whether field is required")
39192
+ var import_zod58 = __toESM(require("zod"));
39193
+ var import_langchain72 = require("langchain");
39194
+ var createSchema = import_zod58.default.object({
39195
+ name: import_zod58.default.string().describe("Collection name (lowercase, underscores only)"),
39196
+ label: import_zod58.default.string().describe("Display name"),
39197
+ embeddingKey: import_zod58.default.string().describe("Embedding model key"),
39198
+ fields: import_zod58.default.array(import_zod58.default.object({
39199
+ key: import_zod58.default.string().describe("Field key name"),
39200
+ type: import_zod58.default.enum(["string", "number", "enum"]).describe("Field data type"),
39201
+ enumValues: import_zod58.default.array(import_zod58.default.string()).optional().describe("Valid values for enum type"),
39202
+ required: import_zod58.default.boolean().optional().default(false).describe("Whether field is required")
39294
39203
  })).optional().describe("Custom field definitions for entries in this collection")
39295
39204
  });
39296
- var createCreateCollectionTool = (scope = {}) => (0, import_langchain73.tool)(
39205
+ var createCreateCollectionTool = (scope = {}) => (0, import_langchain72.tool)(
39297
39206
  async (input, _exeConfig) => {
39298
39207
  try {
39299
39208
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -39319,20 +39228,20 @@ var createCreateCollectionTool = (scope = {}) => (0, import_langchain73.tool)(
39319
39228
  );
39320
39229
 
39321
39230
  // src/tool_lattice/collection/update_collection.ts
39322
- var import_zod60 = __toESM(require("zod"));
39323
- var import_langchain74 = require("langchain");
39324
- var schema = import_zod60.default.object({
39325
- name: import_zod60.default.string().describe("Collection name"),
39326
- label: import_zod60.default.string().optional().describe("New display name"),
39327
- embeddingKey: import_zod60.default.string().optional().describe("New embedding model key"),
39328
- fields: import_zod60.default.array(import_zod60.default.object({
39329
- key: import_zod60.default.string().describe("Field key name"),
39330
- type: import_zod60.default.enum(["string", "number", "enum"]).describe("Field data type"),
39331
- enumValues: import_zod60.default.array(import_zod60.default.string()).optional().describe("Valid values for enum type"),
39332
- required: import_zod60.default.boolean().optional().default(false).describe("Whether field is required")
39231
+ var import_zod59 = __toESM(require("zod"));
39232
+ var import_langchain73 = require("langchain");
39233
+ var schema = import_zod59.default.object({
39234
+ name: import_zod59.default.string().describe("Collection name"),
39235
+ label: import_zod59.default.string().optional().describe("New display name"),
39236
+ embeddingKey: import_zod59.default.string().optional().describe("New embedding model key"),
39237
+ fields: import_zod59.default.array(import_zod59.default.object({
39238
+ key: import_zod59.default.string().describe("Field key name"),
39239
+ type: import_zod59.default.enum(["string", "number", "enum"]).describe("Field data type"),
39240
+ enumValues: import_zod59.default.array(import_zod59.default.string()).optional().describe("Valid values for enum type"),
39241
+ required: import_zod59.default.boolean().optional().default(false).describe("Whether field is required")
39333
39242
  })).optional().describe("Custom field definitions for entries (replaces existing schema)")
39334
39243
  });
39335
- var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain74.tool)(
39244
+ var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain73.tool)(
39336
39245
  async (input, _exeConfig) => {
39337
39246
  try {
39338
39247
  const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
@@ -39353,9 +39262,9 @@ var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true
39353
39262
  );
39354
39263
 
39355
39264
  // src/tool_lattice/collection/delete_collection.ts
39356
- var import_zod61 = __toESM(require("zod"));
39357
- var import_langchain75 = require("langchain");
39358
- var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain75.tool)(
39265
+ var import_zod60 = __toESM(require("zod"));
39266
+ var import_langchain74 = require("langchain");
39267
+ var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain74.tool)(
39359
39268
  async (input, _exeConfig) => {
39360
39269
  try {
39361
39270
  const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
@@ -39367,19 +39276,19 @@ var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true
39367
39276
  return `Error: ${e.message}`;
39368
39277
  }
39369
39278
  },
39370
- { name: "delete_collection", description: `Delete a collection and all its entries. This cannot be undone.`, schema: import_zod61.default.object({ name: import_zod61.default.string().describe("Collection name") }) }
39279
+ { name: "delete_collection", description: `Delete a collection and all its entries. This cannot be undone.`, schema: import_zod60.default.object({ name: import_zod60.default.string().describe("Collection name") }) }
39371
39280
  );
39372
39281
 
39373
39282
  // src/tool_lattice/collection/list_entries.ts
39374
- var import_zod62 = __toESM(require("zod"));
39375
- var import_langchain76 = require("langchain");
39376
- var schema2 = import_zod62.default.object({
39377
- collection: import_zod62.default.string().describe("Collection name")
39283
+ var import_zod61 = __toESM(require("zod"));
39284
+ var import_langchain75 = require("langchain");
39285
+ var schema2 = import_zod61.default.object({
39286
+ collection: import_zod61.default.string().describe("Collection name")
39378
39287
  });
39379
39288
  function buildKey2(tenantId2, name) {
39380
39289
  return `${tenantId2}:${name}`;
39381
39290
  }
39382
- var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain76.tool)(
39291
+ var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain75.tool)(
39383
39292
  async (input, _exeConfig) => {
39384
39293
  try {
39385
39294
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -39408,19 +39317,19 @@ var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) =
39408
39317
  );
39409
39318
 
39410
39319
  // src/tool_lattice/collection/add_entry.ts
39411
- var import_zod63 = __toESM(require("zod"));
39412
- var import_langchain77 = require("langchain");
39320
+ var import_zod62 = __toESM(require("zod"));
39321
+ var import_langchain76 = require("langchain");
39413
39322
  var import_documents = require("@langchain/core/documents");
39414
39323
  var import_uuid11 = require("uuid");
39415
- var schema3 = import_zod63.default.object({
39416
- collection: import_zod63.default.string().describe("Collection name"),
39417
- content: import_zod63.default.string().describe("Entry content text"),
39418
- metadata: import_zod63.default.record(import_zod63.default.unknown()).optional().describe("Metadata fields matching the collection schema")
39324
+ var schema3 = import_zod62.default.object({
39325
+ collection: import_zod62.default.string().describe("Collection name"),
39326
+ content: import_zod62.default.string().describe("Entry content text"),
39327
+ metadata: import_zod62.default.record(import_zod62.default.unknown()).optional().describe("Metadata fields matching the collection schema")
39419
39328
  });
39420
39329
  function key(t, n) {
39421
39330
  return `${t}:${n}`;
39422
39331
  }
39423
- var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain77.tool)(
39332
+ var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain76.tool)(
39424
39333
  async (input, _exeConfig) => {
39425
39334
  try {
39426
39335
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -39452,18 +39361,18 @@ var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (
39452
39361
  );
39453
39362
 
39454
39363
  // src/tool_lattice/collection/update_entry.ts
39455
- var import_zod64 = __toESM(require("zod"));
39456
- var import_langchain78 = require("langchain");
39457
- var schema4 = import_zod64.default.object({
39458
- collection: import_zod64.default.string().describe("Collection name"),
39459
- entryId: import_zod64.default.string().describe("Entry ID to update"),
39460
- content: import_zod64.default.string().optional().describe("New content"),
39461
- metadata: import_zod64.default.record(import_zod64.default.unknown()).optional().describe("New metadata")
39364
+ var import_zod63 = __toESM(require("zod"));
39365
+ var import_langchain77 = require("langchain");
39366
+ var schema4 = import_zod63.default.object({
39367
+ collection: import_zod63.default.string().describe("Collection name"),
39368
+ entryId: import_zod63.default.string().describe("Entry ID to update"),
39369
+ content: import_zod63.default.string().optional().describe("New content"),
39370
+ metadata: import_zod63.default.record(import_zod63.default.unknown()).optional().describe("New metadata")
39462
39371
  });
39463
39372
  function key2(t, n) {
39464
39373
  return `${t}:${n}`;
39465
39374
  }
39466
- var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain78.tool)(
39375
+ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain77.tool)(
39467
39376
  async (input, _exeConfig) => {
39468
39377
  try {
39469
39378
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -39484,16 +39393,16 @@ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
39484
39393
  );
39485
39394
 
39486
39395
  // src/tool_lattice/collection/delete_entry.ts
39487
- var import_zod65 = __toESM(require("zod"));
39488
- var import_langchain79 = require("langchain");
39489
- var schema5 = import_zod65.default.object({
39490
- collection: import_zod65.default.string().describe("Collection name"),
39491
- entryId: import_zod65.default.string().describe("Entry ID to delete")
39396
+ var import_zod64 = __toESM(require("zod"));
39397
+ var import_langchain78 = require("langchain");
39398
+ var schema5 = import_zod64.default.object({
39399
+ collection: import_zod64.default.string().describe("Collection name"),
39400
+ entryId: import_zod64.default.string().describe("Entry ID to delete")
39492
39401
  });
39493
39402
  function key3(t, n) {
39494
39403
  return `${t}:${n}`;
39495
39404
  }
39496
- var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain79.tool)(
39405
+ var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain78.tool)(
39497
39406
  async (input, _exeConfig) => {
39498
39407
  try {
39499
39408
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -39513,7 +39422,7 @@ var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
39513
39422
  function createCollectionMiddleware(params) {
39514
39423
  const { collectionKeys, connectAll, compileStableCandidateTools = false } = params;
39515
39424
  if (!compileStableCandidateTools && !connectAll && (!collectionKeys || collectionKeys.length === 0)) {
39516
- return (0, import_langchain80.createMiddleware)({
39425
+ return (0, import_langchain79.createMiddleware)({
39517
39426
  name: "collectionMiddleware",
39518
39427
  contextSchema,
39519
39428
  tools: [
@@ -39523,7 +39432,7 @@ function createCollectionMiddleware(params) {
39523
39432
  });
39524
39433
  }
39525
39434
  const toolParams = { collectionKeys, connectAll };
39526
- return (0, import_langchain80.createMiddleware)({
39435
+ return (0, import_langchain79.createMiddleware)({
39527
39436
  name: "collectionMiddleware",
39528
39437
  contextSchema,
39529
39438
  tools: [
@@ -39586,24 +39495,24 @@ var collectionPlugin = {
39586
39495
  };
39587
39496
 
39588
39497
  // src/middlewares/askUserClarifyMiddleware.ts
39589
- var import_langchain82 = require("langchain");
39498
+ var import_langchain81 = require("langchain");
39590
39499
  var import_langgraph14 = require("@langchain/langgraph");
39591
39500
 
39592
39501
  // src/tool_lattice/ask_user_to_clarify/index.ts
39593
- var import_langchain81 = require("langchain");
39594
- var import_zod66 = __toESM(require("zod"));
39595
- var questionSchema = import_zod66.default.object({
39596
- question: import_zod66.default.string().describe("The question text to ask the user. MUST include the specific context, options, or details being clarified \u2014 never use a bare generic label. Good: 'Confirm the plan: use Redis cache + PostgreSQL primary, split microservices as needed?' Bad: 'Confirm the plan?'"),
39597
- options: import_zod66.default.array(import_zod66.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."),
39598
- type: import_zod66.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."),
39599
- required: import_zod66.default.boolean().optional().default(false).describe("Whether this question must be answered"),
39600
- allowOther: import_zod66.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.")
39502
+ var import_langchain80 = require("langchain");
39503
+ var import_zod65 = __toESM(require("zod"));
39504
+ var questionSchema = import_zod65.default.object({
39505
+ question: import_zod65.default.string().describe("The question text to ask the user. MUST include the specific context, options, or details being clarified \u2014 never use a bare generic label. Good: 'Confirm the plan: use Redis cache + PostgreSQL primary, split microservices as needed?' Bad: 'Confirm the plan?'"),
39506
+ options: import_zod65.default.array(import_zod65.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."),
39507
+ type: import_zod65.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."),
39508
+ required: import_zod65.default.boolean().optional().default(false).describe("Whether this question must be answered"),
39509
+ allowOther: import_zod65.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.")
39601
39510
  });
39602
- var inputSchema = import_zod66.default.object({
39603
- questions: import_zod66.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.")
39511
+ var inputSchema = import_zod65.default.object({
39512
+ questions: import_zod65.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.")
39604
39513
  });
39605
39514
  function createAskUserToClarifyTool() {
39606
- return (0, import_langchain81.tool)(
39515
+ return (0, import_langchain80.tool)(
39607
39516
  async (input) => {
39608
39517
  return JSON.stringify(input);
39609
39518
  },
@@ -39617,7 +39526,7 @@ function createAskUserToClarifyTool() {
39617
39526
 
39618
39527
  // src/middlewares/askUserClarifyMiddleware.ts
39619
39528
  function createAskUserClarifyMiddleware() {
39620
- return (0, import_langchain82.createMiddleware)({
39529
+ return (0, import_langchain81.createMiddleware)({
39621
39530
  name: "AskUserClarifyMiddleware",
39622
39531
  tools: [createAskUserToClarifyTool()],
39623
39532
  wrapToolCall: async (request, handler) => {
@@ -39628,7 +39537,7 @@ function createAskUserClarifyMiddleware() {
39628
39537
  }
39629
39538
  const parsed = inputSchema.safeParse(toolCall?.args);
39630
39539
  if (!parsed.success) {
39631
- return new import_langchain82.ToolMessage({
39540
+ return new import_langchain81.ToolMessage({
39632
39541
  content: `Invalid clarify tool arguments: ${parsed.error.message}`,
39633
39542
  tool_call_id: toolCall?.id,
39634
39543
  name: toolName2
@@ -39648,7 +39557,7 @@ function createAskUserClarifyMiddleware() {
39648
39557
  const result = await (0, import_langgraph14.interrupt)(md);
39649
39558
  const response = result.data;
39650
39559
  if (!response?.answers || response.answers.length === 0) {
39651
- return new import_langchain82.ToolMessage({
39560
+ return new import_langchain81.ToolMessage({
39652
39561
  content: "No clarification questions were answered.",
39653
39562
  tool_call_id: toolCall?.id,
39654
39563
  name: toolName2
@@ -39658,7 +39567,7 @@ function createAskUserClarifyMiddleware() {
39658
39567
  (answer) => (answer.selectedOptions?.length ?? 0) > 0 || answer.otherText && answer.otherText.trim() !== "" || answer.filePath && answer.filePath.trim() !== ""
39659
39568
  );
39660
39569
  if (answeredQuestions.length === 0) {
39661
- return new import_langchain82.ToolMessage({
39570
+ return new import_langchain81.ToolMessage({
39662
39571
  content: "No clarification questions were answered.",
39663
39572
  tool_call_id: toolCall?.id,
39664
39573
  name: toolName2
@@ -39688,7 +39597,7 @@ function createAskUserClarifyMiddleware() {
39688
39597
  }
39689
39598
  lines.push("");
39690
39599
  }
39691
- return new import_langchain82.ToolMessage({
39600
+ return new import_langchain81.ToolMessage({
39692
39601
  content: lines.join("\n"),
39693
39602
  tool_call_id: toolCall?.id,
39694
39603
  name: toolName2
@@ -39714,11 +39623,11 @@ var askUserClarifyPlugin = {
39714
39623
  };
39715
39624
 
39716
39625
  // src/middlewares/widgetMiddleware.ts
39717
- var import_langchain85 = require("langchain");
39626
+ var import_langchain84 = require("langchain");
39718
39627
 
39719
39628
  // src/tool_lattice/widget/loadGuidelines.ts
39720
- var import_langchain83 = require("langchain");
39721
- var import_zod67 = require("zod");
39629
+ var import_langchain82 = require("langchain");
39630
+ var import_zod66 = require("zod");
39722
39631
 
39723
39632
  // src/middlewares/guidelines/index.ts
39724
39633
  var CORE = `# Imagine \u2014 Visual Creation Suite
@@ -40509,13 +40418,13 @@ function getGuidelines(modules) {
40509
40418
  var AVAILABLE_MODULES = Object.keys(MODULE_SECTIONS);
40510
40419
 
40511
40420
  // src/tool_lattice/widget/loadGuidelines.ts
40512
- var LoadGuidelinesInputSchema = import_zod67.z.object({
40513
- modules: import_zod67.z.array(import_zod67.z.string()).describe(
40421
+ var LoadGuidelinesInputSchema = import_zod66.z.object({
40422
+ modules: import_zod66.z.array(import_zod66.z.string()).describe(
40514
40423
  "Which design modules to load. Choose all that apply. Available modules: [" + AVAILABLE_MODULES.join(",") + "]"
40515
40424
  )
40516
40425
  });
40517
40426
  function createLoadGuidelinesTool() {
40518
- return (0, import_langchain83.tool)(
40427
+ return (0, import_langchain82.tool)(
40519
40428
  async (input) => {
40520
40429
  const result = getGuidelines(input.modules);
40521
40430
  return result;
@@ -40529,8 +40438,8 @@ function createLoadGuidelinesTool() {
40529
40438
  }
40530
40439
 
40531
40440
  // src/tool_lattice/widget/showWidget.ts
40532
- var import_langchain84 = require("langchain");
40533
- var import_zod68 = require("zod");
40441
+ var import_langchain83 = require("langchain");
40442
+ var import_zod67 = require("zod");
40534
40443
  function containsForbiddenTags(code) {
40535
40444
  const forbiddenPatterns = [
40536
40445
  /<!DOCTYPE/i,
@@ -40552,20 +40461,20 @@ function validateWidgetCode(code) {
40552
40461
  }
40553
40462
  return { valid: true };
40554
40463
  }
40555
- var ShowWidgetInputSchema = import_zod68.z.object({
40556
- i_have_seen_guidelines: import_zod68.z.boolean().describe(
40464
+ var ShowWidgetInputSchema = import_zod67.z.object({
40465
+ i_have_seen_guidelines: import_zod67.z.boolean().describe(
40557
40466
  "Must be true. Confirm you have called load_guidelines first."
40558
40467
  ),
40559
- title: import_zod68.z.string().describe("Title displayed above the widget"),
40560
- loading_messages: import_zod68.z.array(import_zod68.z.string()).optional().describe(
40468
+ title: import_zod67.z.string().describe("Title displayed above the widget"),
40469
+ loading_messages: import_zod67.z.array(import_zod67.z.string()).optional().describe(
40561
40470
  "1-4 short strings shown while the widget renders"
40562
40471
  ),
40563
- widget_code: import_zod68.z.string().describe(
40472
+ widget_code: import_zod67.z.string().describe(
40564
40473
  "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."
40565
40474
  )
40566
40475
  });
40567
40476
  function createShowWidgetTool() {
40568
- return (0, import_langchain84.tool)(
40477
+ return (0, import_langchain83.tool)(
40569
40478
  async (input) => {
40570
40479
  if (!input.i_have_seen_guidelines) {
40571
40480
  return "Error: You must call load_guidelines before using show_widget. Set i_have_seen_guidelines to true only after loading guidelines.";
@@ -40596,7 +40505,7 @@ function createWidgetMiddleware() {
40596
40505
  createLoadGuidelinesTool(),
40597
40506
  createShowWidgetTool()
40598
40507
  ];
40599
- return (0, import_langchain85.createMiddleware)({
40508
+ return (0, import_langchain84.createMiddleware)({
40600
40509
  name: "widgetMiddleware",
40601
40510
  contextSchema,
40602
40511
  tools
@@ -40620,10 +40529,10 @@ var widgetPlugin = {
40620
40529
  };
40621
40530
 
40622
40531
  // src/middlewares/taskMiddleware.ts
40623
- var import_langchain86 = require("langchain");
40624
- var import_zod69 = require("zod");
40532
+ var import_langchain85 = require("langchain");
40533
+ var import_zod68 = require("zod");
40625
40534
  var import_langgraph15 = require("@langchain/langgraph");
40626
- var import_protocols34 = require("@axiom-lattice/protocols");
40535
+ var import_protocols33 = require("@axiom-lattice/protocols");
40627
40536
 
40628
40537
  // src/middlewares/taskResponseSerialization.ts
40629
40538
  var TASK_RESPONSE_SCALAR_MAX_BYTES = 4096;
@@ -40954,7 +40863,7 @@ function classifyTaskAuthority(runConfig) {
40954
40863
  return delegatedTaskId ? { kind: "delegated", taskId: delegatedTaskId } : { kind: "ordinary" };
40955
40864
  }
40956
40865
  try {
40957
- const trusted = (0, import_protocols34.parseTrustedRunContext)(hasProjectTask ? { projectTask: runConfig.projectTask } : { projectRoom: runConfig.projectRoom });
40866
+ const trusted = (0, import_protocols33.parseTrustedRunContext)(hasProjectTask ? { projectTask: runConfig.projectTask } : { projectRoom: runConfig.projectRoom });
40958
40867
  return { kind: hasProjectTask ? "projectTask" : "projectRoom", trusted };
40959
40868
  } catch {
40960
40869
  return { kind: "invalid" };
@@ -41297,7 +41206,7 @@ function getTaskWorkItemStore() {
41297
41206
  return getStoreLattice("default", "taskWorkItem").store;
41298
41207
  }
41299
41208
  function getProjectTaskWorkItemStore() {
41300
- return (0, import_protocols34.requireProjectTaskWorkItemStore)(getTaskWorkItemStore());
41209
+ return (0, import_protocols33.requireProjectTaskWorkItemStore)(getTaskWorkItemStore());
41301
41210
  }
41302
41211
  function missingBeliefImpactError() {
41303
41212
  return JSON.stringify({
@@ -41307,38 +41216,38 @@ function missingBeliefImpactError() {
41307
41216
  hint: "Provide beliefImpact: [{ key: '<belief-key>', after: <0-100>, basis: '<evidence>' }]"
41308
41217
  });
41309
41218
  }
41310
- var manageTaskSchema = import_zod69.z.object({
41311
- action: import_zod69.z.enum(["create", "get", "list", "update", "add_activity", "delete"]).describe("Action to perform. Available: create, get, list, update, add_activity, delete. To mark a task complete, use update with status='completed'"),
41312
- id: import_zod69.z.string().optional().describe("Task ID (required for get, update, add_activity, and delete)"),
41313
- title: import_zod69.z.string().optional().describe("Task title (required for create)"),
41314
- description: import_zod69.z.string().optional().describe("Task description in Markdown"),
41315
- priority: import_zod69.z.enum(["low", "medium", "high"]).optional().describe("Priority level"),
41316
- status: import_zod69.z.enum(["pending", "in_progress", "review", "failed", "interrupted", "completed", "cancelled"]).optional().describe("Task status. Agent summary-only interrupted updates default to missing_input"),
41317
- dueDate: import_zod69.z.string().optional().describe("Due date (ISO 8601 format)"),
41318
- metadata: import_zod69.z.record(import_zod69.z.unknown()).optional().describe("Structured metadata (e.g. projectId, module)"),
41319
- parentId: import_zod69.z.string().optional().describe("Parent task ID for grouping subtasks"),
41320
- sourceId: import_zod69.z.string().optional().describe("Source session/thread ID"),
41321
- context: import_zod69.z.record(import_zod69.z.unknown()).optional().describe("Additional context data"),
41322
- ownerType: import_zod69.z.enum(["user", "agent"]).optional().describe("Owner type. Defaults to 'user' if omitted"),
41323
- ownerId: import_zod69.z.string().optional().describe("Owner ID. Auto-filled from current user/agent if omitted"),
41324
- requireReview: import_zod69.z.boolean().optional().describe("If true, agent completion pauses as interrupted(review_required) for HITL approval"),
41325
- dependencies: import_zod69.z.array(import_zod69.z.string()).optional().describe("List of task IDs that must be completed before this task can start"),
41326
- dependencyTaskIds: import_zod69.z.array(import_zod69.z.string().trim().min(1)).optional().describe("Exact blocking task IDs required for an external_dependency interruption"),
41327
- result: import_zod69.z.string().optional().describe("Nonblank result summary required when creating or updating a task with status='completed'"),
41328
- failureReason: import_zod69.z.string().optional().describe("Nonblank failure reason required when creating or updating a task with status='failed'"),
41329
- files: import_zod69.z.array(import_zod69.z.object({
41330
- uri: import_zod69.z.string().describe("Uniquely locates the resource: http(s):// URL, /s/:token share, or sandbox path"),
41331
- name: import_zod69.z.string().optional().describe("Display name"),
41332
- addedBy: import_zod69.z.enum(["user", "agent"]).optional().describe("Who attached the file")
41219
+ var manageTaskSchema = import_zod68.z.object({
41220
+ action: import_zod68.z.enum(["create", "get", "list", "update", "add_activity", "delete"]).describe("Action to perform. Available: create, get, list, update, add_activity, delete. To mark a task complete, use update with status='completed'"),
41221
+ id: import_zod68.z.string().optional().describe("Task ID (required for get, update, add_activity, and delete)"),
41222
+ title: import_zod68.z.string().optional().describe("Task title (required for create)"),
41223
+ description: import_zod68.z.string().optional().describe("Task description in Markdown"),
41224
+ priority: import_zod68.z.enum(["low", "medium", "high"]).optional().describe("Priority level"),
41225
+ status: import_zod68.z.enum(["pending", "in_progress", "review", "failed", "interrupted", "completed", "cancelled"]).optional().describe("Task status. Agent summary-only interrupted updates default to missing_input"),
41226
+ dueDate: import_zod68.z.string().optional().describe("Due date (ISO 8601 format)"),
41227
+ metadata: import_zod68.z.record(import_zod68.z.unknown()).optional().describe("Structured metadata (e.g. projectId, module)"),
41228
+ parentId: import_zod68.z.string().optional().describe("Parent task ID for grouping subtasks"),
41229
+ sourceId: import_zod68.z.string().optional().describe("Source session/thread ID"),
41230
+ context: import_zod68.z.record(import_zod68.z.unknown()).optional().describe("Additional context data"),
41231
+ ownerType: import_zod68.z.enum(["user", "agent"]).optional().describe("Owner type. Defaults to 'user' if omitted"),
41232
+ ownerId: import_zod68.z.string().optional().describe("Owner ID. Auto-filled from current user/agent if omitted"),
41233
+ requireReview: import_zod68.z.boolean().optional().describe("If true, agent completion pauses as interrupted(review_required) for HITL approval"),
41234
+ dependencies: import_zod68.z.array(import_zod68.z.string()).optional().describe("List of task IDs that must be completed before this task can start"),
41235
+ dependencyTaskIds: import_zod68.z.array(import_zod68.z.string().trim().min(1)).optional().describe("Exact blocking task IDs required for an external_dependency interruption"),
41236
+ result: import_zod68.z.string().optional().describe("Nonblank result summary required when creating or updating a task with status='completed'"),
41237
+ failureReason: import_zod68.z.string().optional().describe("Nonblank failure reason required when creating or updating a task with status='failed'"),
41238
+ files: import_zod68.z.array(import_zod68.z.object({
41239
+ uri: import_zod68.z.string().describe("Uniquely locates the resource: http(s):// URL, /s/:token share, or sandbox path"),
41240
+ name: import_zod68.z.string().optional().describe("Display name"),
41241
+ addedBy: import_zod68.z.enum(["user", "agent"]).optional().describe("Who attached the file")
41333
41242
  })).optional().describe("File references attached to this task"),
41334
- beliefImpact: import_zod69.z.array(import_zod69.z.object({
41335
- key: import_zod69.z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
41336
- after: import_zod69.z.number().int().min(0).max(100),
41337
- basis: import_zod69.z.string().trim().min(1).max(1e3)
41243
+ beliefImpact: import_zod68.z.array(import_zod68.z.object({
41244
+ key: import_zod68.z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
41245
+ after: import_zod68.z.number().int().min(0).max(100),
41246
+ basis: import_zod68.z.string().trim().min(1).max(1e3)
41338
41247
  })).optional().describe("Structured belief reports required when an agent-owned task completes; keys must exist in the belief owner's Belief State"),
41339
- content: import_zod69.z.string().optional().describe("Markdown content required for add_activity"),
41340
- summary: import_zod69.z.string().optional().describe("Brief summary of the operation"),
41341
- executionResultId: import_zod69.z.string().refine(import_protocols34.isExecutionResultEventKey, {
41248
+ content: import_zod68.z.string().optional().describe("Markdown content required for add_activity"),
41249
+ summary: import_zod68.z.string().optional().describe("Brief summary of the operation"),
41250
+ executionResultId: import_zod68.z.string().refine(import_protocols33.isExecutionResultEventKey, {
41342
41251
  message: "executionResultId must be the execution-result:<threadId> event key returned by task()"
41343
41252
  }).optional().describe(
41344
41253
  "Canonical ASCII `execution-result:<suffix>` event key returned by task(); the nonempty suffix allows only A-Z, a-z, 0-9, period, underscore, colon, and hyphen, and is not a database row ID"
@@ -41346,15 +41255,15 @@ var manageTaskSchema = import_zod69.z.object({
41346
41255
  }).superRefine((input, context) => {
41347
41256
  if (input.executionResultId && input.action !== "update" && input.action !== "add_activity") {
41348
41257
  context.addIssue({
41349
- code: import_zod69.z.ZodIssueCode.custom,
41258
+ code: import_zod68.z.ZodIssueCode.custom,
41350
41259
  path: ["executionResultId"],
41351
41260
  message: "executionResultId is valid only for update or add_activity"
41352
41261
  });
41353
41262
  }
41354
41263
  });
41355
- var startTaskSchema = import_zod69.z.object({
41356
- taskId: import_zod69.z.string().trim().min(1).describe("ID of the persisted TaskItem to start"),
41357
- agentId: import_zod69.z.string().trim().min(1).describe("ID of the Agent that should execute the task")
41264
+ var startTaskSchema = import_zod68.z.object({
41265
+ taskId: import_zod68.z.string().trim().min(1).describe("ID of the persisted TaskItem to start"),
41266
+ agentId: import_zod68.z.string().trim().min(1).describe("ID of the Agent that should execute the task")
41358
41267
  });
41359
41268
  function mergeTaskUpdateWarnings(existing, added) {
41360
41269
  const warnings = [...existing ?? [], ...added ?? []];
@@ -41386,7 +41295,7 @@ async function getPendingExecutionResultIds(store, tenantId2, taskId) {
41386
41295
  order: "desc",
41387
41296
  limit: PENDING_EXECUTION_RESULT_LIMIT + 1
41388
41297
  });
41389
- const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0, import_protocols34.isExecutionResultEventKey)(item.eventKey));
41298
+ const canonicalCandidates = candidates.slice(0, PENDING_EXECUTION_RESULT_LIMIT + 1).filter((item) => (0, import_protocols33.isExecutionResultEventKey)(item.eventKey));
41390
41299
  const reconciliationRows = new Array(canonicalCandidates.length);
41391
41300
  let nextCandidateIndex = 0;
41392
41301
  let firstError;
@@ -42589,7 +42498,7 @@ function createTaskMiddleware(options = {}) {
42589
42498
  callerThreadId: rc.thread_id
42590
42499
  }));
42591
42500
  };
42592
- return (0, import_langchain86.createMiddleware)({
42501
+ return (0, import_langchain85.createMiddleware)({
42593
42502
  name: "TaskMiddleware",
42594
42503
  contextSchema,
42595
42504
  wrapModelCall: async (request, handler) => {
@@ -42630,7 +42539,7 @@ ${TASK_CONVERGENCE_GUIDANCE}
42630
42539
  });
42631
42540
  },
42632
42541
  tools: [
42633
- (0, import_langchain86.tool)(
42542
+ (0, import_langchain85.tool)(
42634
42543
  handleManageTask,
42635
42544
  {
42636
42545
  name: "manage_task",
@@ -42664,7 +42573,7 @@ pending/in_progress, then complete them separately.`,
42664
42573
  schema: manageTaskSchema
42665
42574
  }
42666
42575
  ),
42667
- (0, import_langchain86.tool)(handleStartTask, {
42576
+ (0, import_langchain85.tool)(handleStartTask, {
42668
42577
  name: "task",
42669
42578
  description: "Start a persisted TaskItem with any Agent in a fresh isolated thread and return an observation plus executionResultId; the caller passes that exact ID to the manage_task update or add_activity that interprets it.",
42670
42579
  schema: startTaskSchema
@@ -42802,8 +42711,8 @@ canonical Belief State:
42802
42711
  };
42803
42712
 
42804
42713
  // src/middlewares/evalMiddleware.ts
42805
- var import_langchain87 = require("langchain");
42806
- var import_zod70 = require("zod");
42714
+ var import_langchain86 = require("langchain");
42715
+ var import_zod69 = require("zod");
42807
42716
  var import_uuid12 = require("uuid");
42808
42717
 
42809
42718
  // src/middlewares/evalSkills.ts
@@ -43022,8 +42931,8 @@ async function runWithResults(tid, store, svc, run, runnerAlive) {
43022
42931
  return { ...run, runnerAlive, results };
43023
42932
  }
43024
42933
  function createReadEvalTool() {
43025
- const schema6 = import_zod70.z.object({
43026
- action: import_zod70.z.enum([
42934
+ const schema6 = import_zod69.z.object({
42935
+ action: import_zod69.z.enum([
43027
42936
  "list_projects",
43028
42937
  "get_project",
43029
42938
  "list_suites",
@@ -43035,13 +42944,13 @@ function createReadEvalTool() {
43035
42944
  "get_run_results",
43036
42945
  "get_project_report"
43037
42946
  ]).describe("Operation"),
43038
- projectId: import_zod70.z.string().optional(),
43039
- suiteId: import_zod70.z.string().optional(),
43040
- caseId: import_zod70.z.string().optional(),
43041
- runId: import_zod70.z.string().optional(),
43042
- status: import_zod70.z.string().optional().describe("Filter: running|completed|failed|aborted")
42947
+ projectId: import_zod69.z.string().optional(),
42948
+ suiteId: import_zod69.z.string().optional(),
42949
+ caseId: import_zod69.z.string().optional(),
42950
+ runId: import_zod69.z.string().optional(),
42951
+ status: import_zod69.z.string().optional().describe("Filter: running|completed|failed|aborted")
43043
42952
  });
43044
- return (0, import_langchain87.tool)(
42953
+ return (0, import_langchain86.tool)(
43045
42954
  async (input, exeConfig) => {
43046
42955
  const tid = tenantId(exeConfig);
43047
42956
  if (!tid) {
@@ -43123,8 +43032,8 @@ ACTIONS:
43123
43032
  );
43124
43033
  }
43125
43034
  function createManageEvalTool() {
43126
- const schema6 = import_zod70.z.object({
43127
- action: import_zod70.z.enum([
43035
+ const schema6 = import_zod69.z.object({
43036
+ action: import_zod69.z.enum([
43128
43037
  "create_project",
43129
43038
  "update_project",
43130
43039
  "delete_project",
@@ -43135,26 +43044,26 @@ function createManageEvalTool() {
43135
43044
  "update_case",
43136
43045
  "delete_case"
43137
43046
  ]).describe("Operation"),
43138
- projectId: import_zod70.z.string().optional(),
43139
- name: import_zod70.z.string().optional(),
43140
- description: import_zod70.z.string().optional(),
43141
- judgeModelKey: import_zod70.z.string().optional(),
43142
- concurrency: import_zod70.z.number().optional(),
43143
- targetAgentId: import_zod70.z.string().optional().describe("Optional for create_project \u2014 the agent this eval project verifies. Recorded in targetServerConfig so the agent's detail page can find its eval data without relying on project naming."),
43144
- suiteId: import_zod70.z.string().optional(),
43145
- caseId: import_zod70.z.string().optional(),
43146
- inputMessage: import_zod70.z.string().optional(),
43147
- inputFiles: import_zod70.z.record(import_zod70.z.string()).optional(),
43148
- steps: import_zod70.z.array(import_zod70.z.object({ agent_id: import_zod70.z.string(), override_message: import_zod70.z.string().optional() })).optional(),
43149
- outputType: import_zod70.z.enum(["file_content", "message_content"]).optional(),
43150
- contentAssertion: import_zod70.z.string().optional(),
43151
- rubrics: import_zod70.z.array(import_zod70.z.object({ name: import_zod70.z.string(), weight: import_zod70.z.number(), description: import_zod70.z.string() })).optional(),
43152
- interruptPolicy: import_zod70.z.object({
43153
- mode: import_zod70.z.enum(["stop", "auto-approve", "auto-reject", "canned-response"]).describe("stop=judge the pause; auto-approve/auto-reject/canned-response=resume the agent to test the flow after the human input"),
43154
- value: import_zod70.z.string().optional().describe("Response to inject (defaults: \u540C\u610F / \u62D2\u7EDD; required for canned-response)")
43047
+ projectId: import_zod69.z.string().optional(),
43048
+ name: import_zod69.z.string().optional(),
43049
+ description: import_zod69.z.string().optional(),
43050
+ judgeModelKey: import_zod69.z.string().optional(),
43051
+ concurrency: import_zod69.z.number().optional(),
43052
+ targetAgentId: import_zod69.z.string().optional().describe("Optional for create_project \u2014 the agent this eval project verifies. Recorded in targetServerConfig so the agent's detail page can find its eval data without relying on project naming."),
43053
+ suiteId: import_zod69.z.string().optional(),
43054
+ caseId: import_zod69.z.string().optional(),
43055
+ inputMessage: import_zod69.z.string().optional(),
43056
+ inputFiles: import_zod69.z.record(import_zod69.z.string()).optional(),
43057
+ steps: import_zod69.z.array(import_zod69.z.object({ agent_id: import_zod69.z.string(), override_message: import_zod69.z.string().optional() })).optional(),
43058
+ outputType: import_zod69.z.enum(["file_content", "message_content"]).optional(),
43059
+ contentAssertion: import_zod69.z.string().optional(),
43060
+ rubrics: import_zod69.z.array(import_zod69.z.object({ name: import_zod69.z.string(), weight: import_zod69.z.number(), description: import_zod69.z.string() })).optional(),
43061
+ interruptPolicy: import_zod69.z.object({
43062
+ mode: import_zod69.z.enum(["stop", "auto-approve", "auto-reject", "canned-response"]).describe("stop=judge the pause; auto-approve/auto-reject/canned-response=resume the agent to test the flow after the human input"),
43063
+ value: import_zod69.z.string().optional().describe("Response to inject (defaults: \u540C\u610F / \u62D2\u7EDD; required for canned-response)")
43155
43064
  }).optional().describe("Optional for create_case/update_case \u2014 how HITL interrupts are handled")
43156
43065
  });
43157
- return (0, import_langchain87.tool)(
43066
+ return (0, import_langchain86.tool)(
43158
43067
  async (input, exeConfig) => {
43159
43068
  const tid = tenantId(exeConfig);
43160
43069
  if (!tid) {
@@ -43263,17 +43172,17 @@ Case: create_case(suiteId, inputMessage, steps, outputType, contentAssertion, in
43263
43172
  );
43264
43173
  }
43265
43174
  function createRunEvalTool() {
43266
- const schema6 = import_zod70.z.object({
43267
- action: import_zod70.z.enum(["start", "status", "resume", "abort"]).describe("Operation"),
43268
- projectId: import_zod70.z.string().optional().describe("Required for start"),
43269
- suiteIds: import_zod70.z.array(import_zod70.z.string()).optional().describe("Optional for start \u2014 only run these suites (e.g. dev set only). Omit to run all."),
43270
- caseIds: import_zod70.z.array(import_zod70.z.string()).optional().describe("Optional for start \u2014 only run these cases across the selected suites. Omit to run all cases in those suites."),
43271
- runId: import_zod70.z.string().optional().describe("Required for status, resume, abort"),
43272
- taskId: import_zod70.z.string().optional().describe("Optional for start \u2014 training task ID this run belongs to (round association)"),
43273
- sleepMs: import_zod70.z.number().int().min(0).max(12e4).optional().describe("Optional for status \u2014 sleep this many ms BEFORE checking the run, to pace polling (e.g. 15000 \u2192 30000 \u2192 60000 \u2192 120000). Omit to check immediately."),
43274
- wait: import_zod70.z.boolean().optional().describe("Optional for start \u2014 defaults to true: block synchronously (up to ~150s) and return final results in one call. Set false to return the runId immediately and poll.")
43175
+ const schema6 = import_zod69.z.object({
43176
+ action: import_zod69.z.enum(["start", "status", "resume", "abort"]).describe("Operation"),
43177
+ projectId: import_zod69.z.string().optional().describe("Required for start"),
43178
+ suiteIds: import_zod69.z.array(import_zod69.z.string()).optional().describe("Optional for start \u2014 only run these suites (e.g. dev set only). Omit to run all."),
43179
+ caseIds: import_zod69.z.array(import_zod69.z.string()).optional().describe("Optional for start \u2014 only run these cases across the selected suites. Omit to run all cases in those suites."),
43180
+ runId: import_zod69.z.string().optional().describe("Required for status, resume, abort"),
43181
+ taskId: import_zod69.z.string().optional().describe("Optional for start \u2014 training task ID this run belongs to (round association)"),
43182
+ sleepMs: import_zod69.z.number().int().min(0).max(12e4).optional().describe("Optional for status \u2014 sleep this many ms BEFORE checking the run, to pace polling (e.g. 15000 \u2192 30000 \u2192 60000 \u2192 120000). Omit to check immediately."),
43183
+ wait: import_zod69.z.boolean().optional().describe("Optional for start \u2014 defaults to true: block synchronously (up to ~150s) and return final results in one call. Set false to return the runId immediately and poll.")
43275
43184
  });
43276
- return (0, import_langchain87.tool)(
43185
+ return (0, import_langchain86.tool)(
43277
43186
  withToolTimeout(
43278
43187
  async (input, exeConfig) => {
43279
43188
  const tid = tenantId(exeConfig);
@@ -43404,15 +43313,15 @@ var evalPlugin = {
43404
43313
  defaultConfig: {}
43405
43314
  },
43406
43315
  skills: EVAL_SKILLS,
43407
- middleware: () => (0, import_langchain87.createMiddleware)({
43316
+ middleware: () => (0, import_langchain86.createMiddleware)({
43408
43317
  name: "EvalMiddleware",
43409
43318
  tools: [createReadEvalTool(), createManageEvalTool(), createRunEvalTool()]
43410
43319
  })
43411
43320
  };
43412
43321
 
43413
43322
  // src/middlewares/documentLearningMiddleware.ts
43414
- var import_protocols35 = require("@axiom-lattice/protocols");
43415
- var import_langchain88 = require("langchain");
43323
+ var import_protocols34 = require("@axiom-lattice/protocols");
43324
+ var import_langchain87 = require("langchain");
43416
43325
 
43417
43326
  // src/middlewares/documentLearningSkills.ts
43418
43327
  var LEARN_CAPABILITY_SKILL = `---
@@ -43624,7 +43533,7 @@ patterns discovered, recommendations. Include validation coverage: user-sample N
43624
43533
  `;
43625
43534
 
43626
43535
  // src/middlewares/documentLearningMiddleware.ts
43627
- var createDocumentLearningMiddleware = () => (0, import_langchain88.createMiddleware)({
43536
+ var createDocumentLearningMiddleware = () => (0, import_langchain87.createMiddleware)({
43628
43537
  name: "DocumentLearningMiddleware",
43629
43538
  contextSchema,
43630
43539
  tools: []
@@ -43651,7 +43560,7 @@ var documentLearningPlugin = {
43651
43560
  key: "document-learner",
43652
43561
  name: "Document Learning Agent",
43653
43562
  description: "Read documents and build structured skill systems with evaluations. Use this agent when you need to extract knowledge from documents and turn it into reusable, testable agent skills.",
43654
- type: import_protocols35.AgentType.DEEP_AGENT,
43563
+ type: import_protocols34.AgentType.DEEP_AGENT,
43655
43564
  prompt: DOCUMENT_LEARNER_SYSTEM_PROMPT,
43656
43565
  subAgents: ["document-parser-benchmark"],
43657
43566
  tools: [
@@ -43742,12 +43651,12 @@ var documentLearningPlugin = {
43742
43651
  };
43743
43652
 
43744
43653
  // src/middlewares/documentParserMiddleware.ts
43745
- var import_langchain90 = require("langchain");
43654
+ var import_langchain89 = require("langchain");
43746
43655
 
43747
43656
  // src/tool_lattice/document_parser/index.ts
43748
43657
  var path7 = __toESM(require("path"));
43749
- var import_zod71 = __toESM(require("zod"));
43750
- var import_langchain89 = require("langchain");
43658
+ var import_zod70 = __toESM(require("zod"));
43659
+ var import_langchain88 = require("langchain");
43751
43660
  var PARSE_DOCUMENT_DESCRIPTION = `Parse a document file (docx, pdf) into structured Markdown using a remote document parsing service.
43752
43661
  This tool handles the full pipeline internally: file upload \u2192 document parsing \u2192 polling until complete \u2192 download result \u2192 save to filesystem.
43753
43662
 
@@ -43870,7 +43779,7 @@ function createParseDocumentTool({
43870
43779
  baseUrl = "",
43871
43780
  apiKey = ""
43872
43781
  }) {
43873
- return (0, import_langchain89.tool)(
43782
+ return (0, import_langchain88.tool)(
43874
43783
  async (input, exe_config) => {
43875
43784
  try {
43876
43785
  const runConfig = exe_config?.configurable?.runConfig ?? { assistant_id: "", thread_id: "" };
@@ -43941,17 +43850,17 @@ function createParseDocumentTool({
43941
43850
  {
43942
43851
  name: "parse_document",
43943
43852
  description: PARSE_DOCUMENT_DESCRIPTION,
43944
- schema: import_zod71.default.object({
43945
- file_path: import_zod71.default.string().describe(
43853
+ schema: import_zod70.default.object({
43854
+ file_path: import_zod70.default.string().describe(
43946
43855
  'Absolute path to the document file. Must point to an existing .docx or .pdf file. Example: "/project/reports/contract.docx". The file must be accessible from the current workspace.'
43947
43856
  ),
43948
- engine: import_zod71.default.string().describe(
43857
+ engine: import_zod70.default.string().describe(
43949
43858
  'Parsing engine to use. Available options: "textin" (recommended, works with local files, supports docx/pdf), "datalab" (alternative engine for docx/pdf), "mineru" (requires public URL, use only if textin/datalab fail), "paddleocr_remote" (PaddleOCR, good for scanned documents), "qwen_ocr" (OCR-focused, best for image-heavy PDFs).'
43950
43859
  ),
43951
- output_path: import_zod71.default.string().optional().describe(
43860
+ output_path: import_zod70.default.string().optional().describe(
43952
43861
  'Path to save the parsed result. If not specified, the input extension is replaced with .md. Example: "/project/report.docx" becomes "/project/report.md". Parent directories are created automatically.'
43953
43862
  ),
43954
- output_format: import_zod71.default.enum(["markdown", "json"]).optional().default("markdown").describe(
43863
+ output_format: import_zod70.default.enum(["markdown", "json"]).optional().default("markdown").describe(
43955
43864
  'Output format. "markdown": structured Markdown with tables, headers, formatting preserved (recommended). "json": raw JSON output from the parsing engine (for programmatic use).'
43956
43865
  )
43957
43866
  })
@@ -43960,7 +43869,7 @@ function createParseDocumentTool({
43960
43869
  }
43961
43870
 
43962
43871
  // src/middlewares/documentParserMiddleware.ts
43963
- var import_protocols36 = require("@axiom-lattice/protocols");
43872
+ var import_protocols35 = require("@axiom-lattice/protocols");
43964
43873
 
43965
43874
  // src/middlewares/documentBenchmarkWorkflow.ts
43966
43875
  var DOCUMENT_PARSER_BENCHMARK_YAML = `name: document-parser-benchmark
@@ -44407,7 +44316,7 @@ function createDocumentParserMiddleware(config) {
44407
44316
  const baseUrl = config.baseUrl || "";
44408
44317
  const apiKey = config.apiKey || "";
44409
44318
  const connections = Array.isArray(config.connections) ? config.connections.filter((key4) => typeof key4 === "string") : [];
44410
- return (0, import_langchain90.createMiddleware)({
44319
+ return (0, import_langchain89.createMiddleware)({
44411
44320
  name: "DocumentParser",
44412
44321
  contextSchema,
44413
44322
  tools: [createParseDocumentTool({ connectAll, connections, baseUrl, apiKey })]
@@ -44484,7 +44393,7 @@ var documentParserPlugin = {
44484
44393
  agents: {
44485
44394
  "document-parser-benchmark": {
44486
44395
  key: "document-parser-benchmark",
44487
- type: import_protocols36.AgentType.WORKFLOW,
44396
+ type: import_protocols35.AgentType.WORKFLOW,
44488
44397
  name: "Document Parser Benchmark",
44489
44398
  description: "Benchmark document parsing engines. Parses a document with 5 engines in parallel, scores results, and produces a ranking report. Use this when you need to evaluate which parsing engine works best for a given document.",
44490
44399
  prompt: "Benchmark document parsing engines: parse with 5 engines, score, and rank results.",
@@ -44519,6 +44428,175 @@ var documentParserPlugin = {
44519
44428
  }
44520
44429
  };
44521
44430
 
44431
+ // src/middlewares/projectRoomMiddleware.ts
44432
+ var import_crypto9 = require("crypto");
44433
+ var import_protocols36 = require("@axiom-lattice/protocols");
44434
+ var import_langchain90 = require("langchain");
44435
+ var import_zod71 = require("zod");
44436
+ var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
44437
+ var PROJECT_ROOM_POST_FAILED = "PROJECT_ROOM_POST_FAILED";
44438
+ var PROJECT_ROOM_ROSTER_FAILED = "PROJECT_ROOM_ROSTER_FAILED";
44439
+ var PROJECT_ROOM_POST_FAILED_MESSAGE = "Project room message could not be posted";
44440
+ var PROJECT_ROOM_ROSTER_FAILED_MESSAGE = "Project room roster is unavailable";
44441
+ var CONTEXT_REQUIRED = JSON.stringify({
44442
+ success: false,
44443
+ error: PROJECT_ROOM_CONTEXT_REQUIRED
44444
+ });
44445
+ var POST_FAILED = JSON.stringify({
44446
+ success: false,
44447
+ error: PROJECT_ROOM_POST_FAILED,
44448
+ message: PROJECT_ROOM_POST_FAILED_MESSAGE
44449
+ });
44450
+ var ROSTER_FAILED = JSON.stringify({
44451
+ success: false,
44452
+ error: PROJECT_ROOM_ROSTER_FAILED,
44453
+ message: PROJECT_ROOM_ROSTER_FAILED_MESSAGE
44454
+ });
44455
+ var postSchema = import_zod71.z.object({
44456
+ text: import_zod71.z.string().trim().min(1).max(2e4)
44457
+ }).strict();
44458
+ var listSchema = import_zod71.z.object({}).strict();
44459
+ function ownDataValue2(record, key4) {
44460
+ if (typeof record !== "object" || record === null || Array.isArray(record)) return void 0;
44461
+ try {
44462
+ const descriptor = Object.getOwnPropertyDescriptor(record, key4);
44463
+ return (0, import_protocols36.descriptorDataValue)(descriptor)?.value;
44464
+ } catch {
44465
+ return void 0;
44466
+ }
44467
+ }
44468
+ function readTrustedRoomScope(config) {
44469
+ const configurable = ownDataValue2(config, "configurable");
44470
+ const runConfig = ownDataValue2(configurable, "runConfig");
44471
+ const projectRoom = ownDataValue2(runConfig, "projectRoom");
44472
+ try {
44473
+ return (0, import_protocols36.parseTrustedRunContext)({ projectRoom }).projectRoom;
44474
+ } catch {
44475
+ return void 0;
44476
+ }
44477
+ }
44478
+ function exactValues2(value, required, optional = []) {
44479
+ try {
44480
+ return (0, import_protocols36.snapshotExactRecord)(value, required, optional);
44481
+ } catch {
44482
+ return void 0;
44483
+ }
44484
+ }
44485
+ function safeDate(value) {
44486
+ try {
44487
+ const timestamp = Date.prototype.getTime.call(value);
44488
+ return Number.isFinite(timestamp) ? new Date(timestamp) : void 0;
44489
+ } catch {
44490
+ return void 0;
44491
+ }
44492
+ }
44493
+ function snapshotMembership3(value) {
44494
+ const required = [
44495
+ "id",
44496
+ "tenantId",
44497
+ "workspaceId",
44498
+ "projectId",
44499
+ "roomId",
44500
+ "assistantId",
44501
+ "role",
44502
+ "title",
44503
+ "mentionName",
44504
+ "status",
44505
+ "roomThreadId",
44506
+ "joinedAt",
44507
+ "updatedAt"
44508
+ ];
44509
+ const values = exactValues2(value, required, ["responsibility"]);
44510
+ const joinedAt = safeDate(values?.joinedAt);
44511
+ const updatedAt = safeDate(values?.updatedAt);
44512
+ if (!values || !joinedAt || !updatedAt || required.slice(0, 6).some((key4) => typeof values[key4] !== "string" || values[key4] === "") || values.role !== "coordinator" && values.role !== "specialist" || typeof values.title !== "string" || values.title === "" || typeof values.mentionName !== "string" || values.mentionName === "" || !["active", "paused", "removed"].includes(values.status) || typeof values.roomThreadId !== "string" || values.roomThreadId === "" || values.responsibility !== void 0 && typeof values.responsibility !== "string") return void 0;
44513
+ return { ...values, joinedAt, updatedAt };
44514
+ }
44515
+ function snapshotRows(value) {
44516
+ return (0, import_protocols36.snapshotExactArray)(value) ?? [];
44517
+ }
44518
+ async function hasActiveCurrentMembership(scope) {
44519
+ const memberships = getStoreLattice("default", "projectBotMembership").store;
44520
+ const member = snapshotMembership3(await memberships.findById(scope.tenantId, scope.membershipId));
44521
+ if (!member || member.status !== "active" || member.id !== scope.membershipId || member.tenantId !== scope.tenantId || member.workspaceId !== scope.workspaceId || member.projectId !== scope.projectId || member.roomId !== scope.roomId || member.assistantId !== scope.assistantId) return false;
44522
+ return true;
44523
+ }
44524
+ function createProjectRoomMiddleware() {
44525
+ return (0, import_langchain90.createMiddleware)({
44526
+ name: "ProjectRoomMiddleware",
44527
+ tools: [
44528
+ (0, import_langchain90.tool)(async (input, config) => {
44529
+ const { text } = input;
44530
+ const scope = readTrustedRoomScope(config);
44531
+ if (!scope) return CONTEXT_REQUIRED;
44532
+ const digest = (0, import_crypto9.createHash)("sha256").update(text).digest("hex");
44533
+ try {
44534
+ const service2 = new RoomAgentMessageService({
44535
+ memberships: getStoreLattice("default", "projectBotMembership").store,
44536
+ messages: getStoreLattice("default", "projectRoomMessage").store
44537
+ });
44538
+ await service2.post({
44539
+ tenantId: scope.tenantId,
44540
+ workspaceId: scope.workspaceId,
44541
+ projectId: scope.projectId,
44542
+ roomId: scope.roomId,
44543
+ membershipId: scope.membershipId,
44544
+ assistantId: scope.assistantId,
44545
+ text,
44546
+ sourceRoomMessageId: scope.sourceRoomMessageId,
44547
+ sourceId: `${scope.inputMessageId}:${digest}`,
44548
+ idempotencyKey: `room-tool:${scope.inputMessageId}:${scope.membershipId}:${digest}`
44549
+ });
44550
+ return JSON.stringify({ success: true, message: "Project room message posted" });
44551
+ } catch {
44552
+ return POST_FAILED;
44553
+ }
44554
+ }, {
44555
+ name: "post_room_message",
44556
+ description: "Post a text reply to the current trusted Project Room message",
44557
+ schema: postSchema
44558
+ }),
44559
+ (0, import_langchain90.tool)(async (_input, config) => {
44560
+ const scope = readTrustedRoomScope(config);
44561
+ if (!scope) return CONTEXT_REQUIRED;
44562
+ try {
44563
+ if (!await hasActiveCurrentMembership(scope)) return CONTEXT_REQUIRED;
44564
+ const rows = await getStoreLattice("default", "projectBotMembership").store.list(scope.tenantId, scope.projectId);
44565
+ const members = snapshotRows(rows).map(snapshotMembership3).filter((member) => member !== void 0 && member.status === "active" && member.tenantId === scope.tenantId && member.workspaceId === scope.workspaceId && member.projectId === scope.projectId && member.roomId === scope.roomId).sort((left, right) => left.joinedAt.getTime() - right.joinedAt.getTime() || (left.id < right.id ? -1 : left.id > right.id ? 1 : 0)).map((member) => ({
44566
+ assistantId: member.assistantId,
44567
+ mentionName: member.mentionName,
44568
+ title: member.title,
44569
+ ...member.responsibility === void 0 ? {} : { responsibility: member.responsibility },
44570
+ role: member.role
44571
+ }));
44572
+ return JSON.stringify({ success: true, members });
44573
+ } catch {
44574
+ return ROSTER_FAILED;
44575
+ }
44576
+ }, {
44577
+ name: "list_room_roster",
44578
+ description: "List active Agent roles in the current trusted Project Room, including assistantId for delegation",
44579
+ schema: listSchema
44580
+ })
44581
+ ]
44582
+ });
44583
+ }
44584
+ var projectRoomPlugin = {
44585
+ meta: {
44586
+ type: "project_room",
44587
+ category: "assistant",
44588
+ name: "Project Room",
44589
+ description: "Trusted Project Room posting and active roster tools",
44590
+ tools: [
44591
+ { name: "post_room_message", description: "Post to the current trusted Project Room" },
44592
+ { name: "list_room_roster", description: "List active Agents in the current trusted Project Room" }
44593
+ ],
44594
+ configSchema: { type: "object", properties: {}, additionalProperties: false },
44595
+ defaultConfig: {}
44596
+ },
44597
+ middleware: () => createProjectRoomMiddleware()
44598
+ };
44599
+
44522
44600
  // src/plugin/BuiltinPlugins.ts
44523
44601
  var BUILTIN_PLUGINS = [
44524
44602
  filesystemPlugin,