@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/dist/index.cjs CHANGED
@@ -228,8 +228,36 @@ function fund(walletAddress) {
228
228
  };
229
229
  }
230
230
 
231
- // src/storage.ts
231
+ // src/hmac.ts
232
232
  var import_node_crypto = require("crypto");
233
+ function computeSignature(secret, method, path, subOrgId, body, timestamp) {
234
+ const bodyDigest = (0, import_node_crypto.createHash)("sha256").update(body).digest("hex");
235
+ const signingString = `${method}
236
+ ${path}
237
+ ${subOrgId}
238
+ ${bodyDigest}
239
+ ${timestamp}`;
240
+ return (0, import_node_crypto.createHmac)("sha256", secret).update(signingString).digest("hex");
241
+ }
242
+ function buildHmacHeaders(secret, method, path, subOrgId, body) {
243
+ const timestamp = String(Math.floor(Date.now() / 1e3));
244
+ const signature = computeSignature(
245
+ secret,
246
+ method,
247
+ path,
248
+ subOrgId,
249
+ body,
250
+ timestamp
251
+ );
252
+ return {
253
+ "X-KH-Sub-Org": subOrgId,
254
+ "X-KH-Timestamp": timestamp,
255
+ "X-KH-Signature": signature
256
+ };
257
+ }
258
+
259
+ // src/storage.ts
260
+ var import_node_crypto2 = require("crypto");
233
261
  var import_promises = require("fs/promises");
234
262
  var import_node_os2 = require("os");
235
263
  var import_node_path2 = require("path");
@@ -289,7 +317,7 @@ async function readWalletConfig() {
289
317
  async function writeWalletConfig(config) {
290
318
  const walletPath = (0, import_node_path2.join)((0, import_node_os2.homedir)(), ".keeperhub", "wallet.json");
291
319
  await (0, import_promises.mkdir)((0, import_node_path2.dirname)(walletPath), { recursive: true, mode: 448 });
292
- const suffix = (0, import_node_crypto.randomBytes)(8).toString("hex");
320
+ const suffix = (0, import_node_crypto2.randomBytes)(8).toString("hex");
293
321
  const tmpPath = `${walletPath}.${process.pid}.${suffix}.tmp`;
294
322
  await (0, import_promises.writeFile)(tmpPath, JSON.stringify(config, null, 2), { mode: 384 });
295
323
  await (0, import_promises.chmod)(tmpPath, 384);
@@ -370,13 +398,13 @@ async function provisionWallet(options = {}) {
370
398
  }
371
399
 
372
400
  // src/skill-install.ts
373
- var import_node_crypto3 = require("crypto");
401
+ var import_node_crypto4 = require("crypto");
374
402
  var import_promises3 = require("fs/promises");
375
403
  var import_node_path5 = require("path");
376
404
  var import_node_url2 = require("url");
377
405
 
378
406
  // src/mcp-register.ts
379
- var import_node_crypto2 = require("crypto");
407
+ var import_node_crypto3 = require("crypto");
380
408
  var import_promises2 = require("fs/promises");
381
409
  var import_node_os3 = require("os");
382
410
  var import_node_path4 = require("path");
@@ -511,7 +539,7 @@ async function readJsonOrEmpty(path) {
511
539
  }
512
540
  async function writeJsonAtomic(path, payload) {
513
541
  await (0, import_promises2.mkdir)((0, import_node_path4.dirname)(path), { recursive: true, mode: 448 });
514
- const suffix = (0, import_node_crypto2.randomBytes)(8).toString("hex");
542
+ const suffix = (0, import_node_crypto3.randomBytes)(8).toString("hex");
515
543
  const tmpPath = `${path}.${process.pid}.${suffix}.tmp`;
516
544
  try {
517
545
  await (0, import_promises2.writeFile)(tmpPath, payload, { mode: 384 });
@@ -642,7 +670,7 @@ async function registerClaudeCodeHook(settingsPath, options = {}) {
642
670
  await (0, import_promises3.mkdir)((0, import_node_path5.dirname)(settingsPath), { recursive: true, mode: 448 });
643
671
  const payload = `${JSON.stringify(config, null, 2)}
644
672
  `;
645
- const suffix = (0, import_node_crypto3.randomBytes)(8).toString("hex");
673
+ const suffix = (0, import_node_crypto4.randomBytes)(8).toString("hex");
646
674
  const tmpPath = `${settingsPath}.${process.pid}.${suffix}.tmp`;
647
675
  try {
648
676
  await (0, import_promises3.writeFile)(tmpPath, payload, { mode: 384 });
@@ -795,6 +823,58 @@ async function cmdInfo() {
795
823
  process.stdout.write(`walletAddress: ${wallet.walletAddress}
796
824
  `);
797
825
  }
826
+ var FEEDBACK_DEFAULT_BASE_URL = "https://app.keeperhub.com";
827
+ async function cmdFeedback(opts) {
828
+ const wallet = await readWalletConfig();
829
+ const baseUrl = (opts.baseUrl ?? FEEDBACK_DEFAULT_BASE_URL).replace(
830
+ /\/$/,
831
+ ""
832
+ );
833
+ const path = "/api/agentic-wallet/feedback";
834
+ const body = {
835
+ executionId: opts.executionId,
836
+ value: Number.parseInt(opts.value, 10),
837
+ valueDecimals: Number.parseInt(opts.decimals ?? "0", 10)
838
+ };
839
+ if (opts.comment !== void 0) {
840
+ body.comment = opts.comment;
841
+ }
842
+ if (opts.agentId !== void 0) {
843
+ body.agentId = opts.agentId;
844
+ }
845
+ if (opts.chainId !== void 0) {
846
+ body.agentChainId = Number.parseInt(opts.chainId, 10);
847
+ }
848
+ const bodyJson = JSON.stringify(body);
849
+ const headers = buildHmacHeaders(
850
+ wallet.hmacSecret,
851
+ "POST",
852
+ path,
853
+ wallet.subOrgId,
854
+ bodyJson
855
+ );
856
+ const response = await fetch(`${baseUrl}${path}`, {
857
+ method: "POST",
858
+ headers: {
859
+ "content-type": "application/json",
860
+ ...headers
861
+ },
862
+ body: bodyJson
863
+ });
864
+ const text = await response.text();
865
+ if (!response.ok) {
866
+ process.stderr.write(`HTTP ${response.status}: ${text}
867
+ `);
868
+ process.exit(1);
869
+ }
870
+ const parsed = JSON.parse(text);
871
+ process.stdout.write(`feedbackId: ${parsed.feedbackId ?? ""}
872
+ `);
873
+ process.stdout.write(`txHash: ${parsed.txHash ?? ""}
874
+ `);
875
+ process.stdout.write(`publicUrl: ${parsed.publicUrl ?? ""}
876
+ `);
877
+ }
798
878
  async function runCli(argv = process.argv) {
799
879
  const program = new import_commander.Command();
800
880
  program.name("keeperhub-wallet").description(
@@ -814,6 +894,27 @@ async function runCli(argv = process.argv) {
814
894
  program.command("info").description("Print subOrgId and walletAddress from local config").action(async () => {
815
895
  await cmdInfo();
816
896
  });
897
+ program.command("feedback").description(
898
+ "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."
899
+ ).requiredOption(
900
+ "--execution-id <id>",
901
+ "workflow execution id to leave feedback for"
902
+ ).requiredOption(
903
+ "--value <int>",
904
+ "raw int128 rating value (e.g. 5 with --decimals 0 for a 5-star rating)"
905
+ ).option(
906
+ "--decimals <int>",
907
+ "decimals for value (0..18); 0 for integer scores, 1 for 0.1-step",
908
+ "0"
909
+ ).option("--comment <text>", "optional plaintext comment").option(
910
+ "--agent-id <id>",
911
+ "rated agent NFT id (uint256 decimal); defaults to KeeperHub agent 31875"
912
+ ).option(
913
+ "--chain-id <int>",
914
+ "agent chain id; defaults to 1 (Ethereum mainnet, only chain supported today)"
915
+ ).option("--base-url <url>", "KeeperHub API base URL").action(async (opts) => {
916
+ await cmdFeedback(opts);
917
+ });
817
918
  program.command("skill").description(
818
919
  "Install the KeeperHub skill file into detected agent directories"
819
920
  ).addCommand(
@@ -886,34 +987,6 @@ async function runCli(argv = process.argv) {
886
987
  }
887
988
  }
888
989
 
889
- // src/hmac.ts
890
- var import_node_crypto4 = require("crypto");
891
- function computeSignature(secret, method, path, subOrgId, body, timestamp) {
892
- const bodyDigest = (0, import_node_crypto4.createHash)("sha256").update(body).digest("hex");
893
- const signingString = `${method}
894
- ${path}
895
- ${subOrgId}
896
- ${bodyDigest}
897
- ${timestamp}`;
898
- return (0, import_node_crypto4.createHmac)("sha256", secret).update(signingString).digest("hex");
899
- }
900
- function buildHmacHeaders(secret, method, path, subOrgId, body) {
901
- const timestamp = String(Math.floor(Date.now() / 1e3));
902
- const signature = computeSignature(
903
- secret,
904
- method,
905
- path,
906
- subOrgId,
907
- body,
908
- timestamp
909
- );
910
- return {
911
- "X-KH-Sub-Org": subOrgId,
912
- "X-KH-Timestamp": timestamp,
913
- "X-KH-Signature": signature
914
- };
915
- }
916
-
917
990
  // src/client.ts
918
991
  var TRAILING_SLASH2 = /\/$/;
919
992
  function defaultCodeForStatus(status) {