@agentgates/cli 0.9.0 → 0.10.0

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +466 -144
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -29086,10 +29086,10 @@ Message: ${transactionMessage}.
29086
29086
  return (requests) => {
29087
29087
  return new Promise((resolve, reject) => {
29088
29088
  if (requests.length === 0) resolve([]);
29089
- const batch = requests.map((params) => {
29089
+ const batch2 = requests.map((params) => {
29090
29090
  return client.request(params.methodName, params.args);
29091
29091
  });
29092
- client.request(batch, (err, response) => {
29092
+ client.request(batch2, (err, response) => {
29093
29093
  if (err) {
29094
29094
  reject(err);
29095
29095
  return;
@@ -30963,14 +30963,14 @@ Message: ${transactionMessage}.
30963
30963
  commitment,
30964
30964
  config
30965
30965
  } = extractCommitmentFromConfig(commitmentOrConfig);
30966
- const batch = signatures.map((signature2) => {
30966
+ const batch2 = signatures.map((signature2) => {
30967
30967
  const args = this._buildArgsAtLeastConfirmed([signature2], commitment, "jsonParsed", config);
30968
30968
  return {
30969
30969
  methodName: "getTransaction",
30970
30970
  args
30971
30971
  };
30972
30972
  });
30973
- const unsafeRes = await this._rpcBatchRequest(batch);
30973
+ const unsafeRes = await this._rpcBatchRequest(batch2);
30974
30974
  const res = unsafeRes.map((unsafeRes2) => {
30975
30975
  const res2 = superstruct.create(unsafeRes2, GetParsedTransactionRpcResult);
30976
30976
  if ("error" in res2) {
@@ -31005,14 +31005,14 @@ Message: ${transactionMessage}.
31005
31005
  commitment,
31006
31006
  config
31007
31007
  } = extractCommitmentFromConfig(commitmentOrConfig);
31008
- const batch = signatures.map((signature2) => {
31008
+ const batch2 = signatures.map((signature2) => {
31009
31009
  const args = this._buildArgsAtLeastConfirmed([signature2], commitment, void 0, config);
31010
31010
  return {
31011
31011
  methodName: "getTransaction",
31012
31012
  args
31013
31013
  };
31014
31014
  });
31015
- const unsafeRes = await this._rpcBatchRequest(batch);
31015
+ const unsafeRes = await this._rpcBatchRequest(batch2);
31016
31016
  const res = unsafeRes.map((unsafeRes2) => {
31017
31017
  const res2 = superstruct.create(unsafeRes2, GetTransactionRpcResult);
31018
31018
  if ("error" in res2) {
@@ -31169,14 +31169,14 @@ Message: ${transactionMessage}.
31169
31169
  * @deprecated Deprecated since RPC v1.7.0. Please use {@link getParsedTransactions} instead.
31170
31170
  */
31171
31171
  async getParsedConfirmedTransactions(signatures, commitment) {
31172
- const batch = signatures.map((signature2) => {
31172
+ const batch2 = signatures.map((signature2) => {
31173
31173
  const args = this._buildArgsAtLeastConfirmed([signature2], commitment, "jsonParsed");
31174
31174
  return {
31175
31175
  methodName: "getTransaction",
31176
31176
  args
31177
31177
  };
31178
31178
  });
31179
- const unsafeRes = await this._rpcBatchRequest(batch);
31179
+ const unsafeRes = await this._rpcBatchRequest(batch2);
31180
31180
  const res = unsafeRes.map((unsafeRes2) => {
31181
31181
  const res2 = superstruct.create(unsafeRes2, GetParsedTransactionRpcResult);
31182
31182
  if ("error" in res2) {
@@ -34297,7 +34297,7 @@ var require_package = __commonJS({
34297
34297
  "package.json"(exports, module) {
34298
34298
  module.exports = {
34299
34299
  name: "@agentgates/cli",
34300
- version: "0.9.0",
34300
+ version: "0.10.0",
34301
34301
  description: "Wallet operations for AI agents and humans",
34302
34302
  keywords: [
34303
34303
  "crypto",
@@ -34373,7 +34373,7 @@ var {
34373
34373
  } = import_index.default;
34374
34374
 
34375
34375
  // src/main.ts
34376
- var import_picocolors20 = __toESM(require_picocolors(), 1);
34376
+ var import_picocolors22 = __toESM(require_picocolors(), 1);
34377
34377
 
34378
34378
  // src/commands/login.ts
34379
34379
  var import_picocolors2 = __toESM(require_picocolors(), 1);
@@ -36625,6 +36625,17 @@ function describeStatus2(s) {
36625
36625
  return s;
36626
36626
  }
36627
36627
  }
36628
+ async function fetchTerminalDetail(intentId, profile) {
36629
+ try {
36630
+ return await apiFetch(`/api/intents/${intentId}/status`, {
36631
+ method: "GET",
36632
+ bearer: profile.bearer,
36633
+ origin: profile.mcpOrigin
36634
+ });
36635
+ } catch {
36636
+ return null;
36637
+ }
36638
+ }
36628
36639
  async function runIntentFlow(opts) {
36629
36640
  let activeProfile = opts.initialProfile;
36630
36641
  let proposed;
@@ -36844,6 +36855,13 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
36844
36855
  }
36845
36856
  }
36846
36857
  const explorer = final.tx_hash != null ? explorerUrl3(final.chain_id, final.tx_hash) : null;
36858
+ const detail = await fetchTerminalDetail(final.approval_id, activeProfile);
36859
+ const failure = detail?.failure;
36860
+ const legs = detail?.kind === "batch" ? detail.legs ?? [] : [];
36861
+ const retryCommand = failure?.retry_slippage_bps != null && opts.buildRetryCommand ? opts.buildRetryCommand({
36862
+ retryBps: failure.retry_slippage_bps,
36863
+ needsOverride: failure.needs_loss_override === true
36864
+ }) : null;
36847
36865
  if (opts.jsonMode) {
36848
36866
  emitNdjson2({
36849
36867
  ok: final.status === "mined",
@@ -36851,11 +36869,33 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
36851
36869
  intent_id: final.approval_id,
36852
36870
  tx_hash: final.tx_hash,
36853
36871
  explorer_url: explorer,
36854
- chain_id: final.chain_id
36872
+ chain_id: final.chain_id,
36873
+ ...failure ? { failure } : {},
36874
+ ...retryCommand ? { retry_command: retryCommand } : {},
36875
+ ...legs.length > 0 ? {
36876
+ kind: "batch",
36877
+ legs: legs.map((l) => ({
36878
+ index: l.index,
36879
+ intent_id: l.intent_id,
36880
+ status: l.status,
36881
+ tx_hash: l.tx_hash,
36882
+ explorer_url: l.tx_hash != null ? explorerUrl3(l.chain_id, l.tx_hash) : null,
36883
+ ...l.failure?.message ? { failure_message: l.failure.message } : {}
36884
+ }))
36885
+ } : {}
36855
36886
  });
36856
36887
  process.exit(final.status === "mined" ? 0 : 1);
36857
36888
  }
36858
36889
  process.stdout.write("\n");
36890
+ const printLegJournal = () => {
36891
+ if (legs.length === 0) return;
36892
+ process.stdout.write(import_picocolors9.default.bold(" Legs:\n"));
36893
+ for (const l of legs) {
36894
+ const line = l.status === "mined" ? import_picocolors9.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors9.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors9.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors9.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors9.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
36895
+ process.stdout.write(` ${line}
36896
+ `);
36897
+ }
36898
+ };
36859
36899
  if (final.status === "mined") {
36860
36900
  process.stdout.write(import_picocolors9.default.green("\u2713 Mined.") + "\n");
36861
36901
  if (final.tx_hash) {
@@ -36866,11 +36906,24 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
36866
36906
  process.stdout.write(` Explorer ${import_picocolors9.default.cyan(explorer)}
36867
36907
  `);
36868
36908
  }
36909
+ printLegJournal();
36869
36910
  process.exit(0);
36870
36911
  }
36871
- const label = final.status === "rejected" ? "Rejected by user" : final.status === "expired" ? "Expired (TTL elapsed before approval)" : final.status === "failed" ? "Broadcast failed" : `Ended in unexpected status: ${final.status}`;
36912
+ if (final.status === "failed" && failure?.message) {
36913
+ process.stderr.write(import_picocolors9.default.red(`\u2715 ${failure.message}
36914
+ `));
36915
+ if (retryCommand) {
36916
+ process.stderr.write(` Retry:
36917
+ ${import_picocolors9.default.cyan(retryCommand)}
36918
+ `);
36919
+ }
36920
+ printLegJournal();
36921
+ process.exit(1);
36922
+ }
36923
+ const label = final.status === "rejected" ? "Rejected by user" : final.status === "expired" ? "Expired (TTL elapsed before approval)" : final.status === "failed" ? "The transaction did not land; nothing moved. Re-run the command to retry with fresh parameters" : `Ended in unexpected status: ${final.status}`;
36872
36924
  process.stderr.write(import_picocolors9.default.red(`\u2715 ${label}.
36873
36925
  `));
36926
+ printLegJournal();
36874
36927
  process.exit(1);
36875
36928
  }
36876
36929
  function resolveBrowserDefault(browserMode) {
@@ -36881,6 +36934,8 @@ function resolveBrowserDefault(browserMode) {
36881
36934
  }
36882
36935
 
36883
36936
  // src/commands/swap.ts
36937
+ var SLIPPAGE_WALL_BPS = 100;
36938
+ var MAX_LOSS_CEILING_BPS = 1e3;
36884
36939
  var ASSET_VALUES = /* @__PURE__ */ new Set(["native", "usdc"]);
36885
36940
  function isAsset(v) {
36886
36941
  return ASSET_VALUES.has(v.toLowerCase());
@@ -36948,11 +37003,34 @@ async function swap(amount, fromAsset, opts) {
36948
37003
  let slippageBps;
36949
37004
  if (opts.slippageBps !== void 0) {
36950
37005
  const n = Number(opts.slippageBps);
36951
- if (!Number.isFinite(n) || !Number.isInteger(n) || n < 1 || n > 1e3) {
36952
- failArg(`--slippage-bps must be an integer 1-1000 (got ${opts.slippageBps}).`);
37006
+ if (!Number.isFinite(n) || !Number.isInteger(n) || n < 1) {
37007
+ failArg(`--slippage-bps must be a positive integer (got ${opts.slippageBps}).`);
37008
+ }
37009
+ if (n > SLIPPAGE_WALL_BPS) {
37010
+ failArg(
37011
+ `--slippage-bps ${n} is above the 1% loss wall (max ${SLIPPAGE_WALL_BPS}). Slippage is a loss bound \u2014 use ${SLIPPAGE_WALL_BPS} or less; to accept a bigger loss on this one swap (last resort), pass --max-loss-bps ${n} instead.`
37012
+ );
36953
37013
  }
36954
37014
  slippageBps = n;
36955
37015
  }
37016
+ let maxLossBps;
37017
+ if (opts.maxLossBps !== void 0) {
37018
+ const n = Number(opts.maxLossBps);
37019
+ if (!Number.isFinite(n) || !Number.isInteger(n)) {
37020
+ failArg(`--max-loss-bps must be an integer (got ${opts.maxLossBps}).`);
37021
+ }
37022
+ if (n <= SLIPPAGE_WALL_BPS) {
37023
+ failArg(
37024
+ `--max-loss-bps is the last-resort override ABOVE the 1% wall. For ${n} bps just use --slippage-bps ${n}.`
37025
+ );
37026
+ }
37027
+ if (n > MAX_LOSS_CEILING_BPS) {
37028
+ failArg(
37029
+ `--max-loss-bps ${n} is above the absolute ceiling (${MAX_LOSS_CEILING_BPS} bps = 10%). No larger loss can be authorized.`
37030
+ );
37031
+ }
37032
+ maxLossBps = n;
37033
+ }
36956
37034
  let maxUsdNumber;
36957
37035
  if (opts.maxUsd !== void 0) {
36958
37036
  const n = Number(opts.maxUsd);
@@ -36987,23 +37065,206 @@ async function swap(amount, fromAsset, opts) {
36987
37065
  if (slippageBps !== void 0) {
36988
37066
  proposeBody.slippage_bps = slippageBps;
36989
37067
  }
37068
+ if (maxLossBps !== void 0) {
37069
+ proposeBody.max_loss_bps = maxLossBps;
37070
+ }
36990
37071
  const shouldOpenBrowser = resolveBrowserDefault(opts.browserMode ?? "auto");
37072
+ const quoteArg = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
37073
+ const buildRetryCommand = ({
37074
+ retryBps,
37075
+ needsOverride
37076
+ }) => {
37077
+ const parts = [
37078
+ "agentgates swap",
37079
+ amount,
37080
+ fromAssetNorm,
37081
+ `--to-asset ${toAssetNorm}`
37082
+ ];
37083
+ if (isSameChain) {
37084
+ parts.push(`--chain ${fromChain}`);
37085
+ } else {
37086
+ parts.push(`--from-chain ${fromChain}`, `--to-chain ${toChain}`);
37087
+ }
37088
+ parts.push(
37089
+ needsOverride ? `--max-loss-bps ${retryBps}` : `--slippage-bps ${retryBps}`
37090
+ );
37091
+ if (opts.maxUsd !== void 0) parts.push(`--max-usd ${opts.maxUsd}`);
37092
+ parts.push(`--user-stated ${quoteArg(opts.userStated)}`);
37093
+ return parts.join(" ");
37094
+ };
36991
37095
  await runIntentFlow({
36992
37096
  endpoint: "/api/intents/propose-swap",
36993
37097
  body: proposeBody,
36994
37098
  profileName,
36995
37099
  initialProfile: profile,
36996
37100
  jsonMode,
37101
+ shouldOpenBrowser,
37102
+ buildRetryCommand
37103
+ });
37104
+ }
37105
+
37106
+ // src/commands/batch.ts
37107
+ var import_picocolors11 = __toESM(require_picocolors(), 1);
37108
+ function failArg2(msg) {
37109
+ process.stderr.write(import_picocolors11.default.red(`\u2715 ${msg}
37110
+ `));
37111
+ process.exit(2);
37112
+ }
37113
+ async function batch(opts) {
37114
+ const requested = opts.profile ?? DEFAULT_PROFILE;
37115
+ const resolved = await resolveProfile(requested);
37116
+ if (!resolved) {
37117
+ process.stderr.write(import_picocolors11.default.red("Not logged in. Run agentgates login first.\n"));
37118
+ process.exit(2);
37119
+ }
37120
+ const { name: profileName, profile } = resolved;
37121
+ const jsonMode = opts.json === true || !process.stdout.isTTY;
37122
+ let legs;
37123
+ try {
37124
+ legs = JSON.parse(opts.legsJson);
37125
+ } catch (err) {
37126
+ failArg2(
37127
+ `--legs-json is not valid JSON: ${err instanceof Error ? err.message : String(err)}`
37128
+ );
37129
+ }
37130
+ if (!Array.isArray(legs) || legs.length < 2 || legs.length > 5) {
37131
+ failArg2(
37132
+ `--legs-json must be an array of 2-5 legs (got ${Array.isArray(legs) ? legs.length : typeof legs}). One leg is just the single verb (send/swap).`
37133
+ );
37134
+ }
37135
+ let maxUsdNumber;
37136
+ if (opts.maxUsd !== void 0) {
37137
+ const n = Number(opts.maxUsd);
37138
+ if (!Number.isFinite(n) || n <= 0) {
37139
+ failArg2(`--max-usd must be a positive number (got ${opts.maxUsd}).`);
37140
+ }
37141
+ maxUsdNumber = n;
37142
+ } else {
37143
+ maxUsdNumber = profile.perTxUSD != null ? Number(profile.perTxUSD) : 1e6;
37144
+ }
37145
+ const userStatedPayload = {
37146
+ raw_request: opts.userStated,
37147
+ interpreted: {
37148
+ max_usd_total: maxUsdNumber,
37149
+ recipient_source: "ai_inferred",
37150
+ asset_label: "BATCH",
37151
+ chain_label: "batch"
37152
+ },
37153
+ ambiguities: []
37154
+ };
37155
+ const shouldOpenBrowser = resolveBrowserDefault(opts.browserMode ?? "auto");
37156
+ await runIntentFlow({
37157
+ endpoint: "/api/intents/propose-batch",
37158
+ body: {
37159
+ legs,
37160
+ ordered: opts.parallel !== true,
37161
+ user_stated: userStatedPayload
37162
+ },
37163
+ profileName,
37164
+ initialProfile: profile,
37165
+ jsonMode,
37166
+ shouldOpenBrowser
37167
+ });
37168
+ }
37169
+
37170
+ // src/commands/fund-wallet.ts
37171
+ var import_picocolors12 = __toESM(require_picocolors(), 1);
37172
+ var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
37173
+ var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
37174
+ function isAddressTarget(target) {
37175
+ return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
37176
+ }
37177
+ function failArg3(msg) {
37178
+ process.stderr.write(import_picocolors12.default.red(`\u2715 ${msg}
37179
+ `));
37180
+ process.exit(2);
37181
+ }
37182
+ async function fundWallet(address, opts) {
37183
+ const requested = opts.profile ?? DEFAULT_PROFILE;
37184
+ const resolved = await resolveProfile(requested);
37185
+ if (!resolved) {
37186
+ process.stderr.write(import_picocolors12.default.red("Not logged in. Run agentgates login first.\n"));
37187
+ process.exit(2);
37188
+ }
37189
+ const { name: profileName, profile } = resolved;
37190
+ const jsonMode = opts.json === true || !process.stdout.isTTY;
37191
+ if (!opts.chain) {
37192
+ failArg3("--chain is required (1/137/8453/42161/900 or shortName).");
37193
+ }
37194
+ const parsePositive = (val, label) => {
37195
+ if (val === void 0) return 0;
37196
+ const n = Number(val);
37197
+ if (!Number.isFinite(n) || n <= 0) {
37198
+ failArg3(`--${label} must be a positive display-units amount (got ${val}).`);
37199
+ }
37200
+ return n;
37201
+ };
37202
+ const usdc = parsePositive(opts.usdc, "usdc");
37203
+ const gas = parsePositive(opts.gas, "gas");
37204
+ if (usdc <= 0 && gas <= 0) {
37205
+ failArg3(
37206
+ "Pass at least one of --usdc / --gas \u2014 what should the payer end up with?"
37207
+ );
37208
+ }
37209
+ let maxUsdNumber;
37210
+ if (opts.maxUsd !== void 0) {
37211
+ const n = Number(opts.maxUsd);
37212
+ if (!Number.isFinite(n) || n <= 0) {
37213
+ failArg3(`--max-usd must be a positive number (got ${opts.maxUsd}).`);
37214
+ }
37215
+ maxUsdNumber = n;
37216
+ } else {
37217
+ maxUsdNumber = profile.perTxUSD != null ? Number(profile.perTxUSD) : 1e6;
37218
+ }
37219
+ const userStatedPayload = {
37220
+ raw_request: opts.userStated,
37221
+ interpreted: {
37222
+ max_usd_total: maxUsdNumber,
37223
+ recipient_source: "ai_inferred",
37224
+ asset_label: usdc > 0 && gas > 0 ? "USDC+GAS" : usdc > 0 ? "USDC" : "GAS",
37225
+ chain_label: opts.chain
37226
+ },
37227
+ ambiguities: []
37228
+ };
37229
+ const shouldOpenBrowser = resolveBrowserDefault(opts.browserMode ?? "auto");
37230
+ if (gas > 0 && usdc <= 0) {
37231
+ await runIntentFlow({
37232
+ endpoint: "/api/intents/propose",
37233
+ body: {
37234
+ to: address,
37235
+ amount: String(opts.gas),
37236
+ asset: "native",
37237
+ chain: opts.chain,
37238
+ user_stated: userStatedPayload
37239
+ },
37240
+ profileName,
37241
+ initialProfile: profile,
37242
+ jsonMode,
37243
+ shouldOpenBrowser
37244
+ });
37245
+ }
37246
+ await runIntentFlow({
37247
+ endpoint: "/api/intents/propose-fund",
37248
+ body: {
37249
+ address,
37250
+ chain: opts.chain,
37251
+ ...usdc > 0 ? { usdc: String(opts.usdc) } : {},
37252
+ ...gas > 0 ? { gas: String(opts.gas) } : {},
37253
+ user_stated: userStatedPayload
37254
+ },
37255
+ profileName,
37256
+ initialProfile: profile,
37257
+ jsonMode,
36997
37258
  shouldOpenBrowser
36998
37259
  });
36999
37260
  }
37000
37261
 
37001
37262
  // src/commands/earn-supply.ts
37002
- var import_picocolors11 = __toESM(require_picocolors(), 1);
37263
+ var import_picocolors13 = __toESM(require_picocolors(), 1);
37003
37264
  var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
37004
37265
  var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
37005
- function failArg2(msg) {
37006
- process.stderr.write(import_picocolors11.default.red(`\u2715 ${msg}
37266
+ function failArg4(msg) {
37267
+ process.stderr.write(import_picocolors13.default.red(`\u2715 ${msg}
37007
37268
  `));
37008
37269
  process.exit(2);
37009
37270
  }
@@ -37011,11 +37272,11 @@ async function earnSupply(amount, asset, opts) {
37011
37272
  const requested = opts.profile ?? DEFAULT_PROFILE;
37012
37273
  const resolved = await resolveProfile(requested);
37013
37274
  if (!resolved) {
37014
- process.stderr.write(import_picocolors11.default.red("Not logged in. Run bounty login first.\n"));
37275
+ process.stderr.write(import_picocolors13.default.red("Not logged in. Run bounty login first.\n"));
37015
37276
  process.exit(2);
37016
37277
  }
37017
37278
  if (resolved.autoSelected) {
37018
- process.stderr.write(import_picocolors11.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37279
+ process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37019
37280
  `));
37020
37281
  }
37021
37282
  const { profile, name: profileName } = resolved;
@@ -37023,28 +37284,28 @@ async function earnSupply(amount, asset, opts) {
37023
37284
  const jsonMode = opts.json === true || !stdoutIsTty;
37024
37285
  const amountNumber = Number(amount);
37025
37286
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
37026
- failArg2(`amount must be a positive number (got ${import_picocolors11.default.bold(amount)}).`);
37287
+ failArg4(`amount must be a positive number (got ${import_picocolors13.default.bold(amount)}).`);
37027
37288
  }
37028
37289
  const assetNorm = asset.toLowerCase();
37029
37290
  if (!ASSET_VALUES2.has(assetNorm)) {
37030
- failArg2(
37031
- `asset must be ${import_picocolors11.default.bold("native")} or ${import_picocolors11.default.bold("usdc")} (got ${import_picocolors11.default.bold(asset)}).`
37291
+ failArg4(
37292
+ `asset must be ${import_picocolors13.default.bold("native")} or ${import_picocolors13.default.bold("usdc")} (got ${import_picocolors13.default.bold(asset)}).`
37032
37293
  );
37033
37294
  }
37034
37295
  if (!opts.chain) {
37035
- failArg2(`--chain <chain> is required.`);
37296
+ failArg4(`--chain <chain> is required.`);
37036
37297
  }
37037
37298
  if (!opts.protocol) {
37038
- failArg2(`--protocol <aave_v3|kamino_lend> is required.`);
37299
+ failArg4(`--protocol <aave_v3|kamino_lend> is required.`);
37039
37300
  }
37040
37301
  const protocolNorm = opts.protocol.toLowerCase();
37041
37302
  if (!PROTOCOLS.has(protocolNorm)) {
37042
- failArg2(
37043
- `--protocol must be ${import_picocolors11.default.bold("aave_v3")} or ${import_picocolors11.default.bold("kamino_lend")} (got ${import_picocolors11.default.bold(opts.protocol)}).`
37303
+ failArg4(
37304
+ `--protocol must be ${import_picocolors13.default.bold("aave_v3")} or ${import_picocolors13.default.bold("kamino_lend")} (got ${import_picocolors13.default.bold(opts.protocol)}).`
37044
37305
  );
37045
37306
  }
37046
37307
  if (!opts.userStated || opts.userStated.trim() === "") {
37047
- failArg2(
37308
+ failArg4(
37048
37309
  `--user-stated <text> is required.
37049
37310
  This is the trust-gap defense: pass the verbatim user request so
37050
37311
  the approval modal can cross-check what the agent thinks the user
@@ -37055,7 +37316,7 @@ async function earnSupply(amount, asset, opts) {
37055
37316
  if (opts.maxUsd !== void 0) {
37056
37317
  const n = Number(opts.maxUsd);
37057
37318
  if (!Number.isFinite(n) || n <= 0) {
37058
- failArg2(`--max-usd must be a positive number (got ${opts.maxUsd}).`);
37319
+ failArg4(`--max-usd must be a positive number (got ${opts.maxUsd}).`);
37059
37320
  }
37060
37321
  maxUsdNumber = n;
37061
37322
  } else {
@@ -37092,11 +37353,11 @@ async function earnSupply(amount, asset, opts) {
37092
37353
  }
37093
37354
 
37094
37355
  // src/commands/earn-withdraw.ts
37095
- var import_picocolors12 = __toESM(require_picocolors(), 1);
37356
+ var import_picocolors14 = __toESM(require_picocolors(), 1);
37096
37357
  var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
37097
37358
  var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
37098
- function failArg3(msg) {
37099
- process.stderr.write(import_picocolors12.default.red(`\u2715 ${msg}
37359
+ function failArg5(msg) {
37360
+ process.stderr.write(import_picocolors14.default.red(`\u2715 ${msg}
37100
37361
  `));
37101
37362
  process.exit(2);
37102
37363
  }
@@ -37104,11 +37365,11 @@ async function earnWithdraw(amountOrMax, asset, opts) {
37104
37365
  const requested = opts.profile ?? DEFAULT_PROFILE;
37105
37366
  const resolved = await resolveProfile(requested);
37106
37367
  if (!resolved) {
37107
- process.stderr.write(import_picocolors12.default.red("Not logged in. Run bounty login first.\n"));
37368
+ process.stderr.write(import_picocolors14.default.red("Not logged in. Run bounty login first.\n"));
37108
37369
  process.exit(2);
37109
37370
  }
37110
37371
  if (resolved.autoSelected) {
37111
- process.stderr.write(import_picocolors12.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37372
+ process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37112
37373
  `));
37113
37374
  }
37114
37375
  const { profile, name: profileName } = resolved;
@@ -37118,31 +37379,31 @@ async function earnWithdraw(amountOrMax, asset, opts) {
37118
37379
  if (!isMax) {
37119
37380
  const amountNumber = Number(amountOrMax);
37120
37381
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
37121
- failArg3(
37122
- `<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors12.default.bold(amountOrMax)}).`
37382
+ failArg5(
37383
+ `<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors14.default.bold(amountOrMax)}).`
37123
37384
  );
37124
37385
  }
37125
37386
  }
37126
37387
  const assetNorm = asset.toLowerCase();
37127
37388
  if (!ASSET_VALUES3.has(assetNorm)) {
37128
- failArg3(
37129
- `asset must be ${import_picocolors12.default.bold("native")} or ${import_picocolors12.default.bold("usdc")} (got ${import_picocolors12.default.bold(asset)}).`
37389
+ failArg5(
37390
+ `asset must be ${import_picocolors14.default.bold("native")} or ${import_picocolors14.default.bold("usdc")} (got ${import_picocolors14.default.bold(asset)}).`
37130
37391
  );
37131
37392
  }
37132
37393
  if (!opts.chain) {
37133
- failArg3(`--chain <chain> is required.`);
37394
+ failArg5(`--chain <chain> is required.`);
37134
37395
  }
37135
37396
  if (!opts.protocol) {
37136
- failArg3(`--protocol <aave_v3|kamino_lend> is required.`);
37397
+ failArg5(`--protocol <aave_v3|kamino_lend> is required.`);
37137
37398
  }
37138
37399
  const protocolNorm = opts.protocol.toLowerCase();
37139
37400
  if (!PROTOCOLS2.has(protocolNorm)) {
37140
- failArg3(
37141
- `--protocol must be ${import_picocolors12.default.bold("aave_v3")} or ${import_picocolors12.default.bold("kamino_lend")} (got ${import_picocolors12.default.bold(opts.protocol)}).`
37401
+ failArg5(
37402
+ `--protocol must be ${import_picocolors14.default.bold("aave_v3")} or ${import_picocolors14.default.bold("kamino_lend")} (got ${import_picocolors14.default.bold(opts.protocol)}).`
37142
37403
  );
37143
37404
  }
37144
37405
  if (!opts.userStated || opts.userStated.trim() === "") {
37145
- failArg3(
37406
+ failArg5(
37146
37407
  `--user-stated <text> is required.
37147
37408
  This is the trust-gap defense: pass the verbatim user request so
37148
37409
  the approval modal can cross-check what the agent thinks the user
@@ -37153,7 +37414,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
37153
37414
  if (opts.maxUsd !== void 0) {
37154
37415
  const n = Number(opts.maxUsd);
37155
37416
  if (!Number.isFinite(n) || n <= 0) {
37156
- failArg3(`--max-usd must be a positive number (got ${opts.maxUsd}).`);
37417
+ failArg5(`--max-usd must be a positive number (got ${opts.maxUsd}).`);
37157
37418
  }
37158
37419
  maxUsdNumber = n;
37159
37420
  } else {
@@ -37190,7 +37451,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
37190
37451
  }
37191
37452
 
37192
37453
  // src/commands/eat.ts
37193
- var import_picocolors13 = __toESM(require_picocolors(), 1);
37454
+ var import_picocolors15 = __toESM(require_picocolors(), 1);
37194
37455
  function parseLineJson(values) {
37195
37456
  const lines = [];
37196
37457
  for (const value of values) {
@@ -37217,11 +37478,11 @@ function parseLineJson(values) {
37217
37478
  async function loadResolvedProfile(requested) {
37218
37479
  const resolved = await resolveProfile(requested);
37219
37480
  if (!resolved) {
37220
- process.stderr.write(import_picocolors13.default.red("Not logged in. Run bounty login first.\n"));
37481
+ process.stderr.write(import_picocolors15.default.red("Not logged in. Run bounty login first.\n"));
37221
37482
  process.exit(2);
37222
37483
  }
37223
37484
  if (resolved.autoSelected) {
37224
- process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37485
+ process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37225
37486
  `));
37226
37487
  }
37227
37488
  return resolved;
@@ -37232,12 +37493,12 @@ function printResult(res, jsonMode) {
37232
37493
  return;
37233
37494
  }
37234
37495
  if (res.blocked) {
37235
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
37496
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
37236
37497
  `));
37237
37498
  if (res.upgrade_url) {
37238
37499
  process.stderr.write(
37239
37500
  ` Open this to grant access, then re-run the command:
37240
- ${import_picocolors13.default.cyan(res.upgrade_url)}
37501
+ ${import_picocolors15.default.cyan(res.upgrade_url)}
37241
37502
  `
37242
37503
  );
37243
37504
  }
@@ -37268,7 +37529,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
37268
37529
  profile: resolved.profile,
37269
37530
  profileName: resolved.name,
37270
37531
  jsonMode,
37271
- ttyHeader: import_picocolors13.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
37532
+ ttyHeader: import_picocolors15.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
37272
37533
  fn: (bearer, origin) => apiFetch(path5, { method: "POST", bearer, origin, body })
37273
37534
  });
37274
37535
  if (outcome.kind === "auth_failed") {
@@ -37278,7 +37539,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
37278
37539
  );
37279
37540
  process.exit(1);
37280
37541
  }
37281
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${outcome.reason}.
37542
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${outcome.reason}.
37282
37543
  `));
37283
37544
  process.exit(1);
37284
37545
  }
@@ -37291,7 +37552,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
37291
37552
  );
37292
37553
  process.exit(1);
37293
37554
  }
37294
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${err.message} (HTTP ${err.status})
37555
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message} (HTTP ${err.status})
37295
37556
  `));
37296
37557
  process.exit(1);
37297
37558
  }
@@ -37304,7 +37565,7 @@ async function searchFood(opts) {
37304
37565
  const jsonMode = opts.json === true || process.stdout.isTTY !== true;
37305
37566
  if (!opts.location && !opts.name) {
37306
37567
  process.stderr.write(
37307
- import_picocolors13.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
37568
+ import_picocolors15.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
37308
37569
  );
37309
37570
  process.exit(2);
37310
37571
  }
@@ -37325,7 +37586,7 @@ async function menuFood(items, opts) {
37325
37586
  const jsonMode = opts.json === true || process.stdout.isTTY !== true;
37326
37587
  if (!opts.brand || !opts.address) {
37327
37588
  process.stderr.write(
37328
- import_picocolors13.default.red(
37589
+ import_picocolors15.default.red(
37329
37590
  "\u2715 --brand and --address are required \u2014 use the pair a `bounty eat search` result gave you, verbatim.\n"
37330
37591
  )
37331
37592
  );
@@ -37345,7 +37606,7 @@ async function orderFood(items, opts) {
37345
37606
  const jsonMode = opts.json === true || process.stdout.isTTY !== true;
37346
37607
  if (!opts.brand || !opts.address) {
37347
37608
  process.stderr.write(
37348
- import_picocolors13.default.red(
37609
+ import_picocolors15.default.red(
37349
37610
  "\u2715 --brand and --address are required \u2014 use the pair a `bounty eat search` result gave you, verbatim.\n"
37350
37611
  )
37351
37612
  );
@@ -37355,14 +37616,14 @@ async function orderFood(items, opts) {
37355
37616
  try {
37356
37617
  structuredLines = parseLineJson(opts.lineJson ?? []);
37357
37618
  } catch (e) {
37358
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
37619
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
37359
37620
  `));
37360
37621
  process.exit(2);
37361
37622
  }
37362
37623
  const lines = [...items ?? [], ...structuredLines];
37363
37624
  if (lines.length === 0) {
37364
37625
  process.stderr.write(
37365
- import_picocolors13.default.red("\u2715 Pass at least one dish \u2014 plain words as arguments, or --line-json for a line with a size/option/note.\n")
37626
+ import_picocolors15.default.red("\u2715 Pass at least one dish \u2014 plain words as arguments, or --line-json for a line with a size/option/note.\n")
37366
37627
  );
37367
37628
  process.exit(2);
37368
37629
  }
@@ -37396,7 +37657,7 @@ async function orderFood(items, opts) {
37396
37657
  if (!agentCard.will_attempt) {
37397
37658
  if (!jsonMode) {
37398
37659
  process.stderr.write(
37399
- import_picocolors13.default.yellow(
37660
+ import_picocolors15.default.yellow(
37400
37661
  `This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
37401
37662
  `
37402
37663
  )
@@ -37413,7 +37674,7 @@ async function orderFood(items, opts) {
37413
37674
  }
37414
37675
  if (verdict.status === "paid") {
37415
37676
  process.stdout.write(
37416
- import_picocolors13.default.green(
37677
+ import_picocolors15.default.green(
37417
37678
  `Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
37418
37679
  )
37419
37680
  );
@@ -37421,7 +37682,7 @@ async function orderFood(items, opts) {
37421
37682
  }
37422
37683
  if (verdict.status === "failed") {
37423
37684
  process.stderr.write(
37424
- import_picocolors13.default.yellow(
37685
+ import_picocolors15.default.yellow(
37425
37686
  `Your saved card did not pay this (${verdict.failure_reason ?? "refused"}${verdict.failure_detail ? `: ${verdict.failure_detail}` : ""}). Nothing was charged. The link still works for you to pay yourself.
37426
37687
  `
37427
37688
  )
@@ -37431,7 +37692,7 @@ async function orderFood(items, opts) {
37431
37692
  }
37432
37693
  if (verdict.status === "unconfirmed") {
37433
37694
  process.stderr.write(
37434
- import_picocolors13.default.red(
37695
+ import_picocolors15.default.red(
37435
37696
  "A payment attempt happened and its outcome is UNKNOWN \u2014 nothing will retry it. Open the order and check before paying anything:\n" + (approvalUrl ? ` ${approvalUrl}
37436
37697
  ` : "")
37437
37698
  )
@@ -37440,7 +37701,7 @@ async function orderFood(items, opts) {
37440
37701
  return;
37441
37702
  }
37442
37703
  process.stderr.write(
37443
- import_picocolors13.default.dim(
37704
+ import_picocolors15.default.dim(
37444
37705
  `Still being attempted. Check with: bounty eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
37445
37706
  )
37446
37707
  );
@@ -37465,7 +37726,7 @@ var POLL_BUDGET_MS = 1e5;
37465
37726
  var POLL_INTERVAL_MS2 = 3500;
37466
37727
  async function pollOrderVerdict(orderId, resolved, jsonMode) {
37467
37728
  if (!jsonMode) {
37468
- process.stderr.write(import_picocolors13.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
37729
+ process.stderr.write(import_picocolors15.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
37469
37730
  }
37470
37731
  const deadline = Date.now() + POLL_BUDGET_MS;
37471
37732
  let last = {
@@ -37535,16 +37796,16 @@ async function statusFood(orderId, opts) {
37535
37796
  }
37536
37797
 
37537
37798
  // src/commands/bounties.ts
37538
- var import_picocolors14 = __toESM(require_picocolors(), 1);
37799
+ var import_picocolors16 = __toESM(require_picocolors(), 1);
37539
37800
  async function withProfile(opts, path5, init) {
37540
37801
  const requested = opts.profile ?? DEFAULT_PROFILE;
37541
37802
  const resolved = await resolveProfile(requested);
37542
37803
  if (!resolved) {
37543
- process.stderr.write(import_picocolors14.default.red("Not logged in. Run bounty login first.\n"));
37804
+ process.stderr.write(import_picocolors16.default.red("Not logged in. Run bounty login first.\n"));
37544
37805
  process.exit(2);
37545
37806
  }
37546
37807
  if (resolved.autoSelected) {
37547
- process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37808
+ process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37548
37809
  `));
37549
37810
  }
37550
37811
  const { profile, name: profileName } = resolved;
@@ -37553,7 +37814,7 @@ async function withProfile(opts, path5, init) {
37553
37814
  profile,
37554
37815
  profileName,
37555
37816
  jsonMode,
37556
- ttyHeader: import_picocolors14.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
37817
+ ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
37557
37818
  fn: (bearer, origin) => apiFetch(path5, init ? { bearer, origin, method: init.method, body: init.body } : { bearer, origin })
37558
37819
  });
37559
37820
  if (outcome.kind === "auth_failed") {
@@ -37561,14 +37822,14 @@ async function withProfile(opts, path5, init) {
37561
37822
  process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
37562
37823
  process.exit(1);
37563
37824
  }
37564
- process.stderr.write(import_picocolors14.default.red(`\u2715 ${outcome.reason}.
37825
+ process.stderr.write(import_picocolors16.default.red(`\u2715 ${outcome.reason}.
37565
37826
  `));
37566
37827
  process.exit(1);
37567
37828
  }
37568
37829
  if (outcome.kind === "error") {
37569
37830
  const err = outcome.error;
37570
37831
  if (err instanceof ApiError) {
37571
- process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message} (HTTP ${err.status})
37832
+ process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
37572
37833
  `));
37573
37834
  process.exit(1);
37574
37835
  }
@@ -37582,12 +37843,12 @@ function handleBlocked(res, jsonMode) {
37582
37843
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
37583
37844
  process.exit(1);
37584
37845
  }
37585
- process.stderr.write(import_picocolors14.default.yellow(`
37846
+ process.stderr.write(import_picocolors16.default.yellow(`
37586
37847
  ${res.reason ?? "Blocked."}
37587
37848
  `));
37588
37849
  if (res.upgrade_url) {
37589
37850
  process.stderr.write(`
37590
- ${import_picocolors14.default.bold(res.upgrade_url)}
37851
+ ${import_picocolors16.default.bold(res.upgrade_url)}
37591
37852
 
37592
37853
  `);
37593
37854
  }
@@ -37630,14 +37891,14 @@ function printTable(rows) {
37630
37891
  const cLeft = w("left", 4);
37631
37892
  const cSubs = w("subs", 4);
37632
37893
  process.stdout.write(
37633
- import_picocolors14.default.dim(
37894
+ import_picocolors16.default.dim(
37634
37895
  "Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
37635
37896
  ) + "\n"
37636
37897
  );
37637
37898
  for (const c of cells) {
37638
- const title = c.live ? import_picocolors14.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
37899
+ const title = c.live ? import_picocolors16.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
37639
37900
  process.stdout.write(
37640
- import_picocolors14.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors14.default.dim(c.id) + "\n"
37901
+ import_picocolors16.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors16.default.dim(c.id) + "\n"
37641
37902
  );
37642
37903
  }
37643
37904
  }
@@ -37649,11 +37910,11 @@ async function listBounties(opts) {
37649
37910
  const min = opts.min !== void 0 ? Number(opts.min) : void 0;
37650
37911
  const max = opts.max !== void 0 ? Number(opts.max) : void 0;
37651
37912
  if (min !== void 0 && !Number.isFinite(min)) {
37652
- process.stderr.write(import_picocolors14.default.red("\u2715 --min must be a number.\n"));
37913
+ process.stderr.write(import_picocolors16.default.red("\u2715 --min must be a number.\n"));
37653
37914
  process.exit(2);
37654
37915
  }
37655
37916
  if (max !== void 0 && !Number.isFinite(max)) {
37656
- process.stderr.write(import_picocolors14.default.red("\u2715 --max must be a number.\n"));
37917
+ process.stderr.write(import_picocolors16.default.red("\u2715 --max must be a number.\n"));
37657
37918
  process.exit(2);
37658
37919
  }
37659
37920
  rows = rows.filter((r) => {
@@ -37678,7 +37939,7 @@ async function listBounties(opts) {
37678
37939
  });
37679
37940
  const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
37680
37941
  if (!Number.isFinite(limit) || limit <= 0) {
37681
- process.stderr.write(import_picocolors14.default.red("\u2715 --limit must be a positive number.\n"));
37942
+ process.stderr.write(import_picocolors16.default.red("\u2715 --limit must be a positive number.\n"));
37682
37943
  process.exit(2);
37683
37944
  }
37684
37945
  const shown = rows.slice(0, limit);
@@ -37687,13 +37948,13 @@ async function listBounties(opts) {
37687
37948
  return;
37688
37949
  }
37689
37950
  if (shown.length === 0) {
37690
- process.stdout.write(import_picocolors14.default.dim("No active bounties match.\n"));
37951
+ process.stdout.write(import_picocolors16.default.dim("No active bounties match.\n"));
37691
37952
  return;
37692
37953
  }
37693
37954
  printTable(shown);
37694
37955
  const clipped = rows.length - shown.length;
37695
37956
  process.stdout.write(
37696
- "\n" + import_picocolors14.default.dim(
37957
+ "\n" + import_picocolors16.default.dim(
37697
37958
  `${shown.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. bounty show <id> for detail.
37698
37959
  `
37699
37960
  )
@@ -37704,7 +37965,7 @@ async function showBounty(id, opts) {
37704
37965
  const jsonMode = opts.json === true;
37705
37966
  const clean = id.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
37706
37967
  if (!clean) {
37707
- process.stderr.write(import_picocolors14.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
37968
+ process.stderr.write(import_picocolors16.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
37708
37969
  process.exit(2);
37709
37970
  }
37710
37971
  const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean)}`);
@@ -37715,26 +37976,26 @@ async function showBounty(id, opts) {
37715
37976
  }
37716
37977
  const b = res.bounty;
37717
37978
  if (!b) {
37718
- process.stdout.write(import_picocolors14.default.dim("Not found.\n"));
37979
+ process.stdout.write(import_picocolors16.default.dim("Not found.\n"));
37719
37980
  return;
37720
37981
  }
37721
- process.stdout.write("\n" + import_picocolors14.default.bold(b.title) + "\n\n");
37982
+ process.stdout.write("\n" + import_picocolors16.default.bold(b.title) + "\n\n");
37722
37983
  process.stdout.write(b.description + "\n\n");
37723
37984
  process.stdout.write(
37724
- import_picocolors14.default.bold(fmtAmount(b.amount)) + import_picocolors14.default.dim(" USDC") + import_picocolors14.default.dim(` \xB7 ${chainOf2(b)} \xB7 ${b.status.toLowerCase()}`) + (b.liveNow ? import_picocolors14.default.green(" \xB7 LIVE now") : "") + "\n"
37985
+ import_picocolors16.default.bold(fmtAmount(b.amount)) + import_picocolors16.default.dim(" USDC") + import_picocolors16.default.dim(` \xB7 ${chainOf2(b)} \xB7 ${b.status.toLowerCase()}`) + (b.liveNow ? import_picocolors16.default.green(" \xB7 LIVE now") : "") + "\n"
37725
37986
  );
37726
37987
  if (b.claimsAllowed && b.claimsAllowed > 1) {
37727
37988
  const left = Math.max(0, b.claimsAllowed - (b.claimsPaid ?? 0));
37728
37989
  process.stdout.write(
37729
- import_picocolors14.default.dim(
37990
+ import_picocolors16.default.dim(
37730
37991
  `${left} of ${b.claimsAllowed} claims left` + (b.perClaimAmount != null ? `, ${fmtAmount(b.perClaimAmount)} each` : "")
37731
37992
  ) + "\n"
37732
37993
  );
37733
37994
  }
37734
- if (b.evidenceType) process.stdout.write(import_picocolors14.default.dim(`Evidence required: ${b.evidenceType}`) + "\n");
37735
- if (b.expiresAt) process.stdout.write(import_picocolors14.default.dim(`Expires in ${fmtExpiry(b.expiresAt)}`) + "\n");
37995
+ if (b.evidenceType) process.stdout.write(import_picocolors16.default.dim(`Evidence required: ${b.evidenceType}`) + "\n");
37996
+ if (b.expiresAt) process.stdout.write(import_picocolors16.default.dim(`Expires in ${fmtExpiry(b.expiresAt)}`) + "\n");
37736
37997
  if (b.geoLabel && b.geoScope !== "global") {
37737
- process.stdout.write(import_picocolors14.default.dim(`Creator says: ${b.geoLabel}`) + "\n");
37998
+ process.stdout.write(import_picocolors16.default.dim(`Creator says: ${b.geoLabel}`) + "\n");
37738
37999
  }
37739
38000
  if (res.url) process.stdout.write("\n" + res.url + "\n");
37740
38001
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -37752,7 +38013,7 @@ async function myBounties(opts) {
37752
38013
  }
37753
38014
  if (rows.length === 0) {
37754
38015
  process.stdout.write(
37755
- import_picocolors14.default.dim(
38016
+ import_picocolors16.default.dim(
37756
38017
  status2 ? `No bounties of yours are ${status2}.
37757
38018
  ` : "You have not created any bounties yet. `bounty draft` starts one.\n"
37758
38019
  )
@@ -37762,7 +38023,7 @@ async function myBounties(opts) {
37762
38023
  printTable(rows);
37763
38024
  const subs = res.submissions ?? [];
37764
38025
  if (subs.length > 0) {
37765
- process.stdout.write("\n" + import_picocolors14.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
38026
+ process.stdout.write("\n" + import_picocolors16.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
37766
38027
  `));
37767
38028
  }
37768
38029
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -37781,19 +38042,19 @@ async function bountyFeed(opts) {
37781
38042
  }
37782
38043
  const subs = res.submissions ?? [];
37783
38044
  if (subs.length === 0) {
37784
- process.stdout.write(import_picocolors14.default.dim("Nothing in the feed for that filter.\n"));
38045
+ process.stdout.write(import_picocolors16.default.dim("Nothing in the feed for that filter.\n"));
37785
38046
  return;
37786
38047
  }
37787
38048
  process.stdout.write(
37788
- `${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors14.default.dim(" More available.") : "") + "\n"
38049
+ `${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors16.default.dim(" More available.") : "") + "\n"
37789
38050
  );
37790
- process.stdout.write(import_picocolors14.default.dim("Use --json for the full rows.\n"));
38051
+ process.stdout.write(import_picocolors16.default.dim("Use --json for the full rows.\n"));
37791
38052
  }
37792
38053
  async function draftBounty(opts) {
37793
38054
  const jsonMode = opts.json === true;
37794
38055
  const amountNum = Number(opts.amount);
37795
38056
  if (!Number.isFinite(amountNum) || amountNum <= 0) {
37796
- process.stderr.write(import_picocolors14.default.red("\u2715 --amount must be a positive number of USDC.\n"));
38057
+ process.stderr.write(import_picocolors16.default.red("\u2715 --amount must be a positive number of USDC.\n"));
37797
38058
  process.exit(2);
37798
38059
  }
37799
38060
  const res = await withProfile(opts, "/api/bounties", {
@@ -37811,20 +38072,20 @@ async function draftBounty(opts) {
37811
38072
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
37812
38073
  return;
37813
38074
  }
37814
- process.stdout.write("\n" + import_picocolors14.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
38075
+ process.stdout.write("\n" + import_picocolors16.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
37815
38076
 
37816
38077
  `);
37817
- process.stdout.write(import_picocolors14.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
38078
+ process.stdout.write(import_picocolors16.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
37818
38079
  if (res.fund_url) {
37819
- process.stdout.write("\nFund it here:\n" + import_picocolors14.default.bold(res.fund_url) + "\n\n");
37820
- process.stdout.write(import_picocolors14.default.dim("Funding happens in your browser with your own wallet.\n"));
38080
+ process.stdout.write("\nFund it here:\n" + import_picocolors16.default.bold(res.fund_url) + "\n\n");
38081
+ process.stdout.write(import_picocolors16.default.dim("Funding happens in your browser with your own wallet.\n"));
37821
38082
  }
37822
38083
  }
37823
38084
 
37824
38085
  // src/commands/bounty-money.ts
37825
- var import_picocolors15 = __toESM(require_picocolors(), 1);
37826
- function failArg4(message) {
37827
- process.stderr.write(import_picocolors15.default.red(`${message}
38086
+ var import_picocolors17 = __toESM(require_picocolors(), 1);
38087
+ function failArg6(message) {
38088
+ process.stderr.write(import_picocolors17.default.red(`${message}
37828
38089
  `));
37829
38090
  process.exit(2);
37830
38091
  }
@@ -37836,12 +38097,12 @@ async function loadProfileOrExit(requested, jsonMode) {
37836
38097
  JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run bounty login first." }) + "\n"
37837
38098
  );
37838
38099
  } else {
37839
- process.stderr.write(import_picocolors15.default.red("Not logged in. Run bounty login first.\n"));
38100
+ process.stderr.write(import_picocolors17.default.red("Not logged in. Run bounty login first.\n"));
37840
38101
  }
37841
38102
  process.exit(2);
37842
38103
  }
37843
38104
  if (resolved.autoSelected && !jsonMode) {
37844
- process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
38105
+ process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37845
38106
  `));
37846
38107
  }
37847
38108
  return { profile: resolved.profile, profileName: resolved.name };
@@ -37850,12 +38111,12 @@ function resolveMaxUsd(opts, profile, fallbackHint) {
37850
38111
  if (opts.maxUsd !== void 0) {
37851
38112
  const n = Number(opts.maxUsd);
37852
38113
  if (!Number.isFinite(n) || n <= 0) {
37853
- failArg4(`--max-usd must be a positive number (got ${opts.maxUsd}).`);
38114
+ failArg6(`--max-usd must be a positive number (got ${opts.maxUsd}).`);
37854
38115
  }
37855
38116
  return n;
37856
38117
  }
37857
38118
  if (profile.perTxUSD != null) return Number(profile.perTxUSD);
37858
- failArg4(
38119
+ failArg6(
37859
38120
  `This pairing has no per-tx cap on file, so --max-usd is required for ${fallbackHint} (your declared USD ceiling).`
37860
38121
  );
37861
38122
  }
@@ -37888,7 +38149,7 @@ async function tipBounty(bountyId, amount, opts) {
37888
38149
  const jsonMode = Boolean(opts.json) || !process.stdout.isTTY;
37889
38150
  const amt = Number(amount);
37890
38151
  if (!Number.isFinite(amt) || amt <= 0) {
37891
- failArg4(`amount must be a positive USDC number (got ${amount}).`);
38152
+ failArg6(`amount must be a positive USDC number (got ${amount}).`);
37892
38153
  }
37893
38154
  const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode);
37894
38155
  const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "bounty tip") : Math.ceil(amt * 1.01 * 100) / 100;
@@ -37918,7 +38179,7 @@ async function subscribeCreator(creatorUserId, opts) {
37918
38179
  const jsonMode = Boolean(opts.json) || !process.stdout.isTTY;
37919
38180
  const months = opts.months === void 0 ? 1 : Number(opts.months);
37920
38181
  if (![1, 3, 12].includes(months)) {
37921
- failArg4(`--months must be 1, 3 or 12 (got ${opts.months}). Prepaid periods only \u2014 no auto-renew exists.`);
38182
+ failArg6(`--months must be 1, 3 or 12 (got ${opts.months}). Prepaid periods only \u2014 no auto-renew exists.`);
37922
38183
  }
37923
38184
  const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode);
37924
38185
  const maxUsd = resolveMaxUsd(opts, profile, "bounty subscribe");
@@ -37946,16 +38207,16 @@ async function subscribeCreator(creatorUserId, opts) {
37946
38207
  }
37947
38208
 
37948
38209
  // src/commands/bounty-work.ts
37949
- var import_picocolors16 = __toESM(require_picocolors(), 1);
38210
+ var import_picocolors18 = __toESM(require_picocolors(), 1);
37950
38211
  async function runWork(path5, body, opts) {
37951
38212
  const requested = opts.profile ?? DEFAULT_PROFILE;
37952
38213
  const resolved = await resolveProfile(requested);
37953
38214
  if (!resolved) {
37954
- process.stderr.write(import_picocolors16.default.red("Not logged in. Run bounty login first.\n"));
38215
+ process.stderr.write(import_picocolors18.default.red("Not logged in. Run bounty login first.\n"));
37955
38216
  process.exit(2);
37956
38217
  }
37957
38218
  if (resolved.autoSelected) {
37958
- process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
38219
+ process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
37959
38220
  `));
37960
38221
  }
37961
38222
  const jsonMode = opts.json === true;
@@ -37963,7 +38224,7 @@ async function runWork(path5, body, opts) {
37963
38224
  profile: resolved.profile,
37964
38225
  profileName: resolved.name,
37965
38226
  jsonMode,
37966
- ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
38227
+ ttyHeader: import_picocolors18.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
37967
38228
  fn: (bearer, origin) => apiFetch(path5, { bearer, origin, method: "POST", body })
37968
38229
  });
37969
38230
  if (outcome.kind === "auth_failed") {
@@ -37971,7 +38232,7 @@ async function runWork(path5, body, opts) {
37971
38232
  process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
37972
38233
  process.exit(1);
37973
38234
  }
37974
- process.stderr.write(import_picocolors16.default.red(`\u2715 ${outcome.reason}.
38235
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${outcome.reason}.
37975
38236
  `));
37976
38237
  process.exit(1);
37977
38238
  }
@@ -37981,7 +38242,7 @@ async function runWork(path5, body, opts) {
37981
38242
  if (jsonMode) {
37982
38243
  process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
37983
38244
  } else {
37984
- process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
38245
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message} (HTTP ${err.status})
37985
38246
  `));
37986
38247
  }
37987
38248
  process.exit(1);
@@ -37994,11 +38255,11 @@ async function runWork(path5, body, opts) {
37994
38255
  process.stdout.write(JSON.stringify({ ok: false, ...data }) + "\n");
37995
38256
  process.exit(1);
37996
38257
  }
37997
- process.stderr.write(import_picocolors16.default.yellow(`
38258
+ process.stderr.write(import_picocolors18.default.yellow(`
37998
38259
  ${data.reason ?? "Blocked."}
37999
38260
  `));
38000
38261
  if (data.upgrade_url) process.stderr.write(`
38001
- ${import_picocolors16.default.bold(data.upgrade_url)}
38262
+ ${import_picocolors18.default.bold(data.upgrade_url)}
38002
38263
 
38003
38264
  `);
38004
38265
  process.exit(1);
@@ -38007,7 +38268,7 @@ ${import_picocolors16.default.bold(data.upgrade_url)}
38007
38268
  if (jsonMode) {
38008
38269
  process.stdout.write(JSON.stringify({ ok: false, error: data.error }) + "\n");
38009
38270
  } else {
38010
- process.stderr.write(import_picocolors16.default.red(`\u2715 ${data.error}
38271
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${data.error}
38011
38272
  `));
38012
38273
  }
38013
38274
  process.exit(1);
@@ -38050,7 +38311,7 @@ async function bountyRetention(bountyId, opts) {
38050
38311
  }
38051
38312
 
38052
38313
  // src/commands/bounty-deliver.ts
38053
- var import_picocolors17 = __toESM(require_picocolors(), 1);
38314
+ var import_picocolors19 = __toESM(require_picocolors(), 1);
38054
38315
  import { spawn } from "node:child_process";
38055
38316
  var FLUSH_MS = 400;
38056
38317
  var FLUSH_BYTES = 2048;
@@ -38059,11 +38320,11 @@ async function deliver(bountyId, command, opts) {
38059
38320
  const requested = opts.profile ?? DEFAULT_PROFILE;
38060
38321
  const resolved = await resolveProfile(requested);
38061
38322
  if (!resolved) {
38062
- process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
38323
+ process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
38063
38324
  process.exit(2);
38064
38325
  }
38065
38326
  if (resolved.autoSelected && !jsonMode) {
38066
- process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
38327
+ process.stderr.write(import_picocolors19.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
38067
38328
  `));
38068
38329
  }
38069
38330
  const post = async (path5, body) => {
@@ -38071,7 +38332,7 @@ async function deliver(bountyId, command, opts) {
38071
38332
  profile: resolved.profile,
38072
38333
  profileName: resolved.name,
38073
38334
  jsonMode,
38074
- ttyHeader: import_picocolors17.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
38335
+ ttyHeader: import_picocolors19.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
38075
38336
  fn: (bearer, origin) => apiFetch(path5, { bearer, origin, method: "POST", body })
38076
38337
  });
38077
38338
  if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
@@ -38082,11 +38343,11 @@ async function deliver(bountyId, command, opts) {
38082
38343
  if (jsonMode) {
38083
38344
  process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data ?? {} }) + "\n");
38084
38345
  } else {
38085
- process.stderr.write(import_picocolors17.default.red(`
38346
+ process.stderr.write(import_picocolors19.default.red(`
38086
38347
  \u2715 ${msg}
38087
38348
  `));
38088
38349
  if (data?.upgrade_url) process.stderr.write(`
38089
- ${import_picocolors17.default.bold(data.upgrade_url)}
38350
+ ${import_picocolors19.default.bold(data.upgrade_url)}
38090
38351
 
38091
38352
  `);
38092
38353
  }
@@ -38111,7 +38372,7 @@ ${import_picocolors17.default.bold(data.upgrade_url)}
38111
38372
  if (!runId) return void die("The service opened a run but did not name it.");
38112
38373
  if (!jsonMode) {
38113
38374
  process.stderr.write(
38114
- import_picocolors17.default.bold("\n\u25CF LIVE ") + import_picocolors17.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors17.default.dim(` ${started.url ?? ""}
38375
+ import_picocolors19.default.bold("\n\u25CF LIVE ") + import_picocolors19.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors19.default.dim(` ${started.url ?? ""}
38115
38376
 
38116
38377
  `)
38117
38378
  );
@@ -38163,10 +38424,10 @@ ${import_picocolors17.default.bold(data.upgrade_url)}
38163
38424
  child.stdout.on("data", (d) => consume(d));
38164
38425
  child.stderr.setEncoding("utf8");
38165
38426
  child.stderr.on("data", (d) => {
38166
- if (!jsonMode) process.stderr.write(import_picocolors17.default.dim(d));
38427
+ if (!jsonMode) process.stderr.write(import_picocolors19.default.dim(d));
38167
38428
  });
38168
38429
  child.on("error", (err) => {
38169
- process.stderr.write(import_picocolors17.default.red(`
38430
+ process.stderr.write(import_picocolors19.default.red(`
38170
38431
  \u2715 Could not run ${command[0]}: ${err.message}
38171
38432
  `));
38172
38433
  resolve(127);
@@ -38203,14 +38464,14 @@ ${import_picocolors17.default.bold(data.upgrade_url)}
38203
38464
  }
38204
38465
  if (appendFailure) {
38205
38466
  process.stderr.write(
38206
- import_picocolors17.default.yellow(`
38467
+ import_picocolors19.default.yellow(`
38207
38468
  ! Some output did not reach the page: ${appendFailure}
38208
- `) + import_picocolors17.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
38469
+ `) + import_picocolors19.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
38209
38470
  );
38210
38471
  }
38211
38472
  if (exitCode) {
38212
38473
  process.stderr.write(
38213
- import_picocolors17.default.yellow(`
38474
+ import_picocolors19.default.yellow(`
38214
38475
  ! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
38215
38476
  `)
38216
38477
  );
@@ -38220,7 +38481,7 @@ ${import_picocolors17.default.bold(data.upgrade_url)}
38220
38481
  }
38221
38482
 
38222
38483
  // src/commands/trade.ts
38223
- var import_picocolors18 = __toESM(require_picocolors(), 1);
38484
+ var import_picocolors20 = __toESM(require_picocolors(), 1);
38224
38485
 
38225
38486
  // src/lib/trade-sol.ts
38226
38487
  var import_web3 = __toESM(require_index_cjs(), 1);
@@ -38586,7 +38847,7 @@ function fail(message, json) {
38586
38847
  if (json) {
38587
38848
  process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
38588
38849
  } else {
38589
- process.stderr.write(import_picocolors18.default.red(`\u2715 ${message}
38850
+ process.stderr.write(import_picocolors20.default.red(`\u2715 ${message}
38590
38851
  `));
38591
38852
  }
38592
38853
  process.exit(1);
@@ -38777,7 +39038,7 @@ async function tradeBuy(coinArg, amount, opts) {
38777
39038
  }
38778
39039
  const { keypair, state, created } = await loadOrCreateTradeKey();
38779
39040
  if (created && !opts.json) {
38780
- process.stderr.write(import_picocolors18.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
39041
+ process.stderr.write(import_picocolors20.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
38781
39042
  `));
38782
39043
  }
38783
39044
  const result = await runTrade({ ctx, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
@@ -38831,7 +39092,7 @@ async function tradeOrderPlace(coinArg, opts) {
38831
39092
  if (opts.mcap && !opts.at) fail("--mcap qualifies --at.", opts.json);
38832
39093
  const { keypair, state, created } = await loadOrCreateTradeKey();
38833
39094
  if (created && !opts.json) {
38834
- process.stderr.write(import_picocolors18.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
39095
+ process.stderr.write(import_picocolors20.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
38835
39096
  `));
38836
39097
  }
38837
39098
  let amount;
@@ -38996,7 +39257,7 @@ async function tradePositions(opts) {
38996
39257
  }
38997
39258
 
38998
39259
  // src/commands/desk.ts
38999
- var import_picocolors19 = __toESM(require_picocolors(), 1);
39260
+ var import_picocolors21 = __toESM(require_picocolors(), 1);
39000
39261
 
39001
39262
  // src/lib/desk-sol.ts
39002
39263
  var import_web32 = __toESM(require_index_cjs(), 1);
@@ -39170,7 +39431,7 @@ function fail2(message, json) {
39170
39431
  if (json) {
39171
39432
  process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
39172
39433
  } else {
39173
- process.stderr.write(import_picocolors19.default.red(`\u2715 ${message}
39434
+ process.stderr.write(import_picocolors21.default.red(`\u2715 ${message}
39174
39435
  `));
39175
39436
  }
39176
39437
  process.exit(1);
@@ -39313,7 +39574,7 @@ async function deskDeposit(amount, opts) {
39313
39574
  if (units <= 0n) fail2("Deposit amount must be above zero.", opts.json);
39314
39575
  const { keypair, state, created } = await loadOrCreateTradeKey();
39315
39576
  if (created && !opts.json) {
39316
- process.stderr.write(import_picocolors19.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
39577
+ process.stderr.write(import_picocolors21.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
39317
39578
  `));
39318
39579
  }
39319
39580
  const result = await runDeskCeremony({
@@ -39408,13 +39669,13 @@ async function deskSessionRegister(opts) {
39408
39669
  }
39409
39670
  const owner = await loadOrCreateTradeKey();
39410
39671
  if (owner.created && !opts.json) {
39411
- process.stderr.write(import_picocolors19.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
39672
+ process.stderr.write(import_picocolors21.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
39412
39673
  `));
39413
39674
  }
39414
39675
  const session = await loadOrCreateDeskSessionKey();
39415
39676
  if (session.created && !opts.json) {
39416
39677
  process.stderr.write(
39417
- import_picocolors19.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
39678
+ import_picocolors21.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
39418
39679
  `)
39419
39680
  );
39420
39681
  }
@@ -39667,7 +39928,10 @@ program2.command("swap").description(
39667
39928
  "the verbatim user request that triggered this swap (trust-gap defense)"
39668
39929
  ).option(
39669
39930
  "--slippage-bps <n>",
39670
- "slippage tolerance in basis points (1-1000, default 50 = 0.5%)"
39931
+ "slippage tolerance in basis points (default 50 = 0.5%). Slippage is a LOSS BOUND with a hard wall at 100 (1%) \u2014 above it, use --max-loss-bps"
39932
+ ).option(
39933
+ "--max-loss-bps <n>",
39934
+ "LAST RESORT (101-1000): accept losing more than 1% on THIS swap only (e.g. exiting a position fast). The approval screen shows the accepted worst case loud. Never a default"
39671
39935
  ).option("--profile <name>", "named profile (default: 'default')").option(
39672
39936
  "--browser",
39673
39937
  "force open the approval URL (default unless --no-browser or CI=1)"
@@ -39690,6 +39954,42 @@ program2.command("swap").description(
39690
39954
  toChain: opts.toChain,
39691
39955
  chain: opts.chain,
39692
39956
  slippageBps: opts.slippageBps,
39957
+ maxLossBps: opts.maxLossBps,
39958
+ userStated: opts.userStated,
39959
+ profile: opts.profile,
39960
+ browserMode,
39961
+ maxUsd: opts.maxUsd,
39962
+ json: opts.json
39963
+ });
39964
+ }
39965
+ );
39966
+ program2.command("batch").description(
39967
+ "Propose SEVERAL money moves as ONE intent with ONE approval ceremony that shows every leg. Ordered by default (each leg waits for the previous to mine; a failure halts the rest and the journal names what landed). For the agent-payer top-up shape, prefer `agentgates fund <address>`."
39968
+ ).requiredOption(
39969
+ "--legs-json <json>",
39970
+ 'the legs, in execution order, as a JSON array of 2-5 objects: {"kind":"send","to","amount","asset":"native|usdc","chain"} or {"kind":"swap","from_asset","to_asset","amount","from_chain","to_chain?","slippage_bps?","max_loss_bps?"}'
39971
+ ).option("--parallel", "run legs independently instead of in order").requiredOption(
39972
+ "--user-stated <text>",
39973
+ "the verbatim user request that triggered this batch (trust-gap defense)"
39974
+ ).option("--profile <name>", "named profile (default: 'default')").option(
39975
+ "--browser",
39976
+ "force open the approval URL (default unless --no-browser or CI=1)"
39977
+ ).option("--no-browser", "skip opening the approval URL").option(
39978
+ "--max-usd <n>",
39979
+ "USD ceiling for the WHOLE batch (forwarded to user_stated.max_usd_total)"
39980
+ ).option(
39981
+ "--json",
39982
+ "NDJSON output (one object per status flip + final terminal object with the per-leg journal)"
39983
+ ).action(
39984
+ async (opts, command) => {
39985
+ const browserSource = command.getOptionValueSource("browser");
39986
+ let browserMode = "auto";
39987
+ if (browserSource === "cli") {
39988
+ browserMode = opts.browser === false ? "skip" : "open";
39989
+ }
39990
+ await batch({
39991
+ legsJson: opts.legsJson,
39992
+ parallel: opts.parallel,
39693
39993
  userStated: opts.userStated,
39694
39994
  profile: opts.profile,
39695
39995
  browserMode,
@@ -39889,20 +40189,42 @@ program2.command("deliver").description(
39889
40189
  await deliver(id, command ?? [], opts);
39890
40190
  });
39891
40191
  program2.command("fund").description(
39892
- "Fund YOUR OWN bounty's escrow so it goes live. Amount, chain and escrow address are read from the bounty itself; opens your browser for biometric approval, then polls until mined."
39893
- ).argument("<id>", "the bounty id (see bounty mine)").requiredOption(
40192
+ "Two shapes, picked by the target. `fund <bounty-id>`: fund YOUR OWN bounty's escrow so it goes live (amount/chain/escrow read from the bounty). `fund <address> --usdc N --gas M --chain C`: top up a payer wallet in ONE approval ceremony \u2014 the server plans the legs (a shortfall swap sized with headroom when your USDC can't cover) and the ceremony shows the whole plan."
40193
+ ).argument("<target>", "a bounty id (see bounty mine) OR a payer address (0x\u2026 / Solana base58)").requiredOption(
39894
40194
  "--user-stated <text>",
39895
40195
  "the verbatim user request that triggered this funding (trust-gap defense)"
39896
- ).option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option(
40196
+ ).option("--usdc <n>", "address targets only: USDC the payer should receive, display units").option("--gas <n>", "address targets only: native gas the payer should receive, display units").option("--chain <chain>", "address targets only: chain id (1/137/8453/42161/900) or shortName").option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option(
39897
40197
  "--max-usd <n>",
39898
- "your declared USD ceiling for this funding (default: the pairing per-tx cap; the bounty's own amount must fit under it)"
39899
- ).option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (id, opts, command) => {
40198
+ "your declared USD ceiling for this funding (default: the pairing per-tx cap)"
40199
+ ).option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (target, opts, command) => {
39900
40200
  const browserSource = command.getOptionValueSource("browser");
39901
40201
  let browserMode = "auto";
39902
40202
  if (browserSource === "cli") {
39903
40203
  browserMode = opts.browser === false ? "skip" : "open";
39904
40204
  }
39905
- await fundBounty(id, {
40205
+ if (isAddressTarget(target)) {
40206
+ await fundWallet(target, {
40207
+ usdc: opts.usdc,
40208
+ gas: opts.gas,
40209
+ chain: opts.chain ?? "",
40210
+ userStated: opts.userStated,
40211
+ profile: opts.profile,
40212
+ browserMode,
40213
+ maxUsd: opts.maxUsd,
40214
+ json: opts.json
40215
+ });
40216
+ return;
40217
+ }
40218
+ if (opts.usdc || opts.gas || opts.chain) {
40219
+ process.stderr.write(
40220
+ import_picocolors22.default.red(
40221
+ `\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
40222
+ `
40223
+ )
40224
+ );
40225
+ process.exit(2);
40226
+ }
40227
+ await fundBounty(target, {
39906
40228
  userStated: opts.userStated,
39907
40229
  profile: opts.profile,
39908
40230
  browserMode,
@@ -40015,10 +40337,10 @@ desk.command("sell").description("Sell desk coin credit back to the curve (sessi
40015
40337
  await deskSell(coin, amount, opts);
40016
40338
  });
40017
40339
  program2.parseAsync(process.argv).catch((err) => {
40018
- process.stderr.write(import_picocolors20.default.red(`\u2715 ${err.message}
40340
+ process.stderr.write(import_picocolors22.default.red(`\u2715 ${err.message}
40019
40341
  `));
40020
40342
  if (process.env.BOUNTY_DEBUG) {
40021
- process.stderr.write(import_picocolors20.default.dim((err.stack ?? "") + "\n"));
40343
+ process.stderr.write(import_picocolors22.default.dim((err.stack ?? "") + "\n"));
40022
40344
  }
40023
40345
  process.exit(1);
40024
40346
  });