@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.mjs CHANGED
@@ -19793,6 +19793,48 @@ function ensurePatchToolCallsMiddleware(middleware) {
19793
19793
  });
19794
19794
  }
19795
19795
 
19796
+ // src/deep_agent_new/middleware/structuredOutputCarrier.ts
19797
+ import { AIMessage as AIMessage5, createMiddleware as createMiddleware12 } from "langchain";
19798
+ var STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME = "structuredOutputCarrierMiddleware";
19799
+ function createStructuredOutputCarrierMiddleware() {
19800
+ return createMiddleware12({
19801
+ name: STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME,
19802
+ wrapModelCall: async (request, handler) => {
19803
+ const result = await handler(request);
19804
+ if (AIMessage5.isInstance(result)) return result;
19805
+ const structured = readStructuredOutputResult(result);
19806
+ if (!structured) return result;
19807
+ const carrier = new AIMessage5({ content: "" });
19808
+ carrier.structuredResponse = structured.structuredResponse;
19809
+ carrier.messages = structured.messages;
19810
+ return carrier;
19811
+ }
19812
+ });
19813
+ }
19814
+ function ensureStructuredOutputCarrierMiddleware(middleware) {
19815
+ const matches = middleware.filter(
19816
+ (candidate) => candidate.name === STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
19817
+ );
19818
+ const withoutCarrier = middleware.filter(
19819
+ (candidate) => candidate.name !== STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
19820
+ );
19821
+ const carrier = matches[0] ?? createStructuredOutputCarrierMiddleware();
19822
+ if (matches.length === 1 && middleware[middleware.length - 1] === carrier) {
19823
+ return middleware;
19824
+ }
19825
+ return [...withoutCarrier, carrier];
19826
+ }
19827
+ function readStructuredOutputResult(value) {
19828
+ if (typeof value !== "object" || value === null) return void 0;
19829
+ if (!("structuredResponse" in value)) return void 0;
19830
+ const record = value;
19831
+ if (!Array.isArray(record.messages)) return void 0;
19832
+ return {
19833
+ structuredResponse: record.structuredResponse,
19834
+ messages: record.messages
19835
+ };
19836
+ }
19837
+
19796
19838
  // src/agent_lattice/builders/commonMiddleware.ts
19797
19839
  import { summarizationMiddleware } from "langchain";
19798
19840
 
@@ -19885,7 +19927,7 @@ function createSandboxResolver(getSandboxFromConfig) {
19885
19927
  }
19886
19928
 
19887
19929
  // src/middlewares/evalMiddleware.ts
19888
- import { createMiddleware as createMiddleware12, tool as tool39 } from "langchain";
19930
+ import { createMiddleware as createMiddleware13, tool as tool39 } from "langchain";
19889
19931
  import { z as z44 } from "zod";
19890
19932
  import { v4 as uuidv43 } from "uuid";
19891
19933
 
@@ -20553,7 +20595,7 @@ var evalPlugin = {
20553
20595
  defaultConfig: {}
20554
20596
  },
20555
20597
  skills: EVAL_SKILLS,
20556
- middleware: () => createMiddleware12({
20598
+ middleware: () => createMiddleware13({
20557
20599
  name: "EvalMiddleware",
20558
20600
  tools: [createReadEvalTool(), createManageEvalTool(), createRunEvalTool()]
20559
20601
  })
@@ -21406,7 +21448,7 @@ function validateSandboxPluginManifest(args) {
21406
21448
  }
21407
21449
 
21408
21450
  // src/sandbox_plugin/SandboxPluginCompiler.ts
21409
- import { createMiddleware as createMiddleware13, tool as tool40 } from "langchain";
21451
+ import { createMiddleware as createMiddleware14, tool as tool40 } from "langchain";
21410
21452
 
21411
21453
  // src/connection/PluginConnectionResolver.ts
21412
21454
  async function resolvePluginConnections(type, config, scope) {
@@ -21768,7 +21810,7 @@ function compileSandboxPlugin(args) {
21768
21810
  { name: t.name, description: t.description, schema: jsonSchemaToZod(t.schema) }
21769
21811
  )
21770
21812
  );
21771
- return createMiddleware13({ name: `SandboxPlugin:${manifest.type}`, tools });
21813
+ return createMiddleware14({ name: `SandboxPlugin:${manifest.type}`, tools });
21772
21814
  },
21773
21815
  skills: manifest.skills,
21774
21816
  agents: manifest.agents
@@ -22645,7 +22687,7 @@ var CapabilityToolRegistry = class {
22645
22687
 
22646
22688
  // src/middlewares/capabilityGuardMiddleware.ts
22647
22689
  import { ToolMessage as ToolMessage6 } from "@langchain/core/messages";
22648
- import { createMiddleware as createMiddleware14 } from "langchain";
22690
+ import { createMiddleware as createMiddleware15 } from "langchain";
22649
22691
  function isRecord11(value) {
22650
22692
  return typeof value === "object" && value !== null && !Array.isArray(value);
22651
22693
  }
@@ -22711,7 +22753,7 @@ function denialMessage(toolCall, denial) {
22711
22753
  });
22712
22754
  }
22713
22755
  function createCapabilityGuardMiddleware(registry4) {
22714
- return createMiddleware14({
22756
+ return createMiddleware15({
22715
22757
  name: "CapabilityGuardMiddleware",
22716
22758
  wrapToolCall: async (request, handler) => {
22717
22759
  const toolName2 = request.toolCall.name;
@@ -23080,7 +23122,7 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
23080
23122
  break;
23081
23123
  }
23082
23124
  }
23083
- return middlewares;
23125
+ return ensureStructuredOutputCarrierMiddleware(middlewares);
23084
23126
  }
23085
23127
 
23086
23128
  // src/deep_agent_new/backends/sandboxFiles.ts
@@ -23332,7 +23374,7 @@ import {
23332
23374
  // src/deep_agent_new/middleware/subagents.ts
23333
23375
  import { z as z47 } from "zod/v3";
23334
23376
  import {
23335
- createMiddleware as createMiddleware15,
23377
+ createMiddleware as createMiddleware16,
23336
23378
  createAgent as createAgent2,
23337
23379
  tool as tool41,
23338
23380
  ToolMessage as ToolMessage8,
@@ -24035,7 +24077,7 @@ function normalizeAgentInterrupts(state, threadId) {
24035
24077
  }
24036
24078
 
24037
24079
  // src/services/Agent.ts
24038
- import { AIMessage as AIMessage5, filterMessages, HumanMessage as HumanMessage4, SystemMessage as SystemMessage2, ToolMessage as ToolMessage7 } from "langchain";
24080
+ import { AIMessage as AIMessage6, filterMessages, HumanMessage as HumanMessage4, SystemMessage as SystemMessage2, ToolMessage as ToolMessage7 } from "langchain";
24039
24081
 
24040
24082
  // src/chunk_buffer_lattice/types.ts
24041
24083
  var ThreadEndError = class extends Error {
@@ -26817,7 +26859,7 @@ function executeRunInputMessages(input, fallbackMessageId) {
26817
26859
  case "system":
26818
26860
  return new SystemMessage2(fields);
26819
26861
  case "assistant":
26820
- return new AIMessage5(fields);
26862
+ return new AIMessage6(fields);
26821
26863
  case "tool":
26822
26864
  return new ToolMessage7({
26823
26865
  ...fields,
@@ -27690,7 +27732,7 @@ var Agent = class {
27690
27732
  case "system":
27691
27733
  return new SystemMessage2(fields);
27692
27734
  case "assistant":
27693
- return new AIMessage5(fields);
27735
+ return new AIMessage6(fields);
27694
27736
  case "tool":
27695
27737
  return new ToolMessage7({
27696
27738
  ...fields,
@@ -30087,7 +30129,7 @@ function createGeneralPurposeAgent(options) {
30087
30129
  model: options.model,
30088
30130
  systemPrompt: DEFAULT_SUBAGENT_PROMPT,
30089
30131
  tools: options.tools,
30090
- middleware,
30132
+ middleware: ensureStructuredOutputCarrierMiddleware(middleware),
30091
30133
  stateSchema: withRunGovernanceStateSchema(withToolCallLimitStateSchema()),
30092
30134
  checkpointer: getCheckpointSaver("default"),
30093
30135
  name: "general-purpose"
@@ -30299,7 +30341,7 @@ function getSubagents(options) {
30299
30341
  model: agentParams.model ?? defaultModel,
30300
30342
  systemPrompt: agentParams.systemPrompt,
30301
30343
  tools: agentParams.tools ?? defaultTools,
30302
- middleware,
30344
+ middleware: ensureStructuredOutputCarrierMiddleware(middleware),
30303
30345
  stateSchema: withRunGovernanceStateSchema(withToolCallLimitStateSchema()),
30304
30346
  checkpointer: getCheckpointSaver("default")
30305
30347
  });
@@ -30469,7 +30511,7 @@ function createSubAgentMiddleware(options) {
30469
30511
  });
30470
30512
  const allTools = [taskTool];
30471
30513
  const effectiveSystemPrompt = systemPrompt;
30472
- return createMiddleware15({
30514
+ return createMiddleware16({
30473
30515
  name: "subAgentMiddleware",
30474
30516
  tools: allTools,
30475
30517
  wrapModelCall: async (request, handler) => {
@@ -30489,7 +30531,7 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
30489
30531
  }
30490
30532
 
30491
30533
  // src/deep_agent_new/middleware/date.ts
30492
- import { createMiddleware as createMiddleware16, tool as tool42 } from "langchain";
30534
+ import { createMiddleware as createMiddleware17, tool as tool42 } from "langchain";
30493
30535
  import { z as z48 } from "zod";
30494
30536
  function formatCurrentDate(timezone = "UTC") {
30495
30537
  const now = /* @__PURE__ */ new Date();
@@ -30518,7 +30560,7 @@ function generateDateContext(timezone = "UTC") {
30518
30560
  function createDateMiddleware(options = {}) {
30519
30561
  const timezone = options.timezone || "UTC";
30520
30562
  const dateContext = generateDateContext(timezone);
30521
- return createMiddleware16({
30563
+ return createMiddleware17({
30522
30564
  name: "DateMiddleware",
30523
30565
  tools: [
30524
30566
  tool42(
@@ -30617,7 +30659,7 @@ var datePlugin = {
30617
30659
  };
30618
30660
 
30619
30661
  // src/deep_agent_new/middleware/scheduler.ts
30620
- import { tool as tool43, createMiddleware as createMiddleware17 } from "langchain";
30662
+ import { tool as tool43, createMiddleware as createMiddleware18 } from "langchain";
30621
30663
  import { z as z49 } from "zod";
30622
30664
  import { v4 as uuidv44 } from "uuid";
30623
30665
  import { ScheduledTaskStatus as ScheduledTaskStatus3, ScheduleExecutionType as ScheduleExecutionType3 } from "@axiom-lattice/protocols";
@@ -30699,7 +30741,7 @@ function registerAgentAddMessageHandler() {
30699
30741
  function createSchedulerMiddleware(options = {}) {
30700
30742
  const defaultMaxRetries = options.defaultMaxRetries ?? 0;
30701
30743
  registerAgentAddMessageHandler();
30702
- return createMiddleware17({
30744
+ return createMiddleware18({
30703
30745
  name: "SchedulerMiddleware",
30704
30746
  tools: [
30705
30747
  tool43(
@@ -32114,7 +32156,7 @@ var MemoryBackend = class {
32114
32156
  // src/deep_agent_new/middleware/todos.ts
32115
32157
  import { Command as Command4 } from "@langchain/langgraph";
32116
32158
  import { z as z50 } from "zod";
32117
- import { createMiddleware as createMiddleware18, tool as tool44, ToolMessage as ToolMessage9 } from "langchain";
32159
+ import { createMiddleware as createMiddleware19, tool as tool44, ToolMessage as ToolMessage9 } from "langchain";
32118
32160
  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.
32119
32161
  It also helps the user understand the progress of the task and overall progress of their requests.
32120
32162
  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.
@@ -32370,7 +32412,7 @@ function todoListMiddleware(options) {
32370
32412
  })
32371
32413
  }
32372
32414
  );
32373
- return createMiddleware18({
32415
+ return createMiddleware19({
32374
32416
  name: "todoListMiddleware",
32375
32417
  stateSchema,
32376
32418
  tools: [writeTodos],
@@ -32418,7 +32460,7 @@ function createDeepAgent(params = {}) {
32418
32460
  ${BASE_PROMPT}` : BASE_PROMPT;
32419
32461
  const filesystemBackend = backend ? backend : async (config) => new StateBackend(config);
32420
32462
  const postDelegationMiddleware = interruptOn ? [humanInTheLoopMiddleware2({ interruptOn })] : [];
32421
- const middleware = ensurePatchToolCallsMiddleware(assembleDeepAgentMiddleware(
32463
+ const middleware = ensureStructuredOutputCarrierMiddleware(ensurePatchToolCallsMiddleware(assembleDeepAgentMiddleware(
32422
32464
  customMiddleware,
32423
32465
  [
32424
32466
  // Provides todo list management capabilities for tracking tasks
@@ -32454,7 +32496,7 @@ ${BASE_PROMPT}` : BASE_PROMPT;
32454
32496
  // unsupportedModelBehavior: "ignore",
32455
32497
  // })
32456
32498
  postDelegationMiddleware
32457
- ));
32499
+ )));
32458
32500
  return createAgent3({
32459
32501
  model,
32460
32502
  systemPrompt: finalSystemPrompt,
@@ -32548,7 +32590,7 @@ var DeepAgentGraphBuilder = class {
32548
32590
 
32549
32591
  // src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
32550
32592
  import { StateGraph as StateGraph2, MessagesAnnotation } from "@langchain/langgraph";
32551
- import { AIMessage as AIMessage6 } from "@langchain/core/messages";
32593
+ import { AIMessage as AIMessage7 } from "@langchain/core/messages";
32552
32594
 
32553
32595
  // src/services/a2a-client.ts
32554
32596
  import { v4 as uuidv45 } from "uuid";
@@ -32867,7 +32909,13 @@ var A2ARemoteClient = _A2ARemoteClient;
32867
32909
 
32868
32910
  // src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
32869
32911
  import { AgentType as AgentType3 } from "@axiom-lattice/protocols";
32912
+ function resolveA2ARemoteContextId(assistantKey, threadId) {
32913
+ return threadId ? `a2a-remote:${assistantKey}:${threadId}` : void 0;
32914
+ }
32870
32915
  var RemoteAgentGraphBuilder = class {
32916
+ constructor(deps = {}) {
32917
+ this.deps = deps;
32918
+ }
32871
32919
  async build(agentLattice, params) {
32872
32920
  if (agentLattice.config.type !== AgentType3.A2A_REMOTE) {
32873
32921
  throw new Error(
@@ -32875,7 +32923,7 @@ var RemoteAgentGraphBuilder = class {
32875
32923
  );
32876
32924
  }
32877
32925
  const config = agentLattice.config;
32878
- const client = new A2ARemoteClient({
32926
+ const client = this.deps.createClient?.(config) ?? new A2ARemoteClient({
32879
32927
  agentCardUrl: config.agentCardUrl,
32880
32928
  apiKey: config.apiKey,
32881
32929
  timeout: config.timeout
@@ -32887,28 +32935,22 @@ var RemoteAgentGraphBuilder = class {
32887
32935
  if (!text) {
32888
32936
  return {
32889
32937
  messages: [
32890
- new AIMessage6("No text input provided to remote agent.")
32938
+ new AIMessage7("No text input provided to remote agent.")
32891
32939
  ]
32892
32940
  };
32893
32941
  }
32894
- try {
32895
- const fullPrompt = params.prompt ? `${params.prompt}
32942
+ const fullPrompt = params.prompt ? `${params.prompt}
32896
32943
 
32897
32944
  User request:
32898
32945
  ${text}` : text;
32899
- const threadId = langGraphConfig?.configurable?.thread_id;
32900
- const response = await client.sendMessage(fullPrompt, threadId);
32901
- return {
32902
- messages: [new AIMessage6(response)]
32903
- };
32904
- } catch (error) {
32905
- const msg = error.message ?? String(error);
32906
- return {
32907
- messages: [
32908
- new AIMessage6(`Remote A2A agent error: ${msg}`)
32909
- ]
32910
- };
32911
- }
32946
+ const threadId = langGraphConfig?.configurable?.thread_id;
32947
+ const response = await client.sendMessage(
32948
+ fullPrompt,
32949
+ resolveA2ARemoteContextId(config.key, threadId)
32950
+ );
32951
+ return {
32952
+ messages: [new AIMessage7(response)]
32953
+ };
32912
32954
  };
32913
32955
  const workflow = new StateGraph2(MessagesAnnotation).addNode("remote_call", remoteCallNode).addEdge("__start__", "remote_call").addEdge("remote_call", "__end__");
32914
32956
  return workflow.compile({ checkpointer: getCheckpointSaver("default") });
@@ -32995,7 +33037,8 @@ var WorkflowAgentGraphBuilder = class {
32995
33037
  }
32996
33038
  ], void 0, false, void 0, params.model);
32997
33039
  const preservedMiddlewareNames = [
32998
- "patchToolCallsMiddleware"
33040
+ "patchToolCallsMiddleware",
33041
+ STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
32999
33042
  ];
33000
33043
  const noWrapMiddlewares = stripWrapModelCallHook(middlewares, preservedMiddlewareNames);
33001
33044
  const noWrapAskMiddlewares = stripWrapModelCallHook(askMiddlewares, preservedMiddlewareNames);
@@ -38807,12 +38850,23 @@ var MAX_MCP_APP_PAYLOAD_BYTES = 256 * 1024;
38807
38850
  function generateToken() {
38808
38851
  return randomBytes3(TOKEN_BYTES).toString("base64url");
38809
38852
  }
38853
+ function normalizeShareResourcePath(raw) {
38854
+ const withoutLeadingSlash = raw.startsWith("/") ? raw.slice(1) : raw;
38855
+ const withoutProject = withoutLeadingSlash.replace(/^project(?:\/|$)/, "");
38856
+ const segments = withoutProject.split("/");
38857
+ if (segments.some((segment) => segment === "..")) return null;
38858
+ const cleaned = segments.filter(
38859
+ (segment) => segment !== "" && segment !== "."
38860
+ );
38861
+ if (cleaned.length === 0) return null;
38862
+ return cleaned.join("/");
38863
+ }
38810
38864
  function createSharePayload(tenantId2, workspaceId, projectId, userId, request) {
38811
- const resourcePath = (request.resourcePath || "").replace(/^\/?project\/?/, "").replace(/\/+$/, "");
38812
- if (!resourcePath || resourcePath === "/") {
38813
- if (request.visibility !== "internal") {
38814
- throw new Error("Cannot share project root \u2014 share a subdirectory or file instead");
38815
- }
38865
+ const resourcePath = normalizeShareResourcePath(request.resourcePath || "");
38866
+ if (resourcePath === null) {
38867
+ throw new Error(
38868
+ "Invalid resource path \u2014 share a file or subdirectory inside the project"
38869
+ );
38816
38870
  }
38817
38871
  return {
38818
38872
  kind: "file",
@@ -45090,7 +45144,7 @@ async function assertSafeUpstreamUrl(raw) {
45090
45144
  }
45091
45145
 
45092
45146
  // src/middlewares/skillMiddleware.ts
45093
- import { createMiddleware as createMiddleware19 } from "langchain";
45147
+ import { createMiddleware as createMiddleware20 } from "langchain";
45094
45148
 
45095
45149
  // src/tool_lattice/skill/load_skills.ts
45096
45150
  import z52 from "zod";
@@ -45493,7 +45547,7 @@ function createSkillMiddleware(params = {}) {
45493
45547
  } = params;
45494
45548
  const skills = params.skills;
45495
45549
  let latestSkills = [];
45496
- return createMiddleware19({
45550
+ return createMiddleware20({
45497
45551
  name: "skillMiddleware",
45498
45552
  contextSchema,
45499
45553
  tools: [
@@ -45643,7 +45697,7 @@ var skillPlugin = {
45643
45697
  };
45644
45698
 
45645
45699
  // src/middlewares/collectionMiddleware.ts
45646
- import { createMiddleware as createMiddleware20 } from "langchain";
45700
+ import { createMiddleware as createMiddleware21 } from "langchain";
45647
45701
 
45648
45702
  // src/tool_lattice/collection/list_collections.ts
45649
45703
  import z56 from "zod";
@@ -46060,7 +46114,7 @@ var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
46060
46114
  function createCollectionMiddleware(params) {
46061
46115
  const { collectionKeys, connectAll, compileStableCandidateTools = false } = params;
46062
46116
  if (!compileStableCandidateTools && !connectAll && (!collectionKeys || collectionKeys.length === 0)) {
46063
- return createMiddleware20({
46117
+ return createMiddleware21({
46064
46118
  name: "collectionMiddleware",
46065
46119
  contextSchema,
46066
46120
  tools: [
@@ -46070,7 +46124,7 @@ function createCollectionMiddleware(params) {
46070
46124
  });
46071
46125
  }
46072
46126
  const toolParams = { collectionKeys, connectAll };
46073
- return createMiddleware20({
46127
+ return createMiddleware21({
46074
46128
  name: "collectionMiddleware",
46075
46129
  contextSchema,
46076
46130
  tools: [
@@ -46133,7 +46187,7 @@ var collectionPlugin = {
46133
46187
  };
46134
46188
 
46135
46189
  // src/middlewares/askUserClarifyMiddleware.ts
46136
- import { createMiddleware as createMiddleware21, ToolMessage as ToolMessage10 } from "langchain";
46190
+ import { createMiddleware as createMiddleware22, ToolMessage as ToolMessage10 } from "langchain";
46137
46191
  import { interrupt as interrupt3 } from "@langchain/langgraph";
46138
46192
 
46139
46193
  // src/tool_lattice/ask_user_to_clarify/index.ts
@@ -46175,7 +46229,7 @@ function isProjectRoomRun(request) {
46175
46229
  return isRecord13(runConfig?.projectRoom);
46176
46230
  }
46177
46231
  function createAskUserClarifyMiddleware() {
46178
- return createMiddleware21({
46232
+ return createMiddleware22({
46179
46233
  name: "AskUserClarifyMiddleware",
46180
46234
  tools: [createAskUserToClarifyTool()],
46181
46235
  wrapToolCall: async (request, handler) => {
@@ -46279,7 +46333,7 @@ var askUserClarifyPlugin = {
46279
46333
  };
46280
46334
 
46281
46335
  // src/middlewares/widgetMiddleware.ts
46282
- import { createMiddleware as createMiddleware22 } from "langchain";
46336
+ import { createMiddleware as createMiddleware23 } from "langchain";
46283
46337
 
46284
46338
  // src/tool_lattice/widget/loadGuidelines.ts
46285
46339
  import { tool as tool60 } from "langchain";
@@ -47237,7 +47291,7 @@ function createWidgetMiddleware() {
47237
47291
  createLoadGuidelinesTool(),
47238
47292
  createShowWidgetTool()
47239
47293
  ];
47240
- return createMiddleware22({
47294
+ return createMiddleware23({
47241
47295
  name: "widgetMiddleware",
47242
47296
  contextSchema,
47243
47297
  tools
@@ -47261,7 +47315,7 @@ var widgetPlugin = {
47261
47315
  };
47262
47316
 
47263
47317
  // src/middlewares/taskMiddleware.ts
47264
- import { createMiddleware as createMiddleware23, tool as tool62, ToolMessage as ToolMessage11 } from "langchain";
47318
+ import { createMiddleware as createMiddleware24, tool as tool62, ToolMessage as ToolMessage11 } from "langchain";
47265
47319
  import { z as z69 } from "zod";
47266
47320
  import { GraphInterrupt as GraphInterrupt3, interrupt as interrupt4 } from "@langchain/langgraph";
47267
47321
  import { resolveRunScope as resolveRunScope3 } from "@axiom-lattice/protocols";
@@ -49602,7 +49656,7 @@ function createTaskMiddleware(options = {}) {
49602
49656
  ...trustedCaller ? { callerMembershipId: trustedCaller.membershipId, callerAssistantId: trustedCaller.assistantId } : rc.assistant_id ? { callerAssistantId: rc.assistant_id } : {}
49603
49657
  }));
49604
49658
  };
49605
- return createMiddleware23({
49659
+ return createMiddleware24({
49606
49660
  name: "TaskMiddleware",
49607
49661
  contextSchema,
49608
49662
  // Persisted between invocations (ADRs: the run↔task binding survives turns).
@@ -49934,7 +49988,7 @@ canonical Belief State:
49934
49988
  };
49935
49989
 
49936
49990
  // src/middlewares/documentLearningMiddleware.ts
49937
- import { createMiddleware as createMiddleware24 } from "langchain";
49991
+ import { createMiddleware as createMiddleware25 } from "langchain";
49938
49992
 
49939
49993
  // src/middlewares/documentLearningSkills.ts
49940
49994
  var LEARN_CAPABILITY_SKILL = `---
@@ -50173,7 +50227,7 @@ patterns discovered, recommendations. Include validation coverage: user-sample N
50173
50227
  `;
50174
50228
 
50175
50229
  // src/middlewares/documentLearningMiddleware.ts
50176
- var createDocumentLearningMiddleware = () => createMiddleware24({
50230
+ var createDocumentLearningMiddleware = () => createMiddleware25({
50177
50231
  name: "DocumentLearningMiddleware",
50178
50232
  contextSchema,
50179
50233
  tools: []
@@ -50196,7 +50250,7 @@ var documentLearningPlugin = {
50196
50250
  };
50197
50251
 
50198
50252
  // src/middlewares/documentParserMiddleware.ts
50199
- import { createMiddleware as createMiddleware25 } from "langchain";
50253
+ import { createMiddleware as createMiddleware26 } from "langchain";
50200
50254
 
50201
50255
  // src/tool_lattice/document_parser/index.ts
50202
50256
  import * as path7 from "path";
@@ -50861,7 +50915,7 @@ function createDocumentParserMiddleware(config) {
50861
50915
  const baseUrl = config.baseUrl || "";
50862
50916
  const apiKey = config.apiKey || "";
50863
50917
  const connections = Array.isArray(config.connections) ? config.connections.filter((key5) => typeof key5 === "string") : [];
50864
- return createMiddleware25({
50918
+ return createMiddleware26({
50865
50919
  name: "DocumentParser",
50866
50920
  contextSchema,
50867
50921
  tools: [createParseDocumentTool({ connectAll, connections, baseUrl, apiKey })]
@@ -51049,7 +51103,7 @@ import {
51049
51103
  snapshotExactArray as snapshotExactArray2,
51050
51104
  snapshotExactRecord as snapshotExactRecord7
51051
51105
  } from "@axiom-lattice/protocols";
51052
- import { createMiddleware as createMiddleware26, tool as tool64 } from "langchain";
51106
+ import { createMiddleware as createMiddleware27, tool as tool64 } from "langchain";
51053
51107
  import { z as z71 } from "zod";
51054
51108
  var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
51055
51109
  var PROJECT_ROOM_POST_FAILED = "PROJECT_ROOM_POST_FAILED";
@@ -51158,7 +51212,7 @@ async function hasActiveCurrentMembership(scope) {
51158
51212
  return true;
51159
51213
  }
51160
51214
  function createProjectRoomMiddleware() {
51161
- return createMiddleware26({
51215
+ return createMiddleware27({
51162
51216
  name: "ProjectRoomMiddleware",
51163
51217
  tools: [
51164
51218
  tool64(async (input, config) => {
@@ -51254,7 +51308,7 @@ var projectRoomPlugin = {
51254
51308
  };
51255
51309
 
51256
51310
  // src/middlewares/sandboxPluginsMiddleware.ts
51257
- import { createMiddleware as createMiddleware27, tool as tool65 } from "langchain";
51311
+ import { createMiddleware as createMiddleware28, tool as tool65 } from "langchain";
51258
51312
  import { z as z72 } from "zod";
51259
51313
  import { AgentType as AgentType10 } from "@axiom-lattice/protocols";
51260
51314
 
@@ -51950,11 +52004,11 @@ The official \`@modelcontextprotocol/ext-apps\` client SDK reports size
51950
52004
  automatically. Otherwise the panel stays at a default height and content taller
51951
52005
  than the host max scrolls; \`templates/ui.html\` already includes this helper.
51952
52006
 
51953
- ## Sharing the UI as a link
51954
- If the human explicitly asks to publish or share this UI, load
51955
- \`app-share-publishing\` and use \`share_app\`. Public links delegate the selected
51956
- connection and re-run the tool on every open; confirm visibility and warn about
51957
- that delegation first.
52007
+ ## Publishing the UI
52008
+ If the human explicitly asks to publish, share, or pin this UI, load
52009
+ \`app-share-publishing\`. Use \`publish_target\` with \`mode:"link"\` for a URL or
52010
+ \`mode:"menu"\` for the workspace menu; call \`list_menu_groups\` before choosing
52011
+ a group. MCP Apps re-run on every open.
51958
52012
 
51959
52013
  ## Publishing the UI to external MCP clients
51960
52014
  If the tool also sets \`"expose": true\`, its UI is published to Axiom's Open/MCP
@@ -52564,8 +52618,10 @@ Follow the authoring skill's "Decide first" steps to confirm the goal
52564
52618
  (inputs/outputs). If the UI class applies, load "sandbox-plugins-ui" before
52565
52619
  authoring it. If the tool must be callable by external MCP clients via an API key,
52566
52620
  load "sandbox-plugins-expose" and follow it (\`expose: true\` + key grants).
52567
- If the human asks to publish or share the plugin's UI as a link, load
52568
- "app-share-publishing" and follow it; never publish proactively. If a tool must
52621
+ If the human asks to publish/share/pin the plugin UI, load
52622
+ "app-share-publishing" and use \`publish_target\`; never publish proactively.
52623
+ For menu mode, call \`list_menu_groups\` first and choose an existing group or
52624
+ confirm a new one with the human. If a tool must
52569
52625
  call the platform's own tools/agents from its handler, load
52570
52626
  "sandbox-plugins-consume-open" and follow its checklist: declare a password field
52571
52627
  in connection.fields, read it from PLUGIN_CONNECTION_FILE, construct OpenMcpClient
@@ -52903,8 +52959,8 @@ var sandboxPluginsPlugin = {
52903
52959
  {
52904
52960
  id: "app-share",
52905
52961
  type: "app-share",
52906
- name: "App Share",
52907
- description: "Publish a plugin UI tool as a public/password share link",
52962
+ name: "Publish",
52963
+ description: "Publish files or plugin UI tools as links or workspace menu items",
52908
52964
  enabled: true,
52909
52965
  config: {}
52910
52966
  },
@@ -52959,7 +53015,7 @@ var sandboxPluginsPlugin = {
52959
53015
  ]
52960
53016
  }
52961
53017
  },
52962
- middleware: () => createMiddleware27({
53018
+ middleware: () => createMiddleware28({
52963
53019
  name: "SandboxPluginsMiddleware",
52964
53020
  tools: [
52965
53021
  tool65(
@@ -53263,6 +53319,8 @@ var sandboxPluginsPlugin = {
53263
53319
 
53264
53320
  // src/middlewares/appShareMiddleware.ts
53265
53321
  import { tool as tool66 } from "langchain";
53322
+
53323
+ // src/middlewares/appShareTargets.ts
53266
53324
  import { z as z73 } from "zod";
53267
53325
 
53268
53326
  // src/middlewares/appShareUi.ts
@@ -53272,18 +53330,57 @@ var SHARE_CARD_APP_HTML = `<!doctype html>
53272
53330
  <head>
53273
53331
  <meta charset="utf-8" />
53274
53332
  <meta name="viewport" content="width=device-width, initial-scale=1" />
53275
- <title>Shared app</title>
53333
+ <title>Shared link</title>
53276
53334
  <style>
53277
- :root { color-scheme: light dark; }
53278
- body { margin: 0; padding: 12px 14px; font: 13px/1.45 Inter, -apple-system, "Segoe UI", sans-serif; }
53279
- .title { font-weight: 600; font-size: 14px; }
53280
- .tag { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: #eef2ff; color: #4338ca; }
53281
- .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; }
53282
- .pwd { margin: 6px 0; color: #6b7280; font-size: 12px; }
53283
- .actions { display: flex; gap: 8px; margin-top: 8px; }
53284
- button { border: 1px solid #d1d5db; background: #fff; border-radius: 8px; padding: 5px 10px; font: inherit; cursor: pointer; }
53285
- button.primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
53286
- .warn { margin-top: 8px; color: #b45309; font-size: 11px; }
53335
+ :root {
53336
+ color-scheme: light dark;
53337
+ --card-bg: #fff;
53338
+ --card-border: #e5e7eb;
53339
+ --text: #111827;
53340
+ --muted: #6b7280;
53341
+ --accent: #4338ca;
53342
+ --accent-bg: #eef2ff;
53343
+ --warning: #b45309;
53344
+ --btn-bg: #fff;
53345
+ --btn-border: #d1d5db;
53346
+ --btn-text: #111827;
53347
+ --primary-bg: #4f46e5;
53348
+ --primary-border: #4f46e5;
53349
+ --primary-text: #fff;
53350
+ --shadow: 0 1px 2px rgba(0,0,0,.04);
53351
+ }
53352
+ @media (prefers-color-scheme: dark) {
53353
+ :root {
53354
+ --card-bg: #111827;
53355
+ --card-border: #374151;
53356
+ --text: #f9fafb;
53357
+ --muted: #9ca3af;
53358
+ --accent: #c7d2fe;
53359
+ --accent-bg: #312e81;
53360
+ --warning: #fbbf24;
53361
+ --btn-bg: #1f2937;
53362
+ --btn-border: #4b5563;
53363
+ --btn-text: #f9fafb;
53364
+ --primary-bg: #6366f1;
53365
+ --primary-border: #6366f1;
53366
+ --primary-text: #fff;
53367
+ --shadow: 0 1px 2px rgba(0,0,0,.4);
53368
+ }
53369
+ }
53370
+ body { margin: 0; padding: 12px 14px; font: 13px/1.45 Inter, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: transparent; }
53371
+ .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); }
53372
+ .head { display: flex; align-items: center; gap: 8px; }
53373
+ .icon { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-bg); color: var(--accent); display: grid; place-items: center; font-size: 14px; }
53374
+ .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
53375
+ .kind { border-radius: 999px; font-size: 11px; padding: 1px 7px; background: var(--accent-bg); color: var(--accent); }
53376
+ .meta { margin: 4px 0 8px; color: var(--muted); font-size: 11px; }
53377
+ .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; }
53378
+ .link:focus-visible { outline: 2px solid var(--primary-bg); outline-offset: 2px; }
53379
+ .pwd { margin-top: 6px; color: var(--muted); font-size: 12px; }
53380
+ .warn { margin-top: 6px; color: var(--warning); font-size: 11px; overflow-wrap: anywhere; }
53381
+ .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
53382
+ 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; }
53383
+ button.primary { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary-text); }
53287
53384
  </style>
53288
53385
  </head>
53289
53386
  <body>
@@ -53316,8 +53413,8 @@ var SHARE_CARD_APP_HTML = `<!doctype html>
53316
53413
  }
53317
53414
  var ZH = (navigator.language || "").toLowerCase().indexOf("zh") === 0;
53318
53415
  var COPY = ZH
53319
- ? { 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" }
53320
- : { copy: "Copy", open: "Open app", password: "Password: ", unavailable: "Share data unavailable.", failed: "Failed to initialize: " };
53416
+ ? { 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" }
53417
+ : { 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: " };
53321
53418
  function esc(v) {
53322
53419
  return String(v == null ? "" : v).replace(/[&<>"']/g, function (ch) {
53323
53420
  return { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[ch];
@@ -53333,26 +53430,39 @@ var SHARE_CARD_APP_HTML = `<!doctype html>
53333
53430
  }
53334
53431
  function render(data) {
53335
53432
  if (!data) { root.innerHTML = "<p>" + COPY.unavailable + "</p>"; sendSize(); return; }
53336
- var html = '<div class="title">' + esc(data.title || "Shared app") + "</div>";
53337
- html += '<span class="tag">' + esc(data.visibility) + "</span>";
53338
- html += '<div class="url">' + esc(data.url || data.path) + "</div>";
53433
+ var title = data.title || "Published link";
53434
+ var full = data.url || data.path;
53435
+ var html = '<div class="card">';
53436
+ 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>';
53437
+ html += '<div class="meta">' + (data.visibility === "password" ? COPY.passwordTag : COPY.publicTag) + "</div>";
53438
+ html += '<div class="link" role="button" tabindex="0" aria-label="' + esc(COPY.copyLink) + '" title="' + esc(full) + '">' + esc(full) + "</div>";
53339
53439
  if (data.password) html += '<div class="pwd">' + COPY.password + esc(data.password) + "</div>";
53340
- html += '<div class="actions">';
53341
- html += '<button id="copy">' + COPY.copy + "</button>";
53342
- html += '<button class="primary" id="open">' + COPY.open + "</button>";
53343
- html += "</div>";
53344
53440
  if (data.warnings && data.warnings.length) {
53345
- html += '<div class="warn">' + esc(data.warnings.join(" ")) + "</div>";
53441
+ var warning = data.warnings.join(" ");
53442
+ html += '<div class="warn" title="' + esc(warning) + '">' + esc(warning) + "</div>";
53346
53443
  }
53444
+ html += '<div class="actions">';
53445
+ html += '<button id="copy" aria-label="' + esc(COPY.copy) + '">' + COPY.copy + "</button>";
53446
+ html += '<button id="open" class="primary" aria-label="' + esc(COPY.open) + '">' + COPY.open + "</button>";
53447
+ html += "</div></div>";
53347
53448
  root.innerHTML = html;
53348
- document.getElementById("copy").onclick = function () {
53449
+ function copyLink() {
53349
53450
  rpc("ui/copy-link", {
53350
53451
  title: data.title,
53351
53452
  url: data.url || data.path,
53352
53453
  password: data.password,
53353
53454
  passwordLabel: COPY.password
53354
53455
  }).catch(function () {});
53456
+ }
53457
+ var link = document.querySelector(".link");
53458
+ link.onclick = copyLink;
53459
+ link.onkeydown = function (event) {
53460
+ if (event.key === "Enter" || event.key === " ") {
53461
+ event.preventDefault();
53462
+ copyLink();
53463
+ }
53355
53464
  };
53465
+ document.getElementById("copy").onclick = copyLink;
53356
53466
  document.getElementById("open").onclick = function () {
53357
53467
  rpc("ui/open-link", { url: data.url || data.path }).catch(function () {});
53358
53468
  };
@@ -53382,220 +53492,538 @@ var SHARE_CARD_APP_HTML = `<!doctype html>
53382
53492
  </body>
53383
53493
  </html>`;
53384
53494
 
53385
- // src/middlewares/appShareSkill.ts
53386
- var APP_SHARE_PUBLISHING_SKILL = `---
53387
- name: app-share-publishing
53388
- 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.
53389
- ---
53390
-
53391
- # Publishing a plugin UI as a share link
53392
-
53393
- \`share_app\` publishes a UI-bearing tool from a tenant sandbox plugin. It does
53394
- not publish agents, files, or MCP-server UIs.
53395
-
53396
- ## Preconditions
53397
- - The plugin is authored, and \`manage_plugin validate\` / \`reload\` / \`test\` passes.
53398
- - The target tool declares \`ui.resource\`.
53399
- - A connection is configured if the plugin needs one. Pass \`connectionKey\` when
53400
- the plugin has multiple connections.
53401
- - Publish only when the human explicitly asks. Never share proactively.
53402
-
53403
- ## Ask before creating
53404
- - visibility: \`public\` or \`password\` (required; there is no default).
53405
- - password when visibility is \`password\`.
53406
- - Optional: title, \`expiresInMinutes\`, \`maxAccess\`.
53407
- - Confirm the initial \`input\`; it is stored and re-run on every open. Never put
53408
- credentials or other secrets in \`input\`.
53409
-
53410
- ## Call
53411
- \`\`\`json
53412
- {
53413
- "pluginType": "<plugin type>",
53414
- "toolName": "<UI-bearing tool>",
53415
- "input": {},
53416
- "connectionKey": "<selected connection, when needed>",
53417
- "visibility": "public | password",
53418
- "password": "<required for password>",
53419
- "title": "<optional>",
53420
- "expiresInMinutes": 1440,
53421
- "maxAccess": 100
53422
- }
53423
- \`\`\`
53424
-
53425
- The result contains the relative link (\`path\`), token, title, visibility,
53426
- optional password, and warnings, plus an inline share card.
53427
-
53428
- ## What the link does
53429
- - Every open re-runs the saved tool with the saved input; results are not
53430
- persisted. Tools with write side effects run on every open.
53431
- - A public share delegates the selected plugin connection: anyone with the link
53432
- can call any tool in that plugin through the gateway. Warn the human before
53433
- creating it.
53434
- - A password share requires the password cookie. Links can be listed and revoked
53435
- on the Shares page.
53436
-
53437
- ## Errors
53438
- - \`TOOL_NOT_UI\` / \`TOOL_NOT_FOUND\`: choose a UI-bearing tool from the plugin.
53439
- - \`CONNECTION_REQUIRED\`: ask the human to configure the plugin connection first.
53440
- - \`CONNECTION_AMBIGUOUS\`: ask which \`connectionKey\` to use.
53441
- - \`CONNECTION_NOT_FOUND\`: verify the requested connection key.
53442
- - \`SCOPE_UNAVAILABLE\`: the deployment cannot sign MCP UI scopes.
53443
- - \`PAYLOAD_TOO_LARGE\`: reduce the stored input.
53444
- - \`USER_REQUIRED\`: invoke from an authenticated user context.
53445
-
53446
- ## Do not
53447
- - Do not use \`share_app\` for non-UI tools or file shares.
53448
- - Do not claim the shared view is a frozen snapshot; it re-executes.
53449
- - Do not include credentials or secrets in \`input\`.
53450
- `;
53451
-
53452
- // src/middlewares/appShareMiddleware.ts
53453
- var SHARE_CARD_UI_REF = {
53454
- kind: "plugin",
53455
- pluginType: "app-share",
53456
- resource: SHARE_CARD_UI_RESOURCE,
53457
- displayMode: "inline",
53458
- title: "Shared app"
53459
- };
53460
- function rawRunConfigFrom(exeConfig) {
53461
- const config = exeConfig;
53462
- return config?.configurable?.runConfig ?? {};
53463
- }
53464
- var shareAppSchema = z73.object({
53495
+ // src/middlewares/appShareTargets.ts
53496
+ var fileTargetSchema = z73.object({
53497
+ kind: z73.literal("file"),
53498
+ path: z73.string().min(1)
53499
+ });
53500
+ var mcpAppTargetSchema = z73.object({
53501
+ kind: z73.literal("mcpApp"),
53465
53502
  pluginType: z73.string().min(1),
53466
53503
  toolName: z73.string().min(1),
53467
53504
  input: z73.record(z73.unknown()).optional(),
53468
- connectionKey: z73.string().min(1).optional(),
53469
- title: z73.string().min(1).max(256).optional(),
53470
- visibility: z73.enum(["public", "password"]),
53471
- password: z73.string().min(1).max(1024).optional(),
53472
- expiresInMinutes: z73.number().int().positive().max(525600).optional(),
53473
- maxAccess: z73.number().int().positive().optional()
53505
+ connectionKey: z73.string().min(1).optional()
53474
53506
  });
53475
- async function shareAppHandler(input, exeConfig) {
53476
- const runConfig = { ...sandboxRunConfigFrom(exeConfig) };
53477
- const rawRunConfig = rawRunConfigFrom(exeConfig);
53478
- const tenantId2 = runConfig.tenantId;
53479
- 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 : "";
53480
- if (!tenantId2 || !createdBy) return JSON.stringify({ error: "USER_REQUIRED" });
53481
- if (input.visibility === "password" && !input.password) {
53482
- return JSON.stringify({ error: "INVALID_REQUEST" });
53507
+ var targetSchema = z73.discriminatedUnion("kind", [
53508
+ fileTargetSchema,
53509
+ mcpAppTargetSchema
53510
+ ]);
53511
+ var publishTargetSchema = z73.discriminatedUnion("mode", [
53512
+ z73.object({
53513
+ mode: z73.literal("link"),
53514
+ target: targetSchema,
53515
+ visibility: z73.enum(["public", "password"]),
53516
+ password: z73.string().min(1).max(1024).optional(),
53517
+ title: z73.string().min(1).max(256).optional(),
53518
+ expiresInMinutes: z73.number().int().positive().max(525600).optional(),
53519
+ maxAccess: z73.number().int().positive().optional()
53520
+ }),
53521
+ z73.object({
53522
+ mode: z73.literal("menu"),
53523
+ target: targetSchema,
53524
+ name: z73.string().min(1).max(256).optional(),
53525
+ group: z73.string().min(1).max(128).optional()
53526
+ })
53527
+ ]).superRefine((value, ctx) => {
53528
+ if (value.mode !== "link") return;
53529
+ if (value.visibility === "password" && !value.password) {
53530
+ ctx.addIssue({
53531
+ code: z73.ZodIssueCode.custom,
53532
+ path: ["password"],
53533
+ message: "password is required when visibility is password"
53534
+ });
53535
+ }
53536
+ if (value.visibility === "public" && value.password) {
53537
+ ctx.addIssue({
53538
+ code: z73.ZodIssueCode.custom,
53539
+ path: ["password"],
53540
+ message: "password must not be provided when visibility is public"
53541
+ });
53483
53542
  }
53484
- if (input.visibility === "public" && input.password) {
53485
- return JSON.stringify({ error: "INVALID_REQUEST" });
53543
+ });
53544
+ var listMenuGroupsSchema = z73.object({});
53545
+ function menuRegistry() {
53546
+ return getStoreLattice("default", "menu").store;
53547
+ }
53548
+ async function listMenuGroupsHandler(_input, exeConfig) {
53549
+ const tenantId2 = sandboxRunConfigFrom(exeConfig).tenantId;
53550
+ if (!tenantId2) return JSON.stringify({ error: "USER_REQUIRED" });
53551
+ let menu;
53552
+ try {
53553
+ menu = menuRegistry();
53554
+ } catch {
53555
+ return JSON.stringify({ error: "MENU_STORE_UNAVAILABLE" });
53486
53556
  }
53487
- let store2;
53557
+ let items;
53488
53558
  try {
53489
- store2 = getStoreLattice("default", "sharedResource").store;
53559
+ items = await menu.list({ tenantId: tenantId2, menuTarget: "workspace" });
53490
53560
  } catch {
53491
- return JSON.stringify({ error: "SHARE_STORE_UNAVAILABLE" });
53561
+ return JSON.stringify({ error: "MENU_LIST_FAILED" });
53562
+ }
53563
+ const counts = /* @__PURE__ */ new Map();
53564
+ let ungroupedCount = 0;
53565
+ for (const item of items) {
53566
+ const group = typeof item.group === "string" ? item.group.trim() : "";
53567
+ if (!group) {
53568
+ ungroupedCount += 1;
53569
+ continue;
53570
+ }
53571
+ counts.set(group, (counts.get(group) ?? 0) + 1);
53492
53572
  }
53573
+ const groups = [...counts.entries()].map(([name, itemCount]) => ({ name, itemCount })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
53574
+ return JSON.stringify({ groups, ungroupedCount });
53575
+ }
53576
+ var SHARE_CARD_UI_REF = {
53577
+ kind: "plugin",
53578
+ pluginType: "app-share",
53579
+ resource: SHARE_CARD_UI_RESOURCE,
53580
+ displayMode: "inline",
53581
+ title: "Published link"
53582
+ };
53583
+ function runConfigOf(exeConfig) {
53584
+ return exeConfig?.configurable?.runConfig ?? {};
53585
+ }
53586
+ function createdByOf(raw) {
53587
+ return typeof raw.user_id === "string" && raw.user_id.length > 0 ? raw.user_id : typeof raw.userId === "string" && raw.userId.length > 0 ? raw.userId : "";
53588
+ }
53589
+ function basename6(path8) {
53590
+ return path8.replace(/\/+$/, "").split("/").pop() || path8;
53591
+ }
53592
+ function normalizeProjectPath(path8) {
53593
+ const withoutLeadingSlash = path8.startsWith("/") ? path8.slice(1) : path8;
53594
+ const segments = withoutLeadingSlash.split("/");
53595
+ if (segments.some((segment) => segment === "..")) return null;
53596
+ const cleaned = segments.filter(
53597
+ (segment) => segment !== "" && segment !== "."
53598
+ );
53599
+ if (cleaned[0] === "project") cleaned.shift();
53600
+ if (cleaned.length === 0) return null;
53601
+ return cleaned.join("/");
53602
+ }
53603
+ function linkResult(input) {
53604
+ const path8 = `/s/${input.token}`;
53605
+ const envBase = process.env.AXIOM_PUBLIC_BASE_URL?.replace(/\/$/, "");
53606
+ const result = {
53607
+ mode: "link",
53608
+ kind: input.kind,
53609
+ token: input.token,
53610
+ path: path8,
53611
+ ...envBase ? { url: `${envBase}${path8}` } : {},
53612
+ title: input.title,
53613
+ visibility: input.visibility,
53614
+ ...input.password ? { password: input.password } : {},
53615
+ ...input.warnings ? { warnings: input.warnings } : {}
53616
+ };
53617
+ const text = JSON.stringify(result).replace(/`/g, "\\u0060");
53618
+ return appendUiFence(text, SHARE_CARD_UI_REF);
53619
+ }
53620
+ async function resolvePluginTarget(input, raw, tenantId2) {
53493
53621
  const catalog2 = getSandboxPluginCatalog();
53494
53622
  const loaded = await catalog2.ensureLoaded(tenantId2);
53495
53623
  const plugin = loaded.plugins.find((p) => p.meta.type === input.pluginType);
53496
- if (!plugin) return JSON.stringify({ error: "TOOL_NOT_FOUND" });
53624
+ if (!plugin) return { error: "TOOL_NOT_FOUND" };
53497
53625
  const manifest = await catalog2.getValidatedManifest(tenantId2, input.pluginType);
53498
53626
  const toolDef = manifest?.tools?.find((t) => t.name === input.toolName);
53499
- if (!toolDef) return JSON.stringify({ error: "TOOL_NOT_FOUND" });
53500
- if (!toolDef.ui?.resource) return JSON.stringify({ error: "TOOL_NOT_UI" });
53501
- const connections = await resolvePluginConnections(
53502
- input.pluginType,
53503
- input.connectionKey ? { connections: [input.connectionKey] } : { connectAll: true },
53504
- { tenantId: tenantId2 }
53505
- );
53506
- if (input.connectionKey && connections.length === 0) {
53507
- return JSON.stringify({ error: "CONNECTION_NOT_FOUND" });
53508
- }
53509
- if (!input.connectionKey && plugin.connection && connections.length === 0) {
53510
- return JSON.stringify({ error: "CONNECTION_REQUIRED" });
53511
- }
53512
- if (!input.connectionKey && plugin.connection && connections.length > 1) {
53513
- return JSON.stringify({
53514
- error: "CONNECTION_AMBIGUOUS",
53515
- keys: connections.map((c) => c.key)
53516
- });
53627
+ if (!toolDef) return { error: "TOOL_NOT_FOUND" };
53628
+ if (!toolDef.ui?.resource) return { error: "TOOL_NOT_UI" };
53629
+ let connectionKey = input.connectionKey;
53630
+ if (plugin.connection || input.connectionKey) {
53631
+ const connections = await resolvePluginConnections(
53632
+ input.pluginType,
53633
+ input.connectionKey ? { connections: [input.connectionKey] } : { connectAll: true },
53634
+ { tenantId: tenantId2 }
53635
+ );
53636
+ if (input.connectionKey && connections.length === 0) {
53637
+ return { error: "CONNECTION_NOT_FOUND" };
53638
+ }
53639
+ if (!input.connectionKey && plugin.connection && connections.length === 0) {
53640
+ return { error: "CONNECTION_REQUIRED" };
53641
+ }
53642
+ if (!input.connectionKey && plugin.connection && connections.length > 1) {
53643
+ return { error: "CONNECTION_AMBIGUOUS", keys: connections.map((c) => c.key) };
53644
+ }
53645
+ connectionKey = input.connectionKey ?? connections[0]?.key;
53517
53646
  }
53518
- const connectionKey = input.connectionKey ?? connections[0]?.key;
53519
53647
  const scope = signMcpUiScope({
53520
53648
  tid: tenantId2,
53521
- thid: runConfig.threadId,
53522
- aid: runConfig.assistantId,
53523
- wid: runConfig.workspaceId,
53524
- pid: runConfig.projectId,
53649
+ thid: typeof raw.thread_id === "string" ? raw.thread_id : void 0,
53650
+ aid: typeof raw.assistant_id === "string" ? raw.assistant_id : void 0,
53651
+ wid: typeof raw.workspaceId === "string" ? raw.workspaceId : void 0,
53652
+ pid: typeof raw.projectId === "string" ? raw.projectId : void 0,
53525
53653
  plugin: input.pluginType,
53526
53654
  resource: toolDef.ui.resource,
53527
53655
  ck: connectionKey
53528
53656
  });
53529
- if (!scope) return JSON.stringify({ error: "SCOPE_UNAVAILABLE" });
53530
- let payload;
53657
+ if (!scope) return { error: "SCOPE_UNAVAILABLE" };
53658
+ return {
53659
+ scope,
53660
+ resource: toolDef.ui.resource,
53661
+ displayMode: toolDef.ui.displayMode ?? "inline",
53662
+ toolName: input.toolName
53663
+ };
53664
+ }
53665
+ var MENU_TOOL_INPUT_MAX_BYTES = 256 * 1024;
53666
+ var MENU_MCP_WARNING = "menu pins are tenant-visible and reuse the selected connection";
53667
+ function matchesScope(cfg, workspaceId, projectId) {
53668
+ return String(cfg.workspaceId ?? "") === workspaceId && String(cfg.projectId ?? "") === projectId;
53669
+ }
53670
+ async function publishMenu(input, raw, ctx) {
53671
+ let menu;
53531
53672
  try {
53532
- payload = createMcpAppSharePayload({
53533
- tenantId: tenantId2,
53534
- createdBy,
53535
- workspaceId: runConfig.workspaceId ?? "",
53536
- projectId: runConfig.projectId ?? "",
53537
- app: {
53538
- kind: "plugin",
53539
- pluginType: input.pluginType,
53540
- resource: toolDef.ui.resource,
53541
- scope,
53542
- toolName: input.toolName,
53543
- displayMode: toolDef.ui.displayMode ?? "inline",
53544
- toolInput: input.input ?? {}
53545
- },
53546
- title: input.title,
53547
- visibility: input.visibility,
53548
- password: input.password,
53549
- expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4) : void 0,
53550
- maxAccess: input.maxAccess
53551
- });
53552
- } catch (error) {
53553
- if (error instanceof SharePayloadError) {
53554
- return JSON.stringify({ error: error.code });
53673
+ menu = menuRegistry();
53674
+ } catch {
53675
+ return JSON.stringify({ error: "MENU_STORE_UNAVAILABLE" });
53676
+ }
53677
+ let contentType;
53678
+ let contentConfig;
53679
+ let defaultName;
53680
+ if (input.target.kind === "file") {
53681
+ const resourcePath = normalizeProjectPath(input.target.path);
53682
+ if (resourcePath === null) {
53683
+ return JSON.stringify({ error: "INVALID_TARGET" });
53684
+ }
53685
+ contentType = "file";
53686
+ defaultName = basename6(resourcePath);
53687
+ contentConfig = {
53688
+ resourcePath,
53689
+ fileName: defaultName,
53690
+ tenantId: ctx.tenantId,
53691
+ workspaceId: ctx.workspaceId,
53692
+ projectId: ctx.projectId,
53693
+ ...typeof raw.assistant_id === "string" ? { assistantId: raw.assistant_id } : {}
53694
+ };
53695
+ } else {
53696
+ const toolInput = input.target.input ?? {};
53697
+ if (Buffer.byteLength(JSON.stringify(toolInput), "utf8") > MENU_TOOL_INPUT_MAX_BYTES) {
53698
+ return JSON.stringify({ error: "PAYLOAD_TOO_LARGE" });
53555
53699
  }
53556
- throw error;
53700
+ let resolved;
53701
+ try {
53702
+ const outcome = await resolvePluginTarget(input.target, raw, ctx.tenantId);
53703
+ if ("error" in outcome) return JSON.stringify(outcome);
53704
+ resolved = outcome;
53705
+ } catch {
53706
+ return JSON.stringify({ error: "MENU_PIN_FAILED" });
53707
+ }
53708
+ contentType = "mcpApp";
53709
+ defaultName = resolved.toolName;
53710
+ contentConfig = {
53711
+ kind: "plugin",
53712
+ pluginType: input.target.pluginType,
53713
+ resource: resolved.resource,
53714
+ scope: resolved.scope,
53715
+ displayMode: resolved.displayMode,
53716
+ toolName: resolved.toolName,
53717
+ toolInput,
53718
+ workspaceId: ctx.workspaceId,
53719
+ projectId: ctx.projectId
53720
+ };
53557
53721
  }
53722
+ let items;
53558
53723
  try {
53559
- await store2.create(payload);
53724
+ items = await menu.list({ tenantId: ctx.tenantId, menuTarget: "workspace" });
53560
53725
  } catch {
53561
- return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
53726
+ return JSON.stringify({ error: "MENU_LIST_FAILED" });
53727
+ }
53728
+ const existing = items.find((item) => {
53729
+ if (item.contentType !== contentType) return false;
53730
+ if (!matchesScope(
53731
+ item.contentConfig,
53732
+ ctx.workspaceId,
53733
+ ctx.projectId
53734
+ )) {
53735
+ return false;
53736
+ }
53737
+ if (contentType === "file") {
53738
+ return item.contentConfig.resourcePath === contentConfig.resourcePath;
53739
+ }
53740
+ const cfg = item.contentConfig;
53741
+ const next = contentConfig;
53742
+ return cfg.kind === "plugin" && next.kind === "plugin" && cfg.pluginType === next.pluginType && cfg.resource === next.resource;
53743
+ });
53744
+ const name = input.name?.trim() || existing?.name || defaultName;
53745
+ const group = input.group?.trim() || void 0;
53746
+ try {
53747
+ if (existing) {
53748
+ const merged = {
53749
+ ...existing.contentConfig,
53750
+ ...contentConfig
53751
+ };
53752
+ if (contentType === "mcpApp") {
53753
+ delete merged.toolResult;
53754
+ delete merged.ui;
53755
+ }
53756
+ const updated = await menu.update(existing.id, {
53757
+ contentConfig: merged,
53758
+ name,
53759
+ ...group ? { group } : {}
53760
+ });
53761
+ console.info(JSON.stringify({
53762
+ event: "publish.pinned",
53763
+ userId: ctx.createdBy,
53764
+ tenantId: ctx.tenantId,
53765
+ workspaceId: ctx.workspaceId,
53766
+ projectId: ctx.projectId,
53767
+ kind: contentType,
53768
+ menuItemId: updated.id,
53769
+ created: false
53770
+ }));
53771
+ return JSON.stringify({
53772
+ mode: "menu",
53773
+ kind: contentType,
53774
+ menuItemId: updated.id,
53775
+ name: updated.name,
53776
+ ...updated.group ? { group: updated.group } : {},
53777
+ ...contentType === "mcpApp" ? { warnings: [MENU_MCP_WARNING] } : {},
53778
+ alreadyPinned: true,
53779
+ refreshOnOpen: contentType === "mcpApp"
53780
+ });
53781
+ }
53782
+ const created = await menu.create({
53783
+ tenantId: ctx.tenantId,
53784
+ menuTarget: "workspace",
53785
+ contentType,
53786
+ contentConfig,
53787
+ name,
53788
+ ...group ? { group } : {},
53789
+ sortOrder: 0
53790
+ });
53791
+ console.info(JSON.stringify({
53792
+ event: "publish.pinned",
53793
+ userId: ctx.createdBy,
53794
+ tenantId: ctx.tenantId,
53795
+ workspaceId: ctx.workspaceId,
53796
+ projectId: ctx.projectId,
53797
+ kind: contentType,
53798
+ menuItemId: created.id,
53799
+ created: true
53800
+ }));
53801
+ return JSON.stringify({
53802
+ mode: "menu",
53803
+ kind: contentType,
53804
+ menuItemId: created.id,
53805
+ name: created.name,
53806
+ ...created.group ? { group: created.group } : {},
53807
+ ...contentType === "mcpApp" ? { warnings: [MENU_MCP_WARNING] } : {},
53808
+ alreadyPinned: false,
53809
+ refreshOnOpen: contentType === "mcpApp"
53810
+ });
53811
+ } catch {
53812
+ return JSON.stringify({ error: "MENU_PIN_FAILED" });
53562
53813
  }
53563
- console.info(JSON.stringify({
53564
- event: "share.created",
53565
- tenantId: tenantId2,
53566
- userId: createdBy,
53567
- kind: "mcpApp",
53568
- appKind: "plugin",
53569
- pluginType: input.pluginType,
53570
- tool: input.toolName,
53571
- visibility: input.visibility,
53572
- tokenPrefix: payload.token.slice(0, 8)
53573
- }));
53574
- const path8 = `/s/${payload.token}`;
53575
- const envBase = process.env.AXIOM_PUBLIC_BASE_URL?.replace(/\/$/, "");
53576
- const result = {
53577
- path: path8,
53578
- ...envBase ? { url: `${envBase}${path8}` } : {},
53579
- token: payload.token,
53580
- title: payload.title ?? "Shared app",
53581
- visibility: payload.visibility,
53582
- ...input.visibility === "password" && input.password ? { password: input.password } : {},
53583
- ...input.visibility === "public" ? { warnings: ["public share delegates the selected plugin connection"] } : {}
53584
- };
53585
- const resultText = JSON.stringify(result).replace(/`/g, "\\u0060");
53586
- return appendUiFence(resultText, SHARE_CARD_UI_REF);
53587
53814
  }
53815
+ async function publishTargetHandler(input, exeConfig) {
53816
+ const raw = runConfigOf(exeConfig);
53817
+ const tenantId2 = typeof raw.tenantId === "string" ? raw.tenantId : "";
53818
+ const createdBy = createdByOf(raw);
53819
+ const workspaceId = typeof raw.workspaceId === "string" ? raw.workspaceId : "";
53820
+ const projectId = typeof raw.projectId === "string" ? raw.projectId : "";
53821
+ if (!tenantId2 || !createdBy) return JSON.stringify({ error: "USER_REQUIRED" });
53822
+ if (!workspaceId || !projectId) return JSON.stringify({ error: "SCOPE_REQUIRED" });
53823
+ if (input.mode === "link") {
53824
+ if (input.visibility === "password" && !input.password) {
53825
+ return JSON.stringify({ error: "INVALID_REQUEST" });
53826
+ }
53827
+ if (input.visibility === "public" && input.password) {
53828
+ return JSON.stringify({ error: "INVALID_REQUEST" });
53829
+ }
53830
+ let store2;
53831
+ try {
53832
+ store2 = getStoreLattice("default", "sharedResource").store;
53833
+ } catch {
53834
+ return JSON.stringify({ error: "SHARE_STORE_UNAVAILABLE" });
53835
+ }
53836
+ if (input.target.kind === "file") {
53837
+ const resourcePath = normalizeProjectPath(input.target.path);
53838
+ if (resourcePath === null) {
53839
+ return JSON.stringify({ error: "INVALID_TARGET" });
53840
+ }
53841
+ try {
53842
+ const payload = createSharePayload(tenantId2, workspaceId, projectId, createdBy, {
53843
+ resourcePath: input.target.path,
53844
+ assistantId: typeof raw.assistant_id === "string" ? raw.assistant_id : void 0,
53845
+ title: input.title ?? basename6(resourcePath),
53846
+ visibility: input.visibility,
53847
+ password: input.password,
53848
+ expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4).toISOString() : void 0,
53849
+ maxAccess: input.maxAccess
53850
+ });
53851
+ const token = generateToken();
53852
+ try {
53853
+ await store2.create({ ...payload, token });
53854
+ } catch {
53855
+ return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
53856
+ }
53857
+ console.info(JSON.stringify({
53858
+ event: "publish.created",
53859
+ tenantId: tenantId2,
53860
+ userId: createdBy,
53861
+ mode: "link",
53862
+ kind: "file",
53863
+ visibility: input.visibility,
53864
+ tokenPrefix: token.slice(0, 8)
53865
+ }));
53866
+ return linkResult({
53867
+ kind: "file",
53868
+ token,
53869
+ title: payload.title ?? basename6(resourcePath),
53870
+ visibility: input.visibility,
53871
+ password: input.password,
53872
+ warnings: input.visibility === "public" ? [
53873
+ "anyone with the link can access this file; artifact app api scripts can execute"
53874
+ ] : void 0
53875
+ });
53876
+ } catch {
53877
+ return JSON.stringify({ error: "INVALID_TARGET" });
53878
+ }
53879
+ } else {
53880
+ let resolved;
53881
+ try {
53882
+ const outcome = await resolvePluginTarget(input.target, raw, tenantId2);
53883
+ if ("error" in outcome) return JSON.stringify(outcome);
53884
+ resolved = outcome;
53885
+ } catch {
53886
+ return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
53887
+ }
53888
+ try {
53889
+ const payload = createMcpAppSharePayload({
53890
+ tenantId: tenantId2,
53891
+ createdBy,
53892
+ workspaceId,
53893
+ projectId,
53894
+ app: {
53895
+ kind: "plugin",
53896
+ pluginType: input.target.pluginType,
53897
+ resource: resolved.resource,
53898
+ scope: resolved.scope,
53899
+ toolName: resolved.toolName,
53900
+ displayMode: resolved.displayMode,
53901
+ toolInput: input.target.input ?? {}
53902
+ },
53903
+ title: input.title,
53904
+ visibility: input.visibility,
53905
+ password: input.password,
53906
+ expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4) : void 0,
53907
+ maxAccess: input.maxAccess
53908
+ });
53909
+ try {
53910
+ await store2.create(payload);
53911
+ } catch {
53912
+ return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
53913
+ }
53914
+ console.info(JSON.stringify({
53915
+ event: "publish.created",
53916
+ tenantId: tenantId2,
53917
+ userId: createdBy,
53918
+ mode: "link",
53919
+ kind: "mcpApp",
53920
+ visibility: input.visibility,
53921
+ pluginType: input.target.pluginType,
53922
+ toolName: input.target.toolName,
53923
+ tokenPrefix: payload.token.slice(0, 8)
53924
+ }));
53925
+ return linkResult({
53926
+ kind: "mcpApp",
53927
+ token: payload.token,
53928
+ title: payload.title ?? resolved.toolName,
53929
+ visibility: input.visibility,
53930
+ password: input.password,
53931
+ warnings: input.visibility === "public" ? ["public share delegates the selected plugin connection"] : void 0
53932
+ });
53933
+ } catch (error) {
53934
+ return JSON.stringify({
53935
+ error: error instanceof SharePayloadError ? error.code : "SHARE_CREATE_FAILED"
53936
+ });
53937
+ }
53938
+ }
53939
+ }
53940
+ return publishMenu(input, raw, { tenantId: tenantId2, workspaceId, projectId, createdBy });
53941
+ }
53942
+
53943
+ // src/middlewares/appShareSkill.ts
53944
+ var APP_SHARE_PUBLISHING_SKILL = `---
53945
+ name: app-share-publishing
53946
+ 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.
53947
+ ---
53948
+
53949
+ # Publishing files and MCP Apps
53950
+
53951
+ \`publish_target\` is the only tool that creates a share or menu pin.
53952
+ \`list_menu_groups\` is read-only discovery of existing workspace menu groups.
53953
+ Publish only when the human explicitly asks to publish, share, or pin something.
53954
+
53955
+ ## Target kinds
53956
+ - \`{ kind: "file", path }\` \u2014 a project-relative file, directory, or artifact app
53957
+ directory. Artifact apps are directories containing \`index.html\`; pass the
53958
+ directory, not \`index.html\`. Paths are project-relative: \`..\` is rejected and
53959
+ the project root is not shareable.
53960
+ - \`{ kind: "mcpApp", pluginType, toolName, input?, connectionKey? }\` \u2014 a
53961
+ UI-bearing sandbox plugin tool.
53962
+
53963
+ ## Modes
53964
+ - \`mode: "link"\` \u2014 creates \`/s/<token>\`. \`visibility\` (\`public | password\`)
53965
+ has no default: ask the human to choose before creating a link. Only \`password\`
53966
+ visibility takes a \`password\`; title, expiresInMinutes, maxAccess are optional.
53967
+ - \`mode: "menu"\` \u2014 pins to the menu, tenant-visible and scoped to the current
53968
+ project. \`name\` and \`group\` are optional; call \`list_menu_groups\` first and
53969
+ choose an existing group or confirm a new one with the human. Before pinning a
53970
+ connection-backed App, confirm with the human that the pin is tenant-visible
53971
+ and reuses the selected connection.
53972
+
53973
+ ## What the link or pin does
53974
+ - File links and pins serve the current file from the project volume. They do not
53975
+ re-run a tool and are not a frozen snapshot. Directory and artifact-app links
53976
+ also expose the App's \`api/*.js\` / \`api/*.py\` scripts for execution.
53977
+ - MCP App links and pins re-run the tool on every open, so tools with write side
53978
+ effects run every time. A public MCP link delegates the selected plugin
53979
+ connection.
53980
+ - Warn the human before creating a public link: anyone with the URL can access a
53981
+ public file (including its artifact-app API scripts), and a public MCP link
53982
+ delegates the selected plugin connection.
53983
+
53984
+ ## Connections
53985
+ Pass \`connectionKey\` when the plugin has multiple connections.
53986
+ \`CONNECTION_AMBIGUOUS\` means ask which key to use; \`CONNECTION_REQUIRED\` means
53987
+ ask the human to configure one first. Never put credentials in \`input\`.
53988
+
53989
+ ## Result
53990
+ - Link: \`token\`, \`path\` (plus \`url\` when a public base URL is configured),
53991
+ title, visibility, optional \`password\`, and \`warnings\`.
53992
+ - Menu: \`menuItemId\`, \`name\`, optional \`group\`, \`warnings\` (MCP App pins),
53993
+ \`alreadyPinned\`, \`refreshOnOpen\`.
53994
+
53995
+ ## Errors
53996
+ - \`TOOL_NOT_FOUND\` / \`TOOL_NOT_UI\`: choose an available UI-bearing plugin tool.
53997
+ - \`CONNECTION_NOT_FOUND\` / \`CONNECTION_REQUIRED\` / \`CONNECTION_AMBIGUOUS\`: fix
53998
+ the connection selection, or ask the human to configure one.
53999
+ - \`SCOPE_REQUIRED\` / \`SCOPE_UNAVAILABLE\`: the run lacks workspace/project scope,
54000
+ or the deployment cannot sign MCP UI scopes.
54001
+ - \`INVALID_TARGET\`: the file path escapes the project, targets the root, or the
54002
+ target shape is unsupported.
54003
+ - \`PAYLOAD_TOO_LARGE\`: reduce the stored tool input.
54004
+ - \`SHARE_STORE_UNAVAILABLE\` / \`MENU_STORE_UNAVAILABLE\`: the store is not
54005
+ configured.
54006
+ - \`MENU_LIST_FAILED\` / \`MENU_PIN_FAILED\`: retry, or report the menu failure.
54007
+ `;
54008
+
54009
+ // src/middlewares/appShareMiddleware.ts
53588
54010
  var appSharePlugin = {
53589
54011
  meta: {
53590
54012
  type: "app-share",
53591
- name: "App Share",
53592
- description: "Publish a sandbox plugin MCP App as a share link.",
53593
- version: "1.0.0",
53594
- tools: [{
53595
- name: "share_app",
53596
- 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.",
53597
- ui: { resource: SHARE_CARD_UI_RESOURCE, displayMode: "inline" }
53598
- }],
54013
+ name: "Publish",
54014
+ description: "Publish project files and sandbox plugin MCP Apps as links or workspace menu items.",
54015
+ version: "2.0.0",
54016
+ tools: [
54017
+ {
54018
+ name: "publish_target",
54019
+ 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.",
54020
+ ui: { resource: SHARE_CARD_UI_RESOURCE, displayMode: "inline" }
54021
+ },
54022
+ {
54023
+ name: "list_menu_groups",
54024
+ description: "List workspace menu groups and counts before choosing a pin group. Read-only."
54025
+ }
54026
+ ],
53599
54027
  uiResources: {
53600
54028
  [SHARE_CARD_UI_RESOURCE]: { html: SHARE_CARD_APP_HTML }
53601
54029
  },
@@ -53604,27 +54032,29 @@ var appSharePlugin = {
53604
54032
  },
53605
54033
  skills: {
53606
54034
  "app-share-publishing": {
53607
- version: "1.0.0",
54035
+ version: "2.0.0",
53608
54036
  content: APP_SHARE_PUBLISHING_SKILL
53609
54037
  }
53610
54038
  },
53611
54039
  middleware: () => ({
53612
54040
  name: "appShareMiddleware",
53613
54041
  tools: [
53614
- tool66(
53615
- async (input, exeConfig) => shareAppHandler(input, exeConfig),
53616
- {
53617
- name: "share_app",
53618
- 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.",
53619
- schema: shareAppSchema
53620
- }
53621
- )
54042
+ tool66(publishTargetHandler, {
54043
+ name: "publish_target",
54044
+ description: "Publish a file or MCP App as a link or workspace menu item.",
54045
+ schema: publishTargetSchema
54046
+ }),
54047
+ tool66(listMenuGroupsHandler, {
54048
+ name: "list_menu_groups",
54049
+ description: "List workspace menu groups and counts before choosing a pin group. Read-only.",
54050
+ schema: listMenuGroupsSchema
54051
+ })
53622
54052
  ]
53623
54053
  })
53624
54054
  };
53625
54055
 
53626
54056
  // src/middlewares/longTermStoreMiddleware.ts
53627
- import { createMiddleware as createMiddleware28, tool as tool67 } from "langchain";
54057
+ import { createMiddleware as createMiddleware29, tool as tool67 } from "langchain";
53628
54058
  import { z as z74 } from "zod";
53629
54059
  import {
53630
54060
  STORE_IDENTITY_SEPARATOR as STORE_IDENTITY_SEPARATOR2,
@@ -54004,7 +54434,7 @@ function createLongTermStoreMiddleware(config = {}) {
54004
54434
  schema: namespacesSchema
54005
54435
  }
54006
54436
  );
54007
- return createMiddleware28({
54437
+ return createMiddleware29({
54008
54438
  name: "LongTermStoreMiddleware",
54009
54439
  tools: readOnly ? [getTool, searchTool, namespacesTool] : [putTool, getTool, searchTool, deleteTool, namespacesTool]
54010
54440
  });
@@ -55143,6 +55573,7 @@ export {
55143
55573
  InMemoryProjectRoomMessageStore,
55144
55574
  InMemoryProjectRoomReadStateStore,
55145
55575
  InMemoryProjectRoomStore,
55576
+ InMemoryProjectStore,
55146
55577
  InMemorySharedResourceStore,
55147
55578
  InMemoryStore,
55148
55579
  InMemoryTaskStore,
@@ -55446,6 +55877,7 @@ export {
55446
55877
  isValidSkillName,
55447
55878
  jsonSchemaToZod,
55448
55879
  listCollectionEntries,
55880
+ listMenuGroupsSchema,
55449
55881
  listModelLatticesForTenant,
55450
55882
  listSandboxProviderTypes,
55451
55883
  listTenantPlugins,
@@ -55487,6 +55919,7 @@ export {
55487
55919
  provisionSandboxOpenClient,
55488
55920
  publishCollectionChanged,
55489
55921
  publishPluginCatalogChanged,
55922
+ publishTargetSchema,
55490
55923
  queueLatticeManager,
55491
55924
  readContextWindow,
55492
55925
  readLoopBreakerConfig,
@@ -55553,7 +55986,6 @@ export {
55553
55986
  setPluginDeploymentService,
55554
55987
  setRunCancelHeartbeatFallbackObserver,
55555
55988
  setSandboxPluginCatalog,
55556
- shareAppSchema,
55557
55989
  signMcpUiScope,
55558
55990
  skillLatticeManager,
55559
55991
  sqlDatabaseManager,