@agent-fuel/sdk 0.3.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to `@agent-fuel/sdk` are documented here. Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this package follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## [0.3.1] — 2026-05-31
6
+
7
+ ### Changed
8
+
9
+ - CLI: replace the generic `account not found: <PDA>` with command-specific messages that name the missing resource and the inputs that produced the lookup. `agent-fuel vault Cowi… 5ro8…` now reports `no vault found at <PDA> for owner=Cowi… agent=5ro8… — has init_vault been called for this pair?` instead of dumping a raw PDA the user has no way to map back. Applies to `score`, `vault`, `policy`, `service`, and `pay`.
10
+
5
11
  ## [0.3.0] — 2026-05-31
6
12
 
7
13
  ### Added
package/dist/cli.cjs CHANGED
@@ -4163,7 +4163,7 @@ async function safeText(res) {
4163
4163
  }
4164
4164
 
4165
4165
  // src/cli.ts
4166
- var VERSION = "0.3.0";
4166
+ var VERSION = "0.3.1";
4167
4167
  var RPC_DEFAULTS = {
4168
4168
  "mainnet-beta": "https://api.mainnet-beta.solana.com",
4169
4169
  devnet: "https://api.devnet.solana.com",
@@ -4281,6 +4281,16 @@ function jsonReplacer(_key, value) {
4281
4281
  function errMsg(e) {
4282
4282
  return e instanceof Error ? e.message : String(e);
4283
4283
  }
4284
+ async function rephraseNotFound(fn, reword) {
4285
+ try {
4286
+ return await fn();
4287
+ } catch (e) {
4288
+ if (e instanceof AccountNotFoundError) {
4289
+ throw new Error(reword(e.account));
4290
+ }
4291
+ throw e;
4292
+ }
4293
+ }
4284
4294
  function explorerUrl(cluster, sig) {
4285
4295
  const suffix = cluster === "mainnet-beta" ? "" : `?cluster=${cluster}`;
4286
4296
  return `https://explorer.solana.com/tx/${sig}${suffix}`;
@@ -4299,7 +4309,10 @@ program.command("score <agent>").description("Show the latest reputation snapsho
4299
4309
  const g = readGlobalOpts(cmd);
4300
4310
  const agentPk = parsePubkey(agent, "<agent>");
4301
4311
  const fuel = readOnlyFuel(g);
4302
- const score = await fuel.getScore(agentPk);
4312
+ const score = await rephraseNotFound(
4313
+ () => fuel.getScore(agentPk),
4314
+ () => `no reputation data yet for agent ${agent} \u2014 the backend has no AgentProfile mirror for this agent (it hasn't received any recorded payments)`
4315
+ );
4303
4316
  emit(g, () => formatScore(score), score);
4304
4317
  });
4305
4318
  program.command("vault <owner> <agent>").description("Show on-chain credit vault state for the (owner, agent) pair.").action(async (owner, agent, _opts, cmd) => {
@@ -4307,7 +4320,10 @@ program.command("vault <owner> <agent>").description("Show on-chain credit vault
4307
4320
  const ownerPk = parsePubkey(owner, "<owner>");
4308
4321
  const agentPk = parsePubkey(agent, "<agent>");
4309
4322
  const fuel = readOnlyFuel(g);
4310
- const vault = await fuel.getVaultBalance({ owner: ownerPk, agent: agentPk });
4323
+ const vault = await rephraseNotFound(
4324
+ () => fuel.getVaultBalance({ owner: ownerPk, agent: agentPk }),
4325
+ (pda) => `no vault found at ${pda} for owner=${owner} agent=${agent} \u2014 has init_vault been called for this pair?`
4326
+ );
4311
4327
  emit(g, () => formatVault(vault), vault);
4312
4328
  });
4313
4329
  program.command("policy <owner> <agent>").description("Show the spend policy guarding an (owner, agent) vault.").action(async (owner, agent, _opts, cmd) => {
@@ -4315,14 +4331,20 @@ program.command("policy <owner> <agent>").description("Show the spend policy gua
4315
4331
  const ownerPk = parsePubkey(owner, "<owner>");
4316
4332
  const agentPk = parsePubkey(agent, "<agent>");
4317
4333
  const fuel = readOnlyFuel(g);
4318
- const policy = await fuel.getPolicy({ owner: ownerPk, agent: agentPk });
4334
+ const policy = await rephraseNotFound(
4335
+ () => fuel.getPolicy({ owner: ownerPk, agent: agentPk }),
4336
+ (pda) => `no spend policy found at ${pda} for owner=${owner} agent=${agent} \u2014 policy is created alongside the vault, so this usually means init_vault hasn't been called`
4337
+ );
4319
4338
  emit(g, () => formatPolicy(policy), policy);
4320
4339
  });
4321
4340
  program.command("service <authority>").description("Look up a registered service by its authority pubkey.").action(async (authority, _opts, cmd) => {
4322
4341
  const g = readGlobalOpts(cmd);
4323
4342
  const authPk = parsePubkey(authority, "<authority>");
4324
4343
  const fuel = readOnlyFuel(g);
4325
- const svc = await fuel.checkService(authPk);
4344
+ const svc = await rephraseNotFound(
4345
+ () => fuel.checkService(authPk),
4346
+ (pda) => `no service registered for authority ${authority} (registry PDA ${pda} doesn't exist) \u2014 run \`agent-fuel register-service\` to create one`
4347
+ );
4326
4348
  emit(g, () => formatService(svc), svc);
4327
4349
  });
4328
4350
  program.command("pay").description(
@@ -4338,14 +4360,17 @@ program.command("pay").description(
4338
4360
  const owner = parsePubkey(opts.owner, "--owner");
4339
4361
  const amountUsdc = parseAmountToMicro(opts.amount);
4340
4362
  const receiptHash = parseReceiptHash(opts.receiptHash);
4341
- const result = await pay({
4342
- agent,
4343
- service,
4344
- owner,
4345
- amountUsdc,
4346
- receiptHash,
4347
- connection: connectionFor(g)
4348
- });
4363
+ const result = await rephraseNotFound(
4364
+ () => pay({
4365
+ agent,
4366
+ service,
4367
+ owner,
4368
+ amountUsdc,
4369
+ receiptHash,
4370
+ connection: connectionFor(g)
4371
+ }),
4372
+ (pda) => `pay failed: account not found at ${pda} \u2014 either the vault for owner=${opts.owner} agent=${agent.publicKey.toBase58()} doesn't exist, or the spend policy hasn't been created. Try \`agent-fuel vault ${opts.owner} ${agent.publicKey.toBase58()}\` to verify.`
4373
+ );
4349
4374
  emit(
4350
4375
  g,
4351
4376
  () => [