@axiom-lattice/core 13.3.1 → 13.4.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
@@ -2788,6 +2788,32 @@ var InMemoryThreadStore = class {
2788
2788
  total: filtered.length
2789
2789
  };
2790
2790
  }
2791
+ async listChannelSenders(tenantId2, channelInstallationId, limit) {
2792
+ const tenantThreads = this.threads.get(tenantId2);
2793
+ if (!tenantThreads) return [];
2794
+ const bySender = /* @__PURE__ */ new Map();
2795
+ for (const assistantThreads of tenantThreads.values()) {
2796
+ for (const thread of assistantThreads.values()) {
2797
+ const metadata = thread.metadata ?? {};
2798
+ if (metadata.channelInstallationId !== channelInstallationId) continue;
2799
+ if (typeof metadata.senderId !== "string" || !metadata.senderId) continue;
2800
+ const existing = bySender.get(metadata.senderId);
2801
+ if (existing && existing.lastSeenAt.getTime() >= thread.updatedAt.getTime()) {
2802
+ continue;
2803
+ }
2804
+ bySender.set(metadata.senderId, {
2805
+ senderId: metadata.senderId,
2806
+ ...typeof metadata.senderDisplayName === "string" && metadata.senderDisplayName ? { displayName: metadata.senderDisplayName } : {},
2807
+ lastSeenAt: thread.updatedAt,
2808
+ lastThreadId: thread.id
2809
+ });
2810
+ }
2811
+ }
2812
+ const bounded = Math.max(1, Math.min(200, Math.floor(limit)));
2813
+ return [...bySender.values()].sort(
2814
+ (left, right) => right.lastSeenAt.getTime() - left.lastSeenAt.getTime()
2815
+ ).slice(0, bounded);
2816
+ }
2791
2817
  /**
2792
2818
  * Get a thread by ID for a specific tenant
2793
2819
  */
@@ -6608,6 +6634,8 @@ var InMemoryChannelInstallationStore = class {
6608
6634
  config: { ...data.config },
6609
6635
  enabled: data.enabled ?? true,
6610
6636
  fallbackAgentId: data.fallbackAgentId,
6637
+ workspaceId: data.workspaceId,
6638
+ projectId: data.projectId,
6611
6639
  rejectWhenNoBinding: data.rejectWhenNoBinding ?? true,
6612
6640
  createdAt: now,
6613
6641
  updatedAt: now
@@ -6631,7 +6659,9 @@ var InMemoryChannelInstallationStore = class {
6631
6659
  name: updates.name !== void 0 ? updates.name : existing.name,
6632
6660
  config: updates.config !== void 0 ? { ...existing.config, ...updates.config } : existing.config,
6633
6661
  enabled: updates.enabled !== void 0 ? updates.enabled : existing.enabled,
6634
- fallbackAgentId: updates.fallbackAgentId !== void 0 ? updates.fallbackAgentId : existing.fallbackAgentId,
6662
+ fallbackAgentId: updates.fallbackAgentId === null || updates.fallbackAgentId === "" ? void 0 : updates.fallbackAgentId !== void 0 ? updates.fallbackAgentId : existing.fallbackAgentId,
6663
+ workspaceId: updates.workspaceId === "" ? void 0 : updates.workspaceId !== void 0 ? updates.workspaceId : existing.workspaceId,
6664
+ projectId: updates.projectId === "" ? void 0 : updates.projectId !== void 0 ? updates.projectId : existing.projectId,
6635
6665
  rejectWhenNoBinding: updates.rejectWhenNoBinding !== void 0 ? updates.rejectWhenNoBinding : existing.rejectWhenNoBinding,
6636
6666
  updatedAt: /* @__PURE__ */ new Date()
6637
6667
  };
@@ -6740,8 +6770,8 @@ var InMemoryBindingStore = class {
6740
6770
  ...existing,
6741
6771
  agentId: patch.agentId ?? existing.agentId,
6742
6772
  threadId: patch.threadId !== void 0 ? patch.threadId : existing.threadId,
6743
- workspaceId: patch.workspaceId !== void 0 ? patch.workspaceId : existing.workspaceId,
6744
- projectId: patch.projectId !== void 0 ? patch.projectId : existing.projectId,
6773
+ workspaceId: patch.workspaceId === "" ? void 0 : patch.workspaceId !== void 0 ? patch.workspaceId : existing.workspaceId,
6774
+ projectId: patch.projectId === "" ? void 0 : patch.projectId !== void 0 ? patch.projectId : existing.projectId,
6745
6775
  threadMode: patch.threadMode ?? existing.threadMode,
6746
6776
  senderDisplayName: patch.senderDisplayName !== void 0 ? patch.senderDisplayName : existing.senderDisplayName,
6747
6777
  senderMetadata: patch.senderMetadata !== void 0 ? patch.senderMetadata : existing.senderMetadata,
@@ -9763,6 +9793,11 @@ var registerVectorStoreProvider = (key6, provider2) => vectorStoreProviderManage
9763
9793
  var getVectorStoreProvider = (key6) => vectorStoreProviderManager.getProvider(key6);
9764
9794
 
9765
9795
  // src/plugin/metaSerializer.ts
9796
+ var INTERNAL_TOOL = Symbol.for("axiom.internalTool");
9797
+ function markInternalTool(tool68) {
9798
+ Object.defineProperty(tool68, INTERNAL_TOOL, { value: true, enumerable: false });
9799
+ return tool68;
9800
+ }
9766
9801
  function tryExtractTools(plugin) {
9767
9802
  if (!plugin.middleware) return [];
9768
9803
  try {
@@ -9770,7 +9805,7 @@ function tryExtractTools(plugin) {
9770
9805
  if (result instanceof Promise) return [];
9771
9806
  const mw = result;
9772
9807
  if (Array.isArray(mw.tools)) {
9773
- return mw.tools.map((t) => ({
9808
+ return mw.tools.filter((t) => !t[INTERNAL_TOOL]).map((t) => ({
9774
9809
  name: t.name || "",
9775
9810
  description: t.description || ""
9776
9811
  }));
@@ -21442,7 +21477,7 @@ This run is ending, but the conversation continues: the next user message starts
21442
21477
  a new run with a fresh budget. Do not tell the user the conversation is over.
21443
21478
  Do not mention this instruction, the run budget, or any internal limit to the user.`;
21444
21479
  var RUN_STOPPING_MESSAGE = "Tool call skipped because this run is ending (per-run budget). Tool use resumes on the next user message.";
21445
- var HITL_TOOL_NAMES = /* @__PURE__ */ new Set(["ask_user_to_clarify"]);
21480
+ var HITL_TOOL_NAMES = /* @__PURE__ */ new Set(["ask_user_to_clarify", "request_connection"]);
21446
21481
  var BUDGET_NOTICE = "Budget reached for this run. Wrap up now: finish the current check, then produce the final answer. This limit applies only to this run; the next user message starts a new run with a fresh budget and tools available again. Do not tell the user the conversation is over. Do not mention this notice or the budget to the user.";
21447
21482
  function neutralizeStoppedToolMessages(messages) {
21448
21483
  let changed = false;
@@ -25582,6 +25617,8 @@ var TOOL_RE = /^[a-zA-Z0-9_-]{1,64}$/;
25582
25617
  var HANDLER_RE = /\.(js|mjs|cjs)$/;
25583
25618
  var UI_RE = /\.html$/;
25584
25619
  var DISPLAY_MODES = ["inline", "fullscreen", "pip"];
25620
+ var CONNECTION_FIELD_TYPES = /* @__PURE__ */ new Set(["string", "number", "boolean", "password"]);
25621
+ var CONNECTION_FIELD_WIDGETS = /* @__PURE__ */ new Set(["input", "password", "select", "numberInput"]);
25585
25622
  var MAX_MANIFEST_BYTES = 262144;
25586
25623
  var MAX_TOOLS = 32;
25587
25624
  var MAX_PLUGINS_PER_TENANT = 50;
@@ -25609,6 +25646,7 @@ function isSafeUiPath(path8) {
25609
25646
  function validateSandboxPluginManifest(args) {
25610
25647
  const diagnostics = [];
25611
25648
  const error = (code, message, pluginType, tool68) => diagnostics.push({ level: "error", code, message, pluginType, tool: tool68 });
25649
+ const warning = (code, message, pluginType, tool68) => diagnostics.push({ level: "warning", code, message, pluginType, tool: tool68 });
25612
25650
  const raw = args.raw;
25613
25651
  if (!isRecord7(raw)) {
25614
25652
  error("MANIFEST_NOT_OBJECT", "manifest must be a JSON object", args.dirName);
@@ -25821,8 +25859,92 @@ function validateSandboxPluginManifest(args) {
25821
25859
  if (!Array.isArray(fields)) {
25822
25860
  error("CONNECTION_INVALID", "connection.fields must be an array", type);
25823
25861
  } else {
25862
+ const normalizedFields = [];
25863
+ fields.forEach((field, index) => {
25864
+ if (!isRecord7(field)) {
25865
+ error(
25866
+ "CONNECTION_FIELD_INVALID",
25867
+ `connection.fields[${index}] must be an object`,
25868
+ type
25869
+ );
25870
+ return;
25871
+ }
25872
+ const key6 = field.key;
25873
+ const fieldType = field.type;
25874
+ const title = field.title;
25875
+ if (typeof key6 !== "string" || key6.trim() === "") {
25876
+ error(
25877
+ "CONNECTION_FIELD_INVALID",
25878
+ `connection.fields[${index}] requires a non-empty string key`,
25879
+ type
25880
+ );
25881
+ return;
25882
+ }
25883
+ if (typeof fieldType !== "string" || !CONNECTION_FIELD_TYPES.has(fieldType)) {
25884
+ error(
25885
+ "CONNECTION_FIELD_INVALID",
25886
+ `connection.fields[${index}] (${key6}) type must be one of ${[
25887
+ ...CONNECTION_FIELD_TYPES
25888
+ ].join(", ")}`,
25889
+ type
25890
+ );
25891
+ return;
25892
+ }
25893
+ if (typeof title !== "string" || title.trim() === "") {
25894
+ error(
25895
+ "CONNECTION_FIELD_INVALID",
25896
+ `connection.fields[${index}] (${key6}) requires a non-empty string title (the human-visible label; use "title", not "label")`,
25897
+ type
25898
+ );
25899
+ return;
25900
+ }
25901
+ if (field.widget !== void 0 && (typeof field.widget !== "string" || !CONNECTION_FIELD_WIDGETS.has(field.widget))) {
25902
+ error(
25903
+ "CONNECTION_FIELD_INVALID",
25904
+ `connection.fields[${index}] (${key6}) widget must be one of ${[
25905
+ ...CONNECTION_FIELD_WIDGETS
25906
+ ].join(", ")}`,
25907
+ type
25908
+ );
25909
+ return;
25910
+ }
25911
+ if (field.required !== void 0 && typeof field.required !== "boolean") {
25912
+ error(
25913
+ "CONNECTION_FIELD_INVALID",
25914
+ `connection.fields[${index}] (${key6}) required must be a boolean`,
25915
+ type
25916
+ );
25917
+ return;
25918
+ }
25919
+ if (field.enumValues !== void 0 && (!Array.isArray(field.enumValues) || field.enumValues.some((value) => typeof value !== "string"))) {
25920
+ error(
25921
+ "CONNECTION_FIELD_INVALID",
25922
+ `connection.fields[${index}] (${key6}) enumValues must be an array of strings`,
25923
+ type
25924
+ );
25925
+ return;
25926
+ }
25927
+ if (field.helpText !== void 0 && typeof field.helpText !== "string") {
25928
+ error(
25929
+ "CONNECTION_FIELD_INVALID",
25930
+ `connection.fields[${index}] (${key6}) helpText must be a string`,
25931
+ type
25932
+ );
25933
+ return;
25934
+ }
25935
+ if (title.trim().toLowerCase() === "label" || title.trim() === key6) {
25936
+ warning(
25937
+ "CONNECTION_FIELD_TITLE_PLACEHOLDER",
25938
+ `connection.fields[${index}] (${key6}) title "${title}" looks like a placeholder; use the human-visible label (for example "API Key")`,
25939
+ type
25940
+ );
25941
+ }
25942
+ normalizedFields.push(
25943
+ field
25944
+ );
25945
+ });
25824
25946
  const normalized = {
25825
- fields
25947
+ fields: normalizedFields
25826
25948
  };
25827
25949
  if (typeof raw.connection.resourceLabel === "string") {
25828
25950
  normalized.resourceLabel = raw.connection.resourceLabel;
@@ -28432,7 +28554,7 @@ function hasExpectedInterrupt(interrupts, expectedInterruptId) {
28432
28554
  return interrupts.length === 1 && interrupts[0]?.interruptId === expectedInterruptId;
28433
28555
  }
28434
28556
  return interrupts.filter(
28435
- (interrupt5) => interrupt5.interruptId === expectedInterruptId
28557
+ (interrupt6) => interrupt6.interruptId === expectedInterruptId
28436
28558
  ).length === 1;
28437
28559
  }
28438
28560
  function normalizeAgentInterrupts(state, threadId) {
@@ -28442,11 +28564,11 @@ function normalizeAgentInterrupts(state, threadId) {
28442
28564
  if (!isRecord12(task) || !Array.isArray(task.interrupts)) return;
28443
28565
  const rawTaskId = task.id;
28444
28566
  const taskId = typeof rawTaskId === "string" || typeof rawTaskId === "number" ? String(rawTaskId) : void 0;
28445
- task.interrupts.forEach((interrupt5, index) => {
28446
- const record = isRecord12(interrupt5) ? interrupt5 : {};
28567
+ task.interrupts.forEach((interrupt6, index) => {
28568
+ const record = isRecord12(interrupt6) ? interrupt6 : {};
28447
28569
  const rawId = record.id;
28448
28570
  const interruptId = typeof rawId === "string" || typeof rawId === "number" ? String(rawId) : `${taskId ?? `task-${taskIndex}`}:${index}`;
28449
- const rawValue = isRecord12(interrupt5) ? record.value : interrupt5;
28571
+ const rawValue = isRecord12(interrupt6) ? record.value : interrupt6;
28450
28572
  const fenced = parseFence(rawValue);
28451
28573
  const value = fenced ? fenced.payload : rawValue;
28452
28574
  let type;
@@ -32802,7 +32924,7 @@ var Agent = class {
32802
32924
  try {
32803
32925
  const state = await this.getCurrentState();
32804
32926
  const durable = (state?.tasks ?? []).some(
32805
- (task) => (task.interrupts ?? []).some((interrupt5) => interrupt5.id === interruptId)
32927
+ (task) => (task.interrupts ?? []).some((interrupt6) => interrupt6.id === interruptId)
32806
32928
  );
32807
32929
  if (durable) return;
32808
32930
  } catch {
@@ -44755,7 +44877,7 @@ function parseJudgeVerdict(raw) {
44755
44877
  }
44756
44878
  }
44757
44879
  var MAX_INTERRUPT_RESUMES = 5;
44758
- function resolveInterruptResponse(policy, interrupt5) {
44880
+ function resolveInterruptResponse(policy, interrupt6) {
44759
44881
  if (policy.mode === "auto-approve") return policy.value ?? "\u540C\u610F";
44760
44882
  if (policy.mode === "auto-reject") return policy.value ?? "\u62D2\u7EDD";
44761
44883
  return policy.value ?? "";
@@ -44857,31 +44979,31 @@ var _LatticeEval = class _LatticeEval {
44857
44979
  let pendingInterrupt;
44858
44980
  let interrupts = Array.isArray(result?.__interrupt__) ? result.__interrupt__ : [];
44859
44981
  while (interrupts.length > 0) {
44860
- const interrupt5 = interrupts[0];
44861
- if (!interrupt5) break;
44982
+ const interrupt6 = interrupts[0];
44983
+ if (!interrupt6) break;
44862
44984
  const policy = interruptPolicy;
44863
44985
  if (!policy || policy.mode === "stop" || resumeCount >= MAX_INTERRUPT_RESUMES) {
44864
- pendingInterrupt = interrupt5;
44986
+ pendingInterrupt = interrupt6;
44865
44987
  break;
44866
44988
  }
44867
- const response = resolveInterruptResponse(policy, interrupt5);
44989
+ const response = resolveInterruptResponse(policy, interrupt6);
44868
44990
  hitlEvents.push({
44869
44991
  type: "interrupt",
44870
- id: interrupt5.id,
44871
- value: interrupt5.value
44992
+ id: interrupt6.id,
44993
+ value: interrupt6.value
44872
44994
  });
44873
44995
  this.log("Auto-resolving HITL interrupt", {
44874
44996
  agent_id: step.agent_id,
44875
44997
  thread_id: threadId,
44876
44998
  mode: policy.mode,
44877
- interrupt_id: interrupt5.id,
44999
+ interrupt_id: interrupt6.id,
44878
45000
  response,
44879
45001
  resume_count: resumeCount + 1
44880
45002
  });
44881
45003
  result = await agent.invokeWithState({ input: stepInput, command: { resume: response } });
44882
45004
  hitlEvents.push({
44883
45005
  type: "interrupt_response",
44884
- id: interrupt5.id,
45006
+ id: interrupt6.id,
44885
45007
  mode: policy.mode,
44886
45008
  response
44887
45009
  });
@@ -44978,7 +45100,7 @@ var _LatticeEval = class _LatticeEval {
44978
45100
  });
44979
45101
  let currentThreadId = threadId;
44980
45102
  let lastResponseData = null;
44981
- let interrupt5;
45103
+ let interrupt6;
44982
45104
  for (const step of evalCase.steps) {
44983
45105
  const result = await this.executeAgentStep(
44984
45106
  step,
@@ -45044,10 +45166,10 @@ ${toolCallStr}` : toolCallStr;
45044
45166
  }
45045
45167
  }
45046
45168
  if (result.interrupted) {
45047
- interrupt5 = result.interrupt;
45169
+ interrupt6 = result.interrupt;
45048
45170
  this.log("Case paused for HITL \u2014 remaining steps skipped; judge will evaluate the pause", {
45049
45171
  case_id: evalCase.caseId,
45050
- interrupt_id: interrupt5?.id
45172
+ interrupt_id: interrupt6?.id
45051
45173
  });
45052
45174
  break;
45053
45175
  }
@@ -45057,7 +45179,7 @@ ${toolCallStr}` : toolCallStr;
45057
45179
  final_thread_id: currentThreadId,
45058
45180
  message_count: this.lastMessages.length
45059
45181
  });
45060
- const finalOutput = interrupt5 ? typeof interrupt5.value === "string" ? interrupt5.value : JSON.stringify(interrupt5.value ?? "") : this.extractFinalMessage(lastResponseData);
45182
+ const finalOutput = interrupt6 ? typeof interrupt6.value === "string" ? interrupt6.value : JSON.stringify(interrupt6.value ?? "") : this.extractFinalMessage(lastResponseData);
45061
45183
  this.lastFinalOutput = finalOutput;
45062
45184
  const trajectory = this.buildTrajectory();
45063
45185
  this.log("Final output extracted", {
@@ -45277,8 +45399,8 @@ Note: if final_score >= 80 and there are no fatal errors, pass should be true; o
45277
45399
  final_score: finalScore,
45278
45400
  dimension_results: dimensionResults,
45279
45401
  summary: parsedResult.summary || testResultContent,
45280
- interrupted: interrupt5 ? true : void 0,
45281
- interrupt: interrupt5 ? { id: interrupt5.id, value: interrupt5.value } : void 0
45402
+ interrupted: interrupt6 ? true : void 0,
45403
+ interrupt: interrupt6 ? { id: interrupt6.id, value: interrupt6.value } : void 0
45282
45404
  };
45283
45405
  }
45284
45406
  };
@@ -56778,6 +56900,7 @@ var projectRoomPlugin = {
56778
56900
 
56779
56901
  // src/middlewares/sandboxPluginsMiddleware.ts
56780
56902
  var import_langchain87 = require("langchain");
56903
+ var import_langgraph14 = require("@langchain/langgraph");
56781
56904
  var import_zod75 = require("zod");
56782
56905
  var import_protocols62 = require("@axiom-lattice/protocols");
56783
56906
 
@@ -57312,7 +57435,7 @@ description: Field-by-field reference for plugin.json of a tenant sandbox plugin
57312
57435
  | \`name\` / \`description\` | Display strings. |
57313
57436
  | \`version\` | Non-empty string; bump it when files change so the hash refreshes. |
57314
57437
  | \`tools[]\` | See below. Max 32 tools. |
57315
- | \`connection\` | Optional; see the sandbox-plugins-connection skill. |
57438
+ | \`connection\` | Optional; \`connection.fields[]\` uses \`{ key, type, title, widget?, required?, default?, enumValues?, helpText? }\` \u2014 \`title\` is the human-visible label (not \`label\`). See the sandbox-plugins-connection skill. |
57316
57439
  | \`skills\` | Optional; keys must start with \`<type>-\`. |
57317
57440
  | \`agents\` | The schema accepts it and tenant plugin agents are registered, but this is **not a supported authoring path** \u2014 do not declare it. Build standalone agents with the Agent Architect (\`agent-architecture\`/\`agent-build\`); built-in plugins may still use this field. |
57318
57441
 
@@ -57665,8 +57788,10 @@ The platform key belongs to a human. Before writing the real handler:
57665
57788
  2. Write a temporary \`handlers/probe.js\` that reads \`PLUGIN_CONNECTION_FILE\`,
57666
57789
  creates \`OpenMcpClient\` with the connection key, and prints
57667
57790
  \`listTools()\` (name, description, inputSchema) as JSON.
57668
- 3. Ask the human to configure the connection + platform key (only a human can
57669
- create the key). Use \`list_connections\` to check whether a connection exists.
57791
+ 3. Call \`list_connections\` first; if no usable connection exists, call
57792
+ \`request_connection { type, pluginKey, toolName, reason }\` \u2014 it opens an inline
57793
+ connection form in the chat. Never ask the user to type, paste, or share any
57794
+ secret (password, API key, token) in chat.
57670
57795
  4. Run \`manage_plugin test\` with the real \`connectionKey\`, e.g.
57671
57796
  \`{ "kind": "tool", "name": "probe", "input": {}, "connectionKey": "prod" }\`.
57672
57797
  5. Read the returned tool list; use it to choose the downstream tool names and
@@ -57866,11 +57991,15 @@ main().catch((err) => {
57866
57991
  });
57867
57992
  \`\`\`
57868
57993
 
57869
- ### 3. Ask a human to configure the connection
57994
+ ### 3. Request the connection
57870
57995
 
57871
57996
  - Call \`list_connections { type }\`.
57872
- - If the connection or key is missing, use \`ask_user_to_clarify\`: only a human can
57873
- create the platform API key and fill the connection.
57997
+ - If no usable connection exists, call
57998
+ \`request_connection { type, pluginKey, toolName, reason }\`; it opens an inline
57999
+ connection form in the chat. Only a human can create the platform API key and
58000
+ fill the connection.
58001
+ - Never ask the user to type, paste, or share any secret (password, API key,
58002
+ token) in chat.
57874
58003
  - Never claim PTC works until a real \`connectionKey\` test passes.
57875
58004
 
57876
58005
  ### 4. Test with a real connection
@@ -57989,8 +58118,8 @@ resolution path. See \`sandbox-plugins-handlers\` \u2192 "Dependencies".
57989
58118
  | every input field missing / \`{}\` | parsed base64 \`PLUGIN_INPUT\` as plaintext and swallowed the error | decode base64 with a plaintext fallback; fail visibly |
57990
58119
  | \`API_GATEWAY_URL\` empty | Gateway has no \`PUBLIC_GATEWAY_URL\` | ask a human to set it; do not guess a host |
57991
58120
  | \`OPEN_API_TOKEN\` empty | expected in plugin handlers (cleared by design) | use the connection password field, never the env token |
57992
- | \`token is required\` / \`OpenMcpConfigError\` | connection has no platform key | ask the human to configure it |
57993
- | \`OpenMcpAuthError\` / 401 | key disabled, rotated, or invalid | ask the human to rotate/configure |
58121
+ | \`token is required\` / \`OpenMcpConfigError\` | connection has no platform key | call \`request_connection\` (inline form) |
58122
+ | \`OpenMcpAuthError\` / 401 | key disabled, rotated, or invalid | call \`request_connection\` (inline form) to reconfigure |
57994
58123
  | tool-not-found | key has no such domain/action | do not retry; fix the key grant |
57995
58124
  | \`GRANT_DENIED\` | key lacks the action | do not retry; fix the key grant |
57996
58125
  | \`CONNECTION_NOT_ALLOWED\` / \`RESOURCE_DENIED\` | \`selector.connections\` mismatch | use an allowed connection or fix the key scope |
@@ -58002,7 +58131,8 @@ If the plugin previously called \`OpenMcpClient.fromEnv()\`:
58002
58131
  1. Add a password field to \`connection.fields\` (for example \`platformApiKey\`).
58003
58132
  2. Read \`PLUGIN_CONNECTION_FILE.connection.platformApiKey\`.
58004
58133
  3. Construct \`new OpenMcpClient({ url: process.env.API_GATEWAY_URL, token: ... })\`.
58005
- 4. Ask the human to fill the connection key.
58134
+ 4. If no usable connection exists, call
58135
+ \`request_connection { type, pluginKey, toolName, reason }\`.
58006
58136
  5. Re-test with \`manage_plugin test\` + \`connectionKey\`.
58007
58137
 
58008
58138
  \`fromEnv()\` still works for agent \`code_eval\`, not for plugin handlers.
@@ -58167,8 +58297,32 @@ description: Define connection fields and test/discover handlers for a tenant sa
58167
58297
 
58168
58298
  # Connections
58169
58299
 
58170
- Define \`connection.fields\` in plugin.json. Field widgets: \`input\`, \`password\`,
58171
- \`select\` (with \`enumValues\`), \`numberInput\`. Mark secrets as \`type: "password"\`.
58300
+ Define \`connection.fields\` in plugin.json. Each field is:
58301
+
58302
+ \`{ key, type, title, widget?, required?, default?, enumValues?, helpText? }\`
58303
+
58304
+ - \`key\` (required): the config key your handler reads from \`PLUGIN_CONNECTION_FILE\`.
58305
+ - \`type\` (required): \`"string"\`, \`"number"\`, \`"boolean"\`, or \`"password"\`.
58306
+ - \`title\` (required): the human-visible label shown in the connection form.
58307
+ Use the real field name (for example \`"API Key"\` or \`"Server URL"\`);
58308
+ never use a placeholder such as \`"label"\`, and never use \`label\` as the
58309
+ property name.
58310
+ - \`widget\` (optional): \`"input"\`, \`"password"\`, \`"select"\`, or \`"numberInput"\`.
58311
+ - \`required\` (optional boolean), \`default\` (optional value),
58312
+ \`enumValues\` (required for \`select\`; string array), \`helpText\` (optional string).
58313
+
58314
+ \`\`\`json
58315
+ {
58316
+ "connection": {
58317
+ "fields": [
58318
+ { "key": "baseUrl", "type": "string", "title": "Server URL", "required": true },
58319
+ { "key": "apiKey", "type": "password", "title": "API Key", "widget": "password", "required": true }
58320
+ ]
58321
+ }
58322
+ }
58323
+ \`\`\`
58324
+
58325
+ Mark secrets as \`type: "password"\`.
58172
58326
 
58173
58327
  The resolved connection is injected at execution time as an
58174
58328
  \`{ connection?, connections? }\` envelope in a JSON file path passed through
@@ -58214,10 +58368,18 @@ Use the \`manage_plugin\` tool. The loop:
58214
58368
  2. \`action: "validate"\` with \`{ type }\` \u2014 reads the plugin back **from the sandbox** and returns diagnostics (no writes). The files must already be on disk; a \`type\` with no files reports a read error.
58215
58369
  3. If the plugin has \`connection.fields\` and a tool reads credentials: a **human**
58216
58370
  must configure a connection of this plugin type. You cannot create credentials.
58217
- Call \`list_connections { type }\` first \u2014 if none exist, use \`ask_user_to_clarify\`
58218
- to state explicitly that only the human can configure the connector, ask them to
58219
- add it (Console \u2192 Connections) and to give you the connection key. Do not claim
58220
- the tool works until a real \`connectionKey\` test passes.
58371
+ Call \`list_connections { type }\` first \u2014 if no usable connection exists, call
58372
+ \`request_connection { type, pluginKey, toolName, reason }\`; it opens an inline
58373
+ connection form in the chat. The human configures, tests, and saves it; you
58374
+ receive only the connection key and whether the test passed \u2014 never the
58375
+ secret values.
58376
+ Never ask the user to type, paste, or share any secret (password, API key,
58377
+ token) in chat. Do not claim the tool works until a real \`connectionKey\` test
58378
+ passes. If the human cancels, report it as unverified (missing credentials) and
58379
+ end the run; do not call \`request_connection\` again in this run.
58380
+ If you just authored or changed this plugin, call \`manage_plugin { action: "reload" }\`
58381
+ before \`request_connection\`; \`/api/middleware-types\` only sees the new connection
58382
+ schema after the catalog reloads.
58221
58383
  4. \`action: "reload"\` \u2014 refresh the compiled catalog after writing/editing files (the catalog caches; an edited file is invisible to \`test\` until you reload).
58222
58384
  5. \`action: "test"\` to exercise a handler without an LLM:
58223
58385
  - Tool: \`{ type, target: { kind: "tool", name, input, connectionKey? } }\`
@@ -58411,13 +58573,22 @@ After the human confirms the design, author the plugin files directly with the f
58411
58573
  the sandbox) \u2192 \`manage_plugin { action: "reload", type }\` (the catalog caches, so a
58412
58574
  freshly written file is invisible to \`test\` until you reload) \u2192 \`manage_plugin
58413
58575
  { action: "test", type, target }\`.
58414
- If a tool needs credentials, a human must configure the connection \u2014 use
58415
- \`list_connections\` to check, and \`ask_user_to_clarify\` to ask the human to add
58416
- the connector and give you its key. Only after a real \`connectionKey\` test
58417
- passes may you call the tool verified; without it, report functionality as
58418
- unverified (missing credentials), not as passing. Use \`shell_exec\` (the tool
58419
- provided by the \`code_eval\` middleware) to run \`node handlers/x.js\` for manual
58420
- checks when reproducing a failure.
58576
+ If a tool needs credentials, check \`list_connections\` first. If no usable
58577
+ connection exists, call \`request_connection { type, pluginKey, toolName, reason }\`
58578
+ \u2014 it opens an inline connection form in the chat. The human fills it in, tests
58579
+ it, and saves; you receive only the connection key and whether the test passed
58580
+ \u2014 never the secret values. If you just authored or changed this plugin, call
58581
+ \`manage_plugin { action: "reload" }\` before \`request_connection\`;
58582
+ \`/api/middleware-types\` only sees the new connection schema after the catalog
58583
+ reloads.
58584
+ Never ask the user to type, paste, or share any secret (password, API key,
58585
+ token) in chat. Only after a real \`connectionKey\` test passes may you call the
58586
+ tool verified; without it, report functionality as unverified (missing
58587
+ credentials), not as passing. If the human cancels, report it as unverified
58588
+ (missing credentials) and end the run; do not call \`request_connection\`
58589
+ again in this run. Use \`shell_exec\` (the tool provided by the \`code_eval\`
58590
+ middleware) to run \`node handlers/x.js\` for manual checks when reproducing a
58591
+ failure.
58421
58592
 
58422
58593
  Deployment is human-gated: do NOT deploy on your own after the tests pass.
58423
58594
  Only deploy when the human explicitly asks for it or approves it, then load
@@ -58616,6 +58787,21 @@ function tenantIdFrom(exeConfig) {
58616
58787
  function errorText(err) {
58617
58788
  return err instanceof Error ? err.message : String(err);
58618
58789
  }
58790
+ function isRecord14(value) {
58791
+ return typeof value === "object" && value !== null && !Array.isArray(value);
58792
+ }
58793
+ function truncate2(value, max) {
58794
+ if (typeof value !== "string") return void 0;
58795
+ return value.length > max ? `${value.slice(0, max)}\u2026` : value;
58796
+ }
58797
+ function isProjectRoomRun2(request) {
58798
+ if (!isRecord14(request) || !isRecord14(request.runtime)) return false;
58799
+ const runtime = request.runtime;
58800
+ const configurable = isRecord14(runtime.configurable) ? runtime.configurable.runConfig : void 0;
58801
+ const context = isRecord14(runtime.context) ? runtime.context.runConfig : void 0;
58802
+ const runConfig = isRecord14(configurable) ? configurable : isRecord14(context) ? context : void 0;
58803
+ return isRecord14(runConfig?.projectRoom);
58804
+ }
58619
58805
  function deploymentUnavailable(action) {
58620
58806
  const error = `plugin deployment service is not configured; cannot ${action}. Resident plugin services are unavailable in this environment.`;
58621
58807
  if (action === "undeploy") return JSON.stringify({ undeployed: false, error });
@@ -58652,6 +58838,13 @@ var managePluginSchema = import_zod75.z.object({
58652
58838
  connectionKey: import_zod75.z.string().optional()
58653
58839
  }).optional()
58654
58840
  });
58841
+ var requestConnectionSchema = import_zod75.z.object({
58842
+ type: import_zod75.z.string().trim().min(1).max(120).describe("Plugin connection type (the plugin meta.type)."),
58843
+ pluginKey: import_zod75.z.string().optional().describe("Plugin type being built, for display only."),
58844
+ toolName: import_zod75.z.string().optional().describe("Tool that needs the connection, for display only."),
58845
+ reason: import_zod75.z.string().optional().describe("Short reason shown to the human."),
58846
+ suggestedKey: import_zod75.z.string().optional().describe("Optional connection key prefill.")
58847
+ });
58655
58848
  var sandboxPluginsPlugin = {
58656
58849
  meta: {
58657
58850
  type: "sandbox-plugins",
@@ -59049,8 +59242,68 @@ var sandboxPluginsPlugin = {
59049
59242
  description: "Author and manage tenant sandbox plugins (list/get/validate/create/delete/reload/test/backup/restore) and deploy/undeploy/status a plugin as a resident service.",
59050
59243
  schema: managePluginSchema
59051
59244
  }
59245
+ ),
59246
+ markInternalTool(
59247
+ (0, import_langchain87.tool)(
59248
+ async (input) => JSON.stringify(input),
59249
+ {
59250
+ name: "request_connection",
59251
+ description: "Ask the human to configure a connection for the plugin being built. Use only when list_connections shows no usable connection. Opens an inline connection form in the chat; the human configures and tests the connector, and you receive only the connection key. Never ask the human to paste secrets into the chat. Call this tool alone, not in parallel with other tools.",
59252
+ schema: requestConnectionSchema
59253
+ }
59254
+ )
59052
59255
  )
59053
- ]
59256
+ ],
59257
+ wrapToolCall: async (request, handler) => {
59258
+ const toolCall = request.toolCall;
59259
+ if (toolCall?.name !== "request_connection") {
59260
+ return handler(request);
59261
+ }
59262
+ if (isProjectRoomRun2(request)) {
59263
+ return new import_langchain87.ToolMessage({
59264
+ content: "You are replying inside a project room, which has no interactive connection setup UI. Ask the user in plain text to configure the connection, then continue after their next message.",
59265
+ tool_call_id: toolCall.id,
59266
+ name: toolCall.name
59267
+ });
59268
+ }
59269
+ const parsed = requestConnectionSchema.safeParse(toolCall.args);
59270
+ if (!parsed.success) {
59271
+ return new import_langchain87.ToolMessage({
59272
+ content: `Invalid request_connection tool arguments: ${parsed.error.message}`,
59273
+ tool_call_id: toolCall.id,
59274
+ name: toolCall.name
59275
+ });
59276
+ }
59277
+ const input = parsed.data;
59278
+ const md = genUIMarkdown("connection_setup", {
59279
+ type: input.type,
59280
+ pluginKey: truncate2(input.pluginKey, 120),
59281
+ toolName: truncate2(input.toolName, 120),
59282
+ reason: truncate2(input.reason, 500),
59283
+ suggestedKey: truncate2(input.suggestedKey, 120)
59284
+ });
59285
+ const feedback = await (0, import_langgraph14.interrupt)(md);
59286
+ if (feedback?.action === "saved" && isRecord14(feedback.data)) {
59287
+ const connectionKey = feedback.data.connectionKey;
59288
+ if (typeof connectionKey === "string" && connectionKey.trim() !== "") {
59289
+ const testOk = feedback.data.testOk;
59290
+ const testPassed = testOk === true ? true : testOk === false ? false : null;
59291
+ return new import_langchain87.ToolMessage({
59292
+ content: JSON.stringify({
59293
+ connectionKey: connectionKey.trim(),
59294
+ testPassed
59295
+ }),
59296
+ tool_call_id: toolCall.id,
59297
+ name: toolCall.name
59298
+ });
59299
+ }
59300
+ }
59301
+ return new import_langchain87.ToolMessage({
59302
+ content: JSON.stringify({ cancelled: true }),
59303
+ tool_call_id: toolCall.id,
59304
+ name: toolCall.name
59305
+ });
59306
+ }
59054
59307
  })
59055
59308
  };
59056
59309
 
@@ -60417,11 +60670,11 @@ var INLINE_INPUT_LIMIT_BYTES2 = 48 * 1024;
60417
60670
  var DEFAULT_HANDLER_TIMEOUT_MS = 6e4;
60418
60671
  var MIN_HANDLER_TIMEOUT_MS = 1e3;
60419
60672
  var MAX_HANDLER_TIMEOUT_MS = 3e5;
60420
- function isRecord14(value) {
60673
+ function isRecord15(value) {
60421
60674
  return typeof value === "object" && value !== null && !Array.isArray(value);
60422
60675
  }
60423
60676
  function isEnvelope3(value) {
60424
- return isRecord14(value) && typeof value.ok === "boolean";
60677
+ return isRecord15(value) && typeof value.ok === "boolean";
60425
60678
  }
60426
60679
  function parseHostArgs(argv) {
60427
60680
  let type;