@axiom-lattice/core 10.1.0 → 11.0.0

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
@@ -1694,6 +1694,7 @@ __export(index_exports, {
1694
1694
  InMemoryProjectRoomMessageStore: () => InMemoryProjectRoomMessageStore,
1695
1695
  InMemoryProjectRoomReadStateStore: () => InMemoryProjectRoomReadStateStore,
1696
1696
  InMemoryProjectRoomStore: () => InMemoryProjectRoomStore,
1697
+ InMemoryProjectStore: () => InMemoryProjectStore,
1697
1698
  InMemorySharedResourceStore: () => InMemorySharedResourceStore,
1698
1699
  InMemoryStore: () => InMemoryStore,
1699
1700
  InMemoryTaskStore: () => InMemoryTaskStore,
@@ -1997,6 +1998,7 @@ __export(index_exports, {
1997
1998
  isValidSkillName: () => isValidSkillName,
1998
1999
  jsonSchemaToZod: () => jsonSchemaToZod,
1999
2000
  listCollectionEntries: () => listCollectionEntries,
2001
+ listMenuGroupsSchema: () => listMenuGroupsSchema,
2000
2002
  listModelLatticesForTenant: () => listModelLatticesForTenant,
2001
2003
  listSandboxProviderTypes: () => listSandboxProviderTypes,
2002
2004
  listTenantPlugins: () => listTenantPlugins,
@@ -2038,6 +2040,7 @@ __export(index_exports, {
2038
2040
  provisionSandboxOpenClient: () => provisionSandboxOpenClient,
2039
2041
  publishCollectionChanged: () => publishCollectionChanged,
2040
2042
  publishPluginCatalogChanged: () => publishPluginCatalogChanged,
2043
+ publishTargetSchema: () => publishTargetSchema,
2041
2044
  queueLatticeManager: () => queueLatticeManager,
2042
2045
  readContextWindow: () => readContextWindow,
2043
2046
  readLoopBreakerConfig: () => readLoopBreakerConfig,
@@ -2104,7 +2107,6 @@ __export(index_exports, {
2104
2107
  setPluginDeploymentService: () => setPluginDeploymentService,
2105
2108
  setRunCancelHeartbeatFallbackObserver: () => setRunCancelHeartbeatFallbackObserver,
2106
2109
  setSandboxPluginCatalog: () => setSandboxPluginCatalog,
2107
- shareAppSchema: () => shareAppSchema,
2108
2110
  signMcpUiScope: () => signMcpUiScope,
2109
2111
  skillLatticeManager: () => skillLatticeManager,
2110
2112
  sqlDatabaseManager: () => sqlDatabaseManager,
@@ -19372,7 +19374,7 @@ var createReactAgentSchema = (schema6) => {
19372
19374
  };
19373
19375
 
19374
19376
  // src/agent_lattice/builders/ReActAgentGraphBuilder.ts
19375
- var import_langchain52 = require("langchain");
19377
+ var import_langchain53 = require("langchain");
19376
19378
 
19377
19379
  // src/middlewares/codeEvalMiddleware.ts
19378
19380
  var import_langchain39 = require("langchain");
@@ -21875,8 +21877,50 @@ function ensurePatchToolCallsMiddleware(middleware) {
21875
21877
  });
21876
21878
  }
21877
21879
 
21880
+ // src/deep_agent_new/middleware/structuredOutputCarrier.ts
21881
+ var import_langchain48 = require("langchain");
21882
+ var STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME = "structuredOutputCarrierMiddleware";
21883
+ function createStructuredOutputCarrierMiddleware() {
21884
+ return (0, import_langchain48.createMiddleware)({
21885
+ name: STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME,
21886
+ wrapModelCall: async (request, handler) => {
21887
+ const result = await handler(request);
21888
+ if (import_langchain48.AIMessage.isInstance(result)) return result;
21889
+ const structured = readStructuredOutputResult(result);
21890
+ if (!structured) return result;
21891
+ const carrier = new import_langchain48.AIMessage({ content: "" });
21892
+ carrier.structuredResponse = structured.structuredResponse;
21893
+ carrier.messages = structured.messages;
21894
+ return carrier;
21895
+ }
21896
+ });
21897
+ }
21898
+ function ensureStructuredOutputCarrierMiddleware(middleware) {
21899
+ const matches = middleware.filter(
21900
+ (candidate) => candidate.name === STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
21901
+ );
21902
+ const withoutCarrier = middleware.filter(
21903
+ (candidate) => candidate.name !== STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
21904
+ );
21905
+ const carrier = matches[0] ?? createStructuredOutputCarrierMiddleware();
21906
+ if (matches.length === 1 && middleware[middleware.length - 1] === carrier) {
21907
+ return middleware;
21908
+ }
21909
+ return [...withoutCarrier, carrier];
21910
+ }
21911
+ function readStructuredOutputResult(value) {
21912
+ if (typeof value !== "object" || value === null) return void 0;
21913
+ if (!("structuredResponse" in value)) return void 0;
21914
+ const record = value;
21915
+ if (!Array.isArray(record.messages)) return void 0;
21916
+ return {
21917
+ structuredResponse: record.structuredResponse,
21918
+ messages: record.messages
21919
+ };
21920
+ }
21921
+
21878
21922
  // src/agent_lattice/builders/commonMiddleware.ts
21879
- var import_langchain51 = require("langchain");
21923
+ var import_langchain52 = require("langchain");
21880
21924
 
21881
21925
  // src/agent_lattice/builders/CustomMiddlewareRegistry.ts
21882
21926
  var CustomMiddlewareRegistry = class {
@@ -21967,7 +22011,7 @@ function createSandboxResolver(getSandboxFromConfig) {
21967
22011
  }
21968
22012
 
21969
22013
  // src/middlewares/evalMiddleware.ts
21970
- var import_langchain48 = require("langchain");
22014
+ var import_langchain49 = require("langchain");
21971
22015
  var import_zod47 = require("zod");
21972
22016
  var import_uuid4 = require("uuid");
21973
22017
 
@@ -22216,7 +22260,7 @@ function createReadEvalTool() {
22216
22260
  verbose: import_zod47.z.boolean().optional().describe("For get_run_results \u2014 return full per-case results. Omit for a compact summary (counts + failing cases only)."),
22217
22261
  status: import_zod47.z.string().optional().describe("Filter: running|completed|failed|aborted")
22218
22262
  });
22219
- return (0, import_langchain48.tool)(
22263
+ return (0, import_langchain49.tool)(
22220
22264
  async (input, exeConfig) => {
22221
22265
  const tid = tenantId(exeConfig);
22222
22266
  if (!tid) {
@@ -22363,7 +22407,7 @@ function createManageEvalTool() {
22363
22407
  value: import_zod47.z.string().optional().describe("Response to inject (defaults: \u540C\u610F / \u62D2\u7EDD; required for canned-response)")
22364
22408
  }).optional().describe("Optional for create_case/update_case \u2014 how HITL interrupts are handled")
22365
22409
  });
22366
- return (0, import_langchain48.tool)(
22410
+ return (0, import_langchain49.tool)(
22367
22411
  async (input, exeConfig) => {
22368
22412
  const tid = tenantId(exeConfig);
22369
22413
  if (!tid) {
@@ -22506,7 +22550,7 @@ function createRunEvalTool() {
22506
22550
  sleepMs: import_zod47.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."),
22507
22551
  wait: import_zod47.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.")
22508
22552
  });
22509
- return (0, import_langchain48.tool)(
22553
+ return (0, import_langchain49.tool)(
22510
22554
  async (input, exeConfig) => {
22511
22555
  const tid = tenantId(exeConfig);
22512
22556
  if (!tid) {
@@ -22635,7 +22679,7 @@ var evalPlugin = {
22635
22679
  defaultConfig: {}
22636
22680
  },
22637
22681
  skills: EVAL_SKILLS,
22638
- middleware: () => (0, import_langchain48.createMiddleware)({
22682
+ middleware: () => (0, import_langchain49.createMiddleware)({
22639
22683
  name: "EvalMiddleware",
22640
22684
  tools: [createReadEvalTool(), createManageEvalTool(), createRunEvalTool()]
22641
22685
  })
@@ -23488,7 +23532,7 @@ function validateSandboxPluginManifest(args) {
23488
23532
  }
23489
23533
 
23490
23534
  // src/sandbox_plugin/SandboxPluginCompiler.ts
23491
- var import_langchain49 = require("langchain");
23535
+ var import_langchain50 = require("langchain");
23492
23536
 
23493
23537
  // src/connection/PluginConnectionResolver.ts
23494
23538
  async function resolvePluginConnections(type, config, scope) {
@@ -23805,7 +23849,7 @@ function compileSandboxPlugin(args) {
23805
23849
  },
23806
23850
  middleware: (config) => {
23807
23851
  const tools = manifest.tools.map(
23808
- (t) => (0, import_langchain49.tool)(
23852
+ (t) => (0, import_langchain50.tool)(
23809
23853
  async (input, exeConfig) => {
23810
23854
  const runConfig = sandboxRunConfigFrom(exeConfig);
23811
23855
  const resolution = await resolveConnection(manifest.type, config, runConfig);
@@ -23850,7 +23894,7 @@ function compileSandboxPlugin(args) {
23850
23894
  { name: t.name, description: t.description, schema: jsonSchemaToZod(t.schema) }
23851
23895
  )
23852
23896
  );
23853
- return (0, import_langchain49.createMiddleware)({ name: `SandboxPlugin:${manifest.type}`, tools });
23897
+ return (0, import_langchain50.createMiddleware)({ name: `SandboxPlugin:${manifest.type}`, tools });
23854
23898
  },
23855
23899
  skills: manifest.skills,
23856
23900
  agents: manifest.agents
@@ -24727,7 +24771,7 @@ var CapabilityToolRegistry = class {
24727
24771
 
24728
24772
  // src/middlewares/capabilityGuardMiddleware.ts
24729
24773
  var import_messages4 = require("@langchain/core/messages");
24730
- var import_langchain50 = require("langchain");
24774
+ var import_langchain51 = require("langchain");
24731
24775
  function isRecord11(value) {
24732
24776
  return typeof value === "object" && value !== null && !Array.isArray(value);
24733
24777
  }
@@ -24793,7 +24837,7 @@ function denialMessage(toolCall, denial) {
24793
24837
  });
24794
24838
  }
24795
24839
  function createCapabilityGuardMiddleware(registry4) {
24796
- return (0, import_langchain50.createMiddleware)({
24840
+ return (0, import_langchain51.createMiddleware)({
24797
24841
  name: "CapabilityGuardMiddleware",
24798
24842
  wrapToolCall: async (request, handler) => {
24799
24843
  const toolName2 = request.toolCall.name;
@@ -25040,7 +25084,7 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
25040
25084
  }));
25041
25085
  if (model) {
25042
25086
  middlewares.push(
25043
- (0, import_langchain51.summarizationMiddleware)({
25087
+ (0, import_langchain52.summarizationMiddleware)({
25044
25088
  model,
25045
25089
  trigger: { tokens: resolveSummarizationTriggerTokens(model) },
25046
25090
  keep: { messages: 6 }
@@ -25162,7 +25206,7 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
25162
25206
  break;
25163
25207
  }
25164
25208
  }
25165
- return middlewares;
25209
+ return ensureStructuredOutputCarrierMiddleware(middlewares);
25166
25210
  }
25167
25211
 
25168
25212
  // src/deep_agent_new/backends/sandboxFiles.ts
@@ -25391,7 +25435,7 @@ var ReActAgentGraphBuilder = class {
25391
25435
  const middlewareConfigs = params.middleware || [];
25392
25436
  const filesystemBackend = createFilesystemBackendFactory(middlewareConfigs);
25393
25437
  const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend, void 0, params.tenantId, params.model);
25394
- return (0, import_langchain52.createAgent)({
25438
+ return (0, import_langchain53.createAgent)({
25395
25439
  model: params.model,
25396
25440
  tools,
25397
25441
  systemPrompt: params.prompt,
@@ -25405,11 +25449,11 @@ var ReActAgentGraphBuilder = class {
25405
25449
  };
25406
25450
 
25407
25451
  // src/deep_agent_new/agent.ts
25408
- var import_langchain58 = require("langchain");
25452
+ var import_langchain59 = require("langchain");
25409
25453
 
25410
25454
  // src/deep_agent_new/middleware/subagents.ts
25411
25455
  var import_v32 = require("zod/v3");
25412
- var import_langchain54 = require("langchain");
25456
+ var import_langchain55 = require("langchain");
25413
25457
  var import_langgraph7 = require("@langchain/langgraph");
25414
25458
 
25415
25459
  // src/agent_worker/agent_worker_graph.ts
@@ -26101,7 +26145,7 @@ function normalizeAgentInterrupts(state, threadId) {
26101
26145
  }
26102
26146
 
26103
26147
  // src/services/Agent.ts
26104
- var import_langchain53 = require("langchain");
26148
+ var import_langchain54 = require("langchain");
26105
26149
 
26106
26150
  // src/chunk_buffer_lattice/types.ts
26107
26151
  var ThreadEndError = class extends Error {
@@ -28879,16 +28923,16 @@ function executeRunInputMessages(input, fallbackMessageId) {
28879
28923
  };
28880
28924
  switch (message.role) {
28881
28925
  case "system":
28882
- return new import_langchain53.SystemMessage(fields);
28926
+ return new import_langchain54.SystemMessage(fields);
28883
28927
  case "assistant":
28884
- return new import_langchain53.AIMessage(fields);
28928
+ return new import_langchain54.AIMessage(fields);
28885
28929
  case "tool":
28886
- return new import_langchain53.ToolMessage({
28930
+ return new import_langchain54.ToolMessage({
28887
28931
  ...fields,
28888
28932
  tool_call_id: typeof message.metadata?.tool_call_id === "string" ? message.metadata.tool_call_id : ""
28889
28933
  });
28890
28934
  case "human":
28891
- return new import_langchain53.HumanMessage(fields);
28935
+ return new import_langchain54.HumanMessage(fields);
28892
28936
  }
28893
28937
  });
28894
28938
  }
@@ -28896,7 +28940,7 @@ function executeRunInputMessages(input, fallbackMessageId) {
28896
28940
  throw new Error("Either input.messages or input.message must be provided");
28897
28941
  }
28898
28942
  const id = typeof input.id === "string" && input.id.length > 0 ? input.id : fallbackMessageId;
28899
- return [new import_langchain53.HumanMessage({ id, content: input.message })];
28943
+ return [new import_langchain54.HumanMessage({ id, content: input.message })];
28900
28944
  }
28901
28945
  function statusFromSnapshot(state) {
28902
28946
  if (!isPlainRecord2(state)) return "error" /* ERROR */;
@@ -29735,14 +29779,14 @@ var Agent = class {
29735
29779
  queuedInputMessages(content) {
29736
29780
  const messages = content.queueMessage.input.messages;
29737
29781
  if (!Array.isArray(messages) || messages.length === 0) {
29738
- return [new import_langchain53.HumanMessage({ id: content.id, content: content.message })];
29782
+ return [new import_langchain54.HumanMessage({ id: content.id, content: content.message })];
29739
29783
  }
29740
29784
  const invalid = messages.filter((message) => !isMessageContent(message.content));
29741
29785
  if (invalid.length > 0) {
29742
29786
  console.error(
29743
29787
  `[Agent] Dropping ${invalid.length} queued message(s) with invalid serialized content for queued message ${content.id}; falling back to stored display content`
29744
29788
  );
29745
- return [new import_langchain53.HumanMessage({ id: content.id, content: content.message })];
29789
+ return [new import_langchain54.HumanMessage({ id: content.id, content: content.message })];
29746
29790
  }
29747
29791
  return messages.map((message) => {
29748
29792
  const fields = {
@@ -29752,16 +29796,16 @@ var Agent = class {
29752
29796
  };
29753
29797
  switch (message.role) {
29754
29798
  case "system":
29755
- return new import_langchain53.SystemMessage(fields);
29799
+ return new import_langchain54.SystemMessage(fields);
29756
29800
  case "assistant":
29757
- return new import_langchain53.AIMessage(fields);
29801
+ return new import_langchain54.AIMessage(fields);
29758
29802
  case "tool":
29759
- return new import_langchain53.ToolMessage({
29803
+ return new import_langchain54.ToolMessage({
29760
29804
  ...fields,
29761
29805
  tool_call_id: typeof message.metadata?.tool_call_id === "string" ? message.metadata.tool_call_id : ""
29762
29806
  });
29763
29807
  case "human":
29764
- return new import_langchain53.HumanMessage(fields);
29808
+ return new import_langchain54.HumanMessage(fields);
29765
29809
  }
29766
29810
  });
29767
29811
  }
@@ -29904,7 +29948,7 @@ var Agent = class {
29904
29948
  this.validateMessageInput(queueMessage);
29905
29949
  const input = {
29906
29950
  ...queueMessage.input,
29907
- ...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain53.HumanMessage({ id: (0, import_uuid5.v4)(), content: queueMessage.input.message })] } : {}
29951
+ ...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain54.HumanMessage({ id: (0, import_uuid5.v4)(), content: queueMessage.input.message })] } : {}
29908
29952
  };
29909
29953
  const recoveryContext = await this.interruptedCommandExecutionContext(queueMessage.command);
29910
29954
  const inputMessage = {
@@ -29938,7 +29982,7 @@ var Agent = class {
29938
29982
  this.validateMessageInput(queueMessage);
29939
29983
  const input = {
29940
29984
  ...queueMessage.input,
29941
- ...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain53.HumanMessage({ id: (0, import_uuid5.v4)(), content: queueMessage.input.message })] } : {}
29985
+ ...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain54.HumanMessage({ id: (0, import_uuid5.v4)(), content: queueMessage.input.message })] } : {}
29942
29986
  };
29943
29987
  const recoveryContext = options?.allowUnmanagedCommand ? await this.unmanagedCommandExecutionContext(queueMessage.command) : await this.interruptedCommandExecutionContext(queueMessage.command);
29944
29988
  const inputMessage = { ...queueMessage, input, trusted_run_context: recoveryContext?.trustedRunContext };
@@ -31220,7 +31264,7 @@ var Agent = class {
31220
31264
  async getCurrentMessages() {
31221
31265
  const state = await this.getCurrentState();
31222
31266
  const messages = state.values.messages || [];
31223
- const filteredMessages = (0, import_langchain53.filterMessages)(messages, {
31267
+ const filteredMessages = (0, import_langchain54.filterMessages)(messages, {
31224
31268
  includeTypes: ["ai", "human", "tool"]
31225
31269
  //["human", "ai", "tool"],
31226
31270
  });
@@ -32146,13 +32190,13 @@ var DEFAULT_GENERAL_PURPOSE_DESCRIPTION = "General-purpose agent for researching
32146
32190
  function createGeneralPurposeAgent(options) {
32147
32191
  const middleware = ensurePatchToolCallsMiddleware([...options.middleware]);
32148
32192
  if (options.interruptOn) {
32149
- middleware.push((0, import_langchain54.humanInTheLoopMiddleware)({ interruptOn: options.interruptOn }));
32193
+ middleware.push((0, import_langchain55.humanInTheLoopMiddleware)({ interruptOn: options.interruptOn }));
32150
32194
  }
32151
- return (0, import_langchain54.createAgent)({
32195
+ return (0, import_langchain55.createAgent)({
32152
32196
  model: options.model,
32153
32197
  systemPrompt: DEFAULT_SUBAGENT_PROMPT,
32154
32198
  tools: options.tools,
32155
- middleware,
32199
+ middleware: ensureStructuredOutputCarrierMiddleware(middleware),
32156
32200
  stateSchema: withRunGovernanceStateSchema(withToolCallLimitStateSchema()),
32157
32201
  checkpointer: getCheckpointSaver("default"),
32158
32202
  name: "general-purpose"
@@ -32315,7 +32359,7 @@ function returnCommandWithStateUpdate(result, toolCallId) {
32315
32359
  update: {
32316
32360
  ...stateUpdate,
32317
32361
  messages: [
32318
- new import_langchain54.ToolMessage({
32362
+ new import_langchain55.ToolMessage({
32319
32363
  content: lastMessage?.content || "Task Failed to complete",
32320
32364
  tool_call_id: toolCallId,
32321
32365
  name: "task"
@@ -32359,12 +32403,12 @@ function getSubagents(options) {
32359
32403
  );
32360
32404
  const interruptOn = agentParams.interruptOn || defaultInterruptOn;
32361
32405
  if (interruptOn)
32362
- middleware.push((0, import_langchain54.humanInTheLoopMiddleware)({ interruptOn }));
32363
- agents[agentParams.key] = (0, import_langchain54.createAgent)({
32406
+ middleware.push((0, import_langchain55.humanInTheLoopMiddleware)({ interruptOn }));
32407
+ agents[agentParams.key] = (0, import_langchain55.createAgent)({
32364
32408
  model: agentParams.model ?? defaultModel,
32365
32409
  systemPrompt: agentParams.systemPrompt,
32366
32410
  tools: agentParams.tools ?? defaultTools,
32367
- middleware,
32411
+ middleware: ensureStructuredOutputCarrierMiddleware(middleware),
32368
32412
  stateSchema: withRunGovernanceStateSchema(withToolCallLimitStateSchema()),
32369
32413
  checkpointer: getCheckpointSaver("default")
32370
32414
  });
@@ -32391,7 +32435,7 @@ function createTaskTool(options) {
32391
32435
  generalPurposeAgent
32392
32436
  });
32393
32437
  const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
32394
- return (0, import_langchain54.tool)(
32438
+ return (0, import_langchain55.tool)(
32395
32439
  async (input, config) => {
32396
32440
  const { description, subagent_type } = input;
32397
32441
  if (input.taskId) {
@@ -32405,7 +32449,7 @@ function createTaskTool(options) {
32405
32449
  return new import_langgraph7.Command({
32406
32450
  update: {
32407
32451
  messages: [
32408
- new import_langchain54.ToolMessage({
32452
+ new import_langchain55.ToolMessage({
32409
32453
  content: JSON.stringify({
32410
32454
  success: false,
32411
32455
  code: "TASK_MIDDLEWARE_REQUIRED",
@@ -32485,7 +32529,7 @@ You are executing a persistent task (ID: ${input.taskId}). Use manage_task.updat
32485
32529
  return new import_langgraph7.Command({
32486
32530
  update: {
32487
32531
  messages: [
32488
- new import_langchain54.ToolMessage({
32532
+ new import_langchain55.ToolMessage({
32489
32533
  content: error instanceof Error ? error.message : "Task Failed to complete",
32490
32534
  tool_call_id: config.toolCall.id,
32491
32535
  name: "task"
@@ -32534,7 +32578,7 @@ function createSubAgentMiddleware(options) {
32534
32578
  });
32535
32579
  const allTools = [taskTool];
32536
32580
  const effectiveSystemPrompt = systemPrompt;
32537
- return (0, import_langchain54.createMiddleware)({
32581
+ return (0, import_langchain55.createMiddleware)({
32538
32582
  name: "subAgentMiddleware",
32539
32583
  tools: allTools,
32540
32584
  wrapModelCall: async (request, handler) => {
@@ -32554,7 +32598,7 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
32554
32598
  }
32555
32599
 
32556
32600
  // src/deep_agent_new/middleware/date.ts
32557
- var import_langchain55 = require("langchain");
32601
+ var import_langchain56 = require("langchain");
32558
32602
  var import_zod50 = require("zod");
32559
32603
  function formatCurrentDate(timezone = "UTC") {
32560
32604
  const now = /* @__PURE__ */ new Date();
@@ -32583,10 +32627,10 @@ function generateDateContext(timezone = "UTC") {
32583
32627
  function createDateMiddleware(options = {}) {
32584
32628
  const timezone = options.timezone || "UTC";
32585
32629
  const dateContext = generateDateContext(timezone);
32586
- return (0, import_langchain55.createMiddleware)({
32630
+ return (0, import_langchain56.createMiddleware)({
32587
32631
  name: "DateMiddleware",
32588
32632
  tools: [
32589
- (0, import_langchain55.tool)(
32633
+ (0, import_langchain56.tool)(
32590
32634
  async () => {
32591
32635
  const now = /* @__PURE__ */ new Date();
32592
32636
  let validTimezone = timezone;
@@ -32682,7 +32726,7 @@ var datePlugin = {
32682
32726
  };
32683
32727
 
32684
32728
  // src/deep_agent_new/middleware/scheduler.ts
32685
- var import_langchain56 = require("langchain");
32729
+ var import_langchain57 = require("langchain");
32686
32730
  var import_zod51 = require("zod");
32687
32731
  var import_uuid6 = require("uuid");
32688
32732
  var import_protocols23 = require("@axiom-lattice/protocols");
@@ -32764,10 +32808,10 @@ function registerAgentAddMessageHandler() {
32764
32808
  function createSchedulerMiddleware(options = {}) {
32765
32809
  const defaultMaxRetries = options.defaultMaxRetries ?? 0;
32766
32810
  registerAgentAddMessageHandler();
32767
- return (0, import_langchain56.createMiddleware)({
32811
+ return (0, import_langchain57.createMiddleware)({
32768
32812
  name: "SchedulerMiddleware",
32769
32813
  tools: [
32770
- (0, import_langchain56.tool)(
32814
+ (0, import_langchain57.tool)(
32771
32815
  async (input, config) => {
32772
32816
  const runConfig = getRunConfig(config);
32773
32817
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
@@ -32802,7 +32846,7 @@ function createSchedulerMiddleware(options = {}) {
32802
32846
  })
32803
32847
  }
32804
32848
  ),
32805
- (0, import_langchain56.tool)(
32849
+ (0, import_langchain57.tool)(
32806
32850
  async (input, config) => {
32807
32851
  const runConfig = getRunConfig(config);
32808
32852
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
@@ -32837,7 +32881,7 @@ function createSchedulerMiddleware(options = {}) {
32837
32881
  })
32838
32882
  }
32839
32883
  ),
32840
- (0, import_langchain56.tool)(
32884
+ (0, import_langchain57.tool)(
32841
32885
  async (input, config) => {
32842
32886
  const runConfig = getRunConfig(config);
32843
32887
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
@@ -32881,7 +32925,7 @@ function createSchedulerMiddleware(options = {}) {
32881
32925
  })
32882
32926
  }
32883
32927
  ),
32884
- (0, import_langchain56.tool)(
32928
+ (0, import_langchain57.tool)(
32885
32929
  async (input) => {
32886
32930
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
32887
32931
  const success = await scheduleLattice.client.cancel(input.taskId);
@@ -32895,7 +32939,7 @@ function createSchedulerMiddleware(options = {}) {
32895
32939
  })
32896
32940
  }
32897
32941
  ),
32898
- (0, import_langchain56.tool)(
32942
+ (0, import_langchain57.tool)(
32899
32943
  async (input, config) => {
32900
32944
  const runConfig = getRunConfig(config);
32901
32945
  const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
@@ -34179,7 +34223,7 @@ var MemoryBackend = class {
34179
34223
  // src/deep_agent_new/middleware/todos.ts
34180
34224
  var import_langgraph8 = require("@langchain/langgraph");
34181
34225
  var import_zod52 = require("zod");
34182
- var import_langchain57 = require("langchain");
34226
+ var import_langchain58 = require("langchain");
34183
34227
  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.
34184
34228
  It also helps the user understand the progress of the task and overall progress of their requests.
34185
34229
  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.
@@ -34413,13 +34457,13 @@ var TodoSchema = import_zod52.z.object({
34413
34457
  });
34414
34458
  var stateSchema = import_zod52.z.object({ todos: import_zod52.z.array(TodoSchema).default([]) });
34415
34459
  function todoListMiddleware(options) {
34416
- const writeTodos = (0, import_langchain57.tool)(
34460
+ const writeTodos = (0, import_langchain58.tool)(
34417
34461
  ({ todos }, config) => {
34418
34462
  return new import_langgraph8.Command({
34419
34463
  update: {
34420
34464
  todos,
34421
34465
  messages: [
34422
- new import_langchain57.ToolMessage({
34466
+ new import_langchain58.ToolMessage({
34423
34467
  content: genUIMarkdown("todo_list", todos),
34424
34468
  tool_call_id: config.toolCall?.id
34425
34469
  })
@@ -34435,7 +34479,7 @@ function todoListMiddleware(options) {
34435
34479
  })
34436
34480
  }
34437
34481
  );
34438
- return (0, import_langchain57.createMiddleware)({
34482
+ return (0, import_langchain58.createMiddleware)({
34439
34483
  name: "todoListMiddleware",
34440
34484
  stateSchema,
34441
34485
  tools: [writeTodos],
@@ -34482,8 +34526,8 @@ function createDeepAgent(params = {}) {
34482
34526
 
34483
34527
  ${BASE_PROMPT}` : BASE_PROMPT;
34484
34528
  const filesystemBackend = backend ? backend : async (config) => new StateBackend(config);
34485
- const postDelegationMiddleware = interruptOn ? [(0, import_langchain58.humanInTheLoopMiddleware)({ interruptOn })] : [];
34486
- const middleware = ensurePatchToolCallsMiddleware(assembleDeepAgentMiddleware(
34529
+ const postDelegationMiddleware = interruptOn ? [(0, import_langchain59.humanInTheLoopMiddleware)({ interruptOn })] : [];
34530
+ const middleware = ensureStructuredOutputCarrierMiddleware(ensurePatchToolCallsMiddleware(assembleDeepAgentMiddleware(
34487
34531
  customMiddleware,
34488
34532
  [
34489
34533
  // Provides todo list management capabilities for tracking tasks
@@ -34504,7 +34548,7 @@ ${BASE_PROMPT}` : BASE_PROMPT;
34504
34548
  backend: filesystemBackend
34505
34549
  }),
34506
34550
  // Subagent middleware: Anthropic prompt caching for improved performance
34507
- (0, import_langchain58.anthropicPromptCachingMiddleware)({
34551
+ (0, import_langchain59.anthropicPromptCachingMiddleware)({
34508
34552
  unsupportedModelBehavior: "ignore"
34509
34553
  }),
34510
34554
  ...customMiddleware
@@ -34519,8 +34563,8 @@ ${BASE_PROMPT}` : BASE_PROMPT;
34519
34563
  // unsupportedModelBehavior: "ignore",
34520
34564
  // })
34521
34565
  postDelegationMiddleware
34522
- ));
34523
- return (0, import_langchain58.createAgent)({
34566
+ )));
34567
+ return (0, import_langchain59.createAgent)({
34524
34568
  model,
34525
34569
  systemPrompt: finalSystemPrompt,
34526
34570
  tools,
@@ -34934,7 +34978,13 @@ var A2ARemoteClient = _A2ARemoteClient;
34934
34978
  // src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
34935
34979
  var import_protocols25 = require("@axiom-lattice/protocols");
34936
34980
  init_MemoryLatticeManager();
34981
+ function resolveA2ARemoteContextId(assistantKey, threadId) {
34982
+ return threadId ? `a2a-remote:${assistantKey}:${threadId}` : void 0;
34983
+ }
34937
34984
  var RemoteAgentGraphBuilder = class {
34985
+ constructor(deps = {}) {
34986
+ this.deps = deps;
34987
+ }
34938
34988
  async build(agentLattice, params) {
34939
34989
  if (agentLattice.config.type !== import_protocols25.AgentType.A2A_REMOTE) {
34940
34990
  throw new Error(
@@ -34942,7 +34992,7 @@ var RemoteAgentGraphBuilder = class {
34942
34992
  );
34943
34993
  }
34944
34994
  const config = agentLattice.config;
34945
- const client = new A2ARemoteClient({
34995
+ const client = this.deps.createClient?.(config) ?? new A2ARemoteClient({
34946
34996
  agentCardUrl: config.agentCardUrl,
34947
34997
  apiKey: config.apiKey,
34948
34998
  timeout: config.timeout
@@ -34958,24 +35008,18 @@ var RemoteAgentGraphBuilder = class {
34958
35008
  ]
34959
35009
  };
34960
35010
  }
34961
- try {
34962
- const fullPrompt = params.prompt ? `${params.prompt}
35011
+ const fullPrompt = params.prompt ? `${params.prompt}
34963
35012
 
34964
35013
  User request:
34965
35014
  ${text}` : text;
34966
- const threadId = langGraphConfig?.configurable?.thread_id;
34967
- const response = await client.sendMessage(fullPrompt, threadId);
34968
- return {
34969
- messages: [new import_messages5.AIMessage(response)]
34970
- };
34971
- } catch (error) {
34972
- const msg = error.message ?? String(error);
34973
- return {
34974
- messages: [
34975
- new import_messages5.AIMessage(`Remote A2A agent error: ${msg}`)
34976
- ]
34977
- };
34978
- }
35015
+ const threadId = langGraphConfig?.configurable?.thread_id;
35016
+ const response = await client.sendMessage(
35017
+ fullPrompt,
35018
+ resolveA2ARemoteContextId(config.key, threadId)
35019
+ );
35020
+ return {
35021
+ messages: [new import_messages5.AIMessage(response)]
35022
+ };
34979
35023
  };
34980
35024
  const workflow = new import_langgraph9.StateGraph(import_langgraph9.MessagesAnnotation).addNode("remote_call", remoteCallNode).addEdge("__start__", "remote_call").addEdge("remote_call", "__end__");
34981
35025
  return workflow.compile({ checkpointer: getCheckpointSaver("default") });
@@ -34999,7 +35043,7 @@ function extractLastHumanMessage(messages) {
34999
35043
  }
35000
35044
 
35001
35045
  // src/agent_lattice/builders/WorkflowAgentGraphBuilder.ts
35002
- var import_langchain59 = require("langchain");
35046
+ var import_langchain60 = require("langchain");
35003
35047
  init_MemoryLatticeManager();
35004
35048
  var import_protocols26 = require("@axiom-lattice/protocols");
35005
35049
  init_compile();
@@ -35064,12 +35108,13 @@ var WorkflowAgentGraphBuilder = class {
35064
35108
  }
35065
35109
  ], void 0, false, void 0, params.model);
35066
35110
  const preservedMiddlewareNames = [
35067
- "patchToolCallsMiddleware"
35111
+ "patchToolCallsMiddleware",
35112
+ STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
35068
35113
  ];
35069
35114
  const noWrapMiddlewares = stripWrapModelCallHook(middlewares, preservedMiddlewareNames);
35070
35115
  const noWrapAskMiddlewares = stripWrapModelCallHook(askMiddlewares, preservedMiddlewareNames);
35071
35116
  console.log(`[WF BUILDER] building default agent | toolCount=${tools.length} | middlewareCount=${middlewares.length}`);
35072
- const defaultAgent = (0, import_langchain59.createAgent)({
35117
+ const defaultAgent = (0, import_langchain60.createAgent)({
35073
35118
  model: params.model,
35074
35119
  tools,
35075
35120
  systemPrompt: buildStepSystemPrompt(false, params.prompt),
@@ -35091,7 +35136,7 @@ var WorkflowAgentGraphBuilder = class {
35091
35136
  console.log(`[WF BUILDER] resolveAgent: cacheKey=${key5.slice(0, 80)}... | cached=${agentCache.has(key5)}`);
35092
35137
  if (!agentCache.has(key5)) {
35093
35138
  console.log(`[WF BUILDER] creating ${isAsk ? "ask" : "agent"} with responseFormat`);
35094
- const agent = (0, import_langchain59.createAgent)({
35139
+ const agent = (0, import_langchain60.createAgent)({
35095
35140
  model: params.model,
35096
35141
  tools,
35097
35142
  systemPrompt: buildStepSystemPrompt(isAsk, params.prompt),
@@ -35109,7 +35154,7 @@ var WorkflowAgentGraphBuilder = class {
35109
35154
  const key5 = "ask:default";
35110
35155
  if (!agentCache.has(key5)) {
35111
35156
  console.log(`[WF BUILDER] creating ask default agent`);
35112
- const agent = (0, import_langchain59.createAgent)({
35157
+ const agent = (0, import_langchain60.createAgent)({
35113
35158
  model: params.model,
35114
35159
  tools,
35115
35160
  systemPrompt: buildStepSystemPrompt(true, params.prompt),
@@ -40876,12 +40921,23 @@ var MAX_MCP_APP_PAYLOAD_BYTES = 256 * 1024;
40876
40921
  function generateToken() {
40877
40922
  return (0, import_crypto7.randomBytes)(TOKEN_BYTES).toString("base64url");
40878
40923
  }
40924
+ function normalizeShareResourcePath(raw) {
40925
+ const withoutLeadingSlash = raw.startsWith("/") ? raw.slice(1) : raw;
40926
+ const withoutProject = withoutLeadingSlash.replace(/^project(?:\/|$)/, "");
40927
+ const segments = withoutProject.split("/");
40928
+ if (segments.some((segment) => segment === "..")) return null;
40929
+ const cleaned = segments.filter(
40930
+ (segment) => segment !== "" && segment !== "."
40931
+ );
40932
+ if (cleaned.length === 0) return null;
40933
+ return cleaned.join("/");
40934
+ }
40879
40935
  function createSharePayload(tenantId2, workspaceId, projectId, userId, request) {
40880
- const resourcePath = (request.resourcePath || "").replace(/^\/?project\/?/, "").replace(/\/+$/, "");
40881
- if (!resourcePath || resourcePath === "/") {
40882
- if (request.visibility !== "internal") {
40883
- throw new Error("Cannot share project root \u2014 share a subdirectory or file instead");
40884
- }
40936
+ const resourcePath = normalizeShareResourcePath(request.resourcePath || "");
40937
+ if (resourcePath === null) {
40938
+ throw new Error(
40939
+ "Invalid resource path \u2014 share a file or subdirectory inside the project"
40940
+ );
40885
40941
  }
40886
40942
  return {
40887
40943
  kind: "file",
@@ -47159,11 +47215,11 @@ async function assertSafeUpstreamUrl(raw) {
47159
47215
  }
47160
47216
 
47161
47217
  // src/middlewares/skillMiddleware.ts
47162
- var import_langchain64 = require("langchain");
47218
+ var import_langchain65 = require("langchain");
47163
47219
 
47164
47220
  // src/tool_lattice/skill/load_skills.ts
47165
47221
  var import_zod54 = __toESM(require("zod"));
47166
- var import_langchain60 = require("langchain");
47222
+ var import_langchain61 = require("langchain");
47167
47223
  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.`;
47168
47224
  function getSandboxFromExeConfig(_exe_config) {
47169
47225
  const runConfig = _exe_config?.configurable?.runConfig || {};
@@ -47178,7 +47234,7 @@ function getSandboxFromExeConfig(_exe_config) {
47178
47234
  });
47179
47235
  }
47180
47236
  var createLoadSkillsTool = ({ skills, readAll, pluginSkills, pluginSkillOwners } = {}) => {
47181
- return (0, import_langchain60.tool)(
47237
+ return (0, import_langchain61.tool)(
47182
47238
  async (_input, _exe_config) => {
47183
47239
  const allSkills = [];
47184
47240
  try {
@@ -47255,7 +47311,7 @@ function isSkillAllowed(skillName, staticSkills, staticReadAll) {
47255
47311
 
47256
47312
  // src/tool_lattice/skill/load_skill_content.ts
47257
47313
  var import_zod55 = __toESM(require("zod"));
47258
- var import_langchain61 = require("langchain");
47314
+ var import_langchain62 = require("langchain");
47259
47315
 
47260
47316
  // src/sandbox_plugin/pluginSkillResolution.ts
47261
47317
  async function resolveTenantPluginSkill(tenantId2, owner3, skillName) {
@@ -47318,7 +47374,7 @@ function getSandboxFromExeConfig2(_exe_config) {
47318
47374
  var createLoadSkillContentTool = (pluginSkills, pluginSkillOwnersOrStaticSelection, staticSelection) => {
47319
47375
  const pluginSkillOwners = staticSelection === void 0 ? isStaticSkillSelection(pluginSkillOwnersOrStaticSelection) ? void 0 : pluginSkillOwnersOrStaticSelection : pluginSkillOwnersOrStaticSelection;
47320
47376
  const effectiveStaticSelection = isStaticSkillSelection(pluginSkillOwnersOrStaticSelection) ? pluginSkillOwnersOrStaticSelection : staticSelection ?? {};
47321
- return (0, import_langchain61.tool)(
47377
+ return (0, import_langchain62.tool)(
47322
47378
  async (input, _exe_config) => {
47323
47379
  try {
47324
47380
  if (!isSkillAllowed2(input.skill_name, effectiveStaticSelection)) {
@@ -47425,7 +47481,7 @@ function isSkillAllowed2(skillName, staticSelection) {
47425
47481
 
47426
47482
  // src/tool_lattice/skill/load_skill_resource.ts
47427
47483
  var import_zod56 = __toESM(require("zod"));
47428
- var import_langchain62 = require("langchain");
47484
+ var import_langchain63 = require("langchain");
47429
47485
  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.`;
47430
47486
  function getSandboxFromExeConfig3(_exe_config) {
47431
47487
  const runConfig = _exe_config?.configurable?.runConfig || {};
@@ -47440,7 +47496,7 @@ function getSandboxFromExeConfig3(_exe_config) {
47440
47496
  });
47441
47497
  }
47442
47498
  var createLoadSkillResourceTool = (pluginSkills, pluginSkillOwners) => {
47443
- return (0, import_langchain62.tool)(
47499
+ return (0, import_langchain63.tool)(
47444
47500
  async (input, _exe_config) => {
47445
47501
  try {
47446
47502
  validateRelativePath(input.skill_name, "skill");
@@ -47478,7 +47534,7 @@ var createLoadSkillResourceTool = (pluginSkills, pluginSkillOwners) => {
47478
47534
 
47479
47535
  // src/tool_lattice/skill/delete_skill.ts
47480
47536
  var import_zod57 = __toESM(require("zod"));
47481
- var import_langchain63 = require("langchain");
47537
+ var import_langchain64 = require("langchain");
47482
47538
  var DELETE_SKILL_DESCRIPTION = `
47483
47539
  Delete a skill by name from the skill system.
47484
47540
  This permanently removes the skill and its SKILL.md file.
@@ -47505,7 +47561,7 @@ function validateSkillName3(name) {
47505
47561
  }
47506
47562
  }
47507
47563
  var createDeleteSkillTool = (staticSelection = {}) => {
47508
- return (0, import_langchain63.tool)(
47564
+ return (0, import_langchain64.tool)(
47509
47565
  async (input, _exe_config) => {
47510
47566
  try {
47511
47567
  validateSkillName3(input.skill_name);
@@ -47562,7 +47618,7 @@ function createSkillMiddleware(params = {}) {
47562
47618
  } = params;
47563
47619
  const skills = params.skills;
47564
47620
  let latestSkills = [];
47565
- return (0, import_langchain64.createMiddleware)({
47621
+ return (0, import_langchain65.createMiddleware)({
47566
47622
  name: "skillMiddleware",
47567
47623
  contextSchema,
47568
47624
  tools: [
@@ -47712,11 +47768,11 @@ var skillPlugin = {
47712
47768
  };
47713
47769
 
47714
47770
  // src/middlewares/collectionMiddleware.ts
47715
- var import_langchain75 = require("langchain");
47771
+ var import_langchain76 = require("langchain");
47716
47772
 
47717
47773
  // src/tool_lattice/collection/list_collections.ts
47718
47774
  var import_zod58 = __toESM(require("zod"));
47719
- var import_langchain65 = require("langchain");
47775
+ var import_langchain66 = require("langchain");
47720
47776
 
47721
47777
  // src/tool_lattice/collection/utils.ts
47722
47778
  function getEffectiveCollectionScope(exeConfig, staticScope) {
@@ -47739,7 +47795,7 @@ var createListCollectionsTool = ({
47739
47795
  collectionKeys,
47740
47796
  connectAll
47741
47797
  }) => {
47742
- return (0, import_langchain65.tool)(
47798
+ return (0, import_langchain66.tool)(
47743
47799
  async (_input, _exeConfig) => {
47744
47800
  try {
47745
47801
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -47781,7 +47837,7 @@ var createListCollectionsTool = ({
47781
47837
 
47782
47838
  // src/tool_lattice/collection/search_collection.ts
47783
47839
  var import_zod59 = __toESM(require("zod"));
47784
- var import_langchain66 = require("langchain");
47840
+ var import_langchain67 = require("langchain");
47785
47841
  var import_protocols42 = require("@axiom-lattice/protocols");
47786
47842
  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.`;
47787
47843
  var searchSchema = import_zod59.default.object({
@@ -47791,7 +47847,7 @@ var searchSchema = import_zod59.default.object({
47791
47847
  top_k: import_zod59.default.number().optional().default(5).describe("Number of results to return")
47792
47848
  });
47793
47849
  var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => {
47794
- return (0, import_langchain66.tool)(
47850
+ return (0, import_langchain67.tool)(
47795
47851
  async (input, _exeConfig) => {
47796
47852
  try {
47797
47853
  const { collection, query, filter: filter2, top_k } = input;
@@ -47865,9 +47921,9 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
47865
47921
 
47866
47922
  // src/tool_lattice/collection/get_collection.ts
47867
47923
  var import_zod60 = __toESM(require("zod"));
47868
- var import_langchain67 = require("langchain");
47924
+ var import_langchain68 = require("langchain");
47869
47925
  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.`;
47870
- var createGetCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain67.tool)(
47926
+ var createGetCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain68.tool)(
47871
47927
  async (input, _exeConfig) => {
47872
47928
  try {
47873
47929
  const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
@@ -47897,7 +47953,7 @@ Embedding: ${c.embeddingKey}${fieldsDesc}`;
47897
47953
 
47898
47954
  // src/tool_lattice/collection/create_collection.ts
47899
47955
  var import_zod61 = __toESM(require("zod"));
47900
- var import_langchain68 = require("langchain");
47956
+ var import_langchain69 = require("langchain");
47901
47957
  var createSchema = import_zod61.default.object({
47902
47958
  name: import_zod61.default.string().describe("Collection name (lowercase, underscores only)"),
47903
47959
  label: import_zod61.default.string().describe("Display name"),
@@ -47909,7 +47965,7 @@ var createSchema = import_zod61.default.object({
47909
47965
  required: import_zod61.default.boolean().optional().default(false).describe("Whether field is required")
47910
47966
  })).optional().describe("Custom field definitions for entries in this collection")
47911
47967
  });
47912
- var createCreateCollectionTool = (scope = {}) => (0, import_langchain68.tool)(
47968
+ var createCreateCollectionTool = (scope = {}) => (0, import_langchain69.tool)(
47913
47969
  async (input, _exeConfig) => {
47914
47970
  try {
47915
47971
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
@@ -47936,7 +47992,7 @@ var createCreateCollectionTool = (scope = {}) => (0, import_langchain68.tool)(
47936
47992
 
47937
47993
  // src/tool_lattice/collection/update_collection.ts
47938
47994
  var import_zod62 = __toESM(require("zod"));
47939
- var import_langchain69 = require("langchain");
47995
+ var import_langchain70 = require("langchain");
47940
47996
  var schema = import_zod62.default.object({
47941
47997
  name: import_zod62.default.string().describe("Collection name"),
47942
47998
  label: import_zod62.default.string().optional().describe("New display name"),
@@ -47948,7 +48004,7 @@ var schema = import_zod62.default.object({
47948
48004
  required: import_zod62.default.boolean().optional().default(false).describe("Whether field is required")
47949
48005
  })).optional().describe("Custom field definitions for entries (replaces existing schema)")
47950
48006
  });
47951
- var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain69.tool)(
48007
+ var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain70.tool)(
47952
48008
  async (input, _exeConfig) => {
47953
48009
  try {
47954
48010
  const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
@@ -47970,8 +48026,8 @@ var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true
47970
48026
 
47971
48027
  // src/tool_lattice/collection/delete_collection.ts
47972
48028
  var import_zod63 = __toESM(require("zod"));
47973
- var import_langchain70 = require("langchain");
47974
- var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain70.tool)(
48029
+ var import_langchain71 = require("langchain");
48030
+ var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain71.tool)(
47975
48031
  async (input, _exeConfig) => {
47976
48032
  try {
47977
48033
  const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
@@ -47988,14 +48044,14 @@ var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true
47988
48044
 
47989
48045
  // src/tool_lattice/collection/list_entries.ts
47990
48046
  var import_zod64 = __toESM(require("zod"));
47991
- var import_langchain71 = require("langchain");
48047
+ var import_langchain72 = require("langchain");
47992
48048
  var schema2 = import_zod64.default.object({
47993
48049
  collection: import_zod64.default.string().describe("Collection name")
47994
48050
  });
47995
48051
  function buildKey2(tenantId2, name) {
47996
48052
  return `${tenantId2}:${name}`;
47997
48053
  }
47998
- var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain71.tool)(
48054
+ var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain72.tool)(
47999
48055
  async (input, _exeConfig) => {
48000
48056
  try {
48001
48057
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -48025,7 +48081,7 @@ var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) =
48025
48081
 
48026
48082
  // src/tool_lattice/collection/add_entry.ts
48027
48083
  var import_zod65 = __toESM(require("zod"));
48028
- var import_langchain72 = require("langchain");
48084
+ var import_langchain73 = require("langchain");
48029
48085
  var import_documents = require("@langchain/core/documents");
48030
48086
  var import_uuid11 = require("uuid");
48031
48087
  var schema3 = import_zod65.default.object({
@@ -48036,7 +48092,7 @@ var schema3 = import_zod65.default.object({
48036
48092
  function key2(t, n) {
48037
48093
  return `${t}:${n}`;
48038
48094
  }
48039
- var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain72.tool)(
48095
+ var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain73.tool)(
48040
48096
  async (input, _exeConfig) => {
48041
48097
  try {
48042
48098
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -48069,7 +48125,7 @@ var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (
48069
48125
 
48070
48126
  // src/tool_lattice/collection/update_entry.ts
48071
48127
  var import_zod66 = __toESM(require("zod"));
48072
- var import_langchain73 = require("langchain");
48128
+ var import_langchain74 = require("langchain");
48073
48129
  var schema4 = import_zod66.default.object({
48074
48130
  collection: import_zod66.default.string().describe("Collection name"),
48075
48131
  entryId: import_zod66.default.string().describe("Entry ID to update"),
@@ -48079,7 +48135,7 @@ var schema4 = import_zod66.default.object({
48079
48135
  function key3(t, n) {
48080
48136
  return `${t}:${n}`;
48081
48137
  }
48082
- var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain73.tool)(
48138
+ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain74.tool)(
48083
48139
  async (input, _exeConfig) => {
48084
48140
  try {
48085
48141
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -48101,7 +48157,7 @@ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
48101
48157
 
48102
48158
  // src/tool_lattice/collection/delete_entry.ts
48103
48159
  var import_zod67 = __toESM(require("zod"));
48104
- var import_langchain74 = require("langchain");
48160
+ var import_langchain75 = require("langchain");
48105
48161
  var schema5 = import_zod67.default.object({
48106
48162
  collection: import_zod67.default.string().describe("Collection name"),
48107
48163
  entryId: import_zod67.default.string().describe("Entry ID to delete")
@@ -48109,7 +48165,7 @@ var schema5 = import_zod67.default.object({
48109
48165
  function key4(t, n) {
48110
48166
  return `${t}:${n}`;
48111
48167
  }
48112
- var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain74.tool)(
48168
+ var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain75.tool)(
48113
48169
  async (input, _exeConfig) => {
48114
48170
  try {
48115
48171
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
@@ -48129,7 +48185,7 @@ var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
48129
48185
  function createCollectionMiddleware(params) {
48130
48186
  const { collectionKeys, connectAll, compileStableCandidateTools = false } = params;
48131
48187
  if (!compileStableCandidateTools && !connectAll && (!collectionKeys || collectionKeys.length === 0)) {
48132
- return (0, import_langchain75.createMiddleware)({
48188
+ return (0, import_langchain76.createMiddleware)({
48133
48189
  name: "collectionMiddleware",
48134
48190
  contextSchema,
48135
48191
  tools: [
@@ -48139,7 +48195,7 @@ function createCollectionMiddleware(params) {
48139
48195
  });
48140
48196
  }
48141
48197
  const toolParams = { collectionKeys, connectAll };
48142
- return (0, import_langchain75.createMiddleware)({
48198
+ return (0, import_langchain76.createMiddleware)({
48143
48199
  name: "collectionMiddleware",
48144
48200
  contextSchema,
48145
48201
  tools: [
@@ -48202,11 +48258,11 @@ var collectionPlugin = {
48202
48258
  };
48203
48259
 
48204
48260
  // src/middlewares/askUserClarifyMiddleware.ts
48205
- var import_langchain77 = require("langchain");
48261
+ var import_langchain78 = require("langchain");
48206
48262
  var import_langgraph13 = require("@langchain/langgraph");
48207
48263
 
48208
48264
  // src/tool_lattice/ask_user_to_clarify/index.ts
48209
- var import_langchain76 = require("langchain");
48265
+ var import_langchain77 = require("langchain");
48210
48266
  var import_zod68 = __toESM(require("zod"));
48211
48267
  var questionSchema = import_zod68.default.object({
48212
48268
  question: import_zod68.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?'"),
@@ -48219,7 +48275,7 @@ var inputSchema = import_zod68.default.object({
48219
48275
  questions: import_zod68.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.")
48220
48276
  });
48221
48277
  function createAskUserToClarifyTool() {
48222
- return (0, import_langchain76.tool)(
48278
+ return (0, import_langchain77.tool)(
48223
48279
  async (input) => {
48224
48280
  return JSON.stringify(input);
48225
48281
  },
@@ -48244,7 +48300,7 @@ function isProjectRoomRun(request) {
48244
48300
  return isRecord13(runConfig?.projectRoom);
48245
48301
  }
48246
48302
  function createAskUserClarifyMiddleware() {
48247
- return (0, import_langchain77.createMiddleware)({
48303
+ return (0, import_langchain78.createMiddleware)({
48248
48304
  name: "AskUserClarifyMiddleware",
48249
48305
  tools: [createAskUserToClarifyTool()],
48250
48306
  wrapToolCall: async (request, handler) => {
@@ -48254,7 +48310,7 @@ function createAskUserClarifyMiddleware() {
48254
48310
  return handler(request);
48255
48311
  }
48256
48312
  if (isProjectRoomRun(request)) {
48257
- return new import_langchain77.ToolMessage({
48313
+ return new import_langchain78.ToolMessage({
48258
48314
  content: "You are replying inside a project room, which has no interactive clarification UI. Ask your clarifying questions directly in your reply text and stop; the user's next room message will continue the conversation.",
48259
48315
  tool_call_id: toolCall?.id,
48260
48316
  name: toolName2
@@ -48262,7 +48318,7 @@ function createAskUserClarifyMiddleware() {
48262
48318
  }
48263
48319
  const parsed = inputSchema.safeParse(toolCall?.args);
48264
48320
  if (!parsed.success) {
48265
- return new import_langchain77.ToolMessage({
48321
+ return new import_langchain78.ToolMessage({
48266
48322
  content: `Invalid clarify tool arguments: ${parsed.error.message}`,
48267
48323
  tool_call_id: toolCall?.id,
48268
48324
  name: toolName2
@@ -48282,7 +48338,7 @@ function createAskUserClarifyMiddleware() {
48282
48338
  const result = await (0, import_langgraph13.interrupt)(md);
48283
48339
  const response = result.data;
48284
48340
  if (!response?.answers || response.answers.length === 0) {
48285
- return new import_langchain77.ToolMessage({
48341
+ return new import_langchain78.ToolMessage({
48286
48342
  content: "No clarification questions were answered.",
48287
48343
  tool_call_id: toolCall?.id,
48288
48344
  name: toolName2
@@ -48292,7 +48348,7 @@ function createAskUserClarifyMiddleware() {
48292
48348
  (answer) => (answer.selectedOptions?.length ?? 0) > 0 || answer.otherText && answer.otherText.trim() !== "" || answer.filePath && answer.filePath.trim() !== ""
48293
48349
  );
48294
48350
  if (answeredQuestions.length === 0) {
48295
- return new import_langchain77.ToolMessage({
48351
+ return new import_langchain78.ToolMessage({
48296
48352
  content: "No clarification questions were answered.",
48297
48353
  tool_call_id: toolCall?.id,
48298
48354
  name: toolName2
@@ -48322,7 +48378,7 @@ function createAskUserClarifyMiddleware() {
48322
48378
  }
48323
48379
  lines.push("");
48324
48380
  }
48325
- return new import_langchain77.ToolMessage({
48381
+ return new import_langchain78.ToolMessage({
48326
48382
  content: lines.join("\n"),
48327
48383
  tool_call_id: toolCall?.id,
48328
48384
  name: toolName2
@@ -48348,10 +48404,10 @@ var askUserClarifyPlugin = {
48348
48404
  };
48349
48405
 
48350
48406
  // src/middlewares/widgetMiddleware.ts
48351
- var import_langchain80 = require("langchain");
48407
+ var import_langchain81 = require("langchain");
48352
48408
 
48353
48409
  // src/tool_lattice/widget/loadGuidelines.ts
48354
- var import_langchain78 = require("langchain");
48410
+ var import_langchain79 = require("langchain");
48355
48411
  var import_zod69 = require("zod");
48356
48412
 
48357
48413
  // src/middlewares/guidelines/index.ts
@@ -49225,7 +49281,7 @@ var LoadGuidelinesInputSchema = import_zod69.z.object({
49225
49281
  )
49226
49282
  });
49227
49283
  function createLoadGuidelinesTool() {
49228
- return (0, import_langchain78.tool)(
49284
+ return (0, import_langchain79.tool)(
49229
49285
  async (input) => {
49230
49286
  const result = getGuidelines(input.modules);
49231
49287
  return result;
@@ -49239,7 +49295,7 @@ function createLoadGuidelinesTool() {
49239
49295
  }
49240
49296
 
49241
49297
  // src/tool_lattice/widget/showWidget.ts
49242
- var import_langchain79 = require("langchain");
49298
+ var import_langchain80 = require("langchain");
49243
49299
  var import_zod70 = require("zod");
49244
49300
  function containsForbiddenTags(code) {
49245
49301
  const forbiddenPatterns = [
@@ -49275,7 +49331,7 @@ var ShowWidgetInputSchema = import_zod70.z.object({
49275
49331
  )
49276
49332
  });
49277
49333
  function createShowWidgetTool() {
49278
- return (0, import_langchain79.tool)(
49334
+ return (0, import_langchain80.tool)(
49279
49335
  async (input) => {
49280
49336
  if (!input.i_have_seen_guidelines) {
49281
49337
  return "Error: You must call load_guidelines before using show_widget. Set i_have_seen_guidelines to true only after loading guidelines.";
@@ -49306,7 +49362,7 @@ function createWidgetMiddleware() {
49306
49362
  createLoadGuidelinesTool(),
49307
49363
  createShowWidgetTool()
49308
49364
  ];
49309
- return (0, import_langchain80.createMiddleware)({
49365
+ return (0, import_langchain81.createMiddleware)({
49310
49366
  name: "widgetMiddleware",
49311
49367
  contextSchema,
49312
49368
  tools
@@ -49330,7 +49386,7 @@ var widgetPlugin = {
49330
49386
  };
49331
49387
 
49332
49388
  // src/middlewares/taskMiddleware.ts
49333
- var import_langchain81 = require("langchain");
49389
+ var import_langchain82 = require("langchain");
49334
49390
  var import_zod71 = require("zod");
49335
49391
  var import_langgraph14 = require("@langchain/langgraph");
49336
49392
  var import_protocols44 = require("@axiom-lattice/protocols");
@@ -51666,7 +51722,7 @@ function createTaskMiddleware(options = {}) {
51666
51722
  ...trustedCaller ? { callerMembershipId: trustedCaller.membershipId, callerAssistantId: trustedCaller.assistantId } : rc.assistant_id ? { callerAssistantId: rc.assistant_id } : {}
51667
51723
  }));
51668
51724
  };
51669
- return (0, import_langchain81.createMiddleware)({
51725
+ return (0, import_langchain82.createMiddleware)({
51670
51726
  name: "TaskMiddleware",
51671
51727
  contextSchema,
51672
51728
  // Persisted between invocations (ADRs: the run↔task binding survives turns).
@@ -51742,7 +51798,7 @@ function createTaskMiddleware(options = {}) {
51742
51798
  const taskId = typeof args?.taskId === "string" ? args.taskId.trim() : "";
51743
51799
  const agentId = typeof args?.agentId === "string" ? args.agentId.trim() : "";
51744
51800
  if (!taskId || !agentId) {
51745
- return new import_langchain81.ToolMessage({
51801
+ return new import_langchain82.ToolMessage({
51746
51802
  name: "task",
51747
51803
  tool_call_id: request.toolCall.id ?? "task-dispatch",
51748
51804
  status: "error",
@@ -51808,7 +51864,7 @@ ${TASK_CONVERGENCE_GUIDANCE}
51808
51864
  });
51809
51865
  },
51810
51866
  tools: [
51811
- (0, import_langchain81.tool)(
51867
+ (0, import_langchain82.tool)(
51812
51868
  handleManageTask,
51813
51869
  {
51814
51870
  name: "manage_task",
@@ -51854,7 +51910,7 @@ to an expert \u2014 never re-dispatch the task you are processing.`,
51854
51910
  schema: manageTaskSchema
51855
51911
  }
51856
51912
  ),
51857
- (0, import_langchain81.tool)(handleStartTask, {
51913
+ (0, import_langchain82.tool)(handleStartTask, {
51858
51914
  name: "task",
51859
51915
  description: `Start a persisted TaskItem with any existing Agent in a fresh isolated thread. This tool CANNOT create a task: create it first with \`manage_task\` action="create" (title + description), then dispatch it with \`task { taskId, agentId }\`. Do not pass action/description/title to this tool. Use this to delegate work \u2014 dispatch a subtask you created to the agent that should execute it; never re-dispatch the task you are currently processing (give the expert a child task instead). Pass agentId "general-purpose" for the general-purpose worker \u2014 ${DEFAULT_GENERAL_PURPOSE_DESCRIPTION} It has access to all the caller's tools, model, and middleware, so use it for general-purpose subtasks, to isolate context and token usage, and whenever no specialized agent fits. The target does NOT need task-management tools: it runs and returns an observation, an executionResultId, and the task's taskStatus (re-read after the worker settled). Check taskStatus before completing: if it is already 'completed' the worker finished it \u2014 do NOT complete again (use manage_task add_activity); if it is still 'in_progress' you are the single completer and pass the executionResultId to manage_task set_status completed; if it is 'failed' or 'interrupted', act on that. The caller reconciles via manage_task, which interprets the result and records the outcome. A project task instead returns a managed result (success:true, managed:true) because the project-lifecycle queue owns execution.`,
51860
51916
  schema: startTaskSchema
@@ -51998,7 +52054,7 @@ canonical Belief State:
51998
52054
  };
51999
52055
 
52000
52056
  // src/middlewares/documentLearningMiddleware.ts
52001
- var import_langchain82 = require("langchain");
52057
+ var import_langchain83 = require("langchain");
52002
52058
 
52003
52059
  // src/middlewares/documentLearningSkills.ts
52004
52060
  var LEARN_CAPABILITY_SKILL = `---
@@ -52237,7 +52293,7 @@ patterns discovered, recommendations. Include validation coverage: user-sample N
52237
52293
  `;
52238
52294
 
52239
52295
  // src/middlewares/documentLearningMiddleware.ts
52240
- var createDocumentLearningMiddleware = () => (0, import_langchain82.createMiddleware)({
52296
+ var createDocumentLearningMiddleware = () => (0, import_langchain83.createMiddleware)({
52241
52297
  name: "DocumentLearningMiddleware",
52242
52298
  contextSchema,
52243
52299
  tools: []
@@ -52260,12 +52316,12 @@ var documentLearningPlugin = {
52260
52316
  };
52261
52317
 
52262
52318
  // src/middlewares/documentParserMiddleware.ts
52263
- var import_langchain84 = require("langchain");
52319
+ var import_langchain85 = require("langchain");
52264
52320
 
52265
52321
  // src/tool_lattice/document_parser/index.ts
52266
52322
  var path7 = __toESM(require("path"));
52267
52323
  var import_zod72 = __toESM(require("zod"));
52268
- var import_langchain83 = require("langchain");
52324
+ var import_langchain84 = require("langchain");
52269
52325
  var PARSE_DOCUMENT_DESCRIPTION = `Parse a document file (docx, pdf) into structured Markdown using a remote document parsing service.
52270
52326
  This tool handles the full pipeline internally: file upload \u2192 document parsing \u2192 polling until complete \u2192 download result \u2192 save to filesystem.
52271
52327
 
@@ -52388,7 +52444,7 @@ function createParseDocumentTool({
52388
52444
  baseUrl = "",
52389
52445
  apiKey = ""
52390
52446
  }) {
52391
- return (0, import_langchain83.tool)(
52447
+ return (0, import_langchain84.tool)(
52392
52448
  async (input, exe_config) => {
52393
52449
  try {
52394
52450
  const runConfig = exe_config?.configurable?.runConfig ?? { assistant_id: "", thread_id: "" };
@@ -52925,7 +52981,7 @@ function createDocumentParserMiddleware(config) {
52925
52981
  const baseUrl = config.baseUrl || "";
52926
52982
  const apiKey = config.apiKey || "";
52927
52983
  const connections = Array.isArray(config.connections) ? config.connections.filter((key5) => typeof key5 === "string") : [];
52928
- return (0, import_langchain84.createMiddleware)({
52984
+ return (0, import_langchain85.createMiddleware)({
52929
52985
  name: "DocumentParser",
52930
52986
  contextSchema,
52931
52987
  tools: [createParseDocumentTool({ connectAll, connections, baseUrl, apiKey })]
@@ -53108,7 +53164,7 @@ var documentParserPlugin = {
53108
53164
  // src/middlewares/projectRoomMiddleware.ts
53109
53165
  var import_crypto10 = require("crypto");
53110
53166
  var import_protocols47 = require("@axiom-lattice/protocols");
53111
- var import_langchain85 = require("langchain");
53167
+ var import_langchain86 = require("langchain");
53112
53168
  var import_zod73 = require("zod");
53113
53169
  var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
53114
53170
  var PROJECT_ROOM_POST_FAILED = "PROJECT_ROOM_POST_FAILED";
@@ -53217,10 +53273,10 @@ async function hasActiveCurrentMembership(scope) {
53217
53273
  return true;
53218
53274
  }
53219
53275
  function createProjectRoomMiddleware() {
53220
- return (0, import_langchain85.createMiddleware)({
53276
+ return (0, import_langchain86.createMiddleware)({
53221
53277
  name: "ProjectRoomMiddleware",
53222
53278
  tools: [
53223
- (0, import_langchain85.tool)(async (input, config) => {
53279
+ (0, import_langchain86.tool)(async (input, config) => {
53224
53280
  const { text } = input;
53225
53281
  const scope = readTrustedRoomScope(config);
53226
53282
  if (!scope) return CONTEXT_REQUIRED;
@@ -53252,7 +53308,7 @@ function createProjectRoomMiddleware() {
53252
53308
  description: "Post a text reply to the current trusted Project Room message",
53253
53309
  schema: postSchema
53254
53310
  }),
53255
- (0, import_langchain85.tool)(async (_input, config) => {
53311
+ (0, import_langchain86.tool)(async (_input, config) => {
53256
53312
  const scope = readTrustedRoomScope(config);
53257
53313
  if (!scope) return CONTEXT_REQUIRED;
53258
53314
  try {
@@ -53313,7 +53369,7 @@ var projectRoomPlugin = {
53313
53369
  };
53314
53370
 
53315
53371
  // src/middlewares/sandboxPluginsMiddleware.ts
53316
- var import_langchain86 = require("langchain");
53372
+ var import_langchain87 = require("langchain");
53317
53373
  var import_zod74 = require("zod");
53318
53374
  var import_protocols48 = require("@axiom-lattice/protocols");
53319
53375
 
@@ -54009,11 +54065,11 @@ The official \`@modelcontextprotocol/ext-apps\` client SDK reports size
54009
54065
  automatically. Otherwise the panel stays at a default height and content taller
54010
54066
  than the host max scrolls; \`templates/ui.html\` already includes this helper.
54011
54067
 
54012
- ## Sharing the UI as a link
54013
- If the human explicitly asks to publish or share this UI, load
54014
- \`app-share-publishing\` and use \`share_app\`. Public links delegate the selected
54015
- connection and re-run the tool on every open; confirm visibility and warn about
54016
- that delegation first.
54068
+ ## Publishing the UI
54069
+ If the human explicitly asks to publish, share, or pin this UI, load
54070
+ \`app-share-publishing\`. Use \`publish_target\` with \`mode:"link"\` for a URL or
54071
+ \`mode:"menu"\` for the workspace menu; call \`list_menu_groups\` before choosing
54072
+ a group. MCP Apps re-run on every open.
54017
54073
 
54018
54074
  ## Publishing the UI to external MCP clients
54019
54075
  If the tool also sets \`"expose": true\`, its UI is published to Axiom's Open/MCP
@@ -54623,8 +54679,10 @@ Follow the authoring skill's "Decide first" steps to confirm the goal
54623
54679
  (inputs/outputs). If the UI class applies, load "sandbox-plugins-ui" before
54624
54680
  authoring it. If the tool must be callable by external MCP clients via an API key,
54625
54681
  load "sandbox-plugins-expose" and follow it (\`expose: true\` + key grants).
54626
- If the human asks to publish or share the plugin's UI as a link, load
54627
- "app-share-publishing" and follow it; never publish proactively. If a tool must
54682
+ If the human asks to publish/share/pin the plugin UI, load
54683
+ "app-share-publishing" and use \`publish_target\`; never publish proactively.
54684
+ For menu mode, call \`list_menu_groups\` first and choose an existing group or
54685
+ confirm a new one with the human. If a tool must
54628
54686
  call the platform's own tools/agents from its handler, load
54629
54687
  "sandbox-plugins-consume-open" and follow its checklist: declare a password field
54630
54688
  in connection.fields, read it from PLUGIN_CONNECTION_FILE, construct OpenMcpClient
@@ -54962,8 +55020,8 @@ var sandboxPluginsPlugin = {
54962
55020
  {
54963
55021
  id: "app-share",
54964
55022
  type: "app-share",
54965
- name: "App Share",
54966
- description: "Publish a plugin UI tool as a public/password share link",
55023
+ name: "Publish",
55024
+ description: "Publish files or plugin UI tools as links or workspace menu items",
54967
55025
  enabled: true,
54968
55026
  config: {}
54969
55027
  },
@@ -55018,10 +55076,10 @@ var sandboxPluginsPlugin = {
55018
55076
  ]
55019
55077
  }
55020
55078
  },
55021
- middleware: () => (0, import_langchain86.createMiddleware)({
55079
+ middleware: () => (0, import_langchain87.createMiddleware)({
55022
55080
  name: "SandboxPluginsMiddleware",
55023
55081
  tools: [
55024
- (0, import_langchain86.tool)(
55082
+ (0, import_langchain87.tool)(
55025
55083
  async (input, exeConfig) => {
55026
55084
  const tenantId2 = tenantIdFrom(exeConfig);
55027
55085
  const catalog2 = getSandboxPluginCatalog();
@@ -55321,7 +55379,9 @@ var sandboxPluginsPlugin = {
55321
55379
  };
55322
55380
 
55323
55381
  // src/middlewares/appShareMiddleware.ts
55324
- var import_langchain87 = require("langchain");
55382
+ var import_langchain88 = require("langchain");
55383
+
55384
+ // src/middlewares/appShareTargets.ts
55325
55385
  var import_zod75 = require("zod");
55326
55386
 
55327
55387
  // src/middlewares/appShareUi.ts
@@ -55331,18 +55391,57 @@ var SHARE_CARD_APP_HTML = `<!doctype html>
55331
55391
  <head>
55332
55392
  <meta charset="utf-8" />
55333
55393
  <meta name="viewport" content="width=device-width, initial-scale=1" />
55334
- <title>Shared app</title>
55394
+ <title>Shared link</title>
55335
55395
  <style>
55336
- :root { color-scheme: light dark; }
55337
- body { margin: 0; padding: 12px 14px; font: 13px/1.45 Inter, -apple-system, "Segoe UI", sans-serif; }
55338
- .title { font-weight: 600; font-size: 14px; }
55339
- .tag { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: #eef2ff; color: #4338ca; }
55340
- .url { margin: 8px 0; padding: 7px 9px; border: 1px solid #e5e7eb; border-radius: 8px; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
55341
- .pwd { margin: 6px 0; color: #6b7280; font-size: 12px; }
55342
- .actions { display: flex; gap: 8px; margin-top: 8px; }
55343
- button { border: 1px solid #d1d5db; background: #fff; border-radius: 8px; padding: 5px 10px; font: inherit; cursor: pointer; }
55344
- button.primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
55345
- .warn { margin-top: 8px; color: #b45309; font-size: 11px; }
55396
+ :root {
55397
+ color-scheme: light dark;
55398
+ --card-bg: #fff;
55399
+ --card-border: #e5e7eb;
55400
+ --text: #111827;
55401
+ --muted: #6b7280;
55402
+ --accent: #4338ca;
55403
+ --accent-bg: #eef2ff;
55404
+ --warning: #b45309;
55405
+ --btn-bg: #fff;
55406
+ --btn-border: #d1d5db;
55407
+ --btn-text: #111827;
55408
+ --primary-bg: #4f46e5;
55409
+ --primary-border: #4f46e5;
55410
+ --primary-text: #fff;
55411
+ --shadow: 0 1px 2px rgba(0,0,0,.04);
55412
+ }
55413
+ @media (prefers-color-scheme: dark) {
55414
+ :root {
55415
+ --card-bg: #111827;
55416
+ --card-border: #374151;
55417
+ --text: #f9fafb;
55418
+ --muted: #9ca3af;
55419
+ --accent: #c7d2fe;
55420
+ --accent-bg: #312e81;
55421
+ --warning: #fbbf24;
55422
+ --btn-bg: #1f2937;
55423
+ --btn-border: #4b5563;
55424
+ --btn-text: #f9fafb;
55425
+ --primary-bg: #6366f1;
55426
+ --primary-border: #6366f1;
55427
+ --primary-text: #fff;
55428
+ --shadow: 0 1px 2px rgba(0,0,0,.4);
55429
+ }
55430
+ }
55431
+ body { margin: 0; padding: 12px 14px; font: 13px/1.45 Inter, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: transparent; }
55432
+ .card { box-sizing: border-box; max-width: 420px; margin: 0 auto; padding: 14px 16px; border: 1px solid var(--card-border); border-radius: 14px; background: var(--card-bg); color: var(--text); box-shadow: var(--shadow); }
55433
+ .head { display: flex; align-items: center; gap: 8px; }
55434
+ .icon { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-bg); color: var(--accent); display: grid; place-items: center; font-size: 14px; }
55435
+ .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
55436
+ .kind { border-radius: 999px; font-size: 11px; padding: 1px 7px; background: var(--accent-bg); color: var(--accent); }
55437
+ .meta { margin: 4px 0 8px; color: var(--muted); font-size: 11px; }
55438
+ .link { padding: 7px 9px; border: 1px solid var(--card-border); border-radius: 8px; color: var(--text); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
55439
+ .link:focus-visible { outline: 2px solid var(--primary-bg); outline-offset: 2px; }
55440
+ .pwd { margin-top: 6px; color: var(--muted); font-size: 12px; }
55441
+ .warn { margin-top: 6px; color: var(--warning); font-size: 11px; overflow-wrap: anywhere; }
55442
+ .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
55443
+ button { border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-text); border-radius: 8px; padding: 5px 10px; font: inherit; cursor: pointer; }
55444
+ button.primary { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary-text); }
55346
55445
  </style>
55347
55446
  </head>
55348
55447
  <body>
@@ -55375,8 +55474,8 @@ var SHARE_CARD_APP_HTML = `<!doctype html>
55375
55474
  }
55376
55475
  var ZH = (navigator.language || "").toLowerCase().indexOf("zh") === 0;
55377
55476
  var COPY = ZH
55378
- ? { copy: "\u590D\u5236", open: "\u6253\u5F00\u5E94\u7528", password: "\u53E3\u4EE4\uFF1A", unavailable: "\u5206\u4EAB\u6570\u636E\u4E0D\u53EF\u7528\u3002", failed: "\u521D\u59CB\u5316\u5931\u8D25\uFF1A" }
55379
- : { copy: "Copy", open: "Open app", password: "Password: ", unavailable: "Share data unavailable.", failed: "Failed to initialize: " };
55477
+ ? { copy: "\u590D\u5236", copyLink: "\u590D\u5236\u94FE\u63A5", open: "\u6253\u5F00", kindApp: "\u5E94\u7528", kindFile: "\u6587\u4EF6", password: "\u53E3\u4EE4\uFF1A", publicTag: "\u516C\u5F00", passwordTag: "\u53E3\u4EE4", unavailable: "\u5206\u4EAB\u6570\u636E\u4E0D\u53EF\u7528\u3002", failed: "\u521D\u59CB\u5316\u5931\u8D25\uFF1A" }
55478
+ : { copy: "Copy", copyLink: "Copy link", open: "Open", kindApp: "App", kindFile: "File", password: "Password: ", publicTag: "Public", passwordTag: "Password", unavailable: "Share data unavailable.", failed: "Failed to initialize: " };
55380
55479
  function esc(v) {
55381
55480
  return String(v == null ? "" : v).replace(/[&<>"']/g, function (ch) {
55382
55481
  return { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[ch];
@@ -55392,26 +55491,39 @@ var SHARE_CARD_APP_HTML = `<!doctype html>
55392
55491
  }
55393
55492
  function render(data) {
55394
55493
  if (!data) { root.innerHTML = "<p>" + COPY.unavailable + "</p>"; sendSize(); return; }
55395
- var html = '<div class="title">' + esc(data.title || "Shared app") + "</div>";
55396
- html += '<span class="tag">' + esc(data.visibility) + "</span>";
55397
- html += '<div class="url">' + esc(data.url || data.path) + "</div>";
55494
+ var title = data.title || "Published link";
55495
+ var full = data.url || data.path;
55496
+ var html = '<div class="card">';
55497
+ html += '<div class="head"><span class="icon" aria-hidden="true">\u2197</span><span class="title" title="' + esc(title) + '">' + esc(title) + '</span><span class="kind">' + (data.kind === "file" ? COPY.kindFile : COPY.kindApp) + '</span></div>';
55498
+ html += '<div class="meta">' + (data.visibility === "password" ? COPY.passwordTag : COPY.publicTag) + "</div>";
55499
+ html += '<div class="link" role="button" tabindex="0" aria-label="' + esc(COPY.copyLink) + '" title="' + esc(full) + '">' + esc(full) + "</div>";
55398
55500
  if (data.password) html += '<div class="pwd">' + COPY.password + esc(data.password) + "</div>";
55399
- html += '<div class="actions">';
55400
- html += '<button id="copy">' + COPY.copy + "</button>";
55401
- html += '<button class="primary" id="open">' + COPY.open + "</button>";
55402
- html += "</div>";
55403
55501
  if (data.warnings && data.warnings.length) {
55404
- html += '<div class="warn">' + esc(data.warnings.join(" ")) + "</div>";
55502
+ var warning = data.warnings.join(" ");
55503
+ html += '<div class="warn" title="' + esc(warning) + '">' + esc(warning) + "</div>";
55405
55504
  }
55505
+ html += '<div class="actions">';
55506
+ html += '<button id="copy" aria-label="' + esc(COPY.copy) + '">' + COPY.copy + "</button>";
55507
+ html += '<button id="open" class="primary" aria-label="' + esc(COPY.open) + '">' + COPY.open + "</button>";
55508
+ html += "</div></div>";
55406
55509
  root.innerHTML = html;
55407
- document.getElementById("copy").onclick = function () {
55510
+ function copyLink() {
55408
55511
  rpc("ui/copy-link", {
55409
55512
  title: data.title,
55410
55513
  url: data.url || data.path,
55411
55514
  password: data.password,
55412
55515
  passwordLabel: COPY.password
55413
55516
  }).catch(function () {});
55517
+ }
55518
+ var link = document.querySelector(".link");
55519
+ link.onclick = copyLink;
55520
+ link.onkeydown = function (event) {
55521
+ if (event.key === "Enter" || event.key === " ") {
55522
+ event.preventDefault();
55523
+ copyLink();
55524
+ }
55414
55525
  };
55526
+ document.getElementById("copy").onclick = copyLink;
55415
55527
  document.getElementById("open").onclick = function () {
55416
55528
  rpc("ui/open-link", { url: data.url || data.path }).catch(function () {});
55417
55529
  };
@@ -55441,220 +55553,538 @@ var SHARE_CARD_APP_HTML = `<!doctype html>
55441
55553
  </body>
55442
55554
  </html>`;
55443
55555
 
55444
- // src/middlewares/appShareSkill.ts
55445
- var APP_SHARE_PUBLISHING_SKILL = `---
55446
- name: app-share-publishing
55447
- description: Use when a user explicitly asks to publish or share a tenant plugin's MCP App UI as a public or password-protected link, or asks for a shareable app URL.
55448
- ---
55449
-
55450
- # Publishing a plugin UI as a share link
55451
-
55452
- \`share_app\` publishes a UI-bearing tool from a tenant sandbox plugin. It does
55453
- not publish agents, files, or MCP-server UIs.
55454
-
55455
- ## Preconditions
55456
- - The plugin is authored, and \`manage_plugin validate\` / \`reload\` / \`test\` passes.
55457
- - The target tool declares \`ui.resource\`.
55458
- - A connection is configured if the plugin needs one. Pass \`connectionKey\` when
55459
- the plugin has multiple connections.
55460
- - Publish only when the human explicitly asks. Never share proactively.
55461
-
55462
- ## Ask before creating
55463
- - visibility: \`public\` or \`password\` (required; there is no default).
55464
- - password when visibility is \`password\`.
55465
- - Optional: title, \`expiresInMinutes\`, \`maxAccess\`.
55466
- - Confirm the initial \`input\`; it is stored and re-run on every open. Never put
55467
- credentials or other secrets in \`input\`.
55468
-
55469
- ## Call
55470
- \`\`\`json
55471
- {
55472
- "pluginType": "<plugin type>",
55473
- "toolName": "<UI-bearing tool>",
55474
- "input": {},
55475
- "connectionKey": "<selected connection, when needed>",
55476
- "visibility": "public | password",
55477
- "password": "<required for password>",
55478
- "title": "<optional>",
55479
- "expiresInMinutes": 1440,
55480
- "maxAccess": 100
55481
- }
55482
- \`\`\`
55483
-
55484
- The result contains the relative link (\`path\`), token, title, visibility,
55485
- optional password, and warnings, plus an inline share card.
55486
-
55487
- ## What the link does
55488
- - Every open re-runs the saved tool with the saved input; results are not
55489
- persisted. Tools with write side effects run on every open.
55490
- - A public share delegates the selected plugin connection: anyone with the link
55491
- can call any tool in that plugin through the gateway. Warn the human before
55492
- creating it.
55493
- - A password share requires the password cookie. Links can be listed and revoked
55494
- on the Shares page.
55495
-
55496
- ## Errors
55497
- - \`TOOL_NOT_UI\` / \`TOOL_NOT_FOUND\`: choose a UI-bearing tool from the plugin.
55498
- - \`CONNECTION_REQUIRED\`: ask the human to configure the plugin connection first.
55499
- - \`CONNECTION_AMBIGUOUS\`: ask which \`connectionKey\` to use.
55500
- - \`CONNECTION_NOT_FOUND\`: verify the requested connection key.
55501
- - \`SCOPE_UNAVAILABLE\`: the deployment cannot sign MCP UI scopes.
55502
- - \`PAYLOAD_TOO_LARGE\`: reduce the stored input.
55503
- - \`USER_REQUIRED\`: invoke from an authenticated user context.
55504
-
55505
- ## Do not
55506
- - Do not use \`share_app\` for non-UI tools or file shares.
55507
- - Do not claim the shared view is a frozen snapshot; it re-executes.
55508
- - Do not include credentials or secrets in \`input\`.
55509
- `;
55510
-
55511
- // src/middlewares/appShareMiddleware.ts
55512
- var SHARE_CARD_UI_REF = {
55513
- kind: "plugin",
55514
- pluginType: "app-share",
55515
- resource: SHARE_CARD_UI_RESOURCE,
55516
- displayMode: "inline",
55517
- title: "Shared app"
55518
- };
55519
- function rawRunConfigFrom(exeConfig) {
55520
- const config = exeConfig;
55521
- return config?.configurable?.runConfig ?? {};
55522
- }
55523
- var shareAppSchema = import_zod75.z.object({
55556
+ // src/middlewares/appShareTargets.ts
55557
+ var fileTargetSchema = import_zod75.z.object({
55558
+ kind: import_zod75.z.literal("file"),
55559
+ path: import_zod75.z.string().min(1)
55560
+ });
55561
+ var mcpAppTargetSchema = import_zod75.z.object({
55562
+ kind: import_zod75.z.literal("mcpApp"),
55524
55563
  pluginType: import_zod75.z.string().min(1),
55525
55564
  toolName: import_zod75.z.string().min(1),
55526
55565
  input: import_zod75.z.record(import_zod75.z.unknown()).optional(),
55527
- connectionKey: import_zod75.z.string().min(1).optional(),
55528
- title: import_zod75.z.string().min(1).max(256).optional(),
55529
- visibility: import_zod75.z.enum(["public", "password"]),
55530
- password: import_zod75.z.string().min(1).max(1024).optional(),
55531
- expiresInMinutes: import_zod75.z.number().int().positive().max(525600).optional(),
55532
- maxAccess: import_zod75.z.number().int().positive().optional()
55566
+ connectionKey: import_zod75.z.string().min(1).optional()
55533
55567
  });
55534
- async function shareAppHandler(input, exeConfig) {
55535
- const runConfig = { ...sandboxRunConfigFrom(exeConfig) };
55536
- const rawRunConfig = rawRunConfigFrom(exeConfig);
55537
- const tenantId2 = runConfig.tenantId;
55538
- const createdBy = typeof rawRunConfig.user_id === "string" && rawRunConfig.user_id.length > 0 ? rawRunConfig.user_id : typeof rawRunConfig.userId === "string" && rawRunConfig.userId.length > 0 ? rawRunConfig.userId : "";
55539
- if (!tenantId2 || !createdBy) return JSON.stringify({ error: "USER_REQUIRED" });
55540
- if (input.visibility === "password" && !input.password) {
55541
- return JSON.stringify({ error: "INVALID_REQUEST" });
55568
+ var targetSchema = import_zod75.z.discriminatedUnion("kind", [
55569
+ fileTargetSchema,
55570
+ mcpAppTargetSchema
55571
+ ]);
55572
+ var publishTargetSchema = import_zod75.z.discriminatedUnion("mode", [
55573
+ import_zod75.z.object({
55574
+ mode: import_zod75.z.literal("link"),
55575
+ target: targetSchema,
55576
+ visibility: import_zod75.z.enum(["public", "password"]),
55577
+ password: import_zod75.z.string().min(1).max(1024).optional(),
55578
+ title: import_zod75.z.string().min(1).max(256).optional(),
55579
+ expiresInMinutes: import_zod75.z.number().int().positive().max(525600).optional(),
55580
+ maxAccess: import_zod75.z.number().int().positive().optional()
55581
+ }),
55582
+ import_zod75.z.object({
55583
+ mode: import_zod75.z.literal("menu"),
55584
+ target: targetSchema,
55585
+ name: import_zod75.z.string().min(1).max(256).optional(),
55586
+ group: import_zod75.z.string().min(1).max(128).optional()
55587
+ })
55588
+ ]).superRefine((value, ctx) => {
55589
+ if (value.mode !== "link") return;
55590
+ if (value.visibility === "password" && !value.password) {
55591
+ ctx.addIssue({
55592
+ code: import_zod75.z.ZodIssueCode.custom,
55593
+ path: ["password"],
55594
+ message: "password is required when visibility is password"
55595
+ });
55596
+ }
55597
+ if (value.visibility === "public" && value.password) {
55598
+ ctx.addIssue({
55599
+ code: import_zod75.z.ZodIssueCode.custom,
55600
+ path: ["password"],
55601
+ message: "password must not be provided when visibility is public"
55602
+ });
55542
55603
  }
55543
- if (input.visibility === "public" && input.password) {
55544
- return JSON.stringify({ error: "INVALID_REQUEST" });
55604
+ });
55605
+ var listMenuGroupsSchema = import_zod75.z.object({});
55606
+ function menuRegistry() {
55607
+ return getStoreLattice("default", "menu").store;
55608
+ }
55609
+ async function listMenuGroupsHandler(_input, exeConfig) {
55610
+ const tenantId2 = sandboxRunConfigFrom(exeConfig).tenantId;
55611
+ if (!tenantId2) return JSON.stringify({ error: "USER_REQUIRED" });
55612
+ let menu;
55613
+ try {
55614
+ menu = menuRegistry();
55615
+ } catch {
55616
+ return JSON.stringify({ error: "MENU_STORE_UNAVAILABLE" });
55545
55617
  }
55546
- let store2;
55618
+ let items;
55547
55619
  try {
55548
- store2 = getStoreLattice("default", "sharedResource").store;
55620
+ items = await menu.list({ tenantId: tenantId2, menuTarget: "workspace" });
55549
55621
  } catch {
55550
- return JSON.stringify({ error: "SHARE_STORE_UNAVAILABLE" });
55622
+ return JSON.stringify({ error: "MENU_LIST_FAILED" });
55623
+ }
55624
+ const counts = /* @__PURE__ */ new Map();
55625
+ let ungroupedCount = 0;
55626
+ for (const item of items) {
55627
+ const group = typeof item.group === "string" ? item.group.trim() : "";
55628
+ if (!group) {
55629
+ ungroupedCount += 1;
55630
+ continue;
55631
+ }
55632
+ counts.set(group, (counts.get(group) ?? 0) + 1);
55551
55633
  }
55634
+ const groups = [...counts.entries()].map(([name, itemCount]) => ({ name, itemCount })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
55635
+ return JSON.stringify({ groups, ungroupedCount });
55636
+ }
55637
+ var SHARE_CARD_UI_REF = {
55638
+ kind: "plugin",
55639
+ pluginType: "app-share",
55640
+ resource: SHARE_CARD_UI_RESOURCE,
55641
+ displayMode: "inline",
55642
+ title: "Published link"
55643
+ };
55644
+ function runConfigOf(exeConfig) {
55645
+ return exeConfig?.configurable?.runConfig ?? {};
55646
+ }
55647
+ function createdByOf(raw) {
55648
+ return typeof raw.user_id === "string" && raw.user_id.length > 0 ? raw.user_id : typeof raw.userId === "string" && raw.userId.length > 0 ? raw.userId : "";
55649
+ }
55650
+ function basename6(path8) {
55651
+ return path8.replace(/\/+$/, "").split("/").pop() || path8;
55652
+ }
55653
+ function normalizeProjectPath(path8) {
55654
+ const withoutLeadingSlash = path8.startsWith("/") ? path8.slice(1) : path8;
55655
+ const segments = withoutLeadingSlash.split("/");
55656
+ if (segments.some((segment) => segment === "..")) return null;
55657
+ const cleaned = segments.filter(
55658
+ (segment) => segment !== "" && segment !== "."
55659
+ );
55660
+ if (cleaned[0] === "project") cleaned.shift();
55661
+ if (cleaned.length === 0) return null;
55662
+ return cleaned.join("/");
55663
+ }
55664
+ function linkResult(input) {
55665
+ const path8 = `/s/${input.token}`;
55666
+ const envBase = process.env.AXIOM_PUBLIC_BASE_URL?.replace(/\/$/, "");
55667
+ const result = {
55668
+ mode: "link",
55669
+ kind: input.kind,
55670
+ token: input.token,
55671
+ path: path8,
55672
+ ...envBase ? { url: `${envBase}${path8}` } : {},
55673
+ title: input.title,
55674
+ visibility: input.visibility,
55675
+ ...input.password ? { password: input.password } : {},
55676
+ ...input.warnings ? { warnings: input.warnings } : {}
55677
+ };
55678
+ const text = JSON.stringify(result).replace(/`/g, "\\u0060");
55679
+ return appendUiFence(text, SHARE_CARD_UI_REF);
55680
+ }
55681
+ async function resolvePluginTarget(input, raw, tenantId2) {
55552
55682
  const catalog2 = getSandboxPluginCatalog();
55553
55683
  const loaded = await catalog2.ensureLoaded(tenantId2);
55554
55684
  const plugin = loaded.plugins.find((p) => p.meta.type === input.pluginType);
55555
- if (!plugin) return JSON.stringify({ error: "TOOL_NOT_FOUND" });
55685
+ if (!plugin) return { error: "TOOL_NOT_FOUND" };
55556
55686
  const manifest = await catalog2.getValidatedManifest(tenantId2, input.pluginType);
55557
55687
  const toolDef = manifest?.tools?.find((t) => t.name === input.toolName);
55558
- if (!toolDef) return JSON.stringify({ error: "TOOL_NOT_FOUND" });
55559
- if (!toolDef.ui?.resource) return JSON.stringify({ error: "TOOL_NOT_UI" });
55560
- const connections = await resolvePluginConnections(
55561
- input.pluginType,
55562
- input.connectionKey ? { connections: [input.connectionKey] } : { connectAll: true },
55563
- { tenantId: tenantId2 }
55564
- );
55565
- if (input.connectionKey && connections.length === 0) {
55566
- return JSON.stringify({ error: "CONNECTION_NOT_FOUND" });
55567
- }
55568
- if (!input.connectionKey && plugin.connection && connections.length === 0) {
55569
- return JSON.stringify({ error: "CONNECTION_REQUIRED" });
55570
- }
55571
- if (!input.connectionKey && plugin.connection && connections.length > 1) {
55572
- return JSON.stringify({
55573
- error: "CONNECTION_AMBIGUOUS",
55574
- keys: connections.map((c) => c.key)
55575
- });
55688
+ if (!toolDef) return { error: "TOOL_NOT_FOUND" };
55689
+ if (!toolDef.ui?.resource) return { error: "TOOL_NOT_UI" };
55690
+ let connectionKey = input.connectionKey;
55691
+ if (plugin.connection || input.connectionKey) {
55692
+ const connections = await resolvePluginConnections(
55693
+ input.pluginType,
55694
+ input.connectionKey ? { connections: [input.connectionKey] } : { connectAll: true },
55695
+ { tenantId: tenantId2 }
55696
+ );
55697
+ if (input.connectionKey && connections.length === 0) {
55698
+ return { error: "CONNECTION_NOT_FOUND" };
55699
+ }
55700
+ if (!input.connectionKey && plugin.connection && connections.length === 0) {
55701
+ return { error: "CONNECTION_REQUIRED" };
55702
+ }
55703
+ if (!input.connectionKey && plugin.connection && connections.length > 1) {
55704
+ return { error: "CONNECTION_AMBIGUOUS", keys: connections.map((c) => c.key) };
55705
+ }
55706
+ connectionKey = input.connectionKey ?? connections[0]?.key;
55576
55707
  }
55577
- const connectionKey = input.connectionKey ?? connections[0]?.key;
55578
55708
  const scope = signMcpUiScope({
55579
55709
  tid: tenantId2,
55580
- thid: runConfig.threadId,
55581
- aid: runConfig.assistantId,
55582
- wid: runConfig.workspaceId,
55583
- pid: runConfig.projectId,
55710
+ thid: typeof raw.thread_id === "string" ? raw.thread_id : void 0,
55711
+ aid: typeof raw.assistant_id === "string" ? raw.assistant_id : void 0,
55712
+ wid: typeof raw.workspaceId === "string" ? raw.workspaceId : void 0,
55713
+ pid: typeof raw.projectId === "string" ? raw.projectId : void 0,
55584
55714
  plugin: input.pluginType,
55585
55715
  resource: toolDef.ui.resource,
55586
55716
  ck: connectionKey
55587
55717
  });
55588
- if (!scope) return JSON.stringify({ error: "SCOPE_UNAVAILABLE" });
55589
- let payload;
55718
+ if (!scope) return { error: "SCOPE_UNAVAILABLE" };
55719
+ return {
55720
+ scope,
55721
+ resource: toolDef.ui.resource,
55722
+ displayMode: toolDef.ui.displayMode ?? "inline",
55723
+ toolName: input.toolName
55724
+ };
55725
+ }
55726
+ var MENU_TOOL_INPUT_MAX_BYTES = 256 * 1024;
55727
+ var MENU_MCP_WARNING = "menu pins are tenant-visible and reuse the selected connection";
55728
+ function matchesScope(cfg, workspaceId, projectId) {
55729
+ return String(cfg.workspaceId ?? "") === workspaceId && String(cfg.projectId ?? "") === projectId;
55730
+ }
55731
+ async function publishMenu(input, raw, ctx) {
55732
+ let menu;
55590
55733
  try {
55591
- payload = createMcpAppSharePayload({
55592
- tenantId: tenantId2,
55593
- createdBy,
55594
- workspaceId: runConfig.workspaceId ?? "",
55595
- projectId: runConfig.projectId ?? "",
55596
- app: {
55597
- kind: "plugin",
55598
- pluginType: input.pluginType,
55599
- resource: toolDef.ui.resource,
55600
- scope,
55601
- toolName: input.toolName,
55602
- displayMode: toolDef.ui.displayMode ?? "inline",
55603
- toolInput: input.input ?? {}
55604
- },
55605
- title: input.title,
55606
- visibility: input.visibility,
55607
- password: input.password,
55608
- expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4) : void 0,
55609
- maxAccess: input.maxAccess
55610
- });
55611
- } catch (error) {
55612
- if (error instanceof SharePayloadError) {
55613
- return JSON.stringify({ error: error.code });
55734
+ menu = menuRegistry();
55735
+ } catch {
55736
+ return JSON.stringify({ error: "MENU_STORE_UNAVAILABLE" });
55737
+ }
55738
+ let contentType;
55739
+ let contentConfig;
55740
+ let defaultName;
55741
+ if (input.target.kind === "file") {
55742
+ const resourcePath = normalizeProjectPath(input.target.path);
55743
+ if (resourcePath === null) {
55744
+ return JSON.stringify({ error: "INVALID_TARGET" });
55745
+ }
55746
+ contentType = "file";
55747
+ defaultName = basename6(resourcePath);
55748
+ contentConfig = {
55749
+ resourcePath,
55750
+ fileName: defaultName,
55751
+ tenantId: ctx.tenantId,
55752
+ workspaceId: ctx.workspaceId,
55753
+ projectId: ctx.projectId,
55754
+ ...typeof raw.assistant_id === "string" ? { assistantId: raw.assistant_id } : {}
55755
+ };
55756
+ } else {
55757
+ const toolInput = input.target.input ?? {};
55758
+ if (Buffer.byteLength(JSON.stringify(toolInput), "utf8") > MENU_TOOL_INPUT_MAX_BYTES) {
55759
+ return JSON.stringify({ error: "PAYLOAD_TOO_LARGE" });
55614
55760
  }
55615
- throw error;
55761
+ let resolved;
55762
+ try {
55763
+ const outcome = await resolvePluginTarget(input.target, raw, ctx.tenantId);
55764
+ if ("error" in outcome) return JSON.stringify(outcome);
55765
+ resolved = outcome;
55766
+ } catch {
55767
+ return JSON.stringify({ error: "MENU_PIN_FAILED" });
55768
+ }
55769
+ contentType = "mcpApp";
55770
+ defaultName = resolved.toolName;
55771
+ contentConfig = {
55772
+ kind: "plugin",
55773
+ pluginType: input.target.pluginType,
55774
+ resource: resolved.resource,
55775
+ scope: resolved.scope,
55776
+ displayMode: resolved.displayMode,
55777
+ toolName: resolved.toolName,
55778
+ toolInput,
55779
+ workspaceId: ctx.workspaceId,
55780
+ projectId: ctx.projectId
55781
+ };
55616
55782
  }
55783
+ let items;
55617
55784
  try {
55618
- await store2.create(payload);
55785
+ items = await menu.list({ tenantId: ctx.tenantId, menuTarget: "workspace" });
55786
+ } catch {
55787
+ return JSON.stringify({ error: "MENU_LIST_FAILED" });
55788
+ }
55789
+ const existing = items.find((item) => {
55790
+ if (item.contentType !== contentType) return false;
55791
+ if (!matchesScope(
55792
+ item.contentConfig,
55793
+ ctx.workspaceId,
55794
+ ctx.projectId
55795
+ )) {
55796
+ return false;
55797
+ }
55798
+ if (contentType === "file") {
55799
+ return item.contentConfig.resourcePath === contentConfig.resourcePath;
55800
+ }
55801
+ const cfg = item.contentConfig;
55802
+ const next = contentConfig;
55803
+ return cfg.kind === "plugin" && next.kind === "plugin" && cfg.pluginType === next.pluginType && cfg.resource === next.resource;
55804
+ });
55805
+ const name = input.name?.trim() || existing?.name || defaultName;
55806
+ const group = input.group?.trim() || void 0;
55807
+ try {
55808
+ if (existing) {
55809
+ const merged = {
55810
+ ...existing.contentConfig,
55811
+ ...contentConfig
55812
+ };
55813
+ if (contentType === "mcpApp") {
55814
+ delete merged.toolResult;
55815
+ delete merged.ui;
55816
+ }
55817
+ const updated = await menu.update(existing.id, {
55818
+ contentConfig: merged,
55819
+ name,
55820
+ ...group ? { group } : {}
55821
+ });
55822
+ console.info(JSON.stringify({
55823
+ event: "publish.pinned",
55824
+ userId: ctx.createdBy,
55825
+ tenantId: ctx.tenantId,
55826
+ workspaceId: ctx.workspaceId,
55827
+ projectId: ctx.projectId,
55828
+ kind: contentType,
55829
+ menuItemId: updated.id,
55830
+ created: false
55831
+ }));
55832
+ return JSON.stringify({
55833
+ mode: "menu",
55834
+ kind: contentType,
55835
+ menuItemId: updated.id,
55836
+ name: updated.name,
55837
+ ...updated.group ? { group: updated.group } : {},
55838
+ ...contentType === "mcpApp" ? { warnings: [MENU_MCP_WARNING] } : {},
55839
+ alreadyPinned: true,
55840
+ refreshOnOpen: contentType === "mcpApp"
55841
+ });
55842
+ }
55843
+ const created = await menu.create({
55844
+ tenantId: ctx.tenantId,
55845
+ menuTarget: "workspace",
55846
+ contentType,
55847
+ contentConfig,
55848
+ name,
55849
+ ...group ? { group } : {},
55850
+ sortOrder: 0
55851
+ });
55852
+ console.info(JSON.stringify({
55853
+ event: "publish.pinned",
55854
+ userId: ctx.createdBy,
55855
+ tenantId: ctx.tenantId,
55856
+ workspaceId: ctx.workspaceId,
55857
+ projectId: ctx.projectId,
55858
+ kind: contentType,
55859
+ menuItemId: created.id,
55860
+ created: true
55861
+ }));
55862
+ return JSON.stringify({
55863
+ mode: "menu",
55864
+ kind: contentType,
55865
+ menuItemId: created.id,
55866
+ name: created.name,
55867
+ ...created.group ? { group: created.group } : {},
55868
+ ...contentType === "mcpApp" ? { warnings: [MENU_MCP_WARNING] } : {},
55869
+ alreadyPinned: false,
55870
+ refreshOnOpen: contentType === "mcpApp"
55871
+ });
55619
55872
  } catch {
55620
- return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
55873
+ return JSON.stringify({ error: "MENU_PIN_FAILED" });
55621
55874
  }
55622
- console.info(JSON.stringify({
55623
- event: "share.created",
55624
- tenantId: tenantId2,
55625
- userId: createdBy,
55626
- kind: "mcpApp",
55627
- appKind: "plugin",
55628
- pluginType: input.pluginType,
55629
- tool: input.toolName,
55630
- visibility: input.visibility,
55631
- tokenPrefix: payload.token.slice(0, 8)
55632
- }));
55633
- const path8 = `/s/${payload.token}`;
55634
- const envBase = process.env.AXIOM_PUBLIC_BASE_URL?.replace(/\/$/, "");
55635
- const result = {
55636
- path: path8,
55637
- ...envBase ? { url: `${envBase}${path8}` } : {},
55638
- token: payload.token,
55639
- title: payload.title ?? "Shared app",
55640
- visibility: payload.visibility,
55641
- ...input.visibility === "password" && input.password ? { password: input.password } : {},
55642
- ...input.visibility === "public" ? { warnings: ["public share delegates the selected plugin connection"] } : {}
55643
- };
55644
- const resultText = JSON.stringify(result).replace(/`/g, "\\u0060");
55645
- return appendUiFence(resultText, SHARE_CARD_UI_REF);
55646
55875
  }
55876
+ async function publishTargetHandler(input, exeConfig) {
55877
+ const raw = runConfigOf(exeConfig);
55878
+ const tenantId2 = typeof raw.tenantId === "string" ? raw.tenantId : "";
55879
+ const createdBy = createdByOf(raw);
55880
+ const workspaceId = typeof raw.workspaceId === "string" ? raw.workspaceId : "";
55881
+ const projectId = typeof raw.projectId === "string" ? raw.projectId : "";
55882
+ if (!tenantId2 || !createdBy) return JSON.stringify({ error: "USER_REQUIRED" });
55883
+ if (!workspaceId || !projectId) return JSON.stringify({ error: "SCOPE_REQUIRED" });
55884
+ if (input.mode === "link") {
55885
+ if (input.visibility === "password" && !input.password) {
55886
+ return JSON.stringify({ error: "INVALID_REQUEST" });
55887
+ }
55888
+ if (input.visibility === "public" && input.password) {
55889
+ return JSON.stringify({ error: "INVALID_REQUEST" });
55890
+ }
55891
+ let store2;
55892
+ try {
55893
+ store2 = getStoreLattice("default", "sharedResource").store;
55894
+ } catch {
55895
+ return JSON.stringify({ error: "SHARE_STORE_UNAVAILABLE" });
55896
+ }
55897
+ if (input.target.kind === "file") {
55898
+ const resourcePath = normalizeProjectPath(input.target.path);
55899
+ if (resourcePath === null) {
55900
+ return JSON.stringify({ error: "INVALID_TARGET" });
55901
+ }
55902
+ try {
55903
+ const payload = createSharePayload(tenantId2, workspaceId, projectId, createdBy, {
55904
+ resourcePath: input.target.path,
55905
+ assistantId: typeof raw.assistant_id === "string" ? raw.assistant_id : void 0,
55906
+ title: input.title ?? basename6(resourcePath),
55907
+ visibility: input.visibility,
55908
+ password: input.password,
55909
+ expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4).toISOString() : void 0,
55910
+ maxAccess: input.maxAccess
55911
+ });
55912
+ const token = generateToken();
55913
+ try {
55914
+ await store2.create({ ...payload, token });
55915
+ } catch {
55916
+ return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
55917
+ }
55918
+ console.info(JSON.stringify({
55919
+ event: "publish.created",
55920
+ tenantId: tenantId2,
55921
+ userId: createdBy,
55922
+ mode: "link",
55923
+ kind: "file",
55924
+ visibility: input.visibility,
55925
+ tokenPrefix: token.slice(0, 8)
55926
+ }));
55927
+ return linkResult({
55928
+ kind: "file",
55929
+ token,
55930
+ title: payload.title ?? basename6(resourcePath),
55931
+ visibility: input.visibility,
55932
+ password: input.password,
55933
+ warnings: input.visibility === "public" ? [
55934
+ "anyone with the link can access this file; artifact app api scripts can execute"
55935
+ ] : void 0
55936
+ });
55937
+ } catch {
55938
+ return JSON.stringify({ error: "INVALID_TARGET" });
55939
+ }
55940
+ } else {
55941
+ let resolved;
55942
+ try {
55943
+ const outcome = await resolvePluginTarget(input.target, raw, tenantId2);
55944
+ if ("error" in outcome) return JSON.stringify(outcome);
55945
+ resolved = outcome;
55946
+ } catch {
55947
+ return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
55948
+ }
55949
+ try {
55950
+ const payload = createMcpAppSharePayload({
55951
+ tenantId: tenantId2,
55952
+ createdBy,
55953
+ workspaceId,
55954
+ projectId,
55955
+ app: {
55956
+ kind: "plugin",
55957
+ pluginType: input.target.pluginType,
55958
+ resource: resolved.resource,
55959
+ scope: resolved.scope,
55960
+ toolName: resolved.toolName,
55961
+ displayMode: resolved.displayMode,
55962
+ toolInput: input.target.input ?? {}
55963
+ },
55964
+ title: input.title,
55965
+ visibility: input.visibility,
55966
+ password: input.password,
55967
+ expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4) : void 0,
55968
+ maxAccess: input.maxAccess
55969
+ });
55970
+ try {
55971
+ await store2.create(payload);
55972
+ } catch {
55973
+ return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
55974
+ }
55975
+ console.info(JSON.stringify({
55976
+ event: "publish.created",
55977
+ tenantId: tenantId2,
55978
+ userId: createdBy,
55979
+ mode: "link",
55980
+ kind: "mcpApp",
55981
+ visibility: input.visibility,
55982
+ pluginType: input.target.pluginType,
55983
+ toolName: input.target.toolName,
55984
+ tokenPrefix: payload.token.slice(0, 8)
55985
+ }));
55986
+ return linkResult({
55987
+ kind: "mcpApp",
55988
+ token: payload.token,
55989
+ title: payload.title ?? resolved.toolName,
55990
+ visibility: input.visibility,
55991
+ password: input.password,
55992
+ warnings: input.visibility === "public" ? ["public share delegates the selected plugin connection"] : void 0
55993
+ });
55994
+ } catch (error) {
55995
+ return JSON.stringify({
55996
+ error: error instanceof SharePayloadError ? error.code : "SHARE_CREATE_FAILED"
55997
+ });
55998
+ }
55999
+ }
56000
+ }
56001
+ return publishMenu(input, raw, { tenantId: tenantId2, workspaceId, projectId, createdBy });
56002
+ }
56003
+
56004
+ // src/middlewares/appShareSkill.ts
56005
+ var APP_SHARE_PUBLISHING_SKILL = `---
56006
+ name: app-share-publishing
56007
+ description: Use when a user explicitly asks to publish, share, or pin a project file, artifact app, or tenant plugin MCP App; covers link generation and workspace menu pinning.
56008
+ ---
56009
+
56010
+ # Publishing files and MCP Apps
56011
+
56012
+ \`publish_target\` is the only tool that creates a share or menu pin.
56013
+ \`list_menu_groups\` is read-only discovery of existing workspace menu groups.
56014
+ Publish only when the human explicitly asks to publish, share, or pin something.
56015
+
56016
+ ## Target kinds
56017
+ - \`{ kind: "file", path }\` \u2014 a project-relative file, directory, or artifact app
56018
+ directory. Artifact apps are directories containing \`index.html\`; pass the
56019
+ directory, not \`index.html\`. Paths are project-relative: \`..\` is rejected and
56020
+ the project root is not shareable.
56021
+ - \`{ kind: "mcpApp", pluginType, toolName, input?, connectionKey? }\` \u2014 a
56022
+ UI-bearing sandbox plugin tool.
56023
+
56024
+ ## Modes
56025
+ - \`mode: "link"\` \u2014 creates \`/s/<token>\`. \`visibility\` (\`public | password\`)
56026
+ has no default: ask the human to choose before creating a link. Only \`password\`
56027
+ visibility takes a \`password\`; title, expiresInMinutes, maxAccess are optional.
56028
+ - \`mode: "menu"\` \u2014 pins to the menu, tenant-visible and scoped to the current
56029
+ project. \`name\` and \`group\` are optional; call \`list_menu_groups\` first and
56030
+ choose an existing group or confirm a new one with the human. Before pinning a
56031
+ connection-backed App, confirm with the human that the pin is tenant-visible
56032
+ and reuses the selected connection.
56033
+
56034
+ ## What the link or pin does
56035
+ - File links and pins serve the current file from the project volume. They do not
56036
+ re-run a tool and are not a frozen snapshot. Directory and artifact-app links
56037
+ also expose the App's \`api/*.js\` / \`api/*.py\` scripts for execution.
56038
+ - MCP App links and pins re-run the tool on every open, so tools with write side
56039
+ effects run every time. A public MCP link delegates the selected plugin
56040
+ connection.
56041
+ - Warn the human before creating a public link: anyone with the URL can access a
56042
+ public file (including its artifact-app API scripts), and a public MCP link
56043
+ delegates the selected plugin connection.
56044
+
56045
+ ## Connections
56046
+ Pass \`connectionKey\` when the plugin has multiple connections.
56047
+ \`CONNECTION_AMBIGUOUS\` means ask which key to use; \`CONNECTION_REQUIRED\` means
56048
+ ask the human to configure one first. Never put credentials in \`input\`.
56049
+
56050
+ ## Result
56051
+ - Link: \`token\`, \`path\` (plus \`url\` when a public base URL is configured),
56052
+ title, visibility, optional \`password\`, and \`warnings\`.
56053
+ - Menu: \`menuItemId\`, \`name\`, optional \`group\`, \`warnings\` (MCP App pins),
56054
+ \`alreadyPinned\`, \`refreshOnOpen\`.
56055
+
56056
+ ## Errors
56057
+ - \`TOOL_NOT_FOUND\` / \`TOOL_NOT_UI\`: choose an available UI-bearing plugin tool.
56058
+ - \`CONNECTION_NOT_FOUND\` / \`CONNECTION_REQUIRED\` / \`CONNECTION_AMBIGUOUS\`: fix
56059
+ the connection selection, or ask the human to configure one.
56060
+ - \`SCOPE_REQUIRED\` / \`SCOPE_UNAVAILABLE\`: the run lacks workspace/project scope,
56061
+ or the deployment cannot sign MCP UI scopes.
56062
+ - \`INVALID_TARGET\`: the file path escapes the project, targets the root, or the
56063
+ target shape is unsupported.
56064
+ - \`PAYLOAD_TOO_LARGE\`: reduce the stored tool input.
56065
+ - \`SHARE_STORE_UNAVAILABLE\` / \`MENU_STORE_UNAVAILABLE\`: the store is not
56066
+ configured.
56067
+ - \`MENU_LIST_FAILED\` / \`MENU_PIN_FAILED\`: retry, or report the menu failure.
56068
+ `;
56069
+
56070
+ // src/middlewares/appShareMiddleware.ts
55647
56071
  var appSharePlugin = {
55648
56072
  meta: {
55649
56073
  type: "app-share",
55650
- name: "App Share",
55651
- description: "Publish a sandbox plugin MCP App as a share link.",
55652
- version: "1.0.0",
55653
- tools: [{
55654
- name: "share_app",
55655
- description: "Publish a UI-bearing sandbox plugin tool as a share link. Only call when the user explicitly asks to publish or share an app. visibility is required (public or password). A public share delegates the selected plugin connection capability, so warn the user. The initial arguments are stored and the tool is re-run on every link open; the tool result is never persisted.",
55656
- ui: { resource: SHARE_CARD_UI_RESOURCE, displayMode: "inline" }
55657
- }],
56074
+ name: "Publish",
56075
+ description: "Publish project files and sandbox plugin MCP Apps as links or workspace menu items.",
56076
+ version: "2.0.0",
56077
+ tools: [
56078
+ {
56079
+ name: "publish_target",
56080
+ description: "Publish a project file (including directories and artifact apps) or a UI-bearing sandbox plugin tool. mode=link creates a share link; mode=menu pins it to the workspace menu. Only call when the user explicitly asks to publish, share, or pin. For menu groups, call list_menu_groups first. Links re-run MCP Apps on every open; file links serve the file.",
56081
+ ui: { resource: SHARE_CARD_UI_RESOURCE, displayMode: "inline" }
56082
+ },
56083
+ {
56084
+ name: "list_menu_groups",
56085
+ description: "List workspace menu groups and counts before choosing a pin group. Read-only."
56086
+ }
56087
+ ],
55658
56088
  uiResources: {
55659
56089
  [SHARE_CARD_UI_RESOURCE]: { html: SHARE_CARD_APP_HTML }
55660
56090
  },
@@ -55663,27 +56093,29 @@ var appSharePlugin = {
55663
56093
  },
55664
56094
  skills: {
55665
56095
  "app-share-publishing": {
55666
- version: "1.0.0",
56096
+ version: "2.0.0",
55667
56097
  content: APP_SHARE_PUBLISHING_SKILL
55668
56098
  }
55669
56099
  },
55670
56100
  middleware: () => ({
55671
56101
  name: "appShareMiddleware",
55672
56102
  tools: [
55673
- (0, import_langchain87.tool)(
55674
- async (input, exeConfig) => shareAppHandler(input, exeConfig),
55675
- {
55676
- name: "share_app",
55677
- description: "Publish a UI-bearing sandbox plugin tool as a share link. Only call when the user explicitly asks to publish or share an app. visibility is required: ask the user whether the link should be public or password-protected. A public share delegates the selected plugin connection capability, so warn the user. The initial arguments are stored and the tool is re-run on every link open; the tool result is never persisted.",
55678
- schema: shareAppSchema
55679
- }
55680
- )
56103
+ (0, import_langchain88.tool)(publishTargetHandler, {
56104
+ name: "publish_target",
56105
+ description: "Publish a file or MCP App as a link or workspace menu item.",
56106
+ schema: publishTargetSchema
56107
+ }),
56108
+ (0, import_langchain88.tool)(listMenuGroupsHandler, {
56109
+ name: "list_menu_groups",
56110
+ description: "List workspace menu groups and counts before choosing a pin group. Read-only.",
56111
+ schema: listMenuGroupsSchema
56112
+ })
55681
56113
  ]
55682
56114
  })
55683
56115
  };
55684
56116
 
55685
56117
  // src/middlewares/longTermStoreMiddleware.ts
55686
- var import_langchain88 = require("langchain");
56118
+ var import_langchain89 = require("langchain");
55687
56119
  var import_zod76 = require("zod");
55688
56120
  var import_protocols49 = require("@axiom-lattice/protocols");
55689
56121
  var DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
@@ -55926,7 +56358,7 @@ function createLongTermStoreMiddleware(config = {}) {
55926
56358
  }
55927
56359
  return resolveNamespace(config, scope, relative4);
55928
56360
  };
55929
- const putTool = (0, import_langchain88.tool)(
56361
+ const putTool = (0, import_langchain89.tool)(
55930
56362
  async (input, exeConfig) => {
55931
56363
  const resolved = resolve4(exeConfig, input.namespace);
55932
56364
  if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
@@ -55957,7 +56389,7 @@ function createLongTermStoreMiddleware(config = {}) {
55957
56389
  schema: putSchema
55958
56390
  }
55959
56391
  );
55960
- const getTool = (0, import_langchain88.tool)(
56392
+ const getTool = (0, import_langchain89.tool)(
55961
56393
  async (input, exeConfig) => {
55962
56394
  const resolved = resolve4(exeConfig, input.namespace);
55963
56395
  if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
@@ -55981,7 +56413,7 @@ function createLongTermStoreMiddleware(config = {}) {
55981
56413
  schema: getSchema
55982
56414
  }
55983
56415
  );
55984
- const searchTool = (0, import_langchain88.tool)(
56416
+ const searchTool = (0, import_langchain89.tool)(
55985
56417
  async (input, exeConfig) => {
55986
56418
  const resolved = resolve4(exeConfig, input.namespace);
55987
56419
  if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
@@ -56008,7 +56440,7 @@ function createLongTermStoreMiddleware(config = {}) {
56008
56440
  schema: searchSchema2
56009
56441
  }
56010
56442
  );
56011
- const deleteTool = (0, import_langchain88.tool)(
56443
+ const deleteTool = (0, import_langchain89.tool)(
56012
56444
  async (input, exeConfig) => {
56013
56445
  const resolved = resolve4(exeConfig, input.namespace);
56014
56446
  if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
@@ -56032,7 +56464,7 @@ function createLongTermStoreMiddleware(config = {}) {
56032
56464
  schema: deleteSchema
56033
56465
  }
56034
56466
  );
56035
- const namespacesTool = (0, import_langchain88.tool)(
56467
+ const namespacesTool = (0, import_langchain89.tool)(
56036
56468
  async (input, exeConfig) => {
56037
56469
  const resolved = resolve4(exeConfig, input.namespace);
56038
56470
  if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
@@ -56060,7 +56492,7 @@ function createLongTermStoreMiddleware(config = {}) {
56060
56492
  schema: namespacesSchema
56061
56493
  }
56062
56494
  );
56063
- return (0, import_langchain88.createMiddleware)({
56495
+ return (0, import_langchain89.createMiddleware)({
56064
56496
  name: "LongTermStoreMiddleware",
56065
56497
  tools: readOnly ? [getTool, searchTool, namespacesTool] : [putTool, getTool, searchTool, deleteTool, namespacesTool]
56066
56498
  });
@@ -57207,6 +57639,7 @@ registerBuiltinPlugins();
57207
57639
  InMemoryProjectRoomMessageStore,
57208
57640
  InMemoryProjectRoomReadStateStore,
57209
57641
  InMemoryProjectRoomStore,
57642
+ InMemoryProjectStore,
57210
57643
  InMemorySharedResourceStore,
57211
57644
  InMemoryStore,
57212
57645
  InMemoryTaskStore,
@@ -57510,6 +57943,7 @@ registerBuiltinPlugins();
57510
57943
  isValidSkillName,
57511
57944
  jsonSchemaToZod,
57512
57945
  listCollectionEntries,
57946
+ listMenuGroupsSchema,
57513
57947
  listModelLatticesForTenant,
57514
57948
  listSandboxProviderTypes,
57515
57949
  listTenantPlugins,
@@ -57551,6 +57985,7 @@ registerBuiltinPlugins();
57551
57985
  provisionSandboxOpenClient,
57552
57986
  publishCollectionChanged,
57553
57987
  publishPluginCatalogChanged,
57988
+ publishTargetSchema,
57554
57989
  queueLatticeManager,
57555
57990
  readContextWindow,
57556
57991
  readLoopBreakerConfig,
@@ -57617,7 +58052,6 @@ registerBuiltinPlugins();
57617
58052
  setPluginDeploymentService,
57618
58053
  setRunCancelHeartbeatFallbackObserver,
57619
58054
  setSandboxPluginCatalog,
57620
- shareAppSchema,
57621
58055
  signMcpUiScope,
57622
58056
  skillLatticeManager,
57623
58057
  sqlDatabaseManager,