@agent-fuel/sdk 0.3.0 → 0.3.2

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,18 @@
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.2] — 2026-05-31
6
+
7
+ ### Changed
8
+
9
+ - `pay()` now bundles `compute_score` as a third instruction in the same atomic transaction. Without this, every paying agent's `agent_profile.score` stayed at its initial value until someone manually invoked `compute_score` — and nothing in the codebase did. The backend mirrors `agents.score` from `ScoreComputed` events only, so the displayed score was effectively stuck at 0 for the entire lifetime of any agent using the SDK's high-level helper. Adding the instruction inside the same tx means the score reflects the freshly-incremented counters with no extra round-trip and no race window where the spend lands but the score-update tx is lost.
10
+
11
+ ## [0.3.1] — 2026-05-31
12
+
13
+ ### Changed
14
+
15
+ - 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`.
16
+
5
17
  ## [0.3.0] — 2026-05-31
6
18
 
7
19
  ### Added
package/dist/cli.cjs CHANGED
@@ -3834,9 +3834,16 @@ async function pay(args) {
3834
3834
  receiptUsed: receipt,
3835
3835
  systemProgram: web3_js.SystemProgram.programId
3836
3836
  });
3837
- const spendIx = await spendBuilder.instruction();
3838
- const recordIx = await recordBuilder.instruction();
3839
- const tx = new web3_js.Transaction().add(createAtaIx, spendIx, recordIx);
3837
+ const computeBuilder = rep.methods.computeScore().accounts({
3838
+ caller: agent.publicKey,
3839
+ agentProfile
3840
+ });
3841
+ const [spendIx, recordIx, computeIx] = await Promise.all([
3842
+ spendBuilder.instruction(),
3843
+ recordBuilder.instruction(),
3844
+ computeBuilder.instruction()
3845
+ ]);
3846
+ const tx = new web3_js.Transaction().add(createAtaIx, spendIx, recordIx, computeIx);
3840
3847
  try {
3841
3848
  const signature = await web3_js.sendAndConfirmTransaction(
3842
3849
  connection,
@@ -4163,7 +4170,7 @@ async function safeText(res) {
4163
4170
  }
4164
4171
 
4165
4172
  // src/cli.ts
4166
- var VERSION = "0.3.0";
4173
+ var VERSION = "0.3.2";
4167
4174
  var RPC_DEFAULTS = {
4168
4175
  "mainnet-beta": "https://api.mainnet-beta.solana.com",
4169
4176
  devnet: "https://api.devnet.solana.com",
@@ -4281,6 +4288,16 @@ function jsonReplacer(_key, value) {
4281
4288
  function errMsg(e) {
4282
4289
  return e instanceof Error ? e.message : String(e);
4283
4290
  }
4291
+ async function rephraseNotFound(fn, reword) {
4292
+ try {
4293
+ return await fn();
4294
+ } catch (e) {
4295
+ if (e instanceof AccountNotFoundError) {
4296
+ throw new Error(reword(e.account));
4297
+ }
4298
+ throw e;
4299
+ }
4300
+ }
4284
4301
  function explorerUrl(cluster, sig) {
4285
4302
  const suffix = cluster === "mainnet-beta" ? "" : `?cluster=${cluster}`;
4286
4303
  return `https://explorer.solana.com/tx/${sig}${suffix}`;
@@ -4299,7 +4316,10 @@ program.command("score <agent>").description("Show the latest reputation snapsho
4299
4316
  const g = readGlobalOpts(cmd);
4300
4317
  const agentPk = parsePubkey(agent, "<agent>");
4301
4318
  const fuel = readOnlyFuel(g);
4302
- const score = await fuel.getScore(agentPk);
4319
+ const score = await rephraseNotFound(
4320
+ () => fuel.getScore(agentPk),
4321
+ () => `no reputation data yet for agent ${agent} \u2014 the backend has no AgentProfile mirror for this agent (it hasn't received any recorded payments)`
4322
+ );
4303
4323
  emit(g, () => formatScore(score), score);
4304
4324
  });
4305
4325
  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 +4327,10 @@ program.command("vault <owner> <agent>").description("Show on-chain credit vault
4307
4327
  const ownerPk = parsePubkey(owner, "<owner>");
4308
4328
  const agentPk = parsePubkey(agent, "<agent>");
4309
4329
  const fuel = readOnlyFuel(g);
4310
- const vault = await fuel.getVaultBalance({ owner: ownerPk, agent: agentPk });
4330
+ const vault = await rephraseNotFound(
4331
+ () => fuel.getVaultBalance({ owner: ownerPk, agent: agentPk }),
4332
+ (pda) => `no vault found at ${pda} for owner=${owner} agent=${agent} \u2014 has init_vault been called for this pair?`
4333
+ );
4311
4334
  emit(g, () => formatVault(vault), vault);
4312
4335
  });
4313
4336
  program.command("policy <owner> <agent>").description("Show the spend policy guarding an (owner, agent) vault.").action(async (owner, agent, _opts, cmd) => {
@@ -4315,14 +4338,20 @@ program.command("policy <owner> <agent>").description("Show the spend policy gua
4315
4338
  const ownerPk = parsePubkey(owner, "<owner>");
4316
4339
  const agentPk = parsePubkey(agent, "<agent>");
4317
4340
  const fuel = readOnlyFuel(g);
4318
- const policy = await fuel.getPolicy({ owner: ownerPk, agent: agentPk });
4341
+ const policy = await rephraseNotFound(
4342
+ () => fuel.getPolicy({ owner: ownerPk, agent: agentPk }),
4343
+ (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`
4344
+ );
4319
4345
  emit(g, () => formatPolicy(policy), policy);
4320
4346
  });
4321
4347
  program.command("service <authority>").description("Look up a registered service by its authority pubkey.").action(async (authority, _opts, cmd) => {
4322
4348
  const g = readGlobalOpts(cmd);
4323
4349
  const authPk = parsePubkey(authority, "<authority>");
4324
4350
  const fuel = readOnlyFuel(g);
4325
- const svc = await fuel.checkService(authPk);
4351
+ const svc = await rephraseNotFound(
4352
+ () => fuel.checkService(authPk),
4353
+ (pda) => `no service registered for authority ${authority} (registry PDA ${pda} doesn't exist) \u2014 run \`agent-fuel register-service\` to create one`
4354
+ );
4326
4355
  emit(g, () => formatService(svc), svc);
4327
4356
  });
4328
4357
  program.command("pay").description(
@@ -4338,14 +4367,17 @@ program.command("pay").description(
4338
4367
  const owner = parsePubkey(opts.owner, "--owner");
4339
4368
  const amountUsdc = parseAmountToMicro(opts.amount);
4340
4369
  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
- });
4370
+ const result = await rephraseNotFound(
4371
+ () => pay({
4372
+ agent,
4373
+ service,
4374
+ owner,
4375
+ amountUsdc,
4376
+ receiptHash,
4377
+ connection: connectionFor(g)
4378
+ }),
4379
+ (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.`
4380
+ );
4349
4381
  emit(
4350
4382
  g,
4351
4383
  () => [