@axiom-lattice/core 10.0.4 → 10.1.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 +319 -11
- package/dist/index.d.ts +319 -11
- package/dist/index.js +1184 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1172 -189
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1658,6 +1658,7 @@ __export(index_exports, {
|
|
|
1658
1658
|
DelegationService: () => DelegationService,
|
|
1659
1659
|
DependencyResolver: () => DependencyResolver,
|
|
1660
1660
|
DuplicateProjectRoomMessageIdempotencyKeyError: () => DuplicateProjectRoomMessageIdempotencyKeyError,
|
|
1661
|
+
DuplicateShareTokenError: () => DuplicateShareTokenError,
|
|
1661
1662
|
E2BInstance: () => E2BInstance,
|
|
1662
1663
|
E2BProvider: () => E2BProvider,
|
|
1663
1664
|
EMPTY_CONTENT_WARNING: () => EMPTY_CONTENT_WARNING,
|
|
@@ -1693,6 +1694,7 @@ __export(index_exports, {
|
|
|
1693
1694
|
InMemoryProjectRoomMessageStore: () => InMemoryProjectRoomMessageStore,
|
|
1694
1695
|
InMemoryProjectRoomReadStateStore: () => InMemoryProjectRoomReadStateStore,
|
|
1695
1696
|
InMemoryProjectRoomStore: () => InMemoryProjectRoomStore,
|
|
1697
|
+
InMemorySharedResourceStore: () => InMemorySharedResourceStore,
|
|
1696
1698
|
InMemoryStore: () => InMemoryStore,
|
|
1697
1699
|
InMemoryTaskStore: () => InMemoryTaskStore,
|
|
1698
1700
|
InMemoryTaskWorkItemStore: () => InMemoryTaskWorkItemStore,
|
|
@@ -1749,6 +1751,7 @@ __export(index_exports, {
|
|
|
1749
1751
|
ProjectBotMembershipIdConflictError: () => ProjectBotMembershipIdConflictError,
|
|
1750
1752
|
ProjectMutationMutex: () => ProjectMutationMutex,
|
|
1751
1753
|
ProjectRoomMessageIdConflictError: () => ProjectRoomMessageIdConflictError,
|
|
1754
|
+
ProjectRoomMessageNotifier: () => ProjectRoomMessageNotifier,
|
|
1752
1755
|
ProjectTaskAdmissionNotifier: () => ProjectTaskAdmissionNotifier,
|
|
1753
1756
|
ProjectTaskOwnerPolicy: () => ProjectTaskOwnerPolicy,
|
|
1754
1757
|
ProjectTaskOwnerPolicyError: () => ProjectTaskOwnerPolicyError,
|
|
@@ -1765,6 +1768,8 @@ __export(index_exports, {
|
|
|
1765
1768
|
SAFE_PATH_COMPONENT: () => SAFE_PATH_COMPONENT,
|
|
1766
1769
|
SANDBOX_OPEN_GATEWAY_URL_ENV: () => SANDBOX_OPEN_GATEWAY_URL_ENV,
|
|
1767
1770
|
SANDBOX_OPEN_TOKEN_ENV: () => SANDBOX_OPEN_TOKEN_ENV,
|
|
1771
|
+
SHARE_CARD_APP_HTML: () => SHARE_CARD_APP_HTML,
|
|
1772
|
+
SHARE_CARD_UI_RESOURCE: () => SHARE_CARD_UI_RESOURCE,
|
|
1768
1773
|
STTModelLattice: () => STTModelLattice,
|
|
1769
1774
|
STTModelLatticeManager: () => STTModelLatticeManager,
|
|
1770
1775
|
SUMMARIZATION_TRIGGER_RATIO: () => SUMMARIZATION_TRIGGER_RATIO,
|
|
@@ -1774,6 +1779,7 @@ __export(index_exports, {
|
|
|
1774
1779
|
SandboxSkillStore: () => SandboxSkillStore,
|
|
1775
1780
|
ScheduleLatticeManager: () => ScheduleLatticeManager,
|
|
1776
1781
|
SemanticMetricsClient: () => SemanticMetricsClient,
|
|
1782
|
+
SharePayloadError: () => SharePayloadError,
|
|
1777
1783
|
SharedChunkBuffer: () => SharedChunkBuffer,
|
|
1778
1784
|
SimpleMemoryVectorStore: () => SimpleMemoryVectorStore,
|
|
1779
1785
|
SkillLatticeManager: () => SkillLatticeManager,
|
|
@@ -1805,6 +1811,7 @@ __export(index_exports, {
|
|
|
1805
1811
|
abortWorkflowRun: () => abortWorkflowRun,
|
|
1806
1812
|
agentInstanceManager: () => agentInstanceManager,
|
|
1807
1813
|
agentLatticeManager: () => agentLatticeManager,
|
|
1814
|
+
appSharePlugin: () => appSharePlugin,
|
|
1808
1815
|
appendReconciliationWarning: () => appendReconciliationWarning,
|
|
1809
1816
|
appendUiFence: () => appendUiFence,
|
|
1810
1817
|
assertQueueSources: () => assertQueueSources,
|
|
@@ -1857,6 +1864,7 @@ __export(index_exports, {
|
|
|
1857
1864
|
createListTablesSqlTool: () => createListTablesSqlTool,
|
|
1858
1865
|
createLongTermStoreMiddleware: () => createLongTermStoreMiddleware,
|
|
1859
1866
|
createMapNode: () => createMapNode,
|
|
1867
|
+
createMcpAppSharePayload: () => createMcpAppSharePayload,
|
|
1860
1868
|
createModelSelectorMiddleware: () => createModelSelectorMiddleware,
|
|
1861
1869
|
createNodeHandler: () => createNodeHandler,
|
|
1862
1870
|
createProjectRoomMiddleware: () => createProjectRoomMiddleware,
|
|
@@ -1950,6 +1958,7 @@ __export(index_exports, {
|
|
|
1950
1958
|
getSTTModelLattice: () => getSTTModelLattice,
|
|
1951
1959
|
getSandBoxManager: () => getSandBoxManager,
|
|
1952
1960
|
getSandboxOpenCredential: () => getSandboxOpenCredential,
|
|
1961
|
+
getSandboxOpenGatewayUrl: () => getSandboxOpenGatewayUrl,
|
|
1953
1962
|
getSandboxPluginCatalog: () => getSandboxPluginCatalog,
|
|
1954
1963
|
getScheduleLattice: () => getScheduleLattice,
|
|
1955
1964
|
getStoreLattice: () => getStoreLattice,
|
|
@@ -2023,6 +2032,7 @@ __export(index_exports, {
|
|
|
2023
2032
|
prepareTaskDispatch: () => prepareTaskDispatch,
|
|
2024
2033
|
probeThreadRunOwner: () => probeThreadRunOwner,
|
|
2025
2034
|
projectMutationMutex: () => projectMutationMutex,
|
|
2035
|
+
projectRoomMessageNotifier: () => projectRoomMessageNotifier,
|
|
2026
2036
|
projectRoomPlugin: () => projectRoomPlugin,
|
|
2027
2037
|
projectTaskAdmissionNotifier: () => projectTaskAdmissionNotifier,
|
|
2028
2038
|
provisionSandboxOpenClient: () => provisionSandboxOpenClient,
|
|
@@ -2049,6 +2059,7 @@ __export(index_exports, {
|
|
|
2049
2059
|
registerQueueLattice: () => registerQueueLattice,
|
|
2050
2060
|
registerSTTModelLattice: () => registerSTTModelLattice,
|
|
2051
2061
|
registerSandboxOpenCredentialProvider: () => registerSandboxOpenCredentialProvider,
|
|
2062
|
+
registerSandboxOpenGatewayUrlProvider: () => registerSandboxOpenGatewayUrlProvider,
|
|
2052
2063
|
registerSandboxProviderType: () => registerSandboxProviderType,
|
|
2053
2064
|
registerScheduleLattice: () => registerScheduleLattice,
|
|
2054
2065
|
registerStoreLattice: () => registerStoreLattice,
|
|
@@ -2093,6 +2104,7 @@ __export(index_exports, {
|
|
|
2093
2104
|
setPluginDeploymentService: () => setPluginDeploymentService,
|
|
2094
2105
|
setRunCancelHeartbeatFallbackObserver: () => setRunCancelHeartbeatFallbackObserver,
|
|
2095
2106
|
setSandboxPluginCatalog: () => setSandboxPluginCatalog,
|
|
2107
|
+
shareAppSchema: () => shareAppSchema,
|
|
2096
2108
|
signMcpUiScope: () => signMcpUiScope,
|
|
2097
2109
|
skillLatticeManager: () => skillLatticeManager,
|
|
2098
2110
|
sqlDatabaseManager: () => sqlDatabaseManager,
|
|
@@ -13430,25 +13442,38 @@ domains your configured middleware exposes \u2014 and nothing beyond it.
|
|
|
13430
13442
|
|
|
13431
13443
|
## Client
|
|
13432
13444
|
|
|
13433
|
-
The sandbox
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
- **Preinstalled in the sandbox image** (recommended): \`open-mcp\` is on \`PATH\`; for
|
|
13437
|
-
\`require("@axiom-lattice/open-mcp-client")\` to resolve, install it into the working
|
|
13438
|
-
directory or point \`NODE_PATH\` at the global \`node_modules\`.
|
|
13439
|
-
- **Install it in this run** when the sandbox has network + npm:
|
|
13440
|
-
|
|
13441
|
-
\`\`\`bash
|
|
13442
|
-
npm install @axiom-lattice/open-mcp-client
|
|
13443
|
-
# or use without installing:
|
|
13444
|
-
npx @axiom-lattice/open-mcp-client tools list --json
|
|
13445
|
-
\`\`\`
|
|
13445
|
+
The sandbox image provides the zero-dependency \`@axiom-lattice/open-mcp-client\`
|
|
13446
|
+
package. Use the bare module:
|
|
13446
13447
|
|
|
13447
13448
|
\`\`\`js
|
|
13448
13449
|
const { OpenMcpClient } = require("@axiom-lattice/open-mcp-client");
|
|
13449
13450
|
const client = OpenMcpClient.fromEnv(); // reads API_GATEWAY_URL + OPEN_API_TOKEN
|
|
13450
13451
|
\`\`\`
|
|
13451
13452
|
|
|
13453
|
+
## Plugin handlers
|
|
13454
|
+
|
|
13455
|
+
A sandbox plugin handler reads the platform API key from its connection:
|
|
13456
|
+
|
|
13457
|
+
\`\`\`js
|
|
13458
|
+
const conn = JSON.parse(
|
|
13459
|
+
require("fs").readFileSync(process.env.PLUGIN_CONNECTION_FILE, "utf8"),
|
|
13460
|
+
).connection;
|
|
13461
|
+
const client = new OpenMcpClient({
|
|
13462
|
+
url: process.env.API_GATEWAY_URL,
|
|
13463
|
+
token: conn.platformApiKey, // \u4F5C\u8005\u5728 connection.fields \u91CC\u5B9A\u4E49\u7684\u5B57\u6BB5
|
|
13464
|
+
});
|
|
13465
|
+
\`\`\`
|
|
13466
|
+
|
|
13467
|
+
- The platform key is a normal password field defined by the plugin author; the
|
|
13468
|
+
framework does not inject or rename it.
|
|
13469
|
+
- \`OPEN_API_TOKEN\` is only for agent \`code_eval\`; plugin handlers use the
|
|
13470
|
+
connection key directly.
|
|
13471
|
+
- Caller grants gate entry and connection selection; after that, the connection
|
|
13472
|
+
key's grants apply (service-account model).
|
|
13473
|
+
|
|
13474
|
+
Resource selection is not the handler's job: Open MCP tools are already bound to
|
|
13475
|
+
their resources. Use \`listTools()\` and \`callTool()\` only.
|
|
13476
|
+
|
|
13452
13477
|
CLI equivalents (config comes from the same env vars):
|
|
13453
13478
|
|
|
13454
13479
|
\`\`\`bash
|
|
@@ -14153,6 +14178,142 @@ var InMemoryMenuStore = class {
|
|
|
14153
14178
|
}
|
|
14154
14179
|
};
|
|
14155
14180
|
|
|
14181
|
+
// src/store_lattice/InMemorySharedResourceStore.ts
|
|
14182
|
+
var DuplicateShareTokenError = class extends Error {
|
|
14183
|
+
/**
|
|
14184
|
+
* Creates a duplicate share token error.
|
|
14185
|
+
*
|
|
14186
|
+
* @param token - Token that is already present in the store.
|
|
14187
|
+
*/
|
|
14188
|
+
constructor(token) {
|
|
14189
|
+
super(`Share token '${token}' already exists`);
|
|
14190
|
+
/** Machine-readable failure code. */
|
|
14191
|
+
this.code = "DUPLICATE_SHARE_TOKEN";
|
|
14192
|
+
this.name = "DuplicateShareTokenError";
|
|
14193
|
+
this.token = token;
|
|
14194
|
+
}
|
|
14195
|
+
};
|
|
14196
|
+
var MUTABLE_FIELDS = [
|
|
14197
|
+
"title",
|
|
14198
|
+
"expiresAt",
|
|
14199
|
+
"maxAccess",
|
|
14200
|
+
"revoked",
|
|
14201
|
+
"visibility",
|
|
14202
|
+
"passwordHash"
|
|
14203
|
+
];
|
|
14204
|
+
function cloneShareRecord(record) {
|
|
14205
|
+
return structuredClone(record);
|
|
14206
|
+
}
|
|
14207
|
+
var InMemorySharedResourceStore = class {
|
|
14208
|
+
constructor() {
|
|
14209
|
+
this.records = /* @__PURE__ */ new Map();
|
|
14210
|
+
}
|
|
14211
|
+
/**
|
|
14212
|
+
* Finds a share by its token.
|
|
14213
|
+
*
|
|
14214
|
+
* @param token - Share token to look up.
|
|
14215
|
+
* @returns An independent copy of the record, or `null` when absent.
|
|
14216
|
+
*/
|
|
14217
|
+
async findByToken(token) {
|
|
14218
|
+
const record = this.records.get(token);
|
|
14219
|
+
return record ? cloneShareRecord(record) : null;
|
|
14220
|
+
}
|
|
14221
|
+
/**
|
|
14222
|
+
* Inserts a new share record with `accessCount: 0`, `version: 1`, and the
|
|
14223
|
+
* current `createdAt`.
|
|
14224
|
+
*
|
|
14225
|
+
* @param record - Insert shape for the new share.
|
|
14226
|
+
* @returns An independent copy of the stored record.
|
|
14227
|
+
* @throws {DuplicateShareTokenError} When the token is already stored.
|
|
14228
|
+
*/
|
|
14229
|
+
async create(record) {
|
|
14230
|
+
if (this.records.has(record.token)) {
|
|
14231
|
+
throw new DuplicateShareTokenError(record.token);
|
|
14232
|
+
}
|
|
14233
|
+
const stored = {
|
|
14234
|
+
...record,
|
|
14235
|
+
accessCount: 0,
|
|
14236
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
14237
|
+
version: 1
|
|
14238
|
+
};
|
|
14239
|
+
this.records.set(stored.token, cloneShareRecord(stored));
|
|
14240
|
+
return cloneShareRecord(stored);
|
|
14241
|
+
}
|
|
14242
|
+
/**
|
|
14243
|
+
* Applies a patch to an existing share.
|
|
14244
|
+
*
|
|
14245
|
+
* Only `title`, `expiresAt`, `maxAccess`, `revoked`, `visibility`, and
|
|
14246
|
+
* `passwordHash` are applied; other keys (for example `token`, `kind`, or
|
|
14247
|
+
* `address`) are ignored. `undefined` values are treated as "no change".
|
|
14248
|
+
* Missing tokens are a no-op.
|
|
14249
|
+
*
|
|
14250
|
+
* @param token - Token of the share to update.
|
|
14251
|
+
* @param patch - Mutable fields to apply.
|
|
14252
|
+
*/
|
|
14253
|
+
async update(token, patch) {
|
|
14254
|
+
const current = this.records.get(token);
|
|
14255
|
+
if (!current) return;
|
|
14256
|
+
const updates = {};
|
|
14257
|
+
for (const field of MUTABLE_FIELDS) {
|
|
14258
|
+
if (patch[field] !== void 0) {
|
|
14259
|
+
updates[field] = patch[field];
|
|
14260
|
+
}
|
|
14261
|
+
}
|
|
14262
|
+
if (Object.keys(updates).length === 0) return;
|
|
14263
|
+
const next = cloneShareRecord(current);
|
|
14264
|
+
Object.assign(next, updates);
|
|
14265
|
+
this.records.set(token, cloneShareRecord(next));
|
|
14266
|
+
}
|
|
14267
|
+
/**
|
|
14268
|
+
* Lists a user's shares within a tenant, newest first by `createdAt`.
|
|
14269
|
+
*
|
|
14270
|
+
* @param tenantId - Tenant to scope the listing to.
|
|
14271
|
+
* @param userId - Creator (`createdBy`) to scope the listing to.
|
|
14272
|
+
* @returns Independent copies of matching records.
|
|
14273
|
+
*/
|
|
14274
|
+
async listByUser(tenantId2, userId) {
|
|
14275
|
+
return [...this.records.values()].map((record, insertionIndex) => ({ record, insertionIndex })).filter(
|
|
14276
|
+
({ record }) => record.tenantId === tenantId2 && record.createdBy === userId
|
|
14277
|
+
).sort(
|
|
14278
|
+
(left, right) => right.record.createdAt.getTime() - left.record.createdAt.getTime() || right.insertionIndex - left.insertionIndex
|
|
14279
|
+
).map(({ record }) => cloneShareRecord(record));
|
|
14280
|
+
}
|
|
14281
|
+
/**
|
|
14282
|
+
* Increments `accessCount` unconditionally when the token exists.
|
|
14283
|
+
*
|
|
14284
|
+
* Use {@link atomicIncrementAccess} when revocation, expiry, and `maxAccess`
|
|
14285
|
+
* must be enforced.
|
|
14286
|
+
*
|
|
14287
|
+
* @param token - Token of the share to count.
|
|
14288
|
+
*/
|
|
14289
|
+
async incrementAccess(token) {
|
|
14290
|
+
const current = this.records.get(token);
|
|
14291
|
+
if (current) current.accessCount += 1;
|
|
14292
|
+
}
|
|
14293
|
+
/**
|
|
14294
|
+
* Atomically increments `accessCount` only when the share is usable and the
|
|
14295
|
+
* access limit has not been reached.
|
|
14296
|
+
*
|
|
14297
|
+
* A share is considered expired when `expiresAt.getTime() <= Date.now()`,
|
|
14298
|
+
* matching PostgreSQL's `expires_at > NOW()` check.
|
|
14299
|
+
*
|
|
14300
|
+
* @param token - Token of the share to count.
|
|
14301
|
+
* @returns `true` when access was granted, `false` otherwise.
|
|
14302
|
+
*/
|
|
14303
|
+
async atomicIncrementAccess(token) {
|
|
14304
|
+
const current = this.records.get(token);
|
|
14305
|
+
if (!current || current.revoked) return false;
|
|
14306
|
+
if (current.expiresAt && current.expiresAt.getTime() <= Date.now()) {
|
|
14307
|
+
return false;
|
|
14308
|
+
}
|
|
14309
|
+
if (current.maxAccess !== null && current.accessCount >= current.maxAccess) {
|
|
14310
|
+
return false;
|
|
14311
|
+
}
|
|
14312
|
+
current.accessCount += 1;
|
|
14313
|
+
return true;
|
|
14314
|
+
}
|
|
14315
|
+
};
|
|
14316
|
+
|
|
14156
14317
|
// src/model_lattice/ModelLatticeManager.ts
|
|
14157
14318
|
var TENANT_DEFAULT_MISS_TTL_MS = 3e4;
|
|
14158
14319
|
var ModelLatticeManager = class _ModelLatticeManager extends BaseLatticeManager {
|
|
@@ -14702,11 +14863,11 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
14702
14863
|
* @param key Lattice键名
|
|
14703
14864
|
* @param tool 已有的StructuredTool实例
|
|
14704
14865
|
*/
|
|
14705
|
-
registerExistingTool(key5,
|
|
14866
|
+
registerExistingTool(key5, tool68) {
|
|
14706
14867
|
const config = {
|
|
14707
|
-
name:
|
|
14708
|
-
description:
|
|
14709
|
-
schema:
|
|
14868
|
+
name: tool68.name,
|
|
14869
|
+
description: tool68.description,
|
|
14870
|
+
schema: tool68.schema,
|
|
14710
14871
|
// StructuredTool的schema已经是Zod兼容的
|
|
14711
14872
|
needUserApprove: false
|
|
14712
14873
|
// MCP工具默认不需要用户批准
|
|
@@ -14714,7 +14875,7 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
14714
14875
|
const toolLattice = {
|
|
14715
14876
|
key: key5,
|
|
14716
14877
|
config,
|
|
14717
|
-
client:
|
|
14878
|
+
client: tool68
|
|
14718
14879
|
};
|
|
14719
14880
|
this.register(key5, toolLattice);
|
|
14720
14881
|
}
|
|
@@ -14725,14 +14886,14 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
14725
14886
|
* @param key - tool lattice key (no tenant prefix)
|
|
14726
14887
|
* @param tool - the StructuredTool client
|
|
14727
14888
|
*/
|
|
14728
|
-
registerExistingToolWithTenant(tenantId2, key5,
|
|
14889
|
+
registerExistingToolWithTenant(tenantId2, key5, tool68) {
|
|
14729
14890
|
const config = {
|
|
14730
|
-
name:
|
|
14731
|
-
description:
|
|
14732
|
-
schema:
|
|
14891
|
+
name: tool68.name,
|
|
14892
|
+
description: tool68.description,
|
|
14893
|
+
schema: tool68.schema,
|
|
14733
14894
|
needUserApprove: false
|
|
14734
14895
|
};
|
|
14735
|
-
const toolLattice = { key: key5, config, client:
|
|
14896
|
+
const toolLattice = { key: key5, config, client: tool68 };
|
|
14736
14897
|
this.registerWithTenant(tenantId2, key5, toolLattice);
|
|
14737
14898
|
}
|
|
14738
14899
|
/**
|
|
@@ -14782,8 +14943,8 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
14782
14943
|
};
|
|
14783
14944
|
var toolLatticeManager = ToolLatticeManager.getInstance();
|
|
14784
14945
|
var registerToolLattice = (key5, config, executor) => toolLatticeManager.registerLattice(key5, config, executor);
|
|
14785
|
-
var registerExistingTool = (key5,
|
|
14786
|
-
var registerExistingToolWithTenant = (tenantId2, key5,
|
|
14946
|
+
var registerExistingTool = (key5, tool68) => toolLatticeManager.registerExistingTool(key5, tool68);
|
|
14947
|
+
var registerExistingToolWithTenant = (tenantId2, key5, tool68) => toolLatticeManager.registerExistingToolWithTenant(tenantId2, key5, tool68);
|
|
14787
14948
|
var getToolLattice = (key5) => toolLatticeManager.getToolLattice(key5);
|
|
14788
14949
|
var getToolClientWithTenant = (tenantId2, key5) => toolLatticeManager.getToolClientWithTenant(tenantId2, key5);
|
|
14789
14950
|
var getToolDefinition = (key5) => toolLatticeManager.getToolDefinition(key5);
|
|
@@ -17773,6 +17934,7 @@ var SANDBOX_OPEN_GATEWAY_URL_ENV = "API_GATEWAY_URL";
|
|
|
17773
17934
|
var SANDBOX_OPEN_TOKEN_ENV = "OPEN_API_TOKEN";
|
|
17774
17935
|
var provider;
|
|
17775
17936
|
var providerErrorHandler;
|
|
17937
|
+
var gatewayUrlProvider;
|
|
17776
17938
|
function registerSandboxOpenCredentialProvider(next, options = {}) {
|
|
17777
17939
|
provider = next;
|
|
17778
17940
|
providerErrorHandler = options.onError;
|
|
@@ -17795,6 +17957,15 @@ async function getSandboxOpenCredential(context) {
|
|
|
17795
17957
|
return void 0;
|
|
17796
17958
|
}
|
|
17797
17959
|
}
|
|
17960
|
+
function registerSandboxOpenGatewayUrlProvider(next) {
|
|
17961
|
+
gatewayUrlProvider = next;
|
|
17962
|
+
return () => {
|
|
17963
|
+
if (gatewayUrlProvider === next) gatewayUrlProvider = void 0;
|
|
17964
|
+
};
|
|
17965
|
+
}
|
|
17966
|
+
function getSandboxOpenGatewayUrl() {
|
|
17967
|
+
return gatewayUrlProvider?.();
|
|
17968
|
+
}
|
|
17798
17969
|
function buildSandboxOpenEnv(credential) {
|
|
17799
17970
|
return `export ${SANDBOX_OPEN_GATEWAY_URL_ENV}=${shellSingleQuote(credential.gatewayUrl)} && export ${SANDBOX_OPEN_TOKEN_ENV}=${shellSingleQuote(credential.token)}`;
|
|
17800
17971
|
}
|
|
@@ -17804,6 +17975,7 @@ function shellSingleQuote(value) {
|
|
|
17804
17975
|
function clearSandboxOpenCredentialProviderForTests() {
|
|
17805
17976
|
provider = void 0;
|
|
17806
17977
|
providerErrorHandler = void 0;
|
|
17978
|
+
gatewayUrlProvider = void 0;
|
|
17807
17979
|
}
|
|
17808
17980
|
|
|
17809
17981
|
// src/tool_lattice/shell_exec/index.ts
|
|
@@ -22626,11 +22798,13 @@ function errorFromStdout(stdout) {
|
|
|
22626
22798
|
return text.slice(0, 4096);
|
|
22627
22799
|
}
|
|
22628
22800
|
function buildResidentPayload(args, timeoutMs) {
|
|
22801
|
+
const gatewayUrl = getSandboxOpenGatewayUrl();
|
|
22629
22802
|
return {
|
|
22630
22803
|
handler: args.handler,
|
|
22631
22804
|
input: args.input,
|
|
22632
22805
|
...args.connection === void 0 ? {} : { connection: args.connection },
|
|
22633
22806
|
...args.connections === void 0 ? {} : { connections: args.connections },
|
|
22807
|
+
...gatewayUrl === void 0 ? {} : { apiGatewayUrl: gatewayUrl },
|
|
22634
22808
|
context: args.context,
|
|
22635
22809
|
timeoutMs
|
|
22636
22810
|
};
|
|
@@ -22885,15 +23059,7 @@ var SandboxPluginExecutor = class {
|
|
|
22885
23059
|
workspaceId: args.runConfig?.workspaceId,
|
|
22886
23060
|
projectId: args.runConfig?.projectId
|
|
22887
23061
|
});
|
|
22888
|
-
const
|
|
22889
|
-
tenantId: tenantId2,
|
|
22890
|
-
workspaceId: args.runConfig?.workspaceId,
|
|
22891
|
-
projectId: args.runConfig?.projectId,
|
|
22892
|
-
sandboxName: sandbox.name,
|
|
22893
|
-
assistantId: args.runConfig?.assistantId,
|
|
22894
|
-
threadId: args.runConfig?.threadId,
|
|
22895
|
-
depth: args.runConfig?.depth
|
|
22896
|
-
}) : void 0;
|
|
23062
|
+
const gatewayUrl = getSandboxOpenGatewayUrl();
|
|
22897
23063
|
const timeoutMs = clamp(args.timeoutMs ?? DEFAULT_TIMEOUT_MS, MIN_TIMEOUT_MS, MAX_TIMEOUT_MS);
|
|
22898
23064
|
const cap = clamp(
|
|
22899
23065
|
args.maxResultBytes ?? DEFAULT_MAX_RESULT_BYTES,
|
|
@@ -22924,13 +23090,12 @@ var SandboxPluginExecutor = class {
|
|
|
22924
23090
|
envParts.push(`PLUGIN_CONNECTION_FILE=${quotePosixShellArg(connectionFile)}`);
|
|
22925
23091
|
}
|
|
22926
23092
|
envParts.push(`PLUGIN_CONTEXT=${quotePosixShellArg(encode(args.context))}`);
|
|
22927
|
-
if (
|
|
23093
|
+
if (gatewayUrl) {
|
|
22928
23094
|
envParts.push(
|
|
22929
|
-
`${SANDBOX_OPEN_GATEWAY_URL_ENV}=${quotePosixShellArg(
|
|
23095
|
+
`${SANDBOX_OPEN_GATEWAY_URL_ENV}=${quotePosixShellArg(gatewayUrl)}`
|
|
22930
23096
|
);
|
|
22931
|
-
envParts.push(`${SANDBOX_OPEN_TOKEN_ENV}=${quotePosixShellArg(openCredential.token)}`);
|
|
22932
23097
|
}
|
|
22933
|
-
const command =
|
|
23098
|
+
const command = `unset OPEN_API_TOKEN; unset API_GATEWAY_URL; ${envParts.join(" ")} node ${quotePosixShellArg(handlerAbs)}`;
|
|
22934
23099
|
const execResult = await sandbox.shell.execCommand({
|
|
22935
23100
|
command,
|
|
22936
23101
|
exec_dir: pluginDir,
|
|
@@ -23081,7 +23246,7 @@ function isSafeUiPath(path8) {
|
|
|
23081
23246
|
}
|
|
23082
23247
|
function validateSandboxPluginManifest(args) {
|
|
23083
23248
|
const diagnostics = [];
|
|
23084
|
-
const error = (code, message, pluginType,
|
|
23249
|
+
const error = (code, message, pluginType, tool68) => diagnostics.push({ level: "error", code, message, pluginType, tool: tool68 });
|
|
23085
23250
|
const raw = args.raw;
|
|
23086
23251
|
if (!isRecord7(raw)) {
|
|
23087
23252
|
error("MANIFEST_NOT_OBJECT", "manifest must be a JSON object", args.dirName);
|
|
@@ -23384,14 +23549,20 @@ function sandboxRunConfigFrom(exeConfig) {
|
|
|
23384
23549
|
// src/mcp_lattice/mcpUi.ts
|
|
23385
23550
|
var import_tools2 = require("@langchain/core/tools");
|
|
23386
23551
|
var isObj = (v) => typeof v === "object" && v !== null;
|
|
23387
|
-
function extractAppsRef(meta, serverKey) {
|
|
23552
|
+
function extractAppsRef(meta, serverKey, toolName2) {
|
|
23388
23553
|
if (!isObj(meta)) return null;
|
|
23389
23554
|
const ui = isObj(meta.ui) ? meta.ui : void 0;
|
|
23390
23555
|
const nested = ui && typeof ui.resourceUri === "string" ? ui.resourceUri : "";
|
|
23391
23556
|
const flat = typeof meta["ui/resourceUri"] === "string" ? meta["ui/resourceUri"] : "";
|
|
23392
23557
|
const uri = nested || flat;
|
|
23393
23558
|
if (!uri.startsWith("ui://")) return null;
|
|
23394
|
-
return {
|
|
23559
|
+
return {
|
|
23560
|
+
kind: "mcp",
|
|
23561
|
+
serverKey,
|
|
23562
|
+
resourceUri: uri,
|
|
23563
|
+
displayMode: "inline",
|
|
23564
|
+
...toolName2 ? { toolName: toolName2 } : {}
|
|
23565
|
+
};
|
|
23395
23566
|
}
|
|
23396
23567
|
function extractLegacyRefs(content, serverKey) {
|
|
23397
23568
|
const blocks = Array.isArray(content) ? content : [];
|
|
@@ -23671,6 +23842,7 @@ function compileSandboxPlugin(args) {
|
|
|
23671
23842
|
pluginType: manifest.type,
|
|
23672
23843
|
resource: ui.resource,
|
|
23673
23844
|
displayMode: ui.displayMode ?? "inline",
|
|
23845
|
+
toolName: t.name,
|
|
23674
23846
|
...scope ? { scope } : {}
|
|
23675
23847
|
} : null;
|
|
23676
23848
|
return ref ? appendUiFence(text, ref) : text;
|
|
@@ -24443,9 +24615,9 @@ function freezeMetadata(metadata) {
|
|
|
24443
24615
|
...resourceSelector ? { resourceSelector } : {}
|
|
24444
24616
|
});
|
|
24445
24617
|
}
|
|
24446
|
-
function toolName(
|
|
24447
|
-
if (typeof
|
|
24448
|
-
return typeof
|
|
24618
|
+
function toolName(tool68) {
|
|
24619
|
+
if (typeof tool68 !== "object" || tool68 === null || !("name" in tool68)) return void 0;
|
|
24620
|
+
return typeof tool68.name === "string" ? tool68.name : void 0;
|
|
24449
24621
|
}
|
|
24450
24622
|
function schemaHasConnectionKey(schema6) {
|
|
24451
24623
|
const definition = isRecord10(schema6._def) ? schema6._def : void 0;
|
|
@@ -24453,10 +24625,10 @@ function schemaHasConnectionKey(schema6) {
|
|
|
24453
24625
|
const fields = typeof shape === "function" ? shape() : shape;
|
|
24454
24626
|
return isRecord10(fields) && Object.prototype.hasOwnProperty.call(fields, "connectionKey");
|
|
24455
24627
|
}
|
|
24456
|
-
function hasConnectionKeySchema(
|
|
24457
|
-
if (!isRecord10(
|
|
24458
|
-
if (schemaHasConnectionKey(
|
|
24459
|
-
const definition = isRecord10(
|
|
24628
|
+
function hasConnectionKeySchema(tool68) {
|
|
24629
|
+
if (!isRecord10(tool68) || !isRecord10(tool68.schema)) return false;
|
|
24630
|
+
if (schemaHasConnectionKey(tool68.schema)) return true;
|
|
24631
|
+
const definition = isRecord10(tool68.schema._def) ? tool68.schema._def : void 0;
|
|
24460
24632
|
if (Array.isArray(definition?.options) && definition.options.length > 0) {
|
|
24461
24633
|
return definition.options.every(
|
|
24462
24634
|
(option) => isRecord10(option) && schemaHasConnectionKey(option)
|
|
@@ -24511,8 +24683,8 @@ var CapabilityToolRegistry = class {
|
|
|
24511
24683
|
* @remarks Standard connection authorization is captured only for tools whose
|
|
24512
24684
|
* schema declares `connectionKey`; legacy selectors remain explicit metadata.
|
|
24513
24685
|
*/
|
|
24514
|
-
register(name, metadata,
|
|
24515
|
-
this.registerInternal(name, metadata, hasConnectionKeySchema(
|
|
24686
|
+
register(name, metadata, tool68) {
|
|
24687
|
+
this.registerInternal(name, metadata, hasConnectionKeySchema(tool68));
|
|
24516
24688
|
}
|
|
24517
24689
|
/**
|
|
24518
24690
|
* Registers all tools actually exposed by a middleware instance.
|
|
@@ -24523,13 +24695,13 @@ var CapabilityToolRegistry = class {
|
|
|
24523
24695
|
* @returns Nothing.
|
|
24524
24696
|
*/
|
|
24525
24697
|
registerMiddleware(capabilityType, middleware, resourceSelectors = {}) {
|
|
24526
|
-
for (const
|
|
24527
|
-
const name = toolName(
|
|
24698
|
+
for (const tool68 of middleware.tools ?? []) {
|
|
24699
|
+
const name = toolName(tool68);
|
|
24528
24700
|
if (name) {
|
|
24529
24701
|
this.registerInternal(name, {
|
|
24530
24702
|
capabilityType,
|
|
24531
24703
|
resourceSelector: resourceSelectors[name]
|
|
24532
|
-
}, hasConnectionKeySchema(
|
|
24704
|
+
}, hasConnectionKeySchema(tool68));
|
|
24533
24705
|
}
|
|
24534
24706
|
}
|
|
24535
24707
|
}
|
|
@@ -25212,9 +25384,9 @@ var ReActAgentGraphBuilder = class {
|
|
|
25212
25384
|
*/
|
|
25213
25385
|
async build(agentLattice, params) {
|
|
25214
25386
|
const tools = params.tools.map((t) => {
|
|
25215
|
-
const
|
|
25216
|
-
return
|
|
25217
|
-
}).filter((
|
|
25387
|
+
const tool68 = getToolClientWithTenant(params.tenantId ?? "default", t.key);
|
|
25388
|
+
return tool68;
|
|
25389
|
+
}).filter((tool68) => tool68 !== void 0);
|
|
25218
25390
|
const stateSchema2 = createReactAgentSchema(params.stateSchema);
|
|
25219
25391
|
const middlewareConfigs = params.middleware || [];
|
|
25220
25392
|
const filesystemBackend = createFilesystemBackendFactory(middlewareConfigs);
|
|
@@ -27276,8 +27448,8 @@ function validateCapability(value, index) {
|
|
|
27276
27448
|
fieldPath: `/capabilities/${index}/allowedTools`
|
|
27277
27449
|
});
|
|
27278
27450
|
}
|
|
27279
|
-
for (const [toolIndex,
|
|
27280
|
-
if (typeof
|
|
27451
|
+
for (const [toolIndex, tool68] of capability.allowedTools.entries()) {
|
|
27452
|
+
if (typeof tool68 !== "string") {
|
|
27281
27453
|
throw new CapabilityBundleValidationError(
|
|
27282
27454
|
"CAPABILITY_BUNDLE_INVALID_CAPABILITY",
|
|
27283
27455
|
"allowedTools entries must be strings",
|
|
@@ -27291,10 +27463,10 @@ function validateCapability(value, index) {
|
|
|
27291
27463
|
fieldPath: `/capabilities/${index}/allowedTools`
|
|
27292
27464
|
});
|
|
27293
27465
|
}
|
|
27294
|
-
const toolNames = new Set(plugin.meta.tools.map((
|
|
27295
|
-
for (const [toolIndex,
|
|
27296
|
-
if (typeof
|
|
27297
|
-
throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_UNKNOWN_TOOL", `Unknown tool '${String(
|
|
27466
|
+
const toolNames = new Set(plugin.meta.tools.map((tool68) => tool68.name));
|
|
27467
|
+
for (const [toolIndex, tool68] of capability.allowedTools.entries()) {
|
|
27468
|
+
if (typeof tool68 !== "string" || !toolNames.has(tool68)) {
|
|
27469
|
+
throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_UNKNOWN_TOOL", `Unknown tool '${String(tool68)}'`, {
|
|
27298
27470
|
capabilityType,
|
|
27299
27471
|
fieldPath: `/capabilities/${index}/allowedTools/${toolIndex}`
|
|
27300
27472
|
});
|
|
@@ -27777,7 +27949,7 @@ function applyStaticCeiling(capabilities, staticMiddleware) {
|
|
|
27777
27949
|
const projectTools = capability.allowedTools;
|
|
27778
27950
|
const staticTools = ceiling.allowedTools;
|
|
27779
27951
|
const effectiveStaticTools = staticTools?.length === 0 ? void 0 : staticTools;
|
|
27780
|
-
const allowedTools = projectTools === void 0 ? effectiveStaticTools : effectiveStaticTools === void 0 ? projectTools : projectTools.filter((
|
|
27952
|
+
const allowedTools = projectTools === void 0 ? effectiveStaticTools : effectiveStaticTools === void 0 ? projectTools : projectTools.filter((tool68) => effectiveStaticTools.includes(tool68));
|
|
27781
27953
|
runtime[capability.type] = structuredClone({
|
|
27782
27954
|
...capability,
|
|
27783
27955
|
config: applyStaticResourceCeiling(capability, ceiling),
|
|
@@ -29926,6 +30098,13 @@ var Agent = class {
|
|
|
29926
30098
|
timestamp: /* @__PURE__ */ new Date(),
|
|
29927
30099
|
queueMode: this.queueMode.mode
|
|
29928
30100
|
});
|
|
30101
|
+
const abortDelegatedChildren = () => {
|
|
30102
|
+
delegationCancellationRegistry.abort(this.tenant_id, this.thread_id);
|
|
30103
|
+
};
|
|
30104
|
+
if (signal) {
|
|
30105
|
+
if (signal.aborted) abortDelegatedChildren();
|
|
30106
|
+
else signal.addEventListener("abort", abortDelegatedChildren, { once: true });
|
|
30107
|
+
}
|
|
29929
30108
|
try {
|
|
29930
30109
|
if (hasContinuation) {
|
|
29931
30110
|
const resumeConfig = effectiveCapabilityRevision === void 0 ? { ...config ?? {} } : { ...config ?? {}, capabilityRuntimeRevision: effectiveCapabilityRevision };
|
|
@@ -29956,6 +30135,8 @@ var Agent = class {
|
|
|
29956
30135
|
});
|
|
29957
30136
|
}
|
|
29958
30137
|
throw error;
|
|
30138
|
+
} finally {
|
|
30139
|
+
signal?.removeEventListener("abort", abortDelegatedChildren);
|
|
29959
30140
|
}
|
|
29960
30141
|
const state = await this.getCurrentState();
|
|
29961
30142
|
const runStatus = statusFromSnapshot(state);
|
|
@@ -34368,7 +34549,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
34368
34549
|
const tools = params.tools.map((t) => {
|
|
34369
34550
|
const toolClient = getToolClientWithTenant(params.tenantId ?? "default", t.key);
|
|
34370
34551
|
return toolClient;
|
|
34371
|
-
}).filter((
|
|
34552
|
+
}).filter((tool68) => tool68 !== void 0);
|
|
34372
34553
|
const subagents = await Promise.all(params.subAgents.map(async (sa) => {
|
|
34373
34554
|
if (sa.client) {
|
|
34374
34555
|
return {
|
|
@@ -35170,7 +35351,7 @@ function requireSkillDeclaration(skillLoaded) {
|
|
|
35170
35351
|
return void 0;
|
|
35171
35352
|
}
|
|
35172
35353
|
async function validateAgentReferences(input, tenantId2) {
|
|
35173
|
-
const availableTools = getAvailableTools(tenantId2).map((
|
|
35354
|
+
const availableTools = getAvailableTools(tenantId2).map((tool68) => tool68.key);
|
|
35174
35355
|
const availableMiddlewareTypes = await getAvailableMiddlewareTypes(tenantId2);
|
|
35175
35356
|
const availableCustomMiddlewareKeys = CustomMiddlewareRegistry.list().filter(
|
|
35176
35357
|
(key5) => CustomMiddlewareRegistry.get(key5) !== void 0
|
|
@@ -37748,11 +37929,11 @@ async function withTimeout2(operation, ms, onTimeout) {
|
|
|
37748
37929
|
|
|
37749
37930
|
// src/mcp_lattice/McpLatticeManager.ts
|
|
37750
37931
|
var realClientFactory = ({ mcpServers }) => new import_mcp_adapters.MultiServerMCPClient({ mcpServers });
|
|
37751
|
-
function extractRawCall(
|
|
37752
|
-
const rawCall =
|
|
37753
|
-
if (typeof rawCall === "function") return rawCall.bind(
|
|
37932
|
+
function extractRawCall(tool68) {
|
|
37933
|
+
const rawCall = tool68._call;
|
|
37934
|
+
if (typeof rawCall === "function") return rawCall.bind(tool68);
|
|
37754
37935
|
return async (...args) => {
|
|
37755
|
-
const invoke =
|
|
37936
|
+
const invoke = tool68.invoke.bind(tool68);
|
|
37756
37937
|
return invoke(args[0], args[2]);
|
|
37757
37938
|
};
|
|
37758
37939
|
}
|
|
@@ -38300,16 +38481,16 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
38300
38481
|
const metaByName = new Map(metaList.map((m) => [m.name, m.meta]));
|
|
38301
38482
|
this.unregisterServerTools(tenantId2, serverKey);
|
|
38302
38483
|
const keys = [];
|
|
38303
|
-
for (const
|
|
38304
|
-
if (rt.selectedTools && !rt.selectedTools.includes(
|
|
38305
|
-
const meta = metaByName.get(
|
|
38484
|
+
for (const tool68 of tools) {
|
|
38485
|
+
if (rt.selectedTools && !rt.selectedTools.includes(tool68.name)) continue;
|
|
38486
|
+
const meta = metaByName.get(tool68.name);
|
|
38306
38487
|
const rawVisibility = meta?.ui?.visibility;
|
|
38307
38488
|
const visibility = Array.isArray(rawVisibility) ? rawVisibility : typeof rawVisibility === "string" ? [rawVisibility] : void 0;
|
|
38308
38489
|
if (visibility && !visibility.includes("model")) continue;
|
|
38309
|
-
const ref = extractAppsRef(meta, serverKey);
|
|
38310
|
-
const resilient = this.wrapToolForResilience(rt,
|
|
38490
|
+
const ref = extractAppsRef(meta, serverKey, tool68.name);
|
|
38491
|
+
const resilient = this.wrapToolForResilience(rt, tool68);
|
|
38311
38492
|
const registered = ref ? wrapMcpToolWithUi(resilient, ref) : resilient;
|
|
38312
|
-
const toolKey = _McpLatticeManager.buildToolKey(serverKey,
|
|
38493
|
+
const toolKey = _McpLatticeManager.buildToolKey(serverKey, tool68.name);
|
|
38313
38494
|
try {
|
|
38314
38495
|
toolLatticeManager.registerExistingToolWithTenant(tenantId2, toolKey, registered);
|
|
38315
38496
|
keys.push(toolKey);
|
|
@@ -40691,6 +40872,7 @@ var TokenCache = class {
|
|
|
40691
40872
|
var import_crypto7 = require("crypto");
|
|
40692
40873
|
var import_bcryptjs = __toESM(require("bcryptjs"));
|
|
40693
40874
|
var TOKEN_BYTES = 24;
|
|
40875
|
+
var MAX_MCP_APP_PAYLOAD_BYTES = 256 * 1024;
|
|
40694
40876
|
function generateToken() {
|
|
40695
40877
|
return (0, import_crypto7.randomBytes)(TOKEN_BYTES).toString("base64url");
|
|
40696
40878
|
}
|
|
@@ -40702,6 +40884,7 @@ function createSharePayload(tenantId2, workspaceId, projectId, userId, request)
|
|
|
40702
40884
|
}
|
|
40703
40885
|
}
|
|
40704
40886
|
return {
|
|
40887
|
+
kind: "file",
|
|
40705
40888
|
address: createResourceAddress({
|
|
40706
40889
|
tenantId: tenantId2,
|
|
40707
40890
|
workspaceId,
|
|
@@ -40723,6 +40906,46 @@ function createSharePayload(tenantId2, workspaceId, projectId, userId, request)
|
|
|
40723
40906
|
revoked: false
|
|
40724
40907
|
};
|
|
40725
40908
|
}
|
|
40909
|
+
var SharePayloadError = class extends Error {
|
|
40910
|
+
/**
|
|
40911
|
+
* @param code - The stable failure code.
|
|
40912
|
+
*/
|
|
40913
|
+
constructor(code) {
|
|
40914
|
+
super(code);
|
|
40915
|
+
this.code = code;
|
|
40916
|
+
this.name = "SharePayloadError";
|
|
40917
|
+
}
|
|
40918
|
+
};
|
|
40919
|
+
function createMcpAppSharePayload(input) {
|
|
40920
|
+
if (input.visibility === "internal") {
|
|
40921
|
+
throw new SharePayloadError("INTERNAL_NOT_SUPPORTED");
|
|
40922
|
+
}
|
|
40923
|
+
const app = { ...input.app, toolInput: input.app.toolInput ?? {} };
|
|
40924
|
+
if (typeof app.toolName !== "string" || app.toolName.trim() === "") {
|
|
40925
|
+
throw new SharePayloadError("TOOL_NAME_REQUIRED");
|
|
40926
|
+
}
|
|
40927
|
+
const size = Buffer.byteLength(JSON.stringify(app), "utf8");
|
|
40928
|
+
if (size > MAX_MCP_APP_PAYLOAD_BYTES) {
|
|
40929
|
+
throw new SharePayloadError("PAYLOAD_TOO_LARGE");
|
|
40930
|
+
}
|
|
40931
|
+
return {
|
|
40932
|
+
token: generateToken(),
|
|
40933
|
+
kind: "mcpApp",
|
|
40934
|
+
address: { kind: "mcpApp", app },
|
|
40935
|
+
title: input.title ?? app.title ?? app.toolName ?? "Shared app",
|
|
40936
|
+
createdBy: input.createdBy,
|
|
40937
|
+
tenantId: input.tenantId,
|
|
40938
|
+
workspaceId: input.workspaceId,
|
|
40939
|
+
projectId: input.projectId,
|
|
40940
|
+
assistantId: null,
|
|
40941
|
+
vmIsolation: "project",
|
|
40942
|
+
visibility: input.visibility,
|
|
40943
|
+
passwordHash: input.password ? import_bcryptjs.default.hashSync(input.password, 10) : null,
|
|
40944
|
+
expiresAt: input.expiresAt ?? null,
|
|
40945
|
+
maxAccess: input.maxAccess ?? null,
|
|
40946
|
+
revoked: false
|
|
40947
|
+
};
|
|
40948
|
+
}
|
|
40726
40949
|
|
|
40727
40950
|
// src/channel/connectAllChannels.ts
|
|
40728
40951
|
async function connectAllChannels(getAdapter, options = {}) {
|
|
@@ -42910,6 +43133,42 @@ function snapshotCanonicalScoped(value, expected) {
|
|
|
42910
43133
|
};
|
|
42911
43134
|
}
|
|
42912
43135
|
|
|
43136
|
+
// src/services/ProjectRoomMessageNotifier.ts
|
|
43137
|
+
var ProjectRoomMessageNotifier = class {
|
|
43138
|
+
constructor() {
|
|
43139
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
43140
|
+
}
|
|
43141
|
+
/**
|
|
43142
|
+
* Registers a committed-message listener.
|
|
43143
|
+
*
|
|
43144
|
+
* @param listener Observer invoked for later commits.
|
|
43145
|
+
* @returns An idempotent unsubscribe callback.
|
|
43146
|
+
*/
|
|
43147
|
+
subscribe(listener) {
|
|
43148
|
+
this.listeners.add(listener);
|
|
43149
|
+
return () => {
|
|
43150
|
+
this.listeners.delete(listener);
|
|
43151
|
+
};
|
|
43152
|
+
}
|
|
43153
|
+
/**
|
|
43154
|
+
* Delivers one committed message to every registered listener.
|
|
43155
|
+
*
|
|
43156
|
+
* @param message Canonical persisted room message.
|
|
43157
|
+
* @returns Nothing; each listener receives its own clone and failures are contained.
|
|
43158
|
+
*/
|
|
43159
|
+
notify(message) {
|
|
43160
|
+
if (this.listeners.size === 0) return;
|
|
43161
|
+
for (const listener of [...this.listeners]) {
|
|
43162
|
+
try {
|
|
43163
|
+
const result = listener(structuredClone(message));
|
|
43164
|
+
if (result !== void 0) void Promise.resolve(result).catch(() => void 0);
|
|
43165
|
+
} catch {
|
|
43166
|
+
}
|
|
43167
|
+
}
|
|
43168
|
+
}
|
|
43169
|
+
};
|
|
43170
|
+
var projectRoomMessageNotifier = new ProjectRoomMessageNotifier();
|
|
43171
|
+
|
|
42913
43172
|
// src/services/ProjectTaskOwnerPolicy.ts
|
|
42914
43173
|
var import_protocols39 = require("@axiom-lattice/protocols");
|
|
42915
43174
|
var MEMBERSHIP_REQUIRED_KEYS = [
|
|
@@ -52969,7 +53228,8 @@ function createProjectRoomMiddleware() {
|
|
|
52969
53228
|
try {
|
|
52970
53229
|
const service3 = new RoomAgentMessageService({
|
|
52971
53230
|
memberships: getStoreLattice("default", "projectBotMembership").store,
|
|
52972
|
-
messages: getStoreLattice("default", "projectRoomMessage").store
|
|
53231
|
+
messages: getStoreLattice("default", "projectRoomMessage").store,
|
|
53232
|
+
onMessageCommitted: (message) => projectRoomMessageNotifier.notify(message)
|
|
52973
53233
|
});
|
|
52974
53234
|
await service3.post({
|
|
52975
53235
|
tenantId: scope.tenantId,
|
|
@@ -53057,12 +53317,149 @@ var import_langchain86 = require("langchain");
|
|
|
53057
53317
|
var import_zod74 = require("zod");
|
|
53058
53318
|
var import_protocols48 = require("@axiom-lattice/protocols");
|
|
53059
53319
|
|
|
53320
|
+
// src/services/PluginUiToolRunner.ts
|
|
53321
|
+
var PluginNotFoundError = class extends Error {
|
|
53322
|
+
/**
|
|
53323
|
+
* @param pluginType - Plugin type that was not found or failed validation.
|
|
53324
|
+
*/
|
|
53325
|
+
constructor(pluginType) {
|
|
53326
|
+
super(`plugin "${pluginType}" not found`);
|
|
53327
|
+
this.pluginType = pluginType;
|
|
53328
|
+
this.name = "PluginNotFoundError";
|
|
53329
|
+
}
|
|
53330
|
+
};
|
|
53331
|
+
var ToolNotFoundError = class extends Error {
|
|
53332
|
+
/**
|
|
53333
|
+
* @param toolName - Tool name that was not found.
|
|
53334
|
+
*/
|
|
53335
|
+
constructor(toolName2) {
|
|
53336
|
+
super(`tool "${toolName2}" not found`);
|
|
53337
|
+
this.toolName = toolName2;
|
|
53338
|
+
this.name = "ToolNotFoundError";
|
|
53339
|
+
}
|
|
53340
|
+
};
|
|
53341
|
+
var ToolNotUiError = class extends Error {
|
|
53342
|
+
/**
|
|
53343
|
+
* @param toolName - Tool that has no `ui` resource.
|
|
53344
|
+
*/
|
|
53345
|
+
constructor(toolName2) {
|
|
53346
|
+
super(`tool "${toolName2}" has no ui`);
|
|
53347
|
+
this.toolName = toolName2;
|
|
53348
|
+
this.name = "ToolNotUiError";
|
|
53349
|
+
}
|
|
53350
|
+
};
|
|
53351
|
+
var ScopeUnavailableError = class extends Error {
|
|
53352
|
+
/**
|
|
53353
|
+
* @param text - Redacted handler text produced before signing failed.
|
|
53354
|
+
*/
|
|
53355
|
+
constructor(text) {
|
|
53356
|
+
super("MCP UI scope is unavailable");
|
|
53357
|
+
this.text = text;
|
|
53358
|
+
this.name = "ScopeUnavailableError";
|
|
53359
|
+
}
|
|
53360
|
+
};
|
|
53361
|
+
var PluginUiToolExecutionError = class extends Error {
|
|
53362
|
+
/**
|
|
53363
|
+
* @param detail - Handler error detail.
|
|
53364
|
+
* @param text - Redacted handler text produced by the failed invocation.
|
|
53365
|
+
*/
|
|
53366
|
+
constructor(detail, text) {
|
|
53367
|
+
super(detail);
|
|
53368
|
+
this.detail = detail;
|
|
53369
|
+
this.text = text;
|
|
53370
|
+
this.name = "PluginUiToolExecutionError";
|
|
53371
|
+
}
|
|
53372
|
+
};
|
|
53373
|
+
async function runSandboxPluginUiTool(input) {
|
|
53374
|
+
const manifest = input.manifest ?? await input.catalog.getValidatedManifest(input.tenantId, input.pluginType);
|
|
53375
|
+
if (!manifest) throw new PluginNotFoundError(input.pluginType);
|
|
53376
|
+
const toolDef = manifest.tools?.find((tool68) => tool68.name === input.toolName);
|
|
53377
|
+
if (!toolDef) throw new ToolNotFoundError(input.toolName);
|
|
53378
|
+
if (!toolDef.ui?.resource) throw new ToolNotUiError(input.toolName);
|
|
53379
|
+
const executor = input.catalog.getExecutor();
|
|
53380
|
+
const result = await executor.invoke({
|
|
53381
|
+
manifest,
|
|
53382
|
+
handler: toolDef.handler,
|
|
53383
|
+
input: input.input,
|
|
53384
|
+
...input.connection === void 0 ? {} : { connection: input.connection },
|
|
53385
|
+
...input.connections === void 0 ? {} : { connections: input.connections },
|
|
53386
|
+
context: {
|
|
53387
|
+
tenantId: input.tenantId,
|
|
53388
|
+
pluginType: input.pluginType,
|
|
53389
|
+
tool: input.toolName
|
|
53390
|
+
},
|
|
53391
|
+
runConfig: input.runConfig
|
|
53392
|
+
});
|
|
53393
|
+
const redacted = input.redact ? input.redact(result) : result;
|
|
53394
|
+
const text = handlerResultText(redacted);
|
|
53395
|
+
if (!result.ok) {
|
|
53396
|
+
const detail = result.error ?? "sandbox plugin execution failed";
|
|
53397
|
+
throw new PluginUiToolExecutionError(
|
|
53398
|
+
input.redact ? input.redact(detail) : detail,
|
|
53399
|
+
text
|
|
53400
|
+
);
|
|
53401
|
+
}
|
|
53402
|
+
const scope = signMcpUiScope({
|
|
53403
|
+
tid: input.runConfig.tenantId || input.tenantId,
|
|
53404
|
+
thid: typeof input.runConfig.threadId === "string" ? input.runConfig.threadId : void 0,
|
|
53405
|
+
aid: typeof input.runConfig.assistantId === "string" ? input.runConfig.assistantId : void 0,
|
|
53406
|
+
wid: typeof input.runConfig.workspaceId === "string" ? input.runConfig.workspaceId : void 0,
|
|
53407
|
+
pid: typeof input.runConfig.projectId === "string" ? input.runConfig.projectId : void 0,
|
|
53408
|
+
plugin: input.pluginType,
|
|
53409
|
+
resource: toolDef.ui.resource,
|
|
53410
|
+
ck: input.connectionKey
|
|
53411
|
+
});
|
|
53412
|
+
if (!scope) throw new ScopeUnavailableError(text);
|
|
53413
|
+
return {
|
|
53414
|
+
text,
|
|
53415
|
+
toolResult: text,
|
|
53416
|
+
uiRef: {
|
|
53417
|
+
kind: "plugin",
|
|
53418
|
+
pluginType: input.pluginType,
|
|
53419
|
+
resource: toolDef.ui.resource,
|
|
53420
|
+
displayMode: toolDef.ui.displayMode ?? "inline",
|
|
53421
|
+
toolName: input.toolName,
|
|
53422
|
+
scope
|
|
53423
|
+
}
|
|
53424
|
+
};
|
|
53425
|
+
}
|
|
53426
|
+
|
|
53060
53427
|
// src/connection/connectionSecretFields.ts
|
|
53061
53428
|
function connectionSecretFields(plugin) {
|
|
53062
53429
|
const fields = plugin?.connection?.fields ?? [];
|
|
53063
53430
|
return fields.filter((field) => field.type === "password" || field.widget === "password").map((field) => field.key);
|
|
53064
53431
|
}
|
|
53065
53432
|
|
|
53433
|
+
// src/services/connectionSecretRedaction.ts
|
|
53434
|
+
function collectSecretValues(connection, fields) {
|
|
53435
|
+
if (!connection) return [];
|
|
53436
|
+
const values = [];
|
|
53437
|
+
for (const field of fields) {
|
|
53438
|
+
const value = connection[field];
|
|
53439
|
+
if (typeof value === "string" && value.length > 0) values.push(value);
|
|
53440
|
+
}
|
|
53441
|
+
return values;
|
|
53442
|
+
}
|
|
53443
|
+
function redactString(value, secrets) {
|
|
53444
|
+
let out = value;
|
|
53445
|
+
for (const secret of secrets) out = out.split(secret).join("[redacted]");
|
|
53446
|
+
return out;
|
|
53447
|
+
}
|
|
53448
|
+
function redactSecretValues(payload, secrets) {
|
|
53449
|
+
if (secrets.length === 0) return payload;
|
|
53450
|
+
const walk = (node) => {
|
|
53451
|
+
if (typeof node === "string") return redactString(node, secrets);
|
|
53452
|
+
if (Array.isArray(node)) return node.map(walk);
|
|
53453
|
+
if (node !== null && typeof node === "object") {
|
|
53454
|
+
const out = {};
|
|
53455
|
+
for (const [key5, value] of Object.entries(node)) out[key5] = walk(value);
|
|
53456
|
+
return out;
|
|
53457
|
+
}
|
|
53458
|
+
return node;
|
|
53459
|
+
};
|
|
53460
|
+
return walk(payload);
|
|
53461
|
+
}
|
|
53462
|
+
|
|
53066
53463
|
// src/middlewares/sandboxPluginsSkills.ts
|
|
53067
53464
|
var PLUGIN_JSON_TEMPLATE = `{
|
|
53068
53465
|
"schemaVersion": 1,
|
|
@@ -53612,6 +54009,12 @@ The official \`@modelcontextprotocol/ext-apps\` client SDK reports size
|
|
|
53612
54009
|
automatically. Otherwise the panel stays at a default height and content taller
|
|
53613
54010
|
than the host max scrolls; \`templates/ui.html\` already includes this helper.
|
|
53614
54011
|
|
|
54012
|
+
## Sharing the UI as a link
|
|
54013
|
+
If the human explicitly asks to publish or share this UI, load
|
|
54014
|
+
\`app-share-publishing\` and use \`share_app\`. Public links delegate the selected
|
|
54015
|
+
connection and re-run the tool on every open; confirm visibility and warn about
|
|
54016
|
+
that delegation first.
|
|
54017
|
+
|
|
53615
54018
|
## Publishing the UI to external MCP clients
|
|
53616
54019
|
If the tool also sets \`"expose": true\`, its UI is published to Axiom's Open/MCP
|
|
53617
54020
|
surface as \`ui://<type>/<ui.resource>\`, gated by the API key's grants (item-level
|
|
@@ -53710,28 +54113,102 @@ MCP endpoint. Reach for this when a tool should orchestrate existing capabilitie
|
|
|
53710
54113
|
(read the knowledge base, create a task, invoke an agent) instead of
|
|
53711
54114
|
re-implementing them.
|
|
53712
54115
|
|
|
53713
|
-
##
|
|
53714
|
-
When the gateway injects the credential, each handler process starts with:
|
|
53715
|
-
- \`API_GATEWAY_URL\` \u2014 the gateway base URL.
|
|
53716
|
-
- \`OPEN_API_TOKEN\` \u2014 a short-lived bearer **scoped to this tenant's plugin callers**.
|
|
54116
|
+
## Two different keys \u2014 do not mix them
|
|
53717
54117
|
|
|
53718
|
-
|
|
53719
|
-
|
|
53720
|
-
|
|
54118
|
+
| Key | Where | Used for |
|
|
54119
|
+
|---|---|---|
|
|
54120
|
+
| External service key (e.g. \`boStoreKey\`) | connection config | calling your upstream service |
|
|
54121
|
+
| Platform key (e.g. \`platformApiKey\`) | connection config | calling \`/open/mcp\` |
|
|
54122
|
+
|
|
54123
|
+
Both are declared by **you** in \`connection.fields\`. The platform key is a normal
|
|
54124
|
+
password field; the framework does not inject or rename it. Use a password field
|
|
54125
|
+
so it is encrypted at rest, and never log or write the key from the handler.
|
|
54126
|
+
|
|
54127
|
+
## Do not use \`OPEN_API_TOKEN\` / \`fromEnv()\` here
|
|
54128
|
+
|
|
54129
|
+
\`OpenMcpClient.fromEnv()\` reads \`API_GATEWAY_URL + OPEN_API_TOKEN\`. That pair is
|
|
54130
|
+
only for agent \`code_eval\`. A plugin handler must read the platform key from
|
|
54131
|
+
\`PLUGIN_CONNECTION_FILE\` and pass it explicitly:
|
|
54132
|
+
|
|
54133
|
+
\`\`\`js
|
|
54134
|
+
const client = new OpenMcpClient({
|
|
54135
|
+
url: process.env.API_GATEWAY_URL,
|
|
54136
|
+
token: conn.platformApiKey, // YOUR connection field
|
|
54137
|
+
});
|
|
54138
|
+
\`\`\`
|
|
54139
|
+
|
|
54140
|
+
\`OPEN_API_TOKEN\` is **not** injected for plugin handlers. If you find yourself
|
|
54141
|
+
calling \`fromEnv()\` in a plugin handler, stop and switch to the connection key.
|
|
54142
|
+
|
|
54143
|
+
## Probe first (recommended)
|
|
54144
|
+
|
|
54145
|
+
The platform key belongs to a human. Before writing the real handler:
|
|
54146
|
+
|
|
54147
|
+
1. Declare the platform-key password field in \`connection.fields\`.
|
|
54148
|
+
2. Write a temporary \`handlers/probe.js\` that reads \`PLUGIN_CONNECTION_FILE\`,
|
|
54149
|
+
creates \`OpenMcpClient\` with the connection key, and prints
|
|
54150
|
+
\`listTools()\` (name, description, inputSchema) as JSON.
|
|
54151
|
+
3. Ask the human to configure the connection + platform key (only a human can
|
|
54152
|
+
create the key). Use \`list_connections\` to check whether a connection exists.
|
|
54153
|
+
4. Run \`manage_plugin test\` with the real \`connectionKey\`, e.g.
|
|
54154
|
+
\`{ "kind": "tool", "name": "probe", "input": {}, "connectionKey": "prod" }\`.
|
|
54155
|
+
5. Read the returned tool list; use it to choose the downstream tool names and
|
|
54156
|
+
argument shapes.
|
|
54157
|
+
6. Write the real handler. Delete the probe or keep it as a debug tool.
|
|
54158
|
+
|
|
54159
|
+
A ready-to-copy probe is in \`templates/probe-handler.js\`.
|
|
54160
|
+
|
|
54161
|
+
### What the probe cannot show
|
|
54162
|
+
|
|
54163
|
+
\`listTools()\` shows the key's **tools**, not its full resource scope. The gateway
|
|
54164
|
+
enforces the key's tenant/project/selector on every call; the handler does **not**
|
|
54165
|
+
need to re-check them to call a tool.
|
|
54166
|
+
|
|
54167
|
+
Ask the human only when the plugin's behavior depends on which project/connection
|
|
54168
|
+
is used, or when a tool schema takes a \`connectionKey\` and multiple connections
|
|
54169
|
+
are possible. A key may intentionally point at another project/tenant \u2014 that is a
|
|
54170
|
+
feature, not an error. Do not guess a connection key.
|
|
54171
|
+
|
|
54172
|
+
## Worked example
|
|
54173
|
+
|
|
54174
|
+
|
|
54175
|
+
### 1. Declare the field in \`plugin.json\`
|
|
54176
|
+
|
|
54177
|
+
\`\`\`json
|
|
54178
|
+
{
|
|
54179
|
+
"connection": {
|
|
54180
|
+
"fields": [
|
|
54181
|
+
{ "key": "baseUrl", "type": "string", "title": "Upstream URL" },
|
|
54182
|
+
{ "key": "boStoreKey", "type": "password", "title": "Upstream password" },
|
|
54183
|
+
{
|
|
54184
|
+
"key": "platformApiKey",
|
|
54185
|
+
"type": "password",
|
|
54186
|
+
"widget": "password",
|
|
54187
|
+
"title": "Platform Open API Key"
|
|
54188
|
+
}
|
|
54189
|
+
]
|
|
54190
|
+
}
|
|
54191
|
+
}
|
|
54192
|
+
\`\`\`
|
|
54193
|
+
|
|
54194
|
+
### 2. Read it in the handler
|
|
53721
54195
|
|
|
53722
|
-
## Discover, then call
|
|
53723
|
-
Never hardcode the tool list: the callable set is **reflected per tenant** and
|
|
53724
|
-
changes as plugins are exposed. Call \`listTools()\` at runtime.
|
|
53725
54196
|
\`\`\`js
|
|
54197
|
+
const fs = require("fs");
|
|
53726
54198
|
const { OpenMcpClient } = require("@axiom-lattice/open-mcp-client");
|
|
53727
|
-
// or require("/root/.agents/sdk/open-mcp-client/index.js") when provisioned there
|
|
53728
54199
|
|
|
53729
54200
|
async function main() {
|
|
53730
54201
|
const input = process.env.PLUGIN_INPUT_FILE
|
|
53731
|
-
? JSON.parse(
|
|
54202
|
+
? JSON.parse(fs.readFileSync(process.env.PLUGIN_INPUT_FILE, "utf8"))
|
|
53732
54203
|
: JSON.parse(process.env.PLUGIN_INPUT || "{}");
|
|
54204
|
+
const conn = JSON.parse(
|
|
54205
|
+
fs.readFileSync(process.env.PLUGIN_CONNECTION_FILE, "utf8"),
|
|
54206
|
+
).connection;
|
|
53733
54207
|
|
|
53734
|
-
const client = OpenMcpClient
|
|
54208
|
+
const client = new OpenMcpClient({
|
|
54209
|
+
url: process.env.API_GATEWAY_URL,
|
|
54210
|
+
token: conn.platformApiKey,
|
|
54211
|
+
});
|
|
53735
54212
|
const tools = await client.listTools(); // exactly what this handler may call
|
|
53736
54213
|
const kb = await client.callTool("kb_search", { collection: "docs", query: input.q });
|
|
53737
54214
|
|
|
@@ -53742,29 +54219,165 @@ main().catch((err) => {
|
|
|
53742
54219
|
});
|
|
53743
54220
|
\`\`\`
|
|
53744
54221
|
|
|
53745
|
-
|
|
53746
|
-
|
|
53747
|
-
-
|
|
53748
|
-
|
|
54222
|
+
### 3. Ask a human to configure the connection
|
|
54223
|
+
|
|
54224
|
+
- Call \`list_connections { type }\`.
|
|
54225
|
+
- If the connection or key is missing, use \`ask_user_to_clarify\`: only a human can
|
|
54226
|
+
create the platform API key and fill the connection.
|
|
54227
|
+
- Never claim PTC works until a real \`connectionKey\` test passes.
|
|
54228
|
+
|
|
54229
|
+
### 4. Test with a real connection
|
|
54230
|
+
|
|
54231
|
+
\`\`\`json
|
|
54232
|
+
{
|
|
54233
|
+
"type": "my-plugin",
|
|
54234
|
+
"target": {
|
|
54235
|
+
"kind": "tool",
|
|
54236
|
+
"name": "my_tool",
|
|
54237
|
+
"input": {},
|
|
54238
|
+
"connectionKey": "prod"
|
|
54239
|
+
}
|
|
54240
|
+
}
|
|
54241
|
+
\`\`\`
|
|
54242
|
+
|
|
54243
|
+
Use \`manage_plugin test\`. Test output redacts secret values; assert on functional
|
|
54244
|
+
output (e.g. the tool result), not on echoing the key.
|
|
54245
|
+
|
|
54246
|
+
## Checklist
|
|
54247
|
+
|
|
54248
|
+
- [ ] \`connection.fields\` declares a password field for the platform key.
|
|
54249
|
+
- [ ] handler reads \`PLUGIN_CONNECTION_FILE.connection.<field>\`.
|
|
54250
|
+
- [ ] handler constructs \`OpenMcpClient\` with \`API_GATEWAY_URL\` + that field.
|
|
54251
|
+
- [ ] \`listTools()\` is called before \`callTool()\`.
|
|
54252
|
+
- [ ] the handler never logs or writes the platform key.
|
|
54253
|
+
- [ ] the key is least-privilege and does not grant the plugin's own domain.
|
|
54254
|
+
- [ ] a probe (if needed) was used to discover tool names and args.
|
|
54255
|
+
- [ ] resident handlers do not cache the client/key.
|
|
54256
|
+
- [ ] a human configured the connection + platform key.
|
|
54257
|
+
- [ ] \`manage_plugin test\` passed with a real \`connectionKey\`.
|
|
54258
|
+
|
|
54259
|
+
## Discover, then call
|
|
54260
|
+
|
|
54261
|
+
Never hardcode the tool list: the callable set is the key's grants. Call
|
|
54262
|
+
\`listTools()\` at runtime. Tool names are \`{domain}_{action}\` (e.g. \`kb_search\`,
|
|
54263
|
+
\`task_manage_task\`); args follow the tool's \`inputSchema\`. Return the result
|
|
54264
|
+
through the normal handler envelope (\`{ ok: true, result }\`) \u2014 see
|
|
54265
|
+
\`sandbox-plugins-handlers\`.
|
|
54266
|
+
|
|
54267
|
+
## Key design
|
|
54268
|
+
|
|
54269
|
+
- Grant only the domains/actions the handler actually calls.
|
|
54270
|
+
- Do **not** grant the plugin's own domain; that enables self-recursion.
|
|
54271
|
+
- Use \`selector.connections\` when the handler must be restricted to specific
|
|
54272
|
+
connections.
|
|
54273
|
+
- Use a separate key per plugin/connection so rotate/disable and audit stay
|
|
54274
|
+
attributable.
|
|
54275
|
+
- Put the key in the connection as a password field; never log or write it.
|
|
54276
|
+
- The key's project/tenant is the project/tenant the downstream tools operate in.
|
|
54277
|
+
It may intentionally differ from the plugin's project; confirm with the human
|
|
54278
|
+
only if the plugin's semantics depend on it.
|
|
53749
54279
|
|
|
53750
54280
|
## What the handler may call
|
|
53751
|
-
|
|
53752
|
-
**
|
|
53753
|
-
|
|
53754
|
-
|
|
54281
|
+
|
|
54282
|
+
The API key carries **only its own grants**. Unlike agent \`code_eval\`, a plugin
|
|
54283
|
+
key does not automatically get the sandbox/\`kb\` defaults; grant those explicitly
|
|
54284
|
+
on the key if the handler needs them. A call outside the key's grants fails
|
|
54285
|
+
(tool-not-found or \`GRANT_DENIED\`); retrying will not help. Give the plugin a
|
|
54286
|
+
least-privilege key.
|
|
54287
|
+
|
|
54288
|
+
Resource selection is not the handler's job: Open MCP tools are already bound to
|
|
54289
|
+
their resources. A key can pin connections via \`selector.connections\` in the key
|
|
54290
|
+
editor; the handler only passes tool arguments.
|
|
54291
|
+
|
|
54292
|
+
## Multiple connections
|
|
54293
|
+
|
|
54294
|
+
- \`PLUGIN_CONNECTION_FILE\` contains \`connection\` (first selected) and
|
|
54295
|
+
\`connections\` (all selected).
|
|
54296
|
+
- If the tool schema has \`connectionKey\`, pick that entry:
|
|
54297
|
+
\`\`\`js
|
|
54298
|
+
const data = JSON.parse(fs.readFileSync(process.env.PLUGIN_CONNECTION_FILE, "utf8"));
|
|
54299
|
+
const conn = (data.connections ?? []).find((c) => c.key === input.connectionKey)?.config
|
|
54300
|
+
?? data.connection;
|
|
54301
|
+
\`\`\`
|
|
54302
|
+
- Without a \`connectionKey\` input and with multiple connections, use
|
|
54303
|
+
\`connection\` (the first) or fail with a clear message; do not silently mix
|
|
54304
|
+
credentials.
|
|
54305
|
+
- Keep the platform key consistent across the connections the handler uses.
|
|
54306
|
+
|
|
54307
|
+
## Resident deployment
|
|
54308
|
+
|
|
54309
|
+
Resident handlers run in a long-lived service, but each \`/invoke\` receives the
|
|
54310
|
+
current connection config and \`apiGatewayUrl\`. Do **not** cache
|
|
54311
|
+
\`OpenMcpClient\`, the key, or \`API_GATEWAY_URL\` at module scope; read
|
|
54312
|
+
\`PLUGIN_CONNECTION_FILE\` per invocation so rotate/disable and connection changes
|
|
54313
|
+
apply.
|
|
53755
54314
|
|
|
53756
54315
|
## Client availability
|
|
53757
|
-
|
|
53758
|
-
sandbox
|
|
53759
|
-
|
|
53760
|
-
|
|
54316
|
+
|
|
54317
|
+
The sandbox image provides \`@axiom-lattice/open-mcp-client\`; use the bare module.
|
|
54318
|
+
|
|
54319
|
+
## Error handling
|
|
54320
|
+
|
|
54321
|
+
| Symptom | Meaning | Action |
|
|
54322
|
+
|---|---|---|
|
|
54323
|
+
| \`token is required\` / \`OpenMcpConfigError\` | connection has no platform key | ask the human to configure it |
|
|
54324
|
+
| \`OpenMcpAuthError\` / 401 | key disabled, rotated, or invalid | ask the human to rotate/configure |
|
|
54325
|
+
| tool-not-found | key has no such domain/action | do not retry; fix the key grant |
|
|
54326
|
+
| \`GRANT_DENIED\` | key lacks the action | do not retry; fix the key grant |
|
|
54327
|
+
| \`CONNECTION_NOT_ALLOWED\` / \`RESOURCE_DENIED\` | \`selector.connections\` mismatch | use an allowed connection or fix the key scope |
|
|
54328
|
+
|
|
54329
|
+
## Migrating from \`OPEN_API_TOKEN\`
|
|
54330
|
+
|
|
54331
|
+
If the plugin previously called \`OpenMcpClient.fromEnv()\`:
|
|
54332
|
+
|
|
54333
|
+
1. Add a password field to \`connection.fields\` (for example \`platformApiKey\`).
|
|
54334
|
+
2. Read \`PLUGIN_CONNECTION_FILE.connection.platformApiKey\`.
|
|
54335
|
+
3. Construct \`new OpenMcpClient({ url: process.env.API_GATEWAY_URL, token: ... })\`.
|
|
54336
|
+
4. Ask the human to fill the connection key.
|
|
54337
|
+
5. Re-test with \`manage_plugin test\` + \`connectionKey\`.
|
|
54338
|
+
|
|
54339
|
+
\`fromEnv()\` still works for agent \`code_eval\`, not for plugin handlers.
|
|
53761
54340
|
|
|
53762
54341
|
## Limits
|
|
53763
|
-
|
|
53764
|
-
|
|
54342
|
+
|
|
54343
|
+
- Plugin handlers do not mint tokens; they reuse the connection key. Agent
|
|
54344
|
+
\`code_eval\` keeps the depth-limited short token path.
|
|
53765
54345
|
- Only call what \`listTools()\` returns, and handle a missing tool gracefully.
|
|
53766
54346
|
`,
|
|
53767
|
-
resources: {
|
|
54347
|
+
resources: {
|
|
54348
|
+
"templates/probe-handler.js": {
|
|
54349
|
+
content: `const fs = require("fs");
|
|
54350
|
+
const { OpenMcpClient } = require("@axiom-lattice/open-mcp-client");
|
|
54351
|
+
|
|
54352
|
+
async function main() {
|
|
54353
|
+
const conn = JSON.parse(
|
|
54354
|
+
fs.readFileSync(process.env.PLUGIN_CONNECTION_FILE, "utf8"),
|
|
54355
|
+
).connection;
|
|
54356
|
+
const client = new OpenMcpClient({
|
|
54357
|
+
url: process.env.API_GATEWAY_URL,
|
|
54358
|
+
token: conn.platformApiKey,
|
|
54359
|
+
timeoutMs: 5000,
|
|
54360
|
+
});
|
|
54361
|
+
const tools = await client.listTools();
|
|
54362
|
+
process.stdout.write(JSON.stringify({
|
|
54363
|
+
ok: true,
|
|
54364
|
+
result: tools.map((tool) => ({
|
|
54365
|
+
name: tool.name,
|
|
54366
|
+
description: tool.description,
|
|
54367
|
+
inputSchema: tool.inputSchema,
|
|
54368
|
+
})),
|
|
54369
|
+
}));
|
|
54370
|
+
}
|
|
54371
|
+
|
|
54372
|
+
main().catch((err) => {
|
|
54373
|
+
process.stdout.write(JSON.stringify({
|
|
54374
|
+
ok: false,
|
|
54375
|
+
error: String(err && err.message ? err.message : err),
|
|
54376
|
+
}));
|
|
54377
|
+
});
|
|
54378
|
+
`
|
|
54379
|
+
}
|
|
54380
|
+
}
|
|
53768
54381
|
},
|
|
53769
54382
|
"sandbox-plugins-handlers": {
|
|
53770
54383
|
version: "1.0.0",
|
|
@@ -54010,8 +54623,17 @@ Follow the authoring skill's "Decide first" steps to confirm the goal
|
|
|
54010
54623
|
(inputs/outputs). If the UI class applies, load "sandbox-plugins-ui" before
|
|
54011
54624
|
authoring it. If the tool must be callable by external MCP clients via an API key,
|
|
54012
54625
|
load "sandbox-plugins-expose" and follow it (\`expose: true\` + key grants).
|
|
54013
|
-
If
|
|
54014
|
-
"
|
|
54626
|
+
If the human asks to publish or share the plugin's UI as a link, load
|
|
54627
|
+
"app-share-publishing" and follow it; never publish proactively. If a tool must
|
|
54628
|
+
call the platform's own tools/agents from its handler, load
|
|
54629
|
+
"sandbox-plugins-consume-open" and follow its checklist: declare a password field
|
|
54630
|
+
in connection.fields, read it from PLUGIN_CONNECTION_FILE, construct OpenMcpClient
|
|
54631
|
+
with API_GATEWAY_URL + that field, and never use
|
|
54632
|
+
OPEN_API_TOKEN/OpenMcpClient.fromEnv() in a plugin handler. A human must
|
|
54633
|
+
configure the connection before PTC can be verified. If the key's capabilities
|
|
54634
|
+
are unknown, author a probe handler first and run manage_plugin test with a real
|
|
54635
|
+
connectionKey; use the returned listTools names/inputSchema before writing the
|
|
54636
|
+
real handler.
|
|
54015
54637
|
|
|
54016
54638
|
Design first, and iterate on it before you build \u2014 the design is a conversation, not
|
|
54017
54639
|
a one-shot. Use the \`widget\` middleware to present it (a decision surface, not a showcase):
|
|
@@ -54257,15 +54879,6 @@ function tenantIdFrom(exeConfig) {
|
|
|
54257
54879
|
const c = exeConfig;
|
|
54258
54880
|
return c?.configurable?.runConfig?.tenantId ?? "default";
|
|
54259
54881
|
}
|
|
54260
|
-
function collectSecretValues(connection, fields) {
|
|
54261
|
-
if (!connection) return [];
|
|
54262
|
-
const values = [];
|
|
54263
|
-
for (const field of fields) {
|
|
54264
|
-
const value = connection[field];
|
|
54265
|
-
if (typeof value === "string" && value.length > 0) values.push(value);
|
|
54266
|
-
}
|
|
54267
|
-
return values;
|
|
54268
|
-
}
|
|
54269
54882
|
function errorText(err) {
|
|
54270
54883
|
return err instanceof Error ? err.message : String(err);
|
|
54271
54884
|
}
|
|
@@ -54278,25 +54891,6 @@ function deploymentUnavailable(action) {
|
|
|
54278
54891
|
function deploymentsResult(payload) {
|
|
54279
54892
|
return appendUiFence(JSON.stringify(payload), SANDBOX_PLUGINS_UI_REF);
|
|
54280
54893
|
}
|
|
54281
|
-
function redactString(value, secrets) {
|
|
54282
|
-
let out = value;
|
|
54283
|
-
for (const secret of secrets) out = out.split(secret).join("[redacted]");
|
|
54284
|
-
return out;
|
|
54285
|
-
}
|
|
54286
|
-
function redactSecretValues(payload, secrets) {
|
|
54287
|
-
if (secrets.length === 0) return payload;
|
|
54288
|
-
const walk = (node) => {
|
|
54289
|
-
if (typeof node === "string") return redactString(node, secrets);
|
|
54290
|
-
if (Array.isArray(node)) return node.map(walk);
|
|
54291
|
-
if (node !== null && typeof node === "object") {
|
|
54292
|
-
const out = {};
|
|
54293
|
-
for (const [key5, value] of Object.entries(node)) out[key5] = walk(value);
|
|
54294
|
-
return out;
|
|
54295
|
-
}
|
|
54296
|
-
return node;
|
|
54297
|
-
};
|
|
54298
|
-
return walk(payload);
|
|
54299
|
-
}
|
|
54300
54894
|
var managePluginSchema = import_zod74.z.object({
|
|
54301
54895
|
action: import_zod74.z.enum([
|
|
54302
54896
|
"list",
|
|
@@ -54365,6 +54959,14 @@ var sandboxPluginsPlugin = {
|
|
|
54365
54959
|
enabled: true,
|
|
54366
54960
|
config: {}
|
|
54367
54961
|
},
|
|
54962
|
+
{
|
|
54963
|
+
id: "app-share",
|
|
54964
|
+
type: "app-share",
|
|
54965
|
+
name: "App Share",
|
|
54966
|
+
description: "Publish a plugin UI tool as a public/password share link",
|
|
54967
|
+
enabled: true,
|
|
54968
|
+
config: {}
|
|
54969
|
+
},
|
|
54368
54970
|
{
|
|
54369
54971
|
id: "skill",
|
|
54370
54972
|
type: "skill",
|
|
@@ -54577,14 +55179,9 @@ var sandboxPluginsPlugin = {
|
|
|
54577
55179
|
}
|
|
54578
55180
|
}
|
|
54579
55181
|
const executor = catalog2.getExecutor();
|
|
54580
|
-
const
|
|
54581
|
-
|
|
54582
|
-
|
|
54583
|
-
parsedManifest = JSON.parse(manifestContent);
|
|
54584
|
-
} catch {
|
|
54585
|
-
return JSON.stringify({ error: "plugin.json is not valid JSON" });
|
|
54586
|
-
}
|
|
54587
|
-
const toolDef = (parsedManifest.tools ?? []).find((t) => t.name === input.target?.name);
|
|
55182
|
+
const manifest = await catalog2.getValidatedManifest(tenantId2, input.type);
|
|
55183
|
+
if (!manifest) return `plugin "${input.type}" not found`;
|
|
55184
|
+
const toolDef = (manifest.tools ?? []).find((t) => t.name === input.target?.name);
|
|
54588
55185
|
if (!toolDef) return `tool "${input.target.name ?? ""}" not found`;
|
|
54589
55186
|
const runConfig = {
|
|
54590
55187
|
...sandboxRunConfigFrom(exeConfig),
|
|
@@ -54596,38 +55193,55 @@ var sandboxPluginsPlugin = {
|
|
|
54596
55193
|
runConfig
|
|
54597
55194
|
) : {};
|
|
54598
55195
|
const secrets = collectSecretValues(resolved.connection, connectionSecretFields(plugin));
|
|
55196
|
+
const ui = toolDef.ui;
|
|
55197
|
+
if (!ui?.resource) {
|
|
55198
|
+
try {
|
|
55199
|
+
const result = await executor.invoke({
|
|
55200
|
+
manifest,
|
|
55201
|
+
handler: toolDef.handler,
|
|
55202
|
+
input: input.target.input ?? null,
|
|
55203
|
+
connection: resolved.connection,
|
|
55204
|
+
connections: resolved.connections,
|
|
55205
|
+
context: { tenantId: tenantId2, pluginType: input.type, tool: toolDef.name },
|
|
55206
|
+
runConfig
|
|
55207
|
+
});
|
|
55208
|
+
return handlerResultText(redactSecretValues(result, secrets));
|
|
55209
|
+
} catch (err) {
|
|
55210
|
+
return JSON.stringify(redactSecretValues({ ok: false, error: errorText(err) }, secrets));
|
|
55211
|
+
}
|
|
55212
|
+
}
|
|
55213
|
+
const uiRefWithoutScope = {
|
|
55214
|
+
kind: "plugin",
|
|
55215
|
+
pluginType: input.type,
|
|
55216
|
+
resource: ui.resource,
|
|
55217
|
+
displayMode: ui.displayMode ?? "inline",
|
|
55218
|
+
toolName: toolDef.name
|
|
55219
|
+
};
|
|
54599
55220
|
try {
|
|
54600
|
-
const
|
|
54601
|
-
|
|
54602
|
-
|
|
55221
|
+
const run = await runSandboxPluginUiTool({
|
|
55222
|
+
tenantId: tenantId2,
|
|
55223
|
+
pluginType: input.type,
|
|
55224
|
+
toolName: toolDef.name,
|
|
54603
55225
|
input: input.target.input ?? null,
|
|
55226
|
+
runConfig,
|
|
54604
55227
|
connection: resolved.connection,
|
|
54605
55228
|
connections: resolved.connections,
|
|
54606
|
-
|
|
54607
|
-
|
|
55229
|
+
connectionKey: resolved.connections?.[0]?.key,
|
|
55230
|
+
catalog: catalog2,
|
|
55231
|
+
manifest,
|
|
55232
|
+
redact: (value) => redactSecretValues(value, secrets)
|
|
54608
55233
|
});
|
|
54609
|
-
|
|
54610
|
-
const ui = toolDef.ui;
|
|
54611
|
-
if (!ui?.resource) return text;
|
|
54612
|
-
const scope = result.ok && ui?.resource ? signMcpUiScope({
|
|
54613
|
-
tid: runConfig.tenantId || tenantId2,
|
|
54614
|
-
thid: runConfig.threadId,
|
|
54615
|
-
aid: runConfig.assistantId,
|
|
54616
|
-
wid: runConfig.workspaceId,
|
|
54617
|
-
pid: runConfig.projectId,
|
|
54618
|
-
plugin: input.type,
|
|
54619
|
-
resource: ui.resource,
|
|
54620
|
-
ck: resolved.connections?.[0]?.key
|
|
54621
|
-
}) : void 0;
|
|
54622
|
-
const uiRef = {
|
|
54623
|
-
kind: "plugin",
|
|
54624
|
-
pluginType: input.type,
|
|
54625
|
-
resource: ui.resource,
|
|
54626
|
-
displayMode: ui.displayMode ?? "inline",
|
|
54627
|
-
...scope ? { scope } : {}
|
|
54628
|
-
};
|
|
54629
|
-
return appendUiFence(text, uiRef);
|
|
55234
|
+
return appendUiFence(run.text, run.uiRef);
|
|
54630
55235
|
} catch (err) {
|
|
55236
|
+
if (err instanceof ToolNotFoundError) {
|
|
55237
|
+
return `tool "${input.target.name ?? ""}" not found`;
|
|
55238
|
+
}
|
|
55239
|
+
if (err instanceof PluginUiToolExecutionError) {
|
|
55240
|
+
return appendUiFence(err.text ?? "", uiRefWithoutScope);
|
|
55241
|
+
}
|
|
55242
|
+
if (err instanceof ScopeUnavailableError) {
|
|
55243
|
+
return appendUiFence(err.text ?? "", uiRefWithoutScope);
|
|
55244
|
+
}
|
|
54631
55245
|
return JSON.stringify(redactSecretValues({ ok: false, error: errorText(err) }, secrets));
|
|
54632
55246
|
}
|
|
54633
55247
|
}
|
|
@@ -54706,9 +55320,371 @@ var sandboxPluginsPlugin = {
|
|
|
54706
55320
|
})
|
|
54707
55321
|
};
|
|
54708
55322
|
|
|
54709
|
-
// src/middlewares/
|
|
55323
|
+
// src/middlewares/appShareMiddleware.ts
|
|
54710
55324
|
var import_langchain87 = require("langchain");
|
|
54711
55325
|
var import_zod75 = require("zod");
|
|
55326
|
+
|
|
55327
|
+
// src/middlewares/appShareUi.ts
|
|
55328
|
+
var SHARE_CARD_UI_RESOURCE = "ui://app-share/share-card";
|
|
55329
|
+
var SHARE_CARD_APP_HTML = `<!doctype html>
|
|
55330
|
+
<html lang="en">
|
|
55331
|
+
<head>
|
|
55332
|
+
<meta charset="utf-8" />
|
|
55333
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
55334
|
+
<title>Shared app</title>
|
|
55335
|
+
<style>
|
|
55336
|
+
:root { color-scheme: light dark; }
|
|
55337
|
+
body { margin: 0; padding: 12px 14px; font: 13px/1.45 Inter, -apple-system, "Segoe UI", sans-serif; }
|
|
55338
|
+
.title { font-weight: 600; font-size: 14px; }
|
|
55339
|
+
.tag { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: #eef2ff; color: #4338ca; }
|
|
55340
|
+
.url { margin: 8px 0; padding: 7px 9px; border: 1px solid #e5e7eb; border-radius: 8px; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
|
|
55341
|
+
.pwd { margin: 6px 0; color: #6b7280; font-size: 12px; }
|
|
55342
|
+
.actions { display: flex; gap: 8px; margin-top: 8px; }
|
|
55343
|
+
button { border: 1px solid #d1d5db; background: #fff; border-radius: 8px; padding: 5px 10px; font: inherit; cursor: pointer; }
|
|
55344
|
+
button.primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
|
|
55345
|
+
.warn { margin-top: 8px; color: #b45309; font-size: 11px; }
|
|
55346
|
+
</style>
|
|
55347
|
+
</head>
|
|
55348
|
+
<body>
|
|
55349
|
+
<div id="root"><p>Loading\u2026</p></div>
|
|
55350
|
+
<script>
|
|
55351
|
+
(function () {
|
|
55352
|
+
var root = document.getElementById("root");
|
|
55353
|
+
function post(message) { window.parent.postMessage(message, "*"); }
|
|
55354
|
+
function notify(method, params) { post({ jsonrpc: "2.0", method: method, params: params }); }
|
|
55355
|
+
var nextId = 1;
|
|
55356
|
+
function rpc(method, params) {
|
|
55357
|
+
var id = nextId++;
|
|
55358
|
+
return new Promise(function (resolve, reject) {
|
|
55359
|
+
function onMessage(event) {
|
|
55360
|
+
var data = event.data;
|
|
55361
|
+
if (!data || data.id !== id) return;
|
|
55362
|
+
window.removeEventListener("message", onMessage);
|
|
55363
|
+
if (data.error) reject(new Error((data.error && data.error.message) || "rpc error"));
|
|
55364
|
+
else resolve(data.result);
|
|
55365
|
+
}
|
|
55366
|
+
window.addEventListener("message", onMessage);
|
|
55367
|
+
post({ jsonrpc: "2.0", id: id, method: method, params: params });
|
|
55368
|
+
});
|
|
55369
|
+
}
|
|
55370
|
+
function sendSize() {
|
|
55371
|
+
notify("ui/notifications/size-changed", {
|
|
55372
|
+
width: Math.ceil(document.documentElement.scrollWidth || document.body.scrollWidth),
|
|
55373
|
+
height: Math.ceil(document.documentElement.scrollHeight || document.body.scrollHeight),
|
|
55374
|
+
});
|
|
55375
|
+
}
|
|
55376
|
+
var ZH = (navigator.language || "").toLowerCase().indexOf("zh") === 0;
|
|
55377
|
+
var COPY = ZH
|
|
55378
|
+
? { copy: "\u590D\u5236", open: "\u6253\u5F00\u5E94\u7528", password: "\u53E3\u4EE4\uFF1A", unavailable: "\u5206\u4EAB\u6570\u636E\u4E0D\u53EF\u7528\u3002", failed: "\u521D\u59CB\u5316\u5931\u8D25\uFF1A" }
|
|
55379
|
+
: { copy: "Copy", open: "Open app", password: "Password: ", unavailable: "Share data unavailable.", failed: "Failed to initialize: " };
|
|
55380
|
+
function esc(v) {
|
|
55381
|
+
return String(v == null ? "" : v).replace(/[&<>"']/g, function (ch) {
|
|
55382
|
+
return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[ch];
|
|
55383
|
+
});
|
|
55384
|
+
}
|
|
55385
|
+
function readResult(params) {
|
|
55386
|
+
if (!params || typeof params !== "object") return null;
|
|
55387
|
+
if (params.structuredContent && typeof params.structuredContent === "object") return params.structuredContent;
|
|
55388
|
+
var content = params.content;
|
|
55389
|
+
var text = content && content[0] && typeof content[0].text === "string" ? content[0].text : "";
|
|
55390
|
+
if (!text) return null;
|
|
55391
|
+
try { return JSON.parse(text); } catch (err) { return null; }
|
|
55392
|
+
}
|
|
55393
|
+
function render(data) {
|
|
55394
|
+
if (!data) { root.innerHTML = "<p>" + COPY.unavailable + "</p>"; sendSize(); return; }
|
|
55395
|
+
var html = '<div class="title">' + esc(data.title || "Shared app") + "</div>";
|
|
55396
|
+
html += '<span class="tag">' + esc(data.visibility) + "</span>";
|
|
55397
|
+
html += '<div class="url">' + esc(data.url || data.path) + "</div>";
|
|
55398
|
+
if (data.password) html += '<div class="pwd">' + COPY.password + esc(data.password) + "</div>";
|
|
55399
|
+
html += '<div class="actions">';
|
|
55400
|
+
html += '<button id="copy">' + COPY.copy + "</button>";
|
|
55401
|
+
html += '<button class="primary" id="open">' + COPY.open + "</button>";
|
|
55402
|
+
html += "</div>";
|
|
55403
|
+
if (data.warnings && data.warnings.length) {
|
|
55404
|
+
html += '<div class="warn">' + esc(data.warnings.join(" ")) + "</div>";
|
|
55405
|
+
}
|
|
55406
|
+
root.innerHTML = html;
|
|
55407
|
+
document.getElementById("copy").onclick = function () {
|
|
55408
|
+
rpc("ui/copy-link", {
|
|
55409
|
+
title: data.title,
|
|
55410
|
+
url: data.url || data.path,
|
|
55411
|
+
password: data.password,
|
|
55412
|
+
passwordLabel: COPY.password
|
|
55413
|
+
}).catch(function () {});
|
|
55414
|
+
};
|
|
55415
|
+
document.getElementById("open").onclick = function () {
|
|
55416
|
+
rpc("ui/open-link", { url: data.url || data.path }).catch(function () {});
|
|
55417
|
+
};
|
|
55418
|
+
sendSize();
|
|
55419
|
+
}
|
|
55420
|
+
window.addEventListener("message", function (event) {
|
|
55421
|
+
var data = event.data;
|
|
55422
|
+
if (!data || typeof data !== "object" || typeof data.method !== "string") return;
|
|
55423
|
+
if (data.method === "ui/notifications/tool-result") render(readResult(data.params));
|
|
55424
|
+
});
|
|
55425
|
+
if (typeof ResizeObserver !== "undefined") new ResizeObserver(sendSize).observe(document.documentElement);
|
|
55426
|
+
else window.addEventListener("resize", sendSize);
|
|
55427
|
+
rpc("ui/initialize", {
|
|
55428
|
+
protocolVersion: "2025-06-18",
|
|
55429
|
+
capabilities: {},
|
|
55430
|
+
clientInfo: { name: "app-share-card", version: "1.0.0" },
|
|
55431
|
+
appCapabilities: { availableDisplayModes: ["inline"] },
|
|
55432
|
+
}).then(function () {
|
|
55433
|
+
notify("ui/notifications/initialized", {});
|
|
55434
|
+
sendSize();
|
|
55435
|
+
}).catch(function (err) {
|
|
55436
|
+
root.innerHTML = "<p>" + COPY.failed + esc((err && err.message) || err) + "</p>";
|
|
55437
|
+
sendSize();
|
|
55438
|
+
});
|
|
55439
|
+
})();
|
|
55440
|
+
</script>
|
|
55441
|
+
</body>
|
|
55442
|
+
</html>`;
|
|
55443
|
+
|
|
55444
|
+
// src/middlewares/appShareSkill.ts
|
|
55445
|
+
var APP_SHARE_PUBLISHING_SKILL = `---
|
|
55446
|
+
name: app-share-publishing
|
|
55447
|
+
description: Use when a user explicitly asks to publish or share a tenant plugin's MCP App UI as a public or password-protected link, or asks for a shareable app URL.
|
|
55448
|
+
---
|
|
55449
|
+
|
|
55450
|
+
# Publishing a plugin UI as a share link
|
|
55451
|
+
|
|
55452
|
+
\`share_app\` publishes a UI-bearing tool from a tenant sandbox plugin. It does
|
|
55453
|
+
not publish agents, files, or MCP-server UIs.
|
|
55454
|
+
|
|
55455
|
+
## Preconditions
|
|
55456
|
+
- The plugin is authored, and \`manage_plugin validate\` / \`reload\` / \`test\` passes.
|
|
55457
|
+
- The target tool declares \`ui.resource\`.
|
|
55458
|
+
- A connection is configured if the plugin needs one. Pass \`connectionKey\` when
|
|
55459
|
+
the plugin has multiple connections.
|
|
55460
|
+
- Publish only when the human explicitly asks. Never share proactively.
|
|
55461
|
+
|
|
55462
|
+
## Ask before creating
|
|
55463
|
+
- visibility: \`public\` or \`password\` (required; there is no default).
|
|
55464
|
+
- password when visibility is \`password\`.
|
|
55465
|
+
- Optional: title, \`expiresInMinutes\`, \`maxAccess\`.
|
|
55466
|
+
- Confirm the initial \`input\`; it is stored and re-run on every open. Never put
|
|
55467
|
+
credentials or other secrets in \`input\`.
|
|
55468
|
+
|
|
55469
|
+
## Call
|
|
55470
|
+
\`\`\`json
|
|
55471
|
+
{
|
|
55472
|
+
"pluginType": "<plugin type>",
|
|
55473
|
+
"toolName": "<UI-bearing tool>",
|
|
55474
|
+
"input": {},
|
|
55475
|
+
"connectionKey": "<selected connection, when needed>",
|
|
55476
|
+
"visibility": "public | password",
|
|
55477
|
+
"password": "<required for password>",
|
|
55478
|
+
"title": "<optional>",
|
|
55479
|
+
"expiresInMinutes": 1440,
|
|
55480
|
+
"maxAccess": 100
|
|
55481
|
+
}
|
|
55482
|
+
\`\`\`
|
|
55483
|
+
|
|
55484
|
+
The result contains the relative link (\`path\`), token, title, visibility,
|
|
55485
|
+
optional password, and warnings, plus an inline share card.
|
|
55486
|
+
|
|
55487
|
+
## What the link does
|
|
55488
|
+
- Every open re-runs the saved tool with the saved input; results are not
|
|
55489
|
+
persisted. Tools with write side effects run on every open.
|
|
55490
|
+
- A public share delegates the selected plugin connection: anyone with the link
|
|
55491
|
+
can call any tool in that plugin through the gateway. Warn the human before
|
|
55492
|
+
creating it.
|
|
55493
|
+
- A password share requires the password cookie. Links can be listed and revoked
|
|
55494
|
+
on the Shares page.
|
|
55495
|
+
|
|
55496
|
+
## Errors
|
|
55497
|
+
- \`TOOL_NOT_UI\` / \`TOOL_NOT_FOUND\`: choose a UI-bearing tool from the plugin.
|
|
55498
|
+
- \`CONNECTION_REQUIRED\`: ask the human to configure the plugin connection first.
|
|
55499
|
+
- \`CONNECTION_AMBIGUOUS\`: ask which \`connectionKey\` to use.
|
|
55500
|
+
- \`CONNECTION_NOT_FOUND\`: verify the requested connection key.
|
|
55501
|
+
- \`SCOPE_UNAVAILABLE\`: the deployment cannot sign MCP UI scopes.
|
|
55502
|
+
- \`PAYLOAD_TOO_LARGE\`: reduce the stored input.
|
|
55503
|
+
- \`USER_REQUIRED\`: invoke from an authenticated user context.
|
|
55504
|
+
|
|
55505
|
+
## Do not
|
|
55506
|
+
- Do not use \`share_app\` for non-UI tools or file shares.
|
|
55507
|
+
- Do not claim the shared view is a frozen snapshot; it re-executes.
|
|
55508
|
+
- Do not include credentials or secrets in \`input\`.
|
|
55509
|
+
`;
|
|
55510
|
+
|
|
55511
|
+
// src/middlewares/appShareMiddleware.ts
|
|
55512
|
+
var SHARE_CARD_UI_REF = {
|
|
55513
|
+
kind: "plugin",
|
|
55514
|
+
pluginType: "app-share",
|
|
55515
|
+
resource: SHARE_CARD_UI_RESOURCE,
|
|
55516
|
+
displayMode: "inline",
|
|
55517
|
+
title: "Shared app"
|
|
55518
|
+
};
|
|
55519
|
+
function rawRunConfigFrom(exeConfig) {
|
|
55520
|
+
const config = exeConfig;
|
|
55521
|
+
return config?.configurable?.runConfig ?? {};
|
|
55522
|
+
}
|
|
55523
|
+
var shareAppSchema = import_zod75.z.object({
|
|
55524
|
+
pluginType: import_zod75.z.string().min(1),
|
|
55525
|
+
toolName: import_zod75.z.string().min(1),
|
|
55526
|
+
input: import_zod75.z.record(import_zod75.z.unknown()).optional(),
|
|
55527
|
+
connectionKey: import_zod75.z.string().min(1).optional(),
|
|
55528
|
+
title: import_zod75.z.string().min(1).max(256).optional(),
|
|
55529
|
+
visibility: import_zod75.z.enum(["public", "password"]),
|
|
55530
|
+
password: import_zod75.z.string().min(1).max(1024).optional(),
|
|
55531
|
+
expiresInMinutes: import_zod75.z.number().int().positive().max(525600).optional(),
|
|
55532
|
+
maxAccess: import_zod75.z.number().int().positive().optional()
|
|
55533
|
+
});
|
|
55534
|
+
async function shareAppHandler(input, exeConfig) {
|
|
55535
|
+
const runConfig = { ...sandboxRunConfigFrom(exeConfig) };
|
|
55536
|
+
const rawRunConfig = rawRunConfigFrom(exeConfig);
|
|
55537
|
+
const tenantId2 = runConfig.tenantId;
|
|
55538
|
+
const createdBy = typeof rawRunConfig.user_id === "string" && rawRunConfig.user_id.length > 0 ? rawRunConfig.user_id : typeof rawRunConfig.userId === "string" && rawRunConfig.userId.length > 0 ? rawRunConfig.userId : "";
|
|
55539
|
+
if (!tenantId2 || !createdBy) return JSON.stringify({ error: "USER_REQUIRED" });
|
|
55540
|
+
if (input.visibility === "password" && !input.password) {
|
|
55541
|
+
return JSON.stringify({ error: "INVALID_REQUEST" });
|
|
55542
|
+
}
|
|
55543
|
+
if (input.visibility === "public" && input.password) {
|
|
55544
|
+
return JSON.stringify({ error: "INVALID_REQUEST" });
|
|
55545
|
+
}
|
|
55546
|
+
let store2;
|
|
55547
|
+
try {
|
|
55548
|
+
store2 = getStoreLattice("default", "sharedResource").store;
|
|
55549
|
+
} catch {
|
|
55550
|
+
return JSON.stringify({ error: "SHARE_STORE_UNAVAILABLE" });
|
|
55551
|
+
}
|
|
55552
|
+
const catalog2 = getSandboxPluginCatalog();
|
|
55553
|
+
const loaded = await catalog2.ensureLoaded(tenantId2);
|
|
55554
|
+
const plugin = loaded.plugins.find((p) => p.meta.type === input.pluginType);
|
|
55555
|
+
if (!plugin) return JSON.stringify({ error: "TOOL_NOT_FOUND" });
|
|
55556
|
+
const manifest = await catalog2.getValidatedManifest(tenantId2, input.pluginType);
|
|
55557
|
+
const toolDef = manifest?.tools?.find((t) => t.name === input.toolName);
|
|
55558
|
+
if (!toolDef) return JSON.stringify({ error: "TOOL_NOT_FOUND" });
|
|
55559
|
+
if (!toolDef.ui?.resource) return JSON.stringify({ error: "TOOL_NOT_UI" });
|
|
55560
|
+
const connections = await resolvePluginConnections(
|
|
55561
|
+
input.pluginType,
|
|
55562
|
+
input.connectionKey ? { connections: [input.connectionKey] } : { connectAll: true },
|
|
55563
|
+
{ tenantId: tenantId2 }
|
|
55564
|
+
);
|
|
55565
|
+
if (input.connectionKey && connections.length === 0) {
|
|
55566
|
+
return JSON.stringify({ error: "CONNECTION_NOT_FOUND" });
|
|
55567
|
+
}
|
|
55568
|
+
if (!input.connectionKey && plugin.connection && connections.length === 0) {
|
|
55569
|
+
return JSON.stringify({ error: "CONNECTION_REQUIRED" });
|
|
55570
|
+
}
|
|
55571
|
+
if (!input.connectionKey && plugin.connection && connections.length > 1) {
|
|
55572
|
+
return JSON.stringify({
|
|
55573
|
+
error: "CONNECTION_AMBIGUOUS",
|
|
55574
|
+
keys: connections.map((c) => c.key)
|
|
55575
|
+
});
|
|
55576
|
+
}
|
|
55577
|
+
const connectionKey = input.connectionKey ?? connections[0]?.key;
|
|
55578
|
+
const scope = signMcpUiScope({
|
|
55579
|
+
tid: tenantId2,
|
|
55580
|
+
thid: runConfig.threadId,
|
|
55581
|
+
aid: runConfig.assistantId,
|
|
55582
|
+
wid: runConfig.workspaceId,
|
|
55583
|
+
pid: runConfig.projectId,
|
|
55584
|
+
plugin: input.pluginType,
|
|
55585
|
+
resource: toolDef.ui.resource,
|
|
55586
|
+
ck: connectionKey
|
|
55587
|
+
});
|
|
55588
|
+
if (!scope) return JSON.stringify({ error: "SCOPE_UNAVAILABLE" });
|
|
55589
|
+
let payload;
|
|
55590
|
+
try {
|
|
55591
|
+
payload = createMcpAppSharePayload({
|
|
55592
|
+
tenantId: tenantId2,
|
|
55593
|
+
createdBy,
|
|
55594
|
+
workspaceId: runConfig.workspaceId ?? "",
|
|
55595
|
+
projectId: runConfig.projectId ?? "",
|
|
55596
|
+
app: {
|
|
55597
|
+
kind: "plugin",
|
|
55598
|
+
pluginType: input.pluginType,
|
|
55599
|
+
resource: toolDef.ui.resource,
|
|
55600
|
+
scope,
|
|
55601
|
+
toolName: input.toolName,
|
|
55602
|
+
displayMode: toolDef.ui.displayMode ?? "inline",
|
|
55603
|
+
toolInput: input.input ?? {}
|
|
55604
|
+
},
|
|
55605
|
+
title: input.title,
|
|
55606
|
+
visibility: input.visibility,
|
|
55607
|
+
password: input.password,
|
|
55608
|
+
expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4) : void 0,
|
|
55609
|
+
maxAccess: input.maxAccess
|
|
55610
|
+
});
|
|
55611
|
+
} catch (error) {
|
|
55612
|
+
if (error instanceof SharePayloadError) {
|
|
55613
|
+
return JSON.stringify({ error: error.code });
|
|
55614
|
+
}
|
|
55615
|
+
throw error;
|
|
55616
|
+
}
|
|
55617
|
+
try {
|
|
55618
|
+
await store2.create(payload);
|
|
55619
|
+
} catch {
|
|
55620
|
+
return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
|
|
55621
|
+
}
|
|
55622
|
+
console.info(JSON.stringify({
|
|
55623
|
+
event: "share.created",
|
|
55624
|
+
tenantId: tenantId2,
|
|
55625
|
+
userId: createdBy,
|
|
55626
|
+
kind: "mcpApp",
|
|
55627
|
+
appKind: "plugin",
|
|
55628
|
+
pluginType: input.pluginType,
|
|
55629
|
+
tool: input.toolName,
|
|
55630
|
+
visibility: input.visibility,
|
|
55631
|
+
tokenPrefix: payload.token.slice(0, 8)
|
|
55632
|
+
}));
|
|
55633
|
+
const path8 = `/s/${payload.token}`;
|
|
55634
|
+
const envBase = process.env.AXIOM_PUBLIC_BASE_URL?.replace(/\/$/, "");
|
|
55635
|
+
const result = {
|
|
55636
|
+
path: path8,
|
|
55637
|
+
...envBase ? { url: `${envBase}${path8}` } : {},
|
|
55638
|
+
token: payload.token,
|
|
55639
|
+
title: payload.title ?? "Shared app",
|
|
55640
|
+
visibility: payload.visibility,
|
|
55641
|
+
...input.visibility === "password" && input.password ? { password: input.password } : {},
|
|
55642
|
+
...input.visibility === "public" ? { warnings: ["public share delegates the selected plugin connection"] } : {}
|
|
55643
|
+
};
|
|
55644
|
+
const resultText = JSON.stringify(result).replace(/`/g, "\\u0060");
|
|
55645
|
+
return appendUiFence(resultText, SHARE_CARD_UI_REF);
|
|
55646
|
+
}
|
|
55647
|
+
var appSharePlugin = {
|
|
55648
|
+
meta: {
|
|
55649
|
+
type: "app-share",
|
|
55650
|
+
name: "App Share",
|
|
55651
|
+
description: "Publish a sandbox plugin MCP App as a share link.",
|
|
55652
|
+
version: "1.0.0",
|
|
55653
|
+
tools: [{
|
|
55654
|
+
name: "share_app",
|
|
55655
|
+
description: "Publish a UI-bearing sandbox plugin tool as a share link. Only call when the user explicitly asks to publish or share an app. visibility is required (public or password). A public share delegates the selected plugin connection capability, so warn the user. The initial arguments are stored and the tool is re-run on every link open; the tool result is never persisted.",
|
|
55656
|
+
ui: { resource: SHARE_CARD_UI_RESOURCE, displayMode: "inline" }
|
|
55657
|
+
}],
|
|
55658
|
+
uiResources: {
|
|
55659
|
+
[SHARE_CARD_UI_RESOURCE]: { html: SHARE_CARD_APP_HTML }
|
|
55660
|
+
},
|
|
55661
|
+
configSchema: { type: "object", properties: {} },
|
|
55662
|
+
defaultConfig: {}
|
|
55663
|
+
},
|
|
55664
|
+
skills: {
|
|
55665
|
+
"app-share-publishing": {
|
|
55666
|
+
version: "1.0.0",
|
|
55667
|
+
content: APP_SHARE_PUBLISHING_SKILL
|
|
55668
|
+
}
|
|
55669
|
+
},
|
|
55670
|
+
middleware: () => ({
|
|
55671
|
+
name: "appShareMiddleware",
|
|
55672
|
+
tools: [
|
|
55673
|
+
(0, import_langchain87.tool)(
|
|
55674
|
+
async (input, exeConfig) => shareAppHandler(input, exeConfig),
|
|
55675
|
+
{
|
|
55676
|
+
name: "share_app",
|
|
55677
|
+
description: "Publish a UI-bearing sandbox plugin tool as a share link. Only call when the user explicitly asks to publish or share an app. visibility is required: ask the user whether the link should be public or password-protected. A public share delegates the selected plugin connection capability, so warn the user. The initial arguments are stored and the tool is re-run on every link open; the tool result is never persisted.",
|
|
55678
|
+
schema: shareAppSchema
|
|
55679
|
+
}
|
|
55680
|
+
)
|
|
55681
|
+
]
|
|
55682
|
+
})
|
|
55683
|
+
};
|
|
55684
|
+
|
|
55685
|
+
// src/middlewares/longTermStoreMiddleware.ts
|
|
55686
|
+
var import_langchain88 = require("langchain");
|
|
55687
|
+
var import_zod76 = require("zod");
|
|
54712
55688
|
var import_protocols49 = require("@axiom-lattice/protocols");
|
|
54713
55689
|
var DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
|
|
54714
55690
|
var DEFAULT_SEARCH_LIMIT = 10;
|
|
@@ -54804,34 +55780,34 @@ function store() {
|
|
|
54804
55780
|
return void 0;
|
|
54805
55781
|
}
|
|
54806
55782
|
}
|
|
54807
|
-
var namespaceSchema =
|
|
55783
|
+
var namespaceSchema = import_zod76.z.array(import_zod76.z.string()).optional().describe(
|
|
54808
55784
|
"Optional relative namespace segments for organization (appended to the scoped prefix)."
|
|
54809
55785
|
);
|
|
54810
|
-
var keySchema =
|
|
54811
|
-
var valueSchema =
|
|
54812
|
-
var putSchema =
|
|
55786
|
+
var keySchema = import_zod76.z.string().min(1).describe("Stable item key within the resolved namespace.");
|
|
55787
|
+
var valueSchema = import_zod76.z.record(import_zod76.z.unknown()).describe("JSON object value to persist.");
|
|
55788
|
+
var putSchema = import_zod76.z.object({
|
|
54813
55789
|
key: keySchema,
|
|
54814
55790
|
value: valueSchema,
|
|
54815
55791
|
namespace: namespaceSchema,
|
|
54816
|
-
ttlMinutes:
|
|
55792
|
+
ttlMinutes: import_zod76.z.number().positive().optional().describe("Optional TTL in minutes; omit to use the plugin default.")
|
|
54817
55793
|
});
|
|
54818
|
-
var getSchema =
|
|
55794
|
+
var getSchema = import_zod76.z.object({
|
|
54819
55795
|
key: keySchema,
|
|
54820
55796
|
namespace: namespaceSchema
|
|
54821
55797
|
});
|
|
54822
|
-
var searchSchema2 =
|
|
54823
|
-
query:
|
|
54824
|
-
filter:
|
|
55798
|
+
var searchSchema2 = import_zod76.z.object({
|
|
55799
|
+
query: import_zod76.z.string().optional().describe("Case-insensitive substring match over serialized values."),
|
|
55800
|
+
filter: import_zod76.z.record(import_zod76.z.unknown()).optional().describe("Deep partial-equality filter over the value object."),
|
|
54825
55801
|
namespace: namespaceSchema,
|
|
54826
|
-
limit:
|
|
55802
|
+
limit: import_zod76.z.number().int().min(1).max(MAX_SEARCH_LIMIT).optional()
|
|
54827
55803
|
});
|
|
54828
|
-
var deleteSchema =
|
|
55804
|
+
var deleteSchema = import_zod76.z.object({
|
|
54829
55805
|
key: keySchema,
|
|
54830
55806
|
namespace: namespaceSchema
|
|
54831
55807
|
});
|
|
54832
|
-
var namespacesSchema =
|
|
55808
|
+
var namespacesSchema = import_zod76.z.object({
|
|
54833
55809
|
namespace: namespaceSchema,
|
|
54834
|
-
limit:
|
|
55810
|
+
limit: import_zod76.z.number().int().min(1).max(MAX_SEARCH_LIMIT).optional()
|
|
54835
55811
|
});
|
|
54836
55812
|
var STORE_SKILL_HINT = "Load long_term_store-usage for namespace/TTL guidance.";
|
|
54837
55813
|
var STORE_DESCRIPTION = [
|
|
@@ -54950,7 +55926,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
54950
55926
|
}
|
|
54951
55927
|
return resolveNamespace(config, scope, relative4);
|
|
54952
55928
|
};
|
|
54953
|
-
const putTool = (0,
|
|
55929
|
+
const putTool = (0, import_langchain88.tool)(
|
|
54954
55930
|
async (input, exeConfig) => {
|
|
54955
55931
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
54956
55932
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -54981,7 +55957,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
54981
55957
|
schema: putSchema
|
|
54982
55958
|
}
|
|
54983
55959
|
);
|
|
54984
|
-
const getTool = (0,
|
|
55960
|
+
const getTool = (0, import_langchain88.tool)(
|
|
54985
55961
|
async (input, exeConfig) => {
|
|
54986
55962
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
54987
55963
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -55005,7 +55981,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
55005
55981
|
schema: getSchema
|
|
55006
55982
|
}
|
|
55007
55983
|
);
|
|
55008
|
-
const searchTool = (0,
|
|
55984
|
+
const searchTool = (0, import_langchain88.tool)(
|
|
55009
55985
|
async (input, exeConfig) => {
|
|
55010
55986
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
55011
55987
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -55032,7 +56008,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
55032
56008
|
schema: searchSchema2
|
|
55033
56009
|
}
|
|
55034
56010
|
);
|
|
55035
|
-
const deleteTool = (0,
|
|
56011
|
+
const deleteTool = (0, import_langchain88.tool)(
|
|
55036
56012
|
async (input, exeConfig) => {
|
|
55037
56013
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
55038
56014
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -55056,7 +56032,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
55056
56032
|
schema: deleteSchema
|
|
55057
56033
|
}
|
|
55058
56034
|
);
|
|
55059
|
-
const namespacesTool = (0,
|
|
56035
|
+
const namespacesTool = (0, import_langchain88.tool)(
|
|
55060
56036
|
async (input, exeConfig) => {
|
|
55061
56037
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
55062
56038
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -55084,7 +56060,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
55084
56060
|
schema: namespacesSchema
|
|
55085
56061
|
}
|
|
55086
56062
|
);
|
|
55087
|
-
return (0,
|
|
56063
|
+
return (0, import_langchain88.createMiddleware)({
|
|
55088
56064
|
name: "LongTermStoreMiddleware",
|
|
55089
56065
|
tools: readOnly ? [getTool, searchTool, namespacesTool] : [putTool, getTool, searchTool, deleteTool, namespacesTool]
|
|
55090
56066
|
});
|
|
@@ -55176,6 +56152,7 @@ var BUILTIN_PLUGINS = [
|
|
|
55176
56152
|
documentParserPlugin,
|
|
55177
56153
|
projectRoomPlugin,
|
|
55178
56154
|
sandboxPluginsPlugin,
|
|
56155
|
+
appSharePlugin,
|
|
55179
56156
|
longTermStorePlugin
|
|
55180
56157
|
];
|
|
55181
56158
|
function registerBuiltinPlugins() {
|
|
@@ -55610,8 +56587,11 @@ async function runHandler(body) {
|
|
|
55610
56587
|
var needsTempDir = inputIsLarge || connectionPayload !== null;
|
|
55611
56588
|
var tempDir = null;
|
|
55612
56589
|
var env = Object.assign({}, process.env);
|
|
55613
|
-
// Handler processes must never inherit scope signing secrets
|
|
56590
|
+
// Handler processes must never inherit scope signing secrets or the
|
|
56591
|
+
// agent-only short-lived Open token.
|
|
55614
56592
|
delete env.MCP_UI_SCOPE_SECRET;
|
|
56593
|
+
delete env.OPEN_API_TOKEN;
|
|
56594
|
+
delete env.API_GATEWAY_URL;
|
|
55615
56595
|
try {
|
|
55616
56596
|
if (needsTempDir) {
|
|
55617
56597
|
tempDir = path.join(os.tmpdir(), "plugin-run-" + Date.now() + "-" + Math.random().toString(36).slice(2));
|
|
@@ -55630,6 +56610,9 @@ async function runHandler(body) {
|
|
|
55630
56610
|
env.PLUGIN_CONNECTION_FILE = connectionFile;
|
|
55631
56611
|
}
|
|
55632
56612
|
env.PLUGIN_CONTEXT = encodeInput(body.context || {});
|
|
56613
|
+
if (typeof body.apiGatewayUrl === "string" && body.apiGatewayUrl) {
|
|
56614
|
+
env.API_GATEWAY_URL = body.apiGatewayUrl;
|
|
56615
|
+
}
|
|
55633
56616
|
var handlerTimeoutMs = resolveHandlerTimeoutMs(body.timeoutMs);
|
|
55634
56617
|
var exec = await runNode(handlerPath, pluginDir, env, handlerTimeoutMs);
|
|
55635
56618
|
if (exec.error) {
|
|
@@ -56188,6 +57171,7 @@ registerBuiltinPlugins();
|
|
|
56188
57171
|
DelegationService,
|
|
56189
57172
|
DependencyResolver,
|
|
56190
57173
|
DuplicateProjectRoomMessageIdempotencyKeyError,
|
|
57174
|
+
DuplicateShareTokenError,
|
|
56191
57175
|
E2BInstance,
|
|
56192
57176
|
E2BProvider,
|
|
56193
57177
|
EMPTY_CONTENT_WARNING,
|
|
@@ -56223,6 +57207,7 @@ registerBuiltinPlugins();
|
|
|
56223
57207
|
InMemoryProjectRoomMessageStore,
|
|
56224
57208
|
InMemoryProjectRoomReadStateStore,
|
|
56225
57209
|
InMemoryProjectRoomStore,
|
|
57210
|
+
InMemorySharedResourceStore,
|
|
56226
57211
|
InMemoryStore,
|
|
56227
57212
|
InMemoryTaskStore,
|
|
56228
57213
|
InMemoryTaskWorkItemStore,
|
|
@@ -56279,6 +57264,7 @@ registerBuiltinPlugins();
|
|
|
56279
57264
|
ProjectBotMembershipIdConflictError,
|
|
56280
57265
|
ProjectMutationMutex,
|
|
56281
57266
|
ProjectRoomMessageIdConflictError,
|
|
57267
|
+
ProjectRoomMessageNotifier,
|
|
56282
57268
|
ProjectTaskAdmissionNotifier,
|
|
56283
57269
|
ProjectTaskOwnerPolicy,
|
|
56284
57270
|
ProjectTaskOwnerPolicyError,
|
|
@@ -56295,6 +57281,8 @@ registerBuiltinPlugins();
|
|
|
56295
57281
|
SAFE_PATH_COMPONENT,
|
|
56296
57282
|
SANDBOX_OPEN_GATEWAY_URL_ENV,
|
|
56297
57283
|
SANDBOX_OPEN_TOKEN_ENV,
|
|
57284
|
+
SHARE_CARD_APP_HTML,
|
|
57285
|
+
SHARE_CARD_UI_RESOURCE,
|
|
56298
57286
|
STTModelLattice,
|
|
56299
57287
|
STTModelLatticeManager,
|
|
56300
57288
|
SUMMARIZATION_TRIGGER_RATIO,
|
|
@@ -56304,6 +57292,7 @@ registerBuiltinPlugins();
|
|
|
56304
57292
|
SandboxSkillStore,
|
|
56305
57293
|
ScheduleLatticeManager,
|
|
56306
57294
|
SemanticMetricsClient,
|
|
57295
|
+
SharePayloadError,
|
|
56307
57296
|
SharedChunkBuffer,
|
|
56308
57297
|
SimpleMemoryVectorStore,
|
|
56309
57298
|
SkillLatticeManager,
|
|
@@ -56335,6 +57324,7 @@ registerBuiltinPlugins();
|
|
|
56335
57324
|
abortWorkflowRun,
|
|
56336
57325
|
agentInstanceManager,
|
|
56337
57326
|
agentLatticeManager,
|
|
57327
|
+
appSharePlugin,
|
|
56338
57328
|
appendReconciliationWarning,
|
|
56339
57329
|
appendUiFence,
|
|
56340
57330
|
assertQueueSources,
|
|
@@ -56387,6 +57377,7 @@ registerBuiltinPlugins();
|
|
|
56387
57377
|
createListTablesSqlTool,
|
|
56388
57378
|
createLongTermStoreMiddleware,
|
|
56389
57379
|
createMapNode,
|
|
57380
|
+
createMcpAppSharePayload,
|
|
56390
57381
|
createModelSelectorMiddleware,
|
|
56391
57382
|
createNodeHandler,
|
|
56392
57383
|
createProjectRoomMiddleware,
|
|
@@ -56480,6 +57471,7 @@ registerBuiltinPlugins();
|
|
|
56480
57471
|
getSTTModelLattice,
|
|
56481
57472
|
getSandBoxManager,
|
|
56482
57473
|
getSandboxOpenCredential,
|
|
57474
|
+
getSandboxOpenGatewayUrl,
|
|
56483
57475
|
getSandboxPluginCatalog,
|
|
56484
57476
|
getScheduleLattice,
|
|
56485
57477
|
getStoreLattice,
|
|
@@ -56553,6 +57545,7 @@ registerBuiltinPlugins();
|
|
|
56553
57545
|
prepareTaskDispatch,
|
|
56554
57546
|
probeThreadRunOwner,
|
|
56555
57547
|
projectMutationMutex,
|
|
57548
|
+
projectRoomMessageNotifier,
|
|
56556
57549
|
projectRoomPlugin,
|
|
56557
57550
|
projectTaskAdmissionNotifier,
|
|
56558
57551
|
provisionSandboxOpenClient,
|
|
@@ -56579,6 +57572,7 @@ registerBuiltinPlugins();
|
|
|
56579
57572
|
registerQueueLattice,
|
|
56580
57573
|
registerSTTModelLattice,
|
|
56581
57574
|
registerSandboxOpenCredentialProvider,
|
|
57575
|
+
registerSandboxOpenGatewayUrlProvider,
|
|
56582
57576
|
registerSandboxProviderType,
|
|
56583
57577
|
registerScheduleLattice,
|
|
56584
57578
|
registerStoreLattice,
|
|
@@ -56623,6 +57617,7 @@ registerBuiltinPlugins();
|
|
|
56623
57617
|
setPluginDeploymentService,
|
|
56624
57618
|
setRunCancelHeartbeatFallbackObserver,
|
|
56625
57619
|
setSandboxPluginCatalog,
|
|
57620
|
+
shareAppSchema,
|
|
56626
57621
|
signMcpUiScope,
|
|
56627
57622
|
skillLatticeManager,
|
|
56628
57623
|
sqlDatabaseManager,
|