@axiom-lattice/core 10.0.5 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +499 -11
- package/dist/index.d.ts +499 -11
- package/dist/index.js +1764 -344
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1661 -255
- 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,8 @@ __export(index_exports, {
|
|
|
1693
1694
|
InMemoryProjectRoomMessageStore: () => InMemoryProjectRoomMessageStore,
|
|
1694
1695
|
InMemoryProjectRoomReadStateStore: () => InMemoryProjectRoomReadStateStore,
|
|
1695
1696
|
InMemoryProjectRoomStore: () => InMemoryProjectRoomStore,
|
|
1697
|
+
InMemoryProjectStore: () => InMemoryProjectStore,
|
|
1698
|
+
InMemorySharedResourceStore: () => InMemorySharedResourceStore,
|
|
1696
1699
|
InMemoryStore: () => InMemoryStore,
|
|
1697
1700
|
InMemoryTaskStore: () => InMemoryTaskStore,
|
|
1698
1701
|
InMemoryTaskWorkItemStore: () => InMemoryTaskWorkItemStore,
|
|
@@ -1749,6 +1752,7 @@ __export(index_exports, {
|
|
|
1749
1752
|
ProjectBotMembershipIdConflictError: () => ProjectBotMembershipIdConflictError,
|
|
1750
1753
|
ProjectMutationMutex: () => ProjectMutationMutex,
|
|
1751
1754
|
ProjectRoomMessageIdConflictError: () => ProjectRoomMessageIdConflictError,
|
|
1755
|
+
ProjectRoomMessageNotifier: () => ProjectRoomMessageNotifier,
|
|
1752
1756
|
ProjectTaskAdmissionNotifier: () => ProjectTaskAdmissionNotifier,
|
|
1753
1757
|
ProjectTaskOwnerPolicy: () => ProjectTaskOwnerPolicy,
|
|
1754
1758
|
ProjectTaskOwnerPolicyError: () => ProjectTaskOwnerPolicyError,
|
|
@@ -1765,6 +1769,8 @@ __export(index_exports, {
|
|
|
1765
1769
|
SAFE_PATH_COMPONENT: () => SAFE_PATH_COMPONENT,
|
|
1766
1770
|
SANDBOX_OPEN_GATEWAY_URL_ENV: () => SANDBOX_OPEN_GATEWAY_URL_ENV,
|
|
1767
1771
|
SANDBOX_OPEN_TOKEN_ENV: () => SANDBOX_OPEN_TOKEN_ENV,
|
|
1772
|
+
SHARE_CARD_APP_HTML: () => SHARE_CARD_APP_HTML,
|
|
1773
|
+
SHARE_CARD_UI_RESOURCE: () => SHARE_CARD_UI_RESOURCE,
|
|
1768
1774
|
STTModelLattice: () => STTModelLattice,
|
|
1769
1775
|
STTModelLatticeManager: () => STTModelLatticeManager,
|
|
1770
1776
|
SUMMARIZATION_TRIGGER_RATIO: () => SUMMARIZATION_TRIGGER_RATIO,
|
|
@@ -1774,6 +1780,7 @@ __export(index_exports, {
|
|
|
1774
1780
|
SandboxSkillStore: () => SandboxSkillStore,
|
|
1775
1781
|
ScheduleLatticeManager: () => ScheduleLatticeManager,
|
|
1776
1782
|
SemanticMetricsClient: () => SemanticMetricsClient,
|
|
1783
|
+
SharePayloadError: () => SharePayloadError,
|
|
1777
1784
|
SharedChunkBuffer: () => SharedChunkBuffer,
|
|
1778
1785
|
SimpleMemoryVectorStore: () => SimpleMemoryVectorStore,
|
|
1779
1786
|
SkillLatticeManager: () => SkillLatticeManager,
|
|
@@ -1805,6 +1812,7 @@ __export(index_exports, {
|
|
|
1805
1812
|
abortWorkflowRun: () => abortWorkflowRun,
|
|
1806
1813
|
agentInstanceManager: () => agentInstanceManager,
|
|
1807
1814
|
agentLatticeManager: () => agentLatticeManager,
|
|
1815
|
+
appSharePlugin: () => appSharePlugin,
|
|
1808
1816
|
appendReconciliationWarning: () => appendReconciliationWarning,
|
|
1809
1817
|
appendUiFence: () => appendUiFence,
|
|
1810
1818
|
assertQueueSources: () => assertQueueSources,
|
|
@@ -1857,6 +1865,7 @@ __export(index_exports, {
|
|
|
1857
1865
|
createListTablesSqlTool: () => createListTablesSqlTool,
|
|
1858
1866
|
createLongTermStoreMiddleware: () => createLongTermStoreMiddleware,
|
|
1859
1867
|
createMapNode: () => createMapNode,
|
|
1868
|
+
createMcpAppSharePayload: () => createMcpAppSharePayload,
|
|
1860
1869
|
createModelSelectorMiddleware: () => createModelSelectorMiddleware,
|
|
1861
1870
|
createNodeHandler: () => createNodeHandler,
|
|
1862
1871
|
createProjectRoomMiddleware: () => createProjectRoomMiddleware,
|
|
@@ -1950,6 +1959,7 @@ __export(index_exports, {
|
|
|
1950
1959
|
getSTTModelLattice: () => getSTTModelLattice,
|
|
1951
1960
|
getSandBoxManager: () => getSandBoxManager,
|
|
1952
1961
|
getSandboxOpenCredential: () => getSandboxOpenCredential,
|
|
1962
|
+
getSandboxOpenGatewayUrl: () => getSandboxOpenGatewayUrl,
|
|
1953
1963
|
getSandboxPluginCatalog: () => getSandboxPluginCatalog,
|
|
1954
1964
|
getScheduleLattice: () => getScheduleLattice,
|
|
1955
1965
|
getStoreLattice: () => getStoreLattice,
|
|
@@ -1988,6 +1998,7 @@ __export(index_exports, {
|
|
|
1988
1998
|
isValidSkillName: () => isValidSkillName,
|
|
1989
1999
|
jsonSchemaToZod: () => jsonSchemaToZod,
|
|
1990
2000
|
listCollectionEntries: () => listCollectionEntries,
|
|
2001
|
+
listMenuGroupsSchema: () => listMenuGroupsSchema,
|
|
1991
2002
|
listModelLatticesForTenant: () => listModelLatticesForTenant,
|
|
1992
2003
|
listSandboxProviderTypes: () => listSandboxProviderTypes,
|
|
1993
2004
|
listTenantPlugins: () => listTenantPlugins,
|
|
@@ -2023,11 +2034,13 @@ __export(index_exports, {
|
|
|
2023
2034
|
prepareTaskDispatch: () => prepareTaskDispatch,
|
|
2024
2035
|
probeThreadRunOwner: () => probeThreadRunOwner,
|
|
2025
2036
|
projectMutationMutex: () => projectMutationMutex,
|
|
2037
|
+
projectRoomMessageNotifier: () => projectRoomMessageNotifier,
|
|
2026
2038
|
projectRoomPlugin: () => projectRoomPlugin,
|
|
2027
2039
|
projectTaskAdmissionNotifier: () => projectTaskAdmissionNotifier,
|
|
2028
2040
|
provisionSandboxOpenClient: () => provisionSandboxOpenClient,
|
|
2029
2041
|
publishCollectionChanged: () => publishCollectionChanged,
|
|
2030
2042
|
publishPluginCatalogChanged: () => publishPluginCatalogChanged,
|
|
2043
|
+
publishTargetSchema: () => publishTargetSchema,
|
|
2031
2044
|
queueLatticeManager: () => queueLatticeManager,
|
|
2032
2045
|
readContextWindow: () => readContextWindow,
|
|
2033
2046
|
readLoopBreakerConfig: () => readLoopBreakerConfig,
|
|
@@ -2049,6 +2062,7 @@ __export(index_exports, {
|
|
|
2049
2062
|
registerQueueLattice: () => registerQueueLattice,
|
|
2050
2063
|
registerSTTModelLattice: () => registerSTTModelLattice,
|
|
2051
2064
|
registerSandboxOpenCredentialProvider: () => registerSandboxOpenCredentialProvider,
|
|
2065
|
+
registerSandboxOpenGatewayUrlProvider: () => registerSandboxOpenGatewayUrlProvider,
|
|
2052
2066
|
registerSandboxProviderType: () => registerSandboxProviderType,
|
|
2053
2067
|
registerScheduleLattice: () => registerScheduleLattice,
|
|
2054
2068
|
registerStoreLattice: () => registerStoreLattice,
|
|
@@ -13430,25 +13444,38 @@ domains your configured middleware exposes \u2014 and nothing beyond it.
|
|
|
13430
13444
|
|
|
13431
13445
|
## Client
|
|
13432
13446
|
|
|
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
|
-
\`\`\`
|
|
13447
|
+
The sandbox image provides the zero-dependency \`@axiom-lattice/open-mcp-client\`
|
|
13448
|
+
package. Use the bare module:
|
|
13446
13449
|
|
|
13447
13450
|
\`\`\`js
|
|
13448
13451
|
const { OpenMcpClient } = require("@axiom-lattice/open-mcp-client");
|
|
13449
13452
|
const client = OpenMcpClient.fromEnv(); // reads API_GATEWAY_URL + OPEN_API_TOKEN
|
|
13450
13453
|
\`\`\`
|
|
13451
13454
|
|
|
13455
|
+
## Plugin handlers
|
|
13456
|
+
|
|
13457
|
+
A sandbox plugin handler reads the platform API key from its connection:
|
|
13458
|
+
|
|
13459
|
+
\`\`\`js
|
|
13460
|
+
const conn = JSON.parse(
|
|
13461
|
+
require("fs").readFileSync(process.env.PLUGIN_CONNECTION_FILE, "utf8"),
|
|
13462
|
+
).connection;
|
|
13463
|
+
const client = new OpenMcpClient({
|
|
13464
|
+
url: process.env.API_GATEWAY_URL,
|
|
13465
|
+
token: conn.platformApiKey, // \u4F5C\u8005\u5728 connection.fields \u91CC\u5B9A\u4E49\u7684\u5B57\u6BB5
|
|
13466
|
+
});
|
|
13467
|
+
\`\`\`
|
|
13468
|
+
|
|
13469
|
+
- The platform key is a normal password field defined by the plugin author; the
|
|
13470
|
+
framework does not inject or rename it.
|
|
13471
|
+
- \`OPEN_API_TOKEN\` is only for agent \`code_eval\`; plugin handlers use the
|
|
13472
|
+
connection key directly.
|
|
13473
|
+
- Caller grants gate entry and connection selection; after that, the connection
|
|
13474
|
+
key's grants apply (service-account model).
|
|
13475
|
+
|
|
13476
|
+
Resource selection is not the handler's job: Open MCP tools are already bound to
|
|
13477
|
+
their resources. Use \`listTools()\` and \`callTool()\` only.
|
|
13478
|
+
|
|
13452
13479
|
CLI equivalents (config comes from the same env vars):
|
|
13453
13480
|
|
|
13454
13481
|
\`\`\`bash
|
|
@@ -14153,6 +14180,142 @@ var InMemoryMenuStore = class {
|
|
|
14153
14180
|
}
|
|
14154
14181
|
};
|
|
14155
14182
|
|
|
14183
|
+
// src/store_lattice/InMemorySharedResourceStore.ts
|
|
14184
|
+
var DuplicateShareTokenError = class extends Error {
|
|
14185
|
+
/**
|
|
14186
|
+
* Creates a duplicate share token error.
|
|
14187
|
+
*
|
|
14188
|
+
* @param token - Token that is already present in the store.
|
|
14189
|
+
*/
|
|
14190
|
+
constructor(token) {
|
|
14191
|
+
super(`Share token '${token}' already exists`);
|
|
14192
|
+
/** Machine-readable failure code. */
|
|
14193
|
+
this.code = "DUPLICATE_SHARE_TOKEN";
|
|
14194
|
+
this.name = "DuplicateShareTokenError";
|
|
14195
|
+
this.token = token;
|
|
14196
|
+
}
|
|
14197
|
+
};
|
|
14198
|
+
var MUTABLE_FIELDS = [
|
|
14199
|
+
"title",
|
|
14200
|
+
"expiresAt",
|
|
14201
|
+
"maxAccess",
|
|
14202
|
+
"revoked",
|
|
14203
|
+
"visibility",
|
|
14204
|
+
"passwordHash"
|
|
14205
|
+
];
|
|
14206
|
+
function cloneShareRecord(record) {
|
|
14207
|
+
return structuredClone(record);
|
|
14208
|
+
}
|
|
14209
|
+
var InMemorySharedResourceStore = class {
|
|
14210
|
+
constructor() {
|
|
14211
|
+
this.records = /* @__PURE__ */ new Map();
|
|
14212
|
+
}
|
|
14213
|
+
/**
|
|
14214
|
+
* Finds a share by its token.
|
|
14215
|
+
*
|
|
14216
|
+
* @param token - Share token to look up.
|
|
14217
|
+
* @returns An independent copy of the record, or `null` when absent.
|
|
14218
|
+
*/
|
|
14219
|
+
async findByToken(token) {
|
|
14220
|
+
const record = this.records.get(token);
|
|
14221
|
+
return record ? cloneShareRecord(record) : null;
|
|
14222
|
+
}
|
|
14223
|
+
/**
|
|
14224
|
+
* Inserts a new share record with `accessCount: 0`, `version: 1`, and the
|
|
14225
|
+
* current `createdAt`.
|
|
14226
|
+
*
|
|
14227
|
+
* @param record - Insert shape for the new share.
|
|
14228
|
+
* @returns An independent copy of the stored record.
|
|
14229
|
+
* @throws {DuplicateShareTokenError} When the token is already stored.
|
|
14230
|
+
*/
|
|
14231
|
+
async create(record) {
|
|
14232
|
+
if (this.records.has(record.token)) {
|
|
14233
|
+
throw new DuplicateShareTokenError(record.token);
|
|
14234
|
+
}
|
|
14235
|
+
const stored = {
|
|
14236
|
+
...record,
|
|
14237
|
+
accessCount: 0,
|
|
14238
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
14239
|
+
version: 1
|
|
14240
|
+
};
|
|
14241
|
+
this.records.set(stored.token, cloneShareRecord(stored));
|
|
14242
|
+
return cloneShareRecord(stored);
|
|
14243
|
+
}
|
|
14244
|
+
/**
|
|
14245
|
+
* Applies a patch to an existing share.
|
|
14246
|
+
*
|
|
14247
|
+
* Only `title`, `expiresAt`, `maxAccess`, `revoked`, `visibility`, and
|
|
14248
|
+
* `passwordHash` are applied; other keys (for example `token`, `kind`, or
|
|
14249
|
+
* `address`) are ignored. `undefined` values are treated as "no change".
|
|
14250
|
+
* Missing tokens are a no-op.
|
|
14251
|
+
*
|
|
14252
|
+
* @param token - Token of the share to update.
|
|
14253
|
+
* @param patch - Mutable fields to apply.
|
|
14254
|
+
*/
|
|
14255
|
+
async update(token, patch) {
|
|
14256
|
+
const current = this.records.get(token);
|
|
14257
|
+
if (!current) return;
|
|
14258
|
+
const updates = {};
|
|
14259
|
+
for (const field of MUTABLE_FIELDS) {
|
|
14260
|
+
if (patch[field] !== void 0) {
|
|
14261
|
+
updates[field] = patch[field];
|
|
14262
|
+
}
|
|
14263
|
+
}
|
|
14264
|
+
if (Object.keys(updates).length === 0) return;
|
|
14265
|
+
const next = cloneShareRecord(current);
|
|
14266
|
+
Object.assign(next, updates);
|
|
14267
|
+
this.records.set(token, cloneShareRecord(next));
|
|
14268
|
+
}
|
|
14269
|
+
/**
|
|
14270
|
+
* Lists a user's shares within a tenant, newest first by `createdAt`.
|
|
14271
|
+
*
|
|
14272
|
+
* @param tenantId - Tenant to scope the listing to.
|
|
14273
|
+
* @param userId - Creator (`createdBy`) to scope the listing to.
|
|
14274
|
+
* @returns Independent copies of matching records.
|
|
14275
|
+
*/
|
|
14276
|
+
async listByUser(tenantId2, userId) {
|
|
14277
|
+
return [...this.records.values()].map((record, insertionIndex) => ({ record, insertionIndex })).filter(
|
|
14278
|
+
({ record }) => record.tenantId === tenantId2 && record.createdBy === userId
|
|
14279
|
+
).sort(
|
|
14280
|
+
(left, right) => right.record.createdAt.getTime() - left.record.createdAt.getTime() || right.insertionIndex - left.insertionIndex
|
|
14281
|
+
).map(({ record }) => cloneShareRecord(record));
|
|
14282
|
+
}
|
|
14283
|
+
/**
|
|
14284
|
+
* Increments `accessCount` unconditionally when the token exists.
|
|
14285
|
+
*
|
|
14286
|
+
* Use {@link atomicIncrementAccess} when revocation, expiry, and `maxAccess`
|
|
14287
|
+
* must be enforced.
|
|
14288
|
+
*
|
|
14289
|
+
* @param token - Token of the share to count.
|
|
14290
|
+
*/
|
|
14291
|
+
async incrementAccess(token) {
|
|
14292
|
+
const current = this.records.get(token);
|
|
14293
|
+
if (current) current.accessCount += 1;
|
|
14294
|
+
}
|
|
14295
|
+
/**
|
|
14296
|
+
* Atomically increments `accessCount` only when the share is usable and the
|
|
14297
|
+
* access limit has not been reached.
|
|
14298
|
+
*
|
|
14299
|
+
* A share is considered expired when `expiresAt.getTime() <= Date.now()`,
|
|
14300
|
+
* matching PostgreSQL's `expires_at > NOW()` check.
|
|
14301
|
+
*
|
|
14302
|
+
* @param token - Token of the share to count.
|
|
14303
|
+
* @returns `true` when access was granted, `false` otherwise.
|
|
14304
|
+
*/
|
|
14305
|
+
async atomicIncrementAccess(token) {
|
|
14306
|
+
const current = this.records.get(token);
|
|
14307
|
+
if (!current || current.revoked) return false;
|
|
14308
|
+
if (current.expiresAt && current.expiresAt.getTime() <= Date.now()) {
|
|
14309
|
+
return false;
|
|
14310
|
+
}
|
|
14311
|
+
if (current.maxAccess !== null && current.accessCount >= current.maxAccess) {
|
|
14312
|
+
return false;
|
|
14313
|
+
}
|
|
14314
|
+
current.accessCount += 1;
|
|
14315
|
+
return true;
|
|
14316
|
+
}
|
|
14317
|
+
};
|
|
14318
|
+
|
|
14156
14319
|
// src/model_lattice/ModelLatticeManager.ts
|
|
14157
14320
|
var TENANT_DEFAULT_MISS_TTL_MS = 3e4;
|
|
14158
14321
|
var ModelLatticeManager = class _ModelLatticeManager extends BaseLatticeManager {
|
|
@@ -14702,11 +14865,11 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
14702
14865
|
* @param key Lattice键名
|
|
14703
14866
|
* @param tool 已有的StructuredTool实例
|
|
14704
14867
|
*/
|
|
14705
|
-
registerExistingTool(key5,
|
|
14868
|
+
registerExistingTool(key5, tool68) {
|
|
14706
14869
|
const config = {
|
|
14707
|
-
name:
|
|
14708
|
-
description:
|
|
14709
|
-
schema:
|
|
14870
|
+
name: tool68.name,
|
|
14871
|
+
description: tool68.description,
|
|
14872
|
+
schema: tool68.schema,
|
|
14710
14873
|
// StructuredTool的schema已经是Zod兼容的
|
|
14711
14874
|
needUserApprove: false
|
|
14712
14875
|
// MCP工具默认不需要用户批准
|
|
@@ -14714,7 +14877,7 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
14714
14877
|
const toolLattice = {
|
|
14715
14878
|
key: key5,
|
|
14716
14879
|
config,
|
|
14717
|
-
client:
|
|
14880
|
+
client: tool68
|
|
14718
14881
|
};
|
|
14719
14882
|
this.register(key5, toolLattice);
|
|
14720
14883
|
}
|
|
@@ -14725,14 +14888,14 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
14725
14888
|
* @param key - tool lattice key (no tenant prefix)
|
|
14726
14889
|
* @param tool - the StructuredTool client
|
|
14727
14890
|
*/
|
|
14728
|
-
registerExistingToolWithTenant(tenantId2, key5,
|
|
14891
|
+
registerExistingToolWithTenant(tenantId2, key5, tool68) {
|
|
14729
14892
|
const config = {
|
|
14730
|
-
name:
|
|
14731
|
-
description:
|
|
14732
|
-
schema:
|
|
14893
|
+
name: tool68.name,
|
|
14894
|
+
description: tool68.description,
|
|
14895
|
+
schema: tool68.schema,
|
|
14733
14896
|
needUserApprove: false
|
|
14734
14897
|
};
|
|
14735
|
-
const toolLattice = { key: key5, config, client:
|
|
14898
|
+
const toolLattice = { key: key5, config, client: tool68 };
|
|
14736
14899
|
this.registerWithTenant(tenantId2, key5, toolLattice);
|
|
14737
14900
|
}
|
|
14738
14901
|
/**
|
|
@@ -14782,8 +14945,8 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
14782
14945
|
};
|
|
14783
14946
|
var toolLatticeManager = ToolLatticeManager.getInstance();
|
|
14784
14947
|
var registerToolLattice = (key5, config, executor) => toolLatticeManager.registerLattice(key5, config, executor);
|
|
14785
|
-
var registerExistingTool = (key5,
|
|
14786
|
-
var registerExistingToolWithTenant = (tenantId2, key5,
|
|
14948
|
+
var registerExistingTool = (key5, tool68) => toolLatticeManager.registerExistingTool(key5, tool68);
|
|
14949
|
+
var registerExistingToolWithTenant = (tenantId2, key5, tool68) => toolLatticeManager.registerExistingToolWithTenant(tenantId2, key5, tool68);
|
|
14787
14950
|
var getToolLattice = (key5) => toolLatticeManager.getToolLattice(key5);
|
|
14788
14951
|
var getToolClientWithTenant = (tenantId2, key5) => toolLatticeManager.getToolClientWithTenant(tenantId2, key5);
|
|
14789
14952
|
var getToolDefinition = (key5) => toolLatticeManager.getToolDefinition(key5);
|
|
@@ -17773,6 +17936,7 @@ var SANDBOX_OPEN_GATEWAY_URL_ENV = "API_GATEWAY_URL";
|
|
|
17773
17936
|
var SANDBOX_OPEN_TOKEN_ENV = "OPEN_API_TOKEN";
|
|
17774
17937
|
var provider;
|
|
17775
17938
|
var providerErrorHandler;
|
|
17939
|
+
var gatewayUrlProvider;
|
|
17776
17940
|
function registerSandboxOpenCredentialProvider(next, options = {}) {
|
|
17777
17941
|
provider = next;
|
|
17778
17942
|
providerErrorHandler = options.onError;
|
|
@@ -17795,6 +17959,15 @@ async function getSandboxOpenCredential(context) {
|
|
|
17795
17959
|
return void 0;
|
|
17796
17960
|
}
|
|
17797
17961
|
}
|
|
17962
|
+
function registerSandboxOpenGatewayUrlProvider(next) {
|
|
17963
|
+
gatewayUrlProvider = next;
|
|
17964
|
+
return () => {
|
|
17965
|
+
if (gatewayUrlProvider === next) gatewayUrlProvider = void 0;
|
|
17966
|
+
};
|
|
17967
|
+
}
|
|
17968
|
+
function getSandboxOpenGatewayUrl() {
|
|
17969
|
+
return gatewayUrlProvider?.();
|
|
17970
|
+
}
|
|
17798
17971
|
function buildSandboxOpenEnv(credential) {
|
|
17799
17972
|
return `export ${SANDBOX_OPEN_GATEWAY_URL_ENV}=${shellSingleQuote(credential.gatewayUrl)} && export ${SANDBOX_OPEN_TOKEN_ENV}=${shellSingleQuote(credential.token)}`;
|
|
17800
17973
|
}
|
|
@@ -17804,6 +17977,7 @@ function shellSingleQuote(value) {
|
|
|
17804
17977
|
function clearSandboxOpenCredentialProviderForTests() {
|
|
17805
17978
|
provider = void 0;
|
|
17806
17979
|
providerErrorHandler = void 0;
|
|
17980
|
+
gatewayUrlProvider = void 0;
|
|
17807
17981
|
}
|
|
17808
17982
|
|
|
17809
17983
|
// src/tool_lattice/shell_exec/index.ts
|
|
@@ -19200,7 +19374,7 @@ var createReactAgentSchema = (schema6) => {
|
|
|
19200
19374
|
};
|
|
19201
19375
|
|
|
19202
19376
|
// src/agent_lattice/builders/ReActAgentGraphBuilder.ts
|
|
19203
|
-
var
|
|
19377
|
+
var import_langchain53 = require("langchain");
|
|
19204
19378
|
|
|
19205
19379
|
// src/middlewares/codeEvalMiddleware.ts
|
|
19206
19380
|
var import_langchain39 = require("langchain");
|
|
@@ -21703,8 +21877,50 @@ function ensurePatchToolCallsMiddleware(middleware) {
|
|
|
21703
21877
|
});
|
|
21704
21878
|
}
|
|
21705
21879
|
|
|
21880
|
+
// src/deep_agent_new/middleware/structuredOutputCarrier.ts
|
|
21881
|
+
var import_langchain48 = require("langchain");
|
|
21882
|
+
var STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME = "structuredOutputCarrierMiddleware";
|
|
21883
|
+
function createStructuredOutputCarrierMiddleware() {
|
|
21884
|
+
return (0, import_langchain48.createMiddleware)({
|
|
21885
|
+
name: STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME,
|
|
21886
|
+
wrapModelCall: async (request, handler) => {
|
|
21887
|
+
const result = await handler(request);
|
|
21888
|
+
if (import_langchain48.AIMessage.isInstance(result)) return result;
|
|
21889
|
+
const structured = readStructuredOutputResult(result);
|
|
21890
|
+
if (!structured) return result;
|
|
21891
|
+
const carrier = new import_langchain48.AIMessage({ content: "" });
|
|
21892
|
+
carrier.structuredResponse = structured.structuredResponse;
|
|
21893
|
+
carrier.messages = structured.messages;
|
|
21894
|
+
return carrier;
|
|
21895
|
+
}
|
|
21896
|
+
});
|
|
21897
|
+
}
|
|
21898
|
+
function ensureStructuredOutputCarrierMiddleware(middleware) {
|
|
21899
|
+
const matches = middleware.filter(
|
|
21900
|
+
(candidate) => candidate.name === STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
|
|
21901
|
+
);
|
|
21902
|
+
const withoutCarrier = middleware.filter(
|
|
21903
|
+
(candidate) => candidate.name !== STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
|
|
21904
|
+
);
|
|
21905
|
+
const carrier = matches[0] ?? createStructuredOutputCarrierMiddleware();
|
|
21906
|
+
if (matches.length === 1 && middleware[middleware.length - 1] === carrier) {
|
|
21907
|
+
return middleware;
|
|
21908
|
+
}
|
|
21909
|
+
return [...withoutCarrier, carrier];
|
|
21910
|
+
}
|
|
21911
|
+
function readStructuredOutputResult(value) {
|
|
21912
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
21913
|
+
if (!("structuredResponse" in value)) return void 0;
|
|
21914
|
+
const record = value;
|
|
21915
|
+
if (!Array.isArray(record.messages)) return void 0;
|
|
21916
|
+
return {
|
|
21917
|
+
structuredResponse: record.structuredResponse,
|
|
21918
|
+
messages: record.messages
|
|
21919
|
+
};
|
|
21920
|
+
}
|
|
21921
|
+
|
|
21706
21922
|
// src/agent_lattice/builders/commonMiddleware.ts
|
|
21707
|
-
var
|
|
21923
|
+
var import_langchain52 = require("langchain");
|
|
21708
21924
|
|
|
21709
21925
|
// src/agent_lattice/builders/CustomMiddlewareRegistry.ts
|
|
21710
21926
|
var CustomMiddlewareRegistry = class {
|
|
@@ -21795,7 +22011,7 @@ function createSandboxResolver(getSandboxFromConfig) {
|
|
|
21795
22011
|
}
|
|
21796
22012
|
|
|
21797
22013
|
// src/middlewares/evalMiddleware.ts
|
|
21798
|
-
var
|
|
22014
|
+
var import_langchain49 = require("langchain");
|
|
21799
22015
|
var import_zod47 = require("zod");
|
|
21800
22016
|
var import_uuid4 = require("uuid");
|
|
21801
22017
|
|
|
@@ -22044,7 +22260,7 @@ function createReadEvalTool() {
|
|
|
22044
22260
|
verbose: import_zod47.z.boolean().optional().describe("For get_run_results \u2014 return full per-case results. Omit for a compact summary (counts + failing cases only)."),
|
|
22045
22261
|
status: import_zod47.z.string().optional().describe("Filter: running|completed|failed|aborted")
|
|
22046
22262
|
});
|
|
22047
|
-
return (0,
|
|
22263
|
+
return (0, import_langchain49.tool)(
|
|
22048
22264
|
async (input, exeConfig) => {
|
|
22049
22265
|
const tid = tenantId(exeConfig);
|
|
22050
22266
|
if (!tid) {
|
|
@@ -22191,7 +22407,7 @@ function createManageEvalTool() {
|
|
|
22191
22407
|
value: import_zod47.z.string().optional().describe("Response to inject (defaults: \u540C\u610F / \u62D2\u7EDD; required for canned-response)")
|
|
22192
22408
|
}).optional().describe("Optional for create_case/update_case \u2014 how HITL interrupts are handled")
|
|
22193
22409
|
});
|
|
22194
|
-
return (0,
|
|
22410
|
+
return (0, import_langchain49.tool)(
|
|
22195
22411
|
async (input, exeConfig) => {
|
|
22196
22412
|
const tid = tenantId(exeConfig);
|
|
22197
22413
|
if (!tid) {
|
|
@@ -22334,7 +22550,7 @@ function createRunEvalTool() {
|
|
|
22334
22550
|
sleepMs: import_zod47.z.number().int().min(0).max(12e4).optional().describe("Optional for status \u2014 sleep this many ms BEFORE checking the run, to pace polling (e.g. 15000 \u2192 30000 \u2192 60000 \u2192 120000). Omit to check immediately."),
|
|
22335
22551
|
wait: import_zod47.z.boolean().optional().describe("Optional for start \u2014 defaults to true: block synchronously (up to ~150s) and return final results in one call. Set false to return the runId immediately and poll.")
|
|
22336
22552
|
});
|
|
22337
|
-
return (0,
|
|
22553
|
+
return (0, import_langchain49.tool)(
|
|
22338
22554
|
async (input, exeConfig) => {
|
|
22339
22555
|
const tid = tenantId(exeConfig);
|
|
22340
22556
|
if (!tid) {
|
|
@@ -22463,7 +22679,7 @@ var evalPlugin = {
|
|
|
22463
22679
|
defaultConfig: {}
|
|
22464
22680
|
},
|
|
22465
22681
|
skills: EVAL_SKILLS,
|
|
22466
|
-
middleware: () => (0,
|
|
22682
|
+
middleware: () => (0, import_langchain49.createMiddleware)({
|
|
22467
22683
|
name: "EvalMiddleware",
|
|
22468
22684
|
tools: [createReadEvalTool(), createManageEvalTool(), createRunEvalTool()]
|
|
22469
22685
|
})
|
|
@@ -22626,11 +22842,13 @@ function errorFromStdout(stdout) {
|
|
|
22626
22842
|
return text.slice(0, 4096);
|
|
22627
22843
|
}
|
|
22628
22844
|
function buildResidentPayload(args, timeoutMs) {
|
|
22845
|
+
const gatewayUrl = getSandboxOpenGatewayUrl();
|
|
22629
22846
|
return {
|
|
22630
22847
|
handler: args.handler,
|
|
22631
22848
|
input: args.input,
|
|
22632
22849
|
...args.connection === void 0 ? {} : { connection: args.connection },
|
|
22633
22850
|
...args.connections === void 0 ? {} : { connections: args.connections },
|
|
22851
|
+
...gatewayUrl === void 0 ? {} : { apiGatewayUrl: gatewayUrl },
|
|
22634
22852
|
context: args.context,
|
|
22635
22853
|
timeoutMs
|
|
22636
22854
|
};
|
|
@@ -22885,15 +23103,7 @@ var SandboxPluginExecutor = class {
|
|
|
22885
23103
|
workspaceId: args.runConfig?.workspaceId,
|
|
22886
23104
|
projectId: args.runConfig?.projectId
|
|
22887
23105
|
});
|
|
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;
|
|
23106
|
+
const gatewayUrl = getSandboxOpenGatewayUrl();
|
|
22897
23107
|
const timeoutMs = clamp(args.timeoutMs ?? DEFAULT_TIMEOUT_MS, MIN_TIMEOUT_MS, MAX_TIMEOUT_MS);
|
|
22898
23108
|
const cap = clamp(
|
|
22899
23109
|
args.maxResultBytes ?? DEFAULT_MAX_RESULT_BYTES,
|
|
@@ -22924,13 +23134,12 @@ var SandboxPluginExecutor = class {
|
|
|
22924
23134
|
envParts.push(`PLUGIN_CONNECTION_FILE=${quotePosixShellArg(connectionFile)}`);
|
|
22925
23135
|
}
|
|
22926
23136
|
envParts.push(`PLUGIN_CONTEXT=${quotePosixShellArg(encode(args.context))}`);
|
|
22927
|
-
if (
|
|
23137
|
+
if (gatewayUrl) {
|
|
22928
23138
|
envParts.push(
|
|
22929
|
-
`${SANDBOX_OPEN_GATEWAY_URL_ENV}=${quotePosixShellArg(
|
|
23139
|
+
`${SANDBOX_OPEN_GATEWAY_URL_ENV}=${quotePosixShellArg(gatewayUrl)}`
|
|
22930
23140
|
);
|
|
22931
|
-
envParts.push(`${SANDBOX_OPEN_TOKEN_ENV}=${quotePosixShellArg(openCredential.token)}`);
|
|
22932
23141
|
}
|
|
22933
|
-
const command =
|
|
23142
|
+
const command = `unset OPEN_API_TOKEN; unset API_GATEWAY_URL; ${envParts.join(" ")} node ${quotePosixShellArg(handlerAbs)}`;
|
|
22934
23143
|
const execResult = await sandbox.shell.execCommand({
|
|
22935
23144
|
command,
|
|
22936
23145
|
exec_dir: pluginDir,
|
|
@@ -23081,7 +23290,7 @@ function isSafeUiPath(path8) {
|
|
|
23081
23290
|
}
|
|
23082
23291
|
function validateSandboxPluginManifest(args) {
|
|
23083
23292
|
const diagnostics = [];
|
|
23084
|
-
const error = (code, message, pluginType,
|
|
23293
|
+
const error = (code, message, pluginType, tool68) => diagnostics.push({ level: "error", code, message, pluginType, tool: tool68 });
|
|
23085
23294
|
const raw = args.raw;
|
|
23086
23295
|
if (!isRecord7(raw)) {
|
|
23087
23296
|
error("MANIFEST_NOT_OBJECT", "manifest must be a JSON object", args.dirName);
|
|
@@ -23323,7 +23532,7 @@ function validateSandboxPluginManifest(args) {
|
|
|
23323
23532
|
}
|
|
23324
23533
|
|
|
23325
23534
|
// src/sandbox_plugin/SandboxPluginCompiler.ts
|
|
23326
|
-
var
|
|
23535
|
+
var import_langchain50 = require("langchain");
|
|
23327
23536
|
|
|
23328
23537
|
// src/connection/PluginConnectionResolver.ts
|
|
23329
23538
|
async function resolvePluginConnections(type, config, scope) {
|
|
@@ -23384,14 +23593,20 @@ function sandboxRunConfigFrom(exeConfig) {
|
|
|
23384
23593
|
// src/mcp_lattice/mcpUi.ts
|
|
23385
23594
|
var import_tools2 = require("@langchain/core/tools");
|
|
23386
23595
|
var isObj = (v) => typeof v === "object" && v !== null;
|
|
23387
|
-
function extractAppsRef(meta, serverKey) {
|
|
23596
|
+
function extractAppsRef(meta, serverKey, toolName2) {
|
|
23388
23597
|
if (!isObj(meta)) return null;
|
|
23389
23598
|
const ui = isObj(meta.ui) ? meta.ui : void 0;
|
|
23390
23599
|
const nested = ui && typeof ui.resourceUri === "string" ? ui.resourceUri : "";
|
|
23391
23600
|
const flat = typeof meta["ui/resourceUri"] === "string" ? meta["ui/resourceUri"] : "";
|
|
23392
23601
|
const uri = nested || flat;
|
|
23393
23602
|
if (!uri.startsWith("ui://")) return null;
|
|
23394
|
-
return {
|
|
23603
|
+
return {
|
|
23604
|
+
kind: "mcp",
|
|
23605
|
+
serverKey,
|
|
23606
|
+
resourceUri: uri,
|
|
23607
|
+
displayMode: "inline",
|
|
23608
|
+
...toolName2 ? { toolName: toolName2 } : {}
|
|
23609
|
+
};
|
|
23395
23610
|
}
|
|
23396
23611
|
function extractLegacyRefs(content, serverKey) {
|
|
23397
23612
|
const blocks = Array.isArray(content) ? content : [];
|
|
@@ -23634,7 +23849,7 @@ function compileSandboxPlugin(args) {
|
|
|
23634
23849
|
},
|
|
23635
23850
|
middleware: (config) => {
|
|
23636
23851
|
const tools = manifest.tools.map(
|
|
23637
|
-
(t) => (0,
|
|
23852
|
+
(t) => (0, import_langchain50.tool)(
|
|
23638
23853
|
async (input, exeConfig) => {
|
|
23639
23854
|
const runConfig = sandboxRunConfigFrom(exeConfig);
|
|
23640
23855
|
const resolution = await resolveConnection(manifest.type, config, runConfig);
|
|
@@ -23671,6 +23886,7 @@ function compileSandboxPlugin(args) {
|
|
|
23671
23886
|
pluginType: manifest.type,
|
|
23672
23887
|
resource: ui.resource,
|
|
23673
23888
|
displayMode: ui.displayMode ?? "inline",
|
|
23889
|
+
toolName: t.name,
|
|
23674
23890
|
...scope ? { scope } : {}
|
|
23675
23891
|
} : null;
|
|
23676
23892
|
return ref ? appendUiFence(text, ref) : text;
|
|
@@ -23678,7 +23894,7 @@ function compileSandboxPlugin(args) {
|
|
|
23678
23894
|
{ name: t.name, description: t.description, schema: jsonSchemaToZod(t.schema) }
|
|
23679
23895
|
)
|
|
23680
23896
|
);
|
|
23681
|
-
return (0,
|
|
23897
|
+
return (0, import_langchain50.createMiddleware)({ name: `SandboxPlugin:${manifest.type}`, tools });
|
|
23682
23898
|
},
|
|
23683
23899
|
skills: manifest.skills,
|
|
23684
23900
|
agents: manifest.agents
|
|
@@ -24443,9 +24659,9 @@ function freezeMetadata(metadata) {
|
|
|
24443
24659
|
...resourceSelector ? { resourceSelector } : {}
|
|
24444
24660
|
});
|
|
24445
24661
|
}
|
|
24446
|
-
function toolName(
|
|
24447
|
-
if (typeof
|
|
24448
|
-
return typeof
|
|
24662
|
+
function toolName(tool68) {
|
|
24663
|
+
if (typeof tool68 !== "object" || tool68 === null || !("name" in tool68)) return void 0;
|
|
24664
|
+
return typeof tool68.name === "string" ? tool68.name : void 0;
|
|
24449
24665
|
}
|
|
24450
24666
|
function schemaHasConnectionKey(schema6) {
|
|
24451
24667
|
const definition = isRecord10(schema6._def) ? schema6._def : void 0;
|
|
@@ -24453,10 +24669,10 @@ function schemaHasConnectionKey(schema6) {
|
|
|
24453
24669
|
const fields = typeof shape === "function" ? shape() : shape;
|
|
24454
24670
|
return isRecord10(fields) && Object.prototype.hasOwnProperty.call(fields, "connectionKey");
|
|
24455
24671
|
}
|
|
24456
|
-
function hasConnectionKeySchema(
|
|
24457
|
-
if (!isRecord10(
|
|
24458
|
-
if (schemaHasConnectionKey(
|
|
24459
|
-
const definition = isRecord10(
|
|
24672
|
+
function hasConnectionKeySchema(tool68) {
|
|
24673
|
+
if (!isRecord10(tool68) || !isRecord10(tool68.schema)) return false;
|
|
24674
|
+
if (schemaHasConnectionKey(tool68.schema)) return true;
|
|
24675
|
+
const definition = isRecord10(tool68.schema._def) ? tool68.schema._def : void 0;
|
|
24460
24676
|
if (Array.isArray(definition?.options) && definition.options.length > 0) {
|
|
24461
24677
|
return definition.options.every(
|
|
24462
24678
|
(option) => isRecord10(option) && schemaHasConnectionKey(option)
|
|
@@ -24511,8 +24727,8 @@ var CapabilityToolRegistry = class {
|
|
|
24511
24727
|
* @remarks Standard connection authorization is captured only for tools whose
|
|
24512
24728
|
* schema declares `connectionKey`; legacy selectors remain explicit metadata.
|
|
24513
24729
|
*/
|
|
24514
|
-
register(name, metadata,
|
|
24515
|
-
this.registerInternal(name, metadata, hasConnectionKeySchema(
|
|
24730
|
+
register(name, metadata, tool68) {
|
|
24731
|
+
this.registerInternal(name, metadata, hasConnectionKeySchema(tool68));
|
|
24516
24732
|
}
|
|
24517
24733
|
/**
|
|
24518
24734
|
* Registers all tools actually exposed by a middleware instance.
|
|
@@ -24523,13 +24739,13 @@ var CapabilityToolRegistry = class {
|
|
|
24523
24739
|
* @returns Nothing.
|
|
24524
24740
|
*/
|
|
24525
24741
|
registerMiddleware(capabilityType, middleware, resourceSelectors = {}) {
|
|
24526
|
-
for (const
|
|
24527
|
-
const name = toolName(
|
|
24742
|
+
for (const tool68 of middleware.tools ?? []) {
|
|
24743
|
+
const name = toolName(tool68);
|
|
24528
24744
|
if (name) {
|
|
24529
24745
|
this.registerInternal(name, {
|
|
24530
24746
|
capabilityType,
|
|
24531
24747
|
resourceSelector: resourceSelectors[name]
|
|
24532
|
-
}, hasConnectionKeySchema(
|
|
24748
|
+
}, hasConnectionKeySchema(tool68));
|
|
24533
24749
|
}
|
|
24534
24750
|
}
|
|
24535
24751
|
}
|
|
@@ -24555,7 +24771,7 @@ var CapabilityToolRegistry = class {
|
|
|
24555
24771
|
|
|
24556
24772
|
// src/middlewares/capabilityGuardMiddleware.ts
|
|
24557
24773
|
var import_messages4 = require("@langchain/core/messages");
|
|
24558
|
-
var
|
|
24774
|
+
var import_langchain51 = require("langchain");
|
|
24559
24775
|
function isRecord11(value) {
|
|
24560
24776
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24561
24777
|
}
|
|
@@ -24621,7 +24837,7 @@ function denialMessage(toolCall, denial) {
|
|
|
24621
24837
|
});
|
|
24622
24838
|
}
|
|
24623
24839
|
function createCapabilityGuardMiddleware(registry4) {
|
|
24624
|
-
return (0,
|
|
24840
|
+
return (0, import_langchain51.createMiddleware)({
|
|
24625
24841
|
name: "CapabilityGuardMiddleware",
|
|
24626
24842
|
wrapToolCall: async (request, handler) => {
|
|
24627
24843
|
const toolName2 = request.toolCall.name;
|
|
@@ -24868,7 +25084,7 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
|
|
|
24868
25084
|
}));
|
|
24869
25085
|
if (model) {
|
|
24870
25086
|
middlewares.push(
|
|
24871
|
-
(0,
|
|
25087
|
+
(0, import_langchain52.summarizationMiddleware)({
|
|
24872
25088
|
model,
|
|
24873
25089
|
trigger: { tokens: resolveSummarizationTriggerTokens(model) },
|
|
24874
25090
|
keep: { messages: 6 }
|
|
@@ -24990,7 +25206,7 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
|
|
|
24990
25206
|
break;
|
|
24991
25207
|
}
|
|
24992
25208
|
}
|
|
24993
|
-
return middlewares;
|
|
25209
|
+
return ensureStructuredOutputCarrierMiddleware(middlewares);
|
|
24994
25210
|
}
|
|
24995
25211
|
|
|
24996
25212
|
// src/deep_agent_new/backends/sandboxFiles.ts
|
|
@@ -25212,14 +25428,14 @@ var ReActAgentGraphBuilder = class {
|
|
|
25212
25428
|
*/
|
|
25213
25429
|
async build(agentLattice, params) {
|
|
25214
25430
|
const tools = params.tools.map((t) => {
|
|
25215
|
-
const
|
|
25216
|
-
return
|
|
25217
|
-
}).filter((
|
|
25431
|
+
const tool68 = getToolClientWithTenant(params.tenantId ?? "default", t.key);
|
|
25432
|
+
return tool68;
|
|
25433
|
+
}).filter((tool68) => tool68 !== void 0);
|
|
25218
25434
|
const stateSchema2 = createReactAgentSchema(params.stateSchema);
|
|
25219
25435
|
const middlewareConfigs = params.middleware || [];
|
|
25220
25436
|
const filesystemBackend = createFilesystemBackendFactory(middlewareConfigs);
|
|
25221
25437
|
const middlewares = await createCommonMiddlewares(middlewareConfigs, filesystemBackend, void 0, params.tenantId, params.model);
|
|
25222
|
-
return (0,
|
|
25438
|
+
return (0, import_langchain53.createAgent)({
|
|
25223
25439
|
model: params.model,
|
|
25224
25440
|
tools,
|
|
25225
25441
|
systemPrompt: params.prompt,
|
|
@@ -25233,11 +25449,11 @@ var ReActAgentGraphBuilder = class {
|
|
|
25233
25449
|
};
|
|
25234
25450
|
|
|
25235
25451
|
// src/deep_agent_new/agent.ts
|
|
25236
|
-
var
|
|
25452
|
+
var import_langchain59 = require("langchain");
|
|
25237
25453
|
|
|
25238
25454
|
// src/deep_agent_new/middleware/subagents.ts
|
|
25239
25455
|
var import_v32 = require("zod/v3");
|
|
25240
|
-
var
|
|
25456
|
+
var import_langchain55 = require("langchain");
|
|
25241
25457
|
var import_langgraph7 = require("@langchain/langgraph");
|
|
25242
25458
|
|
|
25243
25459
|
// src/agent_worker/agent_worker_graph.ts
|
|
@@ -25929,7 +26145,7 @@ function normalizeAgentInterrupts(state, threadId) {
|
|
|
25929
26145
|
}
|
|
25930
26146
|
|
|
25931
26147
|
// src/services/Agent.ts
|
|
25932
|
-
var
|
|
26148
|
+
var import_langchain54 = require("langchain");
|
|
25933
26149
|
|
|
25934
26150
|
// src/chunk_buffer_lattice/types.ts
|
|
25935
26151
|
var ThreadEndError = class extends Error {
|
|
@@ -27276,8 +27492,8 @@ function validateCapability(value, index) {
|
|
|
27276
27492
|
fieldPath: `/capabilities/${index}/allowedTools`
|
|
27277
27493
|
});
|
|
27278
27494
|
}
|
|
27279
|
-
for (const [toolIndex,
|
|
27280
|
-
if (typeof
|
|
27495
|
+
for (const [toolIndex, tool68] of capability.allowedTools.entries()) {
|
|
27496
|
+
if (typeof tool68 !== "string") {
|
|
27281
27497
|
throw new CapabilityBundleValidationError(
|
|
27282
27498
|
"CAPABILITY_BUNDLE_INVALID_CAPABILITY",
|
|
27283
27499
|
"allowedTools entries must be strings",
|
|
@@ -27291,10 +27507,10 @@ function validateCapability(value, index) {
|
|
|
27291
27507
|
fieldPath: `/capabilities/${index}/allowedTools`
|
|
27292
27508
|
});
|
|
27293
27509
|
}
|
|
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(
|
|
27510
|
+
const toolNames = new Set(plugin.meta.tools.map((tool68) => tool68.name));
|
|
27511
|
+
for (const [toolIndex, tool68] of capability.allowedTools.entries()) {
|
|
27512
|
+
if (typeof tool68 !== "string" || !toolNames.has(tool68)) {
|
|
27513
|
+
throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_UNKNOWN_TOOL", `Unknown tool '${String(tool68)}'`, {
|
|
27298
27514
|
capabilityType,
|
|
27299
27515
|
fieldPath: `/capabilities/${index}/allowedTools/${toolIndex}`
|
|
27300
27516
|
});
|
|
@@ -27777,7 +27993,7 @@ function applyStaticCeiling(capabilities, staticMiddleware) {
|
|
|
27777
27993
|
const projectTools = capability.allowedTools;
|
|
27778
27994
|
const staticTools = ceiling.allowedTools;
|
|
27779
27995
|
const effectiveStaticTools = staticTools?.length === 0 ? void 0 : staticTools;
|
|
27780
|
-
const allowedTools = projectTools === void 0 ? effectiveStaticTools : effectiveStaticTools === void 0 ? projectTools : projectTools.filter((
|
|
27996
|
+
const allowedTools = projectTools === void 0 ? effectiveStaticTools : effectiveStaticTools === void 0 ? projectTools : projectTools.filter((tool68) => effectiveStaticTools.includes(tool68));
|
|
27781
27997
|
runtime[capability.type] = structuredClone({
|
|
27782
27998
|
...capability,
|
|
27783
27999
|
config: applyStaticResourceCeiling(capability, ceiling),
|
|
@@ -28707,16 +28923,16 @@ function executeRunInputMessages(input, fallbackMessageId) {
|
|
|
28707
28923
|
};
|
|
28708
28924
|
switch (message.role) {
|
|
28709
28925
|
case "system":
|
|
28710
|
-
return new
|
|
28926
|
+
return new import_langchain54.SystemMessage(fields);
|
|
28711
28927
|
case "assistant":
|
|
28712
|
-
return new
|
|
28928
|
+
return new import_langchain54.AIMessage(fields);
|
|
28713
28929
|
case "tool":
|
|
28714
|
-
return new
|
|
28930
|
+
return new import_langchain54.ToolMessage({
|
|
28715
28931
|
...fields,
|
|
28716
28932
|
tool_call_id: typeof message.metadata?.tool_call_id === "string" ? message.metadata.tool_call_id : ""
|
|
28717
28933
|
});
|
|
28718
28934
|
case "human":
|
|
28719
|
-
return new
|
|
28935
|
+
return new import_langchain54.HumanMessage(fields);
|
|
28720
28936
|
}
|
|
28721
28937
|
});
|
|
28722
28938
|
}
|
|
@@ -28724,7 +28940,7 @@ function executeRunInputMessages(input, fallbackMessageId) {
|
|
|
28724
28940
|
throw new Error("Either input.messages or input.message must be provided");
|
|
28725
28941
|
}
|
|
28726
28942
|
const id = typeof input.id === "string" && input.id.length > 0 ? input.id : fallbackMessageId;
|
|
28727
|
-
return [new
|
|
28943
|
+
return [new import_langchain54.HumanMessage({ id, content: input.message })];
|
|
28728
28944
|
}
|
|
28729
28945
|
function statusFromSnapshot(state) {
|
|
28730
28946
|
if (!isPlainRecord2(state)) return "error" /* ERROR */;
|
|
@@ -29563,14 +29779,14 @@ var Agent = class {
|
|
|
29563
29779
|
queuedInputMessages(content) {
|
|
29564
29780
|
const messages = content.queueMessage.input.messages;
|
|
29565
29781
|
if (!Array.isArray(messages) || messages.length === 0) {
|
|
29566
|
-
return [new
|
|
29782
|
+
return [new import_langchain54.HumanMessage({ id: content.id, content: content.message })];
|
|
29567
29783
|
}
|
|
29568
29784
|
const invalid = messages.filter((message) => !isMessageContent(message.content));
|
|
29569
29785
|
if (invalid.length > 0) {
|
|
29570
29786
|
console.error(
|
|
29571
29787
|
`[Agent] Dropping ${invalid.length} queued message(s) with invalid serialized content for queued message ${content.id}; falling back to stored display content`
|
|
29572
29788
|
);
|
|
29573
|
-
return [new
|
|
29789
|
+
return [new import_langchain54.HumanMessage({ id: content.id, content: content.message })];
|
|
29574
29790
|
}
|
|
29575
29791
|
return messages.map((message) => {
|
|
29576
29792
|
const fields = {
|
|
@@ -29580,16 +29796,16 @@ var Agent = class {
|
|
|
29580
29796
|
};
|
|
29581
29797
|
switch (message.role) {
|
|
29582
29798
|
case "system":
|
|
29583
|
-
return new
|
|
29799
|
+
return new import_langchain54.SystemMessage(fields);
|
|
29584
29800
|
case "assistant":
|
|
29585
|
-
return new
|
|
29801
|
+
return new import_langchain54.AIMessage(fields);
|
|
29586
29802
|
case "tool":
|
|
29587
|
-
return new
|
|
29803
|
+
return new import_langchain54.ToolMessage({
|
|
29588
29804
|
...fields,
|
|
29589
29805
|
tool_call_id: typeof message.metadata?.tool_call_id === "string" ? message.metadata.tool_call_id : ""
|
|
29590
29806
|
});
|
|
29591
29807
|
case "human":
|
|
29592
|
-
return new
|
|
29808
|
+
return new import_langchain54.HumanMessage(fields);
|
|
29593
29809
|
}
|
|
29594
29810
|
});
|
|
29595
29811
|
}
|
|
@@ -29732,7 +29948,7 @@ var Agent = class {
|
|
|
29732
29948
|
this.validateMessageInput(queueMessage);
|
|
29733
29949
|
const input = {
|
|
29734
29950
|
...queueMessage.input,
|
|
29735
|
-
...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new
|
|
29951
|
+
...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain54.HumanMessage({ id: (0, import_uuid5.v4)(), content: queueMessage.input.message })] } : {}
|
|
29736
29952
|
};
|
|
29737
29953
|
const recoveryContext = await this.interruptedCommandExecutionContext(queueMessage.command);
|
|
29738
29954
|
const inputMessage = {
|
|
@@ -29766,7 +29982,7 @@ var Agent = class {
|
|
|
29766
29982
|
this.validateMessageInput(queueMessage);
|
|
29767
29983
|
const input = {
|
|
29768
29984
|
...queueMessage.input,
|
|
29769
|
-
...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new
|
|
29985
|
+
...!Array.isArray(queueMessage.input.messages) && typeof queueMessage.input.message === "string" ? { messages: [new import_langchain54.HumanMessage({ id: (0, import_uuid5.v4)(), content: queueMessage.input.message })] } : {}
|
|
29770
29986
|
};
|
|
29771
29987
|
const recoveryContext = options?.allowUnmanagedCommand ? await this.unmanagedCommandExecutionContext(queueMessage.command) : await this.interruptedCommandExecutionContext(queueMessage.command);
|
|
29772
29988
|
const inputMessage = { ...queueMessage, input, trusted_run_context: recoveryContext?.trustedRunContext };
|
|
@@ -31048,7 +31264,7 @@ var Agent = class {
|
|
|
31048
31264
|
async getCurrentMessages() {
|
|
31049
31265
|
const state = await this.getCurrentState();
|
|
31050
31266
|
const messages = state.values.messages || [];
|
|
31051
|
-
const filteredMessages = (0,
|
|
31267
|
+
const filteredMessages = (0, import_langchain54.filterMessages)(messages, {
|
|
31052
31268
|
includeTypes: ["ai", "human", "tool"]
|
|
31053
31269
|
//["human", "ai", "tool"],
|
|
31054
31270
|
});
|
|
@@ -31974,13 +32190,13 @@ var DEFAULT_GENERAL_PURPOSE_DESCRIPTION = "General-purpose agent for researching
|
|
|
31974
32190
|
function createGeneralPurposeAgent(options) {
|
|
31975
32191
|
const middleware = ensurePatchToolCallsMiddleware([...options.middleware]);
|
|
31976
32192
|
if (options.interruptOn) {
|
|
31977
|
-
middleware.push((0,
|
|
32193
|
+
middleware.push((0, import_langchain55.humanInTheLoopMiddleware)({ interruptOn: options.interruptOn }));
|
|
31978
32194
|
}
|
|
31979
|
-
return (0,
|
|
32195
|
+
return (0, import_langchain55.createAgent)({
|
|
31980
32196
|
model: options.model,
|
|
31981
32197
|
systemPrompt: DEFAULT_SUBAGENT_PROMPT,
|
|
31982
32198
|
tools: options.tools,
|
|
31983
|
-
middleware,
|
|
32199
|
+
middleware: ensureStructuredOutputCarrierMiddleware(middleware),
|
|
31984
32200
|
stateSchema: withRunGovernanceStateSchema(withToolCallLimitStateSchema()),
|
|
31985
32201
|
checkpointer: getCheckpointSaver("default"),
|
|
31986
32202
|
name: "general-purpose"
|
|
@@ -32143,7 +32359,7 @@ function returnCommandWithStateUpdate(result, toolCallId) {
|
|
|
32143
32359
|
update: {
|
|
32144
32360
|
...stateUpdate,
|
|
32145
32361
|
messages: [
|
|
32146
|
-
new
|
|
32362
|
+
new import_langchain55.ToolMessage({
|
|
32147
32363
|
content: lastMessage?.content || "Task Failed to complete",
|
|
32148
32364
|
tool_call_id: toolCallId,
|
|
32149
32365
|
name: "task"
|
|
@@ -32187,12 +32403,12 @@ function getSubagents(options) {
|
|
|
32187
32403
|
);
|
|
32188
32404
|
const interruptOn = agentParams.interruptOn || defaultInterruptOn;
|
|
32189
32405
|
if (interruptOn)
|
|
32190
|
-
middleware.push((0,
|
|
32191
|
-
agents[agentParams.key] = (0,
|
|
32406
|
+
middleware.push((0, import_langchain55.humanInTheLoopMiddleware)({ interruptOn }));
|
|
32407
|
+
agents[agentParams.key] = (0, import_langchain55.createAgent)({
|
|
32192
32408
|
model: agentParams.model ?? defaultModel,
|
|
32193
32409
|
systemPrompt: agentParams.systemPrompt,
|
|
32194
32410
|
tools: agentParams.tools ?? defaultTools,
|
|
32195
|
-
middleware,
|
|
32411
|
+
middleware: ensureStructuredOutputCarrierMiddleware(middleware),
|
|
32196
32412
|
stateSchema: withRunGovernanceStateSchema(withToolCallLimitStateSchema()),
|
|
32197
32413
|
checkpointer: getCheckpointSaver("default")
|
|
32198
32414
|
});
|
|
@@ -32219,7 +32435,7 @@ function createTaskTool(options) {
|
|
|
32219
32435
|
generalPurposeAgent
|
|
32220
32436
|
});
|
|
32221
32437
|
const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
|
|
32222
|
-
return (0,
|
|
32438
|
+
return (0, import_langchain55.tool)(
|
|
32223
32439
|
async (input, config) => {
|
|
32224
32440
|
const { description, subagent_type } = input;
|
|
32225
32441
|
if (input.taskId) {
|
|
@@ -32233,7 +32449,7 @@ function createTaskTool(options) {
|
|
|
32233
32449
|
return new import_langgraph7.Command({
|
|
32234
32450
|
update: {
|
|
32235
32451
|
messages: [
|
|
32236
|
-
new
|
|
32452
|
+
new import_langchain55.ToolMessage({
|
|
32237
32453
|
content: JSON.stringify({
|
|
32238
32454
|
success: false,
|
|
32239
32455
|
code: "TASK_MIDDLEWARE_REQUIRED",
|
|
@@ -32313,7 +32529,7 @@ You are executing a persistent task (ID: ${input.taskId}). Use manage_task.updat
|
|
|
32313
32529
|
return new import_langgraph7.Command({
|
|
32314
32530
|
update: {
|
|
32315
32531
|
messages: [
|
|
32316
|
-
new
|
|
32532
|
+
new import_langchain55.ToolMessage({
|
|
32317
32533
|
content: error instanceof Error ? error.message : "Task Failed to complete",
|
|
32318
32534
|
tool_call_id: config.toolCall.id,
|
|
32319
32535
|
name: "task"
|
|
@@ -32362,7 +32578,7 @@ function createSubAgentMiddleware(options) {
|
|
|
32362
32578
|
});
|
|
32363
32579
|
const allTools = [taskTool];
|
|
32364
32580
|
const effectiveSystemPrompt = systemPrompt;
|
|
32365
|
-
return (0,
|
|
32581
|
+
return (0, import_langchain55.createMiddleware)({
|
|
32366
32582
|
name: "subAgentMiddleware",
|
|
32367
32583
|
tools: allTools,
|
|
32368
32584
|
wrapModelCall: async (request, handler) => {
|
|
@@ -32382,7 +32598,7 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
|
|
|
32382
32598
|
}
|
|
32383
32599
|
|
|
32384
32600
|
// src/deep_agent_new/middleware/date.ts
|
|
32385
|
-
var
|
|
32601
|
+
var import_langchain56 = require("langchain");
|
|
32386
32602
|
var import_zod50 = require("zod");
|
|
32387
32603
|
function formatCurrentDate(timezone = "UTC") {
|
|
32388
32604
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -32411,10 +32627,10 @@ function generateDateContext(timezone = "UTC") {
|
|
|
32411
32627
|
function createDateMiddleware(options = {}) {
|
|
32412
32628
|
const timezone = options.timezone || "UTC";
|
|
32413
32629
|
const dateContext = generateDateContext(timezone);
|
|
32414
|
-
return (0,
|
|
32630
|
+
return (0, import_langchain56.createMiddleware)({
|
|
32415
32631
|
name: "DateMiddleware",
|
|
32416
32632
|
tools: [
|
|
32417
|
-
(0,
|
|
32633
|
+
(0, import_langchain56.tool)(
|
|
32418
32634
|
async () => {
|
|
32419
32635
|
const now = /* @__PURE__ */ new Date();
|
|
32420
32636
|
let validTimezone = timezone;
|
|
@@ -32510,7 +32726,7 @@ var datePlugin = {
|
|
|
32510
32726
|
};
|
|
32511
32727
|
|
|
32512
32728
|
// src/deep_agent_new/middleware/scheduler.ts
|
|
32513
|
-
var
|
|
32729
|
+
var import_langchain57 = require("langchain");
|
|
32514
32730
|
var import_zod51 = require("zod");
|
|
32515
32731
|
var import_uuid6 = require("uuid");
|
|
32516
32732
|
var import_protocols23 = require("@axiom-lattice/protocols");
|
|
@@ -32592,10 +32808,10 @@ function registerAgentAddMessageHandler() {
|
|
|
32592
32808
|
function createSchedulerMiddleware(options = {}) {
|
|
32593
32809
|
const defaultMaxRetries = options.defaultMaxRetries ?? 0;
|
|
32594
32810
|
registerAgentAddMessageHandler();
|
|
32595
|
-
return (0,
|
|
32811
|
+
return (0, import_langchain57.createMiddleware)({
|
|
32596
32812
|
name: "SchedulerMiddleware",
|
|
32597
32813
|
tools: [
|
|
32598
|
-
(0,
|
|
32814
|
+
(0, import_langchain57.tool)(
|
|
32599
32815
|
async (input, config) => {
|
|
32600
32816
|
const runConfig = getRunConfig(config);
|
|
32601
32817
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
@@ -32630,7 +32846,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
32630
32846
|
})
|
|
32631
32847
|
}
|
|
32632
32848
|
),
|
|
32633
|
-
(0,
|
|
32849
|
+
(0, import_langchain57.tool)(
|
|
32634
32850
|
async (input, config) => {
|
|
32635
32851
|
const runConfig = getRunConfig(config);
|
|
32636
32852
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
@@ -32665,7 +32881,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
32665
32881
|
})
|
|
32666
32882
|
}
|
|
32667
32883
|
),
|
|
32668
|
-
(0,
|
|
32884
|
+
(0, import_langchain57.tool)(
|
|
32669
32885
|
async (input, config) => {
|
|
32670
32886
|
const runConfig = getRunConfig(config);
|
|
32671
32887
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
@@ -32709,7 +32925,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
32709
32925
|
})
|
|
32710
32926
|
}
|
|
32711
32927
|
),
|
|
32712
|
-
(0,
|
|
32928
|
+
(0, import_langchain57.tool)(
|
|
32713
32929
|
async (input) => {
|
|
32714
32930
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
32715
32931
|
const success = await scheduleLattice.client.cancel(input.taskId);
|
|
@@ -32723,7 +32939,7 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
32723
32939
|
})
|
|
32724
32940
|
}
|
|
32725
32941
|
),
|
|
32726
|
-
(0,
|
|
32942
|
+
(0, import_langchain57.tool)(
|
|
32727
32943
|
async (input, config) => {
|
|
32728
32944
|
const runConfig = getRunConfig(config);
|
|
32729
32945
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
@@ -34007,7 +34223,7 @@ var MemoryBackend = class {
|
|
|
34007
34223
|
// src/deep_agent_new/middleware/todos.ts
|
|
34008
34224
|
var import_langgraph8 = require("@langchain/langgraph");
|
|
34009
34225
|
var import_zod52 = require("zod");
|
|
34010
|
-
var
|
|
34226
|
+
var import_langchain58 = require("langchain");
|
|
34011
34227
|
var WRITE_TODOS_DESCRIPTION = `Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
34012
34228
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
34013
34229
|
Only use this tool if you think it will be helpful in staying organized. If the user's request is trivial and takes less than 3 steps, it is better to NOT use this tool and just do the taks directly.
|
|
@@ -34241,13 +34457,13 @@ var TodoSchema = import_zod52.z.object({
|
|
|
34241
34457
|
});
|
|
34242
34458
|
var stateSchema = import_zod52.z.object({ todos: import_zod52.z.array(TodoSchema).default([]) });
|
|
34243
34459
|
function todoListMiddleware(options) {
|
|
34244
|
-
const writeTodos = (0,
|
|
34460
|
+
const writeTodos = (0, import_langchain58.tool)(
|
|
34245
34461
|
({ todos }, config) => {
|
|
34246
34462
|
return new import_langgraph8.Command({
|
|
34247
34463
|
update: {
|
|
34248
34464
|
todos,
|
|
34249
34465
|
messages: [
|
|
34250
|
-
new
|
|
34466
|
+
new import_langchain58.ToolMessage({
|
|
34251
34467
|
content: genUIMarkdown("todo_list", todos),
|
|
34252
34468
|
tool_call_id: config.toolCall?.id
|
|
34253
34469
|
})
|
|
@@ -34263,7 +34479,7 @@ function todoListMiddleware(options) {
|
|
|
34263
34479
|
})
|
|
34264
34480
|
}
|
|
34265
34481
|
);
|
|
34266
|
-
return (0,
|
|
34482
|
+
return (0, import_langchain58.createMiddleware)({
|
|
34267
34483
|
name: "todoListMiddleware",
|
|
34268
34484
|
stateSchema,
|
|
34269
34485
|
tools: [writeTodos],
|
|
@@ -34310,8 +34526,8 @@ function createDeepAgent(params = {}) {
|
|
|
34310
34526
|
|
|
34311
34527
|
${BASE_PROMPT}` : BASE_PROMPT;
|
|
34312
34528
|
const filesystemBackend = backend ? backend : async (config) => new StateBackend(config);
|
|
34313
|
-
const postDelegationMiddleware = interruptOn ? [(0,
|
|
34314
|
-
const middleware = ensurePatchToolCallsMiddleware(assembleDeepAgentMiddleware(
|
|
34529
|
+
const postDelegationMiddleware = interruptOn ? [(0, import_langchain59.humanInTheLoopMiddleware)({ interruptOn })] : [];
|
|
34530
|
+
const middleware = ensureStructuredOutputCarrierMiddleware(ensurePatchToolCallsMiddleware(assembleDeepAgentMiddleware(
|
|
34315
34531
|
customMiddleware,
|
|
34316
34532
|
[
|
|
34317
34533
|
// Provides todo list management capabilities for tracking tasks
|
|
@@ -34332,7 +34548,7 @@ ${BASE_PROMPT}` : BASE_PROMPT;
|
|
|
34332
34548
|
backend: filesystemBackend
|
|
34333
34549
|
}),
|
|
34334
34550
|
// Subagent middleware: Anthropic prompt caching for improved performance
|
|
34335
|
-
(0,
|
|
34551
|
+
(0, import_langchain59.anthropicPromptCachingMiddleware)({
|
|
34336
34552
|
unsupportedModelBehavior: "ignore"
|
|
34337
34553
|
}),
|
|
34338
34554
|
...customMiddleware
|
|
@@ -34347,8 +34563,8 @@ ${BASE_PROMPT}` : BASE_PROMPT;
|
|
|
34347
34563
|
// unsupportedModelBehavior: "ignore",
|
|
34348
34564
|
// })
|
|
34349
34565
|
postDelegationMiddleware
|
|
34350
|
-
));
|
|
34351
|
-
return (0,
|
|
34566
|
+
)));
|
|
34567
|
+
return (0, import_langchain59.createAgent)({
|
|
34352
34568
|
model,
|
|
34353
34569
|
systemPrompt: finalSystemPrompt,
|
|
34354
34570
|
tools,
|
|
@@ -34377,7 +34593,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
34377
34593
|
const tools = params.tools.map((t) => {
|
|
34378
34594
|
const toolClient = getToolClientWithTenant(params.tenantId ?? "default", t.key);
|
|
34379
34595
|
return toolClient;
|
|
34380
|
-
}).filter((
|
|
34596
|
+
}).filter((tool68) => tool68 !== void 0);
|
|
34381
34597
|
const subagents = await Promise.all(params.subAgents.map(async (sa) => {
|
|
34382
34598
|
if (sa.client) {
|
|
34383
34599
|
return {
|
|
@@ -34762,7 +34978,13 @@ var A2ARemoteClient = _A2ARemoteClient;
|
|
|
34762
34978
|
// src/agent_lattice/builders/RemoteAgentGraphBuilder.ts
|
|
34763
34979
|
var import_protocols25 = require("@axiom-lattice/protocols");
|
|
34764
34980
|
init_MemoryLatticeManager();
|
|
34981
|
+
function resolveA2ARemoteContextId(assistantKey, threadId) {
|
|
34982
|
+
return threadId ? `a2a-remote:${assistantKey}:${threadId}` : void 0;
|
|
34983
|
+
}
|
|
34765
34984
|
var RemoteAgentGraphBuilder = class {
|
|
34985
|
+
constructor(deps = {}) {
|
|
34986
|
+
this.deps = deps;
|
|
34987
|
+
}
|
|
34766
34988
|
async build(agentLattice, params) {
|
|
34767
34989
|
if (agentLattice.config.type !== import_protocols25.AgentType.A2A_REMOTE) {
|
|
34768
34990
|
throw new Error(
|
|
@@ -34770,7 +34992,7 @@ var RemoteAgentGraphBuilder = class {
|
|
|
34770
34992
|
);
|
|
34771
34993
|
}
|
|
34772
34994
|
const config = agentLattice.config;
|
|
34773
|
-
const client = new A2ARemoteClient({
|
|
34995
|
+
const client = this.deps.createClient?.(config) ?? new A2ARemoteClient({
|
|
34774
34996
|
agentCardUrl: config.agentCardUrl,
|
|
34775
34997
|
apiKey: config.apiKey,
|
|
34776
34998
|
timeout: config.timeout
|
|
@@ -34786,24 +35008,18 @@ var RemoteAgentGraphBuilder = class {
|
|
|
34786
35008
|
]
|
|
34787
35009
|
};
|
|
34788
35010
|
}
|
|
34789
|
-
|
|
34790
|
-
const fullPrompt = params.prompt ? `${params.prompt}
|
|
35011
|
+
const fullPrompt = params.prompt ? `${params.prompt}
|
|
34791
35012
|
|
|
34792
35013
|
User request:
|
|
34793
35014
|
${text}` : text;
|
|
34794
|
-
|
|
34795
|
-
|
|
34796
|
-
|
|
34797
|
-
|
|
34798
|
-
|
|
34799
|
-
|
|
34800
|
-
|
|
34801
|
-
|
|
34802
|
-
messages: [
|
|
34803
|
-
new import_messages5.AIMessage(`Remote A2A agent error: ${msg}`)
|
|
34804
|
-
]
|
|
34805
|
-
};
|
|
34806
|
-
}
|
|
35015
|
+
const threadId = langGraphConfig?.configurable?.thread_id;
|
|
35016
|
+
const response = await client.sendMessage(
|
|
35017
|
+
fullPrompt,
|
|
35018
|
+
resolveA2ARemoteContextId(config.key, threadId)
|
|
35019
|
+
);
|
|
35020
|
+
return {
|
|
35021
|
+
messages: [new import_messages5.AIMessage(response)]
|
|
35022
|
+
};
|
|
34807
35023
|
};
|
|
34808
35024
|
const workflow = new import_langgraph9.StateGraph(import_langgraph9.MessagesAnnotation).addNode("remote_call", remoteCallNode).addEdge("__start__", "remote_call").addEdge("remote_call", "__end__");
|
|
34809
35025
|
return workflow.compile({ checkpointer: getCheckpointSaver("default") });
|
|
@@ -34827,7 +35043,7 @@ function extractLastHumanMessage(messages) {
|
|
|
34827
35043
|
}
|
|
34828
35044
|
|
|
34829
35045
|
// src/agent_lattice/builders/WorkflowAgentGraphBuilder.ts
|
|
34830
|
-
var
|
|
35046
|
+
var import_langchain60 = require("langchain");
|
|
34831
35047
|
init_MemoryLatticeManager();
|
|
34832
35048
|
var import_protocols26 = require("@axiom-lattice/protocols");
|
|
34833
35049
|
init_compile();
|
|
@@ -34892,12 +35108,13 @@ var WorkflowAgentGraphBuilder = class {
|
|
|
34892
35108
|
}
|
|
34893
35109
|
], void 0, false, void 0, params.model);
|
|
34894
35110
|
const preservedMiddlewareNames = [
|
|
34895
|
-
"patchToolCallsMiddleware"
|
|
35111
|
+
"patchToolCallsMiddleware",
|
|
35112
|
+
STRUCTURED_OUTPUT_CARRIER_MIDDLEWARE_NAME
|
|
34896
35113
|
];
|
|
34897
35114
|
const noWrapMiddlewares = stripWrapModelCallHook(middlewares, preservedMiddlewareNames);
|
|
34898
35115
|
const noWrapAskMiddlewares = stripWrapModelCallHook(askMiddlewares, preservedMiddlewareNames);
|
|
34899
35116
|
console.log(`[WF BUILDER] building default agent | toolCount=${tools.length} | middlewareCount=${middlewares.length}`);
|
|
34900
|
-
const defaultAgent = (0,
|
|
35117
|
+
const defaultAgent = (0, import_langchain60.createAgent)({
|
|
34901
35118
|
model: params.model,
|
|
34902
35119
|
tools,
|
|
34903
35120
|
systemPrompt: buildStepSystemPrompt(false, params.prompt),
|
|
@@ -34919,7 +35136,7 @@ var WorkflowAgentGraphBuilder = class {
|
|
|
34919
35136
|
console.log(`[WF BUILDER] resolveAgent: cacheKey=${key5.slice(0, 80)}... | cached=${agentCache.has(key5)}`);
|
|
34920
35137
|
if (!agentCache.has(key5)) {
|
|
34921
35138
|
console.log(`[WF BUILDER] creating ${isAsk ? "ask" : "agent"} with responseFormat`);
|
|
34922
|
-
const agent = (0,
|
|
35139
|
+
const agent = (0, import_langchain60.createAgent)({
|
|
34923
35140
|
model: params.model,
|
|
34924
35141
|
tools,
|
|
34925
35142
|
systemPrompt: buildStepSystemPrompt(isAsk, params.prompt),
|
|
@@ -34937,7 +35154,7 @@ var WorkflowAgentGraphBuilder = class {
|
|
|
34937
35154
|
const key5 = "ask:default";
|
|
34938
35155
|
if (!agentCache.has(key5)) {
|
|
34939
35156
|
console.log(`[WF BUILDER] creating ask default agent`);
|
|
34940
|
-
const agent = (0,
|
|
35157
|
+
const agent = (0, import_langchain60.createAgent)({
|
|
34941
35158
|
model: params.model,
|
|
34942
35159
|
tools,
|
|
34943
35160
|
systemPrompt: buildStepSystemPrompt(true, params.prompt),
|
|
@@ -35179,7 +35396,7 @@ function requireSkillDeclaration(skillLoaded) {
|
|
|
35179
35396
|
return void 0;
|
|
35180
35397
|
}
|
|
35181
35398
|
async function validateAgentReferences(input, tenantId2) {
|
|
35182
|
-
const availableTools = getAvailableTools(tenantId2).map((
|
|
35399
|
+
const availableTools = getAvailableTools(tenantId2).map((tool68) => tool68.key);
|
|
35183
35400
|
const availableMiddlewareTypes = await getAvailableMiddlewareTypes(tenantId2);
|
|
35184
35401
|
const availableCustomMiddlewareKeys = CustomMiddlewareRegistry.list().filter(
|
|
35185
35402
|
(key5) => CustomMiddlewareRegistry.get(key5) !== void 0
|
|
@@ -37757,11 +37974,11 @@ async function withTimeout2(operation, ms, onTimeout) {
|
|
|
37757
37974
|
|
|
37758
37975
|
// src/mcp_lattice/McpLatticeManager.ts
|
|
37759
37976
|
var realClientFactory = ({ mcpServers }) => new import_mcp_adapters.MultiServerMCPClient({ mcpServers });
|
|
37760
|
-
function extractRawCall(
|
|
37761
|
-
const rawCall =
|
|
37762
|
-
if (typeof rawCall === "function") return rawCall.bind(
|
|
37977
|
+
function extractRawCall(tool68) {
|
|
37978
|
+
const rawCall = tool68._call;
|
|
37979
|
+
if (typeof rawCall === "function") return rawCall.bind(tool68);
|
|
37763
37980
|
return async (...args) => {
|
|
37764
|
-
const invoke =
|
|
37981
|
+
const invoke = tool68.invoke.bind(tool68);
|
|
37765
37982
|
return invoke(args[0], args[2]);
|
|
37766
37983
|
};
|
|
37767
37984
|
}
|
|
@@ -38309,16 +38526,16 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
38309
38526
|
const metaByName = new Map(metaList.map((m) => [m.name, m.meta]));
|
|
38310
38527
|
this.unregisterServerTools(tenantId2, serverKey);
|
|
38311
38528
|
const keys = [];
|
|
38312
|
-
for (const
|
|
38313
|
-
if (rt.selectedTools && !rt.selectedTools.includes(
|
|
38314
|
-
const meta = metaByName.get(
|
|
38529
|
+
for (const tool68 of tools) {
|
|
38530
|
+
if (rt.selectedTools && !rt.selectedTools.includes(tool68.name)) continue;
|
|
38531
|
+
const meta = metaByName.get(tool68.name);
|
|
38315
38532
|
const rawVisibility = meta?.ui?.visibility;
|
|
38316
38533
|
const visibility = Array.isArray(rawVisibility) ? rawVisibility : typeof rawVisibility === "string" ? [rawVisibility] : void 0;
|
|
38317
38534
|
if (visibility && !visibility.includes("model")) continue;
|
|
38318
|
-
const ref = extractAppsRef(meta, serverKey);
|
|
38319
|
-
const resilient = this.wrapToolForResilience(rt,
|
|
38535
|
+
const ref = extractAppsRef(meta, serverKey, tool68.name);
|
|
38536
|
+
const resilient = this.wrapToolForResilience(rt, tool68);
|
|
38320
38537
|
const registered = ref ? wrapMcpToolWithUi(resilient, ref) : resilient;
|
|
38321
|
-
const toolKey = _McpLatticeManager.buildToolKey(serverKey,
|
|
38538
|
+
const toolKey = _McpLatticeManager.buildToolKey(serverKey, tool68.name);
|
|
38322
38539
|
try {
|
|
38323
38540
|
toolLatticeManager.registerExistingToolWithTenant(tenantId2, toolKey, registered);
|
|
38324
38541
|
keys.push(toolKey);
|
|
@@ -40700,17 +40917,30 @@ var TokenCache = class {
|
|
|
40700
40917
|
var import_crypto7 = require("crypto");
|
|
40701
40918
|
var import_bcryptjs = __toESM(require("bcryptjs"));
|
|
40702
40919
|
var TOKEN_BYTES = 24;
|
|
40920
|
+
var MAX_MCP_APP_PAYLOAD_BYTES = 256 * 1024;
|
|
40703
40921
|
function generateToken() {
|
|
40704
40922
|
return (0, import_crypto7.randomBytes)(TOKEN_BYTES).toString("base64url");
|
|
40705
40923
|
}
|
|
40924
|
+
function normalizeShareResourcePath(raw) {
|
|
40925
|
+
const withoutLeadingSlash = raw.startsWith("/") ? raw.slice(1) : raw;
|
|
40926
|
+
const withoutProject = withoutLeadingSlash.replace(/^project(?:\/|$)/, "");
|
|
40927
|
+
const segments = withoutProject.split("/");
|
|
40928
|
+
if (segments.some((segment) => segment === "..")) return null;
|
|
40929
|
+
const cleaned = segments.filter(
|
|
40930
|
+
(segment) => segment !== "" && segment !== "."
|
|
40931
|
+
);
|
|
40932
|
+
if (cleaned.length === 0) return null;
|
|
40933
|
+
return cleaned.join("/");
|
|
40934
|
+
}
|
|
40706
40935
|
function createSharePayload(tenantId2, workspaceId, projectId, userId, request) {
|
|
40707
|
-
const resourcePath = (request.resourcePath || "")
|
|
40708
|
-
if (
|
|
40709
|
-
|
|
40710
|
-
|
|
40711
|
-
|
|
40936
|
+
const resourcePath = normalizeShareResourcePath(request.resourcePath || "");
|
|
40937
|
+
if (resourcePath === null) {
|
|
40938
|
+
throw new Error(
|
|
40939
|
+
"Invalid resource path \u2014 share a file or subdirectory inside the project"
|
|
40940
|
+
);
|
|
40712
40941
|
}
|
|
40713
40942
|
return {
|
|
40943
|
+
kind: "file",
|
|
40714
40944
|
address: createResourceAddress({
|
|
40715
40945
|
tenantId: tenantId2,
|
|
40716
40946
|
workspaceId,
|
|
@@ -40732,6 +40962,46 @@ function createSharePayload(tenantId2, workspaceId, projectId, userId, request)
|
|
|
40732
40962
|
revoked: false
|
|
40733
40963
|
};
|
|
40734
40964
|
}
|
|
40965
|
+
var SharePayloadError = class extends Error {
|
|
40966
|
+
/**
|
|
40967
|
+
* @param code - The stable failure code.
|
|
40968
|
+
*/
|
|
40969
|
+
constructor(code) {
|
|
40970
|
+
super(code);
|
|
40971
|
+
this.code = code;
|
|
40972
|
+
this.name = "SharePayloadError";
|
|
40973
|
+
}
|
|
40974
|
+
};
|
|
40975
|
+
function createMcpAppSharePayload(input) {
|
|
40976
|
+
if (input.visibility === "internal") {
|
|
40977
|
+
throw new SharePayloadError("INTERNAL_NOT_SUPPORTED");
|
|
40978
|
+
}
|
|
40979
|
+
const app = { ...input.app, toolInput: input.app.toolInput ?? {} };
|
|
40980
|
+
if (typeof app.toolName !== "string" || app.toolName.trim() === "") {
|
|
40981
|
+
throw new SharePayloadError("TOOL_NAME_REQUIRED");
|
|
40982
|
+
}
|
|
40983
|
+
const size = Buffer.byteLength(JSON.stringify(app), "utf8");
|
|
40984
|
+
if (size > MAX_MCP_APP_PAYLOAD_BYTES) {
|
|
40985
|
+
throw new SharePayloadError("PAYLOAD_TOO_LARGE");
|
|
40986
|
+
}
|
|
40987
|
+
return {
|
|
40988
|
+
token: generateToken(),
|
|
40989
|
+
kind: "mcpApp",
|
|
40990
|
+
address: { kind: "mcpApp", app },
|
|
40991
|
+
title: input.title ?? app.title ?? app.toolName ?? "Shared app",
|
|
40992
|
+
createdBy: input.createdBy,
|
|
40993
|
+
tenantId: input.tenantId,
|
|
40994
|
+
workspaceId: input.workspaceId,
|
|
40995
|
+
projectId: input.projectId,
|
|
40996
|
+
assistantId: null,
|
|
40997
|
+
vmIsolation: "project",
|
|
40998
|
+
visibility: input.visibility,
|
|
40999
|
+
passwordHash: input.password ? import_bcryptjs.default.hashSync(input.password, 10) : null,
|
|
41000
|
+
expiresAt: input.expiresAt ?? null,
|
|
41001
|
+
maxAccess: input.maxAccess ?? null,
|
|
41002
|
+
revoked: false
|
|
41003
|
+
};
|
|
41004
|
+
}
|
|
40735
41005
|
|
|
40736
41006
|
// src/channel/connectAllChannels.ts
|
|
40737
41007
|
async function connectAllChannels(getAdapter, options = {}) {
|
|
@@ -42919,6 +43189,42 @@ function snapshotCanonicalScoped(value, expected) {
|
|
|
42919
43189
|
};
|
|
42920
43190
|
}
|
|
42921
43191
|
|
|
43192
|
+
// src/services/ProjectRoomMessageNotifier.ts
|
|
43193
|
+
var ProjectRoomMessageNotifier = class {
|
|
43194
|
+
constructor() {
|
|
43195
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
43196
|
+
}
|
|
43197
|
+
/**
|
|
43198
|
+
* Registers a committed-message listener.
|
|
43199
|
+
*
|
|
43200
|
+
* @param listener Observer invoked for later commits.
|
|
43201
|
+
* @returns An idempotent unsubscribe callback.
|
|
43202
|
+
*/
|
|
43203
|
+
subscribe(listener) {
|
|
43204
|
+
this.listeners.add(listener);
|
|
43205
|
+
return () => {
|
|
43206
|
+
this.listeners.delete(listener);
|
|
43207
|
+
};
|
|
43208
|
+
}
|
|
43209
|
+
/**
|
|
43210
|
+
* Delivers one committed message to every registered listener.
|
|
43211
|
+
*
|
|
43212
|
+
* @param message Canonical persisted room message.
|
|
43213
|
+
* @returns Nothing; each listener receives its own clone and failures are contained.
|
|
43214
|
+
*/
|
|
43215
|
+
notify(message) {
|
|
43216
|
+
if (this.listeners.size === 0) return;
|
|
43217
|
+
for (const listener of [...this.listeners]) {
|
|
43218
|
+
try {
|
|
43219
|
+
const result = listener(structuredClone(message));
|
|
43220
|
+
if (result !== void 0) void Promise.resolve(result).catch(() => void 0);
|
|
43221
|
+
} catch {
|
|
43222
|
+
}
|
|
43223
|
+
}
|
|
43224
|
+
}
|
|
43225
|
+
};
|
|
43226
|
+
var projectRoomMessageNotifier = new ProjectRoomMessageNotifier();
|
|
43227
|
+
|
|
42922
43228
|
// src/services/ProjectTaskOwnerPolicy.ts
|
|
42923
43229
|
var import_protocols39 = require("@axiom-lattice/protocols");
|
|
42924
43230
|
var MEMBERSHIP_REQUIRED_KEYS = [
|
|
@@ -46909,11 +47215,11 @@ async function assertSafeUpstreamUrl(raw) {
|
|
|
46909
47215
|
}
|
|
46910
47216
|
|
|
46911
47217
|
// src/middlewares/skillMiddleware.ts
|
|
46912
|
-
var
|
|
47218
|
+
var import_langchain65 = require("langchain");
|
|
46913
47219
|
|
|
46914
47220
|
// src/tool_lattice/skill/load_skills.ts
|
|
46915
47221
|
var import_zod54 = __toESM(require("zod"));
|
|
46916
|
-
var
|
|
47222
|
+
var import_langchain61 = require("langchain");
|
|
46917
47223
|
var LOAD_SKILLS_DESCRIPTION = `Load all available skills and return their metadata (name, description, license, compatibility, metadata, and subSkills) without the content. This tool returns skill information including hierarchical relationships (subSkills). Use this to discover what skills are available and their structure.`;
|
|
46918
47224
|
function getSandboxFromExeConfig(_exe_config) {
|
|
46919
47225
|
const runConfig = _exe_config?.configurable?.runConfig || {};
|
|
@@ -46928,7 +47234,7 @@ function getSandboxFromExeConfig(_exe_config) {
|
|
|
46928
47234
|
});
|
|
46929
47235
|
}
|
|
46930
47236
|
var createLoadSkillsTool = ({ skills, readAll, pluginSkills, pluginSkillOwners } = {}) => {
|
|
46931
|
-
return (0,
|
|
47237
|
+
return (0, import_langchain61.tool)(
|
|
46932
47238
|
async (_input, _exe_config) => {
|
|
46933
47239
|
const allSkills = [];
|
|
46934
47240
|
try {
|
|
@@ -47005,7 +47311,7 @@ function isSkillAllowed(skillName, staticSkills, staticReadAll) {
|
|
|
47005
47311
|
|
|
47006
47312
|
// src/tool_lattice/skill/load_skill_content.ts
|
|
47007
47313
|
var import_zod55 = __toESM(require("zod"));
|
|
47008
|
-
var
|
|
47314
|
+
var import_langchain62 = require("langchain");
|
|
47009
47315
|
|
|
47010
47316
|
// src/sandbox_plugin/pluginSkillResolution.ts
|
|
47011
47317
|
async function resolveTenantPluginSkill(tenantId2, owner3, skillName) {
|
|
@@ -47068,7 +47374,7 @@ function getSandboxFromExeConfig2(_exe_config) {
|
|
|
47068
47374
|
var createLoadSkillContentTool = (pluginSkills, pluginSkillOwnersOrStaticSelection, staticSelection) => {
|
|
47069
47375
|
const pluginSkillOwners = staticSelection === void 0 ? isStaticSkillSelection(pluginSkillOwnersOrStaticSelection) ? void 0 : pluginSkillOwnersOrStaticSelection : pluginSkillOwnersOrStaticSelection;
|
|
47070
47376
|
const effectiveStaticSelection = isStaticSkillSelection(pluginSkillOwnersOrStaticSelection) ? pluginSkillOwnersOrStaticSelection : staticSelection ?? {};
|
|
47071
|
-
return (0,
|
|
47377
|
+
return (0, import_langchain62.tool)(
|
|
47072
47378
|
async (input, _exe_config) => {
|
|
47073
47379
|
try {
|
|
47074
47380
|
if (!isSkillAllowed2(input.skill_name, effectiveStaticSelection)) {
|
|
@@ -47175,7 +47481,7 @@ function isSkillAllowed2(skillName, staticSelection) {
|
|
|
47175
47481
|
|
|
47176
47482
|
// src/tool_lattice/skill/load_skill_resource.ts
|
|
47177
47483
|
var import_zod56 = __toESM(require("zod"));
|
|
47178
|
-
var
|
|
47484
|
+
var import_langchain63 = require("langchain");
|
|
47179
47485
|
var LOAD_SKILL_RESOURCE_DESCRIPTION = `Load a specific resource file from a skill's resources directory. Use this tool when you need to access template files, example data, or other resources bundled with a skill. The resource paths are listed in the skill content when using the load_skill_content tool.`;
|
|
47180
47486
|
function getSandboxFromExeConfig3(_exe_config) {
|
|
47181
47487
|
const runConfig = _exe_config?.configurable?.runConfig || {};
|
|
@@ -47190,7 +47496,7 @@ function getSandboxFromExeConfig3(_exe_config) {
|
|
|
47190
47496
|
});
|
|
47191
47497
|
}
|
|
47192
47498
|
var createLoadSkillResourceTool = (pluginSkills, pluginSkillOwners) => {
|
|
47193
|
-
return (0,
|
|
47499
|
+
return (0, import_langchain63.tool)(
|
|
47194
47500
|
async (input, _exe_config) => {
|
|
47195
47501
|
try {
|
|
47196
47502
|
validateRelativePath(input.skill_name, "skill");
|
|
@@ -47228,7 +47534,7 @@ var createLoadSkillResourceTool = (pluginSkills, pluginSkillOwners) => {
|
|
|
47228
47534
|
|
|
47229
47535
|
// src/tool_lattice/skill/delete_skill.ts
|
|
47230
47536
|
var import_zod57 = __toESM(require("zod"));
|
|
47231
|
-
var
|
|
47537
|
+
var import_langchain64 = require("langchain");
|
|
47232
47538
|
var DELETE_SKILL_DESCRIPTION = `
|
|
47233
47539
|
Delete a skill by name from the skill system.
|
|
47234
47540
|
This permanently removes the skill and its SKILL.md file.
|
|
@@ -47255,7 +47561,7 @@ function validateSkillName3(name) {
|
|
|
47255
47561
|
}
|
|
47256
47562
|
}
|
|
47257
47563
|
var createDeleteSkillTool = (staticSelection = {}) => {
|
|
47258
|
-
return (0,
|
|
47564
|
+
return (0, import_langchain64.tool)(
|
|
47259
47565
|
async (input, _exe_config) => {
|
|
47260
47566
|
try {
|
|
47261
47567
|
validateSkillName3(input.skill_name);
|
|
@@ -47312,7 +47618,7 @@ function createSkillMiddleware(params = {}) {
|
|
|
47312
47618
|
} = params;
|
|
47313
47619
|
const skills = params.skills;
|
|
47314
47620
|
let latestSkills = [];
|
|
47315
|
-
return (0,
|
|
47621
|
+
return (0, import_langchain65.createMiddleware)({
|
|
47316
47622
|
name: "skillMiddleware",
|
|
47317
47623
|
contextSchema,
|
|
47318
47624
|
tools: [
|
|
@@ -47462,11 +47768,11 @@ var skillPlugin = {
|
|
|
47462
47768
|
};
|
|
47463
47769
|
|
|
47464
47770
|
// src/middlewares/collectionMiddleware.ts
|
|
47465
|
-
var
|
|
47771
|
+
var import_langchain76 = require("langchain");
|
|
47466
47772
|
|
|
47467
47773
|
// src/tool_lattice/collection/list_collections.ts
|
|
47468
47774
|
var import_zod58 = __toESM(require("zod"));
|
|
47469
|
-
var
|
|
47775
|
+
var import_langchain66 = require("langchain");
|
|
47470
47776
|
|
|
47471
47777
|
// src/tool_lattice/collection/utils.ts
|
|
47472
47778
|
function getEffectiveCollectionScope(exeConfig, staticScope) {
|
|
@@ -47489,7 +47795,7 @@ var createListCollectionsTool = ({
|
|
|
47489
47795
|
collectionKeys,
|
|
47490
47796
|
connectAll
|
|
47491
47797
|
}) => {
|
|
47492
|
-
return (0,
|
|
47798
|
+
return (0, import_langchain66.tool)(
|
|
47493
47799
|
async (_input, _exeConfig) => {
|
|
47494
47800
|
try {
|
|
47495
47801
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -47531,7 +47837,7 @@ var createListCollectionsTool = ({
|
|
|
47531
47837
|
|
|
47532
47838
|
// src/tool_lattice/collection/search_collection.ts
|
|
47533
47839
|
var import_zod59 = __toESM(require("zod"));
|
|
47534
|
-
var
|
|
47840
|
+
var import_langchain67 = require("langchain");
|
|
47535
47841
|
var import_protocols42 = require("@axiom-lattice/protocols");
|
|
47536
47842
|
var SEARCH_COLLECTION_DESCRIPTION = `Search for content within a specific collection using semantic (vector) similarity. Use the 'filter' parameter to narrow results by metadata fields (e.g., {"category": "cardiovascular"}). Returns the most relevant content entries with similarity scores.`;
|
|
47537
47843
|
var searchSchema = import_zod59.default.object({
|
|
@@ -47541,7 +47847,7 @@ var searchSchema = import_zod59.default.object({
|
|
|
47541
47847
|
top_k: import_zod59.default.number().optional().default(5).describe("Number of results to return")
|
|
47542
47848
|
});
|
|
47543
47849
|
var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => {
|
|
47544
|
-
return (0,
|
|
47850
|
+
return (0, import_langchain67.tool)(
|
|
47545
47851
|
async (input, _exeConfig) => {
|
|
47546
47852
|
try {
|
|
47547
47853
|
const { collection, query, filter: filter2, top_k } = input;
|
|
@@ -47615,9 +47921,9 @@ var createSearchCollectionTool = (scope = { collectionKeys: [], connectAll: true
|
|
|
47615
47921
|
|
|
47616
47922
|
// src/tool_lattice/collection/get_collection.ts
|
|
47617
47923
|
var import_zod60 = __toESM(require("zod"));
|
|
47618
|
-
var
|
|
47924
|
+
var import_langchain68 = require("langchain");
|
|
47619
47925
|
var GET_COLLECTION_DESCRIPTION = `Get a collection's full definition including its custom fields schema. Use this to discover what metadata fields are available before adding entries.`;
|
|
47620
|
-
var createGetCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0,
|
|
47926
|
+
var createGetCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain68.tool)(
|
|
47621
47927
|
async (input, _exeConfig) => {
|
|
47622
47928
|
try {
|
|
47623
47929
|
const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
|
|
@@ -47647,7 +47953,7 @@ Embedding: ${c.embeddingKey}${fieldsDesc}`;
|
|
|
47647
47953
|
|
|
47648
47954
|
// src/tool_lattice/collection/create_collection.ts
|
|
47649
47955
|
var import_zod61 = __toESM(require("zod"));
|
|
47650
|
-
var
|
|
47956
|
+
var import_langchain69 = require("langchain");
|
|
47651
47957
|
var createSchema = import_zod61.default.object({
|
|
47652
47958
|
name: import_zod61.default.string().describe("Collection name (lowercase, underscores only)"),
|
|
47653
47959
|
label: import_zod61.default.string().describe("Display name"),
|
|
@@ -47659,7 +47965,7 @@ var createSchema = import_zod61.default.object({
|
|
|
47659
47965
|
required: import_zod61.default.boolean().optional().default(false).describe("Whether field is required")
|
|
47660
47966
|
})).optional().describe("Custom field definitions for entries in this collection")
|
|
47661
47967
|
});
|
|
47662
|
-
var createCreateCollectionTool = (scope = {}) => (0,
|
|
47968
|
+
var createCreateCollectionTool = (scope = {}) => (0, import_langchain69.tool)(
|
|
47663
47969
|
async (input, _exeConfig) => {
|
|
47664
47970
|
try {
|
|
47665
47971
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -47686,7 +47992,7 @@ var createCreateCollectionTool = (scope = {}) => (0, import_langchain68.tool)(
|
|
|
47686
47992
|
|
|
47687
47993
|
// src/tool_lattice/collection/update_collection.ts
|
|
47688
47994
|
var import_zod62 = __toESM(require("zod"));
|
|
47689
|
-
var
|
|
47995
|
+
var import_langchain70 = require("langchain");
|
|
47690
47996
|
var schema = import_zod62.default.object({
|
|
47691
47997
|
name: import_zod62.default.string().describe("Collection name"),
|
|
47692
47998
|
label: import_zod62.default.string().optional().describe("New display name"),
|
|
@@ -47698,7 +48004,7 @@ var schema = import_zod62.default.object({
|
|
|
47698
48004
|
required: import_zod62.default.boolean().optional().default(false).describe("Whether field is required")
|
|
47699
48005
|
})).optional().describe("Custom field definitions for entries (replaces existing schema)")
|
|
47700
48006
|
});
|
|
47701
|
-
var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0,
|
|
48007
|
+
var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain70.tool)(
|
|
47702
48008
|
async (input, _exeConfig) => {
|
|
47703
48009
|
try {
|
|
47704
48010
|
const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
|
|
@@ -47720,8 +48026,8 @@ var createUpdateCollectionTool = (scope = { collectionKeys: [], connectAll: true
|
|
|
47720
48026
|
|
|
47721
48027
|
// src/tool_lattice/collection/delete_collection.ts
|
|
47722
48028
|
var import_zod63 = __toESM(require("zod"));
|
|
47723
|
-
var
|
|
47724
|
-
var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0,
|
|
48029
|
+
var import_langchain71 = require("langchain");
|
|
48030
|
+
var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain71.tool)(
|
|
47725
48031
|
async (input, _exeConfig) => {
|
|
47726
48032
|
try {
|
|
47727
48033
|
const scopeError = validateCollectionScope(input.name, _exeConfig, scope);
|
|
@@ -47738,14 +48044,14 @@ var createDeleteCollectionTool = (scope = { collectionKeys: [], connectAll: true
|
|
|
47738
48044
|
|
|
47739
48045
|
// src/tool_lattice/collection/list_entries.ts
|
|
47740
48046
|
var import_zod64 = __toESM(require("zod"));
|
|
47741
|
-
var
|
|
48047
|
+
var import_langchain72 = require("langchain");
|
|
47742
48048
|
var schema2 = import_zod64.default.object({
|
|
47743
48049
|
collection: import_zod64.default.string().describe("Collection name")
|
|
47744
48050
|
});
|
|
47745
48051
|
function buildKey2(tenantId2, name) {
|
|
47746
48052
|
return `${tenantId2}:${name}`;
|
|
47747
48053
|
}
|
|
47748
|
-
var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) => (0,
|
|
48054
|
+
var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain72.tool)(
|
|
47749
48055
|
async (input, _exeConfig) => {
|
|
47750
48056
|
try {
|
|
47751
48057
|
const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
|
|
@@ -47775,7 +48081,7 @@ var createListEntriesTool = (scope = { collectionKeys: [], connectAll: true }) =
|
|
|
47775
48081
|
|
|
47776
48082
|
// src/tool_lattice/collection/add_entry.ts
|
|
47777
48083
|
var import_zod65 = __toESM(require("zod"));
|
|
47778
|
-
var
|
|
48084
|
+
var import_langchain73 = require("langchain");
|
|
47779
48085
|
var import_documents = require("@langchain/core/documents");
|
|
47780
48086
|
var import_uuid11 = require("uuid");
|
|
47781
48087
|
var schema3 = import_zod65.default.object({
|
|
@@ -47786,7 +48092,7 @@ var schema3 = import_zod65.default.object({
|
|
|
47786
48092
|
function key2(t, n) {
|
|
47787
48093
|
return `${t}:${n}`;
|
|
47788
48094
|
}
|
|
47789
|
-
var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0,
|
|
48095
|
+
var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain73.tool)(
|
|
47790
48096
|
async (input, _exeConfig) => {
|
|
47791
48097
|
try {
|
|
47792
48098
|
const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
|
|
@@ -47819,7 +48125,7 @@ var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (
|
|
|
47819
48125
|
|
|
47820
48126
|
// src/tool_lattice/collection/update_entry.ts
|
|
47821
48127
|
var import_zod66 = __toESM(require("zod"));
|
|
47822
|
-
var
|
|
48128
|
+
var import_langchain74 = require("langchain");
|
|
47823
48129
|
var schema4 = import_zod66.default.object({
|
|
47824
48130
|
collection: import_zod66.default.string().describe("Collection name"),
|
|
47825
48131
|
entryId: import_zod66.default.string().describe("Entry ID to update"),
|
|
@@ -47829,7 +48135,7 @@ var schema4 = import_zod66.default.object({
|
|
|
47829
48135
|
function key3(t, n) {
|
|
47830
48136
|
return `${t}:${n}`;
|
|
47831
48137
|
}
|
|
47832
|
-
var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0,
|
|
48138
|
+
var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain74.tool)(
|
|
47833
48139
|
async (input, _exeConfig) => {
|
|
47834
48140
|
try {
|
|
47835
48141
|
const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
|
|
@@ -47851,7 +48157,7 @@ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
|
|
|
47851
48157
|
|
|
47852
48158
|
// src/tool_lattice/collection/delete_entry.ts
|
|
47853
48159
|
var import_zod67 = __toESM(require("zod"));
|
|
47854
|
-
var
|
|
48160
|
+
var import_langchain75 = require("langchain");
|
|
47855
48161
|
var schema5 = import_zod67.default.object({
|
|
47856
48162
|
collection: import_zod67.default.string().describe("Collection name"),
|
|
47857
48163
|
entryId: import_zod67.default.string().describe("Entry ID to delete")
|
|
@@ -47859,7 +48165,7 @@ var schema5 = import_zod67.default.object({
|
|
|
47859
48165
|
function key4(t, n) {
|
|
47860
48166
|
return `${t}:${n}`;
|
|
47861
48167
|
}
|
|
47862
|
-
var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0,
|
|
48168
|
+
var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) => (0, import_langchain75.tool)(
|
|
47863
48169
|
async (input, _exeConfig) => {
|
|
47864
48170
|
try {
|
|
47865
48171
|
const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
|
|
@@ -47879,7 +48185,7 @@ var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
|
|
|
47879
48185
|
function createCollectionMiddleware(params) {
|
|
47880
48186
|
const { collectionKeys, connectAll, compileStableCandidateTools = false } = params;
|
|
47881
48187
|
if (!compileStableCandidateTools && !connectAll && (!collectionKeys || collectionKeys.length === 0)) {
|
|
47882
|
-
return (0,
|
|
48188
|
+
return (0, import_langchain76.createMiddleware)({
|
|
47883
48189
|
name: "collectionMiddleware",
|
|
47884
48190
|
contextSchema,
|
|
47885
48191
|
tools: [
|
|
@@ -47889,7 +48195,7 @@ function createCollectionMiddleware(params) {
|
|
|
47889
48195
|
});
|
|
47890
48196
|
}
|
|
47891
48197
|
const toolParams = { collectionKeys, connectAll };
|
|
47892
|
-
return (0,
|
|
48198
|
+
return (0, import_langchain76.createMiddleware)({
|
|
47893
48199
|
name: "collectionMiddleware",
|
|
47894
48200
|
contextSchema,
|
|
47895
48201
|
tools: [
|
|
@@ -47952,11 +48258,11 @@ var collectionPlugin = {
|
|
|
47952
48258
|
};
|
|
47953
48259
|
|
|
47954
48260
|
// src/middlewares/askUserClarifyMiddleware.ts
|
|
47955
|
-
var
|
|
48261
|
+
var import_langchain78 = require("langchain");
|
|
47956
48262
|
var import_langgraph13 = require("@langchain/langgraph");
|
|
47957
48263
|
|
|
47958
48264
|
// src/tool_lattice/ask_user_to_clarify/index.ts
|
|
47959
|
-
var
|
|
48265
|
+
var import_langchain77 = require("langchain");
|
|
47960
48266
|
var import_zod68 = __toESM(require("zod"));
|
|
47961
48267
|
var questionSchema = import_zod68.default.object({
|
|
47962
48268
|
question: import_zod68.default.string().describe("The question text to ask the user. MUST include the specific context, options, or details being clarified \u2014 never use a bare generic label. Good: 'Confirm the plan: use Redis cache + PostgreSQL primary, split microservices as needed?' Bad: 'Confirm the plan?'"),
|
|
@@ -47969,7 +48275,7 @@ var inputSchema = import_zod68.default.object({
|
|
|
47969
48275
|
questions: import_zod68.default.array(questionSchema).min(1, "At least one question is required").describe("A structured sequence of clarification questions. Use these to gather missing parameters or disambiguate user intent before proceeding.")
|
|
47970
48276
|
});
|
|
47971
48277
|
function createAskUserToClarifyTool() {
|
|
47972
|
-
return (0,
|
|
48278
|
+
return (0, import_langchain77.tool)(
|
|
47973
48279
|
async (input) => {
|
|
47974
48280
|
return JSON.stringify(input);
|
|
47975
48281
|
},
|
|
@@ -47994,7 +48300,7 @@ function isProjectRoomRun(request) {
|
|
|
47994
48300
|
return isRecord13(runConfig?.projectRoom);
|
|
47995
48301
|
}
|
|
47996
48302
|
function createAskUserClarifyMiddleware() {
|
|
47997
|
-
return (0,
|
|
48303
|
+
return (0, import_langchain78.createMiddleware)({
|
|
47998
48304
|
name: "AskUserClarifyMiddleware",
|
|
47999
48305
|
tools: [createAskUserToClarifyTool()],
|
|
48000
48306
|
wrapToolCall: async (request, handler) => {
|
|
@@ -48004,7 +48310,7 @@ function createAskUserClarifyMiddleware() {
|
|
|
48004
48310
|
return handler(request);
|
|
48005
48311
|
}
|
|
48006
48312
|
if (isProjectRoomRun(request)) {
|
|
48007
|
-
return new
|
|
48313
|
+
return new import_langchain78.ToolMessage({
|
|
48008
48314
|
content: "You are replying inside a project room, which has no interactive clarification UI. Ask your clarifying questions directly in your reply text and stop; the user's next room message will continue the conversation.",
|
|
48009
48315
|
tool_call_id: toolCall?.id,
|
|
48010
48316
|
name: toolName2
|
|
@@ -48012,7 +48318,7 @@ function createAskUserClarifyMiddleware() {
|
|
|
48012
48318
|
}
|
|
48013
48319
|
const parsed = inputSchema.safeParse(toolCall?.args);
|
|
48014
48320
|
if (!parsed.success) {
|
|
48015
|
-
return new
|
|
48321
|
+
return new import_langchain78.ToolMessage({
|
|
48016
48322
|
content: `Invalid clarify tool arguments: ${parsed.error.message}`,
|
|
48017
48323
|
tool_call_id: toolCall?.id,
|
|
48018
48324
|
name: toolName2
|
|
@@ -48032,7 +48338,7 @@ function createAskUserClarifyMiddleware() {
|
|
|
48032
48338
|
const result = await (0, import_langgraph13.interrupt)(md);
|
|
48033
48339
|
const response = result.data;
|
|
48034
48340
|
if (!response?.answers || response.answers.length === 0) {
|
|
48035
|
-
return new
|
|
48341
|
+
return new import_langchain78.ToolMessage({
|
|
48036
48342
|
content: "No clarification questions were answered.",
|
|
48037
48343
|
tool_call_id: toolCall?.id,
|
|
48038
48344
|
name: toolName2
|
|
@@ -48042,7 +48348,7 @@ function createAskUserClarifyMiddleware() {
|
|
|
48042
48348
|
(answer) => (answer.selectedOptions?.length ?? 0) > 0 || answer.otherText && answer.otherText.trim() !== "" || answer.filePath && answer.filePath.trim() !== ""
|
|
48043
48349
|
);
|
|
48044
48350
|
if (answeredQuestions.length === 0) {
|
|
48045
|
-
return new
|
|
48351
|
+
return new import_langchain78.ToolMessage({
|
|
48046
48352
|
content: "No clarification questions were answered.",
|
|
48047
48353
|
tool_call_id: toolCall?.id,
|
|
48048
48354
|
name: toolName2
|
|
@@ -48072,7 +48378,7 @@ function createAskUserClarifyMiddleware() {
|
|
|
48072
48378
|
}
|
|
48073
48379
|
lines.push("");
|
|
48074
48380
|
}
|
|
48075
|
-
return new
|
|
48381
|
+
return new import_langchain78.ToolMessage({
|
|
48076
48382
|
content: lines.join("\n"),
|
|
48077
48383
|
tool_call_id: toolCall?.id,
|
|
48078
48384
|
name: toolName2
|
|
@@ -48098,10 +48404,10 @@ var askUserClarifyPlugin = {
|
|
|
48098
48404
|
};
|
|
48099
48405
|
|
|
48100
48406
|
// src/middlewares/widgetMiddleware.ts
|
|
48101
|
-
var
|
|
48407
|
+
var import_langchain81 = require("langchain");
|
|
48102
48408
|
|
|
48103
48409
|
// src/tool_lattice/widget/loadGuidelines.ts
|
|
48104
|
-
var
|
|
48410
|
+
var import_langchain79 = require("langchain");
|
|
48105
48411
|
var import_zod69 = require("zod");
|
|
48106
48412
|
|
|
48107
48413
|
// src/middlewares/guidelines/index.ts
|
|
@@ -48975,7 +49281,7 @@ var LoadGuidelinesInputSchema = import_zod69.z.object({
|
|
|
48975
49281
|
)
|
|
48976
49282
|
});
|
|
48977
49283
|
function createLoadGuidelinesTool() {
|
|
48978
|
-
return (0,
|
|
49284
|
+
return (0, import_langchain79.tool)(
|
|
48979
49285
|
async (input) => {
|
|
48980
49286
|
const result = getGuidelines(input.modules);
|
|
48981
49287
|
return result;
|
|
@@ -48989,7 +49295,7 @@ function createLoadGuidelinesTool() {
|
|
|
48989
49295
|
}
|
|
48990
49296
|
|
|
48991
49297
|
// src/tool_lattice/widget/showWidget.ts
|
|
48992
|
-
var
|
|
49298
|
+
var import_langchain80 = require("langchain");
|
|
48993
49299
|
var import_zod70 = require("zod");
|
|
48994
49300
|
function containsForbiddenTags(code) {
|
|
48995
49301
|
const forbiddenPatterns = [
|
|
@@ -49025,7 +49331,7 @@ var ShowWidgetInputSchema = import_zod70.z.object({
|
|
|
49025
49331
|
)
|
|
49026
49332
|
});
|
|
49027
49333
|
function createShowWidgetTool() {
|
|
49028
|
-
return (0,
|
|
49334
|
+
return (0, import_langchain80.tool)(
|
|
49029
49335
|
async (input) => {
|
|
49030
49336
|
if (!input.i_have_seen_guidelines) {
|
|
49031
49337
|
return "Error: You must call load_guidelines before using show_widget. Set i_have_seen_guidelines to true only after loading guidelines.";
|
|
@@ -49056,7 +49362,7 @@ function createWidgetMiddleware() {
|
|
|
49056
49362
|
createLoadGuidelinesTool(),
|
|
49057
49363
|
createShowWidgetTool()
|
|
49058
49364
|
];
|
|
49059
|
-
return (0,
|
|
49365
|
+
return (0, import_langchain81.createMiddleware)({
|
|
49060
49366
|
name: "widgetMiddleware",
|
|
49061
49367
|
contextSchema,
|
|
49062
49368
|
tools
|
|
@@ -49080,7 +49386,7 @@ var widgetPlugin = {
|
|
|
49080
49386
|
};
|
|
49081
49387
|
|
|
49082
49388
|
// src/middlewares/taskMiddleware.ts
|
|
49083
|
-
var
|
|
49389
|
+
var import_langchain82 = require("langchain");
|
|
49084
49390
|
var import_zod71 = require("zod");
|
|
49085
49391
|
var import_langgraph14 = require("@langchain/langgraph");
|
|
49086
49392
|
var import_protocols44 = require("@axiom-lattice/protocols");
|
|
@@ -51416,7 +51722,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
51416
51722
|
...trustedCaller ? { callerMembershipId: trustedCaller.membershipId, callerAssistantId: trustedCaller.assistantId } : rc.assistant_id ? { callerAssistantId: rc.assistant_id } : {}
|
|
51417
51723
|
}));
|
|
51418
51724
|
};
|
|
51419
|
-
return (0,
|
|
51725
|
+
return (0, import_langchain82.createMiddleware)({
|
|
51420
51726
|
name: "TaskMiddleware",
|
|
51421
51727
|
contextSchema,
|
|
51422
51728
|
// Persisted between invocations (ADRs: the run↔task binding survives turns).
|
|
@@ -51492,7 +51798,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
51492
51798
|
const taskId = typeof args?.taskId === "string" ? args.taskId.trim() : "";
|
|
51493
51799
|
const agentId = typeof args?.agentId === "string" ? args.agentId.trim() : "";
|
|
51494
51800
|
if (!taskId || !agentId) {
|
|
51495
|
-
return new
|
|
51801
|
+
return new import_langchain82.ToolMessage({
|
|
51496
51802
|
name: "task",
|
|
51497
51803
|
tool_call_id: request.toolCall.id ?? "task-dispatch",
|
|
51498
51804
|
status: "error",
|
|
@@ -51558,7 +51864,7 @@ ${TASK_CONVERGENCE_GUIDANCE}
|
|
|
51558
51864
|
});
|
|
51559
51865
|
},
|
|
51560
51866
|
tools: [
|
|
51561
|
-
(0,
|
|
51867
|
+
(0, import_langchain82.tool)(
|
|
51562
51868
|
handleManageTask,
|
|
51563
51869
|
{
|
|
51564
51870
|
name: "manage_task",
|
|
@@ -51604,7 +51910,7 @@ to an expert \u2014 never re-dispatch the task you are processing.`,
|
|
|
51604
51910
|
schema: manageTaskSchema
|
|
51605
51911
|
}
|
|
51606
51912
|
),
|
|
51607
|
-
(0,
|
|
51913
|
+
(0, import_langchain82.tool)(handleStartTask, {
|
|
51608
51914
|
name: "task",
|
|
51609
51915
|
description: `Start a persisted TaskItem with any existing Agent in a fresh isolated thread. This tool CANNOT create a task: create it first with \`manage_task\` action="create" (title + description), then dispatch it with \`task { taskId, agentId }\`. Do not pass action/description/title to this tool. Use this to delegate work \u2014 dispatch a subtask you created to the agent that should execute it; never re-dispatch the task you are currently processing (give the expert a child task instead). Pass agentId "general-purpose" for the general-purpose worker \u2014 ${DEFAULT_GENERAL_PURPOSE_DESCRIPTION} It has access to all the caller's tools, model, and middleware, so use it for general-purpose subtasks, to isolate context and token usage, and whenever no specialized agent fits. The target does NOT need task-management tools: it runs and returns an observation, an executionResultId, and the task's taskStatus (re-read after the worker settled). Check taskStatus before completing: if it is already 'completed' the worker finished it \u2014 do NOT complete again (use manage_task add_activity); if it is still 'in_progress' you are the single completer and pass the executionResultId to manage_task set_status completed; if it is 'failed' or 'interrupted', act on that. The caller reconciles via manage_task, which interprets the result and records the outcome. A project task instead returns a managed result (success:true, managed:true) because the project-lifecycle queue owns execution.`,
|
|
51610
51916
|
schema: startTaskSchema
|
|
@@ -51748,7 +52054,7 @@ canonical Belief State:
|
|
|
51748
52054
|
};
|
|
51749
52055
|
|
|
51750
52056
|
// src/middlewares/documentLearningMiddleware.ts
|
|
51751
|
-
var
|
|
52057
|
+
var import_langchain83 = require("langchain");
|
|
51752
52058
|
|
|
51753
52059
|
// src/middlewares/documentLearningSkills.ts
|
|
51754
52060
|
var LEARN_CAPABILITY_SKILL = `---
|
|
@@ -51987,7 +52293,7 @@ patterns discovered, recommendations. Include validation coverage: user-sample N
|
|
|
51987
52293
|
`;
|
|
51988
52294
|
|
|
51989
52295
|
// src/middlewares/documentLearningMiddleware.ts
|
|
51990
|
-
var createDocumentLearningMiddleware = () => (0,
|
|
52296
|
+
var createDocumentLearningMiddleware = () => (0, import_langchain83.createMiddleware)({
|
|
51991
52297
|
name: "DocumentLearningMiddleware",
|
|
51992
52298
|
contextSchema,
|
|
51993
52299
|
tools: []
|
|
@@ -52010,12 +52316,12 @@ var documentLearningPlugin = {
|
|
|
52010
52316
|
};
|
|
52011
52317
|
|
|
52012
52318
|
// src/middlewares/documentParserMiddleware.ts
|
|
52013
|
-
var
|
|
52319
|
+
var import_langchain85 = require("langchain");
|
|
52014
52320
|
|
|
52015
52321
|
// src/tool_lattice/document_parser/index.ts
|
|
52016
52322
|
var path7 = __toESM(require("path"));
|
|
52017
52323
|
var import_zod72 = __toESM(require("zod"));
|
|
52018
|
-
var
|
|
52324
|
+
var import_langchain84 = require("langchain");
|
|
52019
52325
|
var PARSE_DOCUMENT_DESCRIPTION = `Parse a document file (docx, pdf) into structured Markdown using a remote document parsing service.
|
|
52020
52326
|
This tool handles the full pipeline internally: file upload \u2192 document parsing \u2192 polling until complete \u2192 download result \u2192 save to filesystem.
|
|
52021
52327
|
|
|
@@ -52138,7 +52444,7 @@ function createParseDocumentTool({
|
|
|
52138
52444
|
baseUrl = "",
|
|
52139
52445
|
apiKey = ""
|
|
52140
52446
|
}) {
|
|
52141
|
-
return (0,
|
|
52447
|
+
return (0, import_langchain84.tool)(
|
|
52142
52448
|
async (input, exe_config) => {
|
|
52143
52449
|
try {
|
|
52144
52450
|
const runConfig = exe_config?.configurable?.runConfig ?? { assistant_id: "", thread_id: "" };
|
|
@@ -52675,7 +52981,7 @@ function createDocumentParserMiddleware(config) {
|
|
|
52675
52981
|
const baseUrl = config.baseUrl || "";
|
|
52676
52982
|
const apiKey = config.apiKey || "";
|
|
52677
52983
|
const connections = Array.isArray(config.connections) ? config.connections.filter((key5) => typeof key5 === "string") : [];
|
|
52678
|
-
return (0,
|
|
52984
|
+
return (0, import_langchain85.createMiddleware)({
|
|
52679
52985
|
name: "DocumentParser",
|
|
52680
52986
|
contextSchema,
|
|
52681
52987
|
tools: [createParseDocumentTool({ connectAll, connections, baseUrl, apiKey })]
|
|
@@ -52858,7 +53164,7 @@ var documentParserPlugin = {
|
|
|
52858
53164
|
// src/middlewares/projectRoomMiddleware.ts
|
|
52859
53165
|
var import_crypto10 = require("crypto");
|
|
52860
53166
|
var import_protocols47 = require("@axiom-lattice/protocols");
|
|
52861
|
-
var
|
|
53167
|
+
var import_langchain86 = require("langchain");
|
|
52862
53168
|
var import_zod73 = require("zod");
|
|
52863
53169
|
var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
|
|
52864
53170
|
var PROJECT_ROOM_POST_FAILED = "PROJECT_ROOM_POST_FAILED";
|
|
@@ -52967,10 +53273,10 @@ async function hasActiveCurrentMembership(scope) {
|
|
|
52967
53273
|
return true;
|
|
52968
53274
|
}
|
|
52969
53275
|
function createProjectRoomMiddleware() {
|
|
52970
|
-
return (0,
|
|
53276
|
+
return (0, import_langchain86.createMiddleware)({
|
|
52971
53277
|
name: "ProjectRoomMiddleware",
|
|
52972
53278
|
tools: [
|
|
52973
|
-
(0,
|
|
53279
|
+
(0, import_langchain86.tool)(async (input, config) => {
|
|
52974
53280
|
const { text } = input;
|
|
52975
53281
|
const scope = readTrustedRoomScope(config);
|
|
52976
53282
|
if (!scope) return CONTEXT_REQUIRED;
|
|
@@ -52978,7 +53284,8 @@ function createProjectRoomMiddleware() {
|
|
|
52978
53284
|
try {
|
|
52979
53285
|
const service3 = new RoomAgentMessageService({
|
|
52980
53286
|
memberships: getStoreLattice("default", "projectBotMembership").store,
|
|
52981
|
-
messages: getStoreLattice("default", "projectRoomMessage").store
|
|
53287
|
+
messages: getStoreLattice("default", "projectRoomMessage").store,
|
|
53288
|
+
onMessageCommitted: (message) => projectRoomMessageNotifier.notify(message)
|
|
52982
53289
|
});
|
|
52983
53290
|
await service3.post({
|
|
52984
53291
|
tenantId: scope.tenantId,
|
|
@@ -53001,7 +53308,7 @@ function createProjectRoomMiddleware() {
|
|
|
53001
53308
|
description: "Post a text reply to the current trusted Project Room message",
|
|
53002
53309
|
schema: postSchema
|
|
53003
53310
|
}),
|
|
53004
|
-
(0,
|
|
53311
|
+
(0, import_langchain86.tool)(async (_input, config) => {
|
|
53005
53312
|
const scope = readTrustedRoomScope(config);
|
|
53006
53313
|
if (!scope) return CONTEXT_REQUIRED;
|
|
53007
53314
|
try {
|
|
@@ -53062,16 +53369,153 @@ var projectRoomPlugin = {
|
|
|
53062
53369
|
};
|
|
53063
53370
|
|
|
53064
53371
|
// src/middlewares/sandboxPluginsMiddleware.ts
|
|
53065
|
-
var
|
|
53372
|
+
var import_langchain87 = require("langchain");
|
|
53066
53373
|
var import_zod74 = require("zod");
|
|
53067
53374
|
var import_protocols48 = require("@axiom-lattice/protocols");
|
|
53068
53375
|
|
|
53376
|
+
// src/services/PluginUiToolRunner.ts
|
|
53377
|
+
var PluginNotFoundError = class extends Error {
|
|
53378
|
+
/**
|
|
53379
|
+
* @param pluginType - Plugin type that was not found or failed validation.
|
|
53380
|
+
*/
|
|
53381
|
+
constructor(pluginType) {
|
|
53382
|
+
super(`plugin "${pluginType}" not found`);
|
|
53383
|
+
this.pluginType = pluginType;
|
|
53384
|
+
this.name = "PluginNotFoundError";
|
|
53385
|
+
}
|
|
53386
|
+
};
|
|
53387
|
+
var ToolNotFoundError = class extends Error {
|
|
53388
|
+
/**
|
|
53389
|
+
* @param toolName - Tool name that was not found.
|
|
53390
|
+
*/
|
|
53391
|
+
constructor(toolName2) {
|
|
53392
|
+
super(`tool "${toolName2}" not found`);
|
|
53393
|
+
this.toolName = toolName2;
|
|
53394
|
+
this.name = "ToolNotFoundError";
|
|
53395
|
+
}
|
|
53396
|
+
};
|
|
53397
|
+
var ToolNotUiError = class extends Error {
|
|
53398
|
+
/**
|
|
53399
|
+
* @param toolName - Tool that has no `ui` resource.
|
|
53400
|
+
*/
|
|
53401
|
+
constructor(toolName2) {
|
|
53402
|
+
super(`tool "${toolName2}" has no ui`);
|
|
53403
|
+
this.toolName = toolName2;
|
|
53404
|
+
this.name = "ToolNotUiError";
|
|
53405
|
+
}
|
|
53406
|
+
};
|
|
53407
|
+
var ScopeUnavailableError = class extends Error {
|
|
53408
|
+
/**
|
|
53409
|
+
* @param text - Redacted handler text produced before signing failed.
|
|
53410
|
+
*/
|
|
53411
|
+
constructor(text) {
|
|
53412
|
+
super("MCP UI scope is unavailable");
|
|
53413
|
+
this.text = text;
|
|
53414
|
+
this.name = "ScopeUnavailableError";
|
|
53415
|
+
}
|
|
53416
|
+
};
|
|
53417
|
+
var PluginUiToolExecutionError = class extends Error {
|
|
53418
|
+
/**
|
|
53419
|
+
* @param detail - Handler error detail.
|
|
53420
|
+
* @param text - Redacted handler text produced by the failed invocation.
|
|
53421
|
+
*/
|
|
53422
|
+
constructor(detail, text) {
|
|
53423
|
+
super(detail);
|
|
53424
|
+
this.detail = detail;
|
|
53425
|
+
this.text = text;
|
|
53426
|
+
this.name = "PluginUiToolExecutionError";
|
|
53427
|
+
}
|
|
53428
|
+
};
|
|
53429
|
+
async function runSandboxPluginUiTool(input) {
|
|
53430
|
+
const manifest = input.manifest ?? await input.catalog.getValidatedManifest(input.tenantId, input.pluginType);
|
|
53431
|
+
if (!manifest) throw new PluginNotFoundError(input.pluginType);
|
|
53432
|
+
const toolDef = manifest.tools?.find((tool68) => tool68.name === input.toolName);
|
|
53433
|
+
if (!toolDef) throw new ToolNotFoundError(input.toolName);
|
|
53434
|
+
if (!toolDef.ui?.resource) throw new ToolNotUiError(input.toolName);
|
|
53435
|
+
const executor = input.catalog.getExecutor();
|
|
53436
|
+
const result = await executor.invoke({
|
|
53437
|
+
manifest,
|
|
53438
|
+
handler: toolDef.handler,
|
|
53439
|
+
input: input.input,
|
|
53440
|
+
...input.connection === void 0 ? {} : { connection: input.connection },
|
|
53441
|
+
...input.connections === void 0 ? {} : { connections: input.connections },
|
|
53442
|
+
context: {
|
|
53443
|
+
tenantId: input.tenantId,
|
|
53444
|
+
pluginType: input.pluginType,
|
|
53445
|
+
tool: input.toolName
|
|
53446
|
+
},
|
|
53447
|
+
runConfig: input.runConfig
|
|
53448
|
+
});
|
|
53449
|
+
const redacted = input.redact ? input.redact(result) : result;
|
|
53450
|
+
const text = handlerResultText(redacted);
|
|
53451
|
+
if (!result.ok) {
|
|
53452
|
+
const detail = result.error ?? "sandbox plugin execution failed";
|
|
53453
|
+
throw new PluginUiToolExecutionError(
|
|
53454
|
+
input.redact ? input.redact(detail) : detail,
|
|
53455
|
+
text
|
|
53456
|
+
);
|
|
53457
|
+
}
|
|
53458
|
+
const scope = signMcpUiScope({
|
|
53459
|
+
tid: input.runConfig.tenantId || input.tenantId,
|
|
53460
|
+
thid: typeof input.runConfig.threadId === "string" ? input.runConfig.threadId : void 0,
|
|
53461
|
+
aid: typeof input.runConfig.assistantId === "string" ? input.runConfig.assistantId : void 0,
|
|
53462
|
+
wid: typeof input.runConfig.workspaceId === "string" ? input.runConfig.workspaceId : void 0,
|
|
53463
|
+
pid: typeof input.runConfig.projectId === "string" ? input.runConfig.projectId : void 0,
|
|
53464
|
+
plugin: input.pluginType,
|
|
53465
|
+
resource: toolDef.ui.resource,
|
|
53466
|
+
ck: input.connectionKey
|
|
53467
|
+
});
|
|
53468
|
+
if (!scope) throw new ScopeUnavailableError(text);
|
|
53469
|
+
return {
|
|
53470
|
+
text,
|
|
53471
|
+
toolResult: text,
|
|
53472
|
+
uiRef: {
|
|
53473
|
+
kind: "plugin",
|
|
53474
|
+
pluginType: input.pluginType,
|
|
53475
|
+
resource: toolDef.ui.resource,
|
|
53476
|
+
displayMode: toolDef.ui.displayMode ?? "inline",
|
|
53477
|
+
toolName: input.toolName,
|
|
53478
|
+
scope
|
|
53479
|
+
}
|
|
53480
|
+
};
|
|
53481
|
+
}
|
|
53482
|
+
|
|
53069
53483
|
// src/connection/connectionSecretFields.ts
|
|
53070
53484
|
function connectionSecretFields(plugin) {
|
|
53071
53485
|
const fields = plugin?.connection?.fields ?? [];
|
|
53072
53486
|
return fields.filter((field) => field.type === "password" || field.widget === "password").map((field) => field.key);
|
|
53073
53487
|
}
|
|
53074
53488
|
|
|
53489
|
+
// src/services/connectionSecretRedaction.ts
|
|
53490
|
+
function collectSecretValues(connection, fields) {
|
|
53491
|
+
if (!connection) return [];
|
|
53492
|
+
const values = [];
|
|
53493
|
+
for (const field of fields) {
|
|
53494
|
+
const value = connection[field];
|
|
53495
|
+
if (typeof value === "string" && value.length > 0) values.push(value);
|
|
53496
|
+
}
|
|
53497
|
+
return values;
|
|
53498
|
+
}
|
|
53499
|
+
function redactString(value, secrets) {
|
|
53500
|
+
let out = value;
|
|
53501
|
+
for (const secret of secrets) out = out.split(secret).join("[redacted]");
|
|
53502
|
+
return out;
|
|
53503
|
+
}
|
|
53504
|
+
function redactSecretValues(payload, secrets) {
|
|
53505
|
+
if (secrets.length === 0) return payload;
|
|
53506
|
+
const walk = (node) => {
|
|
53507
|
+
if (typeof node === "string") return redactString(node, secrets);
|
|
53508
|
+
if (Array.isArray(node)) return node.map(walk);
|
|
53509
|
+
if (node !== null && typeof node === "object") {
|
|
53510
|
+
const out = {};
|
|
53511
|
+
for (const [key5, value] of Object.entries(node)) out[key5] = walk(value);
|
|
53512
|
+
return out;
|
|
53513
|
+
}
|
|
53514
|
+
return node;
|
|
53515
|
+
};
|
|
53516
|
+
return walk(payload);
|
|
53517
|
+
}
|
|
53518
|
+
|
|
53075
53519
|
// src/middlewares/sandboxPluginsSkills.ts
|
|
53076
53520
|
var PLUGIN_JSON_TEMPLATE = `{
|
|
53077
53521
|
"schemaVersion": 1,
|
|
@@ -53621,6 +54065,12 @@ The official \`@modelcontextprotocol/ext-apps\` client SDK reports size
|
|
|
53621
54065
|
automatically. Otherwise the panel stays at a default height and content taller
|
|
53622
54066
|
than the host max scrolls; \`templates/ui.html\` already includes this helper.
|
|
53623
54067
|
|
|
54068
|
+
## Publishing the UI
|
|
54069
|
+
If the human explicitly asks to publish, share, or pin this UI, load
|
|
54070
|
+
\`app-share-publishing\`. Use \`publish_target\` with \`mode:"link"\` for a URL or
|
|
54071
|
+
\`mode:"menu"\` for the workspace menu; call \`list_menu_groups\` before choosing
|
|
54072
|
+
a group. MCP Apps re-run on every open.
|
|
54073
|
+
|
|
53624
54074
|
## Publishing the UI to external MCP clients
|
|
53625
54075
|
If the tool also sets \`"expose": true\`, its UI is published to Axiom's Open/MCP
|
|
53626
54076
|
surface as \`ui://<type>/<ui.resource>\`, gated by the API key's grants (item-level
|
|
@@ -53719,28 +54169,102 @@ MCP endpoint. Reach for this when a tool should orchestrate existing capabilitie
|
|
|
53719
54169
|
(read the knowledge base, create a task, invoke an agent) instead of
|
|
53720
54170
|
re-implementing them.
|
|
53721
54171
|
|
|
53722
|
-
##
|
|
53723
|
-
|
|
53724
|
-
|
|
53725
|
-
|
|
54172
|
+
## Two different keys \u2014 do not mix them
|
|
54173
|
+
|
|
54174
|
+
| Key | Where | Used for |
|
|
54175
|
+
|---|---|---|
|
|
54176
|
+
| External service key (e.g. \`boStoreKey\`) | connection config | calling your upstream service |
|
|
54177
|
+
| Platform key (e.g. \`platformApiKey\`) | connection config | calling \`/open/mcp\` |
|
|
53726
54178
|
|
|
53727
|
-
|
|
53728
|
-
|
|
53729
|
-
|
|
54179
|
+
Both are declared by **you** in \`connection.fields\`. The platform key is a normal
|
|
54180
|
+
password field; the framework does not inject or rename it. Use a password field
|
|
54181
|
+
so it is encrypted at rest, and never log or write the key from the handler.
|
|
54182
|
+
|
|
54183
|
+
## Do not use \`OPEN_API_TOKEN\` / \`fromEnv()\` here
|
|
54184
|
+
|
|
54185
|
+
\`OpenMcpClient.fromEnv()\` reads \`API_GATEWAY_URL + OPEN_API_TOKEN\`. That pair is
|
|
54186
|
+
only for agent \`code_eval\`. A plugin handler must read the platform key from
|
|
54187
|
+
\`PLUGIN_CONNECTION_FILE\` and pass it explicitly:
|
|
53730
54188
|
|
|
53731
|
-
## Discover, then call
|
|
53732
|
-
Never hardcode the tool list: the callable set is **reflected per tenant** and
|
|
53733
|
-
changes as plugins are exposed. Call \`listTools()\` at runtime.
|
|
53734
54189
|
\`\`\`js
|
|
54190
|
+
const client = new OpenMcpClient({
|
|
54191
|
+
url: process.env.API_GATEWAY_URL,
|
|
54192
|
+
token: conn.platformApiKey, // YOUR connection field
|
|
54193
|
+
});
|
|
54194
|
+
\`\`\`
|
|
54195
|
+
|
|
54196
|
+
\`OPEN_API_TOKEN\` is **not** injected for plugin handlers. If you find yourself
|
|
54197
|
+
calling \`fromEnv()\` in a plugin handler, stop and switch to the connection key.
|
|
54198
|
+
|
|
54199
|
+
## Probe first (recommended)
|
|
54200
|
+
|
|
54201
|
+
The platform key belongs to a human. Before writing the real handler:
|
|
54202
|
+
|
|
54203
|
+
1. Declare the platform-key password field in \`connection.fields\`.
|
|
54204
|
+
2. Write a temporary \`handlers/probe.js\` that reads \`PLUGIN_CONNECTION_FILE\`,
|
|
54205
|
+
creates \`OpenMcpClient\` with the connection key, and prints
|
|
54206
|
+
\`listTools()\` (name, description, inputSchema) as JSON.
|
|
54207
|
+
3. Ask the human to configure the connection + platform key (only a human can
|
|
54208
|
+
create the key). Use \`list_connections\` to check whether a connection exists.
|
|
54209
|
+
4. Run \`manage_plugin test\` with the real \`connectionKey\`, e.g.
|
|
54210
|
+
\`{ "kind": "tool", "name": "probe", "input": {}, "connectionKey": "prod" }\`.
|
|
54211
|
+
5. Read the returned tool list; use it to choose the downstream tool names and
|
|
54212
|
+
argument shapes.
|
|
54213
|
+
6. Write the real handler. Delete the probe or keep it as a debug tool.
|
|
54214
|
+
|
|
54215
|
+
A ready-to-copy probe is in \`templates/probe-handler.js\`.
|
|
54216
|
+
|
|
54217
|
+
### What the probe cannot show
|
|
54218
|
+
|
|
54219
|
+
\`listTools()\` shows the key's **tools**, not its full resource scope. The gateway
|
|
54220
|
+
enforces the key's tenant/project/selector on every call; the handler does **not**
|
|
54221
|
+
need to re-check them to call a tool.
|
|
54222
|
+
|
|
54223
|
+
Ask the human only when the plugin's behavior depends on which project/connection
|
|
54224
|
+
is used, or when a tool schema takes a \`connectionKey\` and multiple connections
|
|
54225
|
+
are possible. A key may intentionally point at another project/tenant \u2014 that is a
|
|
54226
|
+
feature, not an error. Do not guess a connection key.
|
|
54227
|
+
|
|
54228
|
+
## Worked example
|
|
54229
|
+
|
|
54230
|
+
|
|
54231
|
+
### 1. Declare the field in \`plugin.json\`
|
|
54232
|
+
|
|
54233
|
+
\`\`\`json
|
|
54234
|
+
{
|
|
54235
|
+
"connection": {
|
|
54236
|
+
"fields": [
|
|
54237
|
+
{ "key": "baseUrl", "type": "string", "title": "Upstream URL" },
|
|
54238
|
+
{ "key": "boStoreKey", "type": "password", "title": "Upstream password" },
|
|
54239
|
+
{
|
|
54240
|
+
"key": "platformApiKey",
|
|
54241
|
+
"type": "password",
|
|
54242
|
+
"widget": "password",
|
|
54243
|
+
"title": "Platform Open API Key"
|
|
54244
|
+
}
|
|
54245
|
+
]
|
|
54246
|
+
}
|
|
54247
|
+
}
|
|
54248
|
+
\`\`\`
|
|
54249
|
+
|
|
54250
|
+
### 2. Read it in the handler
|
|
54251
|
+
|
|
54252
|
+
\`\`\`js
|
|
54253
|
+
const fs = require("fs");
|
|
53735
54254
|
const { OpenMcpClient } = require("@axiom-lattice/open-mcp-client");
|
|
53736
|
-
// or require("/root/.agents/sdk/open-mcp-client/index.js") when provisioned there
|
|
53737
54255
|
|
|
53738
54256
|
async function main() {
|
|
53739
54257
|
const input = process.env.PLUGIN_INPUT_FILE
|
|
53740
|
-
? JSON.parse(
|
|
54258
|
+
? JSON.parse(fs.readFileSync(process.env.PLUGIN_INPUT_FILE, "utf8"))
|
|
53741
54259
|
: JSON.parse(process.env.PLUGIN_INPUT || "{}");
|
|
54260
|
+
const conn = JSON.parse(
|
|
54261
|
+
fs.readFileSync(process.env.PLUGIN_CONNECTION_FILE, "utf8"),
|
|
54262
|
+
).connection;
|
|
53742
54263
|
|
|
53743
|
-
const client = OpenMcpClient
|
|
54264
|
+
const client = new OpenMcpClient({
|
|
54265
|
+
url: process.env.API_GATEWAY_URL,
|
|
54266
|
+
token: conn.platformApiKey,
|
|
54267
|
+
});
|
|
53744
54268
|
const tools = await client.listTools(); // exactly what this handler may call
|
|
53745
54269
|
const kb = await client.callTool("kb_search", { collection: "docs", query: input.q });
|
|
53746
54270
|
|
|
@@ -53751,29 +54275,165 @@ main().catch((err) => {
|
|
|
53751
54275
|
});
|
|
53752
54276
|
\`\`\`
|
|
53753
54277
|
|
|
53754
|
-
|
|
53755
|
-
|
|
53756
|
-
-
|
|
53757
|
-
|
|
54278
|
+
### 3. Ask a human to configure the connection
|
|
54279
|
+
|
|
54280
|
+
- Call \`list_connections { type }\`.
|
|
54281
|
+
- If the connection or key is missing, use \`ask_user_to_clarify\`: only a human can
|
|
54282
|
+
create the platform API key and fill the connection.
|
|
54283
|
+
- Never claim PTC works until a real \`connectionKey\` test passes.
|
|
54284
|
+
|
|
54285
|
+
### 4. Test with a real connection
|
|
54286
|
+
|
|
54287
|
+
\`\`\`json
|
|
54288
|
+
{
|
|
54289
|
+
"type": "my-plugin",
|
|
54290
|
+
"target": {
|
|
54291
|
+
"kind": "tool",
|
|
54292
|
+
"name": "my_tool",
|
|
54293
|
+
"input": {},
|
|
54294
|
+
"connectionKey": "prod"
|
|
54295
|
+
}
|
|
54296
|
+
}
|
|
54297
|
+
\`\`\`
|
|
54298
|
+
|
|
54299
|
+
Use \`manage_plugin test\`. Test output redacts secret values; assert on functional
|
|
54300
|
+
output (e.g. the tool result), not on echoing the key.
|
|
54301
|
+
|
|
54302
|
+
## Checklist
|
|
54303
|
+
|
|
54304
|
+
- [ ] \`connection.fields\` declares a password field for the platform key.
|
|
54305
|
+
- [ ] handler reads \`PLUGIN_CONNECTION_FILE.connection.<field>\`.
|
|
54306
|
+
- [ ] handler constructs \`OpenMcpClient\` with \`API_GATEWAY_URL\` + that field.
|
|
54307
|
+
- [ ] \`listTools()\` is called before \`callTool()\`.
|
|
54308
|
+
- [ ] the handler never logs or writes the platform key.
|
|
54309
|
+
- [ ] the key is least-privilege and does not grant the plugin's own domain.
|
|
54310
|
+
- [ ] a probe (if needed) was used to discover tool names and args.
|
|
54311
|
+
- [ ] resident handlers do not cache the client/key.
|
|
54312
|
+
- [ ] a human configured the connection + platform key.
|
|
54313
|
+
- [ ] \`manage_plugin test\` passed with a real \`connectionKey\`.
|
|
54314
|
+
|
|
54315
|
+
## Discover, then call
|
|
54316
|
+
|
|
54317
|
+
Never hardcode the tool list: the callable set is the key's grants. Call
|
|
54318
|
+
\`listTools()\` at runtime. Tool names are \`{domain}_{action}\` (e.g. \`kb_search\`,
|
|
54319
|
+
\`task_manage_task\`); args follow the tool's \`inputSchema\`. Return the result
|
|
54320
|
+
through the normal handler envelope (\`{ ok: true, result }\`) \u2014 see
|
|
54321
|
+
\`sandbox-plugins-handlers\`.
|
|
54322
|
+
|
|
54323
|
+
## Key design
|
|
54324
|
+
|
|
54325
|
+
- Grant only the domains/actions the handler actually calls.
|
|
54326
|
+
- Do **not** grant the plugin's own domain; that enables self-recursion.
|
|
54327
|
+
- Use \`selector.connections\` when the handler must be restricted to specific
|
|
54328
|
+
connections.
|
|
54329
|
+
- Use a separate key per plugin/connection so rotate/disable and audit stay
|
|
54330
|
+
attributable.
|
|
54331
|
+
- Put the key in the connection as a password field; never log or write it.
|
|
54332
|
+
- The key's project/tenant is the project/tenant the downstream tools operate in.
|
|
54333
|
+
It may intentionally differ from the plugin's project; confirm with the human
|
|
54334
|
+
only if the plugin's semantics depend on it.
|
|
53758
54335
|
|
|
53759
54336
|
## What the handler may call
|
|
53760
|
-
|
|
53761
|
-
**
|
|
53762
|
-
|
|
53763
|
-
|
|
54337
|
+
|
|
54338
|
+
The API key carries **only its own grants**. Unlike agent \`code_eval\`, a plugin
|
|
54339
|
+
key does not automatically get the sandbox/\`kb\` defaults; grant those explicitly
|
|
54340
|
+
on the key if the handler needs them. A call outside the key's grants fails
|
|
54341
|
+
(tool-not-found or \`GRANT_DENIED\`); retrying will not help. Give the plugin a
|
|
54342
|
+
least-privilege key.
|
|
54343
|
+
|
|
54344
|
+
Resource selection is not the handler's job: Open MCP tools are already bound to
|
|
54345
|
+
their resources. A key can pin connections via \`selector.connections\` in the key
|
|
54346
|
+
editor; the handler only passes tool arguments.
|
|
54347
|
+
|
|
54348
|
+
## Multiple connections
|
|
54349
|
+
|
|
54350
|
+
- \`PLUGIN_CONNECTION_FILE\` contains \`connection\` (first selected) and
|
|
54351
|
+
\`connections\` (all selected).
|
|
54352
|
+
- If the tool schema has \`connectionKey\`, pick that entry:
|
|
54353
|
+
\`\`\`js
|
|
54354
|
+
const data = JSON.parse(fs.readFileSync(process.env.PLUGIN_CONNECTION_FILE, "utf8"));
|
|
54355
|
+
const conn = (data.connections ?? []).find((c) => c.key === input.connectionKey)?.config
|
|
54356
|
+
?? data.connection;
|
|
54357
|
+
\`\`\`
|
|
54358
|
+
- Without a \`connectionKey\` input and with multiple connections, use
|
|
54359
|
+
\`connection\` (the first) or fail with a clear message; do not silently mix
|
|
54360
|
+
credentials.
|
|
54361
|
+
- Keep the platform key consistent across the connections the handler uses.
|
|
54362
|
+
|
|
54363
|
+
## Resident deployment
|
|
54364
|
+
|
|
54365
|
+
Resident handlers run in a long-lived service, but each \`/invoke\` receives the
|
|
54366
|
+
current connection config and \`apiGatewayUrl\`. Do **not** cache
|
|
54367
|
+
\`OpenMcpClient\`, the key, or \`API_GATEWAY_URL\` at module scope; read
|
|
54368
|
+
\`PLUGIN_CONNECTION_FILE\` per invocation so rotate/disable and connection changes
|
|
54369
|
+
apply.
|
|
53764
54370
|
|
|
53765
54371
|
## Client availability
|
|
53766
|
-
|
|
53767
|
-
sandbox
|
|
53768
|
-
|
|
53769
|
-
|
|
54372
|
+
|
|
54373
|
+
The sandbox image provides \`@axiom-lattice/open-mcp-client\`; use the bare module.
|
|
54374
|
+
|
|
54375
|
+
## Error handling
|
|
54376
|
+
|
|
54377
|
+
| Symptom | Meaning | Action |
|
|
54378
|
+
|---|---|---|
|
|
54379
|
+
| \`token is required\` / \`OpenMcpConfigError\` | connection has no platform key | ask the human to configure it |
|
|
54380
|
+
| \`OpenMcpAuthError\` / 401 | key disabled, rotated, or invalid | ask the human to rotate/configure |
|
|
54381
|
+
| tool-not-found | key has no such domain/action | do not retry; fix the key grant |
|
|
54382
|
+
| \`GRANT_DENIED\` | key lacks the action | do not retry; fix the key grant |
|
|
54383
|
+
| \`CONNECTION_NOT_ALLOWED\` / \`RESOURCE_DENIED\` | \`selector.connections\` mismatch | use an allowed connection or fix the key scope |
|
|
54384
|
+
|
|
54385
|
+
## Migrating from \`OPEN_API_TOKEN\`
|
|
54386
|
+
|
|
54387
|
+
If the plugin previously called \`OpenMcpClient.fromEnv()\`:
|
|
54388
|
+
|
|
54389
|
+
1. Add a password field to \`connection.fields\` (for example \`platformApiKey\`).
|
|
54390
|
+
2. Read \`PLUGIN_CONNECTION_FILE.connection.platformApiKey\`.
|
|
54391
|
+
3. Construct \`new OpenMcpClient({ url: process.env.API_GATEWAY_URL, token: ... })\`.
|
|
54392
|
+
4. Ask the human to fill the connection key.
|
|
54393
|
+
5. Re-test with \`manage_plugin test\` + \`connectionKey\`.
|
|
54394
|
+
|
|
54395
|
+
\`fromEnv()\` still works for agent \`code_eval\`, not for plugin handlers.
|
|
53770
54396
|
|
|
53771
54397
|
## Limits
|
|
53772
|
-
|
|
53773
|
-
|
|
54398
|
+
|
|
54399
|
+
- Plugin handlers do not mint tokens; they reuse the connection key. Agent
|
|
54400
|
+
\`code_eval\` keeps the depth-limited short token path.
|
|
53774
54401
|
- Only call what \`listTools()\` returns, and handle a missing tool gracefully.
|
|
53775
54402
|
`,
|
|
53776
|
-
resources: {
|
|
54403
|
+
resources: {
|
|
54404
|
+
"templates/probe-handler.js": {
|
|
54405
|
+
content: `const fs = require("fs");
|
|
54406
|
+
const { OpenMcpClient } = require("@axiom-lattice/open-mcp-client");
|
|
54407
|
+
|
|
54408
|
+
async function main() {
|
|
54409
|
+
const conn = JSON.parse(
|
|
54410
|
+
fs.readFileSync(process.env.PLUGIN_CONNECTION_FILE, "utf8"),
|
|
54411
|
+
).connection;
|
|
54412
|
+
const client = new OpenMcpClient({
|
|
54413
|
+
url: process.env.API_GATEWAY_URL,
|
|
54414
|
+
token: conn.platformApiKey,
|
|
54415
|
+
timeoutMs: 5000,
|
|
54416
|
+
});
|
|
54417
|
+
const tools = await client.listTools();
|
|
54418
|
+
process.stdout.write(JSON.stringify({
|
|
54419
|
+
ok: true,
|
|
54420
|
+
result: tools.map((tool) => ({
|
|
54421
|
+
name: tool.name,
|
|
54422
|
+
description: tool.description,
|
|
54423
|
+
inputSchema: tool.inputSchema,
|
|
54424
|
+
})),
|
|
54425
|
+
}));
|
|
54426
|
+
}
|
|
54427
|
+
|
|
54428
|
+
main().catch((err) => {
|
|
54429
|
+
process.stdout.write(JSON.stringify({
|
|
54430
|
+
ok: false,
|
|
54431
|
+
error: String(err && err.message ? err.message : err),
|
|
54432
|
+
}));
|
|
54433
|
+
});
|
|
54434
|
+
`
|
|
54435
|
+
}
|
|
54436
|
+
}
|
|
53777
54437
|
},
|
|
53778
54438
|
"sandbox-plugins-handlers": {
|
|
53779
54439
|
version: "1.0.0",
|
|
@@ -54019,8 +54679,19 @@ Follow the authoring skill's "Decide first" steps to confirm the goal
|
|
|
54019
54679
|
(inputs/outputs). If the UI class applies, load "sandbox-plugins-ui" before
|
|
54020
54680
|
authoring it. If the tool must be callable by external MCP clients via an API key,
|
|
54021
54681
|
load "sandbox-plugins-expose" and follow it (\`expose: true\` + key grants).
|
|
54022
|
-
If
|
|
54023
|
-
"
|
|
54682
|
+
If the human asks to publish/share/pin the plugin UI, load
|
|
54683
|
+
"app-share-publishing" and use \`publish_target\`; never publish proactively.
|
|
54684
|
+
For menu mode, call \`list_menu_groups\` first and choose an existing group or
|
|
54685
|
+
confirm a new one with the human. If a tool must
|
|
54686
|
+
call the platform's own tools/agents from its handler, load
|
|
54687
|
+
"sandbox-plugins-consume-open" and follow its checklist: declare a password field
|
|
54688
|
+
in connection.fields, read it from PLUGIN_CONNECTION_FILE, construct OpenMcpClient
|
|
54689
|
+
with API_GATEWAY_URL + that field, and never use
|
|
54690
|
+
OPEN_API_TOKEN/OpenMcpClient.fromEnv() in a plugin handler. A human must
|
|
54691
|
+
configure the connection before PTC can be verified. If the key's capabilities
|
|
54692
|
+
are unknown, author a probe handler first and run manage_plugin test with a real
|
|
54693
|
+
connectionKey; use the returned listTools names/inputSchema before writing the
|
|
54694
|
+
real handler.
|
|
54024
54695
|
|
|
54025
54696
|
Design first, and iterate on it before you build \u2014 the design is a conversation, not
|
|
54026
54697
|
a one-shot. Use the \`widget\` middleware to present it (a decision surface, not a showcase):
|
|
@@ -54266,15 +54937,6 @@ function tenantIdFrom(exeConfig) {
|
|
|
54266
54937
|
const c = exeConfig;
|
|
54267
54938
|
return c?.configurable?.runConfig?.tenantId ?? "default";
|
|
54268
54939
|
}
|
|
54269
|
-
function collectSecretValues(connection, fields) {
|
|
54270
|
-
if (!connection) return [];
|
|
54271
|
-
const values = [];
|
|
54272
|
-
for (const field of fields) {
|
|
54273
|
-
const value = connection[field];
|
|
54274
|
-
if (typeof value === "string" && value.length > 0) values.push(value);
|
|
54275
|
-
}
|
|
54276
|
-
return values;
|
|
54277
|
-
}
|
|
54278
54940
|
function errorText(err) {
|
|
54279
54941
|
return err instanceof Error ? err.message : String(err);
|
|
54280
54942
|
}
|
|
@@ -54287,25 +54949,6 @@ function deploymentUnavailable(action) {
|
|
|
54287
54949
|
function deploymentsResult(payload) {
|
|
54288
54950
|
return appendUiFence(JSON.stringify(payload), SANDBOX_PLUGINS_UI_REF);
|
|
54289
54951
|
}
|
|
54290
|
-
function redactString(value, secrets) {
|
|
54291
|
-
let out = value;
|
|
54292
|
-
for (const secret of secrets) out = out.split(secret).join("[redacted]");
|
|
54293
|
-
return out;
|
|
54294
|
-
}
|
|
54295
|
-
function redactSecretValues(payload, secrets) {
|
|
54296
|
-
if (secrets.length === 0) return payload;
|
|
54297
|
-
const walk = (node) => {
|
|
54298
|
-
if (typeof node === "string") return redactString(node, secrets);
|
|
54299
|
-
if (Array.isArray(node)) return node.map(walk);
|
|
54300
|
-
if (node !== null && typeof node === "object") {
|
|
54301
|
-
const out = {};
|
|
54302
|
-
for (const [key5, value] of Object.entries(node)) out[key5] = walk(value);
|
|
54303
|
-
return out;
|
|
54304
|
-
}
|
|
54305
|
-
return node;
|
|
54306
|
-
};
|
|
54307
|
-
return walk(payload);
|
|
54308
|
-
}
|
|
54309
54952
|
var managePluginSchema = import_zod74.z.object({
|
|
54310
54953
|
action: import_zod74.z.enum([
|
|
54311
54954
|
"list",
|
|
@@ -54374,6 +55017,14 @@ var sandboxPluginsPlugin = {
|
|
|
54374
55017
|
enabled: true,
|
|
54375
55018
|
config: {}
|
|
54376
55019
|
},
|
|
55020
|
+
{
|
|
55021
|
+
id: "app-share",
|
|
55022
|
+
type: "app-share",
|
|
55023
|
+
name: "Publish",
|
|
55024
|
+
description: "Publish files or plugin UI tools as links or workspace menu items",
|
|
55025
|
+
enabled: true,
|
|
55026
|
+
config: {}
|
|
55027
|
+
},
|
|
54377
55028
|
{
|
|
54378
55029
|
id: "skill",
|
|
54379
55030
|
type: "skill",
|
|
@@ -54425,10 +55076,10 @@ var sandboxPluginsPlugin = {
|
|
|
54425
55076
|
]
|
|
54426
55077
|
}
|
|
54427
55078
|
},
|
|
54428
|
-
middleware: () => (0,
|
|
55079
|
+
middleware: () => (0, import_langchain87.createMiddleware)({
|
|
54429
55080
|
name: "SandboxPluginsMiddleware",
|
|
54430
55081
|
tools: [
|
|
54431
|
-
(0,
|
|
55082
|
+
(0, import_langchain87.tool)(
|
|
54432
55083
|
async (input, exeConfig) => {
|
|
54433
55084
|
const tenantId2 = tenantIdFrom(exeConfig);
|
|
54434
55085
|
const catalog2 = getSandboxPluginCatalog();
|
|
@@ -54586,14 +55237,9 @@ var sandboxPluginsPlugin = {
|
|
|
54586
55237
|
}
|
|
54587
55238
|
}
|
|
54588
55239
|
const executor = catalog2.getExecutor();
|
|
54589
|
-
const
|
|
54590
|
-
|
|
54591
|
-
|
|
54592
|
-
parsedManifest = JSON.parse(manifestContent);
|
|
54593
|
-
} catch {
|
|
54594
|
-
return JSON.stringify({ error: "plugin.json is not valid JSON" });
|
|
54595
|
-
}
|
|
54596
|
-
const toolDef = (parsedManifest.tools ?? []).find((t) => t.name === input.target?.name);
|
|
55240
|
+
const manifest = await catalog2.getValidatedManifest(tenantId2, input.type);
|
|
55241
|
+
if (!manifest) return `plugin "${input.type}" not found`;
|
|
55242
|
+
const toolDef = (manifest.tools ?? []).find((t) => t.name === input.target?.name);
|
|
54597
55243
|
if (!toolDef) return `tool "${input.target.name ?? ""}" not found`;
|
|
54598
55244
|
const runConfig = {
|
|
54599
55245
|
...sandboxRunConfigFrom(exeConfig),
|
|
@@ -54605,38 +55251,55 @@ var sandboxPluginsPlugin = {
|
|
|
54605
55251
|
runConfig
|
|
54606
55252
|
) : {};
|
|
54607
55253
|
const secrets = collectSecretValues(resolved.connection, connectionSecretFields(plugin));
|
|
55254
|
+
const ui = toolDef.ui;
|
|
55255
|
+
if (!ui?.resource) {
|
|
55256
|
+
try {
|
|
55257
|
+
const result = await executor.invoke({
|
|
55258
|
+
manifest,
|
|
55259
|
+
handler: toolDef.handler,
|
|
55260
|
+
input: input.target.input ?? null,
|
|
55261
|
+
connection: resolved.connection,
|
|
55262
|
+
connections: resolved.connections,
|
|
55263
|
+
context: { tenantId: tenantId2, pluginType: input.type, tool: toolDef.name },
|
|
55264
|
+
runConfig
|
|
55265
|
+
});
|
|
55266
|
+
return handlerResultText(redactSecretValues(result, secrets));
|
|
55267
|
+
} catch (err) {
|
|
55268
|
+
return JSON.stringify(redactSecretValues({ ok: false, error: errorText(err) }, secrets));
|
|
55269
|
+
}
|
|
55270
|
+
}
|
|
55271
|
+
const uiRefWithoutScope = {
|
|
55272
|
+
kind: "plugin",
|
|
55273
|
+
pluginType: input.type,
|
|
55274
|
+
resource: ui.resource,
|
|
55275
|
+
displayMode: ui.displayMode ?? "inline",
|
|
55276
|
+
toolName: toolDef.name
|
|
55277
|
+
};
|
|
54608
55278
|
try {
|
|
54609
|
-
const
|
|
54610
|
-
|
|
54611
|
-
|
|
55279
|
+
const run = await runSandboxPluginUiTool({
|
|
55280
|
+
tenantId: tenantId2,
|
|
55281
|
+
pluginType: input.type,
|
|
55282
|
+
toolName: toolDef.name,
|
|
54612
55283
|
input: input.target.input ?? null,
|
|
55284
|
+
runConfig,
|
|
54613
55285
|
connection: resolved.connection,
|
|
54614
55286
|
connections: resolved.connections,
|
|
54615
|
-
|
|
54616
|
-
|
|
55287
|
+
connectionKey: resolved.connections?.[0]?.key,
|
|
55288
|
+
catalog: catalog2,
|
|
55289
|
+
manifest,
|
|
55290
|
+
redact: (value) => redactSecretValues(value, secrets)
|
|
54617
55291
|
});
|
|
54618
|
-
|
|
54619
|
-
const ui = toolDef.ui;
|
|
54620
|
-
if (!ui?.resource) return text;
|
|
54621
|
-
const scope = result.ok && ui?.resource ? signMcpUiScope({
|
|
54622
|
-
tid: runConfig.tenantId || tenantId2,
|
|
54623
|
-
thid: runConfig.threadId,
|
|
54624
|
-
aid: runConfig.assistantId,
|
|
54625
|
-
wid: runConfig.workspaceId,
|
|
54626
|
-
pid: runConfig.projectId,
|
|
54627
|
-
plugin: input.type,
|
|
54628
|
-
resource: ui.resource,
|
|
54629
|
-
ck: resolved.connections?.[0]?.key
|
|
54630
|
-
}) : void 0;
|
|
54631
|
-
const uiRef = {
|
|
54632
|
-
kind: "plugin",
|
|
54633
|
-
pluginType: input.type,
|
|
54634
|
-
resource: ui.resource,
|
|
54635
|
-
displayMode: ui.displayMode ?? "inline",
|
|
54636
|
-
...scope ? { scope } : {}
|
|
54637
|
-
};
|
|
54638
|
-
return appendUiFence(text, uiRef);
|
|
55292
|
+
return appendUiFence(run.text, run.uiRef);
|
|
54639
55293
|
} catch (err) {
|
|
55294
|
+
if (err instanceof ToolNotFoundError) {
|
|
55295
|
+
return `tool "${input.target.name ?? ""}" not found`;
|
|
55296
|
+
}
|
|
55297
|
+
if (err instanceof PluginUiToolExecutionError) {
|
|
55298
|
+
return appendUiFence(err.text ?? "", uiRefWithoutScope);
|
|
55299
|
+
}
|
|
55300
|
+
if (err instanceof ScopeUnavailableError) {
|
|
55301
|
+
return appendUiFence(err.text ?? "", uiRefWithoutScope);
|
|
55302
|
+
}
|
|
54640
55303
|
return JSON.stringify(redactSecretValues({ ok: false, error: errorText(err) }, secrets));
|
|
54641
55304
|
}
|
|
54642
55305
|
}
|
|
@@ -54715,9 +55378,745 @@ var sandboxPluginsPlugin = {
|
|
|
54715
55378
|
})
|
|
54716
55379
|
};
|
|
54717
55380
|
|
|
54718
|
-
// src/middlewares/
|
|
54719
|
-
var
|
|
55381
|
+
// src/middlewares/appShareMiddleware.ts
|
|
55382
|
+
var import_langchain88 = require("langchain");
|
|
55383
|
+
|
|
55384
|
+
// src/middlewares/appShareTargets.ts
|
|
54720
55385
|
var import_zod75 = require("zod");
|
|
55386
|
+
|
|
55387
|
+
// src/middlewares/appShareUi.ts
|
|
55388
|
+
var SHARE_CARD_UI_RESOURCE = "ui://app-share/share-card";
|
|
55389
|
+
var SHARE_CARD_APP_HTML = `<!doctype html>
|
|
55390
|
+
<html lang="en">
|
|
55391
|
+
<head>
|
|
55392
|
+
<meta charset="utf-8" />
|
|
55393
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
55394
|
+
<title>Shared link</title>
|
|
55395
|
+
<style>
|
|
55396
|
+
:root {
|
|
55397
|
+
color-scheme: light dark;
|
|
55398
|
+
--card-bg: #fff;
|
|
55399
|
+
--card-border: #e5e7eb;
|
|
55400
|
+
--text: #111827;
|
|
55401
|
+
--muted: #6b7280;
|
|
55402
|
+
--accent: #4338ca;
|
|
55403
|
+
--accent-bg: #eef2ff;
|
|
55404
|
+
--warning: #b45309;
|
|
55405
|
+
--btn-bg: #fff;
|
|
55406
|
+
--btn-border: #d1d5db;
|
|
55407
|
+
--btn-text: #111827;
|
|
55408
|
+
--primary-bg: #4f46e5;
|
|
55409
|
+
--primary-border: #4f46e5;
|
|
55410
|
+
--primary-text: #fff;
|
|
55411
|
+
--shadow: 0 1px 2px rgba(0,0,0,.04);
|
|
55412
|
+
}
|
|
55413
|
+
@media (prefers-color-scheme: dark) {
|
|
55414
|
+
:root {
|
|
55415
|
+
--card-bg: #111827;
|
|
55416
|
+
--card-border: #374151;
|
|
55417
|
+
--text: #f9fafb;
|
|
55418
|
+
--muted: #9ca3af;
|
|
55419
|
+
--accent: #c7d2fe;
|
|
55420
|
+
--accent-bg: #312e81;
|
|
55421
|
+
--warning: #fbbf24;
|
|
55422
|
+
--btn-bg: #1f2937;
|
|
55423
|
+
--btn-border: #4b5563;
|
|
55424
|
+
--btn-text: #f9fafb;
|
|
55425
|
+
--primary-bg: #6366f1;
|
|
55426
|
+
--primary-border: #6366f1;
|
|
55427
|
+
--primary-text: #fff;
|
|
55428
|
+
--shadow: 0 1px 2px rgba(0,0,0,.4);
|
|
55429
|
+
}
|
|
55430
|
+
}
|
|
55431
|
+
body { margin: 0; padding: 12px 14px; font: 13px/1.45 Inter, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: transparent; }
|
|
55432
|
+
.card { box-sizing: border-box; max-width: 420px; margin: 0 auto; padding: 14px 16px; border: 1px solid var(--card-border); border-radius: 14px; background: var(--card-bg); color: var(--text); box-shadow: var(--shadow); }
|
|
55433
|
+
.head { display: flex; align-items: center; gap: 8px; }
|
|
55434
|
+
.icon { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-bg); color: var(--accent); display: grid; place-items: center; font-size: 14px; }
|
|
55435
|
+
.title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
|
|
55436
|
+
.kind { border-radius: 999px; font-size: 11px; padding: 1px 7px; background: var(--accent-bg); color: var(--accent); }
|
|
55437
|
+
.meta { margin: 4px 0 8px; color: var(--muted); font-size: 11px; }
|
|
55438
|
+
.link { padding: 7px 9px; border: 1px solid var(--card-border); border-radius: 8px; color: var(--text); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
|
|
55439
|
+
.link:focus-visible { outline: 2px solid var(--primary-bg); outline-offset: 2px; }
|
|
55440
|
+
.pwd { margin-top: 6px; color: var(--muted); font-size: 12px; }
|
|
55441
|
+
.warn { margin-top: 6px; color: var(--warning); font-size: 11px; overflow-wrap: anywhere; }
|
|
55442
|
+
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
|
|
55443
|
+
button { border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-text); border-radius: 8px; padding: 5px 10px; font: inherit; cursor: pointer; }
|
|
55444
|
+
button.primary { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary-text); }
|
|
55445
|
+
</style>
|
|
55446
|
+
</head>
|
|
55447
|
+
<body>
|
|
55448
|
+
<div id="root"><p>Loading\u2026</p></div>
|
|
55449
|
+
<script>
|
|
55450
|
+
(function () {
|
|
55451
|
+
var root = document.getElementById("root");
|
|
55452
|
+
function post(message) { window.parent.postMessage(message, "*"); }
|
|
55453
|
+
function notify(method, params) { post({ jsonrpc: "2.0", method: method, params: params }); }
|
|
55454
|
+
var nextId = 1;
|
|
55455
|
+
function rpc(method, params) {
|
|
55456
|
+
var id = nextId++;
|
|
55457
|
+
return new Promise(function (resolve, reject) {
|
|
55458
|
+
function onMessage(event) {
|
|
55459
|
+
var data = event.data;
|
|
55460
|
+
if (!data || data.id !== id) return;
|
|
55461
|
+
window.removeEventListener("message", onMessage);
|
|
55462
|
+
if (data.error) reject(new Error((data.error && data.error.message) || "rpc error"));
|
|
55463
|
+
else resolve(data.result);
|
|
55464
|
+
}
|
|
55465
|
+
window.addEventListener("message", onMessage);
|
|
55466
|
+
post({ jsonrpc: "2.0", id: id, method: method, params: params });
|
|
55467
|
+
});
|
|
55468
|
+
}
|
|
55469
|
+
function sendSize() {
|
|
55470
|
+
notify("ui/notifications/size-changed", {
|
|
55471
|
+
width: Math.ceil(document.documentElement.scrollWidth || document.body.scrollWidth),
|
|
55472
|
+
height: Math.ceil(document.documentElement.scrollHeight || document.body.scrollHeight),
|
|
55473
|
+
});
|
|
55474
|
+
}
|
|
55475
|
+
var ZH = (navigator.language || "").toLowerCase().indexOf("zh") === 0;
|
|
55476
|
+
var COPY = ZH
|
|
55477
|
+
? { copy: "\u590D\u5236", copyLink: "\u590D\u5236\u94FE\u63A5", open: "\u6253\u5F00", kindApp: "\u5E94\u7528", kindFile: "\u6587\u4EF6", password: "\u53E3\u4EE4\uFF1A", publicTag: "\u516C\u5F00", passwordTag: "\u53E3\u4EE4", unavailable: "\u5206\u4EAB\u6570\u636E\u4E0D\u53EF\u7528\u3002", failed: "\u521D\u59CB\u5316\u5931\u8D25\uFF1A" }
|
|
55478
|
+
: { copy: "Copy", copyLink: "Copy link", open: "Open", kindApp: "App", kindFile: "File", password: "Password: ", publicTag: "Public", passwordTag: "Password", unavailable: "Share data unavailable.", failed: "Failed to initialize: " };
|
|
55479
|
+
function esc(v) {
|
|
55480
|
+
return String(v == null ? "" : v).replace(/[&<>"']/g, function (ch) {
|
|
55481
|
+
return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[ch];
|
|
55482
|
+
});
|
|
55483
|
+
}
|
|
55484
|
+
function readResult(params) {
|
|
55485
|
+
if (!params || typeof params !== "object") return null;
|
|
55486
|
+
if (params.structuredContent && typeof params.structuredContent === "object") return params.structuredContent;
|
|
55487
|
+
var content = params.content;
|
|
55488
|
+
var text = content && content[0] && typeof content[0].text === "string" ? content[0].text : "";
|
|
55489
|
+
if (!text) return null;
|
|
55490
|
+
try { return JSON.parse(text); } catch (err) { return null; }
|
|
55491
|
+
}
|
|
55492
|
+
function render(data) {
|
|
55493
|
+
if (!data) { root.innerHTML = "<p>" + COPY.unavailable + "</p>"; sendSize(); return; }
|
|
55494
|
+
var title = data.title || "Published link";
|
|
55495
|
+
var full = data.url || data.path;
|
|
55496
|
+
var html = '<div class="card">';
|
|
55497
|
+
html += '<div class="head"><span class="icon" aria-hidden="true">\u2197</span><span class="title" title="' + esc(title) + '">' + esc(title) + '</span><span class="kind">' + (data.kind === "file" ? COPY.kindFile : COPY.kindApp) + '</span></div>';
|
|
55498
|
+
html += '<div class="meta">' + (data.visibility === "password" ? COPY.passwordTag : COPY.publicTag) + "</div>";
|
|
55499
|
+
html += '<div class="link" role="button" tabindex="0" aria-label="' + esc(COPY.copyLink) + '" title="' + esc(full) + '">' + esc(full) + "</div>";
|
|
55500
|
+
if (data.password) html += '<div class="pwd">' + COPY.password + esc(data.password) + "</div>";
|
|
55501
|
+
if (data.warnings && data.warnings.length) {
|
|
55502
|
+
var warning = data.warnings.join(" ");
|
|
55503
|
+
html += '<div class="warn" title="' + esc(warning) + '">' + esc(warning) + "</div>";
|
|
55504
|
+
}
|
|
55505
|
+
html += '<div class="actions">';
|
|
55506
|
+
html += '<button id="copy" aria-label="' + esc(COPY.copy) + '">' + COPY.copy + "</button>";
|
|
55507
|
+
html += '<button id="open" class="primary" aria-label="' + esc(COPY.open) + '">' + COPY.open + "</button>";
|
|
55508
|
+
html += "</div></div>";
|
|
55509
|
+
root.innerHTML = html;
|
|
55510
|
+
function copyLink() {
|
|
55511
|
+
rpc("ui/copy-link", {
|
|
55512
|
+
title: data.title,
|
|
55513
|
+
url: data.url || data.path,
|
|
55514
|
+
password: data.password,
|
|
55515
|
+
passwordLabel: COPY.password
|
|
55516
|
+
}).catch(function () {});
|
|
55517
|
+
}
|
|
55518
|
+
var link = document.querySelector(".link");
|
|
55519
|
+
link.onclick = copyLink;
|
|
55520
|
+
link.onkeydown = function (event) {
|
|
55521
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
55522
|
+
event.preventDefault();
|
|
55523
|
+
copyLink();
|
|
55524
|
+
}
|
|
55525
|
+
};
|
|
55526
|
+
document.getElementById("copy").onclick = copyLink;
|
|
55527
|
+
document.getElementById("open").onclick = function () {
|
|
55528
|
+
rpc("ui/open-link", { url: data.url || data.path }).catch(function () {});
|
|
55529
|
+
};
|
|
55530
|
+
sendSize();
|
|
55531
|
+
}
|
|
55532
|
+
window.addEventListener("message", function (event) {
|
|
55533
|
+
var data = event.data;
|
|
55534
|
+
if (!data || typeof data !== "object" || typeof data.method !== "string") return;
|
|
55535
|
+
if (data.method === "ui/notifications/tool-result") render(readResult(data.params));
|
|
55536
|
+
});
|
|
55537
|
+
if (typeof ResizeObserver !== "undefined") new ResizeObserver(sendSize).observe(document.documentElement);
|
|
55538
|
+
else window.addEventListener("resize", sendSize);
|
|
55539
|
+
rpc("ui/initialize", {
|
|
55540
|
+
protocolVersion: "2025-06-18",
|
|
55541
|
+
capabilities: {},
|
|
55542
|
+
clientInfo: { name: "app-share-card", version: "1.0.0" },
|
|
55543
|
+
appCapabilities: { availableDisplayModes: ["inline"] },
|
|
55544
|
+
}).then(function () {
|
|
55545
|
+
notify("ui/notifications/initialized", {});
|
|
55546
|
+
sendSize();
|
|
55547
|
+
}).catch(function (err) {
|
|
55548
|
+
root.innerHTML = "<p>" + COPY.failed + esc((err && err.message) || err) + "</p>";
|
|
55549
|
+
sendSize();
|
|
55550
|
+
});
|
|
55551
|
+
})();
|
|
55552
|
+
</script>
|
|
55553
|
+
</body>
|
|
55554
|
+
</html>`;
|
|
55555
|
+
|
|
55556
|
+
// src/middlewares/appShareTargets.ts
|
|
55557
|
+
var fileTargetSchema = import_zod75.z.object({
|
|
55558
|
+
kind: import_zod75.z.literal("file"),
|
|
55559
|
+
path: import_zod75.z.string().min(1)
|
|
55560
|
+
});
|
|
55561
|
+
var mcpAppTargetSchema = import_zod75.z.object({
|
|
55562
|
+
kind: import_zod75.z.literal("mcpApp"),
|
|
55563
|
+
pluginType: import_zod75.z.string().min(1),
|
|
55564
|
+
toolName: import_zod75.z.string().min(1),
|
|
55565
|
+
input: import_zod75.z.record(import_zod75.z.unknown()).optional(),
|
|
55566
|
+
connectionKey: import_zod75.z.string().min(1).optional()
|
|
55567
|
+
});
|
|
55568
|
+
var targetSchema = import_zod75.z.discriminatedUnion("kind", [
|
|
55569
|
+
fileTargetSchema,
|
|
55570
|
+
mcpAppTargetSchema
|
|
55571
|
+
]);
|
|
55572
|
+
var publishTargetSchema = import_zod75.z.discriminatedUnion("mode", [
|
|
55573
|
+
import_zod75.z.object({
|
|
55574
|
+
mode: import_zod75.z.literal("link"),
|
|
55575
|
+
target: targetSchema,
|
|
55576
|
+
visibility: import_zod75.z.enum(["public", "password"]),
|
|
55577
|
+
password: import_zod75.z.string().min(1).max(1024).optional(),
|
|
55578
|
+
title: import_zod75.z.string().min(1).max(256).optional(),
|
|
55579
|
+
expiresInMinutes: import_zod75.z.number().int().positive().max(525600).optional(),
|
|
55580
|
+
maxAccess: import_zod75.z.number().int().positive().optional()
|
|
55581
|
+
}),
|
|
55582
|
+
import_zod75.z.object({
|
|
55583
|
+
mode: import_zod75.z.literal("menu"),
|
|
55584
|
+
target: targetSchema,
|
|
55585
|
+
name: import_zod75.z.string().min(1).max(256).optional(),
|
|
55586
|
+
group: import_zod75.z.string().min(1).max(128).optional()
|
|
55587
|
+
})
|
|
55588
|
+
]).superRefine((value, ctx) => {
|
|
55589
|
+
if (value.mode !== "link") return;
|
|
55590
|
+
if (value.visibility === "password" && !value.password) {
|
|
55591
|
+
ctx.addIssue({
|
|
55592
|
+
code: import_zod75.z.ZodIssueCode.custom,
|
|
55593
|
+
path: ["password"],
|
|
55594
|
+
message: "password is required when visibility is password"
|
|
55595
|
+
});
|
|
55596
|
+
}
|
|
55597
|
+
if (value.visibility === "public" && value.password) {
|
|
55598
|
+
ctx.addIssue({
|
|
55599
|
+
code: import_zod75.z.ZodIssueCode.custom,
|
|
55600
|
+
path: ["password"],
|
|
55601
|
+
message: "password must not be provided when visibility is public"
|
|
55602
|
+
});
|
|
55603
|
+
}
|
|
55604
|
+
});
|
|
55605
|
+
var listMenuGroupsSchema = import_zod75.z.object({});
|
|
55606
|
+
function menuRegistry() {
|
|
55607
|
+
return getStoreLattice("default", "menu").store;
|
|
55608
|
+
}
|
|
55609
|
+
async function listMenuGroupsHandler(_input, exeConfig) {
|
|
55610
|
+
const tenantId2 = sandboxRunConfigFrom(exeConfig).tenantId;
|
|
55611
|
+
if (!tenantId2) return JSON.stringify({ error: "USER_REQUIRED" });
|
|
55612
|
+
let menu;
|
|
55613
|
+
try {
|
|
55614
|
+
menu = menuRegistry();
|
|
55615
|
+
} catch {
|
|
55616
|
+
return JSON.stringify({ error: "MENU_STORE_UNAVAILABLE" });
|
|
55617
|
+
}
|
|
55618
|
+
let items;
|
|
55619
|
+
try {
|
|
55620
|
+
items = await menu.list({ tenantId: tenantId2, menuTarget: "workspace" });
|
|
55621
|
+
} catch {
|
|
55622
|
+
return JSON.stringify({ error: "MENU_LIST_FAILED" });
|
|
55623
|
+
}
|
|
55624
|
+
const counts = /* @__PURE__ */ new Map();
|
|
55625
|
+
let ungroupedCount = 0;
|
|
55626
|
+
for (const item of items) {
|
|
55627
|
+
const group = typeof item.group === "string" ? item.group.trim() : "";
|
|
55628
|
+
if (!group) {
|
|
55629
|
+
ungroupedCount += 1;
|
|
55630
|
+
continue;
|
|
55631
|
+
}
|
|
55632
|
+
counts.set(group, (counts.get(group) ?? 0) + 1);
|
|
55633
|
+
}
|
|
55634
|
+
const groups = [...counts.entries()].map(([name, itemCount]) => ({ name, itemCount })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
55635
|
+
return JSON.stringify({ groups, ungroupedCount });
|
|
55636
|
+
}
|
|
55637
|
+
var SHARE_CARD_UI_REF = {
|
|
55638
|
+
kind: "plugin",
|
|
55639
|
+
pluginType: "app-share",
|
|
55640
|
+
resource: SHARE_CARD_UI_RESOURCE,
|
|
55641
|
+
displayMode: "inline",
|
|
55642
|
+
title: "Published link"
|
|
55643
|
+
};
|
|
55644
|
+
function runConfigOf(exeConfig) {
|
|
55645
|
+
return exeConfig?.configurable?.runConfig ?? {};
|
|
55646
|
+
}
|
|
55647
|
+
function createdByOf(raw) {
|
|
55648
|
+
return typeof raw.user_id === "string" && raw.user_id.length > 0 ? raw.user_id : typeof raw.userId === "string" && raw.userId.length > 0 ? raw.userId : "";
|
|
55649
|
+
}
|
|
55650
|
+
function basename6(path8) {
|
|
55651
|
+
return path8.replace(/\/+$/, "").split("/").pop() || path8;
|
|
55652
|
+
}
|
|
55653
|
+
function normalizeProjectPath(path8) {
|
|
55654
|
+
const withoutLeadingSlash = path8.startsWith("/") ? path8.slice(1) : path8;
|
|
55655
|
+
const segments = withoutLeadingSlash.split("/");
|
|
55656
|
+
if (segments.some((segment) => segment === "..")) return null;
|
|
55657
|
+
const cleaned = segments.filter(
|
|
55658
|
+
(segment) => segment !== "" && segment !== "."
|
|
55659
|
+
);
|
|
55660
|
+
if (cleaned[0] === "project") cleaned.shift();
|
|
55661
|
+
if (cleaned.length === 0) return null;
|
|
55662
|
+
return cleaned.join("/");
|
|
55663
|
+
}
|
|
55664
|
+
function linkResult(input) {
|
|
55665
|
+
const path8 = `/s/${input.token}`;
|
|
55666
|
+
const envBase = process.env.AXIOM_PUBLIC_BASE_URL?.replace(/\/$/, "");
|
|
55667
|
+
const result = {
|
|
55668
|
+
mode: "link",
|
|
55669
|
+
kind: input.kind,
|
|
55670
|
+
token: input.token,
|
|
55671
|
+
path: path8,
|
|
55672
|
+
...envBase ? { url: `${envBase}${path8}` } : {},
|
|
55673
|
+
title: input.title,
|
|
55674
|
+
visibility: input.visibility,
|
|
55675
|
+
...input.password ? { password: input.password } : {},
|
|
55676
|
+
...input.warnings ? { warnings: input.warnings } : {}
|
|
55677
|
+
};
|
|
55678
|
+
const text = JSON.stringify(result).replace(/`/g, "\\u0060");
|
|
55679
|
+
return appendUiFence(text, SHARE_CARD_UI_REF);
|
|
55680
|
+
}
|
|
55681
|
+
async function resolvePluginTarget(input, raw, tenantId2) {
|
|
55682
|
+
const catalog2 = getSandboxPluginCatalog();
|
|
55683
|
+
const loaded = await catalog2.ensureLoaded(tenantId2);
|
|
55684
|
+
const plugin = loaded.plugins.find((p) => p.meta.type === input.pluginType);
|
|
55685
|
+
if (!plugin) return { error: "TOOL_NOT_FOUND" };
|
|
55686
|
+
const manifest = await catalog2.getValidatedManifest(tenantId2, input.pluginType);
|
|
55687
|
+
const toolDef = manifest?.tools?.find((t) => t.name === input.toolName);
|
|
55688
|
+
if (!toolDef) return { error: "TOOL_NOT_FOUND" };
|
|
55689
|
+
if (!toolDef.ui?.resource) return { error: "TOOL_NOT_UI" };
|
|
55690
|
+
let connectionKey = input.connectionKey;
|
|
55691
|
+
if (plugin.connection || input.connectionKey) {
|
|
55692
|
+
const connections = await resolvePluginConnections(
|
|
55693
|
+
input.pluginType,
|
|
55694
|
+
input.connectionKey ? { connections: [input.connectionKey] } : { connectAll: true },
|
|
55695
|
+
{ tenantId: tenantId2 }
|
|
55696
|
+
);
|
|
55697
|
+
if (input.connectionKey && connections.length === 0) {
|
|
55698
|
+
return { error: "CONNECTION_NOT_FOUND" };
|
|
55699
|
+
}
|
|
55700
|
+
if (!input.connectionKey && plugin.connection && connections.length === 0) {
|
|
55701
|
+
return { error: "CONNECTION_REQUIRED" };
|
|
55702
|
+
}
|
|
55703
|
+
if (!input.connectionKey && plugin.connection && connections.length > 1) {
|
|
55704
|
+
return { error: "CONNECTION_AMBIGUOUS", keys: connections.map((c) => c.key) };
|
|
55705
|
+
}
|
|
55706
|
+
connectionKey = input.connectionKey ?? connections[0]?.key;
|
|
55707
|
+
}
|
|
55708
|
+
const scope = signMcpUiScope({
|
|
55709
|
+
tid: tenantId2,
|
|
55710
|
+
thid: typeof raw.thread_id === "string" ? raw.thread_id : void 0,
|
|
55711
|
+
aid: typeof raw.assistant_id === "string" ? raw.assistant_id : void 0,
|
|
55712
|
+
wid: typeof raw.workspaceId === "string" ? raw.workspaceId : void 0,
|
|
55713
|
+
pid: typeof raw.projectId === "string" ? raw.projectId : void 0,
|
|
55714
|
+
plugin: input.pluginType,
|
|
55715
|
+
resource: toolDef.ui.resource,
|
|
55716
|
+
ck: connectionKey
|
|
55717
|
+
});
|
|
55718
|
+
if (!scope) return { error: "SCOPE_UNAVAILABLE" };
|
|
55719
|
+
return {
|
|
55720
|
+
scope,
|
|
55721
|
+
resource: toolDef.ui.resource,
|
|
55722
|
+
displayMode: toolDef.ui.displayMode ?? "inline",
|
|
55723
|
+
toolName: input.toolName
|
|
55724
|
+
};
|
|
55725
|
+
}
|
|
55726
|
+
var MENU_TOOL_INPUT_MAX_BYTES = 256 * 1024;
|
|
55727
|
+
var MENU_MCP_WARNING = "menu pins are tenant-visible and reuse the selected connection";
|
|
55728
|
+
function matchesScope(cfg, workspaceId, projectId) {
|
|
55729
|
+
return String(cfg.workspaceId ?? "") === workspaceId && String(cfg.projectId ?? "") === projectId;
|
|
55730
|
+
}
|
|
55731
|
+
async function publishMenu(input, raw, ctx) {
|
|
55732
|
+
let menu;
|
|
55733
|
+
try {
|
|
55734
|
+
menu = menuRegistry();
|
|
55735
|
+
} catch {
|
|
55736
|
+
return JSON.stringify({ error: "MENU_STORE_UNAVAILABLE" });
|
|
55737
|
+
}
|
|
55738
|
+
let contentType;
|
|
55739
|
+
let contentConfig;
|
|
55740
|
+
let defaultName;
|
|
55741
|
+
if (input.target.kind === "file") {
|
|
55742
|
+
const resourcePath = normalizeProjectPath(input.target.path);
|
|
55743
|
+
if (resourcePath === null) {
|
|
55744
|
+
return JSON.stringify({ error: "INVALID_TARGET" });
|
|
55745
|
+
}
|
|
55746
|
+
contentType = "file";
|
|
55747
|
+
defaultName = basename6(resourcePath);
|
|
55748
|
+
contentConfig = {
|
|
55749
|
+
resourcePath,
|
|
55750
|
+
fileName: defaultName,
|
|
55751
|
+
tenantId: ctx.tenantId,
|
|
55752
|
+
workspaceId: ctx.workspaceId,
|
|
55753
|
+
projectId: ctx.projectId,
|
|
55754
|
+
...typeof raw.assistant_id === "string" ? { assistantId: raw.assistant_id } : {}
|
|
55755
|
+
};
|
|
55756
|
+
} else {
|
|
55757
|
+
const toolInput = input.target.input ?? {};
|
|
55758
|
+
if (Buffer.byteLength(JSON.stringify(toolInput), "utf8") > MENU_TOOL_INPUT_MAX_BYTES) {
|
|
55759
|
+
return JSON.stringify({ error: "PAYLOAD_TOO_LARGE" });
|
|
55760
|
+
}
|
|
55761
|
+
let resolved;
|
|
55762
|
+
try {
|
|
55763
|
+
const outcome = await resolvePluginTarget(input.target, raw, ctx.tenantId);
|
|
55764
|
+
if ("error" in outcome) return JSON.stringify(outcome);
|
|
55765
|
+
resolved = outcome;
|
|
55766
|
+
} catch {
|
|
55767
|
+
return JSON.stringify({ error: "MENU_PIN_FAILED" });
|
|
55768
|
+
}
|
|
55769
|
+
contentType = "mcpApp";
|
|
55770
|
+
defaultName = resolved.toolName;
|
|
55771
|
+
contentConfig = {
|
|
55772
|
+
kind: "plugin",
|
|
55773
|
+
pluginType: input.target.pluginType,
|
|
55774
|
+
resource: resolved.resource,
|
|
55775
|
+
scope: resolved.scope,
|
|
55776
|
+
displayMode: resolved.displayMode,
|
|
55777
|
+
toolName: resolved.toolName,
|
|
55778
|
+
toolInput,
|
|
55779
|
+
workspaceId: ctx.workspaceId,
|
|
55780
|
+
projectId: ctx.projectId
|
|
55781
|
+
};
|
|
55782
|
+
}
|
|
55783
|
+
let items;
|
|
55784
|
+
try {
|
|
55785
|
+
items = await menu.list({ tenantId: ctx.tenantId, menuTarget: "workspace" });
|
|
55786
|
+
} catch {
|
|
55787
|
+
return JSON.stringify({ error: "MENU_LIST_FAILED" });
|
|
55788
|
+
}
|
|
55789
|
+
const existing = items.find((item) => {
|
|
55790
|
+
if (item.contentType !== contentType) return false;
|
|
55791
|
+
if (!matchesScope(
|
|
55792
|
+
item.contentConfig,
|
|
55793
|
+
ctx.workspaceId,
|
|
55794
|
+
ctx.projectId
|
|
55795
|
+
)) {
|
|
55796
|
+
return false;
|
|
55797
|
+
}
|
|
55798
|
+
if (contentType === "file") {
|
|
55799
|
+
return item.contentConfig.resourcePath === contentConfig.resourcePath;
|
|
55800
|
+
}
|
|
55801
|
+
const cfg = item.contentConfig;
|
|
55802
|
+
const next = contentConfig;
|
|
55803
|
+
return cfg.kind === "plugin" && next.kind === "plugin" && cfg.pluginType === next.pluginType && cfg.resource === next.resource;
|
|
55804
|
+
});
|
|
55805
|
+
const name = input.name?.trim() || existing?.name || defaultName;
|
|
55806
|
+
const group = input.group?.trim() || void 0;
|
|
55807
|
+
try {
|
|
55808
|
+
if (existing) {
|
|
55809
|
+
const merged = {
|
|
55810
|
+
...existing.contentConfig,
|
|
55811
|
+
...contentConfig
|
|
55812
|
+
};
|
|
55813
|
+
if (contentType === "mcpApp") {
|
|
55814
|
+
delete merged.toolResult;
|
|
55815
|
+
delete merged.ui;
|
|
55816
|
+
}
|
|
55817
|
+
const updated = await menu.update(existing.id, {
|
|
55818
|
+
contentConfig: merged,
|
|
55819
|
+
name,
|
|
55820
|
+
...group ? { group } : {}
|
|
55821
|
+
});
|
|
55822
|
+
console.info(JSON.stringify({
|
|
55823
|
+
event: "publish.pinned",
|
|
55824
|
+
userId: ctx.createdBy,
|
|
55825
|
+
tenantId: ctx.tenantId,
|
|
55826
|
+
workspaceId: ctx.workspaceId,
|
|
55827
|
+
projectId: ctx.projectId,
|
|
55828
|
+
kind: contentType,
|
|
55829
|
+
menuItemId: updated.id,
|
|
55830
|
+
created: false
|
|
55831
|
+
}));
|
|
55832
|
+
return JSON.stringify({
|
|
55833
|
+
mode: "menu",
|
|
55834
|
+
kind: contentType,
|
|
55835
|
+
menuItemId: updated.id,
|
|
55836
|
+
name: updated.name,
|
|
55837
|
+
...updated.group ? { group: updated.group } : {},
|
|
55838
|
+
...contentType === "mcpApp" ? { warnings: [MENU_MCP_WARNING] } : {},
|
|
55839
|
+
alreadyPinned: true,
|
|
55840
|
+
refreshOnOpen: contentType === "mcpApp"
|
|
55841
|
+
});
|
|
55842
|
+
}
|
|
55843
|
+
const created = await menu.create({
|
|
55844
|
+
tenantId: ctx.tenantId,
|
|
55845
|
+
menuTarget: "workspace",
|
|
55846
|
+
contentType,
|
|
55847
|
+
contentConfig,
|
|
55848
|
+
name,
|
|
55849
|
+
...group ? { group } : {},
|
|
55850
|
+
sortOrder: 0
|
|
55851
|
+
});
|
|
55852
|
+
console.info(JSON.stringify({
|
|
55853
|
+
event: "publish.pinned",
|
|
55854
|
+
userId: ctx.createdBy,
|
|
55855
|
+
tenantId: ctx.tenantId,
|
|
55856
|
+
workspaceId: ctx.workspaceId,
|
|
55857
|
+
projectId: ctx.projectId,
|
|
55858
|
+
kind: contentType,
|
|
55859
|
+
menuItemId: created.id,
|
|
55860
|
+
created: true
|
|
55861
|
+
}));
|
|
55862
|
+
return JSON.stringify({
|
|
55863
|
+
mode: "menu",
|
|
55864
|
+
kind: contentType,
|
|
55865
|
+
menuItemId: created.id,
|
|
55866
|
+
name: created.name,
|
|
55867
|
+
...created.group ? { group: created.group } : {},
|
|
55868
|
+
...contentType === "mcpApp" ? { warnings: [MENU_MCP_WARNING] } : {},
|
|
55869
|
+
alreadyPinned: false,
|
|
55870
|
+
refreshOnOpen: contentType === "mcpApp"
|
|
55871
|
+
});
|
|
55872
|
+
} catch {
|
|
55873
|
+
return JSON.stringify({ error: "MENU_PIN_FAILED" });
|
|
55874
|
+
}
|
|
55875
|
+
}
|
|
55876
|
+
async function publishTargetHandler(input, exeConfig) {
|
|
55877
|
+
const raw = runConfigOf(exeConfig);
|
|
55878
|
+
const tenantId2 = typeof raw.tenantId === "string" ? raw.tenantId : "";
|
|
55879
|
+
const createdBy = createdByOf(raw);
|
|
55880
|
+
const workspaceId = typeof raw.workspaceId === "string" ? raw.workspaceId : "";
|
|
55881
|
+
const projectId = typeof raw.projectId === "string" ? raw.projectId : "";
|
|
55882
|
+
if (!tenantId2 || !createdBy) return JSON.stringify({ error: "USER_REQUIRED" });
|
|
55883
|
+
if (!workspaceId || !projectId) return JSON.stringify({ error: "SCOPE_REQUIRED" });
|
|
55884
|
+
if (input.mode === "link") {
|
|
55885
|
+
if (input.visibility === "password" && !input.password) {
|
|
55886
|
+
return JSON.stringify({ error: "INVALID_REQUEST" });
|
|
55887
|
+
}
|
|
55888
|
+
if (input.visibility === "public" && input.password) {
|
|
55889
|
+
return JSON.stringify({ error: "INVALID_REQUEST" });
|
|
55890
|
+
}
|
|
55891
|
+
let store2;
|
|
55892
|
+
try {
|
|
55893
|
+
store2 = getStoreLattice("default", "sharedResource").store;
|
|
55894
|
+
} catch {
|
|
55895
|
+
return JSON.stringify({ error: "SHARE_STORE_UNAVAILABLE" });
|
|
55896
|
+
}
|
|
55897
|
+
if (input.target.kind === "file") {
|
|
55898
|
+
const resourcePath = normalizeProjectPath(input.target.path);
|
|
55899
|
+
if (resourcePath === null) {
|
|
55900
|
+
return JSON.stringify({ error: "INVALID_TARGET" });
|
|
55901
|
+
}
|
|
55902
|
+
try {
|
|
55903
|
+
const payload = createSharePayload(tenantId2, workspaceId, projectId, createdBy, {
|
|
55904
|
+
resourcePath: input.target.path,
|
|
55905
|
+
assistantId: typeof raw.assistant_id === "string" ? raw.assistant_id : void 0,
|
|
55906
|
+
title: input.title ?? basename6(resourcePath),
|
|
55907
|
+
visibility: input.visibility,
|
|
55908
|
+
password: input.password,
|
|
55909
|
+
expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4).toISOString() : void 0,
|
|
55910
|
+
maxAccess: input.maxAccess
|
|
55911
|
+
});
|
|
55912
|
+
const token = generateToken();
|
|
55913
|
+
try {
|
|
55914
|
+
await store2.create({ ...payload, token });
|
|
55915
|
+
} catch {
|
|
55916
|
+
return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
|
|
55917
|
+
}
|
|
55918
|
+
console.info(JSON.stringify({
|
|
55919
|
+
event: "publish.created",
|
|
55920
|
+
tenantId: tenantId2,
|
|
55921
|
+
userId: createdBy,
|
|
55922
|
+
mode: "link",
|
|
55923
|
+
kind: "file",
|
|
55924
|
+
visibility: input.visibility,
|
|
55925
|
+
tokenPrefix: token.slice(0, 8)
|
|
55926
|
+
}));
|
|
55927
|
+
return linkResult({
|
|
55928
|
+
kind: "file",
|
|
55929
|
+
token,
|
|
55930
|
+
title: payload.title ?? basename6(resourcePath),
|
|
55931
|
+
visibility: input.visibility,
|
|
55932
|
+
password: input.password,
|
|
55933
|
+
warnings: input.visibility === "public" ? [
|
|
55934
|
+
"anyone with the link can access this file; artifact app api scripts can execute"
|
|
55935
|
+
] : void 0
|
|
55936
|
+
});
|
|
55937
|
+
} catch {
|
|
55938
|
+
return JSON.stringify({ error: "INVALID_TARGET" });
|
|
55939
|
+
}
|
|
55940
|
+
} else {
|
|
55941
|
+
let resolved;
|
|
55942
|
+
try {
|
|
55943
|
+
const outcome = await resolvePluginTarget(input.target, raw, tenantId2);
|
|
55944
|
+
if ("error" in outcome) return JSON.stringify(outcome);
|
|
55945
|
+
resolved = outcome;
|
|
55946
|
+
} catch {
|
|
55947
|
+
return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
|
|
55948
|
+
}
|
|
55949
|
+
try {
|
|
55950
|
+
const payload = createMcpAppSharePayload({
|
|
55951
|
+
tenantId: tenantId2,
|
|
55952
|
+
createdBy,
|
|
55953
|
+
workspaceId,
|
|
55954
|
+
projectId,
|
|
55955
|
+
app: {
|
|
55956
|
+
kind: "plugin",
|
|
55957
|
+
pluginType: input.target.pluginType,
|
|
55958
|
+
resource: resolved.resource,
|
|
55959
|
+
scope: resolved.scope,
|
|
55960
|
+
toolName: resolved.toolName,
|
|
55961
|
+
displayMode: resolved.displayMode,
|
|
55962
|
+
toolInput: input.target.input ?? {}
|
|
55963
|
+
},
|
|
55964
|
+
title: input.title,
|
|
55965
|
+
visibility: input.visibility,
|
|
55966
|
+
password: input.password,
|
|
55967
|
+
expiresAt: input.expiresInMinutes ? new Date(Date.now() + input.expiresInMinutes * 6e4) : void 0,
|
|
55968
|
+
maxAccess: input.maxAccess
|
|
55969
|
+
});
|
|
55970
|
+
try {
|
|
55971
|
+
await store2.create(payload);
|
|
55972
|
+
} catch {
|
|
55973
|
+
return JSON.stringify({ error: "SHARE_CREATE_FAILED" });
|
|
55974
|
+
}
|
|
55975
|
+
console.info(JSON.stringify({
|
|
55976
|
+
event: "publish.created",
|
|
55977
|
+
tenantId: tenantId2,
|
|
55978
|
+
userId: createdBy,
|
|
55979
|
+
mode: "link",
|
|
55980
|
+
kind: "mcpApp",
|
|
55981
|
+
visibility: input.visibility,
|
|
55982
|
+
pluginType: input.target.pluginType,
|
|
55983
|
+
toolName: input.target.toolName,
|
|
55984
|
+
tokenPrefix: payload.token.slice(0, 8)
|
|
55985
|
+
}));
|
|
55986
|
+
return linkResult({
|
|
55987
|
+
kind: "mcpApp",
|
|
55988
|
+
token: payload.token,
|
|
55989
|
+
title: payload.title ?? resolved.toolName,
|
|
55990
|
+
visibility: input.visibility,
|
|
55991
|
+
password: input.password,
|
|
55992
|
+
warnings: input.visibility === "public" ? ["public share delegates the selected plugin connection"] : void 0
|
|
55993
|
+
});
|
|
55994
|
+
} catch (error) {
|
|
55995
|
+
return JSON.stringify({
|
|
55996
|
+
error: error instanceof SharePayloadError ? error.code : "SHARE_CREATE_FAILED"
|
|
55997
|
+
});
|
|
55998
|
+
}
|
|
55999
|
+
}
|
|
56000
|
+
}
|
|
56001
|
+
return publishMenu(input, raw, { tenantId: tenantId2, workspaceId, projectId, createdBy });
|
|
56002
|
+
}
|
|
56003
|
+
|
|
56004
|
+
// src/middlewares/appShareSkill.ts
|
|
56005
|
+
var APP_SHARE_PUBLISHING_SKILL = `---
|
|
56006
|
+
name: app-share-publishing
|
|
56007
|
+
description: Use when a user explicitly asks to publish, share, or pin a project file, artifact app, or tenant plugin MCP App; covers link generation and workspace menu pinning.
|
|
56008
|
+
---
|
|
56009
|
+
|
|
56010
|
+
# Publishing files and MCP Apps
|
|
56011
|
+
|
|
56012
|
+
\`publish_target\` is the only tool that creates a share or menu pin.
|
|
56013
|
+
\`list_menu_groups\` is read-only discovery of existing workspace menu groups.
|
|
56014
|
+
Publish only when the human explicitly asks to publish, share, or pin something.
|
|
56015
|
+
|
|
56016
|
+
## Target kinds
|
|
56017
|
+
- \`{ kind: "file", path }\` \u2014 a project-relative file, directory, or artifact app
|
|
56018
|
+
directory. Artifact apps are directories containing \`index.html\`; pass the
|
|
56019
|
+
directory, not \`index.html\`. Paths are project-relative: \`..\` is rejected and
|
|
56020
|
+
the project root is not shareable.
|
|
56021
|
+
- \`{ kind: "mcpApp", pluginType, toolName, input?, connectionKey? }\` \u2014 a
|
|
56022
|
+
UI-bearing sandbox plugin tool.
|
|
56023
|
+
|
|
56024
|
+
## Modes
|
|
56025
|
+
- \`mode: "link"\` \u2014 creates \`/s/<token>\`. \`visibility\` (\`public | password\`)
|
|
56026
|
+
has no default: ask the human to choose before creating a link. Only \`password\`
|
|
56027
|
+
visibility takes a \`password\`; title, expiresInMinutes, maxAccess are optional.
|
|
56028
|
+
- \`mode: "menu"\` \u2014 pins to the menu, tenant-visible and scoped to the current
|
|
56029
|
+
project. \`name\` and \`group\` are optional; call \`list_menu_groups\` first and
|
|
56030
|
+
choose an existing group or confirm a new one with the human. Before pinning a
|
|
56031
|
+
connection-backed App, confirm with the human that the pin is tenant-visible
|
|
56032
|
+
and reuses the selected connection.
|
|
56033
|
+
|
|
56034
|
+
## What the link or pin does
|
|
56035
|
+
- File links and pins serve the current file from the project volume. They do not
|
|
56036
|
+
re-run a tool and are not a frozen snapshot. Directory and artifact-app links
|
|
56037
|
+
also expose the App's \`api/*.js\` / \`api/*.py\` scripts for execution.
|
|
56038
|
+
- MCP App links and pins re-run the tool on every open, so tools with write side
|
|
56039
|
+
effects run every time. A public MCP link delegates the selected plugin
|
|
56040
|
+
connection.
|
|
56041
|
+
- Warn the human before creating a public link: anyone with the URL can access a
|
|
56042
|
+
public file (including its artifact-app API scripts), and a public MCP link
|
|
56043
|
+
delegates the selected plugin connection.
|
|
56044
|
+
|
|
56045
|
+
## Connections
|
|
56046
|
+
Pass \`connectionKey\` when the plugin has multiple connections.
|
|
56047
|
+
\`CONNECTION_AMBIGUOUS\` means ask which key to use; \`CONNECTION_REQUIRED\` means
|
|
56048
|
+
ask the human to configure one first. Never put credentials in \`input\`.
|
|
56049
|
+
|
|
56050
|
+
## Result
|
|
56051
|
+
- Link: \`token\`, \`path\` (plus \`url\` when a public base URL is configured),
|
|
56052
|
+
title, visibility, optional \`password\`, and \`warnings\`.
|
|
56053
|
+
- Menu: \`menuItemId\`, \`name\`, optional \`group\`, \`warnings\` (MCP App pins),
|
|
56054
|
+
\`alreadyPinned\`, \`refreshOnOpen\`.
|
|
56055
|
+
|
|
56056
|
+
## Errors
|
|
56057
|
+
- \`TOOL_NOT_FOUND\` / \`TOOL_NOT_UI\`: choose an available UI-bearing plugin tool.
|
|
56058
|
+
- \`CONNECTION_NOT_FOUND\` / \`CONNECTION_REQUIRED\` / \`CONNECTION_AMBIGUOUS\`: fix
|
|
56059
|
+
the connection selection, or ask the human to configure one.
|
|
56060
|
+
- \`SCOPE_REQUIRED\` / \`SCOPE_UNAVAILABLE\`: the run lacks workspace/project scope,
|
|
56061
|
+
or the deployment cannot sign MCP UI scopes.
|
|
56062
|
+
- \`INVALID_TARGET\`: the file path escapes the project, targets the root, or the
|
|
56063
|
+
target shape is unsupported.
|
|
56064
|
+
- \`PAYLOAD_TOO_LARGE\`: reduce the stored tool input.
|
|
56065
|
+
- \`SHARE_STORE_UNAVAILABLE\` / \`MENU_STORE_UNAVAILABLE\`: the store is not
|
|
56066
|
+
configured.
|
|
56067
|
+
- \`MENU_LIST_FAILED\` / \`MENU_PIN_FAILED\`: retry, or report the menu failure.
|
|
56068
|
+
`;
|
|
56069
|
+
|
|
56070
|
+
// src/middlewares/appShareMiddleware.ts
|
|
56071
|
+
var appSharePlugin = {
|
|
56072
|
+
meta: {
|
|
56073
|
+
type: "app-share",
|
|
56074
|
+
name: "Publish",
|
|
56075
|
+
description: "Publish project files and sandbox plugin MCP Apps as links or workspace menu items.",
|
|
56076
|
+
version: "2.0.0",
|
|
56077
|
+
tools: [
|
|
56078
|
+
{
|
|
56079
|
+
name: "publish_target",
|
|
56080
|
+
description: "Publish a project file (including directories and artifact apps) or a UI-bearing sandbox plugin tool. mode=link creates a share link; mode=menu pins it to the workspace menu. Only call when the user explicitly asks to publish, share, or pin. For menu groups, call list_menu_groups first. Links re-run MCP Apps on every open; file links serve the file.",
|
|
56081
|
+
ui: { resource: SHARE_CARD_UI_RESOURCE, displayMode: "inline" }
|
|
56082
|
+
},
|
|
56083
|
+
{
|
|
56084
|
+
name: "list_menu_groups",
|
|
56085
|
+
description: "List workspace menu groups and counts before choosing a pin group. Read-only."
|
|
56086
|
+
}
|
|
56087
|
+
],
|
|
56088
|
+
uiResources: {
|
|
56089
|
+
[SHARE_CARD_UI_RESOURCE]: { html: SHARE_CARD_APP_HTML }
|
|
56090
|
+
},
|
|
56091
|
+
configSchema: { type: "object", properties: {} },
|
|
56092
|
+
defaultConfig: {}
|
|
56093
|
+
},
|
|
56094
|
+
skills: {
|
|
56095
|
+
"app-share-publishing": {
|
|
56096
|
+
version: "2.0.0",
|
|
56097
|
+
content: APP_SHARE_PUBLISHING_SKILL
|
|
56098
|
+
}
|
|
56099
|
+
},
|
|
56100
|
+
middleware: () => ({
|
|
56101
|
+
name: "appShareMiddleware",
|
|
56102
|
+
tools: [
|
|
56103
|
+
(0, import_langchain88.tool)(publishTargetHandler, {
|
|
56104
|
+
name: "publish_target",
|
|
56105
|
+
description: "Publish a file or MCP App as a link or workspace menu item.",
|
|
56106
|
+
schema: publishTargetSchema
|
|
56107
|
+
}),
|
|
56108
|
+
(0, import_langchain88.tool)(listMenuGroupsHandler, {
|
|
56109
|
+
name: "list_menu_groups",
|
|
56110
|
+
description: "List workspace menu groups and counts before choosing a pin group. Read-only.",
|
|
56111
|
+
schema: listMenuGroupsSchema
|
|
56112
|
+
})
|
|
56113
|
+
]
|
|
56114
|
+
})
|
|
56115
|
+
};
|
|
56116
|
+
|
|
56117
|
+
// src/middlewares/longTermStoreMiddleware.ts
|
|
56118
|
+
var import_langchain89 = require("langchain");
|
|
56119
|
+
var import_zod76 = require("zod");
|
|
54721
56120
|
var import_protocols49 = require("@axiom-lattice/protocols");
|
|
54722
56121
|
var DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
|
|
54723
56122
|
var DEFAULT_SEARCH_LIMIT = 10;
|
|
@@ -54813,34 +56212,34 @@ function store() {
|
|
|
54813
56212
|
return void 0;
|
|
54814
56213
|
}
|
|
54815
56214
|
}
|
|
54816
|
-
var namespaceSchema =
|
|
56215
|
+
var namespaceSchema = import_zod76.z.array(import_zod76.z.string()).optional().describe(
|
|
54817
56216
|
"Optional relative namespace segments for organization (appended to the scoped prefix)."
|
|
54818
56217
|
);
|
|
54819
|
-
var keySchema =
|
|
54820
|
-
var valueSchema =
|
|
54821
|
-
var putSchema =
|
|
56218
|
+
var keySchema = import_zod76.z.string().min(1).describe("Stable item key within the resolved namespace.");
|
|
56219
|
+
var valueSchema = import_zod76.z.record(import_zod76.z.unknown()).describe("JSON object value to persist.");
|
|
56220
|
+
var putSchema = import_zod76.z.object({
|
|
54822
56221
|
key: keySchema,
|
|
54823
56222
|
value: valueSchema,
|
|
54824
56223
|
namespace: namespaceSchema,
|
|
54825
|
-
ttlMinutes:
|
|
56224
|
+
ttlMinutes: import_zod76.z.number().positive().optional().describe("Optional TTL in minutes; omit to use the plugin default.")
|
|
54826
56225
|
});
|
|
54827
|
-
var getSchema =
|
|
56226
|
+
var getSchema = import_zod76.z.object({
|
|
54828
56227
|
key: keySchema,
|
|
54829
56228
|
namespace: namespaceSchema
|
|
54830
56229
|
});
|
|
54831
|
-
var searchSchema2 =
|
|
54832
|
-
query:
|
|
54833
|
-
filter:
|
|
56230
|
+
var searchSchema2 = import_zod76.z.object({
|
|
56231
|
+
query: import_zod76.z.string().optional().describe("Case-insensitive substring match over serialized values."),
|
|
56232
|
+
filter: import_zod76.z.record(import_zod76.z.unknown()).optional().describe("Deep partial-equality filter over the value object."),
|
|
54834
56233
|
namespace: namespaceSchema,
|
|
54835
|
-
limit:
|
|
56234
|
+
limit: import_zod76.z.number().int().min(1).max(MAX_SEARCH_LIMIT).optional()
|
|
54836
56235
|
});
|
|
54837
|
-
var deleteSchema =
|
|
56236
|
+
var deleteSchema = import_zod76.z.object({
|
|
54838
56237
|
key: keySchema,
|
|
54839
56238
|
namespace: namespaceSchema
|
|
54840
56239
|
});
|
|
54841
|
-
var namespacesSchema =
|
|
56240
|
+
var namespacesSchema = import_zod76.z.object({
|
|
54842
56241
|
namespace: namespaceSchema,
|
|
54843
|
-
limit:
|
|
56242
|
+
limit: import_zod76.z.number().int().min(1).max(MAX_SEARCH_LIMIT).optional()
|
|
54844
56243
|
});
|
|
54845
56244
|
var STORE_SKILL_HINT = "Load long_term_store-usage for namespace/TTL guidance.";
|
|
54846
56245
|
var STORE_DESCRIPTION = [
|
|
@@ -54959,7 +56358,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
54959
56358
|
}
|
|
54960
56359
|
return resolveNamespace(config, scope, relative4);
|
|
54961
56360
|
};
|
|
54962
|
-
const putTool = (0,
|
|
56361
|
+
const putTool = (0, import_langchain89.tool)(
|
|
54963
56362
|
async (input, exeConfig) => {
|
|
54964
56363
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
54965
56364
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -54990,7 +56389,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
54990
56389
|
schema: putSchema
|
|
54991
56390
|
}
|
|
54992
56391
|
);
|
|
54993
|
-
const getTool = (0,
|
|
56392
|
+
const getTool = (0, import_langchain89.tool)(
|
|
54994
56393
|
async (input, exeConfig) => {
|
|
54995
56394
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
54996
56395
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -55014,7 +56413,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
55014
56413
|
schema: getSchema
|
|
55015
56414
|
}
|
|
55016
56415
|
);
|
|
55017
|
-
const searchTool = (0,
|
|
56416
|
+
const searchTool = (0, import_langchain89.tool)(
|
|
55018
56417
|
async (input, exeConfig) => {
|
|
55019
56418
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
55020
56419
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -55041,7 +56440,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
55041
56440
|
schema: searchSchema2
|
|
55042
56441
|
}
|
|
55043
56442
|
);
|
|
55044
|
-
const deleteTool = (0,
|
|
56443
|
+
const deleteTool = (0, import_langchain89.tool)(
|
|
55045
56444
|
async (input, exeConfig) => {
|
|
55046
56445
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
55047
56446
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -55065,7 +56464,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
55065
56464
|
schema: deleteSchema
|
|
55066
56465
|
}
|
|
55067
56466
|
);
|
|
55068
|
-
const namespacesTool = (0,
|
|
56467
|
+
const namespacesTool = (0, import_langchain89.tool)(
|
|
55069
56468
|
async (input, exeConfig) => {
|
|
55070
56469
|
const resolved = resolve4(exeConfig, input.namespace);
|
|
55071
56470
|
if (!resolved.namespace) return failure3(resolved.error ?? "Invalid namespace");
|
|
@@ -55093,7 +56492,7 @@ function createLongTermStoreMiddleware(config = {}) {
|
|
|
55093
56492
|
schema: namespacesSchema
|
|
55094
56493
|
}
|
|
55095
56494
|
);
|
|
55096
|
-
return (0,
|
|
56495
|
+
return (0, import_langchain89.createMiddleware)({
|
|
55097
56496
|
name: "LongTermStoreMiddleware",
|
|
55098
56497
|
tools: readOnly ? [getTool, searchTool, namespacesTool] : [putTool, getTool, searchTool, deleteTool, namespacesTool]
|
|
55099
56498
|
});
|
|
@@ -55185,6 +56584,7 @@ var BUILTIN_PLUGINS = [
|
|
|
55185
56584
|
documentParserPlugin,
|
|
55186
56585
|
projectRoomPlugin,
|
|
55187
56586
|
sandboxPluginsPlugin,
|
|
56587
|
+
appSharePlugin,
|
|
55188
56588
|
longTermStorePlugin
|
|
55189
56589
|
];
|
|
55190
56590
|
function registerBuiltinPlugins() {
|
|
@@ -55619,8 +57019,11 @@ async function runHandler(body) {
|
|
|
55619
57019
|
var needsTempDir = inputIsLarge || connectionPayload !== null;
|
|
55620
57020
|
var tempDir = null;
|
|
55621
57021
|
var env = Object.assign({}, process.env);
|
|
55622
|
-
// Handler processes must never inherit scope signing secrets
|
|
57022
|
+
// Handler processes must never inherit scope signing secrets or the
|
|
57023
|
+
// agent-only short-lived Open token.
|
|
55623
57024
|
delete env.MCP_UI_SCOPE_SECRET;
|
|
57025
|
+
delete env.OPEN_API_TOKEN;
|
|
57026
|
+
delete env.API_GATEWAY_URL;
|
|
55624
57027
|
try {
|
|
55625
57028
|
if (needsTempDir) {
|
|
55626
57029
|
tempDir = path.join(os.tmpdir(), "plugin-run-" + Date.now() + "-" + Math.random().toString(36).slice(2));
|
|
@@ -55639,6 +57042,9 @@ async function runHandler(body) {
|
|
|
55639
57042
|
env.PLUGIN_CONNECTION_FILE = connectionFile;
|
|
55640
57043
|
}
|
|
55641
57044
|
env.PLUGIN_CONTEXT = encodeInput(body.context || {});
|
|
57045
|
+
if (typeof body.apiGatewayUrl === "string" && body.apiGatewayUrl) {
|
|
57046
|
+
env.API_GATEWAY_URL = body.apiGatewayUrl;
|
|
57047
|
+
}
|
|
55642
57048
|
var handlerTimeoutMs = resolveHandlerTimeoutMs(body.timeoutMs);
|
|
55643
57049
|
var exec = await runNode(handlerPath, pluginDir, env, handlerTimeoutMs);
|
|
55644
57050
|
if (exec.error) {
|
|
@@ -56197,6 +57603,7 @@ registerBuiltinPlugins();
|
|
|
56197
57603
|
DelegationService,
|
|
56198
57604
|
DependencyResolver,
|
|
56199
57605
|
DuplicateProjectRoomMessageIdempotencyKeyError,
|
|
57606
|
+
DuplicateShareTokenError,
|
|
56200
57607
|
E2BInstance,
|
|
56201
57608
|
E2BProvider,
|
|
56202
57609
|
EMPTY_CONTENT_WARNING,
|
|
@@ -56232,6 +57639,8 @@ registerBuiltinPlugins();
|
|
|
56232
57639
|
InMemoryProjectRoomMessageStore,
|
|
56233
57640
|
InMemoryProjectRoomReadStateStore,
|
|
56234
57641
|
InMemoryProjectRoomStore,
|
|
57642
|
+
InMemoryProjectStore,
|
|
57643
|
+
InMemorySharedResourceStore,
|
|
56235
57644
|
InMemoryStore,
|
|
56236
57645
|
InMemoryTaskStore,
|
|
56237
57646
|
InMemoryTaskWorkItemStore,
|
|
@@ -56288,6 +57697,7 @@ registerBuiltinPlugins();
|
|
|
56288
57697
|
ProjectBotMembershipIdConflictError,
|
|
56289
57698
|
ProjectMutationMutex,
|
|
56290
57699
|
ProjectRoomMessageIdConflictError,
|
|
57700
|
+
ProjectRoomMessageNotifier,
|
|
56291
57701
|
ProjectTaskAdmissionNotifier,
|
|
56292
57702
|
ProjectTaskOwnerPolicy,
|
|
56293
57703
|
ProjectTaskOwnerPolicyError,
|
|
@@ -56304,6 +57714,8 @@ registerBuiltinPlugins();
|
|
|
56304
57714
|
SAFE_PATH_COMPONENT,
|
|
56305
57715
|
SANDBOX_OPEN_GATEWAY_URL_ENV,
|
|
56306
57716
|
SANDBOX_OPEN_TOKEN_ENV,
|
|
57717
|
+
SHARE_CARD_APP_HTML,
|
|
57718
|
+
SHARE_CARD_UI_RESOURCE,
|
|
56307
57719
|
STTModelLattice,
|
|
56308
57720
|
STTModelLatticeManager,
|
|
56309
57721
|
SUMMARIZATION_TRIGGER_RATIO,
|
|
@@ -56313,6 +57725,7 @@ registerBuiltinPlugins();
|
|
|
56313
57725
|
SandboxSkillStore,
|
|
56314
57726
|
ScheduleLatticeManager,
|
|
56315
57727
|
SemanticMetricsClient,
|
|
57728
|
+
SharePayloadError,
|
|
56316
57729
|
SharedChunkBuffer,
|
|
56317
57730
|
SimpleMemoryVectorStore,
|
|
56318
57731
|
SkillLatticeManager,
|
|
@@ -56344,6 +57757,7 @@ registerBuiltinPlugins();
|
|
|
56344
57757
|
abortWorkflowRun,
|
|
56345
57758
|
agentInstanceManager,
|
|
56346
57759
|
agentLatticeManager,
|
|
57760
|
+
appSharePlugin,
|
|
56347
57761
|
appendReconciliationWarning,
|
|
56348
57762
|
appendUiFence,
|
|
56349
57763
|
assertQueueSources,
|
|
@@ -56396,6 +57810,7 @@ registerBuiltinPlugins();
|
|
|
56396
57810
|
createListTablesSqlTool,
|
|
56397
57811
|
createLongTermStoreMiddleware,
|
|
56398
57812
|
createMapNode,
|
|
57813
|
+
createMcpAppSharePayload,
|
|
56399
57814
|
createModelSelectorMiddleware,
|
|
56400
57815
|
createNodeHandler,
|
|
56401
57816
|
createProjectRoomMiddleware,
|
|
@@ -56489,6 +57904,7 @@ registerBuiltinPlugins();
|
|
|
56489
57904
|
getSTTModelLattice,
|
|
56490
57905
|
getSandBoxManager,
|
|
56491
57906
|
getSandboxOpenCredential,
|
|
57907
|
+
getSandboxOpenGatewayUrl,
|
|
56492
57908
|
getSandboxPluginCatalog,
|
|
56493
57909
|
getScheduleLattice,
|
|
56494
57910
|
getStoreLattice,
|
|
@@ -56527,6 +57943,7 @@ registerBuiltinPlugins();
|
|
|
56527
57943
|
isValidSkillName,
|
|
56528
57944
|
jsonSchemaToZod,
|
|
56529
57945
|
listCollectionEntries,
|
|
57946
|
+
listMenuGroupsSchema,
|
|
56530
57947
|
listModelLatticesForTenant,
|
|
56531
57948
|
listSandboxProviderTypes,
|
|
56532
57949
|
listTenantPlugins,
|
|
@@ -56562,11 +57979,13 @@ registerBuiltinPlugins();
|
|
|
56562
57979
|
prepareTaskDispatch,
|
|
56563
57980
|
probeThreadRunOwner,
|
|
56564
57981
|
projectMutationMutex,
|
|
57982
|
+
projectRoomMessageNotifier,
|
|
56565
57983
|
projectRoomPlugin,
|
|
56566
57984
|
projectTaskAdmissionNotifier,
|
|
56567
57985
|
provisionSandboxOpenClient,
|
|
56568
57986
|
publishCollectionChanged,
|
|
56569
57987
|
publishPluginCatalogChanged,
|
|
57988
|
+
publishTargetSchema,
|
|
56570
57989
|
queueLatticeManager,
|
|
56571
57990
|
readContextWindow,
|
|
56572
57991
|
readLoopBreakerConfig,
|
|
@@ -56588,6 +58007,7 @@ registerBuiltinPlugins();
|
|
|
56588
58007
|
registerQueueLattice,
|
|
56589
58008
|
registerSTTModelLattice,
|
|
56590
58009
|
registerSandboxOpenCredentialProvider,
|
|
58010
|
+
registerSandboxOpenGatewayUrlProvider,
|
|
56591
58011
|
registerSandboxProviderType,
|
|
56592
58012
|
registerScheduleLattice,
|
|
56593
58013
|
registerStoreLattice,
|