@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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +304 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +305 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -622,6 +622,32 @@ var InMemoryThreadStore = class {
|
|
|
622
622
|
total: filtered.length
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
|
+
async listChannelSenders(tenantId2, channelInstallationId, limit) {
|
|
626
|
+
const tenantThreads = this.threads.get(tenantId2);
|
|
627
|
+
if (!tenantThreads) return [];
|
|
628
|
+
const bySender = /* @__PURE__ */ new Map();
|
|
629
|
+
for (const assistantThreads of tenantThreads.values()) {
|
|
630
|
+
for (const thread of assistantThreads.values()) {
|
|
631
|
+
const metadata = thread.metadata ?? {};
|
|
632
|
+
if (metadata.channelInstallationId !== channelInstallationId) continue;
|
|
633
|
+
if (typeof metadata.senderId !== "string" || !metadata.senderId) continue;
|
|
634
|
+
const existing = bySender.get(metadata.senderId);
|
|
635
|
+
if (existing && existing.lastSeenAt.getTime() >= thread.updatedAt.getTime()) {
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
bySender.set(metadata.senderId, {
|
|
639
|
+
senderId: metadata.senderId,
|
|
640
|
+
...typeof metadata.senderDisplayName === "string" && metadata.senderDisplayName ? { displayName: metadata.senderDisplayName } : {},
|
|
641
|
+
lastSeenAt: thread.updatedAt,
|
|
642
|
+
lastThreadId: thread.id
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
const bounded = Math.max(1, Math.min(200, Math.floor(limit)));
|
|
647
|
+
return [...bySender.values()].sort(
|
|
648
|
+
(left, right) => right.lastSeenAt.getTime() - left.lastSeenAt.getTime()
|
|
649
|
+
).slice(0, bounded);
|
|
650
|
+
}
|
|
625
651
|
/**
|
|
626
652
|
* Get a thread by ID for a specific tenant
|
|
627
653
|
*/
|
|
@@ -4466,6 +4492,8 @@ var InMemoryChannelInstallationStore = class {
|
|
|
4466
4492
|
config: { ...data.config },
|
|
4467
4493
|
enabled: data.enabled ?? true,
|
|
4468
4494
|
fallbackAgentId: data.fallbackAgentId,
|
|
4495
|
+
workspaceId: data.workspaceId,
|
|
4496
|
+
projectId: data.projectId,
|
|
4469
4497
|
rejectWhenNoBinding: data.rejectWhenNoBinding ?? true,
|
|
4470
4498
|
createdAt: now,
|
|
4471
4499
|
updatedAt: now
|
|
@@ -4489,7 +4517,9 @@ var InMemoryChannelInstallationStore = class {
|
|
|
4489
4517
|
name: updates.name !== void 0 ? updates.name : existing.name,
|
|
4490
4518
|
config: updates.config !== void 0 ? { ...existing.config, ...updates.config } : existing.config,
|
|
4491
4519
|
enabled: updates.enabled !== void 0 ? updates.enabled : existing.enabled,
|
|
4492
|
-
fallbackAgentId: updates.fallbackAgentId !== void 0 ? updates.fallbackAgentId : existing.fallbackAgentId,
|
|
4520
|
+
fallbackAgentId: updates.fallbackAgentId === null || updates.fallbackAgentId === "" ? void 0 : updates.fallbackAgentId !== void 0 ? updates.fallbackAgentId : existing.fallbackAgentId,
|
|
4521
|
+
workspaceId: updates.workspaceId === "" ? void 0 : updates.workspaceId !== void 0 ? updates.workspaceId : existing.workspaceId,
|
|
4522
|
+
projectId: updates.projectId === "" ? void 0 : updates.projectId !== void 0 ? updates.projectId : existing.projectId,
|
|
4493
4523
|
rejectWhenNoBinding: updates.rejectWhenNoBinding !== void 0 ? updates.rejectWhenNoBinding : existing.rejectWhenNoBinding,
|
|
4494
4524
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4495
4525
|
};
|
|
@@ -4600,8 +4630,8 @@ var InMemoryBindingStore = class {
|
|
|
4600
4630
|
...existing,
|
|
4601
4631
|
agentId: patch.agentId ?? existing.agentId,
|
|
4602
4632
|
threadId: patch.threadId !== void 0 ? patch.threadId : existing.threadId,
|
|
4603
|
-
workspaceId: patch.workspaceId !== void 0 ? patch.workspaceId : existing.workspaceId,
|
|
4604
|
-
projectId: patch.projectId !== void 0 ? patch.projectId : existing.projectId,
|
|
4633
|
+
workspaceId: patch.workspaceId === "" ? void 0 : patch.workspaceId !== void 0 ? patch.workspaceId : existing.workspaceId,
|
|
4634
|
+
projectId: patch.projectId === "" ? void 0 : patch.projectId !== void 0 ? patch.projectId : existing.projectId,
|
|
4605
4635
|
threadMode: patch.threadMode ?? existing.threadMode,
|
|
4606
4636
|
senderDisplayName: patch.senderDisplayName !== void 0 ? patch.senderDisplayName : existing.senderDisplayName,
|
|
4607
4637
|
senderMetadata: patch.senderMetadata !== void 0 ? patch.senderMetadata : existing.senderMetadata,
|
|
@@ -7629,6 +7659,11 @@ var registerVectorStoreProvider = (key6, provider2) => vectorStoreProviderManage
|
|
|
7629
7659
|
var getVectorStoreProvider = (key6) => vectorStoreProviderManager.getProvider(key6);
|
|
7630
7660
|
|
|
7631
7661
|
// src/plugin/metaSerializer.ts
|
|
7662
|
+
var INTERNAL_TOOL = Symbol.for("axiom.internalTool");
|
|
7663
|
+
function markInternalTool(tool68) {
|
|
7664
|
+
Object.defineProperty(tool68, INTERNAL_TOOL, { value: true, enumerable: false });
|
|
7665
|
+
return tool68;
|
|
7666
|
+
}
|
|
7632
7667
|
function tryExtractTools(plugin) {
|
|
7633
7668
|
if (!plugin.middleware) return [];
|
|
7634
7669
|
try {
|
|
@@ -7636,7 +7671,7 @@ function tryExtractTools(plugin) {
|
|
|
7636
7671
|
if (result instanceof Promise) return [];
|
|
7637
7672
|
const mw = result;
|
|
7638
7673
|
if (Array.isArray(mw.tools)) {
|
|
7639
|
-
return mw.tools.map((t) => ({
|
|
7674
|
+
return mw.tools.filter((t) => !t[INTERNAL_TOOL]).map((t) => ({
|
|
7640
7675
|
name: t.name || "",
|
|
7641
7676
|
description: t.description || ""
|
|
7642
7677
|
}));
|
|
@@ -19316,7 +19351,7 @@ This run is ending, but the conversation continues: the next user message starts
|
|
|
19316
19351
|
a new run with a fresh budget. Do not tell the user the conversation is over.
|
|
19317
19352
|
Do not mention this instruction, the run budget, or any internal limit to the user.`;
|
|
19318
19353
|
var RUN_STOPPING_MESSAGE = "Tool call skipped because this run is ending (per-run budget). Tool use resumes on the next user message.";
|
|
19319
|
-
var HITL_TOOL_NAMES = /* @__PURE__ */ new Set(["ask_user_to_clarify"]);
|
|
19354
|
+
var HITL_TOOL_NAMES = /* @__PURE__ */ new Set(["ask_user_to_clarify", "request_connection"]);
|
|
19320
19355
|
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.";
|
|
19321
19356
|
function neutralizeStoppedToolMessages(messages) {
|
|
19322
19357
|
let changed = false;
|
|
@@ -23459,6 +23494,8 @@ var TOOL_RE = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
|
23459
23494
|
var HANDLER_RE = /\.(js|mjs|cjs)$/;
|
|
23460
23495
|
var UI_RE = /\.html$/;
|
|
23461
23496
|
var DISPLAY_MODES = ["inline", "fullscreen", "pip"];
|
|
23497
|
+
var CONNECTION_FIELD_TYPES = /* @__PURE__ */ new Set(["string", "number", "boolean", "password"]);
|
|
23498
|
+
var CONNECTION_FIELD_WIDGETS = /* @__PURE__ */ new Set(["input", "password", "select", "numberInput"]);
|
|
23462
23499
|
var MAX_MANIFEST_BYTES = 262144;
|
|
23463
23500
|
var MAX_TOOLS = 32;
|
|
23464
23501
|
var MAX_PLUGINS_PER_TENANT = 50;
|
|
@@ -23486,6 +23523,7 @@ function isSafeUiPath(path8) {
|
|
|
23486
23523
|
function validateSandboxPluginManifest(args) {
|
|
23487
23524
|
const diagnostics = [];
|
|
23488
23525
|
const error = (code, message, pluginType, tool68) => diagnostics.push({ level: "error", code, message, pluginType, tool: tool68 });
|
|
23526
|
+
const warning = (code, message, pluginType, tool68) => diagnostics.push({ level: "warning", code, message, pluginType, tool: tool68 });
|
|
23489
23527
|
const raw = args.raw;
|
|
23490
23528
|
if (!isRecord7(raw)) {
|
|
23491
23529
|
error("MANIFEST_NOT_OBJECT", "manifest must be a JSON object", args.dirName);
|
|
@@ -23698,8 +23736,92 @@ function validateSandboxPluginManifest(args) {
|
|
|
23698
23736
|
if (!Array.isArray(fields)) {
|
|
23699
23737
|
error("CONNECTION_INVALID", "connection.fields must be an array", type);
|
|
23700
23738
|
} else {
|
|
23739
|
+
const normalizedFields = [];
|
|
23740
|
+
fields.forEach((field, index) => {
|
|
23741
|
+
if (!isRecord7(field)) {
|
|
23742
|
+
error(
|
|
23743
|
+
"CONNECTION_FIELD_INVALID",
|
|
23744
|
+
`connection.fields[${index}] must be an object`,
|
|
23745
|
+
type
|
|
23746
|
+
);
|
|
23747
|
+
return;
|
|
23748
|
+
}
|
|
23749
|
+
const key6 = field.key;
|
|
23750
|
+
const fieldType = field.type;
|
|
23751
|
+
const title = field.title;
|
|
23752
|
+
if (typeof key6 !== "string" || key6.trim() === "") {
|
|
23753
|
+
error(
|
|
23754
|
+
"CONNECTION_FIELD_INVALID",
|
|
23755
|
+
`connection.fields[${index}] requires a non-empty string key`,
|
|
23756
|
+
type
|
|
23757
|
+
);
|
|
23758
|
+
return;
|
|
23759
|
+
}
|
|
23760
|
+
if (typeof fieldType !== "string" || !CONNECTION_FIELD_TYPES.has(fieldType)) {
|
|
23761
|
+
error(
|
|
23762
|
+
"CONNECTION_FIELD_INVALID",
|
|
23763
|
+
`connection.fields[${index}] (${key6}) type must be one of ${[
|
|
23764
|
+
...CONNECTION_FIELD_TYPES
|
|
23765
|
+
].join(", ")}`,
|
|
23766
|
+
type
|
|
23767
|
+
);
|
|
23768
|
+
return;
|
|
23769
|
+
}
|
|
23770
|
+
if (typeof title !== "string" || title.trim() === "") {
|
|
23771
|
+
error(
|
|
23772
|
+
"CONNECTION_FIELD_INVALID",
|
|
23773
|
+
`connection.fields[${index}] (${key6}) requires a non-empty string title (the human-visible label; use "title", not "label")`,
|
|
23774
|
+
type
|
|
23775
|
+
);
|
|
23776
|
+
return;
|
|
23777
|
+
}
|
|
23778
|
+
if (field.widget !== void 0 && (typeof field.widget !== "string" || !CONNECTION_FIELD_WIDGETS.has(field.widget))) {
|
|
23779
|
+
error(
|
|
23780
|
+
"CONNECTION_FIELD_INVALID",
|
|
23781
|
+
`connection.fields[${index}] (${key6}) widget must be one of ${[
|
|
23782
|
+
...CONNECTION_FIELD_WIDGETS
|
|
23783
|
+
].join(", ")}`,
|
|
23784
|
+
type
|
|
23785
|
+
);
|
|
23786
|
+
return;
|
|
23787
|
+
}
|
|
23788
|
+
if (field.required !== void 0 && typeof field.required !== "boolean") {
|
|
23789
|
+
error(
|
|
23790
|
+
"CONNECTION_FIELD_INVALID",
|
|
23791
|
+
`connection.fields[${index}] (${key6}) required must be a boolean`,
|
|
23792
|
+
type
|
|
23793
|
+
);
|
|
23794
|
+
return;
|
|
23795
|
+
}
|
|
23796
|
+
if (field.enumValues !== void 0 && (!Array.isArray(field.enumValues) || field.enumValues.some((value) => typeof value !== "string"))) {
|
|
23797
|
+
error(
|
|
23798
|
+
"CONNECTION_FIELD_INVALID",
|
|
23799
|
+
`connection.fields[${index}] (${key6}) enumValues must be an array of strings`,
|
|
23800
|
+
type
|
|
23801
|
+
);
|
|
23802
|
+
return;
|
|
23803
|
+
}
|
|
23804
|
+
if (field.helpText !== void 0 && typeof field.helpText !== "string") {
|
|
23805
|
+
error(
|
|
23806
|
+
"CONNECTION_FIELD_INVALID",
|
|
23807
|
+
`connection.fields[${index}] (${key6}) helpText must be a string`,
|
|
23808
|
+
type
|
|
23809
|
+
);
|
|
23810
|
+
return;
|
|
23811
|
+
}
|
|
23812
|
+
if (title.trim().toLowerCase() === "label" || title.trim() === key6) {
|
|
23813
|
+
warning(
|
|
23814
|
+
"CONNECTION_FIELD_TITLE_PLACEHOLDER",
|
|
23815
|
+
`connection.fields[${index}] (${key6}) title "${title}" looks like a placeholder; use the human-visible label (for example "API Key")`,
|
|
23816
|
+
type
|
|
23817
|
+
);
|
|
23818
|
+
}
|
|
23819
|
+
normalizedFields.push(
|
|
23820
|
+
field
|
|
23821
|
+
);
|
|
23822
|
+
});
|
|
23701
23823
|
const normalized = {
|
|
23702
|
-
fields
|
|
23824
|
+
fields: normalizedFields
|
|
23703
23825
|
};
|
|
23704
23826
|
if (typeof raw.connection.resourceLabel === "string") {
|
|
23705
23827
|
normalized.resourceLabel = raw.connection.resourceLabel;
|
|
@@ -26325,7 +26447,7 @@ function hasExpectedInterrupt(interrupts, expectedInterruptId) {
|
|
|
26325
26447
|
return interrupts.length === 1 && interrupts[0]?.interruptId === expectedInterruptId;
|
|
26326
26448
|
}
|
|
26327
26449
|
return interrupts.filter(
|
|
26328
|
-
(
|
|
26450
|
+
(interrupt6) => interrupt6.interruptId === expectedInterruptId
|
|
26329
26451
|
).length === 1;
|
|
26330
26452
|
}
|
|
26331
26453
|
function normalizeAgentInterrupts(state, threadId) {
|
|
@@ -26335,11 +26457,11 @@ function normalizeAgentInterrupts(state, threadId) {
|
|
|
26335
26457
|
if (!isRecord12(task) || !Array.isArray(task.interrupts)) return;
|
|
26336
26458
|
const rawTaskId = task.id;
|
|
26337
26459
|
const taskId = typeof rawTaskId === "string" || typeof rawTaskId === "number" ? String(rawTaskId) : void 0;
|
|
26338
|
-
task.interrupts.forEach((
|
|
26339
|
-
const record = isRecord12(
|
|
26460
|
+
task.interrupts.forEach((interrupt6, index) => {
|
|
26461
|
+
const record = isRecord12(interrupt6) ? interrupt6 : {};
|
|
26340
26462
|
const rawId = record.id;
|
|
26341
26463
|
const interruptId = typeof rawId === "string" || typeof rawId === "number" ? String(rawId) : `${taskId ?? `task-${taskIndex}`}:${index}`;
|
|
26342
|
-
const rawValue = isRecord12(
|
|
26464
|
+
const rawValue = isRecord12(interrupt6) ? record.value : interrupt6;
|
|
26343
26465
|
const fenced = parseFence(rawValue);
|
|
26344
26466
|
const value = fenced ? fenced.payload : rawValue;
|
|
26345
26467
|
let type;
|
|
@@ -30697,7 +30819,7 @@ var Agent = class {
|
|
|
30697
30819
|
try {
|
|
30698
30820
|
const state = await this.getCurrentState();
|
|
30699
30821
|
const durable = (state?.tasks ?? []).some(
|
|
30700
|
-
(task) => (task.interrupts ?? []).some((
|
|
30822
|
+
(task) => (task.interrupts ?? []).some((interrupt6) => interrupt6.id === interruptId)
|
|
30701
30823
|
);
|
|
30702
30824
|
if (durable) return;
|
|
30703
30825
|
} catch {
|
|
@@ -42647,7 +42769,7 @@ function parseJudgeVerdict(raw) {
|
|
|
42647
42769
|
}
|
|
42648
42770
|
}
|
|
42649
42771
|
var MAX_INTERRUPT_RESUMES = 5;
|
|
42650
|
-
function resolveInterruptResponse(policy,
|
|
42772
|
+
function resolveInterruptResponse(policy, interrupt6) {
|
|
42651
42773
|
if (policy.mode === "auto-approve") return policy.value ?? "\u540C\u610F";
|
|
42652
42774
|
if (policy.mode === "auto-reject") return policy.value ?? "\u62D2\u7EDD";
|
|
42653
42775
|
return policy.value ?? "";
|
|
@@ -42749,31 +42871,31 @@ var _LatticeEval = class _LatticeEval {
|
|
|
42749
42871
|
let pendingInterrupt;
|
|
42750
42872
|
let interrupts = Array.isArray(result?.__interrupt__) ? result.__interrupt__ : [];
|
|
42751
42873
|
while (interrupts.length > 0) {
|
|
42752
|
-
const
|
|
42753
|
-
if (!
|
|
42874
|
+
const interrupt6 = interrupts[0];
|
|
42875
|
+
if (!interrupt6) break;
|
|
42754
42876
|
const policy = interruptPolicy;
|
|
42755
42877
|
if (!policy || policy.mode === "stop" || resumeCount >= MAX_INTERRUPT_RESUMES) {
|
|
42756
|
-
pendingInterrupt =
|
|
42878
|
+
pendingInterrupt = interrupt6;
|
|
42757
42879
|
break;
|
|
42758
42880
|
}
|
|
42759
|
-
const response = resolveInterruptResponse(policy,
|
|
42881
|
+
const response = resolveInterruptResponse(policy, interrupt6);
|
|
42760
42882
|
hitlEvents.push({
|
|
42761
42883
|
type: "interrupt",
|
|
42762
|
-
id:
|
|
42763
|
-
value:
|
|
42884
|
+
id: interrupt6.id,
|
|
42885
|
+
value: interrupt6.value
|
|
42764
42886
|
});
|
|
42765
42887
|
this.log("Auto-resolving HITL interrupt", {
|
|
42766
42888
|
agent_id: step.agent_id,
|
|
42767
42889
|
thread_id: threadId,
|
|
42768
42890
|
mode: policy.mode,
|
|
42769
|
-
interrupt_id:
|
|
42891
|
+
interrupt_id: interrupt6.id,
|
|
42770
42892
|
response,
|
|
42771
42893
|
resume_count: resumeCount + 1
|
|
42772
42894
|
});
|
|
42773
42895
|
result = await agent.invokeWithState({ input: stepInput, command: { resume: response } });
|
|
42774
42896
|
hitlEvents.push({
|
|
42775
42897
|
type: "interrupt_response",
|
|
42776
|
-
id:
|
|
42898
|
+
id: interrupt6.id,
|
|
42777
42899
|
mode: policy.mode,
|
|
42778
42900
|
response
|
|
42779
42901
|
});
|
|
@@ -42870,7 +42992,7 @@ var _LatticeEval = class _LatticeEval {
|
|
|
42870
42992
|
});
|
|
42871
42993
|
let currentThreadId = threadId;
|
|
42872
42994
|
let lastResponseData = null;
|
|
42873
|
-
let
|
|
42995
|
+
let interrupt6;
|
|
42874
42996
|
for (const step of evalCase.steps) {
|
|
42875
42997
|
const result = await this.executeAgentStep(
|
|
42876
42998
|
step,
|
|
@@ -42936,10 +43058,10 @@ ${toolCallStr}` : toolCallStr;
|
|
|
42936
43058
|
}
|
|
42937
43059
|
}
|
|
42938
43060
|
if (result.interrupted) {
|
|
42939
|
-
|
|
43061
|
+
interrupt6 = result.interrupt;
|
|
42940
43062
|
this.log("Case paused for HITL \u2014 remaining steps skipped; judge will evaluate the pause", {
|
|
42941
43063
|
case_id: evalCase.caseId,
|
|
42942
|
-
interrupt_id:
|
|
43064
|
+
interrupt_id: interrupt6?.id
|
|
42943
43065
|
});
|
|
42944
43066
|
break;
|
|
42945
43067
|
}
|
|
@@ -42949,7 +43071,7 @@ ${toolCallStr}` : toolCallStr;
|
|
|
42949
43071
|
final_thread_id: currentThreadId,
|
|
42950
43072
|
message_count: this.lastMessages.length
|
|
42951
43073
|
});
|
|
42952
|
-
const finalOutput =
|
|
43074
|
+
const finalOutput = interrupt6 ? typeof interrupt6.value === "string" ? interrupt6.value : JSON.stringify(interrupt6.value ?? "") : this.extractFinalMessage(lastResponseData);
|
|
42953
43075
|
this.lastFinalOutput = finalOutput;
|
|
42954
43076
|
const trajectory = this.buildTrajectory();
|
|
42955
43077
|
this.log("Final output extracted", {
|
|
@@ -43169,8 +43291,8 @@ Note: if final_score >= 80 and there are no fatal errors, pass should be true; o
|
|
|
43169
43291
|
final_score: finalScore,
|
|
43170
43292
|
dimension_results: dimensionResults,
|
|
43171
43293
|
summary: parsedResult.summary || testResultContent,
|
|
43172
|
-
interrupted:
|
|
43173
|
-
interrupt:
|
|
43294
|
+
interrupted: interrupt6 ? true : void 0,
|
|
43295
|
+
interrupt: interrupt6 ? { id: interrupt6.id, value: interrupt6.value } : void 0
|
|
43174
43296
|
};
|
|
43175
43297
|
}
|
|
43176
43298
|
};
|
|
@@ -54679,7 +54801,8 @@ var projectRoomPlugin = {
|
|
|
54679
54801
|
};
|
|
54680
54802
|
|
|
54681
54803
|
// src/middlewares/sandboxPluginsMiddleware.ts
|
|
54682
|
-
import { createMiddleware as createMiddleware28, tool as tool65 } from "langchain";
|
|
54804
|
+
import { createMiddleware as createMiddleware28, tool as tool65, ToolMessage as ToolMessage12 } from "langchain";
|
|
54805
|
+
import { interrupt as interrupt5 } from "@langchain/langgraph";
|
|
54683
54806
|
import { z as z73 } from "zod";
|
|
54684
54807
|
import { AgentType as AgentType10 } from "@axiom-lattice/protocols";
|
|
54685
54808
|
|
|
@@ -55214,7 +55337,7 @@ description: Field-by-field reference for plugin.json of a tenant sandbox plugin
|
|
|
55214
55337
|
| \`name\` / \`description\` | Display strings. |
|
|
55215
55338
|
| \`version\` | Non-empty string; bump it when files change so the hash refreshes. |
|
|
55216
55339
|
| \`tools[]\` | See below. Max 32 tools. |
|
|
55217
|
-
| \`connection\` | Optional;
|
|
55340
|
+
| \`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. |
|
|
55218
55341
|
| \`skills\` | Optional; keys must start with \`<type>-\`. |
|
|
55219
55342
|
| \`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. |
|
|
55220
55343
|
|
|
@@ -55567,8 +55690,10 @@ The platform key belongs to a human. Before writing the real handler:
|
|
|
55567
55690
|
2. Write a temporary \`handlers/probe.js\` that reads \`PLUGIN_CONNECTION_FILE\`,
|
|
55568
55691
|
creates \`OpenMcpClient\` with the connection key, and prints
|
|
55569
55692
|
\`listTools()\` (name, description, inputSchema) as JSON.
|
|
55570
|
-
3.
|
|
55571
|
-
|
|
55693
|
+
3. Call \`list_connections\` first; if no usable connection exists, call
|
|
55694
|
+
\`request_connection { type, pluginKey, toolName, reason }\` \u2014 it opens an inline
|
|
55695
|
+
connection form in the chat. Never ask the user to type, paste, or share any
|
|
55696
|
+
secret (password, API key, token) in chat.
|
|
55572
55697
|
4. Run \`manage_plugin test\` with the real \`connectionKey\`, e.g.
|
|
55573
55698
|
\`{ "kind": "tool", "name": "probe", "input": {}, "connectionKey": "prod" }\`.
|
|
55574
55699
|
5. Read the returned tool list; use it to choose the downstream tool names and
|
|
@@ -55768,11 +55893,15 @@ main().catch((err) => {
|
|
|
55768
55893
|
});
|
|
55769
55894
|
\`\`\`
|
|
55770
55895
|
|
|
55771
|
-
### 3.
|
|
55896
|
+
### 3. Request the connection
|
|
55772
55897
|
|
|
55773
55898
|
- Call \`list_connections { type }\`.
|
|
55774
|
-
- If
|
|
55775
|
-
|
|
55899
|
+
- If no usable connection exists, call
|
|
55900
|
+
\`request_connection { type, pluginKey, toolName, reason }\`; it opens an inline
|
|
55901
|
+
connection form in the chat. Only a human can create the platform API key and
|
|
55902
|
+
fill the connection.
|
|
55903
|
+
- Never ask the user to type, paste, or share any secret (password, API key,
|
|
55904
|
+
token) in chat.
|
|
55776
55905
|
- Never claim PTC works until a real \`connectionKey\` test passes.
|
|
55777
55906
|
|
|
55778
55907
|
### 4. Test with a real connection
|
|
@@ -55891,8 +56020,8 @@ resolution path. See \`sandbox-plugins-handlers\` \u2192 "Dependencies".
|
|
|
55891
56020
|
| every input field missing / \`{}\` | parsed base64 \`PLUGIN_INPUT\` as plaintext and swallowed the error | decode base64 with a plaintext fallback; fail visibly |
|
|
55892
56021
|
| \`API_GATEWAY_URL\` empty | Gateway has no \`PUBLIC_GATEWAY_URL\` | ask a human to set it; do not guess a host |
|
|
55893
56022
|
| \`OPEN_API_TOKEN\` empty | expected in plugin handlers (cleared by design) | use the connection password field, never the env token |
|
|
55894
|
-
| \`token is required\` / \`OpenMcpConfigError\` | connection has no platform key |
|
|
55895
|
-
| \`OpenMcpAuthError\` / 401 | key disabled, rotated, or invalid |
|
|
56023
|
+
| \`token is required\` / \`OpenMcpConfigError\` | connection has no platform key | call \`request_connection\` (inline form) |
|
|
56024
|
+
| \`OpenMcpAuthError\` / 401 | key disabled, rotated, or invalid | call \`request_connection\` (inline form) to reconfigure |
|
|
55896
56025
|
| tool-not-found | key has no such domain/action | do not retry; fix the key grant |
|
|
55897
56026
|
| \`GRANT_DENIED\` | key lacks the action | do not retry; fix the key grant |
|
|
55898
56027
|
| \`CONNECTION_NOT_ALLOWED\` / \`RESOURCE_DENIED\` | \`selector.connections\` mismatch | use an allowed connection or fix the key scope |
|
|
@@ -55904,7 +56033,8 @@ If the plugin previously called \`OpenMcpClient.fromEnv()\`:
|
|
|
55904
56033
|
1. Add a password field to \`connection.fields\` (for example \`platformApiKey\`).
|
|
55905
56034
|
2. Read \`PLUGIN_CONNECTION_FILE.connection.platformApiKey\`.
|
|
55906
56035
|
3. Construct \`new OpenMcpClient({ url: process.env.API_GATEWAY_URL, token: ... })\`.
|
|
55907
|
-
4.
|
|
56036
|
+
4. If no usable connection exists, call
|
|
56037
|
+
\`request_connection { type, pluginKey, toolName, reason }\`.
|
|
55908
56038
|
5. Re-test with \`manage_plugin test\` + \`connectionKey\`.
|
|
55909
56039
|
|
|
55910
56040
|
\`fromEnv()\` still works for agent \`code_eval\`, not for plugin handlers.
|
|
@@ -56069,8 +56199,32 @@ description: Define connection fields and test/discover handlers for a tenant sa
|
|
|
56069
56199
|
|
|
56070
56200
|
# Connections
|
|
56071
56201
|
|
|
56072
|
-
Define \`connection.fields\` in plugin.json.
|
|
56073
|
-
|
|
56202
|
+
Define \`connection.fields\` in plugin.json. Each field is:
|
|
56203
|
+
|
|
56204
|
+
\`{ key, type, title, widget?, required?, default?, enumValues?, helpText? }\`
|
|
56205
|
+
|
|
56206
|
+
- \`key\` (required): the config key your handler reads from \`PLUGIN_CONNECTION_FILE\`.
|
|
56207
|
+
- \`type\` (required): \`"string"\`, \`"number"\`, \`"boolean"\`, or \`"password"\`.
|
|
56208
|
+
- \`title\` (required): the human-visible label shown in the connection form.
|
|
56209
|
+
Use the real field name (for example \`"API Key"\` or \`"Server URL"\`);
|
|
56210
|
+
never use a placeholder such as \`"label"\`, and never use \`label\` as the
|
|
56211
|
+
property name.
|
|
56212
|
+
- \`widget\` (optional): \`"input"\`, \`"password"\`, \`"select"\`, or \`"numberInput"\`.
|
|
56213
|
+
- \`required\` (optional boolean), \`default\` (optional value),
|
|
56214
|
+
\`enumValues\` (required for \`select\`; string array), \`helpText\` (optional string).
|
|
56215
|
+
|
|
56216
|
+
\`\`\`json
|
|
56217
|
+
{
|
|
56218
|
+
"connection": {
|
|
56219
|
+
"fields": [
|
|
56220
|
+
{ "key": "baseUrl", "type": "string", "title": "Server URL", "required": true },
|
|
56221
|
+
{ "key": "apiKey", "type": "password", "title": "API Key", "widget": "password", "required": true }
|
|
56222
|
+
]
|
|
56223
|
+
}
|
|
56224
|
+
}
|
|
56225
|
+
\`\`\`
|
|
56226
|
+
|
|
56227
|
+
Mark secrets as \`type: "password"\`.
|
|
56074
56228
|
|
|
56075
56229
|
The resolved connection is injected at execution time as an
|
|
56076
56230
|
\`{ connection?, connections? }\` envelope in a JSON file path passed through
|
|
@@ -56116,10 +56270,18 @@ Use the \`manage_plugin\` tool. The loop:
|
|
|
56116
56270
|
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.
|
|
56117
56271
|
3. If the plugin has \`connection.fields\` and a tool reads credentials: a **human**
|
|
56118
56272
|
must configure a connection of this plugin type. You cannot create credentials.
|
|
56119
|
-
Call \`list_connections { type }\` first \u2014 if
|
|
56120
|
-
|
|
56121
|
-
|
|
56122
|
-
the
|
|
56273
|
+
Call \`list_connections { type }\` first \u2014 if no usable connection exists, call
|
|
56274
|
+
\`request_connection { type, pluginKey, toolName, reason }\`; it opens an inline
|
|
56275
|
+
connection form in the chat. The human configures, tests, and saves it; you
|
|
56276
|
+
receive only the connection key and whether the test passed \u2014 never the
|
|
56277
|
+
secret values.
|
|
56278
|
+
Never ask the user to type, paste, or share any secret (password, API key,
|
|
56279
|
+
token) in chat. Do not claim the tool works until a real \`connectionKey\` test
|
|
56280
|
+
passes. If the human cancels, report it as unverified (missing credentials) and
|
|
56281
|
+
end the run; do not call \`request_connection\` again in this run.
|
|
56282
|
+
If you just authored or changed this plugin, call \`manage_plugin { action: "reload" }\`
|
|
56283
|
+
before \`request_connection\`; \`/api/middleware-types\` only sees the new connection
|
|
56284
|
+
schema after the catalog reloads.
|
|
56123
56285
|
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).
|
|
56124
56286
|
5. \`action: "test"\` to exercise a handler without an LLM:
|
|
56125
56287
|
- Tool: \`{ type, target: { kind: "tool", name, input, connectionKey? } }\`
|
|
@@ -56313,13 +56475,22 @@ After the human confirms the design, author the plugin files directly with the f
|
|
|
56313
56475
|
the sandbox) \u2192 \`manage_plugin { action: "reload", type }\` (the catalog caches, so a
|
|
56314
56476
|
freshly written file is invisible to \`test\` until you reload) \u2192 \`manage_plugin
|
|
56315
56477
|
{ action: "test", type, target }\`.
|
|
56316
|
-
If a tool needs credentials,
|
|
56317
|
-
|
|
56318
|
-
|
|
56319
|
-
|
|
56320
|
-
|
|
56321
|
-
|
|
56322
|
-
|
|
56478
|
+
If a tool needs credentials, check \`list_connections\` first. If no usable
|
|
56479
|
+
connection exists, call \`request_connection { type, pluginKey, toolName, reason }\`
|
|
56480
|
+
\u2014 it opens an inline connection form in the chat. The human fills it in, tests
|
|
56481
|
+
it, and saves; you receive only the connection key and whether the test passed
|
|
56482
|
+
\u2014 never the secret values. If you just authored or changed this plugin, call
|
|
56483
|
+
\`manage_plugin { action: "reload" }\` before \`request_connection\`;
|
|
56484
|
+
\`/api/middleware-types\` only sees the new connection schema after the catalog
|
|
56485
|
+
reloads.
|
|
56486
|
+
Never ask the user to type, paste, or share any secret (password, API key,
|
|
56487
|
+
token) in chat. Only after a real \`connectionKey\` test passes may you call the
|
|
56488
|
+
tool verified; without it, report functionality as unverified (missing
|
|
56489
|
+
credentials), not as passing. If the human cancels, report it as unverified
|
|
56490
|
+
(missing credentials) and end the run; do not call \`request_connection\`
|
|
56491
|
+
again in this run. Use \`shell_exec\` (the tool provided by the \`code_eval\`
|
|
56492
|
+
middleware) to run \`node handlers/x.js\` for manual checks when reproducing a
|
|
56493
|
+
failure.
|
|
56323
56494
|
|
|
56324
56495
|
Deployment is human-gated: do NOT deploy on your own after the tests pass.
|
|
56325
56496
|
Only deploy when the human explicitly asks for it or approves it, then load
|
|
@@ -56518,6 +56689,21 @@ function tenantIdFrom(exeConfig) {
|
|
|
56518
56689
|
function errorText(err) {
|
|
56519
56690
|
return err instanceof Error ? err.message : String(err);
|
|
56520
56691
|
}
|
|
56692
|
+
function isRecord14(value) {
|
|
56693
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
56694
|
+
}
|
|
56695
|
+
function truncate2(value, max) {
|
|
56696
|
+
if (typeof value !== "string") return void 0;
|
|
56697
|
+
return value.length > max ? `${value.slice(0, max)}\u2026` : value;
|
|
56698
|
+
}
|
|
56699
|
+
function isProjectRoomRun2(request) {
|
|
56700
|
+
if (!isRecord14(request) || !isRecord14(request.runtime)) return false;
|
|
56701
|
+
const runtime = request.runtime;
|
|
56702
|
+
const configurable = isRecord14(runtime.configurable) ? runtime.configurable.runConfig : void 0;
|
|
56703
|
+
const context = isRecord14(runtime.context) ? runtime.context.runConfig : void 0;
|
|
56704
|
+
const runConfig = isRecord14(configurable) ? configurable : isRecord14(context) ? context : void 0;
|
|
56705
|
+
return isRecord14(runConfig?.projectRoom);
|
|
56706
|
+
}
|
|
56521
56707
|
function deploymentUnavailable(action) {
|
|
56522
56708
|
const error = `plugin deployment service is not configured; cannot ${action}. Resident plugin services are unavailable in this environment.`;
|
|
56523
56709
|
if (action === "undeploy") return JSON.stringify({ undeployed: false, error });
|
|
@@ -56554,6 +56740,13 @@ var managePluginSchema = z73.object({
|
|
|
56554
56740
|
connectionKey: z73.string().optional()
|
|
56555
56741
|
}).optional()
|
|
56556
56742
|
});
|
|
56743
|
+
var requestConnectionSchema = z73.object({
|
|
56744
|
+
type: z73.string().trim().min(1).max(120).describe("Plugin connection type (the plugin meta.type)."),
|
|
56745
|
+
pluginKey: z73.string().optional().describe("Plugin type being built, for display only."),
|
|
56746
|
+
toolName: z73.string().optional().describe("Tool that needs the connection, for display only."),
|
|
56747
|
+
reason: z73.string().optional().describe("Short reason shown to the human."),
|
|
56748
|
+
suggestedKey: z73.string().optional().describe("Optional connection key prefill.")
|
|
56749
|
+
});
|
|
56557
56750
|
var sandboxPluginsPlugin = {
|
|
56558
56751
|
meta: {
|
|
56559
56752
|
type: "sandbox-plugins",
|
|
@@ -56951,8 +57144,68 @@ var sandboxPluginsPlugin = {
|
|
|
56951
57144
|
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.",
|
|
56952
57145
|
schema: managePluginSchema
|
|
56953
57146
|
}
|
|
57147
|
+
),
|
|
57148
|
+
markInternalTool(
|
|
57149
|
+
tool65(
|
|
57150
|
+
async (input) => JSON.stringify(input),
|
|
57151
|
+
{
|
|
57152
|
+
name: "request_connection",
|
|
57153
|
+
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.",
|
|
57154
|
+
schema: requestConnectionSchema
|
|
57155
|
+
}
|
|
57156
|
+
)
|
|
56954
57157
|
)
|
|
56955
|
-
]
|
|
57158
|
+
],
|
|
57159
|
+
wrapToolCall: async (request, handler) => {
|
|
57160
|
+
const toolCall = request.toolCall;
|
|
57161
|
+
if (toolCall?.name !== "request_connection") {
|
|
57162
|
+
return handler(request);
|
|
57163
|
+
}
|
|
57164
|
+
if (isProjectRoomRun2(request)) {
|
|
57165
|
+
return new ToolMessage12({
|
|
57166
|
+
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.",
|
|
57167
|
+
tool_call_id: toolCall.id,
|
|
57168
|
+
name: toolCall.name
|
|
57169
|
+
});
|
|
57170
|
+
}
|
|
57171
|
+
const parsed = requestConnectionSchema.safeParse(toolCall.args);
|
|
57172
|
+
if (!parsed.success) {
|
|
57173
|
+
return new ToolMessage12({
|
|
57174
|
+
content: `Invalid request_connection tool arguments: ${parsed.error.message}`,
|
|
57175
|
+
tool_call_id: toolCall.id,
|
|
57176
|
+
name: toolCall.name
|
|
57177
|
+
});
|
|
57178
|
+
}
|
|
57179
|
+
const input = parsed.data;
|
|
57180
|
+
const md = genUIMarkdown("connection_setup", {
|
|
57181
|
+
type: input.type,
|
|
57182
|
+
pluginKey: truncate2(input.pluginKey, 120),
|
|
57183
|
+
toolName: truncate2(input.toolName, 120),
|
|
57184
|
+
reason: truncate2(input.reason, 500),
|
|
57185
|
+
suggestedKey: truncate2(input.suggestedKey, 120)
|
|
57186
|
+
});
|
|
57187
|
+
const feedback = await interrupt5(md);
|
|
57188
|
+
if (feedback?.action === "saved" && isRecord14(feedback.data)) {
|
|
57189
|
+
const connectionKey = feedback.data.connectionKey;
|
|
57190
|
+
if (typeof connectionKey === "string" && connectionKey.trim() !== "") {
|
|
57191
|
+
const testOk = feedback.data.testOk;
|
|
57192
|
+
const testPassed = testOk === true ? true : testOk === false ? false : null;
|
|
57193
|
+
return new ToolMessage12({
|
|
57194
|
+
content: JSON.stringify({
|
|
57195
|
+
connectionKey: connectionKey.trim(),
|
|
57196
|
+
testPassed
|
|
57197
|
+
}),
|
|
57198
|
+
tool_call_id: toolCall.id,
|
|
57199
|
+
name: toolCall.name
|
|
57200
|
+
});
|
|
57201
|
+
}
|
|
57202
|
+
}
|
|
57203
|
+
return new ToolMessage12({
|
|
57204
|
+
content: JSON.stringify({ cancelled: true }),
|
|
57205
|
+
tool_call_id: toolCall.id,
|
|
57206
|
+
name: toolCall.name
|
|
57207
|
+
});
|
|
57208
|
+
}
|
|
56956
57209
|
})
|
|
56957
57210
|
};
|
|
56958
57211
|
|
|
@@ -58322,11 +58575,11 @@ var INLINE_INPUT_LIMIT_BYTES2 = 48 * 1024;
|
|
|
58322
58575
|
var DEFAULT_HANDLER_TIMEOUT_MS = 6e4;
|
|
58323
58576
|
var MIN_HANDLER_TIMEOUT_MS = 1e3;
|
|
58324
58577
|
var MAX_HANDLER_TIMEOUT_MS = 3e5;
|
|
58325
|
-
function
|
|
58578
|
+
function isRecord15(value) {
|
|
58326
58579
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
58327
58580
|
}
|
|
58328
58581
|
function isEnvelope3(value) {
|
|
58329
|
-
return
|
|
58582
|
+
return isRecord15(value) && typeof value.ok === "boolean";
|
|
58330
58583
|
}
|
|
58331
58584
|
function parseHostArgs(argv) {
|
|
58332
58585
|
let type;
|