@keeperhub/wallet 0.1.12 → 0.1.13
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/README.md +5 -5
- package/dist/cli.cjs +107 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +101 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +107 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +101 -28
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +119 -20
- package/dist/mcp-server.cjs.map +1 -1
- package/dist/mcp-server.js +119 -20
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
- package/skill/keeperhub-wallet.skill.md +8 -8
package/dist/mcp-server.js
CHANGED
|
@@ -97,26 +97,6 @@ function fund(walletAddress) {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
// src/mpp-detect.ts
|
|
101
|
-
var MPP_PREFIX = "Payment ";
|
|
102
|
-
function parseMppChallenge(response) {
|
|
103
|
-
const header = response.headers.get("WWW-Authenticate");
|
|
104
|
-
if (!header) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
if (!header.startsWith(MPP_PREFIX)) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
const serialized = header.slice(MPP_PREFIX.length).trim();
|
|
111
|
-
if (serialized.length === 0) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
return { serialized };
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// src/payment-signer.ts
|
|
118
|
-
import { randomBytes as randomBytes2 } from "crypto";
|
|
119
|
-
|
|
120
100
|
// src/hmac.ts
|
|
121
101
|
import { createHash, createHmac } from "crypto";
|
|
122
102
|
function computeSignature(secret, method, path, subOrgId, body, timestamp) {
|
|
@@ -145,6 +125,26 @@ function buildHmacHeaders(secret, method, path, subOrgId, body) {
|
|
|
145
125
|
};
|
|
146
126
|
}
|
|
147
127
|
|
|
128
|
+
// src/mpp-detect.ts
|
|
129
|
+
var MPP_PREFIX = "Payment ";
|
|
130
|
+
function parseMppChallenge(response) {
|
|
131
|
+
const header = response.headers.get("WWW-Authenticate");
|
|
132
|
+
if (!header) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
if (!header.startsWith(MPP_PREFIX)) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const serialized = header.slice(MPP_PREFIX.length).trim();
|
|
139
|
+
if (serialized.length === 0) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return { serialized };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/payment-signer.ts
|
|
146
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
147
|
+
|
|
148
148
|
// src/types.ts
|
|
149
149
|
var KeeperHubError = class extends Error {
|
|
150
150
|
code;
|
|
@@ -1123,6 +1123,94 @@ async function handleInfo(deps) {
|
|
|
1123
1123
|
} : {}
|
|
1124
1124
|
});
|
|
1125
1125
|
}
|
|
1126
|
+
var submitFeedbackInputSchema = {
|
|
1127
|
+
executionId: z.string().min(1).describe(
|
|
1128
|
+
"Workflow execution id returned in the `executionId` field of a previous successful call_workflow response."
|
|
1129
|
+
),
|
|
1130
|
+
value: z.number().int().describe(
|
|
1131
|
+
"Rating value as a raw int128. With valueDecimals=0 this is a 1-5 star score; with valueDecimals=1 it is 0.1-step score. Server validates int128 range."
|
|
1132
|
+
),
|
|
1133
|
+
valueDecimals: z.number().int().min(0).max(18).describe(
|
|
1134
|
+
"Decimals for value. Use 0 for an integer 1-5 score, 1 for a 0.1-step 0-50 score, etc."
|
|
1135
|
+
),
|
|
1136
|
+
comment: z.string().max(2e3).optional().describe(
|
|
1137
|
+
"Optional plain-text comment included in the feedbackURI JSON."
|
|
1138
|
+
),
|
|
1139
|
+
agentChainId: z.number().int().optional().describe(
|
|
1140
|
+
"Chain id where the rated agent NFT lives. Defaults to 1 (Ethereum mainnet); only 1 is supported today."
|
|
1141
|
+
),
|
|
1142
|
+
agentId: z.string().optional().describe(
|
|
1143
|
+
"Rated agent NFT id (uint256, decimal string). Defaults to KeeperHub's own ERC-8004 agent (31875)."
|
|
1144
|
+
)
|
|
1145
|
+
};
|
|
1146
|
+
async function handleSubmitFeedback(args, deps) {
|
|
1147
|
+
let ensured;
|
|
1148
|
+
try {
|
|
1149
|
+
ensured = await ensureWallet(deps);
|
|
1150
|
+
} catch (err) {
|
|
1151
|
+
return toolErrorEnvelope(err);
|
|
1152
|
+
}
|
|
1153
|
+
const baseUrl = resolveKeeperhubBaseUrl();
|
|
1154
|
+
const path = "/api/agentic-wallet/feedback";
|
|
1155
|
+
const url = `${baseUrl}${path}`;
|
|
1156
|
+
const body = JSON.stringify({
|
|
1157
|
+
executionId: args.executionId,
|
|
1158
|
+
value: args.value,
|
|
1159
|
+
valueDecimals: args.valueDecimals,
|
|
1160
|
+
...args.comment !== void 0 ? { comment: args.comment } : {},
|
|
1161
|
+
...args.agentChainId !== void 0 ? { agentChainId: args.agentChainId } : {},
|
|
1162
|
+
...args.agentId !== void 0 ? { agentId: args.agentId } : {}
|
|
1163
|
+
});
|
|
1164
|
+
const hmacHeaders = buildHmacHeaders(
|
|
1165
|
+
ensured.hmacSecret,
|
|
1166
|
+
"POST",
|
|
1167
|
+
path,
|
|
1168
|
+
ensured.subOrgId,
|
|
1169
|
+
body
|
|
1170
|
+
);
|
|
1171
|
+
let response;
|
|
1172
|
+
try {
|
|
1173
|
+
response = await deps.fetchImpl(url, {
|
|
1174
|
+
method: "POST",
|
|
1175
|
+
headers: {
|
|
1176
|
+
"content-type": "application/json",
|
|
1177
|
+
...hmacHeaders
|
|
1178
|
+
},
|
|
1179
|
+
body,
|
|
1180
|
+
signal: AbortSignal.timeout(HTTP_TIMEOUT_MS)
|
|
1181
|
+
});
|
|
1182
|
+
} catch (err) {
|
|
1183
|
+
return toolErrorEnvelope(err);
|
|
1184
|
+
}
|
|
1185
|
+
let parsedBody;
|
|
1186
|
+
try {
|
|
1187
|
+
parsedBody = await response.json();
|
|
1188
|
+
} catch {
|
|
1189
|
+
const fallback = await response.text();
|
|
1190
|
+
return structuredError({
|
|
1191
|
+
code: "FEEDBACK_UNPARSEABLE_RESPONSE",
|
|
1192
|
+
message: sanitise(
|
|
1193
|
+
`Server returned non-JSON ${response.status}: ${fallback.slice(0, 512)}`
|
|
1194
|
+
)
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
if (!response.ok) {
|
|
1198
|
+
const errBody = parsedBody;
|
|
1199
|
+
return structuredError({
|
|
1200
|
+
code: errBody.code ?? `FEEDBACK_HTTP_${response.status}`,
|
|
1201
|
+
message: sanitise(errBody.error ?? `HTTP ${response.status}`),
|
|
1202
|
+
...errBody.feedbackId ? { feedbackId: errBody.feedbackId } : {}
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
const okBody = parsedBody;
|
|
1206
|
+
return structuredOk({
|
|
1207
|
+
feedbackId: okBody.feedbackId,
|
|
1208
|
+
txHash: okBody.txHash,
|
|
1209
|
+
publicUrl: okBody.publicUrl,
|
|
1210
|
+
// Help the agent surface a confirmation message.
|
|
1211
|
+
summary: okBody.txHash !== void 0 ? `Feedback submitted on-chain. Tx: ${okBody.txHash}` : "Feedback submitted"
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1126
1214
|
function buildMcpServer(options = {}) {
|
|
1127
1215
|
const deps = { ...defaultDeps(), ...options.deps };
|
|
1128
1216
|
const server = new McpServer({
|
|
@@ -1156,6 +1244,17 @@ function buildMcpServer(options = {}) {
|
|
|
1156
1244
|
},
|
|
1157
1245
|
async () => await withToolLogging("info", () => handleInfo(deps))
|
|
1158
1246
|
);
|
|
1247
|
+
server.registerTool(
|
|
1248
|
+
"feedback",
|
|
1249
|
+
{
|
|
1250
|
+
description: "Submit ERC-8004 ReputationRegistry feedback for a workflow execution this wallet paid for. Signs and broadcasts a giveFeedback() transaction on Ethereum mainnet via the KeeperHub server proxy. Caller wallet pays gas natively (~$0.05-2 per call at typical mainnet gas). Use AFTER call_workflow returns successfully and the user has confirmed they want to rate the workflow. The executionId comes from the call_workflow response. Defaults to rating KeeperHub's own ERC-8004 agent (id 31875 on Ethereum) but agentId/agentChainId may be overridden to rate any agent.",
|
|
1251
|
+
inputSchema: submitFeedbackInputSchema
|
|
1252
|
+
},
|
|
1253
|
+
async (args) => await withToolLogging(
|
|
1254
|
+
"feedback",
|
|
1255
|
+
() => handleSubmitFeedback(args, deps)
|
|
1256
|
+
)
|
|
1257
|
+
);
|
|
1159
1258
|
return server;
|
|
1160
1259
|
}
|
|
1161
1260
|
async function runMcpServer() {
|