@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/index.js
CHANGED
|
@@ -178,6 +178,34 @@ function fund(walletAddress) {
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
// src/hmac.ts
|
|
182
|
+
import { createHash, createHmac } from "crypto";
|
|
183
|
+
function computeSignature(secret, method, path, subOrgId, body, timestamp) {
|
|
184
|
+
const bodyDigest = createHash("sha256").update(body).digest("hex");
|
|
185
|
+
const signingString = `${method}
|
|
186
|
+
${path}
|
|
187
|
+
${subOrgId}
|
|
188
|
+
${bodyDigest}
|
|
189
|
+
${timestamp}`;
|
|
190
|
+
return createHmac("sha256", secret).update(signingString).digest("hex");
|
|
191
|
+
}
|
|
192
|
+
function buildHmacHeaders(secret, method, path, subOrgId, body) {
|
|
193
|
+
const timestamp = String(Math.floor(Date.now() / 1e3));
|
|
194
|
+
const signature = computeSignature(
|
|
195
|
+
secret,
|
|
196
|
+
method,
|
|
197
|
+
path,
|
|
198
|
+
subOrgId,
|
|
199
|
+
body,
|
|
200
|
+
timestamp
|
|
201
|
+
);
|
|
202
|
+
return {
|
|
203
|
+
"X-KH-Sub-Org": subOrgId,
|
|
204
|
+
"X-KH-Timestamp": timestamp,
|
|
205
|
+
"X-KH-Signature": signature
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
181
209
|
// src/storage.ts
|
|
182
210
|
import { randomBytes } from "crypto";
|
|
183
211
|
import { chmod, mkdir, readFile, rename, writeFile } from "fs/promises";
|
|
@@ -760,6 +788,58 @@ async function cmdInfo() {
|
|
|
760
788
|
process.stdout.write(`walletAddress: ${wallet.walletAddress}
|
|
761
789
|
`);
|
|
762
790
|
}
|
|
791
|
+
var FEEDBACK_DEFAULT_BASE_URL = "https://app.keeperhub.com";
|
|
792
|
+
async function cmdFeedback(opts) {
|
|
793
|
+
const wallet = await readWalletConfig();
|
|
794
|
+
const baseUrl = (opts.baseUrl ?? FEEDBACK_DEFAULT_BASE_URL).replace(
|
|
795
|
+
/\/$/,
|
|
796
|
+
""
|
|
797
|
+
);
|
|
798
|
+
const path = "/api/agentic-wallet/feedback";
|
|
799
|
+
const body = {
|
|
800
|
+
executionId: opts.executionId,
|
|
801
|
+
value: Number.parseInt(opts.value, 10),
|
|
802
|
+
valueDecimals: Number.parseInt(opts.decimals ?? "0", 10)
|
|
803
|
+
};
|
|
804
|
+
if (opts.comment !== void 0) {
|
|
805
|
+
body.comment = opts.comment;
|
|
806
|
+
}
|
|
807
|
+
if (opts.agentId !== void 0) {
|
|
808
|
+
body.agentId = opts.agentId;
|
|
809
|
+
}
|
|
810
|
+
if (opts.chainId !== void 0) {
|
|
811
|
+
body.agentChainId = Number.parseInt(opts.chainId, 10);
|
|
812
|
+
}
|
|
813
|
+
const bodyJson = JSON.stringify(body);
|
|
814
|
+
const headers = buildHmacHeaders(
|
|
815
|
+
wallet.hmacSecret,
|
|
816
|
+
"POST",
|
|
817
|
+
path,
|
|
818
|
+
wallet.subOrgId,
|
|
819
|
+
bodyJson
|
|
820
|
+
);
|
|
821
|
+
const response = await fetch(`${baseUrl}${path}`, {
|
|
822
|
+
method: "POST",
|
|
823
|
+
headers: {
|
|
824
|
+
"content-type": "application/json",
|
|
825
|
+
...headers
|
|
826
|
+
},
|
|
827
|
+
body: bodyJson
|
|
828
|
+
});
|
|
829
|
+
const text = await response.text();
|
|
830
|
+
if (!response.ok) {
|
|
831
|
+
process.stderr.write(`HTTP ${response.status}: ${text}
|
|
832
|
+
`);
|
|
833
|
+
process.exit(1);
|
|
834
|
+
}
|
|
835
|
+
const parsed = JSON.parse(text);
|
|
836
|
+
process.stdout.write(`feedbackId: ${parsed.feedbackId ?? ""}
|
|
837
|
+
`);
|
|
838
|
+
process.stdout.write(`txHash: ${parsed.txHash ?? ""}
|
|
839
|
+
`);
|
|
840
|
+
process.stdout.write(`publicUrl: ${parsed.publicUrl ?? ""}
|
|
841
|
+
`);
|
|
842
|
+
}
|
|
763
843
|
async function runCli(argv = process.argv) {
|
|
764
844
|
const program = new Command();
|
|
765
845
|
program.name("keeperhub-wallet").description(
|
|
@@ -779,6 +859,27 @@ async function runCli(argv = process.argv) {
|
|
|
779
859
|
program.command("info").description("Print subOrgId and walletAddress from local config").action(async () => {
|
|
780
860
|
await cmdInfo();
|
|
781
861
|
});
|
|
862
|
+
program.command("feedback").description(
|
|
863
|
+
"Submit ERC-8004 ReputationRegistry feedback for a workflow execution this wallet paid for. Signs giveFeedback() via Turnkey and broadcasts on Ethereum mainnet. Caller wallet pays gas natively."
|
|
864
|
+
).requiredOption(
|
|
865
|
+
"--execution-id <id>",
|
|
866
|
+
"workflow execution id to leave feedback for"
|
|
867
|
+
).requiredOption(
|
|
868
|
+
"--value <int>",
|
|
869
|
+
"raw int128 rating value (e.g. 5 with --decimals 0 for a 5-star rating)"
|
|
870
|
+
).option(
|
|
871
|
+
"--decimals <int>",
|
|
872
|
+
"decimals for value (0..18); 0 for integer scores, 1 for 0.1-step",
|
|
873
|
+
"0"
|
|
874
|
+
).option("--comment <text>", "optional plaintext comment").option(
|
|
875
|
+
"--agent-id <id>",
|
|
876
|
+
"rated agent NFT id (uint256 decimal); defaults to KeeperHub agent 31875"
|
|
877
|
+
).option(
|
|
878
|
+
"--chain-id <int>",
|
|
879
|
+
"agent chain id; defaults to 1 (Ethereum mainnet, only chain supported today)"
|
|
880
|
+
).option("--base-url <url>", "KeeperHub API base URL").action(async (opts) => {
|
|
881
|
+
await cmdFeedback(opts);
|
|
882
|
+
});
|
|
782
883
|
program.command("skill").description(
|
|
783
884
|
"Install the KeeperHub skill file into detected agent directories"
|
|
784
885
|
).addCommand(
|
|
@@ -851,34 +952,6 @@ async function runCli(argv = process.argv) {
|
|
|
851
952
|
}
|
|
852
953
|
}
|
|
853
954
|
|
|
854
|
-
// src/hmac.ts
|
|
855
|
-
import { createHash, createHmac } from "crypto";
|
|
856
|
-
function computeSignature(secret, method, path, subOrgId, body, timestamp) {
|
|
857
|
-
const bodyDigest = createHash("sha256").update(body).digest("hex");
|
|
858
|
-
const signingString = `${method}
|
|
859
|
-
${path}
|
|
860
|
-
${subOrgId}
|
|
861
|
-
${bodyDigest}
|
|
862
|
-
${timestamp}`;
|
|
863
|
-
return createHmac("sha256", secret).update(signingString).digest("hex");
|
|
864
|
-
}
|
|
865
|
-
function buildHmacHeaders(secret, method, path, subOrgId, body) {
|
|
866
|
-
const timestamp = String(Math.floor(Date.now() / 1e3));
|
|
867
|
-
const signature = computeSignature(
|
|
868
|
-
secret,
|
|
869
|
-
method,
|
|
870
|
-
path,
|
|
871
|
-
subOrgId,
|
|
872
|
-
body,
|
|
873
|
-
timestamp
|
|
874
|
-
);
|
|
875
|
-
return {
|
|
876
|
-
"X-KH-Sub-Org": subOrgId,
|
|
877
|
-
"X-KH-Timestamp": timestamp,
|
|
878
|
-
"X-KH-Signature": signature
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
|
|
882
955
|
// src/client.ts
|
|
883
956
|
var TRAILING_SLASH2 = /\/$/;
|
|
884
957
|
function defaultCodeForStatus(status) {
|