@agentgates/cli 0.19.1 → 0.19.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +634 -520
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -981,7 +981,7 @@ var require_command = __commonJS({
981
981
  "node_modules/commander/lib/command.js"(exports) {
982
982
  var EventEmitter = __require("node:events").EventEmitter;
983
983
  var childProcess2 = __require("node:child_process");
984
- var path6 = __require("node:path");
984
+ var path7 = __require("node:path");
985
985
  var fs10 = __require("node:fs");
986
986
  var process8 = __require("node:process");
987
987
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -1914,9 +1914,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1914
1914
  let launchWithNode = false;
1915
1915
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1916
1916
  function findFile(baseDir, baseName) {
1917
- const localBin = path6.resolve(baseDir, baseName);
1917
+ const localBin = path7.resolve(baseDir, baseName);
1918
1918
  if (fs10.existsSync(localBin)) return localBin;
1919
- if (sourceExt.includes(path6.extname(baseName))) return void 0;
1919
+ if (sourceExt.includes(path7.extname(baseName))) return void 0;
1920
1920
  const foundExt = sourceExt.find(
1921
1921
  (ext) => fs10.existsSync(`${localBin}${ext}`)
1922
1922
  );
@@ -1934,17 +1934,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
1934
1934
  } catch (err) {
1935
1935
  resolvedScriptPath = this._scriptPath;
1936
1936
  }
1937
- executableDir = path6.resolve(
1938
- path6.dirname(resolvedScriptPath),
1937
+ executableDir = path7.resolve(
1938
+ path7.dirname(resolvedScriptPath),
1939
1939
  executableDir
1940
1940
  );
1941
1941
  }
1942
1942
  if (executableDir) {
1943
1943
  let localFile = findFile(executableDir, executableFile);
1944
1944
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1945
- const legacyName = path6.basename(
1945
+ const legacyName = path7.basename(
1946
1946
  this._scriptPath,
1947
- path6.extname(this._scriptPath)
1947
+ path7.extname(this._scriptPath)
1948
1948
  );
1949
1949
  if (legacyName !== this._name) {
1950
1950
  localFile = findFile(
@@ -1955,7 +1955,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1955
1955
  }
1956
1956
  executableFile = localFile || executableFile;
1957
1957
  }
1958
- launchWithNode = sourceExt.includes(path6.extname(executableFile));
1958
+ launchWithNode = sourceExt.includes(path7.extname(executableFile));
1959
1959
  let proc;
1960
1960
  if (process8.platform !== "win32") {
1961
1961
  if (launchWithNode) {
@@ -2795,7 +2795,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2795
2795
  * @return {Command}
2796
2796
  */
2797
2797
  nameFromFilename(filename) {
2798
- this._name = path6.basename(filename, path6.extname(filename));
2798
+ this._name = path7.basename(filename, path7.extname(filename));
2799
2799
  return this;
2800
2800
  }
2801
2801
  /**
@@ -2809,9 +2809,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2809
2809
  * @param {string} [path]
2810
2810
  * @return {(string|null|Command)}
2811
2811
  */
2812
- executableDir(path7) {
2813
- if (path7 === void 0) return this._executableDir;
2814
- this._executableDir = path7;
2812
+ executableDir(path8) {
2813
+ if (path8 === void 0) return this._executableDir;
2814
+ this._executableDir = path8;
2815
2815
  return this;
2816
2816
  }
2817
2817
  /**
@@ -3232,7 +3232,7 @@ var require_constants = __commonJS({
3232
3232
  var require_node_gyp_build = __commonJS({
3233
3233
  "node_modules/node-gyp-build/node-gyp-build.js"(exports, module) {
3234
3234
  var fs10 = __require("fs");
3235
- var path6 = __require("path");
3235
+ var path7 = __require("path");
3236
3236
  var os5 = __require("os");
3237
3237
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
3238
3238
  var vars = process.config && process.config.variables || {};
@@ -3249,21 +3249,21 @@ var require_node_gyp_build = __commonJS({
3249
3249
  return runtimeRequire(load.resolve(dir));
3250
3250
  }
3251
3251
  load.resolve = load.path = function(dir) {
3252
- dir = path6.resolve(dir || ".");
3252
+ dir = path7.resolve(dir || ".");
3253
3253
  try {
3254
- var name = runtimeRequire(path6.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
3254
+ var name = runtimeRequire(path7.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
3255
3255
  if (process.env[name + "_PREBUILD"]) dir = process.env[name + "_PREBUILD"];
3256
3256
  } catch (err) {
3257
3257
  }
3258
3258
  if (!prebuildsOnly) {
3259
- var release = getFirst(path6.join(dir, "build/Release"), matchBuild);
3259
+ var release = getFirst(path7.join(dir, "build/Release"), matchBuild);
3260
3260
  if (release) return release;
3261
- var debug = getFirst(path6.join(dir, "build/Debug"), matchBuild);
3261
+ var debug = getFirst(path7.join(dir, "build/Debug"), matchBuild);
3262
3262
  if (debug) return debug;
3263
3263
  }
3264
3264
  var prebuild = resolve2(dir);
3265
3265
  if (prebuild) return prebuild;
3266
- var nearby = resolve2(path6.dirname(process.execPath));
3266
+ var nearby = resolve2(path7.dirname(process.execPath));
3267
3267
  if (nearby) return nearby;
3268
3268
  var target = [
3269
3269
  "platform=" + platform2,
@@ -3280,14 +3280,14 @@ var require_node_gyp_build = __commonJS({
3280
3280
  ].filter(Boolean).join(" ");
3281
3281
  throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
3282
3282
  function resolve2(dir2) {
3283
- var tuples = readdirSync(path6.join(dir2, "prebuilds")).map(parseTuple);
3283
+ var tuples = readdirSync(path7.join(dir2, "prebuilds")).map(parseTuple);
3284
3284
  var tuple = tuples.filter(matchTuple(platform2, arch2)).sort(compareTuples)[0];
3285
3285
  if (!tuple) return;
3286
- var prebuilds = path6.join(dir2, "prebuilds", tuple.name);
3286
+ var prebuilds = path7.join(dir2, "prebuilds", tuple.name);
3287
3287
  var parsed = readdirSync(prebuilds).map(parseTags);
3288
3288
  var candidates = parsed.filter(matchTags(runtime, abi));
3289
3289
  var winner = candidates.sort(compareTags(runtime))[0];
3290
- if (winner) return path6.join(prebuilds, winner.file);
3290
+ if (winner) return path7.join(prebuilds, winner.file);
3291
3291
  }
3292
3292
  };
3293
3293
  function readdirSync(dir) {
@@ -3299,7 +3299,7 @@ var require_node_gyp_build = __commonJS({
3299
3299
  }
3300
3300
  function getFirst(dir, filter) {
3301
3301
  var files = readdirSync(dir).filter(filter);
3302
- return files[0] && path6.join(dir, files[0]);
3302
+ return files[0] && path7.join(dir, files[0]);
3303
3303
  }
3304
3304
  function matchBuild(name) {
3305
3305
  return /\.node$/.test(name);
@@ -6875,7 +6875,7 @@ var require_package = __commonJS({
6875
6875
  "package.json"(exports, module) {
6876
6876
  module.exports = {
6877
6877
  name: "@agentgates/cli",
6878
- version: "0.19.1",
6878
+ version: "0.19.2",
6879
6879
  description: "Wallet operations for AI agents and humans",
6880
6880
  keywords: [
6881
6881
  "crypto",
@@ -17398,8 +17398,8 @@ var require_dist = __commonJS({
17398
17398
  constructor(failure, failures) {
17399
17399
  let cached;
17400
17400
  const { message, explanation, ...rest } = failure;
17401
- const { path: path6 } = failure;
17402
- const msg = path6.length === 0 ? message : `At path: ${path6.join(".")} -- ${message}`;
17401
+ const { path: path7 } = failure;
17402
+ const msg = path7.length === 0 ? message : `At path: ${path7.join(".")} -- ${message}`;
17403
17403
  super(explanation ?? msg);
17404
17404
  if (explanation != null)
17405
17405
  this.cause = msg;
@@ -17444,15 +17444,15 @@ var require_dist = __commonJS({
17444
17444
  } else if (typeof result === "string") {
17445
17445
  result = { message: result };
17446
17446
  }
17447
- const { path: path6, branch } = context;
17447
+ const { path: path7, branch } = context;
17448
17448
  const { type: type2 } = struct2;
17449
17449
  const { refinement, message = `Expected a value of type \`${type2}\`${refinement ? ` with refinement \`${refinement}\`` : ""}, but received: \`${print(value)}\`` } = result;
17450
17450
  return {
17451
17451
  value,
17452
17452
  type: type2,
17453
17453
  refinement,
17454
- key: path6[path6.length - 1],
17455
- path: path6,
17454
+ key: path7[path7.length - 1],
17455
+ path: path7,
17456
17456
  branch,
17457
17457
  ...result,
17458
17458
  message
@@ -17470,8 +17470,8 @@ var require_dist = __commonJS({
17470
17470
  }
17471
17471
  }
17472
17472
  function* run(value, struct2, options = {}) {
17473
- const { path: path6 = [], branch = [value], coerce: coerce2 = false, mask: mask3 = false } = options;
17474
- const ctx2 = { path: path6, branch, mask: mask3 };
17473
+ const { path: path7 = [], branch = [value], coerce: coerce2 = false, mask: mask3 = false } = options;
17474
+ const ctx2 = { path: path7, branch, mask: mask3 };
17475
17475
  if (coerce2) {
17476
17476
  value = struct2.coercer(value, ctx2);
17477
17477
  }
@@ -17483,7 +17483,7 @@ var require_dist = __commonJS({
17483
17483
  }
17484
17484
  for (let [k, v, s] of struct2.entries(value, ctx2)) {
17485
17485
  const ts = run(v, s, {
17486
- path: k === void 0 ? path6 : [...path6, k],
17486
+ path: k === void 0 ? path7 : [...path7, k],
17487
17487
  branch: k === void 0 ? branch : [...branch, v],
17488
17488
  coerce: coerce2,
17489
17489
  mask: mask3,
@@ -19413,14 +19413,14 @@ var require_url_state_machine = __commonJS({
19413
19413
  return url.replace(/\u0009|\u000A|\u000D/g, "");
19414
19414
  }
19415
19415
  function shortenPath(url) {
19416
- const path6 = url.path;
19417
- if (path6.length === 0) {
19416
+ const path7 = url.path;
19417
+ if (path7.length === 0) {
19418
19418
  return;
19419
19419
  }
19420
- if (url.scheme === "file" && path6.length === 1 && isNormalizedWindowsDriveLetter(path6[0])) {
19420
+ if (url.scheme === "file" && path7.length === 1 && isNormalizedWindowsDriveLetter(path7[0])) {
19421
19421
  return;
19422
19422
  }
19423
- path6.pop();
19423
+ path7.pop();
19424
19424
  }
19425
19425
  function includesCredentials(url) {
19426
19426
  return url.username !== "" || url.password !== "";
@@ -37870,7 +37870,7 @@ var {
37870
37870
  } = import_index.default;
37871
37871
 
37872
37872
  // src/main.ts
37873
- var import_picocolors30 = __toESM(require_picocolors(), 1);
37873
+ var import_picocolors31 = __toESM(require_picocolors(), 1);
37874
37874
 
37875
37875
  // src/commands/login.ts
37876
37876
  var import_picocolors2 = __toESM(require_picocolors(), 1);
@@ -38847,7 +38847,7 @@ function shortAddress(addr) {
38847
38847
  }
38848
38848
 
38849
38849
  // src/commands/onboard.ts
38850
- var import_picocolors10 = __toESM(require_picocolors(), 1);
38850
+ var import_picocolors11 = __toESM(require_picocolors(), 1);
38851
38851
  import { createInterface } from "node:readline/promises";
38852
38852
 
38853
38853
  // src/lib/water.ts
@@ -42033,12 +42033,12 @@ var Result = class _Result extends Array {
42033
42033
  };
42034
42034
  function checkResultErrors(result) {
42035
42035
  const errors = [];
42036
- const checkErrors = function(path6, object2) {
42036
+ const checkErrors = function(path7, object2) {
42037
42037
  if (!Array.isArray(object2)) {
42038
42038
  return;
42039
42039
  }
42040
42040
  for (let key in object2) {
42041
- const childPath = path6.slice();
42041
+ const childPath = path7.slice();
42042
42042
  childPath.push(key);
42043
42043
  try {
42044
42044
  checkErrors(childPath, object2[key]);
@@ -60645,9 +60645,9 @@ var IpcSocketProvider = class extends SocketProvider {
60645
60645
  get socket() {
60646
60646
  return this.#socket;
60647
60647
  }
60648
- constructor(path6, network, options) {
60648
+ constructor(path7, network, options) {
60649
60649
  super(network, options);
60650
- this.#socket = connect(path6);
60650
+ this.#socket = connect(path7);
60651
60651
  this.socket.on("ready", async () => {
60652
60652
  try {
60653
60653
  await this._start();
@@ -61479,11 +61479,11 @@ function getPassword(password) {
61479
61479
  function spelunk(object2, _path) {
61480
61480
  const match = _path.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i);
61481
61481
  assertArgument(match != null, "invalid path", "path", _path);
61482
- const path6 = match[1];
61482
+ const path7 = match[1];
61483
61483
  const type = match[3];
61484
61484
  const reqd = match[4] === "!";
61485
61485
  let cur = object2;
61486
- for (const comp of path6.toLowerCase().split(".")) {
61486
+ for (const comp of path7.toLowerCase().split(".")) {
61487
61487
  if (Array.isArray(cur)) {
61488
61488
  if (!comp.match(/^[0-9]+$/)) {
61489
61489
  break;
@@ -61505,7 +61505,7 @@ function spelunk(object2, _path) {
61505
61505
  break;
61506
61506
  }
61507
61507
  }
61508
- assertArgument(!reqd || cur != null, "missing required value", "path", path6);
61508
+ assertArgument(!reqd || cur != null, "missing required value", "path", path7);
61509
61509
  if (type && cur != null) {
61510
61510
  if (type === "int") {
61511
61511
  if (typeof cur === "string" && cur.match(/^-?[0-9]+$/)) {
@@ -61530,7 +61530,7 @@ function spelunk(object2, _path) {
61530
61530
  if (type === typeof cur) {
61531
61531
  return cur;
61532
61532
  }
61533
- assertArgument(false, `wrong type found for ${type} `, "path", path6);
61533
+ assertArgument(false, `wrong type found for ${type} `, "path", path7);
61534
61534
  }
61535
61535
  return cur;
61536
61536
  }
@@ -61710,7 +61710,7 @@ function _encryptKeystore(key, kdf, account, options) {
61710
61710
  };
61711
61711
  if (account.mnemonic) {
61712
61712
  const client = options.client != null ? options.client : `ethers/${version}`;
61713
- const path6 = account.mnemonic.path || defaultPath;
61713
+ const path7 = account.mnemonic.path || defaultPath;
61714
61714
  const locale = account.mnemonic.locale || "en";
61715
61715
  const mnemonicKey = key.slice(32, 64);
61716
61716
  const entropy = getBytes(account.mnemonic.entropy, "account.mnemonic.entropy");
@@ -61723,7 +61723,7 @@ function _encryptKeystore(key, kdf, account, options) {
61723
61723
  data4["x-ethers"] = {
61724
61724
  client,
61725
61725
  gethFilename,
61726
- path: path6,
61726
+ path: path7,
61727
61727
  locale,
61728
61728
  mnemonicCounter: hexlify(mnemonicIv).substring(2),
61729
61729
  mnemonicCiphertext: hexlify(mnemonicCiphertext).substring(2),
@@ -61791,11 +61791,11 @@ function ser_I(index, chainCode, publicKey, privateKey) {
61791
61791
  const I = getBytes(computeHmac("sha512", chainCode, data4));
61792
61792
  return { IL: I.slice(0, 32), IR: I.slice(32) };
61793
61793
  }
61794
- function derivePath(node, path6) {
61795
- const components = path6.split("/");
61796
- assertArgument(components.length > 0, "invalid path", "path", path6);
61794
+ function derivePath(node, path7) {
61795
+ const components = path7.split("/");
61796
+ assertArgument(components.length > 0, "invalid path", "path", path7);
61797
61797
  if (components[0] === "m") {
61798
- assertArgument(node.depth === 0, `cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${node.depth}`, "path", path6);
61798
+ assertArgument(node.depth === 0, `cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${node.depth}`, "path", path7);
61799
61799
  components.shift();
61800
61800
  }
61801
61801
  let result = node;
@@ -61865,7 +61865,7 @@ var HDNodeWallet = class _HDNodeWallet extends BaseWallet {
61865
61865
  /**
61866
61866
  * @private
61867
61867
  */
61868
- constructor(guard, signingKey, parentFingerprint, chainCode, path6, index, depth, mnemonic, provider) {
61868
+ constructor(guard, signingKey, parentFingerprint, chainCode, path7, index, depth, mnemonic, provider) {
61869
61869
  super(signingKey, provider);
61870
61870
  assertPrivate(guard, _guard6, "HDNodeWallet");
61871
61871
  defineProperties(this, { publicKey: signingKey.compressedPublicKey });
@@ -61874,7 +61874,7 @@ var HDNodeWallet = class _HDNodeWallet extends BaseWallet {
61874
61874
  parentFingerprint,
61875
61875
  fingerprint,
61876
61876
  chainCode,
61877
- path: path6,
61877
+ path: path7,
61878
61878
  index,
61879
61879
  depth
61880
61880
  });
@@ -61958,22 +61958,22 @@ var HDNodeWallet = class _HDNodeWallet extends BaseWallet {
61958
61958
  deriveChild(_index) {
61959
61959
  const index = getNumber(_index, "index");
61960
61960
  assertArgument(index <= 4294967295, "invalid index", "index", index);
61961
- let path6 = this.path;
61962
- if (path6) {
61963
- path6 += "/" + (index & ~HardenedBit);
61961
+ let path7 = this.path;
61962
+ if (path7) {
61963
+ path7 += "/" + (index & ~HardenedBit);
61964
61964
  if (index & HardenedBit) {
61965
- path6 += "'";
61965
+ path7 += "'";
61966
61966
  }
61967
61967
  }
61968
61968
  const { IR, IL } = ser_I(index, this.chainCode, this.publicKey, this.privateKey);
61969
61969
  const ki = new SigningKey(toBeHex((toBigInt(IL) + BigInt(this.privateKey)) % N2, 32));
61970
- return new _HDNodeWallet(_guard6, ki, this.fingerprint, hexlify(IR), path6, index, this.depth + 1, this.mnemonic, this.provider);
61970
+ return new _HDNodeWallet(_guard6, ki, this.fingerprint, hexlify(IR), path7, index, this.depth + 1, this.mnemonic, this.provider);
61971
61971
  }
61972
61972
  /**
61973
61973
  * Return the HDNode for %%path%% from this node.
61974
61974
  */
61975
- derivePath(path6) {
61976
- return derivePath(this, path6);
61975
+ derivePath(path7) {
61976
+ return derivePath(this, path7);
61977
61977
  }
61978
61978
  static #fromSeed(_seed, mnemonic) {
61979
61979
  assertArgument(isBytesLike(_seed), "invalid seed", "seed", "[REDACTED]");
@@ -62018,43 +62018,43 @@ var HDNodeWallet = class _HDNodeWallet extends BaseWallet {
62018
62018
  /**
62019
62019
  * Creates a new random HDNode.
62020
62020
  */
62021
- static createRandom(password, path6, wordlist9) {
62021
+ static createRandom(password, path7, wordlist9) {
62022
62022
  if (password == null) {
62023
62023
  password = "";
62024
62024
  }
62025
- if (path6 == null) {
62026
- path6 = defaultPath2;
62025
+ if (path7 == null) {
62026
+ path7 = defaultPath2;
62027
62027
  }
62028
62028
  if (wordlist9 == null) {
62029
62029
  wordlist9 = LangEn.wordlist();
62030
62030
  }
62031
62031
  const mnemonic = Mnemonic.fromEntropy(randomBytes3(16), password, wordlist9);
62032
- return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path6);
62032
+ return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path7);
62033
62033
  }
62034
62034
  /**
62035
62035
  * Create an HD Node from %%mnemonic%%.
62036
62036
  */
62037
- static fromMnemonic(mnemonic, path6) {
62038
- if (!path6) {
62039
- path6 = defaultPath2;
62037
+ static fromMnemonic(mnemonic, path7) {
62038
+ if (!path7) {
62039
+ path7 = defaultPath2;
62040
62040
  }
62041
- return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path6);
62041
+ return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path7);
62042
62042
  }
62043
62043
  /**
62044
62044
  * Creates an HD Node from a mnemonic %%phrase%%.
62045
62045
  */
62046
- static fromPhrase(phrase, password, path6, wordlist9) {
62046
+ static fromPhrase(phrase, password, path7, wordlist9) {
62047
62047
  if (password == null) {
62048
62048
  password = "";
62049
62049
  }
62050
- if (path6 == null) {
62051
- path6 = defaultPath2;
62050
+ if (path7 == null) {
62051
+ path7 = defaultPath2;
62052
62052
  }
62053
62053
  if (wordlist9 == null) {
62054
62054
  wordlist9 = LangEn.wordlist();
62055
62055
  }
62056
62056
  const mnemonic = Mnemonic.fromPhrase(phrase, password, wordlist9);
62057
- return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path6);
62057
+ return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path7);
62058
62058
  }
62059
62059
  /**
62060
62060
  * Creates an HD Node from a %%seed%%.
@@ -62106,7 +62106,7 @@ var HDNodeVoidWallet = class _HDNodeVoidWallet extends VoidSigner {
62106
62106
  /**
62107
62107
  * @private
62108
62108
  */
62109
- constructor(guard, address, publicKey, parentFingerprint, chainCode, path6, index, depth, provider) {
62109
+ constructor(guard, address, publicKey, parentFingerprint, chainCode, path7, index, depth, provider) {
62110
62110
  super(address, provider);
62111
62111
  assertPrivate(guard, _guard6, "HDNodeVoidWallet");
62112
62112
  defineProperties(this, { publicKey });
@@ -62116,7 +62116,7 @@ var HDNodeVoidWallet = class _HDNodeVoidWallet extends VoidSigner {
62116
62116
  fingerprint,
62117
62117
  parentFingerprint,
62118
62118
  chainCode,
62119
- path: path6,
62119
+ path: path7,
62120
62120
  index,
62121
62121
  depth
62122
62122
  });
@@ -62154,23 +62154,23 @@ var HDNodeVoidWallet = class _HDNodeVoidWallet extends VoidSigner {
62154
62154
  deriveChild(_index) {
62155
62155
  const index = getNumber(_index, "index");
62156
62156
  assertArgument(index <= 4294967295, "invalid index", "index", index);
62157
- let path6 = this.path;
62158
- if (path6) {
62159
- path6 += "/" + (index & ~HardenedBit);
62157
+ let path7 = this.path;
62158
+ if (path7) {
62159
+ path7 += "/" + (index & ~HardenedBit);
62160
62160
  if (index & HardenedBit) {
62161
- path6 += "'";
62161
+ path7 += "'";
62162
62162
  }
62163
62163
  }
62164
62164
  const { IR, IL } = ser_I(index, this.chainCode, this.publicKey, null);
62165
62165
  const Ki = SigningKey.addPoints(IL, this.publicKey, true);
62166
62166
  const address = computeAddress(Ki);
62167
- return new _HDNodeVoidWallet(_guard6, address, Ki, this.fingerprint, hexlify(IR), path6, index, this.depth + 1, this.provider);
62167
+ return new _HDNodeVoidWallet(_guard6, address, Ki, this.fingerprint, hexlify(IR), path7, index, this.depth + 1, this.provider);
62168
62168
  }
62169
62169
  /**
62170
62170
  * Return the signer for %%path%% from this node.
62171
62171
  */
62172
- derivePath(path6) {
62173
- return derivePath(this, path6);
62172
+ derivePath(path7) {
62173
+ return derivePath(this, path7);
62174
62174
  }
62175
62175
  };
62176
62176
  function getAccountPath(_index) {
@@ -63003,25 +63003,25 @@ var WireError = class extends Error {
63003
63003
  code;
63004
63004
  body;
63005
63005
  };
63006
- async function ownerAuthHeader(wallet, method, path6) {
63006
+ async function ownerAuthHeader(wallet, method, path7) {
63007
63007
  const timestamp = Math.floor(Date.now() / 1e3);
63008
63008
  const nonce = randomBytes4(16).toString("hex");
63009
63009
  const signature = await wallet.signMessage(`${method.toUpperCase()}
63010
- ${path6}
63010
+ ${path7}
63011
63011
  ${nonce}
63012
63012
  ${timestamp}`);
63013
63013
  return Buffer.from(JSON.stringify({ address: wallet.address, timestamp, nonce, signature })).toString("base64");
63014
63014
  }
63015
- async function signedFetch(wallet, method, path6, body, timeoutMs = 13e4) {
63015
+ async function signedFetch(wallet, method, path7, body, timeoutMs = 13e4) {
63016
63016
  const headers = {
63017
63017
  accept: "application/json",
63018
63018
  "user-agent": CLI_USER_AGENT,
63019
- "x-wallet-auth": await ownerAuthHeader(wallet, method, path6)
63019
+ "x-wallet-auth": await ownerAuthHeader(wallet, method, path7)
63020
63020
  };
63021
63021
  if (body !== void 0) headers["content-type"] = "application/json";
63022
63022
  let res;
63023
63023
  try {
63024
- res = await fetch(`${identityOrigin()}${path6}`, {
63024
+ res = await fetch(`${identityOrigin()}${path7}`, {
63025
63025
  method,
63026
63026
  headers,
63027
63027
  body: body !== void 0 ? JSON.stringify(body) : void 0,
@@ -64562,6 +64562,126 @@ async function browserTask(id2, opts) {
64562
64562
  }
64563
64563
  }
64564
64564
 
64565
+ // src/lib/self-update.ts
64566
+ import { existsSync, readFileSync as readFileSync2 } from "node:fs";
64567
+ import path4 from "node:path";
64568
+ import { spawn } from "node:child_process";
64569
+ var PKG = "@agentgates/cli";
64570
+ var LOCAL_VERSION = require_package().version;
64571
+ function olderThan(a, b2) {
64572
+ const num = (v) => v.replace(/^v/, "").split("-")[0].split(".").map((n2) => parseInt(n2, 10) || 0);
64573
+ const [x, y] = [num(a), num(b2)];
64574
+ for (let i = 0; i < Math.max(x.length, y.length); i++) {
64575
+ const d = (y[i] ?? 0) - (x[i] ?? 0);
64576
+ if (d !== 0) return d > 0;
64577
+ }
64578
+ return false;
64579
+ }
64580
+ async function fetchLatest(timeoutMs = 2500) {
64581
+ try {
64582
+ const ctl = new AbortController();
64583
+ const timer = setTimeout(() => ctl.abort(), timeoutMs);
64584
+ const res = await fetch(`https://registry.npmjs.org/${PKG}/latest`, { headers: { accept: "application/json" }, signal: ctl.signal }).finally(() => clearTimeout(timer));
64585
+ if (!res.ok) return null;
64586
+ const { version: version4 } = await res.json();
64587
+ return typeof version4 === "string" ? version4 : null;
64588
+ } catch {
64589
+ return null;
64590
+ }
64591
+ }
64592
+ function installPlace(binPath = process.argv[1] ?? "", env = process.env) {
64593
+ const real = path4.resolve(binPath);
64594
+ const home = env.AGENTGATES_HOME || agentgatesHome();
64595
+ const homePkg = path4.join(home, "node_modules", ...PKG.split("/"));
64596
+ if (real.startsWith(path4.resolve(homePkg) + path4.sep)) {
64597
+ return { kind: "home", home, command: ["install", "--prefix", home, "--prefer-online", "--ignore-scripts", "--no-fund", "--no-audit", `${PKG}@latest`] };
64598
+ }
64599
+ const pkgDir = path4.resolve(path4.dirname(real), "..");
64600
+ if (existsSync(path4.join(pkgDir, "src", "main.ts"))) return { kind: "checkout", dir: pkgDir };
64601
+ return { kind: "global", command: ["install", "-g", "--prefer-online", "--ignore-scripts", "--no-fund", "--no-audit", `${PKG}@latest`] };
64602
+ }
64603
+ function runNpm(args) {
64604
+ return new Promise((resolve2) => {
64605
+ const child = spawn("npm", args, { stdio: "inherit", env: { ...process.env, NODE_NO_WARNINGS: "1" } });
64606
+ child.on("error", () => resolve2(127));
64607
+ child.on("exit", (code) => resolve2(code ?? 1));
64608
+ });
64609
+ }
64610
+ function installedVersionAt(place) {
64611
+ try {
64612
+ if (place.kind === "home") {
64613
+ return JSON.parse(readFileSync2(path4.join(place.home, "node_modules", ...PKG.split("/"), "package.json"), "utf8")).version ?? null;
64614
+ }
64615
+ if (place.kind === "checkout") {
64616
+ return JSON.parse(readFileSync2(path4.join(place.dir, "package.json"), "utf8")).version ?? null;
64617
+ }
64618
+ } catch {
64619
+ return null;
64620
+ }
64621
+ return null;
64622
+ }
64623
+
64624
+ // src/commands/update.ts
64625
+ var import_picocolors10 = __toESM(require_picocolors(), 1);
64626
+ var jsonMode4 = (opts) => opts.json === true || !process.stdout.isTTY;
64627
+ async function update(opts = {}) {
64628
+ const latest = await fetchLatest();
64629
+ const place = installPlace();
64630
+ const stale = !!latest && olderThan(LOCAL_VERSION, latest);
64631
+ const base = { ok: true, package: PKG, current: LOCAL_VERSION, latest, stale, runsFrom: place.kind, ...place.kind === "home" ? { home: place.home } : place.kind === "checkout" ? { dir: place.dir } : {} };
64632
+ if (!latest) {
64633
+ if (jsonMode4(opts)) process.stdout.write(JSON.stringify({ ...base, ok: false, code: "registry_unreachable", error: "npm's registry did not answer; try again in a moment" }, null, 2) + "\n");
64634
+ else process.stderr.write(` ${import_picocolors10.default.red("\u2715")} npm's registry did not answer; try again in a moment
64635
+ `);
64636
+ process.exit(1);
64637
+ }
64638
+ if (opts.check || !stale) {
64639
+ if (jsonMode4(opts)) process.stdout.write(JSON.stringify(base, null, 2) + "\n");
64640
+ else if (stale) process.stdout.write(`
64641
+ ${import_picocolors10.default.yellow("\u2191")} ${latest} is out; this copy is ${LOCAL_VERSION}. ${import_picocolors10.default.dim("agentgates update \xB7 installs it")}
64642
+
64643
+ `);
64644
+ else process.stdout.write(`
64645
+ ${import_picocolors10.default.green("\u2713")} ${LOCAL_VERSION} is the latest
64646
+
64647
+ `);
64648
+ return;
64649
+ }
64650
+ if (place.kind === "checkout") {
64651
+ const line = `cd ${place.dir} && git pull --ff-only && npm run build`;
64652
+ if (jsonMode4(opts)) process.stdout.write(JSON.stringify({ ...base, ok: false, code: "checkout", line, error: "this copy runs from a repository checkout; pull it" }, null, 2) + "\n");
64653
+ else process.stdout.write(`
64654
+ this copy runs from a checkout at ${import_picocolors10.default.bold(place.dir)}; update it with
64655
+ ${import_picocolors10.default.cyan(line)}
64656
+
64657
+ `);
64658
+ return;
64659
+ }
64660
+ if (!jsonMode4(opts)) process.stdout.write(`
64661
+ ${import_picocolors10.default.bold("UPDATE")} ${LOCAL_VERSION} \u2192 ${latest} ${import_picocolors10.default.dim(place.kind === "home" ? `into ${place.home}` : "the global npm install")}
64662
+ ${import_picocolors10.default.dim(`npm ${place.command.join(" ")}`)}
64663
+
64664
+ `);
64665
+ const code = await runNpm(place.command);
64666
+ const now = installedVersionAt(place);
64667
+ const done = code === 0 && (place.kind !== "home" || now === latest);
64668
+ if (jsonMode4(opts)) {
64669
+ process.stdout.write(JSON.stringify({ ...base, ok: done, code: done ? void 0 : "npm_failed", installed: now ?? void 0, exit: code }, null, 2) + "\n");
64670
+ } else if (done) {
64671
+ process.stdout.write(`
64672
+ ${import_picocolors10.default.green("\u2713")} ${PKG} ${now ?? latest} is in. New terminals run it; this one already did.
64673
+
64674
+ `);
64675
+ } else {
64676
+ process.stderr.write(`
64677
+ ${import_picocolors10.default.red("\u2715")} npm exited ${code}. Run it by hand to see why:
64678
+ npm ${place.command.join(" ")}
64679
+
64680
+ `);
64681
+ }
64682
+ if (!done) process.exit(1);
64683
+ }
64684
+
64565
64685
  // src/commands/onboard.ts
64566
64686
  var WORDMARK = [
64567
64687
  " _ _",
@@ -64571,33 +64691,14 @@ var WORDMARK = [
64571
64691
  " |___/ |___/"
64572
64692
  ].join("\n");
64573
64693
  var TAGLINE = "Confidential virtual machines, inference, phone numbers and email, paid per use in USDC.";
64574
- var { version: LOCAL_VERSION } = require_package();
64575
- function olderThan(a, b2) {
64576
- const pa = a.split(".").map(Number);
64577
- const pb = b2.split(".").map(Number);
64578
- for (let i = 0; i < 3; i++) {
64579
- if ((pa[i] ?? 0) < (pb[i] ?? 0)) return true;
64580
- if ((pa[i] ?? 0) > (pb[i] ?? 0)) return false;
64581
- }
64582
- return false;
64583
- }
64694
+ var latestSeen = null;
64584
64695
  async function staleLine() {
64585
- try {
64586
- const ctl = new AbortController();
64587
- const timer = setTimeout(() => ctl.abort(), 900);
64588
- const res = await fetch("https://registry.npmjs.org/@agentgates/cli/latest", {
64589
- headers: { accept: "application/json" },
64590
- signal: ctl.signal
64591
- }).finally(() => clearTimeout(timer));
64592
- if (!res.ok) return null;
64593
- const { version: latest } = await res.json();
64594
- if (!latest || !olderThan(LOCAL_VERSION, latest)) return null;
64595
- return ` ${import_picocolors10.default.yellow("\u2191")} ${latest} is out, this copy is ${LOCAL_VERSION} \xB7 curl -fsSL ${CREATORS_ORIGIN}/api/cli/install | sh
64696
+ const latest = await fetchLatest(900);
64697
+ if (!latest || !olderThan(LOCAL_VERSION, latest)) return null;
64698
+ latestSeen = latest;
64699
+ return ` ${import_picocolors11.default.yellow("\u2191")} ${latest} is out, this copy is ${LOCAL_VERSION} \xB7 ${import_picocolors11.default.bold("agentgates update")} installs it
64596
64700
 
64597
64701
  `;
64598
- } catch {
64599
- return null;
64600
- }
64601
64702
  }
64602
64703
  function makePut(w) {
64603
64704
  return (s) => {
@@ -64607,14 +64708,15 @@ function makePut(w) {
64607
64708
  }
64608
64709
  function banner() {
64609
64710
  const w = water();
64610
- if (!w) process.stdout.write("\n" + import_picocolors10.default.cyan(WORDMARK) + "\n\n");
64711
+ if (!w) process.stdout.write("\n" + import_picocolors11.default.cyan(WORDMARK) + "\n\n");
64611
64712
  const put = makePut(w);
64612
- put(` ${import_picocolors10.default.dim(TAGLINE)}
64713
+ put(` ${import_picocolors11.default.dim(TAGLINE)}
64613
64714
 
64614
64715
  `);
64615
64716
  return { w, put };
64616
64717
  }
64617
64718
  var MENU = {
64719
+ update: { label: "update the CLI to the latest", hint: "(agentgates update)" },
64618
64720
  account: { label: "log in: mint my twelve words, or show my account", hint: "(agentgates init)" },
64619
64721
  seed: { label: "show my twelve words", hint: "(agentgates init --reveal-seed)" },
64620
64722
  balance: { label: "my balance and the address that tops it up", hint: "(agentgates browser balance)" },
@@ -64642,17 +64744,17 @@ function lanesLedBy(lane) {
64642
64744
  const lead = leadLane(lane);
64643
64745
  return [lead, ...LANE_ORDER.filter((l) => l !== lead)];
64644
64746
  }
64645
- function menuOrder(lane, hasAccount) {
64747
+ function menuOrder(lane, hasAccount, stale) {
64646
64748
  const browse = lanesLedBy(lane).map((l) => LANES[l].key);
64647
64749
  const account = hasAccount ? ["account", "seed", "balance"] : ["account"];
64648
- return [...account, ...browse, "docs", "poke", "wallet"];
64750
+ return [...stale ? ["update"] : [], ...account, ...browse, "docs", "poke", "wallet"];
64649
64751
  }
64650
64752
  function printMenu(put, order, first) {
64651
- put(` ${import_picocolors10.default.bold(first ? "choose how to start:" : "what next:")}
64753
+ put(` ${import_picocolors11.default.bold(first ? "choose how to start:" : "what next:")}
64652
64754
  `);
64653
64755
  order.forEach((k, i) => {
64654
64756
  const item = MENU[k];
64655
- put(` ${import_picocolors10.default.cyan(`${i + 1}.`)} ${item.label}${item.hint ? ` ${import_picocolors10.default.dim(item.hint)}` : ""}
64757
+ put(` ${import_picocolors11.default.cyan(`${i + 1}.`)} ${item.label}${item.hint ? ` ${import_picocolors11.default.dim(item.hint)}` : ""}
64656
64758
  `);
64657
64759
  });
64658
64760
  }
@@ -64664,17 +64766,17 @@ async function printDocs(put, lane) {
64664
64766
  if (!res.ok) throw new Error(String(res.status));
64665
64767
  const md = (await res.text()).replace(/\s+$/, "");
64666
64768
  put(`
64667
- ${import_picocolors10.default.bold(`THE ${LANES[lead].name.toUpperCase()} CONTRACT`)} ${import_picocolors10.default.dim(url(lead))}
64769
+ ${import_picocolors11.default.bold(`THE ${LANES[lead].name.toUpperCase()} CONTRACT`)} ${import_picocolors11.default.dim(url(lead))}
64668
64770
 
64669
64771
  `);
64670
64772
  put(md + "\n\n");
64671
- for (const other of others) put(` ${import_picocolors10.default.dim(`the ${LANES[other].name} contract:`)} ${url(other)}
64773
+ for (const other of others) put(` ${import_picocolors11.default.dim(`the ${LANES[other].name} contract:`)} ${url(other)}
64672
64774
  `);
64673
64775
  put("\n");
64674
64776
  } catch {
64675
- put(` ${import_picocolors10.default.red("\u2715")} could not fetch the contract; the URLs:
64777
+ put(` ${import_picocolors11.default.red("\u2715")} could not fetch the contract; the URLs:
64676
64778
  `);
64677
- for (const l of LANE_ORDER) put(` ${import_picocolors10.default.cyan(LANES[l].name.padEnd(16))} ${url(l)}
64779
+ for (const l of LANE_ORDER) put(` ${import_picocolors11.default.cyan(LANES[l].name.padEnd(16))} ${url(l)}
64678
64780
  `);
64679
64781
  put("\n");
64680
64782
  }
@@ -64684,16 +64786,16 @@ async function onboard(opts = {}) {
64684
64786
  const { w, put } = banner();
64685
64787
  const existing = await loadProfile(profileName).catch(() => null);
64686
64788
  if (existing) {
64687
- put(` ${import_picocolors10.default.green("\u2713")} already paired as ${import_picocolors10.default.bold(existing.walletAddress ?? existing.userId)}
64789
+ put(` ${import_picocolors11.default.green("\u2713")} already paired as ${import_picocolors11.default.bold(existing.walletAddress ?? existing.userId)}
64688
64790
  `);
64689
64791
  }
64690
64792
  const account = await loadPasswordsKey().catch(() => null);
64691
64793
  if (account) {
64692
- put(` ${import_picocolors10.default.green("\u2713")} logged in as ${import_picocolors10.default.bold(account.state.address)} ${import_picocolors10.default.dim(account.state.mnemonic ? "(twelve words on this machine)" : "(a bare key)")}
64794
+ put(` ${import_picocolors11.default.green("\u2713")} logged in as ${import_picocolors11.default.bold(account.state.address)} ${import_picocolors11.default.dim(account.state.mnemonic ? "(twelve words on this machine)" : "(a bare key)")}
64693
64795
 
64694
64796
  `);
64695
64797
  } else {
64696
- put(` ${import_picocolors10.default.dim("no account on this machine yet: option 1 mints your twelve words")}
64798
+ put(` ${import_picocolors11.default.dim("no account on this machine yet: option 1 mints your twelve words")}
64697
64799
 
64698
64800
  `);
64699
64801
  }
@@ -64701,39 +64803,39 @@ async function onboard(opts = {}) {
64701
64803
  put(` No terminal attached, so no menu. The machine door:
64702
64804
 
64703
64805
  `);
64704
- put(` agentgates compute plans --json ${import_picocolors10.default.dim("\xB7 virtual machine pricing, JSON")}
64806
+ put(` agentgates compute plans --json ${import_picocolors11.default.dim("\xB7 virtual machine pricing, JSON")}
64705
64807
  `);
64706
- put(` agentgates inference models --json ${import_picocolors10.default.dim("\xB7 model pricing, JSON; --tier --tag --org --search filter it")}
64808
+ put(` agentgates inference models --json ${import_picocolors11.default.dim("\xB7 model pricing, JSON; --tier --tag --org --search filter it")}
64707
64809
  `);
64708
- put(` agentgates phone pricing --json ${import_picocolors10.default.dim("\xB7 number plans, usage and payphone windows, JSON")}
64810
+ put(` agentgates phone pricing --json ${import_picocolors11.default.dim("\xB7 number plans, usage and payphone windows, JSON")}
64709
64811
  `);
64710
- put(` agentgates email pricing --json ${import_picocolors10.default.dim("\xB7 the free inbox, plans and per-send price, JSON")}
64812
+ put(` agentgates email pricing --json ${import_picocolors11.default.dim("\xB7 the free inbox, plans and per-send price, JSON")}
64711
64813
  `);
64712
- put(` agentgates passwords pricing --json ${import_picocolors10.default.dim("\xB7 plans and per-use meter")}
64814
+ put(` agentgates passwords pricing --json ${import_picocolors11.default.dim("\xB7 plans and per-use meter")}
64713
64815
  `);
64714
- put(` agentgates init ${import_picocolors10.default.dim("\xB7 mint your twelve words: your account, printed once with what to tell your human")}
64816
+ put(` agentgates init ${import_picocolors11.default.dim("\xB7 mint your twelve words: your account, printed once with what to tell your human")}
64715
64817
  `);
64716
- put(` agentgates init --reveal-seed ${import_picocolors10.default.dim("\xB7 print them again")}
64818
+ put(` agentgates init --reveal-seed ${import_picocolors11.default.dim("\xB7 print them again")}
64717
64819
  `);
64718
- put(` agentgates browser balance --json ${import_picocolors10.default.dim("\xB7 your balance and the address that tops it up (USDC on Base or Polygon)")}
64820
+ put(` agentgates browser balance --json ${import_picocolors11.default.dim("\xB7 your balance and the address that tops it up (USDC on Base or Polygon)")}
64719
64821
  `);
64720
- put(` agentgates open ${import_picocolors10.default.dim("\xB7 hand this session to a human's browser on this machine")}
64822
+ put(` agentgates open ${import_picocolors11.default.dim("\xB7 hand this session to a human's browser on this machine")}
64721
64823
  `);
64722
- put(` ${CREATORS_ORIGIN}/api/compute/docs ${import_picocolors10.default.dim("\xB7 the buy/read/renew/destroy contract")}
64824
+ put(` ${CREATORS_ORIGIN}/api/compute/docs ${import_picocolors11.default.dim("\xB7 the buy/read/renew/destroy contract")}
64723
64825
  `);
64724
- put(` ${CREATORS_ORIGIN}/api/inference/docs ${import_picocolors10.default.dim("\xB7 the chat contract, x402 or Bearer")}
64826
+ put(` ${CREATORS_ORIGIN}/api/inference/docs ${import_picocolors11.default.dim("\xB7 the chat contract, x402 or Bearer")}
64725
64827
  `);
64726
- put(` ${CREATORS_ORIGIN}/api/identity/docs/phone ${import_picocolors10.default.dim("\xB7 the phone contract: numbers, texts, calls, the payphone")}
64828
+ put(` ${CREATORS_ORIGIN}/api/identity/docs/phone ${import_picocolors11.default.dim("\xB7 the phone contract: numbers, texts, calls, the payphone")}
64727
64829
  `);
64728
- put(` ${CREATORS_ORIGIN}/api/identity/docs/email ${import_picocolors10.default.dim("\xB7 the email contract: inboxes, plans, sends, wait-code")}
64830
+ put(` ${CREATORS_ORIGIN}/api/identity/docs/email ${import_picocolors11.default.dim("\xB7 the email contract: inboxes, plans, sends, wait-code")}
64729
64831
  `);
64730
- put(` ${CREATORS_ORIGIN}/api/identity/docs/passwords ${import_picocolors10.default.dim("\xB7 the passwords contract: store, permits, uses")}
64832
+ put(` ${CREATORS_ORIGIN}/api/identity/docs/passwords ${import_picocolors11.default.dim("\xB7 the passwords contract: store, permits, uses")}
64731
64833
  `);
64732
- put(` ${CREATORS_ORIGIN}/llms.txt ${import_picocolors10.default.dim("\xB7 the whole surface")}
64834
+ put(` ${CREATORS_ORIGIN}/llms.txt ${import_picocolors11.default.dim("\xB7 the whole surface")}
64733
64835
 
64734
64836
  `);
64735
64837
  if (!existing) {
64736
- put(` Pairing a wallet needs a human at a browser: ${import_picocolors10.default.bold("agentgates onboard")} in a real terminal.
64838
+ put(` Pairing a wallet needs a human at a browser: ${import_picocolors11.default.bold("agentgates onboard")} in a real terminal.
64737
64839
 
64738
64840
  `);
64739
64841
  }
@@ -64743,7 +64845,7 @@ async function onboard(opts = {}) {
64743
64845
  }
64744
64846
  const stale = await staleLine();
64745
64847
  if (stale) put(stale);
64746
- const order = menuOrder(opts.lane, !!account).filter((k) => existing ? k !== "wallet" : true);
64848
+ const order = menuOrder(opts.lane, !!account, latestSeen !== null).filter((k) => existing ? k !== "wallet" : true);
64747
64849
  printMenu(put, order, true);
64748
64850
  const rl = createInterface({ input: process.stdin, output: process.stdout });
64749
64851
  const exitDefault = String(order.indexOf("poke") + 1);
@@ -64754,7 +64856,7 @@ async function onboard(opts = {}) {
64754
64856
  const fallback = first ? "1" : exitDefault;
64755
64857
  let choice;
64756
64858
  try {
64757
- choice = (await rl.question(` ${import_picocolors10.default.dim(`choice [${fallback}]:`)} `)).trim() || fallback;
64859
+ choice = (await rl.question(` ${import_picocolors11.default.dim(`choice [${fallback}]:`)} `)).trim() || fallback;
64758
64860
  } catch {
64759
64861
  if (first) w?.stop();
64760
64862
  process.stdout.write("\n");
@@ -64778,7 +64880,16 @@ async function onboard(opts = {}) {
64778
64880
  await runLoginFlow({ profile: profileName, jsonMode: false, ttyHeader: "Pairing this terminal with your wallet\u2026" });
64779
64881
  process.stdout.write("\n");
64780
64882
  } catch {
64781
- plain(` ${import_picocolors10.default.red("\u2715")} pairing didn't complete
64883
+ plain(` ${import_picocolors11.default.red("\u2715")} pairing didn't complete
64884
+
64885
+ `);
64886
+ }
64887
+ break;
64888
+ case "update":
64889
+ try {
64890
+ await update({});
64891
+ } catch {
64892
+ plain(` ${import_picocolors11.default.red("\u2715")} the update did not run; try: agentgates update
64782
64893
 
64783
64894
  `);
64784
64895
  }
@@ -64787,7 +64898,7 @@ async function onboard(opts = {}) {
64787
64898
  try {
64788
64899
  await passwordsInit({});
64789
64900
  } catch {
64790
- plain(` ${import_picocolors10.default.red("\u2715")} the account could not be read or minted
64901
+ plain(` ${import_picocolors11.default.red("\u2715")} the account could not be read or minted
64791
64902
 
64792
64903
  `);
64793
64904
  }
@@ -64796,7 +64907,7 @@ async function onboard(opts = {}) {
64796
64907
  try {
64797
64908
  await passwordsInit({ revealSeed: true });
64798
64909
  } catch {
64799
- plain(` ${import_picocolors10.default.red("\u2715")} the words could not be read
64910
+ plain(` ${import_picocolors11.default.red("\u2715")} the words could not be read
64800
64911
 
64801
64912
  `);
64802
64913
  }
@@ -64805,7 +64916,7 @@ async function onboard(opts = {}) {
64805
64916
  try {
64806
64917
  await browserBalance({});
64807
64918
  } catch {
64808
- plain(` ${import_picocolors10.default.red("\u2715")} the balance could not be read
64919
+ plain(` ${import_picocolors11.default.red("\u2715")} the balance could not be read
64809
64920
 
64810
64921
  `);
64811
64922
  }
@@ -64814,7 +64925,7 @@ async function onboard(opts = {}) {
64814
64925
  try {
64815
64926
  await computePlans({});
64816
64927
  } catch {
64817
- plain(` ${import_picocolors10.default.red("\u2715")} could not read the compute catalog
64928
+ plain(` ${import_picocolors11.default.red("\u2715")} could not read the compute catalog
64818
64929
 
64819
64930
  `);
64820
64931
  }
@@ -64823,7 +64934,7 @@ async function onboard(opts = {}) {
64823
64934
  try {
64824
64935
  await inferenceModels({});
64825
64936
  } catch {
64826
- plain(` ${import_picocolors10.default.red("\u2715")} could not read the model catalog
64937
+ plain(` ${import_picocolors11.default.red("\u2715")} could not read the model catalog
64827
64938
 
64828
64939
  `);
64829
64940
  }
@@ -64832,7 +64943,7 @@ async function onboard(opts = {}) {
64832
64943
  try {
64833
64944
  await phonePricing({});
64834
64945
  } catch {
64835
- plain(` ${import_picocolors10.default.red("\u2715")} could not read the phone catalog
64946
+ plain(` ${import_picocolors11.default.red("\u2715")} could not read the phone catalog
64836
64947
 
64837
64948
  `);
64838
64949
  }
@@ -64841,7 +64952,7 @@ async function onboard(opts = {}) {
64841
64952
  try {
64842
64953
  await emailPricing({});
64843
64954
  } catch {
64844
- plain(` ${import_picocolors10.default.red("\u2715")} could not read the email catalog
64955
+ plain(` ${import_picocolors11.default.red("\u2715")} could not read the email catalog
64845
64956
 
64846
64957
  `);
64847
64958
  }
@@ -64850,7 +64961,7 @@ async function onboard(opts = {}) {
64850
64961
  try {
64851
64962
  await passwordsPricing({});
64852
64963
  } catch {
64853
- plain(` ${import_picocolors10.default.red("\u2715")} could not read the passwords catalog
64964
+ plain(` ${import_picocolors11.default.red("\u2715")} could not read the passwords catalog
64854
64965
 
64855
64966
  `);
64856
64967
  }
@@ -64866,36 +64977,36 @@ async function onboard(opts = {}) {
64866
64977
  }
64867
64978
  }
64868
64979
  function printNext(put) {
64869
- put(` ${import_picocolors10.default.dim("agentgates init")} ${import_picocolors10.default.dim("\xB7 your account: mint the twelve words, or show it; --reveal-seed prints the words")}
64980
+ put(` ${import_picocolors11.default.dim("agentgates init")} ${import_picocolors11.default.dim("\xB7 your account: mint the twelve words, or show it; --reveal-seed prints the words")}
64870
64981
  `);
64871
- put(` ${import_picocolors10.default.dim("agentgates browser balance")} ${import_picocolors10.default.dim("\xB7 your balance and the address that tops it up")}
64982
+ put(` ${import_picocolors11.default.dim("agentgates browser balance")} ${import_picocolors11.default.dim("\xB7 your balance and the address that tops it up")}
64872
64983
  `);
64873
- put(` ${import_picocolors10.default.dim("agentgates compute plans")} ${import_picocolors10.default.dim("\xB7 virtual machines by the hour")}
64984
+ put(` ${import_picocolors11.default.dim("agentgates compute plans")} ${import_picocolors11.default.dim("\xB7 virtual machines by the hour")}
64874
64985
  `);
64875
- put(` ${import_picocolors10.default.dim("agentgates inference models")} ${import_picocolors10.default.dim("\xB7 models by the token")}
64986
+ put(` ${import_picocolors11.default.dim("agentgates inference models")} ${import_picocolors11.default.dim("\xB7 models by the token")}
64876
64987
  `);
64877
- put(` ${import_picocolors10.default.dim("agentgates phone pricing")} ${import_picocolors10.default.dim("\xB7 numbers by the month, calls by the minute")}
64988
+ put(` ${import_picocolors11.default.dim("agentgates phone pricing")} ${import_picocolors11.default.dim("\xB7 numbers by the month, calls by the minute")}
64878
64989
  `);
64879
- put(` ${import_picocolors10.default.dim("agentgates email pricing")} ${import_picocolors10.default.dim("\xB7 inboxes free on a balance, sends per message")}
64990
+ put(` ${import_picocolors11.default.dim("agentgates email pricing")} ${import_picocolors11.default.dim("\xB7 inboxes free on a balance, sends per message")}
64880
64991
  `);
64881
- put(` ${import_picocolors10.default.dim("agentgates passwords pricing")} ${import_picocolors10.default.dim("\xB7 logins an agent uses and never sees")}
64992
+ put(` ${import_picocolors11.default.dim("agentgates passwords pricing")} ${import_picocolors11.default.dim("\xB7 logins an agent uses and never sees")}
64882
64993
  `);
64883
- put(` ${import_picocolors10.default.dim("agentgates --help")} ${import_picocolors10.default.dim("\xB7 everything else")}
64994
+ put(` ${import_picocolors11.default.dim("agentgates --help")} ${import_picocolors11.default.dim("\xB7 everything else")}
64884
64995
 
64885
64996
  `);
64886
64997
  }
64887
64998
 
64888
64999
  // src/commands/logout.ts
64889
- var import_picocolors11 = __toESM(require_picocolors(), 1);
65000
+ var import_picocolors12 = __toESM(require_picocolors(), 1);
64890
65001
  async function logout(opts) {
64891
65002
  const requested = opts.profile ?? DEFAULT_PROFILE;
64892
65003
  const resolved = await resolveProfile(requested);
64893
65004
  if (!resolved) {
64894
- process.stdout.write(import_picocolors11.default.dim("Not logged in \u2014 nothing to log out.\n"));
65005
+ process.stdout.write(import_picocolors12.default.dim("Not logged in \u2014 nothing to log out.\n"));
64895
65006
  return;
64896
65007
  }
64897
65008
  if (resolved.autoSelected) {
64898
- process.stderr.write(import_picocolors11.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65009
+ process.stderr.write(import_picocolors12.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
64899
65010
  `));
64900
65011
  }
64901
65012
  const { profile, name: profileName } = resolved;
@@ -64920,15 +65031,15 @@ async function logout(opts) {
64920
65031
  const removed = await deleteProfile(profileName);
64921
65032
  if (removed) {
64922
65033
  process.stdout.write(
64923
- import_picocolors11.default.green(`\u2713 Logged out of profile ${import_picocolors11.default.bold(profileName)}.
65034
+ import_picocolors12.default.green(`\u2713 Logged out of profile ${import_picocolors12.default.bold(profileName)}.
64924
65035
  `)
64925
65036
  );
64926
65037
  }
64927
65038
  if (serverError) {
64928
65039
  process.stderr.write(
64929
- import_picocolors11.default.yellow(
65040
+ import_picocolors12.default.yellow(
64930
65041
  `\u26A0 Couldn't revoke server-side: ${serverError}
64931
- The local bearer is wiped. If the server still has it, revoke from ${import_picocolors11.default.bold("agentgates.ai/settings/pairings")}.
65042
+ The local bearer is wiped. If the server still has it, revoke from ${import_picocolors12.default.bold("agentgates.ai/settings/pairings")}.
64932
65043
  `
64933
65044
  )
64934
65045
  );
@@ -64936,49 +65047,49 @@ async function logout(opts) {
64936
65047
  }
64937
65048
 
64938
65049
  // src/commands/whoami.ts
64939
- var import_picocolors12 = __toESM(require_picocolors(), 1);
65050
+ var import_picocolors13 = __toESM(require_picocolors(), 1);
64940
65051
  async function whoami(opts) {
64941
65052
  const requested = opts.profile ?? DEFAULT_PROFILE;
64942
65053
  const resolved = await resolveProfile(requested);
64943
65054
  if (!resolved) {
64944
- process.stderr.write(import_picocolors12.default.red("Not logged in. Run agentgates login first.\n"));
65055
+ process.stderr.write(import_picocolors13.default.red("Not logged in. Run agentgates login first.\n"));
64945
65056
  process.exit(2);
64946
65057
  }
64947
65058
  if (resolved.autoSelected) {
64948
- process.stderr.write(import_picocolors12.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65059
+ process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
64949
65060
  `));
64950
65061
  }
64951
65062
  const { profile, name: profileName } = resolved;
64952
- const jsonMode4 = opts.json === true;
65063
+ const jsonMode5 = opts.json === true;
64953
65064
  const outcome = await callWithAutoRelogin({
64954
65065
  profile,
64955
65066
  profileName,
64956
- jsonMode: jsonMode4,
64957
- ttyHeader: import_picocolors12.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65067
+ jsonMode: jsonMode5,
65068
+ ttyHeader: import_picocolors13.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
64958
65069
  fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
64959
65070
  });
64960
65071
  if (outcome.kind === "auth_failed") {
64961
- if (jsonMode4) {
65072
+ if (jsonMode5) {
64962
65073
  process.stdout.write(
64963
65074
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
64964
65075
  );
64965
65076
  process.exit(1);
64966
65077
  }
64967
- process.stderr.write(import_picocolors12.default.red(`\u2715 ${outcome.reason}.
65078
+ process.stderr.write(import_picocolors13.default.red(`\u2715 ${outcome.reason}.
64968
65079
  `));
64969
65080
  process.exit(1);
64970
65081
  }
64971
65082
  if (outcome.kind === "error") {
64972
65083
  const err = outcome.error;
64973
65084
  if (err instanceof ApiError) {
64974
- process.stderr.write(import_picocolors12.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65085
+ process.stderr.write(import_picocolors13.default.red(`\u2715 ${err.message} (HTTP ${err.status})
64975
65086
  `));
64976
65087
  process.exit(1);
64977
65088
  }
64978
65089
  throw err;
64979
65090
  }
64980
65091
  const me = outcome.result;
64981
- if (jsonMode4) {
65092
+ if (jsonMode5) {
64982
65093
  process.stdout.write(JSON.stringify(me, null, 2) + "\n");
64983
65094
  return;
64984
65095
  }
@@ -64992,7 +65103,7 @@ async function whoami(opts) {
64992
65103
  process.stdout.write(`Solana ${me.solanaAddress}
64993
65104
  `);
64994
65105
  }
64995
- process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors12.default.dim("(none)")}
65106
+ process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors13.default.dim("(none)")}
64996
65107
  `);
64997
65108
  const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
64998
65109
  const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
@@ -65009,7 +65120,7 @@ async function whoami(opts) {
65009
65120
  `
65010
65121
  );
65011
65122
  process.stdout.write(
65012
- `Profile ${profileName === DEFAULT_PROFILE ? import_picocolors12.default.dim("(default)") : profileName}
65123
+ `Profile ${profileName === DEFAULT_PROFILE ? import_picocolors13.default.dim("(default)") : profileName}
65013
65124
  `
65014
65125
  );
65015
65126
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -65023,7 +65134,7 @@ function formatDate(iso) {
65023
65134
  }
65024
65135
 
65025
65136
  // src/commands/send.ts
65026
- var import_picocolors13 = __toESM(require_picocolors(), 1);
65137
+ var import_picocolors14 = __toESM(require_picocolors(), 1);
65027
65138
 
65028
65139
  // src/lib/status.ts
65029
65140
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
@@ -65173,20 +65284,20 @@ async function send(amount, asset, opts) {
65173
65284
  const requested = opts.profile ?? DEFAULT_PROFILE;
65174
65285
  const resolved = await resolveProfile(requested);
65175
65286
  if (!resolved) {
65176
- process.stderr.write(import_picocolors13.default.red("Not logged in. Run agentgates login first.\n"));
65287
+ process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
65177
65288
  process.exit(2);
65178
65289
  }
65179
65290
  if (resolved.autoSelected) {
65180
- process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65291
+ process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65181
65292
  `));
65182
65293
  }
65183
65294
  const { profile, name: profileName } = resolved;
65184
65295
  const stdoutIsTty = process.stdout.isTTY === true;
65185
- const jsonMode4 = opts.json === true || !stdoutIsTty;
65296
+ const jsonMode5 = opts.json === true || !stdoutIsTty;
65186
65297
  const amountNumber = Number(amount);
65187
65298
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
65188
65299
  process.stderr.write(
65189
- import_picocolors13.default.red(`\u2715 amount must be a positive number (got ${import_picocolors13.default.bold(amount)}).
65300
+ import_picocolors14.default.red(`\u2715 amount must be a positive number (got ${import_picocolors14.default.bold(amount)}).
65190
65301
  `)
65191
65302
  );
65192
65303
  process.exit(2);
@@ -65194,23 +65305,23 @@ async function send(amount, asset, opts) {
65194
65305
  const assetNormalized = asset.toLowerCase();
65195
65306
  if (assetNormalized !== "native" && assetNormalized !== "usdc") {
65196
65307
  process.stderr.write(
65197
- import_picocolors13.default.red(
65198
- `\u2715 asset must be ${import_picocolors13.default.bold("native")} or ${import_picocolors13.default.bold("usdc")} (got ${import_picocolors13.default.bold(asset)}).
65308
+ import_picocolors14.default.red(
65309
+ `\u2715 asset must be ${import_picocolors14.default.bold("native")} or ${import_picocolors14.default.bold("usdc")} (got ${import_picocolors14.default.bold(asset)}).
65199
65310
  `
65200
65311
  )
65201
65312
  );
65202
65313
  process.exit(2);
65203
65314
  }
65204
65315
  if (!opts.to || opts.to.trim() === "") {
65205
- process.stderr.write(import_picocolors13.default.red(`\u2715 --to <address> is required.
65316
+ process.stderr.write(import_picocolors14.default.red(`\u2715 --to <address> is required.
65206
65317
  `));
65207
65318
  process.exit(2);
65208
65319
  }
65209
65320
  if (isSolanaChainAlias(opts.chain)) {
65210
65321
  if (EVM_ADDRESS_RE.test(opts.to)) {
65211
65322
  process.stderr.write(
65212
- import_picocolors13.default.red(
65213
- `\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors13.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
65323
+ import_picocolors14.default.red(
65324
+ `\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors14.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
65214
65325
  `
65215
65326
  )
65216
65327
  );
@@ -65218,10 +65329,10 @@ async function send(amount, asset, opts) {
65218
65329
  }
65219
65330
  if (!SOLANA_ADDRESS_RE.test(opts.to)) {
65220
65331
  process.stderr.write(
65221
- import_picocolors13.default.red(
65222
- `\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors13.default.bold(opts.to)}).
65332
+ import_picocolors14.default.red(
65333
+ `\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors14.default.bold(opts.to)}).
65223
65334
  `
65224
- ) + import_picocolors13.default.dim(
65335
+ ) + import_picocolors14.default.dim(
65225
65336
  ` SNS resolution is deferred to a future server-side change;
65226
65337
  for now Solana sends require the literal pubkey.
65227
65338
  `
@@ -65232,8 +65343,8 @@ async function send(amount, asset, opts) {
65232
65343
  }
65233
65344
  if (!opts.userStated || opts.userStated.trim() === "") {
65234
65345
  process.stderr.write(
65235
- import_picocolors13.default.red(`\u2715 --user-stated <text> is required.
65236
- `) + import_picocolors13.default.dim(
65346
+ import_picocolors14.default.red(`\u2715 --user-stated <text> is required.
65347
+ `) + import_picocolors14.default.dim(
65237
65348
  ` This is the trust-gap defense: pass the verbatim user request so
65238
65349
  the approval modal can cross-check what the agent thinks the user
65239
65350
  asked for vs. the actual decoded transaction.
@@ -65251,7 +65362,7 @@ async function send(amount, asset, opts) {
65251
65362
  const n2 = Number(opts.maxUsd);
65252
65363
  if (!Number.isFinite(n2) || n2 <= 0) {
65253
65364
  process.stderr.write(
65254
- import_picocolors13.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
65365
+ import_picocolors14.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
65255
65366
  `)
65256
65367
  );
65257
65368
  process.exit(2);
@@ -65291,12 +65402,12 @@ async function send(amount, asset, opts) {
65291
65402
  try {
65292
65403
  activeProfile = await runLoginFlow({
65293
65404
  profile: profileName,
65294
- jsonMode: jsonMode4,
65405
+ jsonMode: jsonMode5,
65295
65406
  origin: activeProfile.mcpOrigin,
65296
- ttyHeader: import_picocolors13.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
65407
+ ttyHeader: import_picocolors14.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
65297
65408
  });
65298
65409
  } catch (reloginErr) {
65299
- if (jsonMode4) {
65410
+ if (jsonMode5) {
65300
65411
  emitNdjson({
65301
65412
  ok: false,
65302
65413
  status: "auth_failed",
@@ -65305,7 +65416,7 @@ async function send(amount, asset, opts) {
65305
65416
  process.exit(1);
65306
65417
  }
65307
65418
  process.stderr.write(
65308
- import_picocolors13.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65419
+ import_picocolors14.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65309
65420
  `)
65310
65421
  );
65311
65422
  process.exit(1);
@@ -65319,7 +65430,7 @@ async function send(amount, asset, opts) {
65319
65430
  });
65320
65431
  } catch (retryErr) {
65321
65432
  if (retryErr instanceof ApiError) {
65322
- if (jsonMode4) {
65433
+ if (jsonMode5) {
65323
65434
  emitNdjson({
65324
65435
  ok: false,
65325
65436
  status: retryErr.status === 401 ? "auth_failed" : "propose_failed",
@@ -65329,7 +65440,7 @@ async function send(amount, asset, opts) {
65329
65440
  process.exit(1);
65330
65441
  }
65331
65442
  process.stderr.write(
65332
- import_picocolors13.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
65443
+ import_picocolors14.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
65333
65444
  `)
65334
65445
  );
65335
65446
  process.exit(1);
@@ -65337,7 +65448,7 @@ async function send(amount, asset, opts) {
65337
65448
  throw retryErr;
65338
65449
  }
65339
65450
  } else if (err instanceof ApiError) {
65340
- if (jsonMode4) {
65451
+ if (jsonMode5) {
65341
65452
  emitNdjson({
65342
65453
  ok: false,
65343
65454
  status: "propose_failed",
@@ -65346,7 +65457,7 @@ async function send(amount, asset, opts) {
65346
65457
  });
65347
65458
  process.exit(1);
65348
65459
  }
65349
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65460
+ process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65350
65461
  `));
65351
65462
  process.exit(1);
65352
65463
  } else {
@@ -65354,7 +65465,7 @@ async function send(amount, asset, opts) {
65354
65465
  }
65355
65466
  }
65356
65467
  if (isBlocked(proposed)) {
65357
- if (jsonMode4) {
65468
+ if (jsonMode5) {
65358
65469
  const envelope = {
65359
65470
  ok: false,
65360
65471
  status: "blocked",
@@ -65372,17 +65483,17 @@ async function send(amount, asset, opts) {
65372
65483
  if (proposed.detail) {
65373
65484
  const d = proposed.detail;
65374
65485
  process.stderr.write(
65375
- import_picocolors13.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
65486
+ import_picocolors14.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
65376
65487
  `
65377
65488
  );
65378
65489
  } else {
65379
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${proposed.reason}
65490
+ process.stderr.write(import_picocolors14.default.red(`\u2715 ${proposed.reason}
65380
65491
  `));
65381
65492
  }
65382
65493
  if (proposed.upgrade_url) {
65383
65494
  process.stderr.write(
65384
65495
  ` Open this to grant access, then re-run the command:
65385
- ${import_picocolors13.default.cyan(proposed.upgrade_url)}
65496
+ ${import_picocolors14.default.cyan(proposed.upgrade_url)}
65386
65497
  `
65387
65498
  );
65388
65499
  }
@@ -65392,21 +65503,21 @@ async function send(amount, asset, opts) {
65392
65503
  const a = proposed.recommended_actions[i];
65393
65504
  process.stderr.write(` ${i + 1}. ${a.label}
65394
65505
  `);
65395
- if (a.reasoning) process.stderr.write(import_picocolors13.default.dim(` ${a.reasoning}
65506
+ if (a.reasoning) process.stderr.write(import_picocolors14.default.dim(` ${a.reasoning}
65396
65507
  `));
65397
65508
  if (a.action_intent && a.action_intent.external_url) {
65398
65509
  process.stderr.write(
65399
- ` ${import_picocolors13.default.cyan(a.action_intent.external_url)}
65510
+ ` ${import_picocolors14.default.cyan(a.action_intent.external_url)}
65400
65511
  `
65401
65512
  );
65402
65513
  }
65403
65514
  }
65404
65515
  }
65405
65516
  if (proposed.suggestions && proposed.suggestions.length > 0) {
65406
- process.stderr.write(import_picocolors13.default.dim("\n Other ways to fund:\n"));
65517
+ process.stderr.write(import_picocolors14.default.dim("\n Other ways to fund:\n"));
65407
65518
  for (const s of proposed.suggestions) {
65408
65519
  if (s.kind === "ask_user") continue;
65409
- process.stderr.write(import_picocolors13.default.dim(` \u2022 ${s.label}
65520
+ process.stderr.write(import_picocolors14.default.dim(` \u2022 ${s.label}
65410
65521
  `));
65411
65522
  }
65412
65523
  }
@@ -65418,7 +65529,7 @@ async function send(amount, asset, opts) {
65418
65529
  if (process.env.CI === "1" || process.env.CI === "true") return false;
65419
65530
  return true;
65420
65531
  })();
65421
- if (jsonMode4) {
65532
+ if (jsonMode5) {
65422
65533
  emitNdjson({
65423
65534
  ok: true,
65424
65535
  status: "proposed",
@@ -65433,8 +65544,8 @@ async function send(amount, asset, opts) {
65433
65544
  } else {
65434
65545
  process.stdout.write(
65435
65546
  `
65436
- ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with biometric:
65437
- ${import_picocolors13.default.cyan(proposed.approval_url)}
65547
+ ${import_picocolors14.default.bold("Proposed.")} Open this URL to approve with biometric:
65548
+ ${import_picocolors14.default.cyan(proposed.approval_url)}
65438
65549
 
65439
65550
  `
65440
65551
  );
@@ -65450,10 +65561,10 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
65450
65561
  intervalMs: POLL_INTERVAL_MS,
65451
65562
  giveUpMs: POLL_GIVEUP_MS,
65452
65563
  onTick: (s) => {
65453
- if (jsonMode4) {
65564
+ if (jsonMode5) {
65454
65565
  emitNdjson({ status: s.status, intent_id: s.approval_id });
65455
65566
  } else {
65456
- process.stdout.write(` ${describeStatus(s.status)}${import_picocolors13.default.dim("\u2026")}\r`);
65567
+ process.stdout.write(` ${describeStatus(s.status)}${import_picocolors14.default.dim("\u2026")}\r`);
65457
65568
  }
65458
65569
  }
65459
65570
  });
@@ -65465,12 +65576,12 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
65465
65576
  try {
65466
65577
  activeProfile = await runLoginFlow({
65467
65578
  profile: profileName,
65468
- jsonMode: jsonMode4,
65579
+ jsonMode: jsonMode5,
65469
65580
  origin: activeProfile.mcpOrigin,
65470
- ttyHeader: import_picocolors13.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
65581
+ ttyHeader: import_picocolors14.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
65471
65582
  });
65472
65583
  } catch (reloginErr) {
65473
- if (jsonMode4) {
65584
+ if (jsonMode5) {
65474
65585
  emitNdjson({
65475
65586
  ok: false,
65476
65587
  status: "auth_failed",
@@ -65480,7 +65591,7 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
65480
65591
  process.exit(1);
65481
65592
  }
65482
65593
  process.stderr.write(
65483
- "\n" + import_picocolors13.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65594
+ "\n" + import_picocolors14.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65484
65595
  `)
65485
65596
  );
65486
65597
  process.exit(1);
@@ -65488,7 +65599,7 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
65488
65599
  try {
65489
65600
  final = await runPoll(activeProfile);
65490
65601
  } catch (retryErr) {
65491
- if (jsonMode4) {
65602
+ if (jsonMode5) {
65492
65603
  emitNdjson({
65493
65604
  ok: false,
65494
65605
  status: retryErr instanceof ApiError && retryErr.status === 401 ? "auth_failed" : "poll_failed",
@@ -65498,13 +65609,13 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
65498
65609
  process.exit(1);
65499
65610
  }
65500
65611
  process.stderr.write(
65501
- "\n" + import_picocolors13.default.red(`\u2715 Status poll failed: ${retryErr.message}
65612
+ "\n" + import_picocolors14.default.red(`\u2715 Status poll failed: ${retryErr.message}
65502
65613
  `)
65503
65614
  );
65504
65615
  process.exit(1);
65505
65616
  }
65506
65617
  } else {
65507
- if (jsonMode4) {
65618
+ if (jsonMode5) {
65508
65619
  emitNdjson({
65509
65620
  ok: false,
65510
65621
  status: "poll_failed",
@@ -65514,14 +65625,14 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
65514
65625
  process.exit(1);
65515
65626
  }
65516
65627
  process.stderr.write(
65517
- "\n" + import_picocolors13.default.red(`\u2715 Status poll failed: ${err.message}
65628
+ "\n" + import_picocolors14.default.red(`\u2715 Status poll failed: ${err.message}
65518
65629
  `)
65519
65630
  );
65520
65631
  process.exit(1);
65521
65632
  }
65522
65633
  }
65523
65634
  const explorer = final.tx_hash != null ? explorerUrl(final.chain_id, final.tx_hash) : null;
65524
- if (jsonMode4) {
65635
+ if (jsonMode5) {
65525
65636
  emitNdjson({
65526
65637
  ok: final.status === "mined",
65527
65638
  status: final.status,
@@ -65534,19 +65645,19 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
65534
65645
  }
65535
65646
  process.stdout.write("\n");
65536
65647
  if (final.status === "mined") {
65537
- process.stdout.write(import_picocolors13.default.green("\u2713 Mined.") + "\n");
65648
+ process.stdout.write(import_picocolors14.default.green("\u2713 Mined.") + "\n");
65538
65649
  if (final.tx_hash) {
65539
65650
  process.stdout.write(` Tx ${final.tx_hash}
65540
65651
  `);
65541
65652
  }
65542
65653
  if (explorer) {
65543
- process.stdout.write(` Explorer ${import_picocolors13.default.cyan(explorer)}
65654
+ process.stdout.write(` Explorer ${import_picocolors14.default.cyan(explorer)}
65544
65655
  `);
65545
65656
  }
65546
65657
  process.exit(0);
65547
65658
  }
65548
65659
  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}`;
65549
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${label}.
65660
+ process.stderr.write(import_picocolors14.default.red(`\u2715 ${label}.
65550
65661
  `));
65551
65662
  process.exit(1);
65552
65663
  }
@@ -65574,7 +65685,7 @@ function describeStatus(s) {
65574
65685
  }
65575
65686
 
65576
65687
  // src/commands/status.ts
65577
- var import_picocolors14 = __toESM(require_picocolors(), 1);
65688
+ var import_picocolors15 = __toESM(require_picocolors(), 1);
65578
65689
  var WATCH_GIVEUP_MS = 10 * 6e4;
65579
65690
  function explorerUrl2(chainId, hash2) {
65580
65691
  switch (chainId) {
@@ -65592,36 +65703,36 @@ function explorerUrl2(chainId, hash2) {
65592
65703
  }
65593
65704
  async function status2(intentId, opts) {
65594
65705
  if (!intentId || intentId.trim() === "") {
65595
- process.stderr.write(import_picocolors14.default.red("\u2715 Missing intent id.\n"));
65706
+ process.stderr.write(import_picocolors15.default.red("\u2715 Missing intent id.\n"));
65596
65707
  process.exit(2);
65597
65708
  }
65598
65709
  const requested = opts.profile ?? DEFAULT_PROFILE;
65599
65710
  const resolved = await resolveProfile(requested);
65600
65711
  if (!resolved) {
65601
- process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
65712
+ process.stderr.write(import_picocolors15.default.red("Not logged in. Run agentgates login first.\n"));
65602
65713
  process.exit(2);
65603
65714
  }
65604
65715
  if (resolved.autoSelected) {
65605
- process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65716
+ process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65606
65717
  `));
65607
65718
  }
65608
65719
  const { profile, name: profileName } = resolved;
65609
- const jsonMode4 = opts.json === true;
65720
+ const jsonMode5 = opts.json === true;
65610
65721
  const outcome = await callWithAutoRelogin({
65611
65722
  profile,
65612
65723
  profileName,
65613
- jsonMode: jsonMode4,
65614
- ttyHeader: import_picocolors14.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65724
+ jsonMode: jsonMode5,
65725
+ ttyHeader: import_picocolors15.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65615
65726
  fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
65616
65727
  });
65617
65728
  if (outcome.kind === "auth_failed") {
65618
- if (jsonMode4) {
65729
+ if (jsonMode5) {
65619
65730
  process.stdout.write(
65620
65731
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
65621
65732
  );
65622
65733
  process.exit(1);
65623
65734
  }
65624
- process.stderr.write(import_picocolors14.default.red(`\u2715 ${outcome.reason}.
65735
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${outcome.reason}.
65625
65736
  `));
65626
65737
  process.exit(1);
65627
65738
  }
@@ -65629,11 +65740,11 @@ async function status2(intentId, opts) {
65629
65740
  const err = outcome.error;
65630
65741
  if (err instanceof ApiError) {
65631
65742
  if (err.status === 404) {
65632
- process.stderr.write(import_picocolors14.default.red(`\u2715 No intent with id ${intentId}.
65743
+ process.stderr.write(import_picocolors15.default.red(`\u2715 No intent with id ${intentId}.
65633
65744
  `));
65634
65745
  process.exit(1);
65635
65746
  }
65636
- process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65747
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65637
65748
  `));
65638
65749
  process.exit(1);
65639
65750
  }
@@ -65642,9 +65753,9 @@ async function status2(intentId, opts) {
65642
65753
  let snap = outcome.result;
65643
65754
  let activeProfile = outcome.profile;
65644
65755
  if (opts.watch && !isTerminalStatus(snap.status)) {
65645
- if (!jsonMode4) {
65756
+ if (!jsonMode5) {
65646
65757
  printSnap(snap);
65647
- process.stdout.write(import_picocolors14.default.dim("Watching\u2026\n"));
65758
+ process.stdout.write(import_picocolors15.default.dim("Watching\u2026\n"));
65648
65759
  }
65649
65760
  const runWatchPoll = (p) => streamStatusUntilTerminal({
65650
65761
  intentId,
@@ -65654,8 +65765,8 @@ async function status2(intentId, opts) {
65654
65765
  intervalMs: 0,
65655
65766
  giveUpMs: WATCH_GIVEUP_MS,
65656
65767
  onTick: (s) => {
65657
- if (!jsonMode4) {
65658
- process.stdout.write(` ${import_picocolors14.default.dim("\u2192")} ${s.status}
65768
+ if (!jsonMode5) {
65769
+ process.stdout.write(` ${import_picocolors15.default.dim("\u2192")} ${s.status}
65659
65770
  `);
65660
65771
  }
65661
65772
  }
@@ -65668,12 +65779,12 @@ async function status2(intentId, opts) {
65668
65779
  try {
65669
65780
  activeProfile = await runLoginFlow({
65670
65781
  profile: profileName,
65671
- jsonMode: jsonMode4,
65782
+ jsonMode: jsonMode5,
65672
65783
  origin: activeProfile.mcpOrigin,
65673
- ttyHeader: import_picocolors14.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
65784
+ ttyHeader: import_picocolors15.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
65674
65785
  });
65675
65786
  } catch (reloginErr) {
65676
- if (jsonMode4) {
65787
+ if (jsonMode5) {
65677
65788
  process.stdout.write(
65678
65789
  JSON.stringify({
65679
65790
  ok: false,
@@ -65684,7 +65795,7 @@ async function status2(intentId, opts) {
65684
65795
  process.exit(1);
65685
65796
  }
65686
65797
  process.stderr.write(
65687
- import_picocolors14.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65798
+ import_picocolors15.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65688
65799
  `)
65689
65800
  );
65690
65801
  process.exit(1);
@@ -65692,24 +65803,24 @@ async function status2(intentId, opts) {
65692
65803
  try {
65693
65804
  final = await runWatchPoll(activeProfile);
65694
65805
  } catch (retryErr) {
65695
- process.stderr.write(import_picocolors14.default.red(`\u2715 ${retryErr.message}
65806
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${retryErr.message}
65696
65807
  `));
65697
65808
  process.exit(1);
65698
65809
  }
65699
65810
  } else {
65700
- process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message}
65811
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message}
65701
65812
  `));
65702
65813
  process.exit(1);
65703
65814
  }
65704
65815
  }
65705
- if (jsonMode4) {
65816
+ if (jsonMode5) {
65706
65817
  process.stdout.write(JSON.stringify(final, null, 2) + "\n");
65707
65818
  } else {
65708
65819
  printSnap(final);
65709
65820
  }
65710
65821
  process.exit(final.status === "mined" ? 0 : 1);
65711
65822
  }
65712
- if (jsonMode4) {
65823
+ if (jsonMode5) {
65713
65824
  process.stdout.write(JSON.stringify(snap, null, 2) + "\n");
65714
65825
  process.exit(snap.status === "mined" ? 0 : 0);
65715
65826
  }
@@ -65718,7 +65829,7 @@ async function status2(intentId, opts) {
65718
65829
  }
65719
65830
  function printSnap(s) {
65720
65831
  const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
65721
- const colorFn = s.status === "mined" ? import_picocolors14.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors14.default.red : import_picocolors14.default.cyan;
65832
+ const colorFn = s.status === "mined" ? import_picocolors15.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors15.default.red : import_picocolors15.default.cyan;
65722
65833
  process.stdout.write(`Intent ${s.approval_id}
65723
65834
  `);
65724
65835
  process.stdout.write(`Status ${colorFn(s.status)}
@@ -65733,12 +65844,12 @@ function printSnap(s) {
65733
65844
  process.stdout.write(`Tx ${s.tx_hash}
65734
65845
  `);
65735
65846
  if (explorer) {
65736
- process.stdout.write(`Explorer ${import_picocolors14.default.cyan(explorer)}
65847
+ process.stdout.write(`Explorer ${import_picocolors15.default.cyan(explorer)}
65737
65848
  `);
65738
65849
  }
65739
65850
  }
65740
65851
  if (!isTerminalStatus(s.status)) {
65741
- process.stdout.write(`Approve ${import_picocolors14.default.cyan(s.approval_url)}
65852
+ process.stdout.write(`Approve ${import_picocolors15.default.cyan(s.approval_url)}
65742
65853
  `);
65743
65854
  }
65744
65855
  process.stdout.write(`Created ${formatDate2(s.created_at)}
@@ -65755,7 +65866,7 @@ function formatDate2(iso) {
65755
65866
  }
65756
65867
 
65757
65868
  // src/commands/balance.ts
65758
- var import_picocolors15 = __toESM(require_picocolors(), 1);
65869
+ var import_picocolors16 = __toESM(require_picocolors(), 1);
65759
65870
  var CHAIN_ALIASES = {
65760
65871
  "1": 1,
65761
65872
  ethereum: 1,
@@ -65778,11 +65889,11 @@ async function balance(opts) {
65778
65889
  const requested = opts.profile ?? DEFAULT_PROFILE;
65779
65890
  const resolved = await resolveProfile(requested);
65780
65891
  if (!resolved) {
65781
- process.stderr.write(import_picocolors15.default.red("Not logged in. Run agentgates login first.\n"));
65892
+ process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
65782
65893
  process.exit(2);
65783
65894
  }
65784
65895
  if (resolved.autoSelected) {
65785
- process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65896
+ process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65786
65897
  `));
65787
65898
  }
65788
65899
  const { profile, name: profileName } = resolved;
@@ -65792,8 +65903,8 @@ async function balance(opts) {
65792
65903
  const id2 = CHAIN_ALIASES[key];
65793
65904
  if (id2 === void 0) {
65794
65905
  process.stderr.write(
65795
- import_picocolors15.default.red(
65796
- `\u2715 Unknown chain ${import_picocolors15.default.bold(opts.chain)}. Supported: ${import_picocolors15.default.bold("1/ethereum")}, ${import_picocolors15.default.bold("137/polygon")}, ${import_picocolors15.default.bold("8453/base")}, ${import_picocolors15.default.bold("42161/arbitrum")}, ${import_picocolors15.default.bold("900/solana")}.
65906
+ import_picocolors16.default.red(
65907
+ `\u2715 Unknown chain ${import_picocolors16.default.bold(opts.chain)}. Supported: ${import_picocolors16.default.bold("1/ethereum")}, ${import_picocolors16.default.bold("137/polygon")}, ${import_picocolors16.default.bold("8453/base")}, ${import_picocolors16.default.bold("42161/arbitrum")}, ${import_picocolors16.default.bold("900/solana")}.
65797
65908
  `
65798
65909
  )
65799
65910
  );
@@ -65801,29 +65912,29 @@ async function balance(opts) {
65801
65912
  }
65802
65913
  chainFilter = id2;
65803
65914
  }
65804
- const jsonMode4 = opts.json === true;
65915
+ const jsonMode5 = opts.json === true;
65805
65916
  const outcome = await callWithAutoRelogin({
65806
65917
  profile,
65807
65918
  profileName,
65808
- jsonMode: jsonMode4,
65809
- ttyHeader: import_picocolors15.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65919
+ jsonMode: jsonMode5,
65920
+ ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65810
65921
  fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
65811
65922
  });
65812
65923
  if (outcome.kind === "auth_failed") {
65813
- if (jsonMode4) {
65924
+ if (jsonMode5) {
65814
65925
  process.stdout.write(
65815
65926
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
65816
65927
  );
65817
65928
  process.exit(1);
65818
65929
  }
65819
- process.stderr.write(import_picocolors15.default.red(`\u2715 ${outcome.reason}.
65930
+ process.stderr.write(import_picocolors16.default.red(`\u2715 ${outcome.reason}.
65820
65931
  `));
65821
65932
  process.exit(1);
65822
65933
  }
65823
65934
  if (outcome.kind === "error") {
65824
65935
  const err = outcome.error;
65825
65936
  if (err instanceof ApiError) {
65826
- process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65937
+ process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65827
65938
  `));
65828
65939
  process.exit(1);
65829
65940
  }
@@ -65831,7 +65942,7 @@ async function balance(opts) {
65831
65942
  }
65832
65943
  const res = outcome.result;
65833
65944
  const filtered = chainFilter !== null ? res.chains.filter((c) => c.chainId === chainFilter) : res.chains;
65834
- if (jsonMode4) {
65945
+ if (jsonMode5) {
65835
65946
  process.stdout.write(
65836
65947
  JSON.stringify(
65837
65948
  chainFilter !== null ? { ...res, chains: filtered } : res,
@@ -65853,7 +65964,7 @@ async function balance(opts) {
65853
65964
  }
65854
65965
  if (filtered.length === 0) {
65855
65966
  process.stdout.write(
65856
- import_picocolors15.default.dim(
65967
+ import_picocolors16.default.dim(
65857
65968
  chainFilter !== null ? `No balances on chain ${chainFilter}.
65858
65969
  ` : `No chain balances returned.
65859
65970
  `
@@ -65865,7 +65976,7 @@ async function balance(opts) {
65865
65976
  const errorLines = [];
65866
65977
  for (const c of filtered) {
65867
65978
  if (c.error) {
65868
- errorLines.push(`${c.chainName} ${import_picocolors15.default.red(`(read failed: ${c.error})`)}`);
65979
+ errorLines.push(`${c.chainName} ${import_picocolors16.default.red(`(read failed: ${c.error})`)}`);
65869
65980
  continue;
65870
65981
  }
65871
65982
  if (c.native.balance > 0) {
@@ -65886,7 +65997,7 @@ async function balance(opts) {
65886
65997
  }
65887
65998
  }
65888
65999
  if (rows.length === 0 && errorLines.length === 0) {
65889
- process.stdout.write(import_picocolors15.default.dim(`All balances are zero.
66000
+ process.stdout.write(import_picocolors16.default.dim(`All balances are zero.
65890
66001
  `));
65891
66002
  process.stdout.write(AI_DIRECTIVE + "\n");
65892
66003
  return;
@@ -65896,7 +66007,7 @@ async function balance(opts) {
65896
66007
  const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
65897
66008
  const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
65898
66009
  const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
65899
- process.stdout.write(import_picocolors15.default.dim(header) + "\n");
66010
+ process.stdout.write(import_picocolors16.default.dim(header) + "\n");
65900
66011
  for (const r of rows) {
65901
66012
  process.stdout.write(
65902
66013
  r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
@@ -65909,7 +66020,7 @@ async function balance(opts) {
65909
66020
  `);
65910
66021
  }
65911
66022
  if (res.fetched_at) {
65912
- process.stdout.write("\n" + import_picocolors15.default.dim(`Fetched ${res.fetched_at}
66023
+ process.stdout.write("\n" + import_picocolors16.default.dim(`Fetched ${res.fetched_at}
65913
66024
  `));
65914
66025
  }
65915
66026
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -65922,18 +66033,18 @@ function formatBalance(value, decimals) {
65922
66033
  }
65923
66034
 
65924
66035
  // src/commands/history.ts
65925
- var import_picocolors16 = __toESM(require_picocolors(), 1);
66036
+ var import_picocolors17 = __toESM(require_picocolors(), 1);
65926
66037
  var DEFAULT_LIMIT = 20;
65927
66038
  var SERVER_MAX_LIMIT = 100;
65928
66039
  async function history(opts) {
65929
66040
  const requested = opts.profile ?? DEFAULT_PROFILE;
65930
66041
  const resolved = await resolveProfile(requested);
65931
66042
  if (!resolved) {
65932
- process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
66043
+ process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
65933
66044
  process.exit(2);
65934
66045
  }
65935
66046
  if (resolved.autoSelected) {
65936
- process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66047
+ process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65937
66048
  `));
65938
66049
  }
65939
66050
  const { profile, name: profileName } = resolved;
@@ -65942,14 +66053,14 @@ async function history(opts) {
65942
66053
  const n2 = Number(opts.limit);
65943
66054
  if (!Number.isFinite(n2) || n2 <= 0 || !Number.isInteger(n2)) {
65944
66055
  process.stderr.write(
65945
- import_picocolors16.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors16.default.bold(opts.limit)}).
66056
+ import_picocolors17.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors17.default.bold(opts.limit)}).
65946
66057
  `)
65947
66058
  );
65948
66059
  process.exit(2);
65949
66060
  }
65950
66061
  if (n2 > SERVER_MAX_LIMIT) {
65951
66062
  process.stderr.write(
65952
- import_picocolors16.default.red(
66063
+ import_picocolors17.default.red(
65953
66064
  `\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n2}.
65954
66065
  `
65955
66066
  )
@@ -65958,39 +66069,39 @@ async function history(opts) {
65958
66069
  }
65959
66070
  limit = n2;
65960
66071
  }
65961
- const jsonMode4 = opts.json === true;
66072
+ const jsonMode5 = opts.json === true;
65962
66073
  const outcome = await callWithAutoRelogin({
65963
66074
  profile,
65964
66075
  profileName,
65965
- jsonMode: jsonMode4,
65966
- ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
66076
+ jsonMode: jsonMode5,
66077
+ ttyHeader: import_picocolors17.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65967
66078
  fn: (bearer, origin) => apiFetch(
65968
66079
  `/api/history?limit=${encodeURIComponent(String(limit))}`,
65969
66080
  { bearer, origin }
65970
66081
  )
65971
66082
  });
65972
66083
  if (outcome.kind === "auth_failed") {
65973
- if (jsonMode4) {
66084
+ if (jsonMode5) {
65974
66085
  process.stdout.write(
65975
66086
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
65976
66087
  );
65977
66088
  process.exit(1);
65978
66089
  }
65979
- process.stderr.write(import_picocolors16.default.red(`\u2715 ${outcome.reason}.
66090
+ process.stderr.write(import_picocolors17.default.red(`\u2715 ${outcome.reason}.
65980
66091
  `));
65981
66092
  process.exit(1);
65982
66093
  }
65983
66094
  if (outcome.kind === "error") {
65984
66095
  const err = outcome.error;
65985
66096
  if (err instanceof ApiError) {
65986
- process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
66097
+ process.stderr.write(import_picocolors17.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65987
66098
  `));
65988
66099
  process.exit(1);
65989
66100
  }
65990
66101
  throw err;
65991
66102
  }
65992
66103
  const res = outcome.result;
65993
- if (jsonMode4) {
66104
+ if (jsonMode5) {
65994
66105
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
65995
66106
  return;
65996
66107
  }
@@ -66000,7 +66111,7 @@ async function history(opts) {
66000
66111
  return;
66001
66112
  }
66002
66113
  if (res.txs.length === 0) {
66003
- process.stdout.write(import_picocolors16.default.dim(`No activity yet.
66114
+ process.stdout.write(import_picocolors17.default.dim(`No activity yet.
66004
66115
  `));
66005
66116
  return;
66006
66117
  }
@@ -66020,7 +66131,7 @@ async function history(opts) {
66020
66131
  const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
66021
66132
  const colTo = Math.max(2, ...rows.map((r) => r.to.length));
66022
66133
  const header = "When".padEnd(colWhen) + " " + "Chain".padEnd(colChain) + " " + "Type".padEnd(colType) + " " + "Amount".padStart(colAmount) + " " + "Asset".padEnd(colAsset) + " " + "To".padEnd(colTo) + " Hash";
66023
- process.stdout.write(import_picocolors16.default.dim(header) + "\n");
66134
+ process.stdout.write(import_picocolors17.default.dim(header) + "\n");
66024
66135
  for (const r of rows) {
66025
66136
  process.stdout.write(
66026
66137
  r.when.padEnd(colWhen) + " " + r.chain.padEnd(colChain) + " " + r.type.padEnd(colType) + " " + r.amount.padStart(colAmount) + " " + r.asset.padEnd(colAsset) + " " + r.to.padEnd(colTo) + " " + r.hash + "\n"
@@ -66028,7 +66139,7 @@ async function history(opts) {
66028
66139
  }
66029
66140
  if (res.fetched_at) {
66030
66141
  process.stdout.write(
66031
- "\n" + import_picocolors16.default.dim(
66142
+ "\n" + import_picocolors17.default.dim(
66032
66143
  `Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
66033
66144
  `
66034
66145
  )
@@ -66115,10 +66226,10 @@ function prettyType(activityType, status3) {
66115
66226
  }
66116
66227
 
66117
66228
  // src/commands/swap.ts
66118
- var import_picocolors18 = __toESM(require_picocolors(), 1);
66229
+ var import_picocolors19 = __toESM(require_picocolors(), 1);
66119
66230
 
66120
66231
  // src/lib/intent-flow.ts
66121
- var import_picocolors17 = __toESM(require_picocolors(), 1);
66232
+ var import_picocolors18 = __toESM(require_picocolors(), 1);
66122
66233
  var STREAM_GIVEUP_MS = 10 * 6e4;
66123
66234
  var SOLANA_CHAIN_ID2 = 900;
66124
66235
  function isBlocked2(r) {
@@ -66193,7 +66304,7 @@ async function runIntentFlow(opts) {
66193
66304
  profile: opts.profileName,
66194
66305
  jsonMode: opts.jsonMode,
66195
66306
  origin: activeProfile.mcpOrigin,
66196
- ttyHeader: import_picocolors17.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
66307
+ ttyHeader: import_picocolors18.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
66197
66308
  });
66198
66309
  } catch (reloginErr) {
66199
66310
  if (opts.jsonMode) {
@@ -66205,7 +66316,7 @@ async function runIntentFlow(opts) {
66205
66316
  process.exit(1);
66206
66317
  }
66207
66318
  process.stderr.write(
66208
- import_picocolors17.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
66319
+ import_picocolors18.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
66209
66320
  `)
66210
66321
  );
66211
66322
  process.exit(1);
@@ -66229,7 +66340,7 @@ async function runIntentFlow(opts) {
66229
66340
  process.exit(1);
66230
66341
  }
66231
66342
  process.stderr.write(
66232
- import_picocolors17.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
66343
+ import_picocolors18.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
66233
66344
  `)
66234
66345
  );
66235
66346
  process.exit(1);
@@ -66246,7 +66357,7 @@ async function runIntentFlow(opts) {
66246
66357
  });
66247
66358
  process.exit(1);
66248
66359
  }
66249
- process.stderr.write(import_picocolors17.default.red(`\u2715 ${err.message} (HTTP ${err.status})
66360
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message} (HTTP ${err.status})
66250
66361
  `));
66251
66362
  process.exit(1);
66252
66363
  } else {
@@ -66268,18 +66379,18 @@ async function runIntentFlow(opts) {
66268
66379
  });
66269
66380
  process.exit(1);
66270
66381
  }
66271
- process.stderr.write(import_picocolors17.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
66382
+ process.stderr.write(import_picocolors18.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
66272
66383
  `));
66273
66384
  if (proposed.upgrade_url) {
66274
66385
  process.stderr.write(
66275
66386
  ` Open this to grant access, then re-run the command:
66276
- ${import_picocolors17.default.cyan(proposed.upgrade_url)}
66387
+ ${import_picocolors18.default.cyan(proposed.upgrade_url)}
66277
66388
  `
66278
66389
  );
66279
66390
  }
66280
66391
  if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
66281
66392
  process.stderr.write(
66282
- import_picocolors17.default.dim(
66393
+ import_picocolors18.default.dim(
66283
66394
  ` Suggested actions:
66284
66395
  ` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
66285
66396
  )
@@ -66302,8 +66413,8 @@ async function runIntentFlow(opts) {
66302
66413
  } else {
66303
66414
  process.stdout.write(
66304
66415
  `
66305
- ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with biometric:
66306
- ${import_picocolors17.default.cyan(proposed.approval_url)}
66416
+ ${import_picocolors18.default.bold("Proposed.")} Open this URL to approve with biometric:
66417
+ ${import_picocolors18.default.cyan(proposed.approval_url)}
66307
66418
 
66308
66419
  `
66309
66420
  );
@@ -66325,7 +66436,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
66325
66436
  if (opts.jsonMode) {
66326
66437
  emitNdjson2({ status: s.status, intent_id: s.approval_id });
66327
66438
  } else {
66328
- process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors17.default.dim("\u2026")}\r`);
66439
+ process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors18.default.dim("\u2026")}\r`);
66329
66440
  }
66330
66441
  }
66331
66442
  });
@@ -66339,7 +66450,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
66339
66450
  profile: opts.profileName,
66340
66451
  jsonMode: opts.jsonMode,
66341
66452
  origin: activeProfile.mcpOrigin,
66342
- ttyHeader: import_picocolors17.default.dim(
66453
+ ttyHeader: import_picocolors18.default.dim(
66343
66454
  "Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
66344
66455
  )
66345
66456
  });
@@ -66354,7 +66465,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
66354
66465
  process.exit(1);
66355
66466
  }
66356
66467
  process.stderr.write(
66357
- "\n" + import_picocolors17.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
66468
+ "\n" + import_picocolors18.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
66358
66469
  `)
66359
66470
  );
66360
66471
  process.exit(1);
@@ -66372,7 +66483,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
66372
66483
  process.exit(1);
66373
66484
  }
66374
66485
  process.stderr.write(
66375
- "\n" + import_picocolors17.default.red(`\u2715 Status poll failed: ${retryErr.message}
66486
+ "\n" + import_picocolors18.default.red(`\u2715 Status poll failed: ${retryErr.message}
66376
66487
  `)
66377
66488
  );
66378
66489
  process.exit(1);
@@ -66388,7 +66499,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
66388
66499
  process.exit(1);
66389
66500
  }
66390
66501
  process.stderr.write(
66391
- "\n" + import_picocolors17.default.red(`\u2715 Status poll failed: ${err.message}
66502
+ "\n" + import_picocolors18.default.red(`\u2715 Status poll failed: ${err.message}
66392
66503
  `)
66393
66504
  );
66394
66505
  process.exit(1);
@@ -66429,39 +66540,39 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
66429
66540
  process.stdout.write("\n");
66430
66541
  const printLegJournal = () => {
66431
66542
  if (legs.length === 0) return;
66432
- process.stdout.write(import_picocolors17.default.bold(" Legs:\n"));
66543
+ process.stdout.write(import_picocolors18.default.bold(" Legs:\n"));
66433
66544
  for (const l of legs) {
66434
- const line = l.status === "mined" ? import_picocolors17.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors17.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors17.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors17.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors17.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
66545
+ const line = l.status === "mined" ? import_picocolors18.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors18.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors18.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors18.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors18.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
66435
66546
  process.stdout.write(` ${line}
66436
66547
  `);
66437
66548
  }
66438
66549
  };
66439
66550
  if (final.status === "mined") {
66440
- process.stdout.write(import_picocolors17.default.green("\u2713 Mined.") + "\n");
66551
+ process.stdout.write(import_picocolors18.default.green("\u2713 Mined.") + "\n");
66441
66552
  if (final.tx_hash) {
66442
66553
  process.stdout.write(` Tx ${final.tx_hash}
66443
66554
  `);
66444
66555
  }
66445
66556
  if (explorer) {
66446
- process.stdout.write(` Explorer ${import_picocolors17.default.cyan(explorer)}
66557
+ process.stdout.write(` Explorer ${import_picocolors18.default.cyan(explorer)}
66447
66558
  `);
66448
66559
  }
66449
66560
  printLegJournal();
66450
66561
  process.exit(0);
66451
66562
  }
66452
66563
  if (final.status === "failed" && failure?.message) {
66453
- process.stderr.write(import_picocolors17.default.red(`\u2715 ${failure.message}
66564
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${failure.message}
66454
66565
  `));
66455
66566
  if (retryCommand) {
66456
66567
  process.stderr.write(` Retry:
66457
- ${import_picocolors17.default.cyan(retryCommand)}
66568
+ ${import_picocolors18.default.cyan(retryCommand)}
66458
66569
  `);
66459
66570
  }
66460
66571
  printLegJournal();
66461
66572
  process.exit(1);
66462
66573
  }
66463
66574
  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}`;
66464
- process.stderr.write(import_picocolors17.default.red(`\u2715 ${label}.
66575
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${label}.
66465
66576
  `));
66466
66577
  printLegJournal();
66467
66578
  process.exit(1);
@@ -66481,7 +66592,7 @@ function isAsset(v) {
66481
66592
  return ASSET_VALUES.has(v.toLowerCase());
66482
66593
  }
66483
66594
  function failArg(msg) {
66484
- process.stderr.write(import_picocolors18.default.red(`\u2715 ${msg}
66595
+ process.stderr.write(import_picocolors19.default.red(`\u2715 ${msg}
66485
66596
  `));
66486
66597
  process.exit(2);
66487
66598
  }
@@ -66489,24 +66600,24 @@ async function swap(amount, fromAsset, opts) {
66489
66600
  const requested = opts.profile ?? DEFAULT_PROFILE;
66490
66601
  const resolved = await resolveProfile(requested);
66491
66602
  if (!resolved) {
66492
- process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
66603
+ process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
66493
66604
  process.exit(2);
66494
66605
  }
66495
66606
  if (resolved.autoSelected) {
66496
- process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66607
+ process.stderr.write(import_picocolors19.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66497
66608
  `));
66498
66609
  }
66499
66610
  const { profile, name: profileName } = resolved;
66500
66611
  const stdoutIsTty = process.stdout.isTTY === true;
66501
- const jsonMode4 = opts.json === true || !stdoutIsTty;
66612
+ const jsonMode5 = opts.json === true || !stdoutIsTty;
66502
66613
  const amountNumber = Number(amount);
66503
66614
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
66504
- failArg(`amount must be a positive number (got ${import_picocolors18.default.bold(amount)}).`);
66615
+ failArg(`amount must be a positive number (got ${import_picocolors19.default.bold(amount)}).`);
66505
66616
  }
66506
66617
  const fromAssetNorm = fromAsset.toLowerCase();
66507
66618
  if (!isAsset(fromAssetNorm)) {
66508
66619
  failArg(
66509
- `from-asset must be ${import_picocolors18.default.bold("native")} or ${import_picocolors18.default.bold("usdc")} (got ${import_picocolors18.default.bold(fromAsset)}).`
66620
+ `from-asset must be ${import_picocolors19.default.bold("native")} or ${import_picocolors19.default.bold("usdc")} (got ${import_picocolors19.default.bold(fromAsset)}).`
66510
66621
  );
66511
66622
  }
66512
66623
  if (!opts.toAsset) {
@@ -66515,7 +66626,7 @@ async function swap(amount, fromAsset, opts) {
66515
66626
  const toAssetNorm = opts.toAsset.toLowerCase();
66516
66627
  if (!isAsset(toAssetNorm)) {
66517
66628
  failArg(
66518
- `--to-asset must be ${import_picocolors18.default.bold("native")} or ${import_picocolors18.default.bold("usdc")} (got ${import_picocolors18.default.bold(opts.toAsset)}).`
66629
+ `--to-asset must be ${import_picocolors19.default.bold("native")} or ${import_picocolors19.default.bold("usdc")} (got ${import_picocolors19.default.bold(opts.toAsset)}).`
66519
66630
  );
66520
66631
  }
66521
66632
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -66637,16 +66748,16 @@ async function swap(amount, fromAsset, opts) {
66637
66748
  body: proposeBody,
66638
66749
  profileName,
66639
66750
  initialProfile: profile,
66640
- jsonMode: jsonMode4,
66751
+ jsonMode: jsonMode5,
66641
66752
  shouldOpenBrowser,
66642
66753
  buildRetryCommand
66643
66754
  });
66644
66755
  }
66645
66756
 
66646
66757
  // src/commands/batch.ts
66647
- var import_picocolors19 = __toESM(require_picocolors(), 1);
66758
+ var import_picocolors20 = __toESM(require_picocolors(), 1);
66648
66759
  function failArg2(msg) {
66649
- process.stderr.write(import_picocolors19.default.red(`\u2715 ${msg}
66760
+ process.stderr.write(import_picocolors20.default.red(`\u2715 ${msg}
66650
66761
  `));
66651
66762
  process.exit(2);
66652
66763
  }
@@ -66654,11 +66765,11 @@ async function batch(opts) {
66654
66765
  const requested = opts.profile ?? DEFAULT_PROFILE;
66655
66766
  const resolved = await resolveProfile(requested);
66656
66767
  if (!resolved) {
66657
- process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
66768
+ process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
66658
66769
  process.exit(2);
66659
66770
  }
66660
66771
  const { name: profileName, profile } = resolved;
66661
- const jsonMode4 = opts.json === true || !process.stdout.isTTY;
66772
+ const jsonMode5 = opts.json === true || !process.stdout.isTTY;
66662
66773
  let legs;
66663
66774
  try {
66664
66775
  legs = JSON.parse(opts.legsJson);
@@ -66702,20 +66813,20 @@ async function batch(opts) {
66702
66813
  },
66703
66814
  profileName,
66704
66815
  initialProfile: profile,
66705
- jsonMode: jsonMode4,
66816
+ jsonMode: jsonMode5,
66706
66817
  shouldOpenBrowser
66707
66818
  });
66708
66819
  }
66709
66820
 
66710
66821
  // src/commands/fund-wallet.ts
66711
- var import_picocolors20 = __toESM(require_picocolors(), 1);
66822
+ var import_picocolors21 = __toESM(require_picocolors(), 1);
66712
66823
  var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
66713
66824
  var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
66714
66825
  function isAddressTarget(target) {
66715
66826
  return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
66716
66827
  }
66717
66828
  function failArg3(msg) {
66718
- process.stderr.write(import_picocolors20.default.red(`\u2715 ${msg}
66829
+ process.stderr.write(import_picocolors21.default.red(`\u2715 ${msg}
66719
66830
  `));
66720
66831
  process.exit(2);
66721
66832
  }
@@ -66723,11 +66834,11 @@ async function fundWallet(address, opts) {
66723
66834
  const requested = opts.profile ?? DEFAULT_PROFILE;
66724
66835
  const resolved = await resolveProfile(requested);
66725
66836
  if (!resolved) {
66726
- process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
66837
+ process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
66727
66838
  process.exit(2);
66728
66839
  }
66729
66840
  const { name: profileName, profile } = resolved;
66730
- const jsonMode4 = opts.json === true || !process.stdout.isTTY;
66841
+ const jsonMode5 = opts.json === true || !process.stdout.isTTY;
66731
66842
  if (!opts.chain) {
66732
66843
  failArg3("--chain is required (1/137/8453/42161/900 or shortName).");
66733
66844
  }
@@ -66779,7 +66890,7 @@ async function fundWallet(address, opts) {
66779
66890
  },
66780
66891
  profileName,
66781
66892
  initialProfile: profile,
66782
- jsonMode: jsonMode4,
66893
+ jsonMode: jsonMode5,
66783
66894
  shouldOpenBrowser
66784
66895
  });
66785
66896
  }
@@ -66794,17 +66905,17 @@ async function fundWallet(address, opts) {
66794
66905
  },
66795
66906
  profileName,
66796
66907
  initialProfile: profile,
66797
- jsonMode: jsonMode4,
66908
+ jsonMode: jsonMode5,
66798
66909
  shouldOpenBrowser
66799
66910
  });
66800
66911
  }
66801
66912
 
66802
66913
  // src/commands/earn-supply.ts
66803
- var import_picocolors21 = __toESM(require_picocolors(), 1);
66914
+ var import_picocolors22 = __toESM(require_picocolors(), 1);
66804
66915
  var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
66805
66916
  var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
66806
66917
  function failArg4(msg) {
66807
- process.stderr.write(import_picocolors21.default.red(`\u2715 ${msg}
66918
+ process.stderr.write(import_picocolors22.default.red(`\u2715 ${msg}
66808
66919
  `));
66809
66920
  process.exit(2);
66810
66921
  }
@@ -66812,24 +66923,24 @@ async function earnSupply(amount, asset, opts) {
66812
66923
  const requested = opts.profile ?? DEFAULT_PROFILE;
66813
66924
  const resolved = await resolveProfile(requested);
66814
66925
  if (!resolved) {
66815
- process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
66926
+ process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
66816
66927
  process.exit(2);
66817
66928
  }
66818
66929
  if (resolved.autoSelected) {
66819
- process.stderr.write(import_picocolors21.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66930
+ process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66820
66931
  `));
66821
66932
  }
66822
66933
  const { profile, name: profileName } = resolved;
66823
66934
  const stdoutIsTty = process.stdout.isTTY === true;
66824
- const jsonMode4 = opts.json === true || !stdoutIsTty;
66935
+ const jsonMode5 = opts.json === true || !stdoutIsTty;
66825
66936
  const amountNumber = Number(amount);
66826
66937
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
66827
- failArg4(`amount must be a positive number (got ${import_picocolors21.default.bold(amount)}).`);
66938
+ failArg4(`amount must be a positive number (got ${import_picocolors22.default.bold(amount)}).`);
66828
66939
  }
66829
66940
  const assetNorm = asset.toLowerCase();
66830
66941
  if (!ASSET_VALUES2.has(assetNorm)) {
66831
66942
  failArg4(
66832
- `asset must be ${import_picocolors21.default.bold("native")} or ${import_picocolors21.default.bold("usdc")} (got ${import_picocolors21.default.bold(asset)}).`
66943
+ `asset must be ${import_picocolors22.default.bold("native")} or ${import_picocolors22.default.bold("usdc")} (got ${import_picocolors22.default.bold(asset)}).`
66833
66944
  );
66834
66945
  }
66835
66946
  if (!opts.chain) {
@@ -66841,7 +66952,7 @@ async function earnSupply(amount, asset, opts) {
66841
66952
  const protocolNorm = opts.protocol.toLowerCase();
66842
66953
  if (!PROTOCOLS.has(protocolNorm)) {
66843
66954
  failArg4(
66844
- `--protocol must be ${import_picocolors21.default.bold("aave_v3")} or ${import_picocolors21.default.bold("kamino_lend")} (got ${import_picocolors21.default.bold(opts.protocol)}).`
66955
+ `--protocol must be ${import_picocolors22.default.bold("aave_v3")} or ${import_picocolors22.default.bold("kamino_lend")} (got ${import_picocolors22.default.bold(opts.protocol)}).`
66845
66956
  );
66846
66957
  }
66847
66958
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -66887,17 +66998,17 @@ async function earnSupply(amount, asset, opts) {
66887
66998
  body: proposeBody,
66888
66999
  profileName,
66889
67000
  initialProfile: profile,
66890
- jsonMode: jsonMode4,
67001
+ jsonMode: jsonMode5,
66891
67002
  shouldOpenBrowser
66892
67003
  });
66893
67004
  }
66894
67005
 
66895
67006
  // src/commands/earn-withdraw.ts
66896
- var import_picocolors22 = __toESM(require_picocolors(), 1);
67007
+ var import_picocolors23 = __toESM(require_picocolors(), 1);
66897
67008
  var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
66898
67009
  var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
66899
67010
  function failArg5(msg) {
66900
- process.stderr.write(import_picocolors22.default.red(`\u2715 ${msg}
67011
+ process.stderr.write(import_picocolors23.default.red(`\u2715 ${msg}
66901
67012
  `));
66902
67013
  process.exit(2);
66903
67014
  }
@@ -66905,29 +67016,29 @@ async function earnWithdraw(amountOrMax, asset, opts) {
66905
67016
  const requested = opts.profile ?? DEFAULT_PROFILE;
66906
67017
  const resolved = await resolveProfile(requested);
66907
67018
  if (!resolved) {
66908
- process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
67019
+ process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
66909
67020
  process.exit(2);
66910
67021
  }
66911
67022
  if (resolved.autoSelected) {
66912
- process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67023
+ process.stderr.write(import_picocolors23.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66913
67024
  `));
66914
67025
  }
66915
67026
  const { profile, name: profileName } = resolved;
66916
67027
  const stdoutIsTty = process.stdout.isTTY === true;
66917
- const jsonMode4 = opts.json === true || !stdoutIsTty;
67028
+ const jsonMode5 = opts.json === true || !stdoutIsTty;
66918
67029
  const isMax = amountOrMax.toLowerCase() === "max";
66919
67030
  if (!isMax) {
66920
67031
  const amountNumber = Number(amountOrMax);
66921
67032
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
66922
67033
  failArg5(
66923
- `<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors22.default.bold(amountOrMax)}).`
67034
+ `<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors23.default.bold(amountOrMax)}).`
66924
67035
  );
66925
67036
  }
66926
67037
  }
66927
67038
  const assetNorm = asset.toLowerCase();
66928
67039
  if (!ASSET_VALUES3.has(assetNorm)) {
66929
67040
  failArg5(
66930
- `asset must be ${import_picocolors22.default.bold("native")} or ${import_picocolors22.default.bold("usdc")} (got ${import_picocolors22.default.bold(asset)}).`
67041
+ `asset must be ${import_picocolors23.default.bold("native")} or ${import_picocolors23.default.bold("usdc")} (got ${import_picocolors23.default.bold(asset)}).`
66931
67042
  );
66932
67043
  }
66933
67044
  if (!opts.chain) {
@@ -66939,7 +67050,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
66939
67050
  const protocolNorm = opts.protocol.toLowerCase();
66940
67051
  if (!PROTOCOLS2.has(protocolNorm)) {
66941
67052
  failArg5(
66942
- `--protocol must be ${import_picocolors22.default.bold("aave_v3")} or ${import_picocolors22.default.bold("kamino_lend")} (got ${import_picocolors22.default.bold(opts.protocol)}).`
67053
+ `--protocol must be ${import_picocolors23.default.bold("aave_v3")} or ${import_picocolors23.default.bold("kamino_lend")} (got ${import_picocolors23.default.bold(opts.protocol)}).`
66943
67054
  );
66944
67055
  }
66945
67056
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -66985,13 +67096,13 @@ async function earnWithdraw(amountOrMax, asset, opts) {
66985
67096
  body: proposeBody,
66986
67097
  profileName,
66987
67098
  initialProfile: profile,
66988
- jsonMode: jsonMode4,
67099
+ jsonMode: jsonMode5,
66989
67100
  shouldOpenBrowser
66990
67101
  });
66991
67102
  }
66992
67103
 
66993
67104
  // src/commands/eat.ts
66994
- var import_picocolors23 = __toESM(require_picocolors(), 1);
67105
+ var import_picocolors24 = __toESM(require_picocolors(), 1);
66995
67106
  function parseLineJson(values) {
66996
67107
  const lines = [];
66997
67108
  for (const value of values) {
@@ -67018,27 +67129,27 @@ function parseLineJson(values) {
67018
67129
  async function loadResolvedProfile(requested) {
67019
67130
  const resolved = await resolveProfile(requested);
67020
67131
  if (!resolved) {
67021
- process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
67132
+ process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
67022
67133
  process.exit(2);
67023
67134
  }
67024
67135
  if (resolved.autoSelected) {
67025
- process.stderr.write(import_picocolors23.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67136
+ process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67026
67137
  `));
67027
67138
  }
67028
67139
  return resolved;
67029
67140
  }
67030
- function printResult(res, jsonMode4) {
67031
- if (jsonMode4) {
67141
+ function printResult(res, jsonMode5) {
67142
+ if (jsonMode5) {
67032
67143
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
67033
67144
  return;
67034
67145
  }
67035
67146
  if (res.blocked) {
67036
- process.stderr.write(import_picocolors23.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
67147
+ process.stderr.write(import_picocolors24.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
67037
67148
  `));
67038
67149
  if (res.upgrade_url) {
67039
67150
  process.stderr.write(
67040
67151
  ` Open this to grant access, then re-run the command:
67041
- ${import_picocolors23.default.cyan(res.upgrade_url)}
67152
+ ${import_picocolors24.default.cyan(res.upgrade_url)}
67042
67153
  `
67043
67154
  );
67044
67155
  }
@@ -67050,49 +67161,49 @@ function printResult(res, jsonMode4) {
67050
67161
  }
67051
67162
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
67052
67163
  }
67053
- async function postRestaurantQuiet(path6, body, resolved) {
67164
+ async function postRestaurantQuiet(path7, body, resolved) {
67054
67165
  try {
67055
67166
  const outcome = await callWithAutoRelogin({
67056
67167
  profile: resolved.profile,
67057
67168
  profileName: resolved.name,
67058
67169
  jsonMode: true,
67059
67170
  ttyHeader: "",
67060
- fn: (bearer, origin) => apiFetch(path6, { method: "POST", bearer, origin, body })
67171
+ fn: (bearer, origin) => apiFetch(path7, { method: "POST", bearer, origin, body })
67061
67172
  });
67062
67173
  return outcome.kind === "ok" ? outcome.result : null;
67063
67174
  } catch {
67064
67175
  return null;
67065
67176
  }
67066
67177
  }
67067
- async function postRestaurant(path6, body, resolved, jsonMode4) {
67178
+ async function postRestaurant(path7, body, resolved, jsonMode5) {
67068
67179
  const outcome = await callWithAutoRelogin({
67069
67180
  profile: resolved.profile,
67070
67181
  profileName: resolved.name,
67071
- jsonMode: jsonMode4,
67072
- ttyHeader: import_picocolors23.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67073
- fn: (bearer, origin) => apiFetch(path6, { method: "POST", bearer, origin, body })
67182
+ jsonMode: jsonMode5,
67183
+ ttyHeader: import_picocolors24.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67184
+ fn: (bearer, origin) => apiFetch(path7, { method: "POST", bearer, origin, body })
67074
67185
  });
67075
67186
  if (outcome.kind === "auth_failed") {
67076
- if (jsonMode4) {
67187
+ if (jsonMode5) {
67077
67188
  process.stdout.write(
67078
67189
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
67079
67190
  );
67080
67191
  process.exit(1);
67081
67192
  }
67082
- process.stderr.write(import_picocolors23.default.red(`\u2715 ${outcome.reason}.
67193
+ process.stderr.write(import_picocolors24.default.red(`\u2715 ${outcome.reason}.
67083
67194
  `));
67084
67195
  process.exit(1);
67085
67196
  }
67086
67197
  if (outcome.kind === "error") {
67087
67198
  const err = outcome.error;
67088
67199
  if (err instanceof ApiError) {
67089
- if (jsonMode4) {
67200
+ if (jsonMode5) {
67090
67201
  process.stdout.write(
67091
67202
  JSON.stringify({ ok: false, status: "request_failed", error: err.message, http_status: err.status }) + "\n"
67092
67203
  );
67093
67204
  process.exit(1);
67094
67205
  }
67095
- process.stderr.write(import_picocolors23.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67206
+ process.stderr.write(import_picocolors24.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67096
67207
  `));
67097
67208
  process.exit(1);
67098
67209
  }
@@ -67102,10 +67213,10 @@ async function postRestaurant(path6, body, resolved, jsonMode4) {
67102
67213
  }
67103
67214
  async function searchFood(opts) {
67104
67215
  const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
67105
- const jsonMode4 = opts.json === true || process.stdout.isTTY !== true;
67216
+ const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
67106
67217
  if (!opts.location && !opts.name) {
67107
67218
  process.stderr.write(
67108
- import_picocolors23.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
67219
+ import_picocolors24.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
67109
67220
  );
67110
67221
  process.exit(2);
67111
67222
  }
@@ -67118,15 +67229,15 @@ async function searchFood(opts) {
67118
67229
  if (opts.radiusMiles !== void 0) body.radius_miles = Number(opts.radiusMiles);
67119
67230
  if (opts.openOnly !== void 0) body.open_only = opts.openOnly;
67120
67231
  if (opts.limit !== void 0) body.limit = Number(opts.limit);
67121
- const result = await postRestaurant("/api/restaurants/search", body, resolved, jsonMode4);
67122
- if (result) printResult(result, jsonMode4);
67232
+ const result = await postRestaurant("/api/restaurants/search", body, resolved, jsonMode5);
67233
+ if (result) printResult(result, jsonMode5);
67123
67234
  }
67124
67235
  async function menuFood(items, opts) {
67125
67236
  const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
67126
- const jsonMode4 = opts.json === true || process.stdout.isTTY !== true;
67237
+ const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
67127
67238
  if (!opts.brand || !opts.address) {
67128
67239
  process.stderr.write(
67129
- import_picocolors23.default.red(
67240
+ import_picocolors24.default.red(
67130
67241
  "\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
67131
67242
  )
67132
67243
  );
@@ -67138,15 +67249,15 @@ async function menuFood(items, opts) {
67138
67249
  intent: opts.intent,
67139
67250
  items: items ?? []
67140
67251
  };
67141
- const result = await postRestaurant("/api/restaurants/menu", body, resolved, jsonMode4);
67142
- if (result) printResult(result, jsonMode4);
67252
+ const result = await postRestaurant("/api/restaurants/menu", body, resolved, jsonMode5);
67253
+ if (result) printResult(result, jsonMode5);
67143
67254
  }
67144
67255
  async function orderFood(items, opts) {
67145
67256
  const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
67146
- const jsonMode4 = opts.json === true || process.stdout.isTTY !== true;
67257
+ const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
67147
67258
  if (!opts.brand || !opts.address) {
67148
67259
  process.stderr.write(
67149
- import_picocolors23.default.red(
67260
+ import_picocolors24.default.red(
67150
67261
  "\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
67151
67262
  )
67152
67263
  );
@@ -67156,14 +67267,14 @@ async function orderFood(items, opts) {
67156
67267
  try {
67157
67268
  structuredLines = parseLineJson(opts.lineJson ?? []);
67158
67269
  } catch (e) {
67159
- process.stderr.write(import_picocolors23.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
67270
+ process.stderr.write(import_picocolors24.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
67160
67271
  `));
67161
67272
  process.exit(2);
67162
67273
  }
67163
67274
  const lines = [...items ?? [], ...structuredLines];
67164
67275
  if (lines.length === 0) {
67165
67276
  process.stderr.write(
67166
- import_picocolors23.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")
67277
+ import_picocolors24.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")
67167
67278
  );
67168
67279
  process.exit(2);
67169
67280
  }
@@ -67174,9 +67285,9 @@ async function orderFood(items, opts) {
67174
67285
  fulfillment: opts.fulfillment,
67175
67286
  intent: opts.intent
67176
67287
  };
67177
- const result = await postRestaurant("/api/restaurants/order", body, resolved, jsonMode4);
67288
+ const result = await postRestaurant("/api/restaurants/order", body, resolved, jsonMode5);
67178
67289
  if (!result) return;
67179
- printResult(result, jsonMode4);
67290
+ printResult(result, jsonMode5);
67180
67291
  const approvalUrl = typeof result.approval_url === "string" ? result.approval_url : null;
67181
67292
  const browserAllowed = (() => {
67182
67293
  if (opts.browserMode === "open") return true;
@@ -67195,9 +67306,9 @@ async function orderFood(items, opts) {
67195
67306
  return;
67196
67307
  }
67197
67308
  if (!agentCard.will_attempt) {
67198
- if (!jsonMode4) {
67309
+ if (!jsonMode5) {
67199
67310
  process.stderr.write(
67200
- import_picocolors23.default.yellow(
67311
+ import_picocolors24.default.yellow(
67201
67312
  `This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
67202
67313
  `
67203
67314
  )
@@ -67206,15 +67317,15 @@ async function orderFood(items, opts) {
67206
67317
  openApproval();
67207
67318
  return;
67208
67319
  }
67209
- const verdict = await pollOrderVerdict(orderId, resolved, jsonMode4);
67210
- if (jsonMode4) {
67320
+ const verdict = await pollOrderVerdict(orderId, resolved, jsonMode5);
67321
+ if (jsonMode5) {
67211
67322
  process.stdout.write(JSON.stringify(verdict) + "\n");
67212
67323
  if (verdict.status === "failed") return;
67213
67324
  return;
67214
67325
  }
67215
67326
  if (verdict.status === "paid") {
67216
67327
  process.stdout.write(
67217
- import_picocolors23.default.green(
67328
+ import_picocolors24.default.green(
67218
67329
  `Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
67219
67330
  )
67220
67331
  );
@@ -67222,7 +67333,7 @@ async function orderFood(items, opts) {
67222
67333
  }
67223
67334
  if (verdict.status === "failed") {
67224
67335
  process.stderr.write(
67225
- import_picocolors23.default.yellow(
67336
+ import_picocolors24.default.yellow(
67226
67337
  `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.
67227
67338
  `
67228
67339
  )
@@ -67232,7 +67343,7 @@ async function orderFood(items, opts) {
67232
67343
  }
67233
67344
  if (verdict.status === "unconfirmed") {
67234
67345
  process.stderr.write(
67235
- import_picocolors23.default.red(
67346
+ import_picocolors24.default.red(
67236
67347
  "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}
67237
67348
  ` : "")
67238
67349
  )
@@ -67241,7 +67352,7 @@ async function orderFood(items, opts) {
67241
67352
  return;
67242
67353
  }
67243
67354
  process.stderr.write(
67244
- import_picocolors23.default.dim(
67355
+ import_picocolors24.default.dim(
67245
67356
  `Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
67246
67357
  )
67247
67358
  );
@@ -67264,9 +67375,9 @@ function fmtCents(cents) {
67264
67375
  }
67265
67376
  var POLL_BUDGET_MS = 1e5;
67266
67377
  var POLL_INTERVAL_MS2 = 3500;
67267
- async function pollOrderVerdict(orderId, resolved, jsonMode4) {
67268
- if (!jsonMode4) {
67269
- process.stderr.write(import_picocolors23.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
67378
+ async function pollOrderVerdict(orderId, resolved, jsonMode5) {
67379
+ if (!jsonMode5) {
67380
+ process.stderr.write(import_picocolors24.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
67270
67381
  }
67271
67382
  const deadline = Date.now() + POLL_BUDGET_MS;
67272
67383
  let last = {
@@ -67296,19 +67407,19 @@ async function pollOrderVerdict(orderId, resolved, jsonMode4) {
67296
67407
  }
67297
67408
  async function statusFood(orderId, opts) {
67298
67409
  const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
67299
- const jsonMode4 = opts.json === true || process.stdout.isTTY !== true;
67410
+ const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
67300
67411
  const result = await postRestaurant(
67301
67412
  "/api/restaurants/order-status",
67302
67413
  { order_id: orderId.trim() },
67303
67414
  resolved,
67304
- jsonMode4
67415
+ jsonMode5
67305
67416
  );
67306
67417
  if (!result) return;
67307
67418
  if (result.blocked) {
67308
- printResult(result, jsonMode4);
67419
+ printResult(result, jsonMode5);
67309
67420
  return;
67310
67421
  }
67311
- if (jsonMode4) {
67422
+ if (jsonMode5) {
67312
67423
  process.stdout.write(JSON.stringify(result, null, 2) + "\n");
67313
67424
  return;
67314
67425
  }
@@ -67336,40 +67447,40 @@ async function statusFood(orderId, opts) {
67336
67447
  }
67337
67448
 
67338
67449
  // src/commands/bounties.ts
67339
- var import_picocolors24 = __toESM(require_picocolors(), 1);
67340
- async function withProfile(opts, path6, init2) {
67450
+ var import_picocolors25 = __toESM(require_picocolors(), 1);
67451
+ async function withProfile(opts, path7, init2) {
67341
67452
  const requested = opts.profile ?? DEFAULT_PROFILE;
67342
67453
  const resolved = await resolveProfile(requested);
67343
67454
  if (!resolved) {
67344
- process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
67455
+ process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
67345
67456
  process.exit(2);
67346
67457
  }
67347
67458
  if (resolved.autoSelected) {
67348
- process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67459
+ process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67349
67460
  `));
67350
67461
  }
67351
67462
  const { profile, name: profileName } = resolved;
67352
- const jsonMode4 = opts.json === true;
67463
+ const jsonMode5 = opts.json === true;
67353
67464
  const outcome = await callWithAutoRelogin({
67354
67465
  profile,
67355
67466
  profileName,
67356
- jsonMode: jsonMode4,
67357
- ttyHeader: import_picocolors24.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67358
- fn: (bearer, origin) => apiFetch(path6, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
67467
+ jsonMode: jsonMode5,
67468
+ ttyHeader: import_picocolors25.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67469
+ fn: (bearer, origin) => apiFetch(path7, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
67359
67470
  });
67360
67471
  if (outcome.kind === "auth_failed") {
67361
- if (jsonMode4) {
67472
+ if (jsonMode5) {
67362
67473
  process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
67363
67474
  process.exit(1);
67364
67475
  }
67365
- process.stderr.write(import_picocolors24.default.red(`\u2715 ${outcome.reason}.
67476
+ process.stderr.write(import_picocolors25.default.red(`\u2715 ${outcome.reason}.
67366
67477
  `));
67367
67478
  process.exit(1);
67368
67479
  }
67369
67480
  if (outcome.kind === "error") {
67370
67481
  const err = outcome.error;
67371
67482
  if (err instanceof ApiError) {
67372
- process.stderr.write(import_picocolors24.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67483
+ process.stderr.write(import_picocolors25.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67373
67484
  `));
67374
67485
  process.exit(1);
67375
67486
  }
@@ -67377,18 +67488,18 @@ async function withProfile(opts, path6, init2) {
67377
67488
  }
67378
67489
  return outcome.result;
67379
67490
  }
67380
- function handleBlocked(res, jsonMode4) {
67491
+ function handleBlocked(res, jsonMode5) {
67381
67492
  if (!res.blocked) return false;
67382
- if (jsonMode4) {
67493
+ if (jsonMode5) {
67383
67494
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
67384
67495
  process.exit(1);
67385
67496
  }
67386
- process.stderr.write(import_picocolors24.default.yellow(`
67497
+ process.stderr.write(import_picocolors25.default.yellow(`
67387
67498
  ${res.reason ?? "Blocked."}
67388
67499
  `));
67389
67500
  if (res.upgrade_url) {
67390
67501
  process.stderr.write(`
67391
- ${import_picocolors24.default.bold(res.upgrade_url)}
67502
+ ${import_picocolors25.default.bold(res.upgrade_url)}
67392
67503
 
67393
67504
  `);
67394
67505
  }
@@ -67431,30 +67542,30 @@ function printTable(rows) {
67431
67542
  const cLeft = w("left", 4);
67432
67543
  const cSubs = w("subs", 4);
67433
67544
  process.stdout.write(
67434
- import_picocolors24.default.dim(
67545
+ import_picocolors25.default.dim(
67435
67546
  "Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
67436
67547
  ) + "\n"
67437
67548
  );
67438
67549
  for (const c of cells) {
67439
- const title = c.live ? import_picocolors24.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
67550
+ const title = c.live ? import_picocolors25.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
67440
67551
  process.stdout.write(
67441
- import_picocolors24.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors24.default.dim(c.id) + "\n"
67552
+ import_picocolors25.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors25.default.dim(c.id) + "\n"
67442
67553
  );
67443
67554
  }
67444
67555
  }
67445
67556
  async function listBounties(opts) {
67446
- const jsonMode4 = opts.json === true;
67557
+ const jsonMode5 = opts.json === true;
67447
67558
  const res = await withProfile(opts, "/api/bounties");
67448
- handleBlocked(res, jsonMode4);
67559
+ handleBlocked(res, jsonMode5);
67449
67560
  let rows = res.bounties ?? [];
67450
67561
  const min = opts.min !== void 0 ? Number(opts.min) : void 0;
67451
67562
  const max = opts.max !== void 0 ? Number(opts.max) : void 0;
67452
67563
  if (min !== void 0 && !Number.isFinite(min)) {
67453
- process.stderr.write(import_picocolors24.default.red("\u2715 --min must be a number.\n"));
67564
+ process.stderr.write(import_picocolors25.default.red("\u2715 --min must be a number.\n"));
67454
67565
  process.exit(2);
67455
67566
  }
67456
67567
  if (max !== void 0 && !Number.isFinite(max)) {
67457
- process.stderr.write(import_picocolors24.default.red("\u2715 --max must be a number.\n"));
67568
+ process.stderr.write(import_picocolors25.default.red("\u2715 --max must be a number.\n"));
67458
67569
  process.exit(2);
67459
67570
  }
67460
67571
  rows = rows.filter((r) => {
@@ -67479,22 +67590,22 @@ async function listBounties(opts) {
67479
67590
  });
67480
67591
  const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
67481
67592
  if (!Number.isFinite(limit) || limit <= 0) {
67482
- process.stderr.write(import_picocolors24.default.red("\u2715 --limit must be a positive number.\n"));
67593
+ process.stderr.write(import_picocolors25.default.red("\u2715 --limit must be a positive number.\n"));
67483
67594
  process.exit(2);
67484
67595
  }
67485
67596
  const shown2 = rows.slice(0, limit);
67486
- if (jsonMode4) {
67597
+ if (jsonMode5) {
67487
67598
  process.stdout.write(JSON.stringify({ bounties: shown2, matched: rows.length }, null, 2) + "\n");
67488
67599
  return;
67489
67600
  }
67490
67601
  if (shown2.length === 0) {
67491
- process.stdout.write(import_picocolors24.default.dim("No active bounties match.\n"));
67602
+ process.stdout.write(import_picocolors25.default.dim("No active bounties match.\n"));
67492
67603
  return;
67493
67604
  }
67494
67605
  printTable(shown2);
67495
67606
  const clipped = rows.length - shown2.length;
67496
67607
  process.stdout.write(
67497
- "\n" + import_picocolors24.default.dim(
67608
+ "\n" + import_picocolors25.default.dim(
67498
67609
  `${shown2.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
67499
67610
  `
67500
67611
  )
@@ -67502,58 +67613,58 @@ async function listBounties(opts) {
67502
67613
  process.stdout.write(AI_DIRECTIVE + "\n");
67503
67614
  }
67504
67615
  async function showBounty(id2, opts) {
67505
- const jsonMode4 = opts.json === true;
67616
+ const jsonMode5 = opts.json === true;
67506
67617
  const clean = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
67507
67618
  if (!clean) {
67508
- process.stderr.write(import_picocolors24.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
67619
+ process.stderr.write(import_picocolors25.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
67509
67620
  process.exit(2);
67510
67621
  }
67511
67622
  const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean)}`);
67512
- handleBlocked(res, jsonMode4);
67513
- if (jsonMode4) {
67623
+ handleBlocked(res, jsonMode5);
67624
+ if (jsonMode5) {
67514
67625
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
67515
67626
  return;
67516
67627
  }
67517
67628
  const b2 = res.bounty;
67518
67629
  if (!b2) {
67519
- process.stdout.write(import_picocolors24.default.dim("Not found.\n"));
67630
+ process.stdout.write(import_picocolors25.default.dim("Not found.\n"));
67520
67631
  return;
67521
67632
  }
67522
- process.stdout.write("\n" + import_picocolors24.default.bold(b2.title) + "\n\n");
67633
+ process.stdout.write("\n" + import_picocolors25.default.bold(b2.title) + "\n\n");
67523
67634
  process.stdout.write(b2.description + "\n\n");
67524
67635
  process.stdout.write(
67525
- import_picocolors24.default.bold(fmtAmount(b2.amount)) + import_picocolors24.default.dim(" USDC") + import_picocolors24.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors24.default.green(" \xB7 LIVE now") : "") + "\n"
67636
+ import_picocolors25.default.bold(fmtAmount(b2.amount)) + import_picocolors25.default.dim(" USDC") + import_picocolors25.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors25.default.green(" \xB7 LIVE now") : "") + "\n"
67526
67637
  );
67527
67638
  if (b2.claimsAllowed && b2.claimsAllowed > 1) {
67528
67639
  const left = Math.max(0, b2.claimsAllowed - (b2.claimsPaid ?? 0));
67529
67640
  process.stdout.write(
67530
- import_picocolors24.default.dim(
67641
+ import_picocolors25.default.dim(
67531
67642
  `${left} of ${b2.claimsAllowed} claims left` + (b2.perClaimAmount != null ? `, ${fmtAmount(b2.perClaimAmount)} each` : "")
67532
67643
  ) + "\n"
67533
67644
  );
67534
67645
  }
67535
- if (b2.evidenceType) process.stdout.write(import_picocolors24.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
67536
- if (b2.expiresAt) process.stdout.write(import_picocolors24.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
67646
+ if (b2.evidenceType) process.stdout.write(import_picocolors25.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
67647
+ if (b2.expiresAt) process.stdout.write(import_picocolors25.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
67537
67648
  if (b2.geoLabel && b2.geoScope !== "global") {
67538
- process.stdout.write(import_picocolors24.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
67649
+ process.stdout.write(import_picocolors25.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
67539
67650
  }
67540
67651
  if (res.url) process.stdout.write("\n" + res.url + "\n");
67541
67652
  process.stdout.write(AI_DIRECTIVE + "\n");
67542
67653
  }
67543
67654
  async function myBounties(opts) {
67544
- const jsonMode4 = opts.json === true;
67655
+ const jsonMode5 = opts.json === true;
67545
67656
  const res = await withProfile(opts, "/api/bounties?mine=1");
67546
- handleBlocked(res, jsonMode4);
67657
+ handleBlocked(res, jsonMode5);
67547
67658
  const all = res.bounties ?? [];
67548
67659
  const status3 = opts.status?.trim().toUpperCase();
67549
67660
  const rows = status3 ? all.filter((r) => (r.status ?? "").toUpperCase() === status3) : all;
67550
- if (jsonMode4) {
67661
+ if (jsonMode5) {
67551
67662
  process.stdout.write(JSON.stringify({ bounties: rows, submissions: res.submissions ?? [] }, null, 2) + "\n");
67552
67663
  return;
67553
67664
  }
67554
67665
  if (rows.length === 0) {
67555
67666
  process.stdout.write(
67556
- import_picocolors24.default.dim(
67667
+ import_picocolors25.default.dim(
67557
67668
  status3 ? `No bounties of yours are ${status3}.
67558
67669
  ` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
67559
67670
  )
@@ -67563,38 +67674,38 @@ async function myBounties(opts) {
67563
67674
  printTable(rows);
67564
67675
  const subs = res.submissions ?? [];
67565
67676
  if (subs.length > 0) {
67566
- process.stdout.write("\n" + import_picocolors24.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
67677
+ process.stdout.write("\n" + import_picocolors25.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
67567
67678
  `));
67568
67679
  }
67569
67680
  process.stdout.write(AI_DIRECTIVE + "\n");
67570
67681
  }
67571
67682
  async function bountyFeed(opts) {
67572
- const jsonMode4 = opts.json === true;
67683
+ const jsonMode5 = opts.json === true;
67573
67684
  const params = new URLSearchParams();
67574
67685
  if (opts.limit) params.set("limit", opts.limit);
67575
67686
  if (opts.type) params.set("type", opts.type);
67576
67687
  const qs = params.toString();
67577
67688
  const res = await withProfile(opts, `/api/bounties/feed${qs ? `?${qs}` : ""}`);
67578
- handleBlocked(res, jsonMode4);
67579
- if (jsonMode4) {
67689
+ handleBlocked(res, jsonMode5);
67690
+ if (jsonMode5) {
67580
67691
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
67581
67692
  return;
67582
67693
  }
67583
67694
  const subs = res.submissions ?? [];
67584
67695
  if (subs.length === 0) {
67585
- process.stdout.write(import_picocolors24.default.dim("Nothing in the feed for that filter.\n"));
67696
+ process.stdout.write(import_picocolors25.default.dim("Nothing in the feed for that filter.\n"));
67586
67697
  return;
67587
67698
  }
67588
67699
  process.stdout.write(
67589
- `${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors24.default.dim(" More available.") : "") + "\n"
67700
+ `${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors25.default.dim(" More available.") : "") + "\n"
67590
67701
  );
67591
- process.stdout.write(import_picocolors24.default.dim("Use --json for the full rows.\n"));
67702
+ process.stdout.write(import_picocolors25.default.dim("Use --json for the full rows.\n"));
67592
67703
  }
67593
67704
  async function draftBounty(opts) {
67594
- const jsonMode4 = opts.json === true;
67705
+ const jsonMode5 = opts.json === true;
67595
67706
  const amountNum = Number(opts.amount);
67596
67707
  if (!Number.isFinite(amountNum) || amountNum <= 0) {
67597
- process.stderr.write(import_picocolors24.default.red("\u2715 --amount must be a positive number of USDC.\n"));
67708
+ process.stderr.write(import_picocolors25.default.red("\u2715 --amount must be a positive number of USDC.\n"));
67598
67709
  process.exit(2);
67599
67710
  }
67600
67711
  const res = await withProfile(opts, "/api/bounties", {
@@ -67607,42 +67718,42 @@ async function draftBounty(opts) {
67607
67718
  evidenceType: opts.evidenceType
67608
67719
  }
67609
67720
  });
67610
- handleBlocked(res, jsonMode4);
67611
- if (jsonMode4) {
67721
+ handleBlocked(res, jsonMode5);
67722
+ if (jsonMode5) {
67612
67723
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
67613
67724
  return;
67614
67725
  }
67615
- process.stdout.write("\n" + import_picocolors24.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
67726
+ process.stdout.write("\n" + import_picocolors25.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
67616
67727
 
67617
67728
  `);
67618
- process.stdout.write(import_picocolors24.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
67729
+ process.stdout.write(import_picocolors25.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
67619
67730
  if (res.fund_url) {
67620
- process.stdout.write("\nFund it here:\n" + import_picocolors24.default.bold(res.fund_url) + "\n\n");
67621
- process.stdout.write(import_picocolors24.default.dim("Funding happens in your browser with your own wallet.\n"));
67731
+ process.stdout.write("\nFund it here:\n" + import_picocolors25.default.bold(res.fund_url) + "\n\n");
67732
+ process.stdout.write(import_picocolors25.default.dim("Funding happens in your browser with your own wallet.\n"));
67622
67733
  }
67623
67734
  }
67624
67735
 
67625
67736
  // src/commands/bounty-money.ts
67626
- var import_picocolors25 = __toESM(require_picocolors(), 1);
67737
+ var import_picocolors26 = __toESM(require_picocolors(), 1);
67627
67738
  function failArg6(message) {
67628
- process.stderr.write(import_picocolors25.default.red(`${message}
67739
+ process.stderr.write(import_picocolors26.default.red(`${message}
67629
67740
  `));
67630
67741
  process.exit(2);
67631
67742
  }
67632
- async function loadProfileOrExit(requested, jsonMode4) {
67743
+ async function loadProfileOrExit(requested, jsonMode5) {
67633
67744
  const resolved = await resolveProfile(requested);
67634
67745
  if (!resolved) {
67635
- if (jsonMode4) {
67746
+ if (jsonMode5) {
67636
67747
  process.stdout.write(
67637
67748
  JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
67638
67749
  );
67639
67750
  } else {
67640
- process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
67751
+ process.stderr.write(import_picocolors26.default.red("Not logged in. Run agentgates login first.\n"));
67641
67752
  }
67642
67753
  process.exit(2);
67643
67754
  }
67644
- if (resolved.autoSelected && !jsonMode4) {
67645
- process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67755
+ if (resolved.autoSelected && !jsonMode5) {
67756
+ process.stderr.write(import_picocolors26.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67646
67757
  `));
67647
67758
  }
67648
67759
  return { profile: resolved.profile, profileName: resolved.name };
@@ -67661,8 +67772,8 @@ function resolveMaxUsd(opts, profile, fallbackHint) {
67661
67772
  );
67662
67773
  }
67663
67774
  async function fundBounty(bountyId, opts) {
67664
- const jsonMode4 = Boolean(opts.json) || !process.stdout.isTTY;
67665
- const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode4);
67775
+ const jsonMode5 = Boolean(opts.json) || !process.stdout.isTTY;
67776
+ const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode5);
67666
67777
  const maxUsd = resolveMaxUsd(opts, profile, "agentgates fund");
67667
67778
  return runIntentFlow({
67668
67779
  endpoint: "/api/intents/propose-fund-bounty",
@@ -67681,17 +67792,17 @@ async function fundBounty(bountyId, opts) {
67681
67792
  },
67682
67793
  profileName,
67683
67794
  initialProfile: profile,
67684
- jsonMode: jsonMode4,
67795
+ jsonMode: jsonMode5,
67685
67796
  shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
67686
67797
  });
67687
67798
  }
67688
67799
  async function tipBounty(bountyId, amount, opts) {
67689
- const jsonMode4 = Boolean(opts.json) || !process.stdout.isTTY;
67800
+ const jsonMode5 = Boolean(opts.json) || !process.stdout.isTTY;
67690
67801
  const amt = Number(amount);
67691
67802
  if (!Number.isFinite(amt) || amt <= 0) {
67692
67803
  failArg6(`amount must be a positive USDC number (got ${amount}).`);
67693
67804
  }
67694
- const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode4);
67805
+ const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode5);
67695
67806
  const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "agentgates tip") : Math.ceil(amt * 1.01 * 100) / 100;
67696
67807
  return runIntentFlow({
67697
67808
  endpoint: "/api/intents/propose-tip",
@@ -67711,17 +67822,17 @@ async function tipBounty(bountyId, amount, opts) {
67711
67822
  },
67712
67823
  profileName,
67713
67824
  initialProfile: profile,
67714
- jsonMode: jsonMode4,
67825
+ jsonMode: jsonMode5,
67715
67826
  shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
67716
67827
  });
67717
67828
  }
67718
67829
  async function subscribeCreator(creatorUserId, opts) {
67719
- const jsonMode4 = Boolean(opts.json) || !process.stdout.isTTY;
67830
+ const jsonMode5 = Boolean(opts.json) || !process.stdout.isTTY;
67720
67831
  const months = opts.months === void 0 ? 1 : Number(opts.months);
67721
67832
  if (![1, 3, 12].includes(months)) {
67722
67833
  failArg6(`--months must be 1, 3 or 12 (got ${opts.months}). Prepaid periods only \u2014 no auto-renew exists.`);
67723
67834
  }
67724
- const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode4);
67835
+ const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode5);
67725
67836
  const maxUsd = resolveMaxUsd(opts, profile, "agentgates subscribe");
67726
67837
  return runIntentFlow({
67727
67838
  endpoint: "/api/intents/propose-subscribe",
@@ -67741,48 +67852,48 @@ async function subscribeCreator(creatorUserId, opts) {
67741
67852
  },
67742
67853
  profileName,
67743
67854
  initialProfile: profile,
67744
- jsonMode: jsonMode4,
67855
+ jsonMode: jsonMode5,
67745
67856
  shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
67746
67857
  });
67747
67858
  }
67748
67859
 
67749
67860
  // src/commands/bounty-work.ts
67750
- var import_picocolors26 = __toESM(require_picocolors(), 1);
67751
- async function runWork(path6, body, opts) {
67861
+ var import_picocolors27 = __toESM(require_picocolors(), 1);
67862
+ async function runWork(path7, body, opts) {
67752
67863
  const requested = opts.profile ?? DEFAULT_PROFILE;
67753
67864
  const resolved = await resolveProfile(requested);
67754
67865
  if (!resolved) {
67755
- process.stderr.write(import_picocolors26.default.red("Not logged in. Run agentgates login first.\n"));
67866
+ process.stderr.write(import_picocolors27.default.red("Not logged in. Run agentgates login first.\n"));
67756
67867
  process.exit(2);
67757
67868
  }
67758
67869
  if (resolved.autoSelected) {
67759
- process.stderr.write(import_picocolors26.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67870
+ process.stderr.write(import_picocolors27.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67760
67871
  `));
67761
67872
  }
67762
- const jsonMode4 = opts.json === true;
67873
+ const jsonMode5 = opts.json === true;
67763
67874
  const outcome = await callWithAutoRelogin({
67764
67875
  profile: resolved.profile,
67765
67876
  profileName: resolved.name,
67766
- jsonMode: jsonMode4,
67767
- ttyHeader: import_picocolors26.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67768
- fn: (bearer, origin) => apiFetch(path6, { bearer, origin, method: "POST", body })
67877
+ jsonMode: jsonMode5,
67878
+ ttyHeader: import_picocolors27.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67879
+ fn: (bearer, origin) => apiFetch(path7, { bearer, origin, method: "POST", body })
67769
67880
  });
67770
67881
  if (outcome.kind === "auth_failed") {
67771
- if (jsonMode4) {
67882
+ if (jsonMode5) {
67772
67883
  process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
67773
67884
  process.exit(1);
67774
67885
  }
67775
- process.stderr.write(import_picocolors26.default.red(`\u2715 ${outcome.reason}.
67886
+ process.stderr.write(import_picocolors27.default.red(`\u2715 ${outcome.reason}.
67776
67887
  `));
67777
67888
  process.exit(1);
67778
67889
  }
67779
67890
  if (outcome.kind === "error") {
67780
67891
  const err = outcome.error;
67781
67892
  if (err instanceof ApiError) {
67782
- if (jsonMode4) {
67893
+ if (jsonMode5) {
67783
67894
  process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
67784
67895
  } else {
67785
- process.stderr.write(import_picocolors26.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67896
+ process.stderr.write(import_picocolors27.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67786
67897
  `));
67787
67898
  }
67788
67899
  process.exit(1);
@@ -67791,29 +67902,29 @@ async function runWork(path6, body, opts) {
67791
67902
  }
67792
67903
  const data4 = outcome.result;
67793
67904
  if (data4.blocked) {
67794
- if (jsonMode4) {
67905
+ if (jsonMode5) {
67795
67906
  process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
67796
67907
  process.exit(1);
67797
67908
  }
67798
- process.stderr.write(import_picocolors26.default.yellow(`
67909
+ process.stderr.write(import_picocolors27.default.yellow(`
67799
67910
  ${data4.reason ?? "Blocked."}
67800
67911
  `));
67801
67912
  if (data4.upgrade_url) process.stderr.write(`
67802
- ${import_picocolors26.default.bold(data4.upgrade_url)}
67913
+ ${import_picocolors27.default.bold(data4.upgrade_url)}
67803
67914
 
67804
67915
  `);
67805
67916
  process.exit(1);
67806
67917
  }
67807
67918
  if (typeof data4.error === "string" && data4.error) {
67808
- if (jsonMode4) {
67919
+ if (jsonMode5) {
67809
67920
  process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
67810
67921
  } else {
67811
- process.stderr.write(import_picocolors26.default.red(`\u2715 ${data4.error}
67922
+ process.stderr.write(import_picocolors27.default.red(`\u2715 ${data4.error}
67812
67923
  `));
67813
67924
  }
67814
67925
  process.exit(1);
67815
67926
  }
67816
- if (jsonMode4) {
67927
+ if (jsonMode5) {
67817
67928
  process.stdout.write(JSON.stringify({ ok: true, ...data4 }) + "\n");
67818
67929
  return;
67819
67930
  }
@@ -67851,43 +67962,43 @@ async function bountyRetention(bountyId, opts) {
67851
67962
  }
67852
67963
 
67853
67964
  // src/commands/bounty-deliver.ts
67854
- var import_picocolors27 = __toESM(require_picocolors(), 1);
67855
- import { spawn } from "node:child_process";
67965
+ var import_picocolors28 = __toESM(require_picocolors(), 1);
67966
+ import { spawn as spawn2 } from "node:child_process";
67856
67967
  var FLUSH_MS = 400;
67857
67968
  var FLUSH_BYTES = 2048;
67858
67969
  async function deliver(bountyId, command, opts) {
67859
- const jsonMode4 = opts.json === true;
67970
+ const jsonMode5 = opts.json === true;
67860
67971
  const requested = opts.profile ?? DEFAULT_PROFILE;
67861
67972
  const resolved = await resolveProfile(requested);
67862
67973
  if (!resolved) {
67863
- process.stderr.write(import_picocolors27.default.red("Not logged in. Run agentgates login first.\n"));
67974
+ process.stderr.write(import_picocolors28.default.red("Not logged in. Run agentgates login first.\n"));
67864
67975
  process.exit(2);
67865
67976
  }
67866
- if (resolved.autoSelected && !jsonMode4) {
67867
- process.stderr.write(import_picocolors27.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67977
+ if (resolved.autoSelected && !jsonMode5) {
67978
+ process.stderr.write(import_picocolors28.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67868
67979
  `));
67869
67980
  }
67870
- const post = async (path6, body) => {
67981
+ const post = async (path7, body) => {
67871
67982
  const outcome = await callWithAutoRelogin({
67872
67983
  profile: resolved.profile,
67873
67984
  profileName: resolved.name,
67874
- jsonMode: jsonMode4,
67875
- ttyHeader: import_picocolors27.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67876
- fn: (bearer, origin) => apiFetch(path6, { bearer, origin, method: "POST", body })
67985
+ jsonMode: jsonMode5,
67986
+ ttyHeader: import_picocolors28.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67987
+ fn: (bearer, origin) => apiFetch(path7, { bearer, origin, method: "POST", body })
67877
67988
  });
67878
67989
  if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
67879
67990
  if (outcome.kind === "error") throw outcome.error;
67880
67991
  return outcome.result;
67881
67992
  };
67882
67993
  const die = (msg, data4) => {
67883
- if (jsonMode4) {
67994
+ if (jsonMode5) {
67884
67995
  process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
67885
67996
  } else {
67886
- process.stderr.write(import_picocolors27.default.red(`
67997
+ process.stderr.write(import_picocolors28.default.red(`
67887
67998
  \u2715 ${msg}
67888
67999
  `));
67889
68000
  if (data4?.upgrade_url) process.stderr.write(`
67890
- ${import_picocolors27.default.bold(data4.upgrade_url)}
68001
+ ${import_picocolors28.default.bold(data4.upgrade_url)}
67891
68002
 
67892
68003
  `);
67893
68004
  }
@@ -67910,9 +68021,9 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
67910
68021
  if (started.error) return void die(started.error, started);
67911
68022
  const runId = started.run_id;
67912
68023
  if (!runId) return void die("The service opened a run but did not name it.");
67913
- if (!jsonMode4) {
68024
+ if (!jsonMode5) {
67914
68025
  process.stderr.write(
67915
- import_picocolors27.default.bold("\n\u25CF LIVE ") + import_picocolors27.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors27.default.dim(` ${started.url ?? ""}
68026
+ import_picocolors28.default.bold("\n\u25CF LIVE ") + import_picocolors28.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors28.default.dim(` ${started.url ?? ""}
67916
68027
 
67917
68028
  `)
67918
68029
  );
@@ -67941,7 +68052,7 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
67941
68052
  const timer = setInterval(() => flush(true), FLUSH_MS);
67942
68053
  const consume = (data4) => {
67943
68054
  buffer += data4;
67944
- if (!opts.quiet && !jsonMode4) process.stderr.write(data4);
68055
+ if (!opts.quiet && !jsonMode5) process.stderr.write(data4);
67945
68056
  flush();
67946
68057
  };
67947
68058
  let exitCode = 0;
@@ -67956,7 +68067,7 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
67956
68067
  });
67957
68068
  } else {
67958
68069
  exitCode = await new Promise((resolve2) => {
67959
- const child = spawn(command[0], command.slice(1), {
68070
+ const child = spawn2(command[0], command.slice(1), {
67960
68071
  stdio: ["inherit", "pipe", "pipe"],
67961
68072
  env: process.env
67962
68073
  });
@@ -67964,10 +68075,10 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
67964
68075
  child.stdout.on("data", (d) => consume(d));
67965
68076
  child.stderr.setEncoding("utf8");
67966
68077
  child.stderr.on("data", (d) => {
67967
- if (!jsonMode4) process.stderr.write(import_picocolors27.default.dim(d));
68078
+ if (!jsonMode5) process.stderr.write(import_picocolors28.default.dim(d));
67968
68079
  });
67969
68080
  child.on("error", (err) => {
67970
- process.stderr.write(import_picocolors27.default.red(`
68081
+ process.stderr.write(import_picocolors28.default.red(`
67971
68082
  \u2715 Could not run ${command[0]}: ${err.message}
67972
68083
  `));
67973
68084
  resolve2(127);
@@ -67989,7 +68100,7 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
67989
68100
  }
67990
68101
  if (finished.blocked) return void die(finished.reason ?? "Blocked.", finished);
67991
68102
  if (finished.error) return void die(finished.error, finished);
67992
- if (jsonMode4) {
68103
+ if (jsonMode5) {
67993
68104
  process.stdout.write(
67994
68105
  JSON.stringify({
67995
68106
  ok: true,
@@ -68004,14 +68115,14 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
68004
68115
  }
68005
68116
  if (appendFailure) {
68006
68117
  process.stderr.write(
68007
- import_picocolors27.default.yellow(`
68118
+ import_picocolors28.default.yellow(`
68008
68119
  ! Some output did not reach the page: ${appendFailure}
68009
- `) + import_picocolors27.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
68120
+ `) + import_picocolors28.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
68010
68121
  );
68011
68122
  }
68012
68123
  if (exitCode) {
68013
68124
  process.stderr.write(
68014
- import_picocolors27.default.yellow(`
68125
+ import_picocolors28.default.yellow(`
68015
68126
  ! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
68016
68127
  `)
68017
68128
  );
@@ -68021,12 +68132,12 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
68021
68132
  }
68022
68133
 
68023
68134
  // src/commands/trade.ts
68024
- var import_picocolors28 = __toESM(require_picocolors(), 1);
68135
+ var import_picocolors29 = __toESM(require_picocolors(), 1);
68025
68136
 
68026
68137
  // src/lib/trade-sol.ts
68027
68138
  var import_web3 = __toESM(require_index_cjs(), 1);
68028
68139
  import { promises as fs8 } from "node:fs";
68029
- import * as path4 from "node:path";
68140
+ import * as path5 from "node:path";
68030
68141
  import * as os3 from "node:os";
68031
68142
  var TRADE_CHAIN_ID = 901;
68032
68143
  if (TRADE_CHAIN_ID === 900) {
@@ -68117,7 +68228,7 @@ async function relayGet(pathname) {
68117
68228
  return parsed;
68118
68229
  }
68119
68230
  function tradeSolPath() {
68120
- return path4.join(os3.homedir(), ".agentgates", "trade-sol.json");
68231
+ return path5.join(os3.homedir(), ".agentgates", "trade-sol.json");
68121
68232
  }
68122
68233
  async function loadTradeKey() {
68123
68234
  let raw;
@@ -68149,7 +68260,7 @@ async function loadOrCreateTradeKey() {
68149
68260
  secretKey: Array.from(keypair.secretKey),
68150
68261
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
68151
68262
  };
68152
- const dir = path4.dirname(tradeSolPath());
68263
+ const dir = path5.dirname(tradeSolPath());
68153
68264
  await fs8.mkdir(dir, { recursive: true, mode: 448 });
68154
68265
  await fs8.chmod(dir, 448).catch(() => {
68155
68266
  });
@@ -68387,7 +68498,7 @@ function fail(message, json2) {
68387
68498
  if (json2) {
68388
68499
  process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
68389
68500
  } else {
68390
- process.stderr.write(import_picocolors28.default.red(`\u2715 ${message}
68501
+ process.stderr.write(import_picocolors29.default.red(`\u2715 ${message}
68391
68502
  `));
68392
68503
  }
68393
68504
  process.exit(1);
@@ -68578,7 +68689,7 @@ async function tradeBuy(coinArg, amount, opts) {
68578
68689
  }
68579
68690
  const { keypair, state, created } = await loadOrCreateTradeKey();
68580
68691
  if (created && !opts.json) {
68581
- process.stderr.write(import_picocolors28.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
68692
+ process.stderr.write(import_picocolors29.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
68582
68693
  `));
68583
68694
  }
68584
68695
  const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
@@ -68632,7 +68743,7 @@ async function tradeOrderPlace(coinArg, opts) {
68632
68743
  if (opts.mcap && !opts.at) fail("--mcap qualifies --at.", opts.json);
68633
68744
  const { keypair, state, created } = await loadOrCreateTradeKey();
68634
68745
  if (created && !opts.json) {
68635
- process.stderr.write(import_picocolors28.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
68746
+ process.stderr.write(import_picocolors29.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
68636
68747
  `));
68637
68748
  }
68638
68749
  let amount;
@@ -68797,12 +68908,12 @@ async function tradePositions(opts) {
68797
68908
  }
68798
68909
 
68799
68910
  // src/commands/desk.ts
68800
- var import_picocolors29 = __toESM(require_picocolors(), 1);
68911
+ var import_picocolors30 = __toESM(require_picocolors(), 1);
68801
68912
 
68802
68913
  // src/lib/desk-sol.ts
68803
68914
  var import_web32 = __toESM(require_index_cjs(), 1);
68804
68915
  import { promises as fs9 } from "node:fs";
68805
- import * as path5 from "node:path";
68916
+ import * as path6 from "node:path";
68806
68917
  import * as os4 from "node:os";
68807
68918
  async function resolveDeskContext() {
68808
68919
  const ctx2 = await resolveTradeContext();
@@ -68815,7 +68926,7 @@ async function resolveDeskContext() {
68815
68926
  return { ...ctx2, desk: desk2 };
68816
68927
  }
68817
68928
  function deskSessionPath() {
68818
- return path5.join(os4.homedir(), ".agentgates", "desk-session-sol.json");
68929
+ return path6.join(os4.homedir(), ".agentgates", "desk-session-sol.json");
68819
68930
  }
68820
68931
  function deskSessionKeyPath() {
68821
68932
  return deskSessionPath();
@@ -68851,7 +68962,7 @@ async function loadOrCreateDeskSessionKey() {
68851
68962
  secretKey: Array.from(keypair.secretKey),
68852
68963
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
68853
68964
  };
68854
- const dir = path5.dirname(deskSessionPath());
68965
+ const dir = path6.dirname(deskSessionPath());
68855
68966
  await fs9.mkdir(dir, { recursive: true, mode: 448 });
68856
68967
  await fs9.chmod(dir, 448).catch(() => {
68857
68968
  });
@@ -68971,7 +69082,7 @@ function fail2(message, json2) {
68971
69082
  if (json2) {
68972
69083
  process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
68973
69084
  } else {
68974
- process.stderr.write(import_picocolors29.default.red(`\u2715 ${message}
69085
+ process.stderr.write(import_picocolors30.default.red(`\u2715 ${message}
68975
69086
  `));
68976
69087
  }
68977
69088
  process.exit(1);
@@ -69114,7 +69225,7 @@ async function deskDeposit(amount, opts) {
69114
69225
  if (units <= 0n) fail2("Deposit amount must be above zero.", opts.json);
69115
69226
  const { keypair, state, created } = await loadOrCreateTradeKey();
69116
69227
  if (created && !opts.json) {
69117
- process.stderr.write(import_picocolors29.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
69228
+ process.stderr.write(import_picocolors30.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
69118
69229
  `));
69119
69230
  }
69120
69231
  const result = await runDeskCeremony({
@@ -69209,13 +69320,13 @@ async function deskSessionRegister(opts) {
69209
69320
  }
69210
69321
  const owner = await loadOrCreateTradeKey();
69211
69322
  if (owner.created && !opts.json) {
69212
- process.stderr.write(import_picocolors29.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
69323
+ process.stderr.write(import_picocolors30.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
69213
69324
  `));
69214
69325
  }
69215
69326
  const session = await loadOrCreateDeskSessionKey();
69216
69327
  if (session.created && !opts.json) {
69217
69328
  process.stderr.write(
69218
- import_picocolors29.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
69329
+ import_picocolors30.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
69219
69330
  `)
69220
69331
  );
69221
69332
  }
@@ -69757,7 +69868,7 @@ program2.command("fund").description(
69757
69868
  }
69758
69869
  if (opts.usdc || opts.gas || opts.chain) {
69759
69870
  process.stderr.write(
69760
- import_picocolors30.default.red(
69871
+ import_picocolors31.default.red(
69761
69872
  `\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
69762
69873
  `
69763
69874
  )
@@ -69960,6 +70071,9 @@ program2.command("init").description(
69960
70071
  ).option("--seed <twelve words>", "bring the phrase (quote it)").option("--reveal-seed", "print this key's words again, with the handoff for your human").option("--import <hex>", "bring a bare 32-byte secp256k1 private key (64 hex chars) instead of words").option("--replace", "with --seed or --import: overwrite what is already here").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
69961
70072
  await passwordsInit(opts);
69962
70073
  });
70074
+ program2.command("update").description("Bring this copy to the version npm serves as latest, in the place it runs from (the installer's ~/.agentgates, or a global npm install).").option("--check", "say whether a newer version is out; install nothing").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
70075
+ await update(opts);
70076
+ });
69963
70077
  program2.command("open").description(
69964
70078
  "Hand this session to a human: opens agentgates.ai in the browser already logged in as this key's account. The words travel once over 127.0.0.1 with a one-time token; never a server, never a URL, never a page that stays."
69965
70079
  ).option("--wait <seconds>", "how long the link stays alive (300)").option("--no-browser", "print the link instead of opening it").option("--print-url", "print the link as well as opening it").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
@@ -69974,10 +70088,10 @@ browser.command("balance").description("The prepaid balance every step draws fro
69974
70088
  await browserBalance(opts);
69975
70089
  });
69976
70090
  program2.parseAsync(process.argv).catch((err) => {
69977
- process.stderr.write(import_picocolors30.default.red(`\u2715 ${err.message}
70091
+ process.stderr.write(import_picocolors31.default.red(`\u2715 ${err.message}
69978
70092
  `));
69979
70093
  if (process.env.BOUNTY_DEBUG) {
69980
- process.stderr.write(import_picocolors30.default.dim((err.stack ?? "") + "\n"));
70094
+ process.stderr.write(import_picocolors31.default.dim((err.stack ?? "") + "\n"));
69981
70095
  }
69982
70096
  process.exit(1);
69983
70097
  });