@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.cjs
CHANGED
|
@@ -118,26 +118,6 @@ function fund(walletAddress) {
|
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
// src/mpp-detect.ts
|
|
122
|
-
var MPP_PREFIX = "Payment ";
|
|
123
|
-
function parseMppChallenge(response) {
|
|
124
|
-
const header = response.headers.get("WWW-Authenticate");
|
|
125
|
-
if (!header) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
if (!header.startsWith(MPP_PREFIX)) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
const serialized = header.slice(MPP_PREFIX.length).trim();
|
|
132
|
-
if (serialized.length === 0) {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
return { serialized };
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/payment-signer.ts
|
|
139
|
-
var import_node_crypto3 = require("crypto");
|
|
140
|
-
|
|
141
121
|
// src/hmac.ts
|
|
142
122
|
var import_node_crypto = require("crypto");
|
|
143
123
|
function computeSignature(secret, method, path, subOrgId, body, timestamp) {
|
|
@@ -166,6 +146,26 @@ function buildHmacHeaders(secret, method, path, subOrgId, body) {
|
|
|
166
146
|
};
|
|
167
147
|
}
|
|
168
148
|
|
|
149
|
+
// src/mpp-detect.ts
|
|
150
|
+
var MPP_PREFIX = "Payment ";
|
|
151
|
+
function parseMppChallenge(response) {
|
|
152
|
+
const header = response.headers.get("WWW-Authenticate");
|
|
153
|
+
if (!header) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
if (!header.startsWith(MPP_PREFIX)) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const serialized = header.slice(MPP_PREFIX.length).trim();
|
|
160
|
+
if (serialized.length === 0) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return { serialized };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/payment-signer.ts
|
|
167
|
+
var import_node_crypto3 = require("crypto");
|
|
168
|
+
|
|
169
169
|
// src/types.ts
|
|
170
170
|
var KeeperHubError = class extends Error {
|
|
171
171
|
code;
|
|
@@ -1144,6 +1144,94 @@ async function handleInfo(deps) {
|
|
|
1144
1144
|
} : {}
|
|
1145
1145
|
});
|
|
1146
1146
|
}
|
|
1147
|
+
var submitFeedbackInputSchema = {
|
|
1148
|
+
executionId: import_zod.z.string().min(1).describe(
|
|
1149
|
+
"Workflow execution id returned in the `executionId` field of a previous successful call_workflow response."
|
|
1150
|
+
),
|
|
1151
|
+
value: import_zod.z.number().int().describe(
|
|
1152
|
+
"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."
|
|
1153
|
+
),
|
|
1154
|
+
valueDecimals: import_zod.z.number().int().min(0).max(18).describe(
|
|
1155
|
+
"Decimals for value. Use 0 for an integer 1-5 score, 1 for a 0.1-step 0-50 score, etc."
|
|
1156
|
+
),
|
|
1157
|
+
comment: import_zod.z.string().max(2e3).optional().describe(
|
|
1158
|
+
"Optional plain-text comment included in the feedbackURI JSON."
|
|
1159
|
+
),
|
|
1160
|
+
agentChainId: import_zod.z.number().int().optional().describe(
|
|
1161
|
+
"Chain id where the rated agent NFT lives. Defaults to 1 (Ethereum mainnet); only 1 is supported today."
|
|
1162
|
+
),
|
|
1163
|
+
agentId: import_zod.z.string().optional().describe(
|
|
1164
|
+
"Rated agent NFT id (uint256, decimal string). Defaults to KeeperHub's own ERC-8004 agent (31875)."
|
|
1165
|
+
)
|
|
1166
|
+
};
|
|
1167
|
+
async function handleSubmitFeedback(args, deps) {
|
|
1168
|
+
let ensured;
|
|
1169
|
+
try {
|
|
1170
|
+
ensured = await ensureWallet(deps);
|
|
1171
|
+
} catch (err) {
|
|
1172
|
+
return toolErrorEnvelope(err);
|
|
1173
|
+
}
|
|
1174
|
+
const baseUrl = resolveKeeperhubBaseUrl();
|
|
1175
|
+
const path = "/api/agentic-wallet/feedback";
|
|
1176
|
+
const url = `${baseUrl}${path}`;
|
|
1177
|
+
const body = JSON.stringify({
|
|
1178
|
+
executionId: args.executionId,
|
|
1179
|
+
value: args.value,
|
|
1180
|
+
valueDecimals: args.valueDecimals,
|
|
1181
|
+
...args.comment !== void 0 ? { comment: args.comment } : {},
|
|
1182
|
+
...args.agentChainId !== void 0 ? { agentChainId: args.agentChainId } : {},
|
|
1183
|
+
...args.agentId !== void 0 ? { agentId: args.agentId } : {}
|
|
1184
|
+
});
|
|
1185
|
+
const hmacHeaders = buildHmacHeaders(
|
|
1186
|
+
ensured.hmacSecret,
|
|
1187
|
+
"POST",
|
|
1188
|
+
path,
|
|
1189
|
+
ensured.subOrgId,
|
|
1190
|
+
body
|
|
1191
|
+
);
|
|
1192
|
+
let response;
|
|
1193
|
+
try {
|
|
1194
|
+
response = await deps.fetchImpl(url, {
|
|
1195
|
+
method: "POST",
|
|
1196
|
+
headers: {
|
|
1197
|
+
"content-type": "application/json",
|
|
1198
|
+
...hmacHeaders
|
|
1199
|
+
},
|
|
1200
|
+
body,
|
|
1201
|
+
signal: AbortSignal.timeout(HTTP_TIMEOUT_MS)
|
|
1202
|
+
});
|
|
1203
|
+
} catch (err) {
|
|
1204
|
+
return toolErrorEnvelope(err);
|
|
1205
|
+
}
|
|
1206
|
+
let parsedBody;
|
|
1207
|
+
try {
|
|
1208
|
+
parsedBody = await response.json();
|
|
1209
|
+
} catch {
|
|
1210
|
+
const fallback = await response.text();
|
|
1211
|
+
return structuredError({
|
|
1212
|
+
code: "FEEDBACK_UNPARSEABLE_RESPONSE",
|
|
1213
|
+
message: sanitise(
|
|
1214
|
+
`Server returned non-JSON ${response.status}: ${fallback.slice(0, 512)}`
|
|
1215
|
+
)
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
if (!response.ok) {
|
|
1219
|
+
const errBody = parsedBody;
|
|
1220
|
+
return structuredError({
|
|
1221
|
+
code: errBody.code ?? `FEEDBACK_HTTP_${response.status}`,
|
|
1222
|
+
message: sanitise(errBody.error ?? `HTTP ${response.status}`),
|
|
1223
|
+
...errBody.feedbackId ? { feedbackId: errBody.feedbackId } : {}
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
const okBody = parsedBody;
|
|
1227
|
+
return structuredOk({
|
|
1228
|
+
feedbackId: okBody.feedbackId,
|
|
1229
|
+
txHash: okBody.txHash,
|
|
1230
|
+
publicUrl: okBody.publicUrl,
|
|
1231
|
+
// Help the agent surface a confirmation message.
|
|
1232
|
+
summary: okBody.txHash !== void 0 ? `Feedback submitted on-chain. Tx: ${okBody.txHash}` : "Feedback submitted"
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1147
1235
|
function buildMcpServer(options = {}) {
|
|
1148
1236
|
const deps = { ...defaultDeps(), ...options.deps };
|
|
1149
1237
|
const server = new import_mcp.McpServer({
|
|
@@ -1177,6 +1265,17 @@ function buildMcpServer(options = {}) {
|
|
|
1177
1265
|
},
|
|
1178
1266
|
async () => await withToolLogging("info", () => handleInfo(deps))
|
|
1179
1267
|
);
|
|
1268
|
+
server.registerTool(
|
|
1269
|
+
"feedback",
|
|
1270
|
+
{
|
|
1271
|
+
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.",
|
|
1272
|
+
inputSchema: submitFeedbackInputSchema
|
|
1273
|
+
},
|
|
1274
|
+
async (args) => await withToolLogging(
|
|
1275
|
+
"feedback",
|
|
1276
|
+
() => handleSubmitFeedback(args, deps)
|
|
1277
|
+
)
|
|
1278
|
+
);
|
|
1180
1279
|
return server;
|
|
1181
1280
|
}
|
|
1182
1281
|
async function runMcpServer() {
|