@axiom-lattice/core 13.3.0 → 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 +40 -13
- package/dist/index.d.ts +40 -13
- package/dist/index.js +362 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +363 -67
- 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
|
}));
|
|
@@ -7688,7 +7723,7 @@ function serializePluginMeta(plugin) {
|
|
|
7688
7723
|
}
|
|
7689
7724
|
|
|
7690
7725
|
// src/sandbox_lattice/sandboxPaths.ts
|
|
7691
|
-
var NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.
|
|
7726
|
+
var NONROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.2.2";
|
|
7692
7727
|
var LEGACY_ROOT_SANDBOX_IMAGE = "kioko12520/sandbox:0.1.0";
|
|
7693
7728
|
function normalizeSandboxHome(value) {
|
|
7694
7729
|
const trimmed = value.trim();
|
|
@@ -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;
|
|
@@ -29870,6 +29992,27 @@ var Agent = class {
|
|
|
29870
29992
|
this.queue_workspace_id = params.workspace_id === null ? null : this.workspace_id;
|
|
29871
29993
|
this.queue_project_id = params.project_id == null || params.project_id === "" ? null : this.project_id;
|
|
29872
29994
|
}
|
|
29995
|
+
/**
|
|
29996
|
+
* Re-pins scope for a dispatch without racing an in-flight run.
|
|
29997
|
+
*
|
|
29998
|
+
* Legacy entry points reuse one Agent per thread; when they carry a project
|
|
29999
|
+
* scope they must make it authoritative before the next sandbox is created.
|
|
30000
|
+
* If a run is already active, defer the update until it settles.
|
|
30001
|
+
*/
|
|
30002
|
+
applyExecutionScopeIfIdle(params) {
|
|
30003
|
+
if (this.activeExecutionPromise !== void 0) {
|
|
30004
|
+
this.pendingExecutionScope = params;
|
|
30005
|
+
return;
|
|
30006
|
+
}
|
|
30007
|
+
this.applyExecutionScope(params);
|
|
30008
|
+
}
|
|
30009
|
+
/** Applies a scope requested during the previous active execution. */
|
|
30010
|
+
applyPendingExecutionScope() {
|
|
30011
|
+
const pending = this.pendingExecutionScope;
|
|
30012
|
+
if (pending === void 0) return;
|
|
30013
|
+
this.pendingExecutionScope = void 0;
|
|
30014
|
+
this.applyExecutionScope(pending);
|
|
30015
|
+
}
|
|
29873
30016
|
/**
|
|
29874
30017
|
* Accepts host-authenticated queue metadata through the package-private symbol capability.
|
|
29875
30018
|
*
|
|
@@ -30676,7 +30819,7 @@ var Agent = class {
|
|
|
30676
30819
|
try {
|
|
30677
30820
|
const state = await this.getCurrentState();
|
|
30678
30821
|
const durable = (state?.tasks ?? []).some(
|
|
30679
|
-
(task) => (task.interrupts ?? []).some((
|
|
30822
|
+
(task) => (task.interrupts ?? []).some((interrupt6) => interrupt6.id === interruptId)
|
|
30680
30823
|
);
|
|
30681
30824
|
if (durable) return;
|
|
30682
30825
|
} catch {
|
|
@@ -31857,7 +32000,9 @@ var Agent = class {
|
|
|
31857
32000
|
trackActiveExecution(execution) {
|
|
31858
32001
|
this.activeExecutionPromise = execution;
|
|
31859
32002
|
const clear = () => {
|
|
31860
|
-
if (this.activeExecutionPromise
|
|
32003
|
+
if (this.activeExecutionPromise !== execution) return;
|
|
32004
|
+
this.activeExecutionPromise = void 0;
|
|
32005
|
+
this.applyPendingExecutionScope();
|
|
31861
32006
|
};
|
|
31862
32007
|
void execution.then(clear, clear);
|
|
31863
32008
|
return execution;
|
|
@@ -32069,8 +32214,11 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
32069
32214
|
});
|
|
32070
32215
|
}
|
|
32071
32216
|
/**
|
|
32072
|
-
* Get or create Agent instance for a thread
|
|
32073
|
-
*
|
|
32217
|
+
* Get or create Agent instance for a thread.
|
|
32218
|
+
*
|
|
32219
|
+
* Ensures only one instance per thread exists. Read-only callers should use
|
|
32220
|
+
* {@link getAgentForRead}; dispatch callers use {@link getAgentForDispatch}
|
|
32221
|
+
* so the run's project scope is applied before a sandbox is created.
|
|
32074
32222
|
*/
|
|
32075
32223
|
getAgent(params) {
|
|
32076
32224
|
const key6 = this.getKey(params);
|
|
@@ -32081,6 +32229,26 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
32081
32229
|
}
|
|
32082
32230
|
return this.agents.get(key6);
|
|
32083
32231
|
}
|
|
32232
|
+
/**
|
|
32233
|
+
* Resolve the managed Agent for a dispatch and apply its explicit project.
|
|
32234
|
+
*
|
|
32235
|
+
* Legacy execution paths (channels, commands, cron, scheduler, Web App,
|
|
32236
|
+
* Open API, task comments, queue recovery) reuse the same per-thread Agent
|
|
32237
|
+
* instance. An explicit project must become authoritative before the next
|
|
32238
|
+
* sandbox is created; while a run is active it is deferred by
|
|
32239
|
+
* {@link Agent.applyExecutionScopeIfIdle}. Calls without a project do not
|
|
32240
|
+
* clear an already-established scope.
|
|
32241
|
+
*/
|
|
32242
|
+
getAgentForDispatch(params) {
|
|
32243
|
+
const agent = this.getAgent(params);
|
|
32244
|
+
if (typeof params.project_id === "string" && params.project_id.length > 0) {
|
|
32245
|
+
agent.applyExecutionScopeIfIdle({
|
|
32246
|
+
workspace_id: params.workspace_id,
|
|
32247
|
+
project_id: params.project_id
|
|
32248
|
+
});
|
|
32249
|
+
}
|
|
32250
|
+
return agent;
|
|
32251
|
+
}
|
|
32084
32252
|
/**
|
|
32085
32253
|
* Get the managed Agent for an exclusive execution and re-pin its scope.
|
|
32086
32254
|
*
|
|
@@ -32103,14 +32271,11 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
32103
32271
|
/**
|
|
32104
32272
|
* Get the managed Agent for a thread WITHOUT creating or registering one.
|
|
32105
32273
|
*
|
|
32106
|
-
* Read-only control-plane callers (state, memory, inbox) must not
|
|
32107
|
-
*
|
|
32108
|
-
* `(tenant_id, assistant_id, thread_id)`, whichever caller reaches
|
|
32109
|
-
* {@link getAgent} first fixes the instance's workspace/project for its whole
|
|
32110
|
-
* lifetime, and a later trusted dispatch on that thread would then fail
|
|
32111
|
-
* trusted-scope validation. This returns the existing managed instance when
|
|
32274
|
+
* Read-only control-plane callers (state, memory, inbox) must not mutate a
|
|
32275
|
+
* thread's execution scope. This returns the existing managed instance when
|
|
32112
32276
|
* present, otherwise a transient unregistered Agent that is sufficient for
|
|
32113
|
-
* state reads and disappears with the request.
|
|
32277
|
+
* state reads and disappears with the request. Dispatch callers use
|
|
32278
|
+
* {@link getAgentForDispatch}.
|
|
32114
32279
|
*
|
|
32115
32280
|
* @param params - Thread identity; scope is only used for the transient Agent.
|
|
32116
32281
|
* @returns The managed instance if any, else an unregistered read-only Agent.
|
|
@@ -32223,7 +32388,7 @@ var DelegationService = class {
|
|
|
32223
32388
|
throw new DelegatedThreadBusyError(request.thread_id);
|
|
32224
32389
|
}
|
|
32225
32390
|
try {
|
|
32226
|
-
const agent = agentInstanceManager.
|
|
32391
|
+
const agent = agentInstanceManager.getAgentForDispatch({
|
|
32227
32392
|
assistant_id: request.assistant_id,
|
|
32228
32393
|
thread_id: request.thread_id,
|
|
32229
32394
|
tenant_id: request.tenantId,
|
|
@@ -33067,7 +33232,7 @@ function registerAgentAddMessageHandler() {
|
|
|
33067
33232
|
workspace_id: runConfigFromMetadata?.workspaceId ?? "",
|
|
33068
33233
|
project_id: runConfigFromMetadata?.projectId ?? ""
|
|
33069
33234
|
}));
|
|
33070
|
-
const agent = agentInstanceManager.
|
|
33235
|
+
const agent = agentInstanceManager.getAgentForDispatch({
|
|
33071
33236
|
tenant_id: taskInfo.tenantId,
|
|
33072
33237
|
assistant_id: taskInfo.assistantId ?? "",
|
|
33073
33238
|
thread_id: taskInfo.threadId ?? "",
|
|
@@ -42604,7 +42769,7 @@ function parseJudgeVerdict(raw) {
|
|
|
42604
42769
|
}
|
|
42605
42770
|
}
|
|
42606
42771
|
var MAX_INTERRUPT_RESUMES = 5;
|
|
42607
|
-
function resolveInterruptResponse(policy,
|
|
42772
|
+
function resolveInterruptResponse(policy, interrupt6) {
|
|
42608
42773
|
if (policy.mode === "auto-approve") return policy.value ?? "\u540C\u610F";
|
|
42609
42774
|
if (policy.mode === "auto-reject") return policy.value ?? "\u62D2\u7EDD";
|
|
42610
42775
|
return policy.value ?? "";
|
|
@@ -42695,7 +42860,7 @@ var _LatticeEval = class _LatticeEval {
|
|
|
42695
42860
|
workspace_id: this.config.workspace_id || "default",
|
|
42696
42861
|
project_id: this.config.project_id || "default"
|
|
42697
42862
|
};
|
|
42698
|
-
const agent = agentInstanceManager.
|
|
42863
|
+
const agent = agentInstanceManager.getAgentForDispatch(agentParams);
|
|
42699
42864
|
try {
|
|
42700
42865
|
const stepInput = {
|
|
42701
42866
|
message: step.override_message || inputMessage,
|
|
@@ -42706,31 +42871,31 @@ var _LatticeEval = class _LatticeEval {
|
|
|
42706
42871
|
let pendingInterrupt;
|
|
42707
42872
|
let interrupts = Array.isArray(result?.__interrupt__) ? result.__interrupt__ : [];
|
|
42708
42873
|
while (interrupts.length > 0) {
|
|
42709
|
-
const
|
|
42710
|
-
if (!
|
|
42874
|
+
const interrupt6 = interrupts[0];
|
|
42875
|
+
if (!interrupt6) break;
|
|
42711
42876
|
const policy = interruptPolicy;
|
|
42712
42877
|
if (!policy || policy.mode === "stop" || resumeCount >= MAX_INTERRUPT_RESUMES) {
|
|
42713
|
-
pendingInterrupt =
|
|
42878
|
+
pendingInterrupt = interrupt6;
|
|
42714
42879
|
break;
|
|
42715
42880
|
}
|
|
42716
|
-
const response = resolveInterruptResponse(policy,
|
|
42881
|
+
const response = resolveInterruptResponse(policy, interrupt6);
|
|
42717
42882
|
hitlEvents.push({
|
|
42718
42883
|
type: "interrupt",
|
|
42719
|
-
id:
|
|
42720
|
-
value:
|
|
42884
|
+
id: interrupt6.id,
|
|
42885
|
+
value: interrupt6.value
|
|
42721
42886
|
});
|
|
42722
42887
|
this.log("Auto-resolving HITL interrupt", {
|
|
42723
42888
|
agent_id: step.agent_id,
|
|
42724
42889
|
thread_id: threadId,
|
|
42725
42890
|
mode: policy.mode,
|
|
42726
|
-
interrupt_id:
|
|
42891
|
+
interrupt_id: interrupt6.id,
|
|
42727
42892
|
response,
|
|
42728
42893
|
resume_count: resumeCount + 1
|
|
42729
42894
|
});
|
|
42730
42895
|
result = await agent.invokeWithState({ input: stepInput, command: { resume: response } });
|
|
42731
42896
|
hitlEvents.push({
|
|
42732
42897
|
type: "interrupt_response",
|
|
42733
|
-
id:
|
|
42898
|
+
id: interrupt6.id,
|
|
42734
42899
|
mode: policy.mode,
|
|
42735
42900
|
response
|
|
42736
42901
|
});
|
|
@@ -42827,7 +42992,7 @@ var _LatticeEval = class _LatticeEval {
|
|
|
42827
42992
|
});
|
|
42828
42993
|
let currentThreadId = threadId;
|
|
42829
42994
|
let lastResponseData = null;
|
|
42830
|
-
let
|
|
42995
|
+
let interrupt6;
|
|
42831
42996
|
for (const step of evalCase.steps) {
|
|
42832
42997
|
const result = await this.executeAgentStep(
|
|
42833
42998
|
step,
|
|
@@ -42893,10 +43058,10 @@ ${toolCallStr}` : toolCallStr;
|
|
|
42893
43058
|
}
|
|
42894
43059
|
}
|
|
42895
43060
|
if (result.interrupted) {
|
|
42896
|
-
|
|
43061
|
+
interrupt6 = result.interrupt;
|
|
42897
43062
|
this.log("Case paused for HITL \u2014 remaining steps skipped; judge will evaluate the pause", {
|
|
42898
43063
|
case_id: evalCase.caseId,
|
|
42899
|
-
interrupt_id:
|
|
43064
|
+
interrupt_id: interrupt6?.id
|
|
42900
43065
|
});
|
|
42901
43066
|
break;
|
|
42902
43067
|
}
|
|
@@ -42906,7 +43071,7 @@ ${toolCallStr}` : toolCallStr;
|
|
|
42906
43071
|
final_thread_id: currentThreadId,
|
|
42907
43072
|
message_count: this.lastMessages.length
|
|
42908
43073
|
});
|
|
42909
|
-
const finalOutput =
|
|
43074
|
+
const finalOutput = interrupt6 ? typeof interrupt6.value === "string" ? interrupt6.value : JSON.stringify(interrupt6.value ?? "") : this.extractFinalMessage(lastResponseData);
|
|
42910
43075
|
this.lastFinalOutput = finalOutput;
|
|
42911
43076
|
const trajectory = this.buildTrajectory();
|
|
42912
43077
|
this.log("Final output extracted", {
|
|
@@ -43126,8 +43291,8 @@ Note: if final_score >= 80 and there are no fatal errors, pass should be true; o
|
|
|
43126
43291
|
final_score: finalScore,
|
|
43127
43292
|
dimension_results: dimensionResults,
|
|
43128
43293
|
summary: parsedResult.summary || testResultContent,
|
|
43129
|
-
interrupted:
|
|
43130
|
-
interrupt:
|
|
43294
|
+
interrupted: interrupt6 ? true : void 0,
|
|
43295
|
+
interrupt: interrupt6 ? { id: interrupt6.id, value: interrupt6.value } : void 0
|
|
43131
43296
|
};
|
|
43132
43297
|
}
|
|
43133
43298
|
};
|
|
@@ -44682,7 +44847,7 @@ var ThreadExecutionSupervisor = class {
|
|
|
44682
44847
|
this.probeCooldownMs = positiveOr(options.probeCooldownMs, this.cooldownMs);
|
|
44683
44848
|
this.reapEveryNTicks = positiveIntegerOr(options.reapEveryNTicks, 10);
|
|
44684
44849
|
this.maxInFlightAgeMs = positiveOr(options.maxInFlightAgeMs, 30 * 60 * 1e3);
|
|
44685
|
-
this.getAgent = options.getAgent ?? ((params) => agentInstanceManager.
|
|
44850
|
+
this.getAgent = options.getAgent ?? ((params) => agentInstanceManager.getAgentForDispatch(params));
|
|
44686
44851
|
this.probeThreadRunOwner = options.probeThreadRunOwner ?? probeThreadRunOwner;
|
|
44687
44852
|
this.log = options.log;
|
|
44688
44853
|
}
|
|
@@ -54636,7 +54801,8 @@ var projectRoomPlugin = {
|
|
|
54636
54801
|
};
|
|
54637
54802
|
|
|
54638
54803
|
// src/middlewares/sandboxPluginsMiddleware.ts
|
|
54639
|
-
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";
|
|
54640
54806
|
import { z as z73 } from "zod";
|
|
54641
54807
|
import { AgentType as AgentType10 } from "@axiom-lattice/protocols";
|
|
54642
54808
|
|
|
@@ -55171,7 +55337,7 @@ description: Field-by-field reference for plugin.json of a tenant sandbox plugin
|
|
|
55171
55337
|
| \`name\` / \`description\` | Display strings. |
|
|
55172
55338
|
| \`version\` | Non-empty string; bump it when files change so the hash refreshes. |
|
|
55173
55339
|
| \`tools[]\` | See below. Max 32 tools. |
|
|
55174
|
-
| \`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. |
|
|
55175
55341
|
| \`skills\` | Optional; keys must start with \`<type>-\`. |
|
|
55176
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. |
|
|
55177
55343
|
|
|
@@ -55524,8 +55690,10 @@ The platform key belongs to a human. Before writing the real handler:
|
|
|
55524
55690
|
2. Write a temporary \`handlers/probe.js\` that reads \`PLUGIN_CONNECTION_FILE\`,
|
|
55525
55691
|
creates \`OpenMcpClient\` with the connection key, and prints
|
|
55526
55692
|
\`listTools()\` (name, description, inputSchema) as JSON.
|
|
55527
|
-
3.
|
|
55528
|
-
|
|
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.
|
|
55529
55697
|
4. Run \`manage_plugin test\` with the real \`connectionKey\`, e.g.
|
|
55530
55698
|
\`{ "kind": "tool", "name": "probe", "input": {}, "connectionKey": "prod" }\`.
|
|
55531
55699
|
5. Read the returned tool list; use it to choose the downstream tool names and
|
|
@@ -55725,11 +55893,15 @@ main().catch((err) => {
|
|
|
55725
55893
|
});
|
|
55726
55894
|
\`\`\`
|
|
55727
55895
|
|
|
55728
|
-
### 3.
|
|
55896
|
+
### 3. Request the connection
|
|
55729
55897
|
|
|
55730
55898
|
- Call \`list_connections { type }\`.
|
|
55731
|
-
- If
|
|
55732
|
-
|
|
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.
|
|
55733
55905
|
- Never claim PTC works until a real \`connectionKey\` test passes.
|
|
55734
55906
|
|
|
55735
55907
|
### 4. Test with a real connection
|
|
@@ -55848,8 +56020,8 @@ resolution path. See \`sandbox-plugins-handlers\` \u2192 "Dependencies".
|
|
|
55848
56020
|
| every input field missing / \`{}\` | parsed base64 \`PLUGIN_INPUT\` as plaintext and swallowed the error | decode base64 with a plaintext fallback; fail visibly |
|
|
55849
56021
|
| \`API_GATEWAY_URL\` empty | Gateway has no \`PUBLIC_GATEWAY_URL\` | ask a human to set it; do not guess a host |
|
|
55850
56022
|
| \`OPEN_API_TOKEN\` empty | expected in plugin handlers (cleared by design) | use the connection password field, never the env token |
|
|
55851
|
-
| \`token is required\` / \`OpenMcpConfigError\` | connection has no platform key |
|
|
55852
|
-
| \`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 |
|
|
55853
56025
|
| tool-not-found | key has no such domain/action | do not retry; fix the key grant |
|
|
55854
56026
|
| \`GRANT_DENIED\` | key lacks the action | do not retry; fix the key grant |
|
|
55855
56027
|
| \`CONNECTION_NOT_ALLOWED\` / \`RESOURCE_DENIED\` | \`selector.connections\` mismatch | use an allowed connection or fix the key scope |
|
|
@@ -55861,7 +56033,8 @@ If the plugin previously called \`OpenMcpClient.fromEnv()\`:
|
|
|
55861
56033
|
1. Add a password field to \`connection.fields\` (for example \`platformApiKey\`).
|
|
55862
56034
|
2. Read \`PLUGIN_CONNECTION_FILE.connection.platformApiKey\`.
|
|
55863
56035
|
3. Construct \`new OpenMcpClient({ url: process.env.API_GATEWAY_URL, token: ... })\`.
|
|
55864
|
-
4.
|
|
56036
|
+
4. If no usable connection exists, call
|
|
56037
|
+
\`request_connection { type, pluginKey, toolName, reason }\`.
|
|
55865
56038
|
5. Re-test with \`manage_plugin test\` + \`connectionKey\`.
|
|
55866
56039
|
|
|
55867
56040
|
\`fromEnv()\` still works for agent \`code_eval\`, not for plugin handlers.
|
|
@@ -56026,8 +56199,32 @@ description: Define connection fields and test/discover handlers for a tenant sa
|
|
|
56026
56199
|
|
|
56027
56200
|
# Connections
|
|
56028
56201
|
|
|
56029
|
-
Define \`connection.fields\` in plugin.json.
|
|
56030
|
-
|
|
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"\`.
|
|
56031
56228
|
|
|
56032
56229
|
The resolved connection is injected at execution time as an
|
|
56033
56230
|
\`{ connection?, connections? }\` envelope in a JSON file path passed through
|
|
@@ -56073,10 +56270,18 @@ Use the \`manage_plugin\` tool. The loop:
|
|
|
56073
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.
|
|
56074
56271
|
3. If the plugin has \`connection.fields\` and a tool reads credentials: a **human**
|
|
56075
56272
|
must configure a connection of this plugin type. You cannot create credentials.
|
|
56076
|
-
Call \`list_connections { type }\` first \u2014 if
|
|
56077
|
-
|
|
56078
|
-
|
|
56079
|
-
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.
|
|
56080
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).
|
|
56081
56286
|
5. \`action: "test"\` to exercise a handler without an LLM:
|
|
56082
56287
|
- Tool: \`{ type, target: { kind: "tool", name, input, connectionKey? } }\`
|
|
@@ -56270,13 +56475,22 @@ After the human confirms the design, author the plugin files directly with the f
|
|
|
56270
56475
|
the sandbox) \u2192 \`manage_plugin { action: "reload", type }\` (the catalog caches, so a
|
|
56271
56476
|
freshly written file is invisible to \`test\` until you reload) \u2192 \`manage_plugin
|
|
56272
56477
|
{ action: "test", type, target }\`.
|
|
56273
|
-
If a tool needs credentials,
|
|
56274
|
-
|
|
56275
|
-
|
|
56276
|
-
|
|
56277
|
-
|
|
56278
|
-
|
|
56279
|
-
|
|
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.
|
|
56280
56494
|
|
|
56281
56495
|
Deployment is human-gated: do NOT deploy on your own after the tests pass.
|
|
56282
56496
|
Only deploy when the human explicitly asks for it or approves it, then load
|
|
@@ -56475,6 +56689,21 @@ function tenantIdFrom(exeConfig) {
|
|
|
56475
56689
|
function errorText(err) {
|
|
56476
56690
|
return err instanceof Error ? err.message : String(err);
|
|
56477
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
|
+
}
|
|
56478
56707
|
function deploymentUnavailable(action) {
|
|
56479
56708
|
const error = `plugin deployment service is not configured; cannot ${action}. Resident plugin services are unavailable in this environment.`;
|
|
56480
56709
|
if (action === "undeploy") return JSON.stringify({ undeployed: false, error });
|
|
@@ -56511,6 +56740,13 @@ var managePluginSchema = z73.object({
|
|
|
56511
56740
|
connectionKey: z73.string().optional()
|
|
56512
56741
|
}).optional()
|
|
56513
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
|
+
});
|
|
56514
56750
|
var sandboxPluginsPlugin = {
|
|
56515
56751
|
meta: {
|
|
56516
56752
|
type: "sandbox-plugins",
|
|
@@ -56908,8 +57144,68 @@ var sandboxPluginsPlugin = {
|
|
|
56908
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.",
|
|
56909
57145
|
schema: managePluginSchema
|
|
56910
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
|
+
)
|
|
56911
57157
|
)
|
|
56912
|
-
]
|
|
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
|
+
}
|
|
56913
57209
|
})
|
|
56914
57210
|
};
|
|
56915
57211
|
|
|
@@ -58279,11 +58575,11 @@ var INLINE_INPUT_LIMIT_BYTES2 = 48 * 1024;
|
|
|
58279
58575
|
var DEFAULT_HANDLER_TIMEOUT_MS = 6e4;
|
|
58280
58576
|
var MIN_HANDLER_TIMEOUT_MS = 1e3;
|
|
58281
58577
|
var MAX_HANDLER_TIMEOUT_MS = 3e5;
|
|
58282
|
-
function
|
|
58578
|
+
function isRecord15(value) {
|
|
58283
58579
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
58284
58580
|
}
|
|
58285
58581
|
function isEnvelope3(value) {
|
|
58286
|
-
return
|
|
58582
|
+
return isRecord15(value) && typeof value.ok === "boolean";
|
|
58287
58583
|
}
|
|
58288
58584
|
function parseHostArgs(argv) {
|
|
58289
58585
|
let type;
|