@axiom-lattice/gateway 2.1.77 → 2.1.79
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +24 -0
- package/dist/index.js +79 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/channels/lark/LarkChannelAdapter.ts +1 -1
- package/src/channels/lark/controller.ts +4 -3
- package/src/controllers/sandbox.ts +21 -21
- package/src/controllers/workflow-tracking.ts +59 -3
- package/src/router/MessageRouter.ts +15 -5
- package/src/routes/index.ts +5 -1
package/dist/index.mjs
CHANGED
|
@@ -1717,7 +1717,7 @@ async function executeSqlQuery(client, body, reply) {
|
|
|
1717
1717
|
}
|
|
1718
1718
|
|
|
1719
1719
|
// src/controllers/workflow-tracking.ts
|
|
1720
|
-
import { getStoreLattice as getStoreLattice4, agentInstanceManager as agentInstanceManager4 } from "@axiom-lattice/core";
|
|
1720
|
+
import { getStoreLattice as getStoreLattice4, agentInstanceManager as agentInstanceManager4, ThreadStatus as ThreadStatus2 } from "@axiom-lattice/core";
|
|
1721
1721
|
import { MessageChunkTypes as MessageChunkTypes2 } from "@axiom-lattice/protocols";
|
|
1722
1722
|
function getTenantId6(request) {
|
|
1723
1723
|
const userTenantId = request.user?.tenantId;
|
|
@@ -1963,6 +1963,41 @@ async function getWorkflowRun(request, reply) {
|
|
|
1963
1963
|
return reply.status(500).send({ success: false, message: "Failed to retrieve workflow run" });
|
|
1964
1964
|
}
|
|
1965
1965
|
}
|
|
1966
|
+
async function deleteWorkflowRun(request, reply) {
|
|
1967
|
+
const { runId } = request.params;
|
|
1968
|
+
const tenantId = getTenantId6(request);
|
|
1969
|
+
try {
|
|
1970
|
+
const store = getTrackingStore();
|
|
1971
|
+
if (!store) {
|
|
1972
|
+
return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
|
|
1973
|
+
}
|
|
1974
|
+
const run = await store.getWorkflowRun(runId);
|
|
1975
|
+
if (!run) {
|
|
1976
|
+
return reply.status(404).send({ success: false, message: "Workflow run not found" });
|
|
1977
|
+
}
|
|
1978
|
+
if (run.status === "running") {
|
|
1979
|
+
try {
|
|
1980
|
+
const workspace_id = request.headers["x-workspace-id"];
|
|
1981
|
+
const project_id = request.headers["x-project-id"];
|
|
1982
|
+
const agent = agentInstanceManager4.getAgent({
|
|
1983
|
+
assistant_id: run.assistantId,
|
|
1984
|
+
thread_id: run.threadId,
|
|
1985
|
+
tenant_id: tenantId,
|
|
1986
|
+
workspace_id,
|
|
1987
|
+
project_id
|
|
1988
|
+
});
|
|
1989
|
+
await agent.abort();
|
|
1990
|
+
} catch (err) {
|
|
1991
|
+
request.log.warn({ runId, error: err.message }, "Failed to abort agent, deleting tracking records anyway");
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
await store.deleteWorkflowRun(runId);
|
|
1995
|
+
return { success: true, message: "Workflow run deleted" };
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
request.log.error(error, "Failed to delete workflow run");
|
|
1998
|
+
return reply.status(500).send({ success: false, message: "Failed to delete workflow run" });
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
1966
2001
|
async function getRunSteps(request, reply) {
|
|
1967
2002
|
const { runId } = request.params;
|
|
1968
2003
|
const { step_type, status: stepStatus } = request.query;
|
|
@@ -2035,6 +2070,14 @@ async function replyInboxTask(request, reply) {
|
|
|
2035
2070
|
workspace_id,
|
|
2036
2071
|
project_id
|
|
2037
2072
|
});
|
|
2073
|
+
const runStatus = await agent.getRunStatus();
|
|
2074
|
+
if (runStatus !== ThreadStatus2.INTERRUPTED) {
|
|
2075
|
+
return reply.status(409).send({
|
|
2076
|
+
success: false,
|
|
2077
|
+
message: `Cannot resume: graph is not interrupted (current status: ${runStatus})`,
|
|
2078
|
+
data: { runId: run.id, assistantId: run.assistantId, threadId: run.threadId, status: runStatus }
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2038
2081
|
agent.addMessage({
|
|
2039
2082
|
input: { message: "Clarification answers submitted" },
|
|
2040
2083
|
command: {
|
|
@@ -2686,13 +2729,17 @@ function registerSandboxProxyRoutes(app2) {
|
|
|
2686
2729
|
if (!vmIsolation) {
|
|
2687
2730
|
return reply.status(500).send({ error: "Assistant sandbox config not found" });
|
|
2688
2731
|
}
|
|
2689
|
-
const
|
|
2690
|
-
|
|
2691
|
-
threadId,
|
|
2692
|
-
vmIsolation
|
|
2693
|
-
);
|
|
2732
|
+
const workspaceId = request.headers["x-workspace-id"];
|
|
2733
|
+
const projectId = request.headers["x-project-id"];
|
|
2694
2734
|
const sandboxManager = getSandBoxManager2();
|
|
2695
|
-
const sandbox = await sandboxManager.
|
|
2735
|
+
const sandbox = await sandboxManager.getSandboxFromConfig({
|
|
2736
|
+
assistant_id: assistantId,
|
|
2737
|
+
thread_id: threadId,
|
|
2738
|
+
tenantId,
|
|
2739
|
+
workspaceId,
|
|
2740
|
+
projectId,
|
|
2741
|
+
vmIsolation
|
|
2742
|
+
});
|
|
2696
2743
|
try {
|
|
2697
2744
|
const data = await request.file();
|
|
2698
2745
|
if (!data) {
|
|
@@ -2730,13 +2777,17 @@ function registerSandboxProxyRoutes(app2) {
|
|
|
2730
2777
|
if (!vmIsolation) {
|
|
2731
2778
|
return reply.status(500).send({ error: "Assistant filesystem vmIsolation not found" });
|
|
2732
2779
|
}
|
|
2733
|
-
const
|
|
2734
|
-
|
|
2735
|
-
threadId,
|
|
2736
|
-
vmIsolation
|
|
2737
|
-
);
|
|
2780
|
+
const workspaceId = request.headers["x-workspace-id"];
|
|
2781
|
+
const projectId = request.headers["x-project-id"];
|
|
2738
2782
|
const sandboxManager = getSandBoxManager2();
|
|
2739
|
-
const sandbox = await sandboxManager.
|
|
2783
|
+
const sandbox = await sandboxManager.getSandboxFromConfig({
|
|
2784
|
+
assistant_id: assistantId,
|
|
2785
|
+
thread_id: threadId,
|
|
2786
|
+
tenantId,
|
|
2787
|
+
workspaceId,
|
|
2788
|
+
projectId,
|
|
2789
|
+
vmIsolation
|
|
2790
|
+
});
|
|
2740
2791
|
try {
|
|
2741
2792
|
const resolvedPath = filePath.startsWith("/") ? filePath : `/${filePath}`;
|
|
2742
2793
|
const filename = getFilenameFromPath(resolvedPath);
|
|
@@ -5787,7 +5838,7 @@ var larkChannelAdapter = {
|
|
|
5787
5838
|
},
|
|
5788
5839
|
async sendReply(replyTarget, message, installation) {
|
|
5789
5840
|
const { createLarkSender } = await import("./sender-PX32VSHB.mjs");
|
|
5790
|
-
const sender = createLarkSender(installation.config);
|
|
5841
|
+
const sender = await createLarkSender(installation.config);
|
|
5791
5842
|
await sender.sendTextReply({
|
|
5792
5843
|
chatId: replyTarget.rawTarget.chatId,
|
|
5793
5844
|
text: message.text
|
|
@@ -5965,12 +6016,13 @@ function createLarkEventHandler(deps) {
|
|
|
5965
6016
|
reply.status(404).send({ success: false, message: "Installation not found" });
|
|
5966
6017
|
return;
|
|
5967
6018
|
}
|
|
5968
|
-
const
|
|
6019
|
+
const larkInstallation = installation;
|
|
6020
|
+
const body = parseLarkRequestBody(request.body, larkInstallation.config.encryptKey);
|
|
5969
6021
|
if (body.type === "url_verification" && body.challenge) {
|
|
5970
6022
|
reply.status(200).send({ challenge: body.challenge });
|
|
5971
6023
|
return;
|
|
5972
6024
|
}
|
|
5973
|
-
const inboundMessage = await larkChannelAdapter.receive(request.body,
|
|
6025
|
+
const inboundMessage = await larkChannelAdapter.receive(request.body, larkInstallation);
|
|
5974
6026
|
if (!inboundMessage) {
|
|
5975
6027
|
reply.status(200).send();
|
|
5976
6028
|
return;
|
|
@@ -6524,7 +6576,7 @@ var registerLatticeRoutes = (app2, channelDeps) => {
|
|
|
6524
6576
|
const inboundMessage = {
|
|
6525
6577
|
channel: msg.channel,
|
|
6526
6578
|
channelInstallationId: msg.channelInstallationId || "",
|
|
6527
|
-
tenantId: msg.tenantId
|
|
6579
|
+
tenantId: msg.tenantId,
|
|
6528
6580
|
sender: {
|
|
6529
6581
|
id: msg.sender.id,
|
|
6530
6582
|
displayName: msg.sender.displayName
|
|
@@ -6565,6 +6617,7 @@ var registerLatticeRoutes = (app2, channelDeps) => {
|
|
|
6565
6617
|
getWorkflowRuns
|
|
6566
6618
|
);
|
|
6567
6619
|
app2.get("/api/workflows/runs/:runId", getWorkflowRun);
|
|
6620
|
+
app2.delete("/api/workflows/runs/:runId", deleteWorkflowRun);
|
|
6568
6621
|
app2.get("/api/workflows/runs/:runId/steps", getRunSteps);
|
|
6569
6622
|
app2.get("/api/workflows/runs/:runId/tasks", getRunTasks);
|
|
6570
6623
|
app2.post("/api/workflows/inbox/reply", replyInboxTask);
|
|
@@ -6603,11 +6656,17 @@ var MessageRouter = class {
|
|
|
6603
6656
|
};
|
|
6604
6657
|
try {
|
|
6605
6658
|
await this.runMiddlewares(ctx, async () => {
|
|
6659
|
+
const tenantId = message.tenantId || (await this.installationStore.getInstallationById(message.channelInstallationId))?.tenantId;
|
|
6660
|
+
if (!tenantId) {
|
|
6661
|
+
throw new Error(
|
|
6662
|
+
"tenantId is required: provide it in the message or ensure the channelInstallation has a tenantId"
|
|
6663
|
+
);
|
|
6664
|
+
}
|
|
6606
6665
|
let binding = await this.bindingRegistry.resolve({
|
|
6607
6666
|
channel: message.channel,
|
|
6608
6667
|
senderId: message.sender.id,
|
|
6609
6668
|
channelInstallationId: message.channelInstallationId,
|
|
6610
|
-
tenantId
|
|
6669
|
+
tenantId
|
|
6611
6670
|
});
|
|
6612
6671
|
if (!binding) {
|
|
6613
6672
|
const installation = await this.installationStore.getInstallationById(
|
|
@@ -6623,7 +6682,7 @@ var MessageRouter = class {
|
|
|
6623
6682
|
id: "fallback",
|
|
6624
6683
|
channel: message.channel,
|
|
6625
6684
|
channelInstallationId: message.channelInstallationId,
|
|
6626
|
-
tenantId
|
|
6685
|
+
tenantId,
|
|
6627
6686
|
senderId: message.sender.id,
|
|
6628
6687
|
agentId: installation.fallbackAgentId,
|
|
6629
6688
|
threadId: void 0,
|
|
@@ -6649,7 +6708,7 @@ var MessageRouter = class {
|
|
|
6649
6708
|
const threadStore = getStoreLattice14("default", "thread").store;
|
|
6650
6709
|
const newThreadId = randomUUID7();
|
|
6651
6710
|
const newThread = await threadStore.createThread(
|
|
6652
|
-
|
|
6711
|
+
tenantId,
|
|
6653
6712
|
ctx.binding.agentId,
|
|
6654
6713
|
newThreadId,
|
|
6655
6714
|
{
|
|
@@ -6670,7 +6729,7 @@ var MessageRouter = class {
|
|
|
6670
6729
|
}
|
|
6671
6730
|
}
|
|
6672
6731
|
const agent = agentInstanceManager6.getAgent({
|
|
6673
|
-
tenant_id:
|
|
6732
|
+
tenant_id: tenantId,
|
|
6674
6733
|
assistant_id: ctx.binding.agentId,
|
|
6675
6734
|
thread_id: threadId,
|
|
6676
6735
|
workspace_id: ctx.binding.workspaceId || "",
|