@axiom-lattice/gateway 4.8.1 → 4.8.3
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/embed/{embed-page-AgentDetailSideApp-R2RYOFBU.js → embed-page-AgentDetailSideApp-MVSXAG5S.js} +1 -1
- package/dist/embed/{embed-page-AgentGovernanceWorkbench-DYEK37IB.js → embed-page-AgentGovernanceWorkbench-ZEVAVRIQ.js} +1 -1
- package/dist/embed/{embed-page-MessageGraph-GQKF6ERQ.js → embed-page-MessageGraph-CPZJIKOD.js} +1 -1
- package/dist/embed/{embed-page-ReactChart-2J36M2FN.js → embed-page-ReactChart-7NQMTFJE.js} +1 -1
- package/dist/embed/{embed-page-TasksSideApp-IEKDM5AK.js → embed-page-TasksSideApp-CY6NI4DD.js} +1 -1
- package/dist/embed/{embed-page-TeamWorkspace-7IBW4J2Z.js → embed-page-TeamWorkspace-7GQCMJWF.js} +1 -1
- package/dist/embed/{embed-page-TopologyRuntimeView-TVYZRWMY.js → embed-page-TopologyRuntimeView-5DJPLCLQ.js} +1 -1
- package/dist/embed/{embed-page-WorkflowAutomationView-SS6TZVER.js → embed-page-WorkflowAutomationView-PDVXZXEF.js} +1 -1
- package/dist/embed/{embed-page-chunk-CFUFMRE6.js → embed-page-chunk-3SV3E6X5.js} +180 -179
- package/dist/embed/{embed-page-chunk-FRXM6EXJ.js → embed-page-chunk-BKCIU75D.js} +1 -1
- package/dist/embed/{embed-page-chunk-TJGWHX6G.js → embed-page-chunk-PZCET7LJ.js} +1 -1
- package/dist/embed/{embed-page-chunk-SG4KQEFI.js → embed-page-chunk-SFHRRNYQ.js} +1 -1
- package/dist/embed/{embed-page-chunk-626XAYL6.js → embed-page-chunk-ULBEL4OA.js} +1 -1
- package/dist/embed/{embed-page-chunk-NCP3KPCF.js → embed-page-chunk-UWL37DAK.js} +1 -1
- package/dist/embed/embed-page.js +1 -1
- package/dist/index.js +426 -439
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -966,7 +966,7 @@ function outcome(task) {
|
|
|
966
966
|
});
|
|
967
967
|
}
|
|
968
968
|
async function backfillTopCallerGroup(tasks, top, deps) {
|
|
969
|
-
const registry = deps.registry ??
|
|
969
|
+
const registry = deps.registry ?? import_core71.taskRunRegistry;
|
|
970
970
|
const results = [];
|
|
971
971
|
const eligible = [];
|
|
972
972
|
for (const task of tasks) {
|
|
@@ -1020,11 +1020,11 @@ async function recoverTask(task, deps) {
|
|
|
1020
1020
|
if (task.status !== "in_progress") {
|
|
1021
1021
|
return { kind: "skipped", reason: "not_in_progress" };
|
|
1022
1022
|
}
|
|
1023
|
-
const registry = deps.registry ??
|
|
1023
|
+
const registry = deps.registry ?? import_core71.taskRunRegistry;
|
|
1024
1024
|
if (registry.isLive(task.id) || deps.isTaskLive && await deps.isTaskLive(task)) {
|
|
1025
1025
|
return { kind: "skipped", reason: "live" };
|
|
1026
1026
|
}
|
|
1027
|
-
const { convergedTasks } = await (0,
|
|
1027
|
+
const { convergedTasks } = await (0, import_core71.reconcileStaleTaskRuns)({
|
|
1028
1028
|
tasks: [task],
|
|
1029
1029
|
actor: "system:on-demand-recovery",
|
|
1030
1030
|
lifecycle: deps.lifecycle,
|
|
@@ -1120,29 +1120,29 @@ async function runOrphanRecovery(deps) {
|
|
|
1120
1120
|
deps.log.info("Task orphan recovery complete", { recovered, skipped });
|
|
1121
1121
|
return { recovered, skipped };
|
|
1122
1122
|
}
|
|
1123
|
-
var import_messages,
|
|
1123
|
+
var import_messages, import_core71;
|
|
1124
1124
|
var init_TopCallerRecovery = __esm({
|
|
1125
1125
|
"src/services/collaboration/TopCallerRecovery.ts"() {
|
|
1126
1126
|
"use strict";
|
|
1127
1127
|
import_messages = require("@langchain/core/messages");
|
|
1128
|
-
|
|
1128
|
+
import_core71 = require("@axiom-lattice/core");
|
|
1129
1129
|
}
|
|
1130
1130
|
});
|
|
1131
1131
|
|
|
1132
1132
|
// src/services/collaboration/taskRunLiveness.ts
|
|
1133
1133
|
function createTaskRunLiveness() {
|
|
1134
1134
|
try {
|
|
1135
|
-
|
|
1135
|
+
import_core72.storeLatticeManager.getStoreLattice("default", "lease");
|
|
1136
1136
|
} catch {
|
|
1137
1137
|
return void 0;
|
|
1138
1138
|
}
|
|
1139
1139
|
return async (task) => {
|
|
1140
1140
|
try {
|
|
1141
|
-
const store2 =
|
|
1142
|
-
if (await store2.get((0,
|
|
1141
|
+
const store2 = import_core72.storeLatticeManager.getStoreLattice("default", "lease").store;
|
|
1142
|
+
if (await store2.get((0, import_core72.taskRunLeaseKey)(task.id))) return true;
|
|
1143
1143
|
const threadId = typeof task.context?.thread_id === "string" ? task.context.thread_id : void 0;
|
|
1144
1144
|
if (threadId && task.ownerId) {
|
|
1145
|
-
if (await store2.get((0,
|
|
1145
|
+
if (await store2.get((0, import_core72.threadRunLeaseKey)(task.tenantId, task.ownerId, threadId))) return true;
|
|
1146
1146
|
}
|
|
1147
1147
|
return false;
|
|
1148
1148
|
} catch {
|
|
@@ -1150,11 +1150,11 @@ function createTaskRunLiveness() {
|
|
|
1150
1150
|
}
|
|
1151
1151
|
};
|
|
1152
1152
|
}
|
|
1153
|
-
var
|
|
1153
|
+
var import_core72;
|
|
1154
1154
|
var init_taskRunLiveness = __esm({
|
|
1155
1155
|
"src/services/collaboration/taskRunLiveness.ts"() {
|
|
1156
1156
|
"use strict";
|
|
1157
|
-
|
|
1157
|
+
import_core72 = require("@axiom-lattice/core");
|
|
1158
1158
|
}
|
|
1159
1159
|
});
|
|
1160
1160
|
|
|
@@ -1164,7 +1164,7 @@ __export(OrphanRecoveryRuntime_exports, {
|
|
|
1164
1164
|
createOrphanRecoveryRuntime: () => createOrphanRecoveryRuntime
|
|
1165
1165
|
});
|
|
1166
1166
|
function createOrphanRecoveryRuntime(deps) {
|
|
1167
|
-
const lifecycle = deps.lifecycle ?? (0,
|
|
1167
|
+
const lifecycle = deps.lifecycle ?? (0, import_core73.createTaskLifecycleService)({
|
|
1168
1168
|
taskStore: deps.taskStore,
|
|
1169
1169
|
workItemStore: deps.workItemStore
|
|
1170
1170
|
});
|
|
@@ -1172,7 +1172,7 @@ function createOrphanRecoveryRuntime(deps) {
|
|
|
1172
1172
|
async recoverAll() {
|
|
1173
1173
|
const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
|
|
1174
1174
|
return runOrphanRecovery({
|
|
1175
|
-
reconcile: () => (0,
|
|
1175
|
+
reconcile: () => (0, import_core73.reconcileAllTenantTaskRuns)({
|
|
1176
1176
|
actor: "system:orphan-recovery",
|
|
1177
1177
|
tenantStore: {
|
|
1178
1178
|
listTenants: async () => (await deps.tenantStore.getAllTenants()).map((tenant2) => ({ id: tenant2.id }))
|
|
@@ -1198,7 +1198,7 @@ function createOrphanRecoveryRuntime(deps) {
|
|
|
1198
1198
|
const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
|
|
1199
1199
|
return recoverTask(task, {
|
|
1200
1200
|
lifecycle,
|
|
1201
|
-
registry:
|
|
1201
|
+
registry: import_core73.taskRunRegistry,
|
|
1202
1202
|
orphans,
|
|
1203
1203
|
callerFor: deps.callerFor,
|
|
1204
1204
|
resume: deps.resume,
|
|
@@ -1207,11 +1207,11 @@ function createOrphanRecoveryRuntime(deps) {
|
|
|
1207
1207
|
}
|
|
1208
1208
|
};
|
|
1209
1209
|
}
|
|
1210
|
-
var
|
|
1210
|
+
var import_core73;
|
|
1211
1211
|
var init_OrphanRecoveryRuntime = __esm({
|
|
1212
1212
|
"src/services/collaboration/OrphanRecoveryRuntime.ts"() {
|
|
1213
1213
|
"use strict";
|
|
1214
|
-
|
|
1214
|
+
import_core73 = require("@axiom-lattice/core");
|
|
1215
1215
|
init_TopCallerRecovery();
|
|
1216
1216
|
init_projectTaskScope();
|
|
1217
1217
|
init_taskRunLiveness();
|
|
@@ -1227,12 +1227,12 @@ function createRecoveryCallerDeps() {
|
|
|
1227
1227
|
return {
|
|
1228
1228
|
callerFor: async (top, tenantId) => {
|
|
1229
1229
|
if (!top.assistantId) return void 0;
|
|
1230
|
-
const load =
|
|
1230
|
+
const load = import_core74.getAgentClientAsync ?? import_core74.getAgentClient;
|
|
1231
1231
|
const client = await load(tenantId, top.assistantId);
|
|
1232
1232
|
const config = { configurable: { thread_id: top.threadId, runConfig: { tenantId, assistant_id: top.assistantId } } };
|
|
1233
1233
|
let agent;
|
|
1234
1234
|
try {
|
|
1235
|
-
agent =
|
|
1235
|
+
agent = import_core74.agentInstanceManager.getAgent({ assistant_id: top.assistantId, thread_id: top.threadId, tenant_id: tenantId });
|
|
1236
1236
|
} catch {
|
|
1237
1237
|
}
|
|
1238
1238
|
return agent ? { client, config, agent } : { client, config };
|
|
@@ -1249,11 +1249,11 @@ function createRecoveryCallerDeps() {
|
|
|
1249
1249
|
}
|
|
1250
1250
|
};
|
|
1251
1251
|
}
|
|
1252
|
-
var
|
|
1252
|
+
var import_core74;
|
|
1253
1253
|
var init_RecoveryCallerDeps = __esm({
|
|
1254
1254
|
"src/services/collaboration/RecoveryCallerDeps.ts"() {
|
|
1255
1255
|
"use strict";
|
|
1256
|
-
|
|
1256
|
+
import_core74 = require("@axiom-lattice/core");
|
|
1257
1257
|
}
|
|
1258
1258
|
});
|
|
1259
1259
|
|
|
@@ -1843,13 +1843,13 @@ function isA2ATaskSnapshot(value) {
|
|
|
1843
1843
|
function snapshotSequence(value) {
|
|
1844
1844
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
1845
1845
|
}
|
|
1846
|
-
var import_node_crypto28, import_node_util,
|
|
1846
|
+
var import_node_crypto28, import_node_util, import_core75, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
|
|
1847
1847
|
var init_A2ATaskStoreAdapter = __esm({
|
|
1848
1848
|
"src/services/a2a/A2ATaskStoreAdapter.ts"() {
|
|
1849
1849
|
"use strict";
|
|
1850
1850
|
import_node_crypto28 = require("crypto");
|
|
1851
1851
|
import_node_util = require("util");
|
|
1852
|
-
|
|
1852
|
+
import_core75 = require("@axiom-lattice/core");
|
|
1853
1853
|
TASK_STATUS_TO_A2A_STATE = {
|
|
1854
1854
|
pending: "submitted",
|
|
1855
1855
|
in_progress: "working",
|
|
@@ -1875,7 +1875,7 @@ var init_A2ATaskStoreAdapter = __esm({
|
|
|
1875
1875
|
this.workItemStore = options.workItemStore;
|
|
1876
1876
|
this.lifecycle = options.lifecycle;
|
|
1877
1877
|
this.scope = options.scope;
|
|
1878
|
-
this.runBridge = (0,
|
|
1878
|
+
this.runBridge = (0, import_core75.createTaskRunBridge)({
|
|
1879
1879
|
lifecycle: this.lifecycle,
|
|
1880
1880
|
taskStore: this.taskStore,
|
|
1881
1881
|
workItemStore: this.workItemStore
|
|
@@ -2226,12 +2226,12 @@ function assistantHasGovernedTask(assistant) {
|
|
|
2226
2226
|
const allowedTools = taskMiddleware?.allowedTools;
|
|
2227
2227
|
return !!taskMiddleware && (allowedTools === void 0 || Array.isArray(allowedTools) && (allowedTools.length === 0 || allowedTools.includes("manage_task")));
|
|
2228
2228
|
}
|
|
2229
|
-
var import_uuid11,
|
|
2229
|
+
var import_uuid11, import_core76, import_protocols35, _AxiomAgentExecutor, AxiomAgentExecutor;
|
|
2230
2230
|
var init_AxiomAgentExecutor = __esm({
|
|
2231
2231
|
"src/services/a2a/AxiomAgentExecutor.ts"() {
|
|
2232
2232
|
"use strict";
|
|
2233
2233
|
import_uuid11 = require("uuid");
|
|
2234
|
-
|
|
2234
|
+
import_core76 = require("@axiom-lattice/core");
|
|
2235
2235
|
import_protocols35 = require("@axiom-lattice/protocols");
|
|
2236
2236
|
init_a2aFileRefs();
|
|
2237
2237
|
init_task_file_refs();
|
|
@@ -2328,7 +2328,7 @@ var init_AxiomAgentExecutor = __esm({
|
|
|
2328
2328
|
await this.taskStore.save(initialTask);
|
|
2329
2329
|
bus.publish(initialTask);
|
|
2330
2330
|
try {
|
|
2331
|
-
const agent =
|
|
2331
|
+
const agent = import_core76.agentInstanceManager.getAgent(this.agentParams(threadId));
|
|
2332
2332
|
const requestText = inputFiles.length > 0 ? `${text}
|
|
2333
2333
|
|
|
2334
2334
|
${formatFileRefsSection(inputFiles)}` : text;
|
|
@@ -2516,7 +2516,7 @@ ${formatFileRefsSection(inputFiles)}` : text;
|
|
|
2516
2516
|
const threadId = task ? asString2(task.metadata?.threadId) : void 0;
|
|
2517
2517
|
if (threadId) {
|
|
2518
2518
|
try {
|
|
2519
|
-
const agent =
|
|
2519
|
+
const agent = import_core76.agentInstanceManager.getAgent(this.agentParams(threadId));
|
|
2520
2520
|
await agent.abort();
|
|
2521
2521
|
} catch (err) {
|
|
2522
2522
|
console.warn({
|
|
@@ -2890,10 +2890,10 @@ function isAsyncGenerator(value) {
|
|
|
2890
2890
|
}
|
|
2891
2891
|
function registerA2AStandardRoutes(app2, deps) {
|
|
2892
2892
|
const authService = deps.authService;
|
|
2893
|
-
const resolveTasks = deps.getTaskStoreLattice ?? (() => (0,
|
|
2894
|
-
const resolveTaskWorkItems = deps.getTaskWorkItemStore ?? (() => (0,
|
|
2895
|
-
const getAssistantStore2 = deps.getAssistantStore ?? (() => (0,
|
|
2896
|
-
const getProjectStore2 = deps.getProjectStore ?? (() => (0,
|
|
2893
|
+
const resolveTasks = deps.getTaskStoreLattice ?? (() => (0, import_core77.getStoreLattice)("default", "task").store);
|
|
2894
|
+
const resolveTaskWorkItems = deps.getTaskWorkItemStore ?? (() => (0, import_core77.getStoreLattice)("default", "taskWorkItem").store);
|
|
2895
|
+
const getAssistantStore2 = deps.getAssistantStore ?? (() => (0, import_core77.getStoreLattice)("default", "assistant").store);
|
|
2896
|
+
const getProjectStore2 = deps.getProjectStore ?? (() => (0, import_core77.getStoreLattice)("default", "project").store);
|
|
2897
2897
|
const runtimeRegistry = deps.runtimeRegistry ?? new A2ARuntimeRegistry();
|
|
2898
2898
|
app2.addHook("onClose", async () => {
|
|
2899
2899
|
runtimeRegistry.close();
|
|
@@ -2976,7 +2976,7 @@ function registerA2AStandardRoutes(app2, deps) {
|
|
|
2976
2976
|
const taskStore = assistantHasGovernedTask(assistant) ? new A2ATaskStoreAdapter({
|
|
2977
2977
|
taskStore: internalTasks,
|
|
2978
2978
|
workItemStore: workItems,
|
|
2979
|
-
lifecycle: (0,
|
|
2979
|
+
lifecycle: (0, import_core77.createTaskLifecycleService)({
|
|
2980
2980
|
taskStore: internalTasks,
|
|
2981
2981
|
workItemStore: workItems
|
|
2982
2982
|
}),
|
|
@@ -3095,7 +3095,7 @@ data: ${JSON.stringify(errorResponse)}
|
|
|
3095
3095
|
const taskStore = assistantHasGovernedTask(assistant) ? new A2ATaskStoreAdapter({
|
|
3096
3096
|
taskStore: internalTasks,
|
|
3097
3097
|
workItemStore: workItems,
|
|
3098
|
-
lifecycle: (0,
|
|
3098
|
+
lifecycle: (0, import_core77.createTaskLifecycleService)({
|
|
3099
3099
|
taskStore: internalTasks,
|
|
3100
3100
|
workItemStore: workItems
|
|
3101
3101
|
}),
|
|
@@ -3150,13 +3150,13 @@ data: ${JSON.stringify(data)}
|
|
|
3150
3150
|
}
|
|
3151
3151
|
);
|
|
3152
3152
|
}
|
|
3153
|
-
var import_uuid12, import_server2,
|
|
3153
|
+
var import_uuid12, import_server2, import_core77, SSE_HEADERS;
|
|
3154
3154
|
var init_a2a_standard = __esm({
|
|
3155
3155
|
"src/routes/a2a-standard.ts"() {
|
|
3156
3156
|
"use strict";
|
|
3157
3157
|
import_uuid12 = require("uuid");
|
|
3158
3158
|
import_server2 = require("@a2a-js/sdk/server");
|
|
3159
|
-
|
|
3159
|
+
import_core77 = require("@axiom-lattice/core");
|
|
3160
3160
|
init_A2AAuthService();
|
|
3161
3161
|
init_A2AAgentCardBuilder();
|
|
3162
3162
|
init_A2ATaskStoreAdapter();
|
|
@@ -3908,8 +3908,8 @@ function exposedDeclarations(plugin) {
|
|
|
3908
3908
|
return (plugin.meta.tools ?? []).filter((t2) => t2.expose);
|
|
3909
3909
|
}
|
|
3910
3910
|
async function registerExposedPluginTools() {
|
|
3911
|
-
for (const key of
|
|
3912
|
-
const plugin =
|
|
3911
|
+
for (const key of import_core78.PluginRegistry.list()) {
|
|
3912
|
+
const plugin = import_core78.PluginRegistry.get(key);
|
|
3913
3913
|
if (!plugin?.middleware) continue;
|
|
3914
3914
|
const exposed = exposedDeclarations(plugin);
|
|
3915
3915
|
if (exposed.length === 0) continue;
|
|
@@ -3944,8 +3944,8 @@ async function registerExposedPluginTools() {
|
|
|
3944
3944
|
}
|
|
3945
3945
|
function collectExposedPluginUiResources(grants) {
|
|
3946
3946
|
const resources = /* @__PURE__ */ new Map();
|
|
3947
|
-
for (const type of
|
|
3948
|
-
const plugin =
|
|
3947
|
+
for (const type of import_core78.PluginRegistry.list()) {
|
|
3948
|
+
const plugin = import_core78.PluginRegistry.get(type);
|
|
3949
3949
|
if (!plugin?.middleware) continue;
|
|
3950
3950
|
const exposedNames = new Set(exposedDeclarations(plugin).map((d) => d.name));
|
|
3951
3951
|
if (exposedNames.size === 0) continue;
|
|
@@ -3969,11 +3969,11 @@ function collectExposedPluginUiResources(grants) {
|
|
|
3969
3969
|
}
|
|
3970
3970
|
return resources;
|
|
3971
3971
|
}
|
|
3972
|
-
var
|
|
3972
|
+
var import_core78;
|
|
3973
3973
|
var init_registerExposedPlugins = __esm({
|
|
3974
3974
|
"src/services/open/registerExposedPlugins.ts"() {
|
|
3975
3975
|
"use strict";
|
|
3976
|
-
|
|
3976
|
+
import_core78 = require("@axiom-lattice/core");
|
|
3977
3977
|
init_openLattice();
|
|
3978
3978
|
init_pluginExposeAdapter();
|
|
3979
3979
|
}
|
|
@@ -3988,14 +3988,14 @@ function toText(result) {
|
|
|
3988
3988
|
}
|
|
3989
3989
|
function defaultCatalog() {
|
|
3990
3990
|
return {
|
|
3991
|
-
getValidatedManifest: (tenantId, type) => (0,
|
|
3992
|
-
getExecutor: () => (0,
|
|
3993
|
-
readPluginFile: (tenantId, type, relPath) => (0,
|
|
3991
|
+
getValidatedManifest: (tenantId, type) => (0, import_core79.getSandboxPluginCatalog)().getValidatedManifest(tenantId, type),
|
|
3992
|
+
getExecutor: () => (0, import_core79.getSandboxPluginCatalog)().getExecutor(),
|
|
3993
|
+
readPluginFile: (tenantId, type, relPath) => (0, import_core79.getSandboxPluginCatalog)().readPluginFile(tenantId, type, relPath)
|
|
3994
3994
|
};
|
|
3995
3995
|
}
|
|
3996
3996
|
async function defaultResolveConnections(pluginType, ctx) {
|
|
3997
3997
|
try {
|
|
3998
|
-
return await (0,
|
|
3998
|
+
return await (0, import_core79.resolveSandboxPluginConnections)(
|
|
3999
3999
|
pluginType,
|
|
4000
4000
|
{ connectAll: true },
|
|
4001
4001
|
{
|
|
@@ -4024,7 +4024,7 @@ function mergeOpenCatalog(globalCatalog, tenantTools) {
|
|
|
4024
4024
|
async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
|
|
4025
4025
|
const catalog = deps.catalog ?? defaultCatalog();
|
|
4026
4026
|
const listPlugins = deps.listPlugins ?? (async (tenant2) => {
|
|
4027
|
-
const snapshot = await (0,
|
|
4027
|
+
const snapshot = await (0, import_core79.getSandboxPluginCatalog)().ensureLoaded(tenant2);
|
|
4028
4028
|
return { plugins: snapshot.plugins, diagnostics: snapshot.diagnostics };
|
|
4029
4029
|
});
|
|
4030
4030
|
const resolveConnections = deps.resolveConnections ?? defaultResolveConnections;
|
|
@@ -4066,7 +4066,7 @@ async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
|
|
|
4066
4066
|
domain,
|
|
4067
4067
|
action: tool.name,
|
|
4068
4068
|
description: tool.description,
|
|
4069
|
-
schema: (0,
|
|
4069
|
+
schema: (0, import_core79.jsonSchemaToZod)(tool.schema),
|
|
4070
4070
|
annotations: {
|
|
4071
4071
|
readOnlyHint: tool.readOnly ?? false,
|
|
4072
4072
|
destructiveHint: tool.destructive ?? false
|
|
@@ -4117,11 +4117,11 @@ async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
|
|
|
4117
4117
|
}
|
|
4118
4118
|
};
|
|
4119
4119
|
}
|
|
4120
|
-
var
|
|
4120
|
+
var import_core79;
|
|
4121
4121
|
var init_tenantOpenPlugins = __esm({
|
|
4122
4122
|
"src/services/open/tenantOpenPlugins.ts"() {
|
|
4123
4123
|
"use strict";
|
|
4124
|
-
|
|
4124
|
+
import_core79 = require("@axiom-lattice/core");
|
|
4125
4125
|
init_openLattice();
|
|
4126
4126
|
init_pluginToolExecution();
|
|
4127
4127
|
}
|
|
@@ -4158,13 +4158,13 @@ function emptyTenantPlugins() {
|
|
|
4158
4158
|
}
|
|
4159
4159
|
function registerOpenRoutes(app2, deps = {}) {
|
|
4160
4160
|
const openAuth = deps.openAuth ?? new OpenCredentialService(
|
|
4161
|
-
(0,
|
|
4162
|
-
(0,
|
|
4161
|
+
(0, import_core80.getStoreLattice)("default", "a2aApiKey").store,
|
|
4162
|
+
(0, import_core80.getStoreLattice)("default", "project").store
|
|
4163
4163
|
);
|
|
4164
4164
|
const grantsSource = deps.grantsSource ?? ((ctx) => ctx.grants);
|
|
4165
4165
|
const audit = deps.audit ?? (() => {
|
|
4166
4166
|
try {
|
|
4167
|
-
const store2 = (0,
|
|
4167
|
+
const store2 = (0, import_core80.getStoreLattice)("default", "openAudit").store;
|
|
4168
4168
|
return new OpenAuditService(store2);
|
|
4169
4169
|
} catch {
|
|
4170
4170
|
return void 0;
|
|
@@ -4319,12 +4319,12 @@ function registerOpenRoutes(app2, deps = {}) {
|
|
|
4319
4319
|
}
|
|
4320
4320
|
);
|
|
4321
4321
|
}
|
|
4322
|
-
var import_types,
|
|
4322
|
+
var import_types, import_core80, RPC_ERROR;
|
|
4323
4323
|
var init_open = __esm({
|
|
4324
4324
|
"src/routes/open.ts"() {
|
|
4325
4325
|
"use strict";
|
|
4326
4326
|
import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
4327
|
-
|
|
4327
|
+
import_core80 = require("@axiom-lattice/core");
|
|
4328
4328
|
init_openCredentialService();
|
|
4329
4329
|
init_openAuditService();
|
|
4330
4330
|
init_openRateLimiter();
|
|
@@ -4357,7 +4357,7 @@ function registerOpenSessionRoutes(app2) {
|
|
|
4357
4357
|
if (typeof shareToken !== "string" || shareToken.length === 0) {
|
|
4358
4358
|
return reply.status(400).send({ error: "SHARE_TOKEN_REQUIRED" });
|
|
4359
4359
|
}
|
|
4360
|
-
const store2 = (0,
|
|
4360
|
+
const store2 = (0, import_core81.getStoreLattice)("default", "sharedResource").store;
|
|
4361
4361
|
const record = await store2.findByToken(shareToken);
|
|
4362
4362
|
if (!record || record.revoked) {
|
|
4363
4363
|
return reply.status(404).send({ error: "SHARE_NOT_FOUND" });
|
|
@@ -4382,11 +4382,11 @@ function registerOpenSessionRoutes(app2) {
|
|
|
4382
4382
|
}
|
|
4383
4383
|
);
|
|
4384
4384
|
}
|
|
4385
|
-
var
|
|
4385
|
+
var import_core81;
|
|
4386
4386
|
var init_open_session = __esm({
|
|
4387
4387
|
"src/routes/open-session.ts"() {
|
|
4388
4388
|
"use strict";
|
|
4389
|
-
|
|
4389
|
+
import_core81 = require("@axiom-lattice/core");
|
|
4390
4390
|
init_openToken();
|
|
4391
4391
|
init_previewToken();
|
|
4392
4392
|
init_openLattice();
|
|
@@ -4395,13 +4395,13 @@ var init_open_session = __esm({
|
|
|
4395
4395
|
|
|
4396
4396
|
// src/services/open/openCatalogService.ts
|
|
4397
4397
|
async function defaultListTenantPlugins(tenantId) {
|
|
4398
|
-
return (await (0,
|
|
4398
|
+
return (await (0, import_core82.getSandboxPluginCatalog)().ensureLoaded(tenantId)).plugins;
|
|
4399
4399
|
}
|
|
4400
|
-
var
|
|
4400
|
+
var import_core82, OpenCatalogService;
|
|
4401
4401
|
var init_openCatalogService = __esm({
|
|
4402
4402
|
"src/services/open/openCatalogService.ts"() {
|
|
4403
4403
|
"use strict";
|
|
4404
|
-
|
|
4404
|
+
import_core82 = require("@axiom-lattice/core");
|
|
4405
4405
|
init_openLattice();
|
|
4406
4406
|
OpenCatalogService = class {
|
|
4407
4407
|
constructor(assistantStore, lattice = openLattice, listTenantPlugins2 = defaultListTenantPlugins) {
|
|
@@ -4476,17 +4476,17 @@ function registerOpenCatalogRoutes(app2) {
|
|
|
4476
4476
|
if (!tenantId) {
|
|
4477
4477
|
return reply.status(401).send({ success: false, error: "Unauthorized" });
|
|
4478
4478
|
}
|
|
4479
|
-
const assistantStore = (0,
|
|
4479
|
+
const assistantStore = (0, import_core83.getStoreLattice)("default", "assistant").store;
|
|
4480
4480
|
const service2 = new OpenCatalogService(assistantStore);
|
|
4481
4481
|
const catalog = await service2.buildForTenant(tenantId);
|
|
4482
4482
|
return reply.status(200).send({ success: true, data: catalog });
|
|
4483
4483
|
});
|
|
4484
4484
|
}
|
|
4485
|
-
var
|
|
4485
|
+
var import_core83;
|
|
4486
4486
|
var init_open_catalog = __esm({
|
|
4487
4487
|
"src/routes/open-catalog.ts"() {
|
|
4488
4488
|
"use strict";
|
|
4489
|
-
|
|
4489
|
+
import_core83 = require("@axiom-lattice/core");
|
|
4490
4490
|
init_openCatalogService();
|
|
4491
4491
|
}
|
|
4492
4492
|
});
|
|
@@ -4501,11 +4501,11 @@ async function resolveContextSandbox(ctx) {
|
|
|
4501
4501
|
const sandboxName = ctx.runConfig?.sandboxName;
|
|
4502
4502
|
if (typeof sandboxName === "string" && sandboxName.length > 0) {
|
|
4503
4503
|
try {
|
|
4504
|
-
return await
|
|
4504
|
+
return await import_core84.sandboxLatticeManager.getSandbox(sandboxName);
|
|
4505
4505
|
} catch {
|
|
4506
4506
|
}
|
|
4507
4507
|
}
|
|
4508
|
-
return
|
|
4508
|
+
return import_core84.sandboxLatticeManager.getSandboxFromConfig({
|
|
4509
4509
|
assistant_id: "",
|
|
4510
4510
|
thread_id: "",
|
|
4511
4511
|
tenantId: ctx.tenantId,
|
|
@@ -4603,12 +4603,12 @@ ${truncated}`
|
|
|
4603
4603
|
}
|
|
4604
4604
|
};
|
|
4605
4605
|
}
|
|
4606
|
-
var import_zod21,
|
|
4606
|
+
var import_zod21, import_core84, MAX_OUTPUT_BYTES;
|
|
4607
4607
|
var init_sandboxProvider = __esm({
|
|
4608
4608
|
"src/services/open/providers/sandboxProvider.ts"() {
|
|
4609
4609
|
"use strict";
|
|
4610
4610
|
import_zod21 = require("zod");
|
|
4611
|
-
|
|
4611
|
+
import_core84 = require("@axiom-lattice/core");
|
|
4612
4612
|
MAX_OUTPUT_BYTES = 64e3;
|
|
4613
4613
|
}
|
|
4614
4614
|
});
|
|
@@ -4630,12 +4630,12 @@ function safePath(raw) {
|
|
|
4630
4630
|
}
|
|
4631
4631
|
function registerOpenFilesRoutes(app2, deps = {}) {
|
|
4632
4632
|
const openAuth = deps.openAuth ?? new OpenCredentialService(
|
|
4633
|
-
(0,
|
|
4634
|
-
(0,
|
|
4633
|
+
(0, import_core85.getStoreLattice)("default", "a2aApiKey").store,
|
|
4634
|
+
(0, import_core85.getStoreLattice)("default", "project").store
|
|
4635
4635
|
);
|
|
4636
4636
|
const audit = deps.audit ?? (() => {
|
|
4637
4637
|
try {
|
|
4638
|
-
const store2 = (0,
|
|
4638
|
+
const store2 = (0, import_core85.getStoreLattice)("default", "openAudit").store;
|
|
4639
4639
|
return new OpenAuditService(store2);
|
|
4640
4640
|
} catch {
|
|
4641
4641
|
return void 0;
|
|
@@ -4745,11 +4745,11 @@ function registerOpenFilesRoutes(app2, deps = {}) {
|
|
|
4745
4745
|
}
|
|
4746
4746
|
});
|
|
4747
4747
|
}
|
|
4748
|
-
var
|
|
4748
|
+
var import_core85;
|
|
4749
4749
|
var init_open_files = __esm({
|
|
4750
4750
|
"src/routes/open-files.ts"() {
|
|
4751
4751
|
"use strict";
|
|
4752
|
-
|
|
4752
|
+
import_core85 = require("@axiom-lattice/core");
|
|
4753
4753
|
init_openCredentialService();
|
|
4754
4754
|
init_openLattice();
|
|
4755
4755
|
init_sandboxProvider();
|
|
@@ -4771,7 +4771,7 @@ function registerOpenAuditRoutes(app2) {
|
|
|
4771
4771
|
return reply.status(401).send({ success: false, error: "Unauthorized" });
|
|
4772
4772
|
}
|
|
4773
4773
|
const status = request.query.status === "ok" || request.query.status === "error" ? request.query.status : void 0;
|
|
4774
|
-
const store2 = (0,
|
|
4774
|
+
const store2 = (0, import_core86.getStoreLattice)("default", "openAudit").store;
|
|
4775
4775
|
const records = await store2.query({
|
|
4776
4776
|
tenantId,
|
|
4777
4777
|
credentialId: request.query.credentialId,
|
|
@@ -4786,11 +4786,11 @@ function registerOpenAuditRoutes(app2) {
|
|
|
4786
4786
|
}
|
|
4787
4787
|
);
|
|
4788
4788
|
}
|
|
4789
|
-
var
|
|
4789
|
+
var import_core86;
|
|
4790
4790
|
var init_open_audit = __esm({
|
|
4791
4791
|
"src/routes/open-audit.ts"() {
|
|
4792
4792
|
"use strict";
|
|
4793
|
-
|
|
4793
|
+
import_core86 = require("@axiom-lattice/core");
|
|
4794
4794
|
}
|
|
4795
4795
|
});
|
|
4796
4796
|
|
|
@@ -4807,7 +4807,7 @@ function registerOpenExposureRoutes(app2, deps = {}) {
|
|
|
4807
4807
|
if (!tenantId) {
|
|
4808
4808
|
return reply.status(401).send({ success: false, error: "Unauthorized" });
|
|
4809
4809
|
}
|
|
4810
|
-
const keyStore = (0,
|
|
4810
|
+
const keyStore = (0, import_core87.getStoreLattice)("default", "a2aApiKey").store;
|
|
4811
4811
|
const record = await keyStore.findById(request.params.id);
|
|
4812
4812
|
if (!record || record.tenantId !== tenantId) {
|
|
4813
4813
|
return reply.status(404).send({ success: false, error: "Key not found" });
|
|
@@ -4841,7 +4841,7 @@ function registerOpenExposureRoutes(app2, deps = {}) {
|
|
|
4841
4841
|
hasUi: Boolean(t2.ui)
|
|
4842
4842
|
}));
|
|
4843
4843
|
const agentGrant = grants.find((g) => g.domain === "agent");
|
|
4844
|
-
const assistantStore = (0,
|
|
4844
|
+
const assistantStore = (0, import_core87.getStoreLattice)("default", "assistant").store;
|
|
4845
4845
|
const agents = [];
|
|
4846
4846
|
for (const assistantId of agentGrant?.items ?? []) {
|
|
4847
4847
|
const assistant = await assistantStore.getAssistantById(
|
|
@@ -4876,11 +4876,11 @@ function registerOpenExposureRoutes(app2, deps = {}) {
|
|
|
4876
4876
|
}
|
|
4877
4877
|
);
|
|
4878
4878
|
}
|
|
4879
|
-
var
|
|
4879
|
+
var import_core87, import_protocols38;
|
|
4880
4880
|
var init_open_exposure = __esm({
|
|
4881
4881
|
"src/routes/open-exposure.ts"() {
|
|
4882
4882
|
"use strict";
|
|
4883
|
-
|
|
4883
|
+
import_core87 = require("@axiom-lattice/core");
|
|
4884
4884
|
import_protocols38 = require("@axiom-lattice/protocols");
|
|
4885
4885
|
init_openLattice();
|
|
4886
4886
|
init_tenantOpenPlugins();
|
|
@@ -5000,7 +5000,7 @@ function createAgentProvider(deps = {}) {
|
|
|
5000
5000
|
} catch {
|
|
5001
5001
|
}
|
|
5002
5002
|
}
|
|
5003
|
-
const agent =
|
|
5003
|
+
const agent = import_core88.agentInstanceManager.getAgent({
|
|
5004
5004
|
tenant_id: ctx.tenantId,
|
|
5005
5005
|
assistant_id: assistantId,
|
|
5006
5006
|
thread_id: threadId,
|
|
@@ -5025,12 +5025,12 @@ function createAgentProvider(deps = {}) {
|
|
|
5025
5025
|
}
|
|
5026
5026
|
};
|
|
5027
5027
|
}
|
|
5028
|
-
var import_zod23,
|
|
5028
|
+
var import_zod23, import_core88, import_protocols39, STOP_TYPES;
|
|
5029
5029
|
var init_agentProvider = __esm({
|
|
5030
5030
|
"src/services/open/providers/agentProvider.ts"() {
|
|
5031
5031
|
"use strict";
|
|
5032
5032
|
import_zod23 = require("zod");
|
|
5033
|
-
|
|
5033
|
+
import_core88 = require("@axiom-lattice/core");
|
|
5034
5034
|
import_protocols39 = require("@axiom-lattice/protocols");
|
|
5035
5035
|
STOP_TYPES = [import_protocols39.MessageChunkTypes.MESSAGE_COMPLETED];
|
|
5036
5036
|
}
|
|
@@ -5133,11 +5133,11 @@ async function resolveAgentOpenGrants(tenantId, assistantId, deps) {
|
|
|
5133
5133
|
}
|
|
5134
5134
|
}
|
|
5135
5135
|
function createDefaultAgentReflectionDeps(tenantId) {
|
|
5136
|
-
(0,
|
|
5136
|
+
(0, import_core89.ensureBuiltinAgentsForTenant)(tenantId);
|
|
5137
5137
|
return {
|
|
5138
|
-
ensure: (t2) =>
|
|
5138
|
+
ensure: (t2) => import_core89.agentLatticeManager.initializeStoredAssistantsForTenant(t2),
|
|
5139
5139
|
getAgentConfig: (t2, assistantId) => {
|
|
5140
|
-
const config =
|
|
5140
|
+
const config = import_core89.agentLatticeManager.getAgentConfigWithTenant(t2, assistantId);
|
|
5141
5141
|
if (!config) return void 0;
|
|
5142
5142
|
return {
|
|
5143
5143
|
middleware: extractMiddleware(config),
|
|
@@ -5145,16 +5145,16 @@ function createDefaultAgentReflectionDeps(tenantId) {
|
|
|
5145
5145
|
};
|
|
5146
5146
|
},
|
|
5147
5147
|
getAssistantMiddleware: async (t2, assistantId) => {
|
|
5148
|
-
const store2 = (0,
|
|
5148
|
+
const store2 = (0, import_core89.getStoreLattice)("default", "assistant").store;
|
|
5149
5149
|
const assistant = await store2.getAssistantById(t2, assistantId);
|
|
5150
5150
|
return extractMiddleware(assistant?.graphDefinition);
|
|
5151
5151
|
},
|
|
5152
5152
|
exposedActionsByType: (type) => {
|
|
5153
|
-
const plugin =
|
|
5153
|
+
const plugin = import_core89.PluginRegistry.get(type);
|
|
5154
5154
|
return plugin ? normalizeOpenExpose(plugin.meta.openExpose) : [];
|
|
5155
5155
|
},
|
|
5156
5156
|
resolvableAssistants: async (t2) => new Set(
|
|
5157
|
-
|
|
5157
|
+
import_core89.agentLatticeManager.getAllAgentLatticesByTenant(t2).map((lattice) => lattice.config.key)
|
|
5158
5158
|
)
|
|
5159
5159
|
};
|
|
5160
5160
|
}
|
|
@@ -5219,30 +5219,30 @@ function buildTenantExposedGrants(manifests) {
|
|
|
5219
5219
|
}
|
|
5220
5220
|
function createDefaultPluginReflectionDeps() {
|
|
5221
5221
|
return {
|
|
5222
|
-
ensure: (tenantId) =>
|
|
5222
|
+
ensure: (tenantId) => import_core89.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
|
|
5223
5223
|
globalExposedDomains: () => {
|
|
5224
5224
|
const grants = [];
|
|
5225
|
-
for (const type of
|
|
5226
|
-
const plugin =
|
|
5225
|
+
for (const type of import_core89.PluginRegistry.list()) {
|
|
5226
|
+
const plugin = import_core89.PluginRegistry.get(type);
|
|
5227
5227
|
const items = normalizeOpenExpose(plugin?.meta.openExpose);
|
|
5228
5228
|
if (items.length > 0) grants.push({ domain: type, items });
|
|
5229
5229
|
}
|
|
5230
5230
|
return grants;
|
|
5231
5231
|
},
|
|
5232
5232
|
tenantExposedDomains: async (tenantId) => {
|
|
5233
|
-
const { manifests } = await (0,
|
|
5233
|
+
const { manifests } = await (0, import_core89.getSandboxPluginCatalog)().ensureLoaded(tenantId);
|
|
5234
5234
|
return buildTenantExposedGrants(Object.values(manifests));
|
|
5235
5235
|
},
|
|
5236
5236
|
resolvableAssistants: async (tenantId) => new Set(
|
|
5237
|
-
|
|
5237
|
+
import_core89.agentLatticeManager.getAllAgentLatticesByTenant(tenantId).map((lattice) => lattice.config.key)
|
|
5238
5238
|
)
|
|
5239
5239
|
};
|
|
5240
5240
|
}
|
|
5241
|
-
var
|
|
5241
|
+
var import_core89, AGENT_REFLECTION_CACHE_TTL_MS, cache, PLUGIN_REFLECTION_CACHE_TTL_MS, pluginCache;
|
|
5242
5242
|
var init_sandboxOpenReflection = __esm({
|
|
5243
5243
|
"src/services/open/sandboxOpenReflection.ts"() {
|
|
5244
5244
|
"use strict";
|
|
5245
|
-
|
|
5245
|
+
import_core89 = require("@axiom-lattice/core");
|
|
5246
5246
|
AGENT_REFLECTION_CACHE_TTL_MS = 6e4;
|
|
5247
5247
|
cache = /* @__PURE__ */ new Map();
|
|
5248
5248
|
PLUGIN_REFLECTION_CACHE_TTL_MS = 6e4;
|
|
@@ -5288,7 +5288,7 @@ function createSandboxOpenCredentialProvider(options) {
|
|
|
5288
5288
|
};
|
|
5289
5289
|
}
|
|
5290
5290
|
function registerGatewaySandboxOpenCredentialProvider(onError) {
|
|
5291
|
-
return (0,
|
|
5291
|
+
return (0, import_core90.registerSandboxOpenCredentialProvider)(
|
|
5292
5292
|
createSandboxOpenCredentialProvider({
|
|
5293
5293
|
gatewayUrl: process.env.PUBLIC_GATEWAY_URL?.trim() || void 0,
|
|
5294
5294
|
onError
|
|
@@ -5296,11 +5296,11 @@ function registerGatewaySandboxOpenCredentialProvider(onError) {
|
|
|
5296
5296
|
{ onError }
|
|
5297
5297
|
);
|
|
5298
5298
|
}
|
|
5299
|
-
var
|
|
5299
|
+
var import_core90, DEFAULT_SANDBOX_OPEN_GRANTS, MAX_SANDBOX_OPEN_DEPTH;
|
|
5300
5300
|
var init_sandboxOpenCredentialProvider = __esm({
|
|
5301
5301
|
"src/services/open/sandboxOpenCredentialProvider.ts"() {
|
|
5302
5302
|
"use strict";
|
|
5303
|
-
|
|
5303
|
+
import_core90 = require("@axiom-lattice/core");
|
|
5304
5304
|
init_openToken();
|
|
5305
5305
|
init_sandboxOpenReflection();
|
|
5306
5306
|
DEFAULT_SANDBOX_OPEN_GRANTS = [
|
|
@@ -5337,12 +5337,12 @@ var resources_exports = {};
|
|
|
5337
5337
|
__export(resources_exports, {
|
|
5338
5338
|
ResourceController: () => ResourceController
|
|
5339
5339
|
});
|
|
5340
|
-
var import_bcryptjs,
|
|
5340
|
+
var import_bcryptjs, import_core91, ResourceController;
|
|
5341
5341
|
var init_resources = __esm({
|
|
5342
5342
|
"src/controllers/resources.ts"() {
|
|
5343
5343
|
"use strict";
|
|
5344
5344
|
import_bcryptjs = __toESM(require("bcryptjs"));
|
|
5345
|
-
|
|
5345
|
+
import_core91 = require("@axiom-lattice/core");
|
|
5346
5346
|
init_mime();
|
|
5347
5347
|
init_http_range();
|
|
5348
5348
|
init_sandboxGrants();
|
|
@@ -5359,14 +5359,14 @@ var init_resources = __esm({
|
|
|
5359
5359
|
if (!workspaceId || !projectId) {
|
|
5360
5360
|
return reply.status(400).send({ error: "x-workspace-id and x-project-id headers required" });
|
|
5361
5361
|
}
|
|
5362
|
-
const payload = (0,
|
|
5362
|
+
const payload = (0, import_core91.createSharePayload)(
|
|
5363
5363
|
tenantId,
|
|
5364
5364
|
workspaceId,
|
|
5365
5365
|
projectId,
|
|
5366
5366
|
userId,
|
|
5367
5367
|
body
|
|
5368
5368
|
);
|
|
5369
|
-
const token = (0,
|
|
5369
|
+
const token = (0, import_core91.generateToken)();
|
|
5370
5370
|
try {
|
|
5371
5371
|
await this.deps.store.create({ ...payload, token });
|
|
5372
5372
|
this.deps.logger.info(
|
|
@@ -5518,7 +5518,7 @@ var init_resources = __esm({
|
|
|
5518
5518
|
resourcePath: subPath
|
|
5519
5519
|
}, subPath, ext, request, reply);
|
|
5520
5520
|
}
|
|
5521
|
-
const volume = (0,
|
|
5521
|
+
const volume = (0, import_core91.buildNamedVolumeName)("p", "project", tenantId, workspaceId, projectId);
|
|
5522
5522
|
return this._resolveAndServe(
|
|
5523
5523
|
volume,
|
|
5524
5524
|
subPath,
|
|
@@ -10178,23 +10178,13 @@ var import_core20 = require("@axiom-lattice/core");
|
|
|
10178
10178
|
|
|
10179
10179
|
// src/services/plugins/tenantPluginResolver.ts
|
|
10180
10180
|
var import_core19 = require("@axiom-lattice/core");
|
|
10181
|
-
async function listTenantPlugins(tenantId) {
|
|
10182
|
-
let tenantPlugins = [];
|
|
10183
|
-
try {
|
|
10184
|
-
tenantPlugins = (await (0, import_core19.getSandboxPluginCatalog)().ensureLoaded(tenantId)).plugins;
|
|
10185
|
-
} catch {
|
|
10186
|
-
tenantPlugins = [];
|
|
10187
|
-
}
|
|
10188
|
-
const globalPlugins = import_core19.PluginRegistry.list().map((type) => import_core19.PluginRegistry.get(type)).filter((p) => Boolean(p));
|
|
10189
|
-
return (0, import_core19.mergePluginSources)(globalPlugins, tenantPlugins);
|
|
10190
|
-
}
|
|
10191
10181
|
async function resolveTenantPluginByType(tenantId, type) {
|
|
10192
|
-
return (await listTenantPlugins(tenantId)).find((p) => p.meta.type === type);
|
|
10182
|
+
return (await (0, import_core19.listTenantPlugins)(tenantId)).find((p) => p.meta.type === type);
|
|
10193
10183
|
}
|
|
10194
10184
|
|
|
10195
10185
|
// src/controllers/middleware-types.ts
|
|
10196
10186
|
async function collectMiddlewareMetas(tenantId) {
|
|
10197
|
-
return (await listTenantPlugins(tenantId)).map(import_core20.serializePluginMeta);
|
|
10187
|
+
return (await (0, import_core19.listTenantPlugins)(tenantId)).map(import_core20.serializePluginMeta);
|
|
10198
10188
|
}
|
|
10199
10189
|
function middlewareTypesRoutes(fastify2) {
|
|
10200
10190
|
fastify2.get("/api/middleware-types", async (request, reply) => {
|
|
@@ -13329,8 +13319,17 @@ function registerMetricsServerConfigRoutes(app2) {
|
|
|
13329
13319
|
}
|
|
13330
13320
|
|
|
13331
13321
|
// src/controllers/connections.ts
|
|
13332
|
-
var
|
|
13322
|
+
var import_core33 = require("@axiom-lattice/core");
|
|
13333
13323
|
var import_zod2 = require("zod");
|
|
13324
|
+
|
|
13325
|
+
// src/services/plugins/connectionSecretFields.ts
|
|
13326
|
+
var import_core32 = require("@axiom-lattice/core");
|
|
13327
|
+
function secretFieldsForConnection(plugin) {
|
|
13328
|
+
const keys2 = (0, import_core32.connectionSecretFields)(plugin);
|
|
13329
|
+
return keys2.length > 0 ? keys2 : void 0;
|
|
13330
|
+
}
|
|
13331
|
+
|
|
13332
|
+
// src/controllers/connections.ts
|
|
13334
13333
|
var createBody = import_zod2.z.object({
|
|
13335
13334
|
type: import_zod2.z.string().min(1),
|
|
13336
13335
|
key: import_zod2.z.string().min(1),
|
|
@@ -13352,28 +13351,9 @@ function getTenant(request) {
|
|
|
13352
13351
|
async function getTenantPlugin(request, type) {
|
|
13353
13352
|
return resolveTenantPluginByType(getTenant(request), type);
|
|
13354
13353
|
}
|
|
13355
|
-
function maskSecrets(config) {
|
|
13356
|
-
const sensitive = /* @__PURE__ */ new Set([
|
|
13357
|
-
"password",
|
|
13358
|
-
"secret",
|
|
13359
|
-
"token",
|
|
13360
|
-
"apikey",
|
|
13361
|
-
"api_key",
|
|
13362
|
-
"session",
|
|
13363
|
-
"privatekey",
|
|
13364
|
-
"private_key",
|
|
13365
|
-
"accesskey",
|
|
13366
|
-
"access_key"
|
|
13367
|
-
]);
|
|
13368
|
-
const out = {};
|
|
13369
|
-
for (const [k, v] of Object.entries(config)) {
|
|
13370
|
-
out[k] = sensitive.has(k.toLowerCase()) ? "********" : v;
|
|
13371
|
-
}
|
|
13372
|
-
return out;
|
|
13373
|
-
}
|
|
13374
13354
|
async function resolveConfig(type, body, tenantId) {
|
|
13375
13355
|
if (body.key) {
|
|
13376
|
-
const entry = await
|
|
13356
|
+
const entry = await import_core33.ConnectionRegistry.get(type, body.key, tenantId);
|
|
13377
13357
|
if (!entry) throw { status: 404, error: `Connection "${body.key}" not found` };
|
|
13378
13358
|
return entry.config;
|
|
13379
13359
|
}
|
|
@@ -13384,25 +13364,27 @@ function connectionRoutes(fastify2) {
|
|
|
13384
13364
|
fastify2.get("/api/connections", async (request, reply) => {
|
|
13385
13365
|
const { type } = request.query;
|
|
13386
13366
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
13387
|
-
const entries = await
|
|
13367
|
+
const entries = await import_core33.ConnectionRegistry.list(type, getTenant(request));
|
|
13388
13368
|
return reply.send({
|
|
13389
13369
|
success: true,
|
|
13390
|
-
data: { records: entries
|
|
13370
|
+
data: { records: entries, total: entries.length }
|
|
13391
13371
|
});
|
|
13392
13372
|
});
|
|
13393
13373
|
fastify2.post("/api/connections", async (request, reply) => {
|
|
13394
13374
|
const parsed = createBody.parse(request.body);
|
|
13395
|
-
const
|
|
13375
|
+
const plugin = await getTenantPlugin(request, parsed.type);
|
|
13376
|
+
const entry = await import_core33.ConnectionRegistry.create({
|
|
13396
13377
|
tenantId: getTenant(request),
|
|
13397
13378
|
type: parsed.type,
|
|
13398
13379
|
key: parsed.key,
|
|
13399
13380
|
name: parsed.name,
|
|
13400
13381
|
description: parsed.description,
|
|
13401
|
-
config: parsed.config
|
|
13382
|
+
config: parsed.config,
|
|
13383
|
+
secretFields: secretFieldsForConnection(plugin)
|
|
13402
13384
|
});
|
|
13403
13385
|
return reply.status(201).send({
|
|
13404
13386
|
success: true,
|
|
13405
|
-
data:
|
|
13387
|
+
data: entry
|
|
13406
13388
|
});
|
|
13407
13389
|
});
|
|
13408
13390
|
fastify2.put("/api/connections/:key", async (request, reply) => {
|
|
@@ -13411,25 +13393,27 @@ function connectionRoutes(fastify2) {
|
|
|
13411
13393
|
const { key } = request.params;
|
|
13412
13394
|
const body = request.body;
|
|
13413
13395
|
const tenantId = getTenant(request);
|
|
13414
|
-
const existing = await
|
|
13396
|
+
const existing = await import_core33.ConnectionRegistry.get(type, key, tenantId);
|
|
13415
13397
|
if (!existing) return reply.status(404).send({ error: "not found" });
|
|
13398
|
+
const plugin = await getTenantPlugin(request, type);
|
|
13416
13399
|
const updates = {};
|
|
13417
13400
|
if (body.name !== void 0) updates.name = body.name;
|
|
13418
13401
|
if (body.description !== void 0) updates.description = body.description;
|
|
13419
13402
|
if (body.config) {
|
|
13420
13403
|
updates.config = { ...existing.config, ...body.config };
|
|
13404
|
+
updates.secretFields = secretFieldsForConnection(plugin);
|
|
13421
13405
|
}
|
|
13422
|
-
const entry = await
|
|
13406
|
+
const entry = await import_core33.ConnectionRegistry.update(tenantId, type, key, updates);
|
|
13423
13407
|
return reply.send({
|
|
13424
13408
|
success: true,
|
|
13425
|
-
data:
|
|
13409
|
+
data: entry
|
|
13426
13410
|
});
|
|
13427
13411
|
});
|
|
13428
13412
|
fastify2.delete("/api/connections/:key", async (request, reply) => {
|
|
13429
13413
|
const { type } = request.query;
|
|
13430
13414
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
13431
13415
|
const { key } = request.params;
|
|
13432
|
-
const ok = await
|
|
13416
|
+
const ok = await import_core33.ConnectionRegistry.delete(getTenant(request), type, key);
|
|
13433
13417
|
return reply.send({ success: ok });
|
|
13434
13418
|
});
|
|
13435
13419
|
fastify2.post("/api/connections/test", async (request, reply) => {
|
|
@@ -13490,7 +13474,7 @@ function connectionRoutes(fastify2) {
|
|
|
13490
13474
|
}
|
|
13491
13475
|
|
|
13492
13476
|
// src/controllers/mcp-configs.ts
|
|
13493
|
-
var
|
|
13477
|
+
var import_core34 = require("@axiom-lattice/core");
|
|
13494
13478
|
var import_crypto8 = require("crypto");
|
|
13495
13479
|
|
|
13496
13480
|
// src/services/mcpConfigSync.ts
|
|
@@ -13539,15 +13523,15 @@ function getTenantId11(request) {
|
|
|
13539
13523
|
function broadcastMcpConfigChanged(tenantId, serverKey) {
|
|
13540
13524
|
if (!tenantId || !serverKey) return;
|
|
13541
13525
|
try {
|
|
13542
|
-
const outbox = (0,
|
|
13543
|
-
void publishMcpConfigChanged(outbox, (0,
|
|
13526
|
+
const outbox = (0, import_core34.getStoreLattice)("default", "outbox").store;
|
|
13527
|
+
void publishMcpConfigChanged(outbox, (0, import_core34.getReplicaId)(), tenantId, serverKey);
|
|
13544
13528
|
} catch {
|
|
13545
13529
|
}
|
|
13546
13530
|
}
|
|
13547
13531
|
async function getMcpServerConfigList(request, reply) {
|
|
13548
13532
|
const tenantId = getTenantId11(request);
|
|
13549
13533
|
try {
|
|
13550
|
-
const storeLattice = (0,
|
|
13534
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13551
13535
|
const store2 = storeLattice.store;
|
|
13552
13536
|
const configs = await store2.getAllConfigs(tenantId);
|
|
13553
13537
|
return {
|
|
@@ -13574,7 +13558,7 @@ async function getMcpServerConfig(request, reply) {
|
|
|
13574
13558
|
const tenantId = getTenantId11(request);
|
|
13575
13559
|
const { key } = request.params;
|
|
13576
13560
|
try {
|
|
13577
|
-
const storeLattice = (0,
|
|
13561
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13578
13562
|
const store2 = storeLattice.store;
|
|
13579
13563
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
13580
13564
|
if (!config) {
|
|
@@ -13600,7 +13584,7 @@ async function createMcpServerConfig(request, reply) {
|
|
|
13600
13584
|
const tenantId = getTenantId11(request);
|
|
13601
13585
|
const body = request.body;
|
|
13602
13586
|
try {
|
|
13603
|
-
const storeLattice = (0,
|
|
13587
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13604
13588
|
const store2 = storeLattice.store;
|
|
13605
13589
|
const existing = await store2.getConfigByKey(tenantId, body.key);
|
|
13606
13590
|
if (existing) {
|
|
@@ -13641,7 +13625,7 @@ async function updateMcpServerConfig(request, reply) {
|
|
|
13641
13625
|
const { key } = request.params;
|
|
13642
13626
|
const updates = request.body;
|
|
13643
13627
|
try {
|
|
13644
|
-
const storeLattice = (0,
|
|
13628
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13645
13629
|
const store2 = storeLattice.store;
|
|
13646
13630
|
const existing = await store2.getConfigByKey(tenantId, key);
|
|
13647
13631
|
if (!existing) {
|
|
@@ -13663,13 +13647,13 @@ async function updateMcpServerConfig(request, reply) {
|
|
|
13663
13647
|
}
|
|
13664
13648
|
if (configChanged) {
|
|
13665
13649
|
try {
|
|
13666
|
-
const connection = (0,
|
|
13667
|
-
|
|
13650
|
+
const connection = (0, import_core34.convertToConnection)(updated.config);
|
|
13651
|
+
import_core34.mcpManager.registerServer(tenantId, key, connection, {
|
|
13668
13652
|
timeoutMs: updated.config.timeout,
|
|
13669
13653
|
maxAttempts: updated.config.retryAttempts
|
|
13670
13654
|
});
|
|
13671
|
-
await
|
|
13672
|
-
await
|
|
13655
|
+
await import_core34.mcpManager.ensureConnected(tenantId, key);
|
|
13656
|
+
await import_core34.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
|
|
13673
13657
|
await store2.updateConfig(tenantId, existing.id, { status: "connected" });
|
|
13674
13658
|
updated.status = "connected";
|
|
13675
13659
|
} catch (error) {
|
|
@@ -13677,16 +13661,16 @@ async function updateMcpServerConfig(request, reply) {
|
|
|
13677
13661
|
await store2.updateConfig(tenantId, existing.id, { status: "error" });
|
|
13678
13662
|
updated.status = "error";
|
|
13679
13663
|
}
|
|
13680
|
-
} else if (toolsChanged &&
|
|
13664
|
+
} else if (toolsChanged && import_core34.mcpManager.hasServer(tenantId, key)) {
|
|
13681
13665
|
try {
|
|
13682
|
-
await
|
|
13666
|
+
await import_core34.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
|
|
13683
13667
|
} catch (error) {
|
|
13684
13668
|
console.warn("Failed to re-register MCP tools:", error);
|
|
13685
13669
|
}
|
|
13686
13670
|
}
|
|
13687
|
-
if (statusChanged && updated.status !== "connected" &&
|
|
13671
|
+
if (statusChanged && updated.status !== "connected" && import_core34.mcpManager.hasServer(tenantId, key)) {
|
|
13688
13672
|
try {
|
|
13689
|
-
await
|
|
13673
|
+
await import_core34.mcpManager.removeServer(tenantId, key);
|
|
13690
13674
|
} catch (error) {
|
|
13691
13675
|
console.warn("Failed to remove MCP server:", error);
|
|
13692
13676
|
}
|
|
@@ -13711,7 +13695,7 @@ async function deleteMcpServerConfig(request, reply) {
|
|
|
13711
13695
|
const tenantId = getTenantId11(request);
|
|
13712
13696
|
const { keyOrId } = request.params;
|
|
13713
13697
|
try {
|
|
13714
|
-
const storeLattice = (0,
|
|
13698
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13715
13699
|
const store2 = storeLattice.store;
|
|
13716
13700
|
let config = await store2.getConfigByKey(tenantId, keyOrId);
|
|
13717
13701
|
let configKey = keyOrId;
|
|
@@ -13729,8 +13713,8 @@ async function deleteMcpServerConfig(request, reply) {
|
|
|
13729
13713
|
};
|
|
13730
13714
|
}
|
|
13731
13715
|
try {
|
|
13732
|
-
if (
|
|
13733
|
-
await
|
|
13716
|
+
if (import_core34.mcpManager.hasServer(tenantId, configKey)) {
|
|
13717
|
+
await import_core34.mcpManager.removeServer(tenantId, configKey);
|
|
13734
13718
|
}
|
|
13735
13719
|
} catch (error) {
|
|
13736
13720
|
console.warn("Failed to remove from MCP manager:", error);
|
|
@@ -13759,7 +13743,7 @@ async function testMcpServerConnection(request, reply) {
|
|
|
13759
13743
|
const tenantId = getTenantId11(request);
|
|
13760
13744
|
const { key } = request.params;
|
|
13761
13745
|
try {
|
|
13762
|
-
const storeLattice = (0,
|
|
13746
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13763
13747
|
const store2 = storeLattice.store;
|
|
13764
13748
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
13765
13749
|
if (!config) {
|
|
@@ -13771,8 +13755,8 @@ async function testMcpServerConnection(request, reply) {
|
|
|
13771
13755
|
}
|
|
13772
13756
|
try {
|
|
13773
13757
|
const testKey = `__test_${key}_${Date.now()}`;
|
|
13774
|
-
const connection = (0,
|
|
13775
|
-
const { latency } = await
|
|
13758
|
+
const connection = (0, import_core34.convertToConnection)(config.config);
|
|
13759
|
+
const { latency } = await import_core34.McpLatticeManager.testConnection(testKey, connection);
|
|
13776
13760
|
return {
|
|
13777
13761
|
success: true,
|
|
13778
13762
|
message: "Connection test successful",
|
|
@@ -13807,7 +13791,7 @@ async function listMcpServerTools(request, reply) {
|
|
|
13807
13791
|
const tenantId = getTenantId11(request);
|
|
13808
13792
|
const { key } = request.params;
|
|
13809
13793
|
try {
|
|
13810
|
-
const storeLattice = (0,
|
|
13794
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13811
13795
|
const store2 = storeLattice.store;
|
|
13812
13796
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
13813
13797
|
if (!config) {
|
|
@@ -13817,7 +13801,7 @@ async function listMcpServerTools(request, reply) {
|
|
|
13817
13801
|
message: "MCP server configuration not found"
|
|
13818
13802
|
};
|
|
13819
13803
|
}
|
|
13820
|
-
const wasConnected =
|
|
13804
|
+
const wasConnected = import_core34.mcpManager.isServerConnected(tenantId, key);
|
|
13821
13805
|
if (!wasConnected) {
|
|
13822
13806
|
await connectAndRegisterTools(config);
|
|
13823
13807
|
}
|
|
@@ -13828,7 +13812,7 @@ async function listMcpServerTools(request, reply) {
|
|
|
13828
13812
|
if (!wasConnected || statusStale) {
|
|
13829
13813
|
broadcastMcpConfigChanged(tenantId, key);
|
|
13830
13814
|
}
|
|
13831
|
-
const tools = await
|
|
13815
|
+
const tools = await import_core34.mcpManager.getServerTools(tenantId, key);
|
|
13832
13816
|
return {
|
|
13833
13817
|
success: true,
|
|
13834
13818
|
message: "Tools retrieved successfully",
|
|
@@ -13848,7 +13832,7 @@ async function connectMcpServer(request, reply) {
|
|
|
13848
13832
|
const tenantId = getTenantId11(request);
|
|
13849
13833
|
const { key } = request.params;
|
|
13850
13834
|
try {
|
|
13851
|
-
const storeLattice = (0,
|
|
13835
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13852
13836
|
const store2 = storeLattice.store;
|
|
13853
13837
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
13854
13838
|
if (!config) {
|
|
@@ -13870,7 +13854,7 @@ async function connectMcpServer(request, reply) {
|
|
|
13870
13854
|
};
|
|
13871
13855
|
} catch (error) {
|
|
13872
13856
|
console.error("Failed to connect MCP server:", error);
|
|
13873
|
-
const storeLattice = (0,
|
|
13857
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13874
13858
|
const store2 = storeLattice.store;
|
|
13875
13859
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
13876
13860
|
if (config) {
|
|
@@ -13887,7 +13871,7 @@ async function disconnectMcpServer(request, reply) {
|
|
|
13887
13871
|
const tenantId = getTenantId11(request);
|
|
13888
13872
|
const { key } = request.params;
|
|
13889
13873
|
try {
|
|
13890
|
-
const storeLattice = (0,
|
|
13874
|
+
const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
|
|
13891
13875
|
const store2 = storeLattice.store;
|
|
13892
13876
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
13893
13877
|
if (!config) {
|
|
@@ -13897,8 +13881,8 @@ async function disconnectMcpServer(request, reply) {
|
|
|
13897
13881
|
message: "MCP server configuration not found"
|
|
13898
13882
|
};
|
|
13899
13883
|
}
|
|
13900
|
-
if (
|
|
13901
|
-
await
|
|
13884
|
+
if (import_core34.mcpManager.hasServer(tenantId, key)) {
|
|
13885
|
+
await import_core34.mcpManager.removeServer(tenantId, key);
|
|
13902
13886
|
}
|
|
13903
13887
|
const updated = await store2.updateConfig(tenantId, config.id, {
|
|
13904
13888
|
status: "disconnected"
|
|
@@ -13928,8 +13912,8 @@ async function testMcpServerTools(request, reply) {
|
|
|
13928
13912
|
};
|
|
13929
13913
|
}
|
|
13930
13914
|
const testKey = `__test_${Date.now()}`;
|
|
13931
|
-
const connection = (0,
|
|
13932
|
-
const { tools } = await
|
|
13915
|
+
const connection = (0, import_core34.convertToConnection)(body.config);
|
|
13916
|
+
const { tools } = await import_core34.McpLatticeManager.testConnection(testKey, connection);
|
|
13933
13917
|
return {
|
|
13934
13918
|
success: true,
|
|
13935
13919
|
message: "Tools retrieved successfully",
|
|
@@ -13946,14 +13930,14 @@ async function testMcpServerTools(request, reply) {
|
|
|
13946
13930
|
}
|
|
13947
13931
|
}
|
|
13948
13932
|
async function connectAndRegisterTools(config) {
|
|
13949
|
-
const connection = (0,
|
|
13950
|
-
|
|
13933
|
+
const connection = (0, import_core34.convertToConnection)(config.config);
|
|
13934
|
+
import_core34.mcpManager.registerServer(config.tenantId, config.key, connection, {
|
|
13951
13935
|
timeoutMs: config.config.timeout,
|
|
13952
13936
|
maxAttempts: config.config.retryAttempts,
|
|
13953
13937
|
selectedTools: config.selectedTools
|
|
13954
13938
|
});
|
|
13955
|
-
await
|
|
13956
|
-
await
|
|
13939
|
+
await import_core34.mcpManager.ensureConnected(config.tenantId, config.key);
|
|
13940
|
+
await import_core34.mcpManager.registerToolsToToolLattice(
|
|
13957
13941
|
config.tenantId,
|
|
13958
13942
|
config.key,
|
|
13959
13943
|
config.selectedTools
|
|
@@ -13974,7 +13958,7 @@ function registerMcpServerConfigRoutes(app2) {
|
|
|
13974
13958
|
|
|
13975
13959
|
// src/routes/mcp-apps.ts
|
|
13976
13960
|
var import_protocols6 = require("@axiom-lattice/protocols");
|
|
13977
|
-
var
|
|
13961
|
+
var import_core35 = require("@axiom-lattice/core");
|
|
13978
13962
|
|
|
13979
13963
|
// src/services/mcp-ui/UiResourceResolver.ts
|
|
13980
13964
|
var import_node_crypto5 = require("crypto");
|
|
@@ -14339,26 +14323,26 @@ function createDefaultPluginBackend() {
|
|
|
14339
14323
|
return {
|
|
14340
14324
|
resolvePlugin: (tenantId, type) => resolveTenantPluginByType(tenantId, type),
|
|
14341
14325
|
catalog: {
|
|
14342
|
-
readPluginFile: (tenantId, pluginType, relPath) => (0,
|
|
14343
|
-
getValidatedManifest: (tenantId, pluginType) => (0,
|
|
14344
|
-
getExecutor: () => (0,
|
|
14326
|
+
readPluginFile: (tenantId, pluginType, relPath) => (0, import_core35.getSandboxPluginCatalog)().readPluginFile(tenantId, pluginType, relPath),
|
|
14327
|
+
getValidatedManifest: (tenantId, pluginType) => (0, import_core35.getSandboxPluginCatalog)().getValidatedManifest(tenantId, pluginType),
|
|
14328
|
+
getExecutor: () => (0, import_core35.getSandboxPluginCatalog)().getExecutor()
|
|
14345
14329
|
}
|
|
14346
14330
|
};
|
|
14347
14331
|
}
|
|
14348
14332
|
function resolveMcpAppDeps(pluginBackend = createDefaultPluginBackend()) {
|
|
14349
14333
|
const uiResourceResolver = new UiResourceResolver({
|
|
14350
14334
|
store: new InMemoryMcpUiResourceCacheStore(),
|
|
14351
|
-
fetchMcp: (tenantId, serverKey, resourceUri) =>
|
|
14335
|
+
fetchMcp: (tenantId, serverKey, resourceUri) => import_core35.mcpManager.readUiResource(tenantId, serverKey, resourceUri),
|
|
14352
14336
|
fetchPlugin: (tenantId, pluginType, resource) => fetchPluginUiResource(pluginBackend, tenantId, pluginType, resource)
|
|
14353
14337
|
});
|
|
14354
14338
|
return {
|
|
14355
14339
|
resolveUiResource: (tenantId, ref) => uiResourceResolver.resolve(tenantId, ref),
|
|
14356
|
-
callTool: (tenantId, ref, name, args, context) => ref.kind === "mcp" ?
|
|
14340
|
+
callTool: (tenantId, ref, name, args, context) => ref.kind === "mcp" ? import_core35.mcpManager.callServerTool(tenantId, ref.serverKey, name, args) : callPluginTool(pluginBackend, tenantId, ref, name, args, context),
|
|
14357
14341
|
// Plugin refs reach these only after `tools/call`; the handler treats the
|
|
14358
14342
|
// rejection as an unsupported method (403). The branches are live because
|
|
14359
14343
|
// the pure handler deliberately delegates method policy to the deps.
|
|
14360
|
-
readResource: (tenantId, ref, uri) => ref.kind === "mcp" ?
|
|
14361
|
-
listTools: (tenantId, ref) => ref.kind === "mcp" ?
|
|
14344
|
+
readResource: (tenantId, ref, uri) => ref.kind === "mcp" ? import_core35.mcpManager.readServerResource(tenantId, ref.serverKey, uri) : Promise.reject(new PluginMethodNotSupportedError("resources/read")),
|
|
14345
|
+
listTools: (tenantId, ref) => ref.kind === "mcp" ? import_core35.mcpManager.getAvailableTools(tenantId, ref.serverKey) : Promise.reject(new PluginMethodNotSupportedError("tools/list"))
|
|
14362
14346
|
};
|
|
14363
14347
|
}
|
|
14364
14348
|
function firstHeader(request, name) {
|
|
@@ -14402,12 +14386,12 @@ function registerMcpAppRoutes(fastify2) {
|
|
|
14402
14386
|
}
|
|
14403
14387
|
|
|
14404
14388
|
// src/controllers/eval.ts
|
|
14405
|
-
var
|
|
14389
|
+
var import_core37 = require("@axiom-lattice/core");
|
|
14406
14390
|
var import_uuid5 = require("uuid");
|
|
14407
14391
|
|
|
14408
14392
|
// src/services/eval-runner.ts
|
|
14409
14393
|
var import_events = require("events");
|
|
14410
|
-
var
|
|
14394
|
+
var import_core36 = require("@axiom-lattice/core");
|
|
14411
14395
|
var import_uuid4 = require("uuid");
|
|
14412
14396
|
var TERMINAL_PERSIST_ATTEMPTS = 2;
|
|
14413
14397
|
function mapLogs(logs) {
|
|
@@ -14517,12 +14501,12 @@ var EvalRunner = class {
|
|
|
14517
14501
|
const judgeModelKey = judgeCfg.modelKey || "";
|
|
14518
14502
|
let resolvedJudgeModelKey;
|
|
14519
14503
|
if (judgeModelKey) {
|
|
14520
|
-
if (!
|
|
14504
|
+
if (!import_core36.modelLatticeManager.hasLattice(judgeModelKey)) {
|
|
14521
14505
|
throw new Error(`Judge model "${judgeModelKey}" is not registered`);
|
|
14522
14506
|
}
|
|
14523
14507
|
resolvedJudgeModelKey = judgeModelKey;
|
|
14524
14508
|
} else {
|
|
14525
|
-
const models =
|
|
14509
|
+
const models = import_core36.modelLatticeManager.getAllLattices();
|
|
14526
14510
|
const defaultModel = models.find((m) => m.key === "default");
|
|
14527
14511
|
resolvedJudgeModelKey = defaultModel?.key ?? models[0]?.key ?? "";
|
|
14528
14512
|
if (!resolvedJudgeModelKey) {
|
|
@@ -14630,7 +14614,7 @@ var EvalRunner = class {
|
|
|
14630
14614
|
};
|
|
14631
14615
|
const runPromise = (async () => {
|
|
14632
14616
|
try {
|
|
14633
|
-
const evalProject = new
|
|
14617
|
+
const evalProject = new import_core36.LatticeEvalProject(projectConfig, onCaseComplete);
|
|
14634
14618
|
const calibration = await evalProject.calibrateJudge();
|
|
14635
14619
|
if (!calibration.ok && !calibration.bypassed) {
|
|
14636
14620
|
throw new Error(`Judge calibration failed: ${calibration.reason}`);
|
|
@@ -14734,7 +14718,7 @@ var EvalRunner = class {
|
|
|
14734
14718
|
return ctx !== void 0 && !ctx.terminal.workerSettled && (tenantId === void 0 || ctx.tenantId === tenantId);
|
|
14735
14719
|
}
|
|
14736
14720
|
getEvalStore() {
|
|
14737
|
-
return (0,
|
|
14721
|
+
return (0, import_core36.getStoreLattice)("default", "eval").store;
|
|
14738
14722
|
}
|
|
14739
14723
|
releaseProjectLease(leaseKey, leaseToken) {
|
|
14740
14724
|
if (this.projectLeases.get(leaseKey) === leaseToken) this.projectLeases.delete(leaseKey);
|
|
@@ -14751,7 +14735,7 @@ function getTenantId12(request) {
|
|
|
14751
14735
|
return request.headers["x-tenant-id"] || "default";
|
|
14752
14736
|
}
|
|
14753
14737
|
function getEvalStore() {
|
|
14754
|
-
return (0,
|
|
14738
|
+
return (0, import_core37.getStoreLattice)("default", "eval").store;
|
|
14755
14739
|
}
|
|
14756
14740
|
async function getOwnedSuite(store2, tenantId, projectId, suiteId) {
|
|
14757
14741
|
const project = await store2.getProjectById(tenantId, projectId);
|
|
@@ -15281,11 +15265,11 @@ data: ${JSON.stringify(event.data)}
|
|
|
15281
15265
|
}
|
|
15282
15266
|
|
|
15283
15267
|
// src/controllers/users.ts
|
|
15284
|
-
var
|
|
15268
|
+
var import_core38 = require("@axiom-lattice/core");
|
|
15285
15269
|
var import_uuid6 = require("uuid");
|
|
15286
15270
|
var UsersController = class {
|
|
15287
15271
|
constructor() {
|
|
15288
|
-
this.userStore = (0,
|
|
15272
|
+
this.userStore = (0, import_core38.getStoreLattice)("default", "user").store;
|
|
15289
15273
|
}
|
|
15290
15274
|
async listUsers(request, reply) {
|
|
15291
15275
|
const { email } = request.query;
|
|
@@ -15363,11 +15347,11 @@ function registerUserRoutes(app2) {
|
|
|
15363
15347
|
}
|
|
15364
15348
|
|
|
15365
15349
|
// src/controllers/tenants.ts
|
|
15366
|
-
var
|
|
15350
|
+
var import_core39 = require("@axiom-lattice/core");
|
|
15367
15351
|
var import_uuid7 = require("uuid");
|
|
15368
15352
|
var TenantsController = class {
|
|
15369
15353
|
constructor() {
|
|
15370
|
-
this.tenantStore = (0,
|
|
15354
|
+
this.tenantStore = (0, import_core39.getStoreLattice)("default", "tenant").store;
|
|
15371
15355
|
}
|
|
15372
15356
|
// ==================== Tenant CRUD ====================
|
|
15373
15357
|
async listTenants(request, reply) {
|
|
@@ -15431,7 +15415,7 @@ function registerTenantRoutes(app2) {
|
|
|
15431
15415
|
}
|
|
15432
15416
|
|
|
15433
15417
|
// src/controllers/auth.ts
|
|
15434
|
-
var
|
|
15418
|
+
var import_core40 = require("@axiom-lattice/core");
|
|
15435
15419
|
var import_uuid8 = require("uuid");
|
|
15436
15420
|
var import_node_crypto6 = require("crypto");
|
|
15437
15421
|
var defaultAuthConfig = {
|
|
@@ -15441,9 +15425,9 @@ var defaultAuthConfig = {
|
|
|
15441
15425
|
};
|
|
15442
15426
|
var AuthController = class {
|
|
15443
15427
|
constructor(config = {}) {
|
|
15444
|
-
this.userStore = (0,
|
|
15445
|
-
this.tenantStore = (0,
|
|
15446
|
-
this.userTenantLinkStore = (0,
|
|
15428
|
+
this.userStore = (0, import_core40.getStoreLattice)("default", "user").store;
|
|
15429
|
+
this.tenantStore = (0, import_core40.getStoreLattice)("default", "tenant").store;
|
|
15430
|
+
this.userTenantLinkStore = (0, import_core40.getStoreLattice)("default", "userTenantLink").store;
|
|
15447
15431
|
this.config = { ...defaultAuthConfig, ...config };
|
|
15448
15432
|
}
|
|
15449
15433
|
async register(request, reply) {
|
|
@@ -15602,7 +15586,7 @@ var AuthController = class {
|
|
|
15602
15586
|
const linkMeta = link?.metadata || {};
|
|
15603
15587
|
let personalAssistant = null;
|
|
15604
15588
|
if (linkMeta.personalAssistantId) {
|
|
15605
|
-
const assistantStore = (0,
|
|
15589
|
+
const assistantStore = (0, import_core40.getStoreLattice)("default", "assistant").store;
|
|
15606
15590
|
const exists = await assistantStore.hasAssistant(tenantId, linkMeta.personalAssistantId);
|
|
15607
15591
|
if (exists) {
|
|
15608
15592
|
personalAssistant = {
|
|
@@ -16739,7 +16723,7 @@ function registerChannelInstallationRoutes(app2) {
|
|
|
16739
16723
|
|
|
16740
16724
|
// src/controllers/channel-bindings.ts
|
|
16741
16725
|
var import_protocols8 = require("@axiom-lattice/protocols");
|
|
16742
|
-
var
|
|
16726
|
+
var import_core41 = require("@axiom-lattice/core");
|
|
16743
16727
|
function getTenantId14(request) {
|
|
16744
16728
|
const userTenantId = request.user?.tenantId;
|
|
16745
16729
|
if (typeof userTenantId === "string" && userTenantId) return userTenantId;
|
|
@@ -16797,7 +16781,7 @@ function snapshotPublicUpdate(value) {
|
|
|
16797
16781
|
return body;
|
|
16798
16782
|
}
|
|
16799
16783
|
function getInstallationStore2() {
|
|
16800
|
-
return (0,
|
|
16784
|
+
return (0, import_core41.getStoreLattice)("default", "channelInstallation").store;
|
|
16801
16785
|
}
|
|
16802
16786
|
async function isValidPublicInstallation(tenantId, channelInstallationId, channel) {
|
|
16803
16787
|
const installation = await getInstallationStore2().getInstallationById(channelInstallationId);
|
|
@@ -16816,7 +16800,7 @@ async function getBindingList(request, _reply) {
|
|
|
16816
16800
|
const tenantId = getTenantId14(request);
|
|
16817
16801
|
const { channel, agentId, channelInstallationId, limit, offset } = request.query;
|
|
16818
16802
|
try {
|
|
16819
|
-
const registry = (0,
|
|
16803
|
+
const registry = (0, import_core41.getBindingRegistry)();
|
|
16820
16804
|
const bindings = await registry.list({
|
|
16821
16805
|
channel,
|
|
16822
16806
|
agentId,
|
|
@@ -16835,7 +16819,7 @@ async function getBindingList(request, _reply) {
|
|
|
16835
16819
|
async function getBinding(request, reply) {
|
|
16836
16820
|
const tenantId = getTenantId14(request);
|
|
16837
16821
|
try {
|
|
16838
|
-
const registry = (0,
|
|
16822
|
+
const registry = (0, import_core41.getBindingRegistry)();
|
|
16839
16823
|
const binding = await registry.findById(tenantId, request.params.id);
|
|
16840
16824
|
if (!binding || isInternalBinding(binding)) {
|
|
16841
16825
|
reply.status(404);
|
|
@@ -16857,7 +16841,7 @@ async function createBinding(request, reply) {
|
|
|
16857
16841
|
input.channelInstallationId,
|
|
16858
16842
|
input.channel
|
|
16859
16843
|
)) return invalidPublicInstallation(reply);
|
|
16860
|
-
const registry = (0,
|
|
16844
|
+
const registry = (0, import_core41.getBindingRegistry)();
|
|
16861
16845
|
const binding = await registry.create({ ...input, tenantId });
|
|
16862
16846
|
reply.status(201);
|
|
16863
16847
|
return { success: true, message: "Binding created", data: binding };
|
|
@@ -16874,7 +16858,7 @@ async function createBinding(request, reply) {
|
|
|
16874
16858
|
async function updateBinding(request, reply) {
|
|
16875
16859
|
try {
|
|
16876
16860
|
const tenantId = getTenantId14(request);
|
|
16877
|
-
const registry = (0,
|
|
16861
|
+
const registry = (0, import_core41.getBindingRegistry)();
|
|
16878
16862
|
const existing = await registry.findById(tenantId, request.params.id);
|
|
16879
16863
|
if (!existing || isInternalBinding(existing)) {
|
|
16880
16864
|
reply.status(404);
|
|
@@ -16901,7 +16885,7 @@ async function updateBinding(request, reply) {
|
|
|
16901
16885
|
async function deleteBinding(request, reply) {
|
|
16902
16886
|
try {
|
|
16903
16887
|
const tenantId = getTenantId14(request);
|
|
16904
|
-
const registry = (0,
|
|
16888
|
+
const registry = (0, import_core41.getBindingRegistry)();
|
|
16905
16889
|
const existing = await registry.findById(tenantId, request.params.id);
|
|
16906
16890
|
if (!existing || isInternalBinding(existing)) {
|
|
16907
16891
|
reply.status(404);
|
|
@@ -16923,7 +16907,7 @@ async function resolveBinding(request, _reply) {
|
|
|
16923
16907
|
return { success: false, message: "No binding found", data: null };
|
|
16924
16908
|
}
|
|
16925
16909
|
try {
|
|
16926
|
-
const registry = (0,
|
|
16910
|
+
const registry = (0, import_core41.getBindingRegistry)();
|
|
16927
16911
|
const binding = await registry.resolve({ channel, senderId, channelInstallationId, tenantId });
|
|
16928
16912
|
if (!binding) {
|
|
16929
16913
|
return { success: false, message: "No binding found", data: null };
|
|
@@ -16946,7 +16930,7 @@ function registerChannelBindingRoutes(app2) {
|
|
|
16946
16930
|
}
|
|
16947
16931
|
|
|
16948
16932
|
// src/controllers/menu-items.ts
|
|
16949
|
-
var
|
|
16933
|
+
var import_core42 = require("@axiom-lattice/core");
|
|
16950
16934
|
function getTenantId15(request) {
|
|
16951
16935
|
const userTenantId = request.user?.tenantId;
|
|
16952
16936
|
if (userTenantId) return userTenantId;
|
|
@@ -16958,7 +16942,7 @@ function errorMessage(err) {
|
|
|
16958
16942
|
async function getMenuItemList(request, _reply) {
|
|
16959
16943
|
const tenantId = getTenantId15(request);
|
|
16960
16944
|
try {
|
|
16961
|
-
const registry = (0,
|
|
16945
|
+
const registry = (0, import_core42.getMenuRegistry)();
|
|
16962
16946
|
const items = await registry.list({ tenantId, menuTarget: request.query.menuTarget });
|
|
16963
16947
|
return { success: true, message: "Menu items retrieved", data: { records: items, total: items.length } };
|
|
16964
16948
|
} catch (error) {
|
|
@@ -16970,7 +16954,7 @@ async function getMenuItemList(request, _reply) {
|
|
|
16970
16954
|
async function getMenuItem(request, reply) {
|
|
16971
16955
|
const tenantId = getTenantId15(request);
|
|
16972
16956
|
try {
|
|
16973
|
-
const registry = (0,
|
|
16957
|
+
const registry = (0, import_core42.getMenuRegistry)();
|
|
16974
16958
|
const item = await registry.getById(request.params.id);
|
|
16975
16959
|
if (!item || item.tenantId !== tenantId) {
|
|
16976
16960
|
reply.status(404);
|
|
@@ -16987,7 +16971,7 @@ async function getMenuItem(request, reply) {
|
|
|
16987
16971
|
async function createMenuItem(request, reply) {
|
|
16988
16972
|
const tenantId = getTenantId15(request);
|
|
16989
16973
|
try {
|
|
16990
|
-
const registry = (0,
|
|
16974
|
+
const registry = (0, import_core42.getMenuRegistry)();
|
|
16991
16975
|
const item = await registry.create({ ...request.body, tenantId });
|
|
16992
16976
|
reply.status(201);
|
|
16993
16977
|
return { success: true, message: "Menu item created", data: item };
|
|
@@ -17001,7 +16985,7 @@ async function createMenuItem(request, reply) {
|
|
|
17001
16985
|
async function updateMenuItem(request, reply) {
|
|
17002
16986
|
try {
|
|
17003
16987
|
const tenantId = getTenantId15(request);
|
|
17004
|
-
const registry = (0,
|
|
16988
|
+
const registry = (0, import_core42.getMenuRegistry)();
|
|
17005
16989
|
const existing = await registry.getById(request.params.id);
|
|
17006
16990
|
if (!existing || existing.tenantId !== tenantId) {
|
|
17007
16991
|
reply.status(404);
|
|
@@ -17019,7 +17003,7 @@ async function updateMenuItem(request, reply) {
|
|
|
17019
17003
|
async function deleteMenuItem(request, reply) {
|
|
17020
17004
|
try {
|
|
17021
17005
|
const tenantId = getTenantId15(request);
|
|
17022
|
-
const registry = (0,
|
|
17006
|
+
const registry = (0, import_core42.getMenuRegistry)();
|
|
17023
17007
|
const existing = await registry.getById(request.params.id);
|
|
17024
17008
|
if (!existing || existing.tenantId !== tenantId) {
|
|
17025
17009
|
reply.status(404);
|
|
@@ -17219,7 +17203,7 @@ function registerA2ABridgeRoutes(app2) {
|
|
|
17219
17203
|
}
|
|
17220
17204
|
|
|
17221
17205
|
// src/routes/stt.ts
|
|
17222
|
-
var
|
|
17206
|
+
var import_core43 = require("@axiom-lattice/core");
|
|
17223
17207
|
var ALLOWED_AUDIO_FORMATS = /* @__PURE__ */ new Set([
|
|
17224
17208
|
"webm",
|
|
17225
17209
|
"wav",
|
|
@@ -17232,7 +17216,7 @@ var ALLOWED_AUDIO_FORMATS = /* @__PURE__ */ new Set([
|
|
|
17232
17216
|
var MAX_AUDIO_FILE_SIZE = 25 * 1024 * 1024;
|
|
17233
17217
|
var registerSTTRoutes = (app2) => {
|
|
17234
17218
|
app2.get("/api/stt/models", async (_request, reply) => {
|
|
17235
|
-
const models =
|
|
17219
|
+
const models = import_core43.sttModelLatticeManager.getAllSTTModelInfo();
|
|
17236
17220
|
return reply.send({ models });
|
|
17237
17221
|
});
|
|
17238
17222
|
app2.post(
|
|
@@ -17275,7 +17259,7 @@ var registerSTTRoutes = (app2) => {
|
|
|
17275
17259
|
try {
|
|
17276
17260
|
let client;
|
|
17277
17261
|
try {
|
|
17278
|
-
client = (0,
|
|
17262
|
+
client = (0, import_core43.getSTTClient)(modelKey2);
|
|
17279
17263
|
} catch {
|
|
17280
17264
|
return reply.status(404).send({ error: `STT model "${modelKey2}" not found` });
|
|
17281
17265
|
}
|
|
@@ -17297,7 +17281,7 @@ var registerSTTRoutes = (app2) => {
|
|
|
17297
17281
|
};
|
|
17298
17282
|
|
|
17299
17283
|
// src/controllers/local-a2a.ts
|
|
17300
|
-
var
|
|
17284
|
+
var import_core44 = require("@axiom-lattice/core");
|
|
17301
17285
|
var import_protocols9 = require("@axiom-lattice/protocols");
|
|
17302
17286
|
function getTenantId16(request) {
|
|
17303
17287
|
const userTenantId = request.user?.tenantId;
|
|
@@ -17311,7 +17295,7 @@ function getLocalRuntime(assistant) {
|
|
|
17311
17295
|
return graphDefinition.localRuntime;
|
|
17312
17296
|
}
|
|
17313
17297
|
async function getLocalA2AAssistants(tenantId) {
|
|
17314
|
-
const storeLattice = (0,
|
|
17298
|
+
const storeLattice = (0, import_core44.getStoreLattice)("default", "assistant");
|
|
17315
17299
|
const assistants = await storeLattice.store.getAllAssistants(tenantId);
|
|
17316
17300
|
const results = [];
|
|
17317
17301
|
for (const assistant of assistants) {
|
|
@@ -17323,7 +17307,7 @@ async function getLocalA2AAssistants(tenantId) {
|
|
|
17323
17307
|
return results;
|
|
17324
17308
|
}
|
|
17325
17309
|
async function getLocalA2AAssistant(tenantId, assistantId) {
|
|
17326
|
-
const storeLattice = (0,
|
|
17310
|
+
const storeLattice = (0, import_core44.getStoreLattice)("default", "assistant");
|
|
17327
17311
|
const assistant = await storeLattice.store.getAssistantById(tenantId, assistantId);
|
|
17328
17312
|
if (!assistant) return null;
|
|
17329
17313
|
const runtime = getLocalRuntime(assistant);
|
|
@@ -17565,11 +17549,11 @@ function registerTaskRoutes(app2, controller) {
|
|
|
17565
17549
|
}
|
|
17566
17550
|
|
|
17567
17551
|
// src/routes/index.ts
|
|
17568
|
-
var
|
|
17552
|
+
var import_core55 = require("@axiom-lattice/core");
|
|
17569
17553
|
|
|
17570
17554
|
// src/controllers/tasks.ts
|
|
17571
17555
|
var import_protocols13 = require("@axiom-lattice/protocols");
|
|
17572
|
-
var
|
|
17556
|
+
var import_core46 = require("@axiom-lattice/core");
|
|
17573
17557
|
|
|
17574
17558
|
// src/services/collaboration/ProjectTaskThreadService.ts
|
|
17575
17559
|
var import_protocols11 = require("@axiom-lattice/protocols");
|
|
@@ -17889,7 +17873,7 @@ var import_node_crypto9 = require("crypto");
|
|
|
17889
17873
|
|
|
17890
17874
|
// src/services/collaboration/ProjectTaskExecutionService.ts
|
|
17891
17875
|
var import_node_crypto8 = require("crypto");
|
|
17892
|
-
var
|
|
17876
|
+
var import_core45 = require("@axiom-lattice/core");
|
|
17893
17877
|
var import_protocols12 = require("@axiom-lattice/protocols");
|
|
17894
17878
|
init_projectTaskScope();
|
|
17895
17879
|
|
|
@@ -17953,7 +17937,7 @@ var ProjectTaskExecutionService = class {
|
|
|
17953
17937
|
if (!Number.isFinite(options.lifecycleSettlementTimeoutMs) || options.lifecycleSettlementTimeoutMs <= 0) {
|
|
17954
17938
|
throw new Error("Project task lifecycle settlement timeout must be positive");
|
|
17955
17939
|
}
|
|
17956
|
-
this.runBridge = (0,
|
|
17940
|
+
this.runBridge = (0, import_core45.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
|
|
17957
17941
|
}
|
|
17958
17942
|
/** Validates, atomically starts, dispatches, and settles a pending Project Task. */
|
|
17959
17943
|
async start(input, signal) {
|
|
@@ -18148,15 +18132,15 @@ var ProjectTaskExecutionService = class {
|
|
|
18148
18132
|
settlement.cleanup();
|
|
18149
18133
|
return { kind: "deferred", task: input.task, thread: input.thread, messageId: input.inputMessageId };
|
|
18150
18134
|
}
|
|
18151
|
-
if (resumed.status ===
|
|
18135
|
+
if (resumed.status === import_core45.ThreadStatus.INTERRUPTED && settlement.tryClaim()) {
|
|
18152
18136
|
settlement.cleanup();
|
|
18153
18137
|
const outcome2 = await this.settleInterruptedEvent(input.task, input.thread, input.inputMessageId);
|
|
18154
18138
|
settlement.resolve(outcome2);
|
|
18155
18139
|
return outcome2;
|
|
18156
18140
|
}
|
|
18157
|
-
if ((resumed.status ===
|
|
18141
|
+
if ((resumed.status === import_core45.ThreadStatus.IDLE || resumed.status === import_core45.ThreadStatus.ERROR) && settlement.tryClaim()) {
|
|
18158
18142
|
settlement.cleanup();
|
|
18159
|
-
const reason = resumed.status ===
|
|
18143
|
+
const reason = resumed.status === import_core45.ThreadStatus.IDLE ? "Project task execution ended without lifecycle transition" : "Recovered Agent execution is in error state";
|
|
18160
18144
|
const outcome2 = await this.settleEndedRecovery(input, reason);
|
|
18161
18145
|
settlement.resolve(outcome2);
|
|
18162
18146
|
return outcome2;
|
|
@@ -19199,7 +19183,7 @@ function withErrors(handler) {
|
|
|
19199
19183
|
if (error instanceof HttpTaskError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
|
|
19200
19184
|
if (error instanceof TaskCommandError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
|
|
19201
19185
|
if (error instanceof ProjectCollaborationError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
|
|
19202
|
-
if (error instanceof
|
|
19186
|
+
if (error instanceof import_core46.ProjectTaskOwnerPolicyError) return reply.code(403).send({ success: false, code: error.code, error: error.message });
|
|
19203
19187
|
if (error instanceof ProjectTaskThreadError) return reply.code(409).send({ success: false, code: error.code, error: error.message });
|
|
19204
19188
|
request.log.error({ error }, "Task route failed");
|
|
19205
19189
|
return reply.code(500).send({ success: false, code: "TASK_INTERNAL_ERROR", error: "Task operation failed" });
|
|
@@ -19836,7 +19820,7 @@ var import_zod6 = require("zod");
|
|
|
19836
19820
|
// src/services/agent-web-app/AgentWebAppRuntimeService.ts
|
|
19837
19821
|
var import_node_crypto10 = require("crypto");
|
|
19838
19822
|
var import_protocols14 = require("@axiom-lattice/protocols");
|
|
19839
|
-
var
|
|
19823
|
+
var import_core47 = require("@axiom-lattice/core");
|
|
19840
19824
|
init_task_file_refs();
|
|
19841
19825
|
function isRecord2(value) {
|
|
19842
19826
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -20000,12 +19984,12 @@ var AgentWebAppRuntimeService = class {
|
|
|
20000
19984
|
const runtime = await this.resolveRuntime(webAppId, selection);
|
|
20001
19985
|
await this.requireOwnedThread(runtime, userId, threadId);
|
|
20002
19986
|
if (process.env.AXIOM_REPLICA_ID) {
|
|
20003
|
-
const owner = await (0,
|
|
19987
|
+
const owner = await (0, import_core47.getThreadRunOwner)({
|
|
20004
19988
|
tenantId: runtime.webApp.tenantId,
|
|
20005
19989
|
assistantId: runtime.webApp.assistantId,
|
|
20006
19990
|
threadId
|
|
20007
19991
|
});
|
|
20008
|
-
if (owner && owner !== (0,
|
|
19992
|
+
if (owner && owner !== (0, import_core47.getReplicaId)()) {
|
|
20009
19993
|
return {
|
|
20010
19994
|
stream: (async function* () {
|
|
20011
19995
|
yield (0, import_protocols14.buildAffinityMissChunk)(owner, threadId);
|
|
@@ -20358,7 +20342,7 @@ async function verifyWebAppToken(token, issuer, options = {}) {
|
|
|
20358
20342
|
|
|
20359
20343
|
// src/routes/agent-web-app-runtime.ts
|
|
20360
20344
|
var import_protocols15 = require("@axiom-lattice/protocols");
|
|
20361
|
-
var
|
|
20345
|
+
var import_core48 = require("@axiom-lattice/core");
|
|
20362
20346
|
var idSchema = import_zod6.z.string().min(1).max(128);
|
|
20363
20347
|
var paramsSchema = import_zod6.z.object({ webAppId: idSchema }).strict();
|
|
20364
20348
|
var threadParamsSchema = import_zod6.z.object({ webAppId: idSchema, threadId: idSchema }).strict();
|
|
@@ -20792,7 +20776,7 @@ function registerAgentWebAppRuntimeRoutes(app2, deps) {
|
|
|
20792
20776
|
if (!threadId) throw new AgentWebAppRuntimeError("INVALID_REQUEST", 400, "thread_id is required");
|
|
20793
20777
|
const content = body.messages.map((message) => message.content).join("\n");
|
|
20794
20778
|
const { messageId } = await deps.service.enqueueMessage(webAppId, identity.userId, threadId, content, { projectId: body.projectId, modelKey: body.modelKey });
|
|
20795
|
-
reply.header(import_protocols15.REPLICA_HEADER, (0,
|
|
20779
|
+
reply.header(import_protocols15.REPLICA_HEADER, (0, import_core48.getReplicaId)());
|
|
20796
20780
|
for (const [name, value] of Object.entries((0, import_protocols15.affinityEchoHeaders)(request.headers[import_protocols15.AGENT_AFFINITY_HEADER]))) {
|
|
20797
20781
|
reply.header(name, value);
|
|
20798
20782
|
}
|
|
@@ -20878,7 +20862,7 @@ function beginSse(reply, request) {
|
|
|
20878
20862
|
"X-Accel-Buffering": "no",
|
|
20879
20863
|
"Access-Control-Allow-Origin": "*",
|
|
20880
20864
|
"Access-Control-Expose-Headers": `${import_protocols15.REPLICA_HEADER}, ${import_protocols15.AFFINITY_ECHO_HEADER}`,
|
|
20881
|
-
[import_protocols15.REPLICA_HEADER]: (0,
|
|
20865
|
+
[import_protocols15.REPLICA_HEADER]: (0, import_core48.getReplicaId)(),
|
|
20882
20866
|
...(0, import_protocols15.affinityEchoHeaders)(request.headers[import_protocols15.AGENT_AFFINITY_HEADER])
|
|
20883
20867
|
});
|
|
20884
20868
|
}
|
|
@@ -21115,7 +21099,7 @@ var import_zod9 = require("zod");
|
|
|
21115
21099
|
|
|
21116
21100
|
// src/services/capability/CapabilityBundleService.ts
|
|
21117
21101
|
var import_zod8 = require("zod");
|
|
21118
|
-
var
|
|
21102
|
+
var import_core49 = require("@axiom-lattice/core");
|
|
21119
21103
|
var CapabilityBundleServiceError = class extends Error {
|
|
21120
21104
|
constructor(code, message, statusCode) {
|
|
21121
21105
|
super(message);
|
|
@@ -21156,7 +21140,7 @@ function projectBundleIds(config) {
|
|
|
21156
21140
|
return [...value];
|
|
21157
21141
|
}
|
|
21158
21142
|
function issue(error) {
|
|
21159
|
-
if (error instanceof
|
|
21143
|
+
if (error instanceof import_core49.CapabilityBundleMergeError || error instanceof import_core49.CapabilityBundleValidationError) return { code: error instanceof import_core49.CapabilityBundleValidationError && error.code === "CAPABILITY_BUNDLE_INVALID_CONFIG" ? "INVALID_BUNDLE_CONFIG" : error.code, message: error.message, bundleId: error instanceof import_core49.CapabilityBundleMergeError ? error.bundleId : void 0, capabilityType: error.capabilityType, fieldPath: error.fieldPath };
|
|
21160
21144
|
return { code: "CAPABILITY_BUNDLE_CONFIGURATION_ERROR", message: error instanceof Error ? error.message : "Invalid capability bundle configuration" };
|
|
21161
21145
|
}
|
|
21162
21146
|
var CapabilityBundleService = class {
|
|
@@ -21169,7 +21153,7 @@ var CapabilityBundleService = class {
|
|
|
21169
21153
|
const errors = [];
|
|
21170
21154
|
for (const value of values) {
|
|
21171
21155
|
try {
|
|
21172
|
-
(0,
|
|
21156
|
+
(0, import_core49.validateCapabilityBundleInput)(value);
|
|
21173
21157
|
bundles.push(value);
|
|
21174
21158
|
} catch {
|
|
21175
21159
|
errors.push({ bundleId: value.id, code: "INVALID_BUNDLE_CONFIG", message: "Capability bundle record is invalid" });
|
|
@@ -21181,7 +21165,7 @@ var CapabilityBundleService = class {
|
|
|
21181
21165
|
const value = await this.deps.bundleStore.getById(tenantId, id3);
|
|
21182
21166
|
if (!value) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
|
|
21183
21167
|
try {
|
|
21184
|
-
(0,
|
|
21168
|
+
(0, import_core49.validateCapabilityBundleInput)(value);
|
|
21185
21169
|
} catch {
|
|
21186
21170
|
throw new CapabilityBundleServiceError("INVALID_BUNDLE_CONFIG", "Capability bundle record is invalid", 422);
|
|
21187
21171
|
}
|
|
@@ -21189,7 +21173,7 @@ var CapabilityBundleService = class {
|
|
|
21189
21173
|
}
|
|
21190
21174
|
async create(tenantId, input) {
|
|
21191
21175
|
rejectStableKey(input);
|
|
21192
|
-
(0,
|
|
21176
|
+
(0, import_core49.validateCapabilityBundleInput)(input);
|
|
21193
21177
|
const value = input;
|
|
21194
21178
|
const name = value.name.trim();
|
|
21195
21179
|
const base = slugify(name);
|
|
@@ -21200,10 +21184,10 @@ var CapabilityBundleService = class {
|
|
|
21200
21184
|
let suffix = 2;
|
|
21201
21185
|
while (keys2.has(key)) key = `${base}-${suffix++}`;
|
|
21202
21186
|
const normalized = { ...value, key, name };
|
|
21203
|
-
(0,
|
|
21187
|
+
(0, import_core49.validateCapabilityBundleInput)(normalized);
|
|
21204
21188
|
try {
|
|
21205
21189
|
const result = await this.deps.bundleStore.create(tenantId, normalized);
|
|
21206
|
-
(0,
|
|
21190
|
+
(0, import_core49.validateCapabilityBundleInput)(result);
|
|
21207
21191
|
return result;
|
|
21208
21192
|
} catch (error) {
|
|
21209
21193
|
if (!isDuplicate(error)) throw error;
|
|
@@ -21214,16 +21198,16 @@ var CapabilityBundleService = class {
|
|
|
21214
21198
|
}
|
|
21215
21199
|
async update(tenantId, id3, input) {
|
|
21216
21200
|
rejectStableKey(input);
|
|
21217
|
-
(0,
|
|
21201
|
+
(0, import_core49.validateCapabilityBundleInput)(input, { partial: true });
|
|
21218
21202
|
if (!input || typeof input !== "object" || Array.isArray(input) || typeof input.expectedUpdatedAt !== "string" || !input.expectedUpdatedAt.trim()) throw new CapabilityBundleServiceError("INVALID_BUNDLE_CONFIG", "expectedUpdatedAt is required for capability bundle updates", 400);
|
|
21219
21203
|
const value = input;
|
|
21220
21204
|
const normalized = { ...value, ...value.name === void 0 ? {} : { name: value.name.trim() }, ...Object.prototype.hasOwnProperty.call(value, "description") ? { description: value.description?.trim() || void 0 } : {} };
|
|
21221
|
-
(0,
|
|
21205
|
+
(0, import_core49.validateCapabilityBundleInput)(normalized, { partial: true });
|
|
21222
21206
|
try {
|
|
21223
21207
|
const result = await this.deps.bundleStore.update(tenantId, id3, normalized);
|
|
21224
21208
|
if (!result) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
|
|
21225
21209
|
if ("status" in result && result.status === "conflict") throw new CapabilityBundleServiceError("BUNDLE_CONFLICT", "Capability bundle changed after it was loaded; reload before saving", 409);
|
|
21226
|
-
(0,
|
|
21210
|
+
(0, import_core49.validateCapabilityBundleInput)(result);
|
|
21227
21211
|
return result;
|
|
21228
21212
|
} catch (error) {
|
|
21229
21213
|
if (error instanceof CapabilityBundleServiceError) throw error;
|
|
@@ -21258,8 +21242,8 @@ var CapabilityBundleService = class {
|
|
|
21258
21242
|
if (missing.length > 0) return { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: missing.map((id3) => ({ code: "BUNDLE_NOT_FOUND", message: `Persisted capability bundle '${id3}' is missing`, bundleId: id3 })), revision: "" };
|
|
21259
21243
|
try {
|
|
21260
21244
|
const ordered = ids.map((id3) => byId.get(id3));
|
|
21261
|
-
ordered.forEach((bundle) => (0,
|
|
21262
|
-
return (0,
|
|
21245
|
+
ordered.forEach((bundle) => (0, import_core49.validateCapabilityBundleInput)(bundle));
|
|
21246
|
+
return (0, import_core49.mergeCapabilityBundles)(ordered);
|
|
21263
21247
|
} catch (error) {
|
|
21264
21248
|
return { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: [issue(error)], revision: "" };
|
|
21265
21249
|
}
|
|
@@ -21292,7 +21276,7 @@ var CapabilityBundleService = class {
|
|
|
21292
21276
|
return ids.map((id3) => {
|
|
21293
21277
|
const value = byId.get(id3);
|
|
21294
21278
|
if (!value) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
|
|
21295
|
-
(0,
|
|
21279
|
+
(0, import_core49.validateCapabilityBundleInput)(value);
|
|
21296
21280
|
return value;
|
|
21297
21281
|
});
|
|
21298
21282
|
}
|
|
@@ -21307,7 +21291,7 @@ var CapabilityBundleService = class {
|
|
|
21307
21291
|
continue;
|
|
21308
21292
|
}
|
|
21309
21293
|
try {
|
|
21310
|
-
(0,
|
|
21294
|
+
(0, import_core49.validateCapabilityBundleInput)(bundle);
|
|
21311
21295
|
valid.push(bundle);
|
|
21312
21296
|
} catch (error) {
|
|
21313
21297
|
errors.push({ ...issue(error), bundleId: id3 });
|
|
@@ -21315,7 +21299,7 @@ var CapabilityBundleService = class {
|
|
|
21315
21299
|
}
|
|
21316
21300
|
let preview;
|
|
21317
21301
|
try {
|
|
21318
|
-
preview = (0,
|
|
21302
|
+
preview = (0, import_core49.mergeCapabilityBundles)(valid);
|
|
21319
21303
|
} catch (error) {
|
|
21320
21304
|
preview = { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: [issue(error)], revision: "" };
|
|
21321
21305
|
}
|
|
@@ -21467,7 +21451,7 @@ var import_zod11 = require("zod");
|
|
|
21467
21451
|
// src/services/model-provider/ModelProviderService.ts
|
|
21468
21452
|
var import_node_crypto14 = require("crypto");
|
|
21469
21453
|
var import_protocols16 = require("@axiom-lattice/protocols");
|
|
21470
|
-
var
|
|
21454
|
+
var import_core50 = require("@axiom-lattice/core");
|
|
21471
21455
|
|
|
21472
21456
|
// src/services/model-provider/errors.ts
|
|
21473
21457
|
var ModelProviderServiceError = class extends Error {
|
|
@@ -22271,9 +22255,9 @@ var ModelProviderService = class {
|
|
|
22271
22255
|
*/
|
|
22272
22256
|
async assertSafeUrl(baseURL) {
|
|
22273
22257
|
try {
|
|
22274
|
-
await (0,
|
|
22258
|
+
await (0, import_core50.assertSafeUpstreamUrl)(baseURL);
|
|
22275
22259
|
} catch (error) {
|
|
22276
|
-
if (error instanceof
|
|
22260
|
+
if (error instanceof import_core50.UnsafeUpstreamUrlError) {
|
|
22277
22261
|
throw new ModelProviderServiceError(
|
|
22278
22262
|
unsafeReasonToErrorCode[error.reason],
|
|
22279
22263
|
400,
|
|
@@ -23739,7 +23723,7 @@ async function execute(reply, operation) {
|
|
|
23739
23723
|
// src/routes/cospace.ts
|
|
23740
23724
|
var import_node_crypto20 = require("crypto");
|
|
23741
23725
|
var import_zod15 = require("zod");
|
|
23742
|
-
var
|
|
23726
|
+
var import_core51 = require("@axiom-lattice/core");
|
|
23743
23727
|
var import_protocols19 = require("@axiom-lattice/protocols");
|
|
23744
23728
|
var CoSpaceAuthError = class extends Error {
|
|
23745
23729
|
constructor() {
|
|
@@ -23924,14 +23908,14 @@ function registerCoSpaceRoutes(app2, deps) {
|
|
|
23924
23908
|
}
|
|
23925
23909
|
let projectId;
|
|
23926
23910
|
if (body.type === "human") {
|
|
23927
|
-
projectId = (0,
|
|
23911
|
+
projectId = (0, import_core51.generateDirectHumanProjectId)(
|
|
23928
23912
|
actor3.tenantId,
|
|
23929
23913
|
params.workspaceId,
|
|
23930
23914
|
actor3.userId,
|
|
23931
23915
|
body.targetUserId
|
|
23932
23916
|
);
|
|
23933
23917
|
} else {
|
|
23934
|
-
projectId = (0,
|
|
23918
|
+
projectId = (0, import_core51.generateDirectBotProjectId)(
|
|
23935
23919
|
actor3.tenantId,
|
|
23936
23920
|
params.workspaceId,
|
|
23937
23921
|
actor3.userId,
|
|
@@ -24138,7 +24122,7 @@ function registerCoSpaceRoutes(app2, deps) {
|
|
|
24138
24122
|
);
|
|
24139
24123
|
const bots = [];
|
|
24140
24124
|
for (const assistant of assistants) {
|
|
24141
|
-
const directProjectId = (0,
|
|
24125
|
+
const directProjectId = (0, import_core51.generateDirectBotProjectId)(
|
|
24142
24126
|
actor3.tenantId,
|
|
24143
24127
|
params.workspaceId,
|
|
24144
24128
|
actor3.userId,
|
|
@@ -24200,7 +24184,7 @@ function registerCoSpaceRoutes(app2, deps) {
|
|
|
24200
24184
|
if (link.userId === actor3.userId) continue;
|
|
24201
24185
|
const user = await deps.userStore.getUserById(link.userId);
|
|
24202
24186
|
if (!user) continue;
|
|
24203
|
-
const directProjectId = (0,
|
|
24187
|
+
const directProjectId = (0, import_core51.generateDirectHumanProjectId)(
|
|
24204
24188
|
actor3.tenantId,
|
|
24205
24189
|
params.workspaceId,
|
|
24206
24190
|
actor3.userId,
|
|
@@ -25017,7 +25001,7 @@ function createRoomMessageRetentionJob(input) {
|
|
|
25017
25001
|
|
|
25018
25002
|
// src/services/collaboration/ProjectTaskExecutionMutex.ts
|
|
25019
25003
|
var import_protocols22 = require("@axiom-lattice/protocols");
|
|
25020
|
-
var
|
|
25004
|
+
var import_core52 = require("@axiom-lattice/core");
|
|
25021
25005
|
var MACHINE_LEASE_OPTIONS = { ttlMs: 6e4, acquireTimeoutMs: 9e4, retryDelayMs: 100 };
|
|
25022
25006
|
function machineKey(scope) {
|
|
25023
25007
|
const snapshot = (0, import_protocols22.snapshotExactRecord)(scope, ["tenantId", "assistantId", "projectId"]);
|
|
@@ -25045,9 +25029,9 @@ var ProjectTaskExecutionMutex = class {
|
|
|
25045
25029
|
const leaseKey = `project-task-machine:${encodeURIComponent(scope.tenantId)}:${encodeURIComponent(scope.assistantId)}:${encodeURIComponent(scope.projectId)}`;
|
|
25046
25030
|
await this.acquire(key, signal);
|
|
25047
25031
|
try {
|
|
25048
|
-
const store2 = (0,
|
|
25032
|
+
const store2 = (0, import_core52.getCoordinationLeaseStore)();
|
|
25049
25033
|
if (!store2) return await operation();
|
|
25050
|
-
return await (0,
|
|
25034
|
+
return await (0, import_core52.withLease)(store2, leaseKey, (0, import_core52.getReplicaId)(), operation, MACHINE_LEASE_OPTIONS);
|
|
25051
25035
|
} finally {
|
|
25052
25036
|
this.release(key);
|
|
25053
25037
|
}
|
|
@@ -25100,7 +25084,7 @@ var ProjectTaskExecutionMutex = class {
|
|
|
25100
25084
|
|
|
25101
25085
|
// src/services/collaboration/ProjectTaskObserver.ts
|
|
25102
25086
|
var import_node_crypto22 = require("crypto");
|
|
25103
|
-
var
|
|
25087
|
+
var import_core53 = require("@axiom-lattice/core");
|
|
25104
25088
|
var import_protocols23 = require("@axiom-lattice/protocols");
|
|
25105
25089
|
|
|
25106
25090
|
// src/services/collaboration/projectTaskDispatchMarker.ts
|
|
@@ -25137,7 +25121,7 @@ var ProjectTaskObserver = class {
|
|
|
25137
25121
|
throw new Error(`Invalid Project task observer bound: ${name}`);
|
|
25138
25122
|
}
|
|
25139
25123
|
}
|
|
25140
|
-
this.runBridge = (0,
|
|
25124
|
+
this.runBridge = (0, import_core53.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
|
|
25141
25125
|
}
|
|
25142
25126
|
/** Fire-and-forget notifier adapter that never waits for observer work or machine acquisition. */
|
|
25143
25127
|
async listener(event) {
|
|
@@ -26353,7 +26337,7 @@ function isRecord3(value) {
|
|
|
26353
26337
|
init_projectTaskScope();
|
|
26354
26338
|
|
|
26355
26339
|
// src/services/collaboration/ProjectRoomRealtimeRuntime.ts
|
|
26356
|
-
var
|
|
26340
|
+
var import_core54 = require("@axiom-lattice/core");
|
|
26357
26341
|
|
|
26358
26342
|
// src/services/collaboration/ProjectRoomEventBroker.ts
|
|
26359
26343
|
var import_node_crypto24 = require("crypto");
|
|
@@ -27128,7 +27112,7 @@ function createProjectRoomRealtimeRuntime(deps) {
|
|
|
27128
27112
|
broker,
|
|
27129
27113
|
publisher,
|
|
27130
27114
|
subscriber,
|
|
27131
|
-
subscribe: (listener) =>
|
|
27115
|
+
subscribe: (listener) => import_core54.taskLifecycleNotifier.subscribe(listener),
|
|
27132
27116
|
log: deps.log,
|
|
27133
27117
|
shutdownTimeoutMs: deps.shutdownTimeoutMs
|
|
27134
27118
|
});
|
|
@@ -27866,35 +27850,35 @@ function hookErrorMessage(error) {
|
|
|
27866
27850
|
function wrapReassignmentThreadError(error) {
|
|
27867
27851
|
if (error instanceof ProjectTaskThreadError) {
|
|
27868
27852
|
if (error.code === "PROJECT_TASK_THREAD_SCOPE_INVALID") {
|
|
27869
|
-
return new
|
|
27853
|
+
return new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", error.message, {
|
|
27870
27854
|
hint: "Project task, room, or roster scope changed; re-read the task and retry."
|
|
27871
27855
|
});
|
|
27872
27856
|
}
|
|
27873
27857
|
if (error.code === "PROJECT_TASK_THREAD_OWNER_INVALID") {
|
|
27874
|
-
return new
|
|
27858
|
+
return new import_core55.ManagedTaskStartError("TASK_REASSIGN_NO_CHANGE", error.message, {
|
|
27875
27859
|
hint: "The target already owns this task; re-read before dispatching."
|
|
27876
27860
|
});
|
|
27877
27861
|
}
|
|
27878
|
-
return new
|
|
27862
|
+
return new import_core55.ManagedTaskStartError("TASK_THREAD_CONFLICT", error.message, {
|
|
27879
27863
|
hint: "Task Thread changed concurrently; re-read the task and retry."
|
|
27880
27864
|
});
|
|
27881
27865
|
}
|
|
27882
|
-
return new
|
|
27866
|
+
return new import_core55.ManagedTaskStartError("TASK_EXECUTION_ENQUEUE_FAILED", hookErrorMessage(error), {
|
|
27883
27867
|
hint: "Re-read the task and retry the dispatch."
|
|
27884
27868
|
});
|
|
27885
27869
|
}
|
|
27886
27870
|
function wrapReassignmentAuthorizationError(error) {
|
|
27887
|
-
if (error instanceof
|
|
27871
|
+
if (error instanceof import_core55.ProjectTaskOwnerPolicyError) {
|
|
27888
27872
|
if (error.code === "PROJECT_TASK_CALLER_INACTIVE") {
|
|
27889
|
-
return new
|
|
27873
|
+
return new import_core55.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", error.message, {
|
|
27890
27874
|
hint: "Dispatch from an active Project Room member bot."
|
|
27891
27875
|
});
|
|
27892
27876
|
}
|
|
27893
|
-
return new
|
|
27877
|
+
return new import_core55.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", error.message, {
|
|
27894
27878
|
hint: "Dispatch to an active bot in this Project's roster."
|
|
27895
27879
|
});
|
|
27896
27880
|
}
|
|
27897
|
-
return new
|
|
27881
|
+
return new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", hookErrorMessage(error), {
|
|
27898
27882
|
hint: "Re-read the task and roster, then retry the dispatch."
|
|
27899
27883
|
});
|
|
27900
27884
|
}
|
|
@@ -27923,43 +27907,43 @@ async function transferGovernedDispatchOwner(task, options, deps) {
|
|
|
27923
27907
|
const agentId = options?.agentId;
|
|
27924
27908
|
if (!agentId || agentId === task.ownerId) return void 0;
|
|
27925
27909
|
if (!task.workspaceId || !task.projectId) {
|
|
27926
|
-
throw new
|
|
27910
|
+
throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is not governed by a Project lifecycle.", {
|
|
27927
27911
|
hint: "Dispatch governed tasks from a trusted Project run; ordinary tasks execute immediately."
|
|
27928
27912
|
});
|
|
27929
27913
|
}
|
|
27930
27914
|
return deps.mutex.runExclusive({ tenantId: task.tenantId, projectId: task.projectId }, async () => {
|
|
27931
27915
|
const current = await deps.tasks.getById(task.tenantId, task.id);
|
|
27932
27916
|
if (!current || !isProjectLifecycleTask(current) || current.workspaceId !== task.workspaceId || current.projectId !== task.projectId) {
|
|
27933
|
-
throw new
|
|
27917
|
+
throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is no longer a Project lifecycle task.", {
|
|
27934
27918
|
hint: "Re-read the task and confirm it still belongs to this Project before dispatching."
|
|
27935
27919
|
});
|
|
27936
27920
|
}
|
|
27937
27921
|
if (current.ownerType !== "agent") {
|
|
27938
|
-
throw new
|
|
27922
|
+
throw new import_core55.ManagedTaskStartError("AGENT_TASK_REQUIRED", "Project task owner must be an Agent.", {
|
|
27939
27923
|
hint: "Assign the task to an Agent before dispatching."
|
|
27940
27924
|
});
|
|
27941
27925
|
}
|
|
27942
27926
|
if (current.status !== "pending") {
|
|
27943
|
-
throw new
|
|
27927
|
+
throw new import_core55.ManagedTaskStartError("TASK_NOT_DISPATCHABLE", "Only a `pending` Project task can be dispatched.", {
|
|
27944
27928
|
hint: `This task is '${current.status}'. Resolve it or create a new task before dispatching.`
|
|
27945
27929
|
});
|
|
27946
27930
|
}
|
|
27947
27931
|
if (agentId === current.ownerId) return current;
|
|
27948
27932
|
const room = await deps.rooms.getMainRoom(current.tenantId, current.projectId);
|
|
27949
27933
|
if (!room || room.tenantId !== current.tenantId || room.workspaceId !== current.workspaceId || room.projectId !== current.projectId || room.type !== "main") {
|
|
27950
|
-
throw new
|
|
27934
|
+
throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Project main room is unavailable.", {
|
|
27951
27935
|
hint: "Open or repair the Project Room before dispatching."
|
|
27952
27936
|
});
|
|
27953
27937
|
}
|
|
27954
27938
|
const target = await deps.botMemberships.findByAssistant(current.tenantId, current.projectId, agentId);
|
|
27955
27939
|
if (!target || target.status !== "active" || target.tenantId !== current.tenantId || target.workspaceId !== current.workspaceId || target.projectId !== current.projectId || target.assistantId !== agentId || target.roomId !== room.id) {
|
|
27956
|
-
throw new
|
|
27940
|
+
throw new import_core55.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", "Target Project task owner is not active in the exact roster.", {
|
|
27957
27941
|
hint: "Dispatch to an active bot in this Project's roster."
|
|
27958
27942
|
});
|
|
27959
27943
|
}
|
|
27960
27944
|
const caller = options?.callerMembershipId ? await deps.botMemberships.findById(current.tenantId, options.callerMembershipId) : null;
|
|
27961
27945
|
if (!caller || !options?.callerAssistantId || caller.id !== options.callerMembershipId || caller.assistantId !== options.callerAssistantId || caller.status !== "active" || caller.tenantId !== current.tenantId || caller.workspaceId !== current.workspaceId || caller.projectId !== current.projectId || caller.roomId !== room.id) {
|
|
27962
|
-
throw new
|
|
27946
|
+
throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", "Current Project task caller is not active in the exact roster.", {
|
|
27963
27947
|
hint: "Dispatch from an active Project Room member bot."
|
|
27964
27948
|
});
|
|
27965
27949
|
}
|
|
@@ -27994,7 +27978,7 @@ async function transferGovernedDispatchOwner(task, options, deps) {
|
|
|
27994
27978
|
actor: `agent:${caller.assistantId}`
|
|
27995
27979
|
});
|
|
27996
27980
|
if (!result.success) {
|
|
27997
|
-
throw new
|
|
27981
|
+
throw new import_core55.ManagedTaskStartError(result.code, result.error, {
|
|
27998
27982
|
hint: result.hint ?? reassignmentFailureHint(result.code),
|
|
27999
27983
|
...result.retryable !== void 0 ? { retryable: result.retryable } : {}
|
|
28000
27984
|
});
|
|
@@ -28003,19 +27987,19 @@ async function transferGovernedDispatchOwner(task, options, deps) {
|
|
|
28003
27987
|
});
|
|
28004
27988
|
}
|
|
28005
27989
|
var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
28006
|
-
const webAppStore = (0,
|
|
28007
|
-
const assistantStore = (0,
|
|
28008
|
-
const projectStore = (0,
|
|
28009
|
-
const projectMembershipStore = (0,
|
|
28010
|
-
const userTenantLinkStore = (0,
|
|
28011
|
-
const projectRoomStore = (0,
|
|
28012
|
-
const projectBotMembershipStore = (0,
|
|
28013
|
-
const projectRoomMessageStore = (0,
|
|
28014
|
-
const projectRoomReadStateStore = (0,
|
|
28015
|
-
const userPushSubscriptionStore = (0,
|
|
28016
|
-
const threadStore = (0,
|
|
28017
|
-
const taskStore = (0,
|
|
28018
|
-
const taskWorkItemStore = (0,
|
|
27990
|
+
const webAppStore = (0, import_core55.getStoreLattice)("default", "agentWebApp").store;
|
|
27991
|
+
const assistantStore = (0, import_core55.getStoreLattice)("default", "assistant").store;
|
|
27992
|
+
const projectStore = (0, import_core55.getStoreLattice)("default", "project").store;
|
|
27993
|
+
const projectMembershipStore = (0, import_core55.getStoreLattice)("default", "projectMembership").store;
|
|
27994
|
+
const userTenantLinkStore = (0, import_core55.getStoreLattice)("default", "userTenantLink").store;
|
|
27995
|
+
const projectRoomStore = (0, import_core55.getStoreLattice)("default", "projectRoom").store;
|
|
27996
|
+
const projectBotMembershipStore = (0, import_core55.getStoreLattice)("default", "projectBotMembership").store;
|
|
27997
|
+
const projectRoomMessageStore = (0, import_core55.getStoreLattice)("default", "projectRoomMessage").store;
|
|
27998
|
+
const projectRoomReadStateStore = (0, import_core55.getStoreLattice)("default", "projectRoomReadState").store;
|
|
27999
|
+
const userPushSubscriptionStore = (0, import_core55.getStoreLattice)("default", "userPushSubscription").store;
|
|
28000
|
+
const threadStore = (0, import_core55.getStoreLattice)("default", "thread").store;
|
|
28001
|
+
const taskStore = (0, import_core55.getStoreLattice)("default", "task").store;
|
|
28002
|
+
const taskWorkItemStore = (0, import_core55.getStoreLattice)("default", "taskWorkItem").store;
|
|
28019
28003
|
const projectTaskEnabled = options.projectTaskEnabled ?? process.env.AXIOM_PROJECT_TASK_EXECUTION_ENABLED !== "false";
|
|
28020
28004
|
const accessService = new ProjectAccessService({ projectStore, membershipStore: projectMembershipStore, userTenantLinkStore });
|
|
28021
28005
|
const realtimeMode = resolveProjectRoomRealtimeMode();
|
|
@@ -28081,7 +28065,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28081
28065
|
updateAssistant: assistantStore.updateAssistant.bind(assistantStore)
|
|
28082
28066
|
});
|
|
28083
28067
|
const resolveCoordinatorMentionName = async (tenantId) => {
|
|
28084
|
-
const tenant2 = await (0,
|
|
28068
|
+
const tenant2 = await (0, import_core55.getStoreLattice)("default", "tenant").store.getTenantById(tenantId);
|
|
28085
28069
|
const value = tenant2?.metadata?.coordinatorMentionName;
|
|
28086
28070
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
28087
28071
|
};
|
|
@@ -28108,7 +28092,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28108
28092
|
return membership !== null && membership.projectId === projectId ? membership : null;
|
|
28109
28093
|
},
|
|
28110
28094
|
getThreadStatus: async ({ tenantId, assistantId, threadId, workspaceId, projectId }) => {
|
|
28111
|
-
const agent =
|
|
28095
|
+
const agent = import_core55.agentInstanceManager.getAgent({
|
|
28112
28096
|
tenant_id: tenantId,
|
|
28113
28097
|
assistant_id: assistantId,
|
|
28114
28098
|
thread_id: threadId,
|
|
@@ -28117,9 +28101,9 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28117
28101
|
});
|
|
28118
28102
|
return String(await agent.getRunStatus());
|
|
28119
28103
|
},
|
|
28120
|
-
dispatcher: (0,
|
|
28104
|
+
dispatcher: (0, import_core55.createTrustedAgentMessageDispatcher)((scope) => import_core55.agentInstanceManager.getAgent(scope))
|
|
28121
28105
|
});
|
|
28122
|
-
const membershipService = new ProjectMembershipService({ membershipStore: projectMembershipStore, userTenantLinkStore, accessService, projectMutationMutex:
|
|
28106
|
+
const membershipService = new ProjectMembershipService({ membershipStore: projectMembershipStore, userTenantLinkStore, accessService, projectMutationMutex: import_core55.projectMutationMutex, roomStore: projectRoomStore, realtime, onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:membership-realtime-failed", { code, membershipId }) : void 0 });
|
|
28123
28107
|
const rosterService = new ProjectRosterService({
|
|
28124
28108
|
accessService,
|
|
28125
28109
|
roomService,
|
|
@@ -28130,7 +28114,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28130
28114
|
assistantStore,
|
|
28131
28115
|
taskStore,
|
|
28132
28116
|
bindingLifecycle,
|
|
28133
|
-
projectMutationMutex:
|
|
28117
|
+
projectMutationMutex: import_core55.projectMutationMutex,
|
|
28134
28118
|
realtime,
|
|
28135
28119
|
onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:roster-realtime-failed", { code, membershipId }) : void 0
|
|
28136
28120
|
});
|
|
@@ -28186,9 +28170,9 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28186
28170
|
}
|
|
28187
28171
|
if (projectTaskComposition) app2.addHook("onClose", async () => projectTaskComposition.lease.release());
|
|
28188
28172
|
const taskThreadService = projectTaskComposition?.lease.runtime.threads ?? new ProjectTaskThreadService({ threads: threadStore, idFactory: import_node_crypto26.randomUUID });
|
|
28189
|
-
const taskLifecycle = projectTaskComposition?.lease.runtime.lifecycle ?? (0,
|
|
28190
|
-
const reassignmentAuthorizer = (0,
|
|
28191
|
-
new
|
|
28173
|
+
const taskLifecycle = projectTaskComposition?.lease.runtime.lifecycle ?? (0, import_core55.createTaskLifecycleService)({ taskStore, workItemStore: taskWorkItemStore });
|
|
28174
|
+
const reassignmentAuthorizer = (0, import_core55.createProjectTaskReassignmentAuthorizer)(
|
|
28175
|
+
new import_core55.ProjectTaskOwnerPolicy(projectBotMembershipStore),
|
|
28192
28176
|
(input) => validateReassignmentThread(threadStore, input)
|
|
28193
28177
|
);
|
|
28194
28178
|
const taskCommandService = new TaskCommandService({
|
|
@@ -28197,7 +28181,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28197
28181
|
lifecycle: taskLifecycle,
|
|
28198
28182
|
execution: projectTaskComposition?.lease.runtime.execution,
|
|
28199
28183
|
threads: taskThreadService,
|
|
28200
|
-
agents: { getAgent: (params) =>
|
|
28184
|
+
agents: { getAgent: (params) => import_core55.agentInstanceManager.getAgent(params) },
|
|
28201
28185
|
taskScope: (task) => resolveCommandTaskScope(task, {
|
|
28202
28186
|
rooms: projectRoomStore,
|
|
28203
28187
|
bots: projectBotMembershipStore,
|
|
@@ -28235,7 +28219,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28235
28219
|
readStateService,
|
|
28236
28220
|
interruptService: roomInterruptService,
|
|
28237
28221
|
userDirectory: {
|
|
28238
|
-
getUserById: (id3) => (0,
|
|
28222
|
+
getUserById: (id3) => (0, import_core55.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { name: u.name } : null)
|
|
28239
28223
|
}
|
|
28240
28224
|
});
|
|
28241
28225
|
registerProjectRosterRoutes(app2, { service: rosterService });
|
|
@@ -28246,7 +28230,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28246
28230
|
createProject: projectStore.createProject.bind(projectStore)
|
|
28247
28231
|
},
|
|
28248
28232
|
workspaceStore: {
|
|
28249
|
-
getWorkspaceById: (tenantId, id3) => (0,
|
|
28233
|
+
getWorkspaceById: (tenantId, id3) => (0, import_core55.getStoreLattice)("default", "workspace").store.getWorkspaceById(tenantId, id3)
|
|
28250
28234
|
},
|
|
28251
28235
|
membershipStore: {
|
|
28252
28236
|
list: projectMembershipStore.list.bind(projectMembershipStore),
|
|
@@ -28269,7 +28253,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28269
28253
|
getUsersByTenant: userTenantLinkStore.getUsersByTenant.bind(userTenantLinkStore)
|
|
28270
28254
|
},
|
|
28271
28255
|
userStore: {
|
|
28272
|
-
getUserById: (id3) => (0,
|
|
28256
|
+
getUserById: (id3) => (0, import_core55.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { id: u.id, name: u.name, email: u.email } : null)
|
|
28273
28257
|
},
|
|
28274
28258
|
assistantStore: {
|
|
28275
28259
|
getAssistantById: assistantStore.getAssistantById.bind(assistantStore),
|
|
@@ -28291,17 +28275,17 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28291
28275
|
}
|
|
28292
28276
|
});
|
|
28293
28277
|
registerCapabilityBundleRoutes(app2, new CapabilityBundleController({
|
|
28294
|
-
bundleStore: (0,
|
|
28278
|
+
bundleStore: (0, import_core55.getStoreLattice)("default", "capabilityBundle").store,
|
|
28295
28279
|
projectStore
|
|
28296
28280
|
}, { authRequired: process.env.AUTH_REQUIRED === "true" }));
|
|
28297
28281
|
const modelProviderController = new ModelProviderController({
|
|
28298
|
-
providerStore: (0,
|
|
28282
|
+
providerStore: (0, import_core55.getStoreLattice)("default", "modelProvider").store,
|
|
28299
28283
|
userTenantLinkStore,
|
|
28300
28284
|
registry: {
|
|
28301
|
-
register: (tenantId, modelKey2, config) =>
|
|
28302
|
-
has: (tenantId, modelKey2) =>
|
|
28303
|
-
remove: (tenantId, modelKey2) =>
|
|
28304
|
-
listRegistered: (tenantId) =>
|
|
28285
|
+
register: (tenantId, modelKey2, config) => import_core55.modelLatticeManager.registerLatticeWithTenant(tenantId, modelKey2, config),
|
|
28286
|
+
has: (tenantId, modelKey2) => import_core55.modelLatticeManager.hasLatticeWithTenant(tenantId, modelKey2),
|
|
28287
|
+
remove: (tenantId, modelKey2) => import_core55.modelLatticeManager.removeLatticeWithTenant(tenantId, modelKey2),
|
|
28288
|
+
listRegistered: (tenantId) => import_core55.modelLatticeManager.getLatticeKeysByTenant(tenantId)
|
|
28305
28289
|
}
|
|
28306
28290
|
}, { authRequired: process.env.AUTH_REQUIRED === "true" });
|
|
28307
28291
|
registerModelProviderRoutes(app2, modelProviderController);
|
|
@@ -28311,10 +28295,10 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28311
28295
|
webAppStore,
|
|
28312
28296
|
assistantStore,
|
|
28313
28297
|
projectStore,
|
|
28314
|
-
modelRegistry: { has: (key) =>
|
|
28298
|
+
modelRegistry: { has: (key) => import_core55.modelLatticeManager.hasLattice(key) },
|
|
28315
28299
|
configuredAgentResolver: createConfiguredAgentResolver({
|
|
28316
|
-
hydrate: (tenantId) =>
|
|
28317
|
-
has: (tenantId, assistantId) =>
|
|
28300
|
+
hydrate: (tenantId) => import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
|
|
28301
|
+
has: (tenantId, assistantId) => import_core55.agentLatticeManager.hasAgentLatticeWithTenant(tenantId, assistantId)
|
|
28318
28302
|
})
|
|
28319
28303
|
})
|
|
28320
28304
|
});
|
|
@@ -28351,28 +28335,28 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28351
28335
|
},
|
|
28352
28336
|
tasks: taskStore,
|
|
28353
28337
|
workItems: taskWorkItemStore,
|
|
28354
|
-
projectMutationMutex:
|
|
28338
|
+
projectMutationMutex: import_core55.projectMutationMutex,
|
|
28355
28339
|
...projectTaskComposition ? { commands: taskCommandService } : {}
|
|
28356
28340
|
}),
|
|
28357
28341
|
service: new AgentWebAppRuntimeService({
|
|
28358
28342
|
webAppStore,
|
|
28359
|
-
threadStore: (0,
|
|
28343
|
+
threadStore: (0, import_core55.getStoreLattice)("default", "thread").store,
|
|
28360
28344
|
projectStore,
|
|
28361
28345
|
assistantResolver: {
|
|
28362
28346
|
resolve: async (tenantId, assistantId) => {
|
|
28363
28347
|
const stored = await assistantStore.getAssistantById(tenantId, assistantId);
|
|
28364
28348
|
if (stored) return { id: stored.id, name: stored.name, description: stored.description };
|
|
28365
|
-
await
|
|
28366
|
-
const config =
|
|
28349
|
+
await import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId);
|
|
28350
|
+
const config = import_core55.agentLatticeManager.getAgentConfigWithTenant(tenantId, assistantId);
|
|
28367
28351
|
return config ? { id: assistantId, name: config.name, description: config.description } : null;
|
|
28368
28352
|
}
|
|
28369
28353
|
},
|
|
28370
28354
|
modelRegistry: {
|
|
28371
|
-
has: (key) =>
|
|
28355
|
+
has: (key) => import_core55.modelLatticeManager.hasLattice(key),
|
|
28372
28356
|
label: (key) => key
|
|
28373
28357
|
},
|
|
28374
28358
|
messageReader: {
|
|
28375
|
-
getCurrentMessages: ({ tenantId, assistantId, threadId, workspaceId, projectId }) =>
|
|
28359
|
+
getCurrentMessages: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core55.agentInstanceManager.getAgentForRead({
|
|
28376
28360
|
tenant_id: tenantId,
|
|
28377
28361
|
assistant_id: assistantId,
|
|
28378
28362
|
thread_id: threadId,
|
|
@@ -28381,7 +28365,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28381
28365
|
}).getCurrentMessages()
|
|
28382
28366
|
},
|
|
28383
28367
|
agentResolver: {
|
|
28384
|
-
getAgent: ({ tenantId, assistantId, threadId, workspaceId, projectId }) =>
|
|
28368
|
+
getAgent: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core55.agentInstanceManager.getAgent({
|
|
28385
28369
|
tenant_id: tenantId,
|
|
28386
28370
|
assistant_id: assistantId,
|
|
28387
28371
|
thread_id: threadId,
|
|
@@ -28399,8 +28383,8 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28399
28383
|
if (webApp.tenantId !== preview.tenantId) return false;
|
|
28400
28384
|
const assistant = await assistantStore.getAssistantById(preview.tenantId, webApp.assistantId);
|
|
28401
28385
|
if (assistant) return !assistant.ownerUserId || assistant.ownerUserId === preview.userId;
|
|
28402
|
-
await
|
|
28403
|
-
return
|
|
28386
|
+
await import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(preview.tenantId);
|
|
28387
|
+
return import_core55.agentLatticeManager.hasAgentLatticeWithTenant(preview.tenantId, webApp.assistantId);
|
|
28404
28388
|
}
|
|
28405
28389
|
})
|
|
28406
28390
|
});
|
|
@@ -28457,14 +28441,14 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28457
28441
|
app2.post("/api/personal-assistant", createPersonalAssistant);
|
|
28458
28442
|
app2.get("/api/personal-assistant", getPersonalAssistant);
|
|
28459
28443
|
app2.delete("/api/personal-assistant", deletePersonalAssistant);
|
|
28460
|
-
|
|
28444
|
+
import_core55.executionAuthorityRegistry.register({
|
|
28461
28445
|
id: "project-lifecycle",
|
|
28462
28446
|
matches: isProjectLifecycleTask,
|
|
28463
28447
|
code: "PROJECT_TASK_EXECUTION_MANAGED",
|
|
28464
28448
|
message: "Project tasks are executed by the durable Project queue runtime",
|
|
28465
28449
|
onManagedStart: async (task, options2) => {
|
|
28466
28450
|
if (!projectTaskComposition && options2?.agentId && options2.agentId !== task.ownerId) {
|
|
28467
|
-
throw new
|
|
28451
|
+
throw new import_core55.ManagedTaskStartError(
|
|
28468
28452
|
"PROJECT_TASK_RUNTIME_UNAVAILABLE",
|
|
28469
28453
|
"Project task ownership transfer requires the Project task runtime.",
|
|
28470
28454
|
{ hint: "Project task execution is disabled; enable the Project task runtime or dispatch to the current owner." }
|
|
@@ -28477,7 +28461,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28477
28461
|
threads: taskThreadService,
|
|
28478
28462
|
reassignmentAuthorizer,
|
|
28479
28463
|
lifecycle: taskLifecycle,
|
|
28480
|
-
mutex:
|
|
28464
|
+
mutex: import_core55.projectMutationMutex
|
|
28481
28465
|
}) : void 0;
|
|
28482
28466
|
const admitted = transferred ?? task;
|
|
28483
28467
|
if (!admitted.workspaceId || !admitted.projectId) return;
|
|
@@ -28485,7 +28469,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28485
28469
|
context: withExecutionRequest(admitted.context, (/* @__PURE__ */ new Date()).toISOString())
|
|
28486
28470
|
}).catch(() => null);
|
|
28487
28471
|
const eventTask = markerUpdated ?? admitted;
|
|
28488
|
-
void
|
|
28472
|
+
void import_core55.projectTaskAdmissionNotifier.publish({
|
|
28489
28473
|
tenantId: eventTask.tenantId,
|
|
28490
28474
|
workspaceId: eventTask.workspaceId,
|
|
28491
28475
|
projectId: eventTask.projectId,
|
|
@@ -28499,7 +28483,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
|
|
|
28499
28483
|
access: accessService,
|
|
28500
28484
|
tasks: taskStore,
|
|
28501
28485
|
workItems: taskWorkItemStore,
|
|
28502
|
-
projectMutationMutex:
|
|
28486
|
+
projectMutationMutex: import_core55.projectMutationMutex,
|
|
28503
28487
|
commands: taskCommandService,
|
|
28504
28488
|
readableProjects: async ({ tenantId, userId, workspaceId }) => {
|
|
28505
28489
|
const projects = await projectStore.getProjectsByWorkspace(tenantId, workspaceId);
|
|
@@ -28781,9 +28765,9 @@ function tryCreateProjectTaskRuntime(input) {
|
|
|
28781
28765
|
let stores;
|
|
28782
28766
|
try {
|
|
28783
28767
|
stores = {
|
|
28784
|
-
tenants: (0,
|
|
28785
|
-
workspaces: (0,
|
|
28786
|
-
queue: (0,
|
|
28768
|
+
tenants: (0, import_core55.getStoreLattice)("default", "tenant").store,
|
|
28769
|
+
workspaces: (0, import_core55.getStoreLattice)("default", "workspace").store,
|
|
28770
|
+
queue: (0, import_core55.getStoreLattice)("default", "threadMessageQueue").store
|
|
28787
28771
|
};
|
|
28788
28772
|
const missing = missingRuntimeMethod(input, stores);
|
|
28789
28773
|
if (missing) return { reason: missing };
|
|
@@ -28815,7 +28799,7 @@ function createRuntime(input, stores, log2) {
|
|
|
28815
28799
|
const controller = new AbortController();
|
|
28816
28800
|
const mutex = new ProjectTaskExecutionMutex();
|
|
28817
28801
|
const threads = new ProjectTaskThreadService({ threads: input.threadStore, idFactory: import_node_crypto26.randomUUID });
|
|
28818
|
-
const lifecycle = (0,
|
|
28802
|
+
const lifecycle = (0, import_core55.createTaskLifecycleService)({ taskStore: input.taskStore, workItemStore: input.taskWorkItemStore });
|
|
28819
28803
|
const projection = new RoomProjectionService({
|
|
28820
28804
|
messages: input.projectRoomMessageStore,
|
|
28821
28805
|
events: input.taskWorkItemStore,
|
|
@@ -28825,7 +28809,7 @@ function createRuntime(input, stores, log2) {
|
|
|
28825
28809
|
realtime: input.realtime,
|
|
28826
28810
|
idFactory: import_node_crypto26.randomUUID
|
|
28827
28811
|
});
|
|
28828
|
-
const agentFor = (task, thread) =>
|
|
28812
|
+
const agentFor = (task, thread) => import_core55.agentInstanceManager.getAgent({
|
|
28829
28813
|
tenant_id: task.tenantId,
|
|
28830
28814
|
assistant_id: task.ownerId,
|
|
28831
28815
|
thread_id: thread.id,
|
|
@@ -28839,7 +28823,7 @@ function createRuntime(input, stores, log2) {
|
|
|
28839
28823
|
bots: input.projectBotMembershipStore,
|
|
28840
28824
|
threads,
|
|
28841
28825
|
lifecycle,
|
|
28842
|
-
dispatcher: (0,
|
|
28826
|
+
dispatcher: (0, import_core55.createTrustedAgentMessageDispatcher)((scope) => import_core55.agentInstanceManager.getAgent(scope)),
|
|
28843
28827
|
queue: stores.queue,
|
|
28844
28828
|
agentFor
|
|
28845
28829
|
}, {
|
|
@@ -28866,8 +28850,8 @@ function createRuntime(input, stores, log2) {
|
|
|
28866
28850
|
const taskLifecycleListener = ((event) => {
|
|
28867
28851
|
void observer.listener(event);
|
|
28868
28852
|
});
|
|
28869
|
-
const unsubscribe =
|
|
28870
|
-
const unsubscribeAdmission =
|
|
28853
|
+
const unsubscribe = import_core55.taskLifecycleNotifier.subscribe(taskLifecycleListener);
|
|
28854
|
+
const unsubscribeAdmission = import_core55.projectTaskAdmissionNotifier.subscribe((event, signal) => {
|
|
28871
28855
|
observer.admit(event, signal);
|
|
28872
28856
|
});
|
|
28873
28857
|
let reconciliationWork;
|
|
@@ -29014,12 +28998,12 @@ function registerResourceRoutes(app2, controller) {
|
|
|
29014
28998
|
}
|
|
29015
28999
|
|
|
29016
29000
|
// src/export_registrations/index.ts
|
|
29017
|
-
var
|
|
29001
|
+
var import_core66 = require("@axiom-lattice/core");
|
|
29018
29002
|
|
|
29019
29003
|
// src/export_registrations/skill.registration.ts
|
|
29020
|
-
var
|
|
29004
|
+
var import_core56 = require("@axiom-lattice/core");
|
|
29021
29005
|
function getStore(context) {
|
|
29022
|
-
return new
|
|
29006
|
+
return new import_core56.SandboxSkillStore({
|
|
29023
29007
|
workspaceId: context?.workspaceId,
|
|
29024
29008
|
projectId: context?.projectId
|
|
29025
29009
|
});
|
|
@@ -29037,7 +29021,7 @@ var skillRegistration = {
|
|
|
29037
29021
|
async listForExport(tenantId, context) {
|
|
29038
29022
|
const store2 = getStore(context);
|
|
29039
29023
|
const skills = await store2.getAllSkills(tenantId, toStoreContext(context));
|
|
29040
|
-
return skills.filter((s) => !(0,
|
|
29024
|
+
return skills.filter((s) => !(0, import_core56.isBuiltInSkill)(s.id)).map((s) => ({
|
|
29041
29025
|
_exportId: "",
|
|
29042
29026
|
data: {
|
|
29043
29027
|
id: s.id,
|
|
@@ -29102,7 +29086,7 @@ var skillRegistration = {
|
|
|
29102
29086
|
const insertions = [];
|
|
29103
29087
|
for (const entity of entities) {
|
|
29104
29088
|
const id3 = entity.data.id;
|
|
29105
|
-
if ((0,
|
|
29089
|
+
if ((0, import_core56.isBuiltInSkill)(id3)) continue;
|
|
29106
29090
|
if (existingIds.has(id3)) {
|
|
29107
29091
|
conflicts.push({
|
|
29108
29092
|
_exportId: entity._exportId,
|
|
@@ -29161,9 +29145,9 @@ var skillRegistration = {
|
|
|
29161
29145
|
};
|
|
29162
29146
|
|
|
29163
29147
|
// src/export_registrations/agent.registration.ts
|
|
29164
|
-
var
|
|
29148
|
+
var import_core57 = require("@axiom-lattice/core");
|
|
29165
29149
|
function getStore2() {
|
|
29166
|
-
return (0,
|
|
29150
|
+
return (0, import_core57.getStoreLattice)("default", "assistant").store;
|
|
29167
29151
|
}
|
|
29168
29152
|
var agentRegistration = {
|
|
29169
29153
|
entityType: "agent",
|
|
@@ -29243,9 +29227,9 @@ var agentRegistration = {
|
|
|
29243
29227
|
};
|
|
29244
29228
|
|
|
29245
29229
|
// src/export_registrations/database-config.registration.ts
|
|
29246
|
-
var
|
|
29230
|
+
var import_core58 = require("@axiom-lattice/core");
|
|
29247
29231
|
function getStore3() {
|
|
29248
|
-
return (0,
|
|
29232
|
+
return (0, import_core58.getStoreLattice)("default", "database").store;
|
|
29249
29233
|
}
|
|
29250
29234
|
var databaseConfigRegistration = {
|
|
29251
29235
|
entityType: "database_config",
|
|
@@ -29325,9 +29309,9 @@ var databaseConfigRegistration = {
|
|
|
29325
29309
|
};
|
|
29326
29310
|
|
|
29327
29311
|
// src/export_registrations/metrics-config.registration.ts
|
|
29328
|
-
var
|
|
29312
|
+
var import_core59 = require("@axiom-lattice/core");
|
|
29329
29313
|
function getStore4() {
|
|
29330
|
-
return (0,
|
|
29314
|
+
return (0, import_core59.getStoreLattice)("default", "metrics").store;
|
|
29331
29315
|
}
|
|
29332
29316
|
var metricsConfigRegistration = {
|
|
29333
29317
|
entityType: "metrics_config",
|
|
@@ -29407,9 +29391,9 @@ var metricsConfigRegistration = {
|
|
|
29407
29391
|
};
|
|
29408
29392
|
|
|
29409
29393
|
// src/export_registrations/mcp-config.registration.ts
|
|
29410
|
-
var
|
|
29394
|
+
var import_core60 = require("@axiom-lattice/core");
|
|
29411
29395
|
function getStore5() {
|
|
29412
|
-
return (0,
|
|
29396
|
+
return (0, import_core60.getStoreLattice)("default", "mcp").store;
|
|
29413
29397
|
}
|
|
29414
29398
|
var mcpConfigRegistration = {
|
|
29415
29399
|
entityType: "mcp_config",
|
|
@@ -29492,9 +29476,9 @@ var mcpConfigRegistration = {
|
|
|
29492
29476
|
};
|
|
29493
29477
|
|
|
29494
29478
|
// src/export_registrations/connection.registration.ts
|
|
29495
|
-
var
|
|
29479
|
+
var import_core61 = require("@axiom-lattice/core");
|
|
29496
29480
|
function getStore6() {
|
|
29497
|
-
return (0,
|
|
29481
|
+
return (0, import_core61.getStoreLattice)("default", "connection").store;
|
|
29498
29482
|
}
|
|
29499
29483
|
async function listAllConnections(tenantId) {
|
|
29500
29484
|
const store2 = getStore6();
|
|
@@ -29519,7 +29503,8 @@ var connectionRegistration = {
|
|
|
29519
29503
|
key: c2.key,
|
|
29520
29504
|
name: c2.name,
|
|
29521
29505
|
description: c2.description,
|
|
29522
|
-
config: c2.config
|
|
29506
|
+
config: c2.config,
|
|
29507
|
+
secretFields: c2.secretFields
|
|
29523
29508
|
}
|
|
29524
29509
|
}));
|
|
29525
29510
|
},
|
|
@@ -29563,22 +29548,24 @@ var connectionRegistration = {
|
|
|
29563
29548
|
} catch {
|
|
29564
29549
|
}
|
|
29565
29550
|
}
|
|
29551
|
+
const secretFields = Array.isArray(d.secretFields) ? d.secretFields : secretFieldsForConnection(await resolveTenantPluginByType(tenantId, type));
|
|
29566
29552
|
await store2.create({
|
|
29567
29553
|
tenantId,
|
|
29568
29554
|
type,
|
|
29569
29555
|
key,
|
|
29570
29556
|
name: d.name,
|
|
29571
29557
|
description: d.description,
|
|
29572
|
-
config: d.config
|
|
29558
|
+
config: d.config,
|
|
29559
|
+
secretFields
|
|
29573
29560
|
});
|
|
29574
29561
|
return { newId: void 0 };
|
|
29575
29562
|
}
|
|
29576
29563
|
};
|
|
29577
29564
|
|
|
29578
29565
|
// src/export_registrations/collection.registration.ts
|
|
29579
|
-
var
|
|
29566
|
+
var import_core62 = require("@axiom-lattice/core");
|
|
29580
29567
|
function getStore7() {
|
|
29581
|
-
return (0,
|
|
29568
|
+
return (0, import_core62.getStoreLattice)("default", "collection").store;
|
|
29582
29569
|
}
|
|
29583
29570
|
var collectionRegistration = {
|
|
29584
29571
|
entityType: "collection",
|
|
@@ -29649,7 +29636,7 @@ var collectionRegistration = {
|
|
|
29649
29636
|
};
|
|
29650
29637
|
|
|
29651
29638
|
// src/export_registrations/channel-installation.registration.ts
|
|
29652
|
-
var
|
|
29639
|
+
var import_core63 = require("@axiom-lattice/core");
|
|
29653
29640
|
var import_crypto11 = require("crypto");
|
|
29654
29641
|
var UUID_PATTERN2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
29655
29642
|
var PUBLIC_CHANNELS = /* @__PURE__ */ new Set(["lark", "email", "slack", "wechat"]);
|
|
@@ -29683,7 +29670,7 @@ function validateImportData(data) {
|
|
|
29683
29670
|
};
|
|
29684
29671
|
}
|
|
29685
29672
|
function getStore8() {
|
|
29686
|
-
return (0,
|
|
29673
|
+
return (0, import_core63.getStoreLattice)("default", "channelInstallation").store;
|
|
29687
29674
|
}
|
|
29688
29675
|
function getOverwriteError(tenantId, incomingChannel, existing) {
|
|
29689
29676
|
if (!existing) return "Channel installation overwrite target must exist";
|
|
@@ -29817,9 +29804,9 @@ var channelInstallationRegistration = {
|
|
|
29817
29804
|
};
|
|
29818
29805
|
|
|
29819
29806
|
// src/export_registrations/menu.registration.ts
|
|
29820
|
-
var
|
|
29807
|
+
var import_core64 = require("@axiom-lattice/core");
|
|
29821
29808
|
function getStore9() {
|
|
29822
|
-
return (0,
|
|
29809
|
+
return (0, import_core64.getStoreLattice)("default", "menu").store;
|
|
29823
29810
|
}
|
|
29824
29811
|
var menuRegistration = {
|
|
29825
29812
|
entityType: "menu",
|
|
@@ -29897,9 +29884,9 @@ var menuRegistration = {
|
|
|
29897
29884
|
};
|
|
29898
29885
|
|
|
29899
29886
|
// src/export_registrations/eval.registration.ts
|
|
29900
|
-
var
|
|
29887
|
+
var import_core65 = require("@axiom-lattice/core");
|
|
29901
29888
|
function getStore10() {
|
|
29902
|
-
return (0,
|
|
29889
|
+
return (0, import_core65.getStoreLattice)("default", "eval").store;
|
|
29903
29890
|
}
|
|
29904
29891
|
var evalRegistration = {
|
|
29905
29892
|
entityType: "eval",
|
|
@@ -30225,7 +30212,7 @@ var evalRegistration = {
|
|
|
30225
30212
|
|
|
30226
30213
|
// src/export_registrations/index.ts
|
|
30227
30214
|
function registerAllBuiltinEntities() {
|
|
30228
|
-
const registry =
|
|
30215
|
+
const registry = import_core66.ExportableEntityRegistry.getInstance();
|
|
30229
30216
|
registry.register(skillRegistration);
|
|
30230
30217
|
registry.register(agentRegistration);
|
|
30231
30218
|
registry.register(databaseConfigRegistration);
|
|
@@ -30356,7 +30343,7 @@ function createAuditLoggerMiddleware() {
|
|
|
30356
30343
|
}
|
|
30357
30344
|
|
|
30358
30345
|
// src/index.ts
|
|
30359
|
-
var
|
|
30346
|
+
var import_core92 = require("@axiom-lattice/core");
|
|
30360
30347
|
|
|
30361
30348
|
// src/swagger.ts
|
|
30362
30349
|
var import_swagger = __toESM(require("@fastify/swagger"));
|
|
@@ -30422,7 +30409,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
|
|
|
30422
30409
|
|
|
30423
30410
|
// src/services/agent_task_consumer.ts
|
|
30424
30411
|
var import_node_crypto27 = require("crypto");
|
|
30425
|
-
var
|
|
30412
|
+
var import_core67 = require("@axiom-lattice/core");
|
|
30426
30413
|
var import_protocols31 = require("@axiom-lattice/protocols");
|
|
30427
30414
|
var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
30428
30415
|
const {
|
|
@@ -30442,7 +30429,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
30442
30429
|
`\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
30443
30430
|
);
|
|
30444
30431
|
const scope = (0, import_protocols31.resolveRunScope)(runConfig);
|
|
30445
|
-
const agent =
|
|
30432
|
+
const agent = import_core67.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: scope.workspaceId, project_id: scope.projectId, custom_run_config: runConfig });
|
|
30446
30433
|
if (callback_event) {
|
|
30447
30434
|
const callbackEvent = callback_event;
|
|
30448
30435
|
const messageId = typeof input?.id === "string" && input.id !== "" ? input.id : (0, import_node_crypto27.randomUUID)();
|
|
@@ -30463,13 +30450,13 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
30463
30450
|
const onCompleted = (evt) => {
|
|
30464
30451
|
if (!belongsToMessage(evt)) return;
|
|
30465
30452
|
settle(() => {
|
|
30466
|
-
|
|
30453
|
+
import_core67.eventBus.publish(callbackEvent, {
|
|
30467
30454
|
success: true,
|
|
30468
30455
|
state: evt.state
|
|
30469
30456
|
});
|
|
30470
30457
|
if (main_thread_id && main_tenant_id) {
|
|
30471
30458
|
try {
|
|
30472
|
-
const mainAgent =
|
|
30459
|
+
const mainAgent = import_core67.agentInstanceManager.getAgent({
|
|
30473
30460
|
assistant_id: main_assistant_id ?? assistant_id,
|
|
30474
30461
|
thread_id: main_thread_id,
|
|
30475
30462
|
tenant_id: main_tenant_id,
|
|
@@ -30502,7 +30489,7 @@ ${summary}`
|
|
|
30502
30489
|
const onInterrupted = (evt) => {
|
|
30503
30490
|
if (!belongsToMessage(evt)) return;
|
|
30504
30491
|
settle(() => {
|
|
30505
|
-
|
|
30492
|
+
import_core67.eventBus.publish(callbackEvent, {
|
|
30506
30493
|
success: true,
|
|
30507
30494
|
state: evt.state
|
|
30508
30495
|
});
|
|
@@ -30511,7 +30498,7 @@ ${summary}`
|
|
|
30511
30498
|
const onFailed = (evt) => {
|
|
30512
30499
|
if (!belongsToMessage(evt)) return;
|
|
30513
30500
|
settle(() => {
|
|
30514
|
-
|
|
30501
|
+
import_core67.eventBus.publish(callbackEvent, {
|
|
30515
30502
|
success: false,
|
|
30516
30503
|
error: evt?.error instanceof Error ? evt.error.message : typeof evt?.error === "string" ? evt.error : "Agent execution failed"
|
|
30517
30504
|
});
|
|
@@ -30526,13 +30513,13 @@ ${summary}`
|
|
|
30526
30513
|
agent.subscribe("message:interrupted", onInterrupted);
|
|
30527
30514
|
agent.subscribe("message:failed", onFailed);
|
|
30528
30515
|
try {
|
|
30529
|
-
await agent.addMessage({ input: { ...input, id: messageId }, command, custom_run_config: runConfig },
|
|
30516
|
+
await agent.addMessage({ input: { ...input, id: messageId }, command, custom_run_config: runConfig }, import_core67.QueueMode.STEER);
|
|
30530
30517
|
} catch (error) {
|
|
30531
30518
|
dispose();
|
|
30532
30519
|
throw error;
|
|
30533
30520
|
}
|
|
30534
30521
|
} else {
|
|
30535
|
-
await agent.addMessage({ input, command, custom_run_config: runConfig },
|
|
30522
|
+
await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core67.QueueMode.STEER);
|
|
30536
30523
|
}
|
|
30537
30524
|
return true;
|
|
30538
30525
|
} catch (error) {
|
|
@@ -30551,7 +30538,7 @@ ${summary}`
|
|
|
30551
30538
|
return handleAgentTask(taskRequest, nextRetryCount);
|
|
30552
30539
|
}
|
|
30553
30540
|
if (callback_event) {
|
|
30554
|
-
|
|
30541
|
+
import_core67.eventBus.publish(callback_event, {
|
|
30555
30542
|
success: false,
|
|
30556
30543
|
error: error instanceof Error ? error.message : String(error)
|
|
30557
30544
|
});
|
|
@@ -30588,7 +30575,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
30588
30575
|
* 初始化事件监听和队列轮询
|
|
30589
30576
|
*/
|
|
30590
30577
|
initialize() {
|
|
30591
|
-
|
|
30578
|
+
import_core67.eventBus.subscribe(import_core67.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
|
|
30592
30579
|
this.startPollingQueue();
|
|
30593
30580
|
console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
|
|
30594
30581
|
}
|
|
@@ -30707,7 +30694,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
30707
30694
|
handleAgentTask(taskRequest).catch((error) => {
|
|
30708
30695
|
console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
|
|
30709
30696
|
if (taskRequest.callback_event) {
|
|
30710
|
-
|
|
30697
|
+
import_core67.eventBus.publish(taskRequest.callback_event, {
|
|
30711
30698
|
success: false,
|
|
30712
30699
|
error: error instanceof Error ? error.message : String(error)
|
|
30713
30700
|
});
|
|
@@ -30722,13 +30709,13 @@ _AgentTaskConsumer.agent_run_endpoint = "http://localhost:4001/api/runs";
|
|
|
30722
30709
|
var AgentTaskConsumer = _AgentTaskConsumer;
|
|
30723
30710
|
|
|
30724
30711
|
// src/index.ts
|
|
30725
|
-
var
|
|
30712
|
+
var import_core93 = require("@axiom-lattice/core");
|
|
30726
30713
|
|
|
30727
30714
|
// src/channels/ChannelInfrastructure.ts
|
|
30728
|
-
var
|
|
30715
|
+
var import_core69 = require("@axiom-lattice/core");
|
|
30729
30716
|
|
|
30730
30717
|
// src/router/MessageRouter.ts
|
|
30731
|
-
var
|
|
30718
|
+
var import_core68 = require("@axiom-lattice/core");
|
|
30732
30719
|
var import_protocols32 = require("@axiom-lattice/protocols");
|
|
30733
30720
|
var import_crypto12 = require("crypto");
|
|
30734
30721
|
var BindingNotFoundError = class extends Error {
|
|
@@ -31014,7 +31001,7 @@ var MessageRouter = class {
|
|
|
31014
31001
|
channel: message.channel,
|
|
31015
31002
|
adapterChannel: adapter.channel
|
|
31016
31003
|
}, "Thread resolved by adapter strategy");
|
|
31017
|
-
const threadStore = (0,
|
|
31004
|
+
const threadStore = (0, import_core68.getStoreLattice)("default", "thread").store;
|
|
31018
31005
|
try {
|
|
31019
31006
|
await threadStore.createThread(
|
|
31020
31007
|
tenantId,
|
|
@@ -31051,7 +31038,7 @@ var MessageRouter = class {
|
|
|
31051
31038
|
}
|
|
31052
31039
|
}
|
|
31053
31040
|
if (!threadId) {
|
|
31054
|
-
const threadStore = (0,
|
|
31041
|
+
const threadStore = (0, import_core68.getStoreLattice)("default", "thread").store;
|
|
31055
31042
|
const newThreadId = (0, import_crypto12.randomUUID)();
|
|
31056
31043
|
console.log({
|
|
31057
31044
|
event: "dispatch:thread:create",
|
|
@@ -31091,7 +31078,7 @@ var MessageRouter = class {
|
|
|
31091
31078
|
senderId: message.sender.id,
|
|
31092
31079
|
contentLength: message.content.text.length
|
|
31093
31080
|
}, "Dispatching to agent");
|
|
31094
|
-
const agent =
|
|
31081
|
+
const agent = import_core68.agentInstanceManager.getAgent({
|
|
31095
31082
|
tenant_id: tenantId,
|
|
31096
31083
|
assistant_id: agentId,
|
|
31097
31084
|
thread_id: threadId,
|
|
@@ -31364,7 +31351,7 @@ function createChannelInfrastructure(deps) {
|
|
|
31364
31351
|
onMessageCommitted: deps.onMessageCommitted ?? (deps.realtime ? (message) => deps.realtime?.messageCreated(message) : void 0),
|
|
31365
31352
|
onCallbackFailure: (event) => deps.warn("project-room:message-commit-callback-failed", event)
|
|
31366
31353
|
};
|
|
31367
|
-
deps.adapterRegistry.register(createRoomChannelAdapter(new
|
|
31354
|
+
deps.adapterRegistry.register(createRoomChannelAdapter(new import_core69.RoomAgentMessageService(writerDeps)));
|
|
31368
31355
|
} catch (error) {
|
|
31369
31356
|
deps.warn("Room channel unavailable", { error: error instanceof Error ? error.message : String(error) });
|
|
31370
31357
|
}
|
|
@@ -31385,11 +31372,11 @@ async function prepareProjectTaskRuntime(runtime, log2) {
|
|
|
31385
31372
|
}
|
|
31386
31373
|
|
|
31387
31374
|
// src/services/multiReplicaReadiness.ts
|
|
31388
|
-
var
|
|
31375
|
+
var import_core70 = require("@axiom-lattice/core");
|
|
31389
31376
|
var SHARED_STORE_KINDS = ["lease", "outbox", "threadMessageQueue", "task", "taskWorkItem"];
|
|
31390
31377
|
function storeClassName(kind) {
|
|
31391
31378
|
try {
|
|
31392
|
-
return (0,
|
|
31379
|
+
return (0, import_core70.getStoreLattice)("default", kind).store.constructor?.name;
|
|
31393
31380
|
} catch {
|
|
31394
31381
|
return void 0;
|
|
31395
31382
|
}
|
|
@@ -31559,11 +31546,11 @@ var DEFAULT_LOGGER_CONFIG = {
|
|
|
31559
31546
|
var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
|
|
31560
31547
|
var logger7 = loggerLattice.client;
|
|
31561
31548
|
function initializeLogger(config) {
|
|
31562
|
-
if (
|
|
31563
|
-
|
|
31549
|
+
if (import_core93.loggerLatticeManager.hasLattice("default")) {
|
|
31550
|
+
import_core93.loggerLatticeManager.removeLattice("default");
|
|
31564
31551
|
}
|
|
31565
|
-
(0,
|
|
31566
|
-
return (0,
|
|
31552
|
+
(0, import_core93.registerLoggerLattice)("default", config);
|
|
31553
|
+
return (0, import_core93.getLoggerLattice)("default");
|
|
31567
31554
|
}
|
|
31568
31555
|
var app = (0, import_fastify.default)({
|
|
31569
31556
|
logger: false,
|
|
@@ -31660,7 +31647,7 @@ app.setErrorHandler((error, request, reply) => {
|
|
|
31660
31647
|
});
|
|
31661
31648
|
function getConfiguredSandboxProvider() {
|
|
31662
31649
|
const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox-remote";
|
|
31663
|
-
return (0,
|
|
31650
|
+
return (0, import_core93.createSandboxProvider)({
|
|
31664
31651
|
type: sandboxProviderType,
|
|
31665
31652
|
remoteBaseURL: process.env.SANDBOX_BASE_URL,
|
|
31666
31653
|
microsandboxServiceBaseURL: process.env.MICROSANDBOX_SERVICE_BASE_URL,
|
|
@@ -31676,7 +31663,7 @@ function getConfiguredSandboxProvider() {
|
|
|
31676
31663
|
}
|
|
31677
31664
|
async function restoreMcpConnections() {
|
|
31678
31665
|
try {
|
|
31679
|
-
const storeLattice = (0,
|
|
31666
|
+
const storeLattice = (0, import_core93.getStoreLattice)("default", "mcp");
|
|
31680
31667
|
const store2 = storeLattice.store;
|
|
31681
31668
|
if (!store2) {
|
|
31682
31669
|
logger7.info("MCP store not configured, skipping connection restoration");
|
|
@@ -31689,8 +31676,8 @@ async function restoreMcpConnections() {
|
|
|
31689
31676
|
logger7.info(`Restoring ${configs.length} MCP server connections...`);
|
|
31690
31677
|
const deps = {
|
|
31691
31678
|
store: store2,
|
|
31692
|
-
manager:
|
|
31693
|
-
convertToConnection:
|
|
31679
|
+
manager: import_core93.mcpManager,
|
|
31680
|
+
convertToConnection: import_core93.convertToConnection
|
|
31694
31681
|
};
|
|
31695
31682
|
const results = await Promise.allSettled(
|
|
31696
31683
|
configs.map(
|
|
@@ -31731,9 +31718,9 @@ var start = async (config) => {
|
|
|
31731
31718
|
let projectRoomRealtimeRuntime;
|
|
31732
31719
|
if (projectRoomRealtimeMode === "single-gateway") {
|
|
31733
31720
|
projectRoomRealtimeRuntime = createProjectRoomRealtimeRuntime({
|
|
31734
|
-
tasks: (0,
|
|
31735
|
-
rooms: (0,
|
|
31736
|
-
memberships: (0,
|
|
31721
|
+
tasks: (0, import_core93.getStoreLattice)("default", "task").store,
|
|
31722
|
+
rooms: (0, import_core93.getStoreLattice)("default", "projectRoom").store,
|
|
31723
|
+
memberships: (0, import_core93.getStoreLattice)("default", "projectBotMembership").store,
|
|
31737
31724
|
log: { warn: (message, context) => logger7.warn(message, context) }
|
|
31738
31725
|
});
|
|
31739
31726
|
}
|
|
@@ -31747,7 +31734,7 @@ var start = async (config) => {
|
|
|
31747
31734
|
const infrastructure = createChannelInfrastructure({
|
|
31748
31735
|
adapterRegistry,
|
|
31749
31736
|
getStore: ((kind) => getStore11("default", kind).store),
|
|
31750
|
-
trustedDispatcher: (0,
|
|
31737
|
+
trustedDispatcher: (0, import_core93.createTrustedAgentMessageDispatcher)((scope) => import_core93.agentInstanceManager.getAgent(scope)),
|
|
31751
31738
|
middlewares: [
|
|
31752
31739
|
createDeduplicationMiddleware(),
|
|
31753
31740
|
createRateLimitMiddleware(),
|
|
@@ -31758,7 +31745,7 @@ var start = async (config) => {
|
|
|
31758
31745
|
});
|
|
31759
31746
|
const bindingStore = infrastructure.bindingRegistry;
|
|
31760
31747
|
const installationStore = infrastructure.installationStore;
|
|
31761
|
-
(0,
|
|
31748
|
+
(0, import_core92.setBindingRegistry)(bindingStore);
|
|
31762
31749
|
const router = infrastructure.router;
|
|
31763
31750
|
app.addHook("onClose", async () => router.dispose());
|
|
31764
31751
|
channelDeps = {
|
|
@@ -31774,10 +31761,10 @@ var start = async (config) => {
|
|
|
31774
31761
|
error: err instanceof Error ? err.message : String(err)
|
|
31775
31762
|
});
|
|
31776
31763
|
}
|
|
31777
|
-
(0,
|
|
31764
|
+
(0, import_core92.setEvalRunService)(evalRunner);
|
|
31778
31765
|
try {
|
|
31779
|
-
const menuStore = (0,
|
|
31780
|
-
(0,
|
|
31766
|
+
const menuStore = (0, import_core93.getStoreLattice)("default", "menu").store;
|
|
31767
|
+
(0, import_core92.setMenuRegistry)(menuStore);
|
|
31781
31768
|
logger7.info("Menu registry initialized");
|
|
31782
31769
|
} catch {
|
|
31783
31770
|
}
|
|
@@ -31794,10 +31781,10 @@ var start = async (config) => {
|
|
|
31794
31781
|
const { A2AAuthService: A2AAuthService2, parseEnvKeys: parseEnvKeys2 } = await Promise.resolve().then(() => (init_A2AAuthService(), A2AAuthService_exports));
|
|
31795
31782
|
const { registerA2AStandardRoutes: registerA2AStandardRoutes2 } = await Promise.resolve().then(() => (init_a2a_standard(), a2a_standard_exports));
|
|
31796
31783
|
const a2a = await Promise.resolve().then(() => (init_a2a(), a2a_exports));
|
|
31797
|
-
const a2aKeyStore = (0,
|
|
31798
|
-
const assistantStore = (0,
|
|
31799
|
-
const projectStore = (0,
|
|
31800
|
-
const taskStore = (0,
|
|
31784
|
+
const a2aKeyStore = (0, import_core93.getStoreLattice)("default", "a2aApiKey").store;
|
|
31785
|
+
const assistantStore = (0, import_core93.getStoreLattice)("default", "assistant").store;
|
|
31786
|
+
const projectStore = (0, import_core93.getStoreLattice)("default", "project").store;
|
|
31787
|
+
const taskStore = (0, import_core93.getStoreLattice)("default", "task").store;
|
|
31801
31788
|
const authService = new A2AAuthService2({
|
|
31802
31789
|
keyStore: a2aKeyStore,
|
|
31803
31790
|
assistantStore,
|
|
@@ -31836,8 +31823,8 @@ var start = async (config) => {
|
|
|
31836
31823
|
const { CollectionService: CollectionService2 } = await Promise.resolve().then(() => (init_collection_service(), collection_service_exports));
|
|
31837
31824
|
openLattice2.register(createKbProvider2(new CollectionService2()));
|
|
31838
31825
|
openLattice2.register(createOpenSandboxProvider2());
|
|
31839
|
-
const threadStore = (0,
|
|
31840
|
-
const assistantStore = (0,
|
|
31826
|
+
const threadStore = (0, import_core93.getStoreLattice)("default", "thread").store;
|
|
31827
|
+
const assistantStore = (0, import_core93.getStoreLattice)("default", "assistant").store;
|
|
31841
31828
|
openLattice2.register(
|
|
31842
31829
|
createAgentProvider2({
|
|
31843
31830
|
threadStore,
|
|
@@ -31871,17 +31858,17 @@ var start = async (config) => {
|
|
|
31871
31858
|
error: err instanceof Error ? err.message : String(err)
|
|
31872
31859
|
});
|
|
31873
31860
|
}
|
|
31874
|
-
if (!
|
|
31875
|
-
|
|
31861
|
+
if (!import_core93.sandboxLatticeManager.hasLattice("default")) {
|
|
31862
|
+
import_core93.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
|
|
31876
31863
|
logger7.info("Registered sandbox manager from env configuration");
|
|
31877
31864
|
}
|
|
31878
31865
|
try {
|
|
31879
31866
|
const { ResourceController: ResourceController2 } = await Promise.resolve().then(() => (init_resources(), resources_exports));
|
|
31880
|
-
const sharedResourceStore = (0,
|
|
31881
|
-
const cache2 = new
|
|
31867
|
+
const sharedResourceStore = (0, import_core93.getStoreLattice)("default", "sharedResource").store;
|
|
31868
|
+
const cache2 = new import_core93.TokenCache();
|
|
31882
31869
|
const resourceController = new ResourceController2({
|
|
31883
31870
|
store: sharedResourceStore,
|
|
31884
|
-
sandboxManager:
|
|
31871
|
+
sandboxManager: import_core93.sandboxLatticeManager,
|
|
31885
31872
|
cache: cache2,
|
|
31886
31873
|
logger: logger7
|
|
31887
31874
|
});
|
|
@@ -31906,39 +31893,39 @@ var start = async (config) => {
|
|
|
31906
31893
|
}
|
|
31907
31894
|
}
|
|
31908
31895
|
const target_port = config?.port || Number(process.env.PORT) || 4001;
|
|
31909
|
-
(0,
|
|
31910
|
-
const outboxStore = (0,
|
|
31911
|
-
|
|
31912
|
-
|
|
31913
|
-
(0,
|
|
31896
|
+
(0, import_core93.configureCoordinationLeaseStore)((0, import_core93.getStoreLattice)("default", "lease").store);
|
|
31897
|
+
const outboxStore = (0, import_core93.getStoreLattice)("default", "outbox").store;
|
|
31898
|
+
import_core93.taskLifecycleNotifier.setOutbox(outboxStore);
|
|
31899
|
+
import_core93.projectTaskAdmissionNotifier.setOutbox(outboxStore);
|
|
31900
|
+
(0, import_core93.configurePluginCatalogSync)({ outbox: outboxStore, owner: (0, import_core93.getReplicaId)() });
|
|
31914
31901
|
bridgeAssistantEvents(
|
|
31915
|
-
(event, cb) =>
|
|
31902
|
+
(event, cb) => import_core93.eventBus.subscribe(event, cb),
|
|
31916
31903
|
outboxStore,
|
|
31917
|
-
(0,
|
|
31904
|
+
(0, import_core93.getReplicaId)()
|
|
31918
31905
|
);
|
|
31919
31906
|
if (projectRoomRealtimeRuntime) {
|
|
31920
31907
|
projectRoomRealtimeRuntime.broker.setBroadcastHook((scope, serialized, sourceKey) => {
|
|
31921
|
-
void publishRoomEvent(outboxStore, (0,
|
|
31908
|
+
void publishRoomEvent(outboxStore, (0, import_core93.getReplicaId)(), scope, serialized, sourceKey);
|
|
31922
31909
|
});
|
|
31923
31910
|
}
|
|
31924
|
-
const outboxPoller = new
|
|
31911
|
+
const outboxPoller = new import_core93.OutboxPoller({
|
|
31925
31912
|
store: outboxStore,
|
|
31926
|
-
owner: (0,
|
|
31913
|
+
owner: (0, import_core93.getReplicaId)(),
|
|
31927
31914
|
handlers: {
|
|
31928
|
-
"task-lifecycle": (payload) =>
|
|
31929
|
-
"project-task-admission": (payload) =>
|
|
31915
|
+
"task-lifecycle": (payload) => import_core93.taskLifecycleNotifier.deliverFromOutbox(payload),
|
|
31916
|
+
"project-task-admission": (payload) => import_core93.projectTaskAdmissionNotifier.deliverFromOutbox(payload),
|
|
31930
31917
|
[ROOM_EVENT_TOPIC]: async (payload) => {
|
|
31931
31918
|
if (projectRoomRealtimeRuntime) ingestRoomEvent(payload, projectRoomRealtimeRuntime.broker);
|
|
31932
31919
|
},
|
|
31933
|
-
"assistant-changed": (payload) => handleAssistantChanged(payload, (tenantId) =>
|
|
31920
|
+
"assistant-changed": (payload) => handleAssistantChanged(payload, (tenantId) => import_core93.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId)),
|
|
31934
31921
|
[MCP_CONFIG_CHANGED_TOPIC]: (payload) => reconcileMcpConfigChange(payload, {
|
|
31935
|
-
store: (0,
|
|
31936
|
-
manager:
|
|
31937
|
-
convertToConnection:
|
|
31922
|
+
store: (0, import_core93.getStoreLattice)("default", "mcp").store,
|
|
31923
|
+
manager: import_core93.mcpManager,
|
|
31924
|
+
convertToConnection: import_core93.convertToConnection
|
|
31938
31925
|
}),
|
|
31939
|
-
[
|
|
31926
|
+
[import_core93.PLUGIN_CATALOG_CHANGED_TOPIC]: async (payload) => {
|
|
31940
31927
|
const tenantId = payload?.tenantId;
|
|
31941
|
-
if (typeof tenantId === "string" && tenantId.length > 0) (0,
|
|
31928
|
+
if (typeof tenantId === "string" && tenantId.length > 0) (0, import_core93.getSandboxPluginCatalog)().invalidate(tenantId);
|
|
31942
31929
|
}
|
|
31943
31930
|
},
|
|
31944
31931
|
log: logger7
|
|
@@ -31948,7 +31935,7 @@ var start = async (config) => {
|
|
|
31948
31935
|
} catch (err) {
|
|
31949
31936
|
logger7.warn("Outbox poller failed to start", { error: err instanceof Error ? err.message : String(err) });
|
|
31950
31937
|
}
|
|
31951
|
-
const leaseStore = (0,
|
|
31938
|
+
const leaseStore = (0, import_core93.getStoreLattice)("default", "lease").store;
|
|
31952
31939
|
if (leaseStore.constructor?.name === "InMemoryLeaseStore") {
|
|
31953
31940
|
logger7.warn(
|
|
31954
31941
|
"Startup recovery leader gate uses a non-distributed lease store (per-process only); configure a shared 'lease' store for multi-replica deployments",
|
|
@@ -31956,7 +31943,7 @@ var start = async (config) => {
|
|
|
31956
31943
|
);
|
|
31957
31944
|
}
|
|
31958
31945
|
warnMultiReplicaReadiness(logger7);
|
|
31959
|
-
const startup = await (0,
|
|
31946
|
+
const startup = await (0, import_core93.runAsLeader)(leaseStore, "startup-recovery", async () => {
|
|
31960
31947
|
if (routes.projectTaskRuntime) {
|
|
31961
31948
|
await prepareProjectTaskRuntime(routes.projectTaskRuntime, logger7);
|
|
31962
31949
|
}
|
|
@@ -31965,9 +31952,9 @@ var start = async (config) => {
|
|
|
31965
31952
|
const { createOrphanRecoveryRuntime: createOrphanRecoveryRuntime2 } = await Promise.resolve().then(() => (init_OrphanRecoveryRuntime(), OrphanRecoveryRuntime_exports));
|
|
31966
31953
|
const { createRecoveryCallerDeps: createRecoveryCallerDeps2 } = await Promise.resolve().then(() => (init_RecoveryCallerDeps(), RecoveryCallerDeps_exports));
|
|
31967
31954
|
const runtime = createOrphanRecoveryRuntime2({
|
|
31968
|
-
taskStore: (0,
|
|
31969
|
-
workItemStore: (0,
|
|
31970
|
-
tenantStore: (0,
|
|
31955
|
+
taskStore: (0, import_core93.getStoreLattice)("default", "task").store,
|
|
31956
|
+
workItemStore: (0, import_core93.getStoreLattice)("default", "taskWorkItem").store,
|
|
31957
|
+
tenantStore: (0, import_core93.getStoreLattice)("default", "tenant").store,
|
|
31971
31958
|
...createRecoveryCallerDeps2(),
|
|
31972
31959
|
log: logger7
|
|
31973
31960
|
});
|
|
@@ -31976,9 +31963,9 @@ var start = async (config) => {
|
|
|
31976
31963
|
logger7.warn("Task orphan recovery failed", { error: err instanceof Error ? err.message : String(err) });
|
|
31977
31964
|
}
|
|
31978
31965
|
}
|
|
31979
|
-
if (
|
|
31966
|
+
if (import_core93.scheduleLatticeManager.hasLattice("default")) {
|
|
31980
31967
|
try {
|
|
31981
|
-
const restored = await
|
|
31968
|
+
const restored = await import_core93.scheduleLatticeManager.getScheduleLattice("default").restore();
|
|
31982
31969
|
logger7.info("Scheduled tasks restored", { phase: "startup_recovery", restored });
|
|
31983
31970
|
} catch (err) {
|
|
31984
31971
|
logger7.warn("Scheduled task restore failed", {
|