@haven_ai/mcp 0.4.0-alpha.0 → 0.5.0-alpha.1
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/cli.cjs +14 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +15 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +14 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { composeDescription, toolDescriptions as toolDescriptions$1, HavenClient, isSupportedNodeVersion, unsupportedNodeVersionMessage, HavenPaymentStateError, HavenSigningError, HavenApiError, AgentPaymentNextAction, HavenError, AgentPaymentFailureCode, verifyPaymentReceipt, discoverMerchantMcpUrl, sameUrl } from '@haven_ai/sdk';
|
|
4
|
+
import { composeDescription, toolDescriptions as toolDescriptions$1, HavenClient, havenClientIdentity, isSupportedNodeVersion, unsupportedNodeVersionMessage, HavenPaymentStateError, HavenSigningError, HavenApiError, AgentPaymentNextAction, HavenError, AgentPaymentFailureCode, verifyPaymentReceipt, discoverMerchantMcpUrl, sameUrl } from '@haven_ai/sdk';
|
|
5
5
|
import { readFile, mkdir, writeFile, stat } from 'fs/promises';
|
|
6
6
|
import { z } from 'zod/v3';
|
|
7
7
|
import { createHash } from 'crypto';
|
|
@@ -730,6 +730,9 @@ function normalizeError(err) {
|
|
|
730
730
|
phase: stringOrUndefined(body?.phase),
|
|
731
731
|
nextAction: stringOrUndefined(body?.nextAction) ?? stringOrUndefined(body?.next_action) ?? AgentPaymentNextAction.StopAndTellUser,
|
|
732
732
|
next_action: stringOrUndefined(body?.nextAction) ?? stringOrUndefined(body?.next_action) ?? AgentPaymentNextAction.StopAndTellUser,
|
|
733
|
+
// #3303: a backend refusal that already names why no tool follows (the
|
|
734
|
+
// 426 `client_outdated` does) keeps that reason at the top level.
|
|
735
|
+
...typeof body?.next_tool_omitted_reason === "string" ? { next_tool_omitted_reason: body.next_tool_omitted_reason } : {},
|
|
733
736
|
body: err.body
|
|
734
737
|
};
|
|
735
738
|
}
|
|
@@ -782,7 +785,7 @@ function renderConsentBlock(input, hash) {
|
|
|
782
785
|
];
|
|
783
786
|
if (input.apiUrl) lines.push(`Haven API: ${input.apiUrl}`);
|
|
784
787
|
if (input.agentId) lines.push(`Agent ID: ${input.agentId}`);
|
|
785
|
-
if (input.accountAddress) lines.push(`Haven wallet
|
|
788
|
+
if (input.accountAddress) lines.push(`Haven wallet: ${input.accountAddress}`);
|
|
786
789
|
if (input.delegateAddress) lines.push(`Delegate (local signer): ${input.delegateAddress}`);
|
|
787
790
|
if (typeof input.chainId === "number") lines.push(`Chain ID: ${input.chainId}`);
|
|
788
791
|
lines.push("");
|
|
@@ -941,12 +944,15 @@ async function resolveHavenClient(options = {}) {
|
|
|
941
944
|
const client = new HavenClient({
|
|
942
945
|
apiKey: credentials.apiKey,
|
|
943
946
|
delegateKey: credentials.delegateKey,
|
|
944
|
-
baseUrl: credentials.apiUrl
|
|
947
|
+
baseUrl: credentials.apiUrl,
|
|
948
|
+
// #3303: name this package, not the SDK inside it, so the backend's
|
|
949
|
+
// update hint and refusal speak about what the user actually installed.
|
|
950
|
+
clientIdentity: havenClientIdentity(MCP_NAME, MCP_VERSION)
|
|
945
951
|
});
|
|
946
952
|
return { client, credentials };
|
|
947
953
|
}
|
|
948
954
|
var MCP_NAME = "@haven_ai/mcp";
|
|
949
|
-
var MCP_VERSION = "0.
|
|
955
|
+
var MCP_VERSION = "0.5.0-alpha.1";
|
|
950
956
|
var MCP_INSTRUCTIONS = [
|
|
951
957
|
"Haven local MCP server: signs in-process with the delegate key it holds on",
|
|
952
958
|
"this machine \u2014 the key never leaves this process. Call haven_get_agent",
|
|
@@ -983,7 +989,7 @@ function buildMcpServer(haven) {
|
|
|
983
989
|
toolSchemas[name],
|
|
984
990
|
async (args) => haven.withRequestContext(
|
|
985
991
|
{ "X-Haven-MCP-Tool": name },
|
|
986
|
-
async () => toMcpResult(await handlers[name](args))
|
|
992
|
+
async () => toMcpResult(withClientUpdate(await handlers[name](args), haven.clientUpdate()))
|
|
987
993
|
)
|
|
988
994
|
);
|
|
989
995
|
}
|
|
@@ -1033,6 +1039,10 @@ async function runConsentGate(haven, credentials, options) {
|
|
|
1033
1039
|
writeAck: options.writeAck
|
|
1034
1040
|
});
|
|
1035
1041
|
}
|
|
1042
|
+
function withClientUpdate(payload, hint) {
|
|
1043
|
+
if (!hint || payload.client_update) return payload;
|
|
1044
|
+
return { ...payload, client_update: hint };
|
|
1045
|
+
}
|
|
1036
1046
|
function toMcpResult(payload) {
|
|
1037
1047
|
return {
|
|
1038
1048
|
isError: !payload.success,
|