@suveren/gateway 0.2.9 → 0.2.10
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/mcp-server/http.mjs
CHANGED
|
@@ -1553,9 +1553,10 @@ async function executeCommitted(proposal, state2, integrationManager2) {
|
|
|
1553
1553
|
`[Suveren MCP] Warning: proposal ${proposal.id} has no action_type in executionContext. Bounds check may be skipped. Fix the integration manifest for ${proposal.tool}.`
|
|
1554
1554
|
);
|
|
1555
1555
|
}
|
|
1556
|
+
let receiptId;
|
|
1556
1557
|
try {
|
|
1557
1558
|
const boundsHash = proposal.frameHash.split(":").slice(0, 2).join(":");
|
|
1558
|
-
await state2.spClient.postReceipt({
|
|
1559
|
+
const { receipt } = await state2.spClient.postReceipt({
|
|
1559
1560
|
boundsHash,
|
|
1560
1561
|
profileId: proposal.profileId,
|
|
1561
1562
|
action: proposal.tool,
|
|
@@ -1565,6 +1566,7 @@ async function executeCommitted(proposal, state2, integrationManager2) {
|
|
|
1565
1566
|
proposalId: proposal.id,
|
|
1566
1567
|
toolArgs: proposal.toolArgs
|
|
1567
1568
|
});
|
|
1569
|
+
receiptId = typeof receipt?.id === "string" ? receipt.id : void 0;
|
|
1568
1570
|
} catch (err) {
|
|
1569
1571
|
if (err instanceof SPReceiptError) {
|
|
1570
1572
|
const code = err.body.errors?.[0]?.code;
|
|
@@ -1584,7 +1586,20 @@ async function executeCommitted(proposal, state2, integrationManager2) {
|
|
|
1584
1586
|
};
|
|
1585
1587
|
}
|
|
1586
1588
|
try {
|
|
1587
|
-
|
|
1589
|
+
let outgoingArgs = proposal.toolArgs;
|
|
1590
|
+
if (shouldAttachFooter() && receiptId) {
|
|
1591
|
+
const discovered = integrationManager2.getAllTools().find((t) => t.integrationId === integrationId && t.originalName === toolName);
|
|
1592
|
+
if (discovered) {
|
|
1593
|
+
outgoingArgs = appendVerificationFooter(discovered, proposal.toolArgs, receiptId);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
const result = await integrationManager2.callTool(integrationId, toolName, outgoingArgs);
|
|
1597
|
+
state2.executionLog.record({
|
|
1598
|
+
profileId: proposal.profileId,
|
|
1599
|
+
path: proposal.path,
|
|
1600
|
+
execution: proposal.executionContext,
|
|
1601
|
+
timestamp: Math.floor(Date.now() / 1e3)
|
|
1602
|
+
});
|
|
1588
1603
|
const resultText = result.content?.[0]?.text ?? JSON.stringify(result);
|
|
1589
1604
|
return { text: `Proposal ${proposal.id} committed and executed.
|
|
1590
1605
|
Result: ${resultText}` };
|
|
@@ -2763,59 +2778,10 @@ app.listen(port, "0.0.0.0", () => {
|
|
|
2763
2778
|
const committed = await state.spClient.getCommittedProposals();
|
|
2764
2779
|
for (const proposal of committed) {
|
|
2765
2780
|
try {
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
if (parts.length !== 2) {
|
|
2771
|
-
console.error(`[Suveren MCP] Invalid tool name in proposal ${proposal.id}: ${proposal.tool}`);
|
|
2772
|
-
continue;
|
|
2773
|
-
}
|
|
2774
|
-
[integrationId, toolName] = parts;
|
|
2775
|
-
} else {
|
|
2776
|
-
const sep = proposal.tool.indexOf("__");
|
|
2777
|
-
if (sep < 0) {
|
|
2778
|
-
console.error(`[Suveren MCP] Invalid tool name in proposal ${proposal.id}: ${proposal.tool}`);
|
|
2779
|
-
continue;
|
|
2780
|
-
}
|
|
2781
|
-
integrationId = proposal.tool.slice(0, sep);
|
|
2782
|
-
toolName = proposal.tool.slice(sep + 2);
|
|
2783
|
-
}
|
|
2784
|
-
const proposalActionType = typeof proposal.executionContext.action_type === "string" ? proposal.executionContext.action_type : void 0;
|
|
2785
|
-
if (!proposalActionType) {
|
|
2786
|
-
console.error(
|
|
2787
|
-
`[Suveren MCP] Warning: proposal ${proposal.id} has no action_type in executionContext. Bounds check may be skipped. Fix the integration manifest for ${proposal.tool}.`
|
|
2788
|
-
);
|
|
2789
|
-
}
|
|
2790
|
-
try {
|
|
2791
|
-
await state.spClient.postReceipt({
|
|
2792
|
-
attestationHash: proposal.frameHash,
|
|
2793
|
-
profileId: proposal.profileId,
|
|
2794
|
-
path: proposal.path,
|
|
2795
|
-
action: proposal.tool,
|
|
2796
|
-
actionType: proposalActionType,
|
|
2797
|
-
executionContext: proposal.executionContext,
|
|
2798
|
-
amount: typeof proposal.executionContext.amount === "number" ? proposal.executionContext.amount : void 0,
|
|
2799
|
-
proposalId: proposal.id,
|
|
2800
|
-
toolArgs: proposal.toolArgs
|
|
2801
|
-
});
|
|
2802
|
-
} catch (err) {
|
|
2803
|
-
console.error(`[Suveren MCP] Receipt failed for proposal ${proposal.id}:`, err instanceof Error ? err.message : err);
|
|
2804
|
-
continue;
|
|
2805
|
-
}
|
|
2806
|
-
try {
|
|
2807
|
-
await integrationManager.callTool(integrationId, toolName, proposal.toolArgs);
|
|
2808
|
-
} catch (err) {
|
|
2809
|
-
console.error(`[Suveren MCP] Tool execution failed for proposal ${proposal.id} after receipt issued:`, err);
|
|
2810
|
-
continue;
|
|
2811
|
-
}
|
|
2812
|
-
state.executionLog.record({
|
|
2813
|
-
profileId: proposal.profileId,
|
|
2814
|
-
path: proposal.path,
|
|
2815
|
-
execution: proposal.executionContext,
|
|
2816
|
-
timestamp: Math.floor(Date.now() / 1e3)
|
|
2817
|
-
});
|
|
2818
|
-
console.error(`[Suveren MCP] Auto-executed proposal ${proposal.id}: ${proposal.tool}`);
|
|
2781
|
+
const { text, isError } = await executeCommitted(proposal, state, integrationManager);
|
|
2782
|
+
console.error(
|
|
2783
|
+
isError ? `[Suveren MCP] Auto-exec proposal ${proposal.id}: ${text}` : `[Suveren MCP] Auto-executed proposal ${proposal.id}: ${proposal.tool}`
|
|
2784
|
+
);
|
|
2819
2785
|
} catch (err) {
|
|
2820
2786
|
console.error(`[Suveren MCP] Failed to execute proposal ${proposal.id}:`, err);
|
|
2821
2787
|
}
|