@agentgates/cli 0.15.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +5 -4
  2. package/dist/cli.mjs +1465 -757
  3. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -5588,7 +5588,7 @@ var require_websocket = __commonJS({
5588
5588
  var http2 = __require("http");
5589
5589
  var net = __require("net");
5590
5590
  var tls = __require("tls");
5591
- var { randomBytes: randomBytes7, createHash: createHash5 } = __require("crypto");
5591
+ var { randomBytes: randomBytes8, createHash: createHash5 } = __require("crypto");
5592
5592
  var { Duplex, Readable } = __require("stream");
5593
5593
  var { URL: URL4 } = __require("url");
5594
5594
  var PerMessageDeflate = require_permessage_deflate();
@@ -6114,7 +6114,7 @@ var require_websocket = __commonJS({
6114
6114
  }
6115
6115
  }
6116
6116
  const defaultPort = isSecure ? 443 : 80;
6117
- const key = randomBytes7(16).toString("base64");
6117
+ const key = randomBytes8(16).toString("base64");
6118
6118
  const request = isSecure ? https2.request : http2.request;
6119
6119
  const protocolSet = /* @__PURE__ */ new Set();
6120
6120
  let perMessageDeflate;
@@ -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.15.0",
6878
+ version: "0.19.1",
6879
6879
  description: "Wallet operations for AI agents and humans",
6880
6880
  keywords: [
6881
6881
  "crypto",
@@ -6977,7 +6977,7 @@ var require_utils = __commonJS({
6977
6977
  exports.createHasher = createHasher;
6978
6978
  exports.createOptHasher = createOptHasher;
6979
6979
  exports.createXOFer = createXOFer;
6980
- exports.randomBytes = randomBytes7;
6980
+ exports.randomBytes = randomBytes8;
6981
6981
  var crypto_1 = require_cryptoNode();
6982
6982
  function isBytes(a) {
6983
6983
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
@@ -7175,7 +7175,7 @@ var require_utils = __commonJS({
7175
7175
  exports.wrapConstructor = createHasher;
7176
7176
  exports.wrapConstructorWithOpts = createOptHasher;
7177
7177
  exports.wrapXOFConstructorWithOpts = createXOFer;
7178
- function randomBytes7(bytesLength = 32) {
7178
+ function randomBytes8(bytesLength = 32) {
7179
7179
  if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") {
7180
7180
  return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
7181
7181
  }
@@ -9347,7 +9347,7 @@ var require_edwards = __commonJS({
9347
9347
  });
9348
9348
  const { prehash } = eddsaOpts;
9349
9349
  const { BASE, Fp: Fp2, Fn } = Point2;
9350
- const randomBytes7 = eddsaOpts.randomBytes || utils_ts_1.randomBytes;
9350
+ const randomBytes8 = eddsaOpts.randomBytes || utils_ts_1.randomBytes;
9351
9351
  const adjustScalarBytes = eddsaOpts.adjustScalarBytes || ((bytes2) => bytes2);
9352
9352
  const domain = eddsaOpts.domain || ((data4, ctx2, phflag) => {
9353
9353
  (0, utils_ts_1._abool2)(phflag, "phflag");
@@ -9429,7 +9429,7 @@ var require_edwards = __commonJS({
9429
9429
  signature: 2 * _size,
9430
9430
  seed: _size
9431
9431
  };
9432
- function randomSecretKey(seed = randomBytes7(lengths.seed)) {
9432
+ function randomSecretKey(seed = randomBytes8(lengths.seed)) {
9433
9433
  return (0, utils_ts_1._abytes2)(seed, lengths.seed, "seed");
9434
9434
  }
9435
9435
  function keygen(seed) {
@@ -17475,10 +17475,10 @@ var require_dist = __commonJS({
17475
17475
  if (coerce2) {
17476
17476
  value = struct2.coercer(value, ctx2);
17477
17477
  }
17478
- let status2 = "valid";
17478
+ let status3 = "valid";
17479
17479
  for (const failure of struct2.validator(value, ctx2)) {
17480
17480
  failure.explanation = options.message;
17481
- status2 = "not_valid";
17481
+ status3 = "not_valid";
17482
17482
  yield [failure, void 0];
17483
17483
  }
17484
17484
  for (let [k, v, s] of struct2.entries(value, ctx2)) {
@@ -17491,7 +17491,7 @@ var require_dist = __commonJS({
17491
17491
  });
17492
17492
  for (const t of ts) {
17493
17493
  if (t[0]) {
17494
- status2 = t[0].refinement != null ? "not_refined" : "not_valid";
17494
+ status3 = t[0].refinement != null ? "not_refined" : "not_valid";
17495
17495
  yield [t[0], void 0];
17496
17496
  } else if (coerce2) {
17497
17497
  v = t[1];
@@ -17508,14 +17508,14 @@ var require_dist = __commonJS({
17508
17508
  }
17509
17509
  }
17510
17510
  }
17511
- if (status2 !== "not_valid") {
17511
+ if (status3 !== "not_valid") {
17512
17512
  for (const failure of struct2.refiner(value, ctx2)) {
17513
17513
  failure.explanation = options.message;
17514
- status2 = "not_refined";
17514
+ status3 = "not_refined";
17515
17515
  yield [failure, void 0];
17516
17516
  }
17517
17517
  }
17518
- if (status2 === "valid") {
17518
+ if (status3 === "valid") {
17519
17519
  yield [void 0, value];
17520
17520
  }
17521
17521
  }
@@ -18903,8 +18903,8 @@ var require_tr46 = __commonJS({
18903
18903
  var len = countSymbols(domain_name);
18904
18904
  for (var i = 0; i < len; ++i) {
18905
18905
  var codePoint = domain_name.codePointAt(i);
18906
- var status2 = findStatus(codePoint);
18907
- switch (status2[1]) {
18906
+ var status3 = findStatus(codePoint);
18907
+ switch (status3[1]) {
18908
18908
  case "disallowed":
18909
18909
  hasError = true;
18910
18910
  processed += String.fromCodePoint(codePoint);
@@ -18912,11 +18912,11 @@ var require_tr46 = __commonJS({
18912
18912
  case "ignored":
18913
18913
  break;
18914
18914
  case "mapped":
18915
- processed += String.fromCodePoint.apply(String, status2[2]);
18915
+ processed += String.fromCodePoint.apply(String, status3[2]);
18916
18916
  break;
18917
18917
  case "deviation":
18918
18918
  if (processing_option === PROCESSING_OPTIONS.TRANSITIONAL) {
18919
- processed += String.fromCodePoint.apply(String, status2[2]);
18919
+ processed += String.fromCodePoint.apply(String, status3[2]);
18920
18920
  } else {
18921
18921
  processed += String.fromCodePoint(codePoint);
18922
18922
  }
@@ -18929,7 +18929,7 @@ var require_tr46 = __commonJS({
18929
18929
  hasError = true;
18930
18930
  processed += String.fromCodePoint(codePoint);
18931
18931
  } else {
18932
- processed += String.fromCodePoint.apply(String, status2[2]);
18932
+ processed += String.fromCodePoint.apply(String, status3[2]);
18933
18933
  }
18934
18934
  break;
18935
18935
  case "disallowed_STD3_valid":
@@ -18957,8 +18957,8 @@ var require_tr46 = __commonJS({
18957
18957
  }
18958
18958
  var len = countSymbols(label);
18959
18959
  for (var i = 0; i < len; ++i) {
18960
- var status2 = findStatus(label.codePointAt(i));
18961
- if (processing === PROCESSING_OPTIONS.TRANSITIONAL && status2[1] !== "valid" || processing === PROCESSING_OPTIONS.NONTRANSITIONAL && status2[1] !== "valid" && status2[1] !== "deviation") {
18960
+ var status3 = findStatus(label.codePointAt(i));
18961
+ if (processing === PROCESSING_OPTIONS.TRANSITIONAL && status3[1] !== "valid" || processing === PROCESSING_OPTIONS.NONTRANSITIONAL && status3[1] !== "valid" && status3[1] !== "deviation") {
18962
18962
  error = true;
18963
18963
  break;
18964
18964
  }
@@ -19397,14 +19397,14 @@ var require_url_state_machine = __commonJS({
19397
19397
  len: maxLen
19398
19398
  };
19399
19399
  }
19400
- function serializeHost(host) {
19401
- if (typeof host === "number") {
19402
- return serializeIPv4(host);
19400
+ function serializeHost(host2) {
19401
+ if (typeof host2 === "number") {
19402
+ return serializeIPv4(host2);
19403
19403
  }
19404
- if (host instanceof Array) {
19405
- return "[" + serializeIPv6(host) + "]";
19404
+ if (host2 instanceof Array) {
19405
+ return "[" + serializeIPv6(host2) + "]";
19406
19406
  }
19407
- return host;
19407
+ return host2;
19408
19408
  }
19409
19409
  function trimControlChars(url) {
19410
19410
  return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, "");
@@ -19707,11 +19707,11 @@ var require_url_state_machine = __commonJS({
19707
19707
  this.parseError = true;
19708
19708
  return failure;
19709
19709
  }
19710
- const host = parseHost(this.buffer, isSpecial(this.url));
19711
- if (host === failure) {
19710
+ const host2 = parseHost(this.buffer, isSpecial(this.url));
19711
+ if (host2 === failure) {
19712
19712
  return failure;
19713
19713
  }
19714
- this.url.host = host;
19714
+ this.url.host = host2;
19715
19715
  this.buffer = "";
19716
19716
  this.state = "port";
19717
19717
  if (this.stateOverride === "hostname") {
@@ -19726,11 +19726,11 @@ var require_url_state_machine = __commonJS({
19726
19726
  this.parseError = true;
19727
19727
  return false;
19728
19728
  }
19729
- const host = parseHost(this.buffer, isSpecial(this.url));
19730
- if (host === failure) {
19729
+ const host2 = parseHost(this.buffer, isSpecial(this.url));
19730
+ if (host2 === failure) {
19731
19731
  return failure;
19732
19732
  }
19733
- this.url.host = host;
19733
+ this.url.host = host2;
19734
19734
  this.buffer = "";
19735
19735
  this.state = "path start";
19736
19736
  if (this.stateOverride) {
@@ -19845,14 +19845,14 @@ var require_url_state_machine = __commonJS({
19845
19845
  }
19846
19846
  this.state = "path start";
19847
19847
  } else {
19848
- let host = parseHost(this.buffer, isSpecial(this.url));
19849
- if (host === failure) {
19848
+ let host2 = parseHost(this.buffer, isSpecial(this.url));
19849
+ if (host2 === failure) {
19850
19850
  return failure;
19851
19851
  }
19852
- if (host === "localhost") {
19853
- host = "";
19852
+ if (host2 === "localhost") {
19853
+ host2 = "";
19854
19854
  }
19855
- this.url.host = host;
19855
+ this.url.host = host2;
19856
19856
  if (this.stateOverride) {
19857
19857
  return false;
19858
19858
  }
@@ -21205,7 +21205,7 @@ var require_lib3 = __commonJS({
21205
21205
  let body = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
21206
21206
  let opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
21207
21207
  Body.call(this, body, opts);
21208
- const status2 = opts.status || 200;
21208
+ const status3 = opts.status || 200;
21209
21209
  const headers = new Headers(opts.headers);
21210
21210
  if (body != null && !headers.has("Content-Type")) {
21211
21211
  const contentType = extractContentType(body);
@@ -21215,8 +21215,8 @@ var require_lib3 = __commonJS({
21215
21215
  }
21216
21216
  this[INTERNALS$1] = {
21217
21217
  url: opts.url,
21218
- status: status2,
21219
- statusText: opts.statusText || STATUS_CODES[status2],
21218
+ status: status3,
21219
+ statusText: opts.statusText || STATUS_CODES[status3],
21220
21220
  headers,
21221
21221
  counter: opts.counter
21222
21222
  };
@@ -23937,7 +23937,7 @@ var require_websocket2 = __commonJS({
23937
23937
  var http2 = __require("http");
23938
23938
  var net = __require("net");
23939
23939
  var tls = __require("tls");
23940
- var { randomBytes: randomBytes7, createHash: createHash5 } = __require("crypto");
23940
+ var { randomBytes: randomBytes8, createHash: createHash5 } = __require("crypto");
23941
23941
  var { Duplex, Readable } = __require("stream");
23942
23942
  var { URL: URL4 } = __require("url");
23943
23943
  var PerMessageDeflate = require_permessage_deflate2();
@@ -24475,7 +24475,7 @@ var require_websocket2 = __commonJS({
24475
24475
  }
24476
24476
  }
24477
24477
  const defaultPort = isSecure ? 443 : 80;
24478
- const key = randomBytes7(16).toString("base64");
24478
+ const key = randomBytes8(16).toString("base64");
24479
24479
  const request = isSecure ? https2.request : http2.request;
24480
24480
  const protocolSet = /* @__PURE__ */ new Set();
24481
24481
  let perMessageDeflate;
@@ -25454,7 +25454,7 @@ var require_eventemitter3 = __commonJS({
25454
25454
  if (listeners.fn) return 1;
25455
25455
  return listeners.length;
25456
25456
  };
25457
- EventEmitter.prototype.emit = function emit3(event, a1, a2, a3, a4, a5) {
25457
+ EventEmitter.prototype.emit = function emit4(event, a1, a2, a3, a4, a5) {
25458
25458
  var evt = prefix ? prefix + event : event;
25459
25459
  if (!this._events[evt]) return false;
25460
25460
  var listeners = this._events[evt], len = arguments.length, args, i;
@@ -28092,7 +28092,7 @@ var require_weierstrass = __commonJS({
28092
28092
  bits2int: "function",
28093
28093
  bits2int_modN: "function"
28094
28094
  });
28095
- const randomBytes7 = ecdsaOpts.randomBytes || utils_ts_1.randomBytes;
28095
+ const randomBytes8 = ecdsaOpts.randomBytes || utils_ts_1.randomBytes;
28096
28096
  const hmac2 = ecdsaOpts.hmac || ((key, ...msgs) => (0, hmac_js_1.hmac)(hash2, key, (0, utils_ts_1.concatBytes)(...msgs)));
28097
28097
  const { Fp: Fp2, Fn } = Point2;
28098
28098
  const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
@@ -28247,7 +28247,7 @@ var require_weierstrass = __commonJS({
28247
28247
  const d = _normFnElement(Fn, privateKey);
28248
28248
  const seedArgs = [int2octets(d), int2octets(h1int)];
28249
28249
  if (extraEntropy != null && extraEntropy !== false) {
28250
- const e = extraEntropy === true ? randomBytes7(lengths.secretKey) : extraEntropy;
28250
+ const e = extraEntropy === true ? randomBytes8(lengths.secretKey) : extraEntropy;
28251
28251
  seedArgs.push((0, utils_ts_1.ensureBytes)("extraEntropy", e));
28252
28252
  }
28253
28253
  const seed = (0, utils_ts_1.concatBytes)(...seedArgs);
@@ -30611,9 +30611,9 @@ Message: ${transactionMessage}.
30611
30611
  minContextSlot: options.minContextSlot
30612
30612
  };
30613
30613
  const signature2 = await connection.sendTransaction(transaction, signers, sendOptions);
30614
- let status2;
30614
+ let status3;
30615
30615
  if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {
30616
- status2 = (await connection.confirmTransaction({
30616
+ status3 = (await connection.confirmTransaction({
30617
30617
  abortSignal: options?.abortSignal,
30618
30618
  signature: signature2,
30619
30619
  blockhash: transaction.recentBlockhash,
@@ -30624,7 +30624,7 @@ Message: ${transactionMessage}.
30624
30624
  nonceInstruction
30625
30625
  } = transaction.nonceInfo;
30626
30626
  const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
30627
- status2 = (await connection.confirmTransaction({
30627
+ status3 = (await connection.confirmTransaction({
30628
30628
  abortSignal: options?.abortSignal,
30629
30629
  minContextSlot: transaction.minNonceContextSlot,
30630
30630
  nonceAccountPubkey,
@@ -30635,17 +30635,17 @@ Message: ${transactionMessage}.
30635
30635
  if (options?.abortSignal != null) {
30636
30636
  console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable.");
30637
30637
  }
30638
- status2 = (await connection.confirmTransaction(signature2, options && options.commitment)).value;
30638
+ status3 = (await connection.confirmTransaction(signature2, options && options.commitment)).value;
30639
30639
  }
30640
- if (status2.err) {
30640
+ if (status3.err) {
30641
30641
  if (signature2 != null) {
30642
30642
  throw new SendTransactionError({
30643
30643
  action: "send",
30644
30644
  signature: signature2,
30645
- transactionMessage: `Status: (${JSON.stringify(status2)})`
30645
+ transactionMessage: `Status: (${JSON.stringify(status3)})`
30646
30646
  });
30647
30647
  }
30648
- throw new Error(`Transaction ${signature2} failed (${JSON.stringify(status2)})`);
30648
+ throw new Error(`Transaction ${signature2} failed (${JSON.stringify(status3)})`);
30649
30649
  }
30650
30650
  return signature2;
30651
30651
  }
@@ -33824,15 +33824,15 @@ Message: ${transactionMessage}.
33824
33824
  } else {
33825
33825
  let signatureStatus;
33826
33826
  while (true) {
33827
- const status2 = await this.getSignatureStatus(signature2);
33828
- if (status2 == null) {
33827
+ const status3 = await this.getSignatureStatus(signature2);
33828
+ if (status3 == null) {
33829
33829
  break;
33830
33830
  }
33831
- if (status2.context.slot < (outcome.slotInWhichNonceDidAdvance ?? minContextSlot)) {
33831
+ if (status3.context.slot < (outcome.slotInWhichNonceDidAdvance ?? minContextSlot)) {
33832
33832
  await sleep3(400);
33833
33833
  continue;
33834
33834
  }
33835
- signatureStatus = status2;
33835
+ signatureStatus = status3;
33836
33836
  break;
33837
33837
  }
33838
33838
  if (signatureStatus?.value) {
@@ -37759,16 +37759,16 @@ Message: ${transactionMessage}.
37759
37759
  const signature2 = await connection.sendRawTransaction(rawTransaction, sendOptions);
37760
37760
  const commitment = options && options.commitment;
37761
37761
  const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature2, commitment);
37762
- const status2 = (await confirmationPromise).value;
37763
- if (status2.err) {
37762
+ const status3 = (await confirmationPromise).value;
37763
+ if (status3.err) {
37764
37764
  if (signature2 != null) {
37765
37765
  throw new SendTransactionError({
37766
37766
  action: sendOptions?.skipPreflight ? "send" : "simulate",
37767
37767
  signature: signature2,
37768
- transactionMessage: `Status: (${JSON.stringify(status2)})`
37768
+ transactionMessage: `Status: (${JSON.stringify(status3)})`
37769
37769
  });
37770
37770
  }
37771
- throw new Error(`Raw transaction ${signature2} failed (${JSON.stringify(status2)})`);
37771
+ throw new Error(`Raw transaction ${signature2} failed (${JSON.stringify(status3)})`);
37772
37772
  }
37773
37773
  return signature2;
37774
37774
  }
@@ -37870,7 +37870,7 @@ var {
37870
37870
  } = import_index.default;
37871
37871
 
37872
37872
  // src/main.ts
37873
- var import_picocolors28 = __toESM(require_picocolors(), 1);
37873
+ var import_picocolors30 = __toESM(require_picocolors(), 1);
37874
37874
 
37875
37875
  // src/commands/login.ts
37876
37876
  var import_picocolors2 = __toESM(require_picocolors(), 1);
@@ -37891,9 +37891,9 @@ var AI_DIRECTIVE = "\n[AI: present the above verbatim inside a markdown code blo
37891
37891
 
37892
37892
  // src/lib/api.ts
37893
37893
  var ApiError = class extends Error {
37894
- constructor(status2, code, message, body) {
37894
+ constructor(status3, code, message, body) {
37895
37895
  super(message);
37896
- this.status = status2;
37896
+ this.status = status3;
37897
37897
  this.code = code;
37898
37898
  this.body = body;
37899
37899
  this.name = "ApiError";
@@ -37988,8 +37988,8 @@ async function readConfig() {
37988
37988
  }
37989
37989
  async function writeConfig(cfg) {
37990
37990
  await ensureDir();
37991
- const json = JSON.stringify(cfg, null, 2);
37992
- await fs.writeFile(configPath(), json, { mode: 384 });
37991
+ const json2 = JSON.stringify(cfg, null, 2);
37992
+ await fs.writeFile(configPath(), json2, { mode: 384 });
37993
37993
  await fs.chmod(configPath(), 384).catch(() => {
37994
37994
  });
37995
37995
  }
@@ -38368,9 +38368,9 @@ var baseOpen = async (options) => {
38368
38368
  firefox: "--private-window",
38369
38369
  edge: "--inPrivate"
38370
38370
  };
38371
- const browser = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser2();
38372
- if (browser.id in ids) {
38373
- const browserName = ids[browser.id];
38371
+ const browser2 = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser2();
38372
+ if (browser2.id in ids) {
38373
+ const browserName = ids[browser2.id];
38374
38374
  if (app === "browserPrivate") {
38375
38375
  appArguments.push(flags[browserName]);
38376
38376
  }
@@ -38382,7 +38382,7 @@ var baseOpen = async (options) => {
38382
38382
  }
38383
38383
  });
38384
38384
  }
38385
- throw new Error(`${browser.name} is not supported as a default browser`);
38385
+ throw new Error(`${browser2.name} is not supported as a default browser`);
38386
38386
  }
38387
38387
  let command;
38388
38388
  const cliArguments = [];
@@ -38847,7 +38847,7 @@ function shortAddress(addr) {
38847
38847
  }
38848
38848
 
38849
38849
  // src/commands/onboard.ts
38850
- var import_picocolors8 = __toESM(require_picocolors(), 1);
38850
+ var import_picocolors10 = __toESM(require_picocolors(), 1);
38851
38851
  import { createInterface } from "node:readline/promises";
38852
38852
 
38853
38853
  // src/lib/water.ts
@@ -39321,9 +39321,16 @@ async function emailSend() {
39321
39321
  }
39322
39322
 
39323
39323
  // src/commands/passwords.ts
39324
- var import_picocolors7 = __toESM(require_picocolors(), 1);
39324
+ var import_picocolors8 = __toESM(require_picocolors(), 1);
39325
39325
  import { readFileSync } from "node:fs";
39326
- import { randomBytes as randomBytes6 } from "node:crypto";
39326
+ import { randomBytes as randomBytes7 } from "node:crypto";
39327
+
39328
+ // src/commands/session.ts
39329
+ var import_picocolors7 = __toESM(require_picocolors(), 1);
39330
+
39331
+ // src/lib/passwords-key.ts
39332
+ import { promises as fs7 } from "node:fs";
39333
+ import * as path3 from "node:path";
39327
39334
 
39328
39335
  // node_modules/ethers/lib.esm/ethers.js
39329
39336
  var ethers_exports = {};
@@ -41769,8 +41776,8 @@ function parseEther(ether) {
41769
41776
  }
41770
41777
 
41771
41778
  // node_modules/ethers/lib.esm/utils/uuid.js
41772
- function uuidV4(randomBytes7) {
41773
- const bytes2 = getBytes(randomBytes7, "randomBytes");
41779
+ function uuidV4(randomBytes8) {
41780
+ const bytes2 = getBytes(randomBytes8, "randomBytes");
41774
41781
  bytes2[6] = bytes2[6] & 15 | 64;
41775
41782
  bytes2[8] = bytes2[8] & 63 | 128;
41776
41783
  const value = hexlify(bytes2);
@@ -44645,7 +44652,7 @@ function weierstrass(curveDef) {
44645
44652
  function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
44646
44653
  if (["recovered", "canonical"].some((k) => k in opts))
44647
44654
  throw new Error("sign() legacy options not supported");
44648
- const { hash: hash2, randomBytes: randomBytes7 } = CURVE;
44655
+ const { hash: hash2, randomBytes: randomBytes8 } = CURVE;
44649
44656
  let { lowS, prehash, extraEntropy: ent } = opts;
44650
44657
  if (lowS == null)
44651
44658
  lowS = true;
@@ -44656,7 +44663,7 @@ function weierstrass(curveDef) {
44656
44663
  const d = normPrivateKeyToScalar(privateKey);
44657
44664
  const seedArgs = [int2octets(d), int2octets(h1int)];
44658
44665
  if (ent != null) {
44659
- const e = ent === true ? randomBytes7(Fp2.BYTES) : ent;
44666
+ const e = ent === true ? randomBytes8(Fp2.BYTES) : ent;
44660
44667
  seedArgs.push(ensureBytes("extraEntropy", e));
44661
44668
  }
44662
44669
  const seed = concatBytes2(...seedArgs);
@@ -52503,7 +52510,7 @@ var TransactionReceipt = class {
52503
52510
  logsBloom,
52504
52511
  logs,
52505
52512
  //byzantium,
52506
- status: status2,
52513
+ status: status3,
52507
52514
  root
52508
52515
  } = this;
52509
52516
  return {
@@ -52523,7 +52530,7 @@ var TransactionReceipt = class {
52523
52530
  logs,
52524
52531
  logsBloom,
52525
52532
  root,
52526
- status: status2,
52533
+ status: status3,
52527
52534
  to
52528
52535
  };
52529
52536
  }
@@ -61530,9 +61537,9 @@ function spelunk(object2, _path) {
61530
61537
 
61531
61538
  // node_modules/ethers/lib.esm/wallet/json-keystore.js
61532
61539
  var defaultPath = "m/44'/60'/0'/0/0";
61533
- function isKeystoreJson(json) {
61540
+ function isKeystoreJson(json2) {
61534
61541
  try {
61535
- const data4 = JSON.parse(json);
61542
+ const data4 = JSON.parse(json2);
61536
61543
  const version4 = data4.version != null ? parseInt(data4.version) : 0;
61537
61544
  if (version4 === 3) {
61538
61545
  return true;
@@ -61607,8 +61614,8 @@ function getDecryptKdfParams(data4) {
61607
61614
  }
61608
61615
  assertArgument(false, "unsupported key-derivation function", "kdf", kdf);
61609
61616
  }
61610
- function decryptKeystoreJsonSync(json, _password) {
61611
- const data4 = JSON.parse(json);
61617
+ function decryptKeystoreJsonSync(json2, _password) {
61618
+ const data4 = JSON.parse(json2);
61612
61619
  const password = getPassword(_password);
61613
61620
  const params = getDecryptKdfParams(data4);
61614
61621
  if (params.name === "pbkdf2") {
@@ -61628,8 +61635,8 @@ function stall3(duration) {
61628
61635
  }, duration);
61629
61636
  });
61630
61637
  }
61631
- async function decryptKeystoreJson(json, _password, progress) {
61632
- const data4 = JSON.parse(json);
61638
+ async function decryptKeystoreJson(json2, _password, progress) {
61639
+ const data4 = JSON.parse(json2);
61633
61640
  const password = getPassword(_password);
61634
61641
  const params = getDecryptKdfParams(data4);
61635
61642
  if (params.name === "pbkdf2") {
@@ -62178,9 +62185,9 @@ function getIndexedAccountPath(_index) {
62178
62185
  }
62179
62186
 
62180
62187
  // node_modules/ethers/lib.esm/wallet/json-crowdsale.js
62181
- function isCrowdsaleJson(json) {
62188
+ function isCrowdsaleJson(json2) {
62182
62189
  try {
62183
- const data4 = JSON.parse(json);
62190
+ const data4 = JSON.parse(json2);
62184
62191
  if (data4.encseed) {
62185
62192
  return true;
62186
62193
  }
@@ -62188,12 +62195,12 @@ function isCrowdsaleJson(json) {
62188
62195
  }
62189
62196
  return false;
62190
62197
  }
62191
- function decryptCrowdsaleJson(json, _password) {
62192
- const data4 = JSON.parse(json);
62198
+ function decryptCrowdsaleJson(json2, _password) {
62199
+ const data4 = JSON.parse(json2);
62193
62200
  const password = getPassword(_password);
62194
62201
  const address = getAddress(spelunk(data4, "ethaddr:string!"));
62195
62202
  const encseed = looseArrayify(spelunk(data4, "encseed:string!"));
62196
- assertArgument(encseed && encseed.length % 16 === 0, "invalid encseed", "json", json);
62203
+ assertArgument(encseed && encseed.length % 16 === 0, "invalid encseed", "json", json2);
62197
62204
  const key = getBytes(pbkdf2(password, password, 2e3, 32, "sha256")).slice(0, 16);
62198
62205
  const iv = encseed.slice(0, 16);
62199
62206
  const encryptedSeed = encseed.slice(16);
@@ -62275,16 +62282,16 @@ var Wallet = class _Wallet extends BaseWallet {
62275
62282
  * If %%progress%% is provided, it is called periodically during
62276
62283
  * decryption so that any UI can be updated.
62277
62284
  */
62278
- static async fromEncryptedJson(json, password, progress) {
62285
+ static async fromEncryptedJson(json2, password, progress) {
62279
62286
  let account = null;
62280
- if (isKeystoreJson(json)) {
62281
- account = await decryptKeystoreJson(json, password, progress);
62282
- } else if (isCrowdsaleJson(json)) {
62287
+ if (isKeystoreJson(json2)) {
62288
+ account = await decryptKeystoreJson(json2, password, progress);
62289
+ } else if (isCrowdsaleJson(json2)) {
62283
62290
  if (progress) {
62284
62291
  progress(0);
62285
62292
  await stall4(0);
62286
62293
  }
62287
- account = decryptCrowdsaleJson(json, password);
62294
+ account = decryptCrowdsaleJson(json2, password);
62288
62295
  if (progress) {
62289
62296
  progress(1);
62290
62297
  await stall4(0);
@@ -62299,12 +62306,12 @@ var Wallet = class _Wallet extends BaseWallet {
62299
62306
  * will lock up and freeze the UI during decryption, which may take
62300
62307
  * some time.
62301
62308
  */
62302
- static fromEncryptedJsonSync(json, password) {
62309
+ static fromEncryptedJsonSync(json2, password) {
62303
62310
  let account = null;
62304
- if (isKeystoreJson(json)) {
62305
- account = decryptKeystoreJsonSync(json, password);
62306
- } else if (isCrowdsaleJson(json)) {
62307
- account = decryptCrowdsaleJson(json, password);
62311
+ if (isKeystoreJson(json2)) {
62312
+ account = decryptKeystoreJsonSync(json2, password);
62313
+ } else if (isCrowdsaleJson(json2)) {
62314
+ account = decryptCrowdsaleJson(json2, password);
62308
62315
  } else {
62309
62316
  assertArgument(false, "invalid JSON wallet", "json", "[ REDACTED ]");
62310
62317
  }
@@ -62853,8 +62860,6 @@ var wordlists2 = {
62853
62860
  };
62854
62861
 
62855
62862
  // src/lib/passwords-key.ts
62856
- import { promises as fs7 } from "node:fs";
62857
- import * as path3 from "node:path";
62858
62863
  var SEED_PATH = "m/44'/60'/0'/0/0";
62859
62864
  var SEED_WORDS = 12;
62860
62865
  function passwordsKeyPath() {
@@ -62866,13 +62871,13 @@ function keysOf(state) {
62866
62871
  throw new Error(`${passwordsKeyPath()} is corrupt: the secret does not derive the recorded address.`);
62867
62872
  }
62868
62873
  if (state.vaultPrivateKey) {
62869
- const vaultWallet = new ethers_exports.Wallet(state.vaultPrivateKey);
62870
- if (vaultWallet.address.toLowerCase() !== String(state.vaultAddress).toLowerCase()) {
62871
- throw new Error(`${passwordsKeyPath()} is corrupt: the vault secret does not derive the recorded vault address.`);
62874
+ const olderLock = new ethers_exports.Wallet(state.vaultPrivateKey);
62875
+ if (olderLock.address.toLowerCase() !== String(state.vaultAddress).toLowerCase()) {
62876
+ throw new Error(`${passwordsKeyPath()} is corrupt: the older lock does not derive the recorded address.`);
62872
62877
  }
62873
- return { state, wallet, vaultWallet, separateLock: true };
62878
+ return { state, wallet, olderLock };
62874
62879
  }
62875
- return { state, wallet, vaultWallet: wallet, separateLock: false };
62880
+ return { state, wallet };
62876
62881
  }
62877
62882
  async function loadPasswordsKey() {
62878
62883
  let raw;
@@ -62904,20 +62909,15 @@ function normaliseSeed(raw, what = "a seed") {
62904
62909
  if (!ethers_exports.Mnemonic.isValidMnemonic(phrase)) throw new Error(`${what}: those are not twelve words from the wordlist, or the last one does not check out.`);
62905
62910
  return phrase;
62906
62911
  }
62907
- function nodeOf(phrase) {
62908
- return ethers_exports.HDNodeWallet.fromPhrase(phrase, void 0, SEED_PATH);
62909
- }
62910
- function stateOf(signing, vault) {
62911
- const s = nodeOf(signing);
62912
- const v = vault ? nodeOf(vault) : null;
62912
+ function stateOf(phrase) {
62913
+ const node = ethers_exports.HDNodeWallet.fromPhrase(phrase, void 0, SEED_PATH);
62913
62914
  return {
62914
- version: 3,
62915
+ version: 2,
62915
62916
  family: "evm",
62916
- address: s.address,
62917
- privateKey: s.privateKey,
62918
- mnemonic: signing,
62917
+ address: node.address,
62918
+ privateKey: node.privateKey,
62919
+ mnemonic: phrase,
62919
62920
  path: SEED_PATH,
62920
- ...v ? { vaultMnemonic: vault, vaultAddress: v.address, vaultPrivateKey: v.privateKey } : {},
62921
62921
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
62922
62922
  };
62923
62923
  }
@@ -62930,32 +62930,20 @@ async function loadOrCreatePasswordsKey() {
62930
62930
  const existing = await loadPasswordsKey();
62931
62931
  if (existing) return { ...existing, created: false };
62932
62932
  const seed = mintPhrase();
62933
- const vaultSeed = mintPhrase();
62934
- const state = stateOf(seed, vaultSeed);
62933
+ const state = stateOf(seed);
62935
62934
  await writeKey(state);
62936
- return { ...keysOf(state), created: true, minted: { seed, vaultSeed } };
62935
+ return { ...keysOf(state), created: true, minted: { seed } };
62937
62936
  }
62938
62937
  async function importPasswordsSeed(args) {
62939
- const seed = args.seed ? normaliseSeed(args.seed, "--seed") : null;
62940
- const vaultSeed = args.vaultSeed ? normaliseSeed(args.vaultSeed, "--vault-seed") : null;
62941
- if (!seed && !vaultSeed) throw new Error("bring twelve words with --seed, and the vault's twelve with --vault-seed.");
62938
+ const seed = normaliseSeed(args.seed, "--seed");
62942
62939
  const existing = await loadPasswordsKey();
62943
- if (!seed) {
62944
- if (!existing?.state.mnemonic) throw new Error("--vault-seed alone needs a signing key here already: run init, or bring --seed with it.");
62945
- if (existing.state.vaultMnemonic && existing.state.vaultMnemonic !== vaultSeed && !args.replace) {
62946
- throw new Error(`this key already has vault words (${existing.state.vaultAddress}); pass --replace to overwrite them. Rows sealed under the old ones open only under the old ones.`);
62947
- }
62948
- const state2 = stateOf(existing.state.mnemonic, vaultSeed);
62949
- await writeKey(state2);
62950
- return keysOf(state2);
62951
- }
62952
62940
  if (existing && !args.replace) {
62953
- if (existing.state.mnemonic === seed && (!vaultSeed || existing.state.vaultMnemonic === vaultSeed)) return existing;
62941
+ if (existing.state.mnemonic === seed) return existing;
62954
62942
  throw new Error(
62955
62943
  `a passwords key already exists at ${passwordsKeyPath()} (${existing.state.address}); pass --replace to overwrite it. The old key is the only thing that opens the rows it sealed.`
62956
62944
  );
62957
62945
  }
62958
- const state = stateOf(seed, vaultSeed);
62946
+ const state = stateOf(seed);
62959
62947
  await writeKey(state);
62960
62948
  return keysOf(state);
62961
62949
  }
@@ -62983,17 +62971,424 @@ async function importPasswordsKey(privateKeyHex, replace) {
62983
62971
  }
62984
62972
  async function requirePasswordsKey() {
62985
62973
  const fromEnv = (process.env.AGENTGATES_PASSWORDS_SEED || "").trim();
62986
- if (fromEnv) {
62987
- const vaultEnv = (process.env.AGENTGATES_PASSWORDS_VAULT_SEED || "").trim();
62988
- return keysOf(stateOf(normaliseSeed(fromEnv, "AGENTGATES_PASSWORDS_SEED"), vaultEnv ? normaliseSeed(vaultEnv, "AGENTGATES_PASSWORDS_VAULT_SEED") : null));
62989
- }
62974
+ if (fromEnv) return keysOf(stateOf(normaliseSeed(fromEnv, "AGENTGATES_PASSWORDS_SEED")));
62990
62975
  const existing = await loadPasswordsKey();
62991
62976
  if (!existing) throw new Error("no passwords key on this machine yet: run `agentgates passwords init` first, or set AGENTGATES_PASSWORDS_SEED to twelve words.");
62992
62977
  return existing;
62993
62978
  }
62994
62979
 
62980
+ // src/lib/session-bridge.ts
62981
+ import { createServer } from "node:http";
62982
+ import { randomBytes as randomBytes5 } from "node:crypto";
62983
+
62984
+ // src/lib/passwords-wire.ts
62985
+ import { randomBytes as randomBytes4 } from "node:crypto";
62986
+ var trim2 = (v) => v ? v.replace(/\/$/, "") : "";
62987
+ function identityOrigin() {
62988
+ return trim2(process.env.AGENTGATES_IDENTITY_ORIGIN) || trim2(process.env.AGENTGATES_ORIGIN) || "https://agentgates.ai";
62989
+ }
62990
+ function siteOrigin() {
62991
+ return trim2(process.env.AGENTGATES_ORIGIN) || "https://agentgates.ai";
62992
+ }
62993
+ var LANE = "/api/identity";
62994
+ var WireError = class extends Error {
62995
+ constructor(status3, code, message, body) {
62996
+ super(message);
62997
+ this.status = status3;
62998
+ this.code = code;
62999
+ this.body = body;
63000
+ this.name = "WireError";
63001
+ }
63002
+ status;
63003
+ code;
63004
+ body;
63005
+ };
63006
+ async function ownerAuthHeader(wallet, method, path6) {
63007
+ const timestamp = Math.floor(Date.now() / 1e3);
63008
+ const nonce = randomBytes4(16).toString("hex");
63009
+ const signature = await wallet.signMessage(`${method.toUpperCase()}
63010
+ ${path6}
63011
+ ${nonce}
63012
+ ${timestamp}`);
63013
+ return Buffer.from(JSON.stringify({ address: wallet.address, timestamp, nonce, signature })).toString("base64");
63014
+ }
63015
+ async function signedFetch(wallet, method, path6, body, timeoutMs = 13e4) {
63016
+ const headers = {
63017
+ accept: "application/json",
63018
+ "user-agent": CLI_USER_AGENT,
63019
+ "x-wallet-auth": await ownerAuthHeader(wallet, method, path6)
63020
+ };
63021
+ if (body !== void 0) headers["content-type"] = "application/json";
63022
+ let res;
63023
+ try {
63024
+ res = await fetch(`${identityOrigin()}${path6}`, {
63025
+ method,
63026
+ headers,
63027
+ body: body !== void 0 ? JSON.stringify(body) : void 0,
63028
+ signal: AbortSignal.timeout(timeoutMs)
63029
+ });
63030
+ } catch (err) {
63031
+ throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
63032
+ }
63033
+ const text = await res.text();
63034
+ let json2 = null;
63035
+ try {
63036
+ json2 = text ? JSON.parse(text) : null;
63037
+ } catch {
63038
+ json2 = null;
63039
+ }
63040
+ return { status: res.status, body: json2, text };
63041
+ }
63042
+ function expectOk(answer, what) {
63043
+ if (answer.status >= 200 && answer.status < 300 && answer.body) return answer.body;
63044
+ const b2 = answer.body ?? {};
63045
+ const code = typeof b2.code === "string" ? b2.code : null;
63046
+ const error = typeof b2.error === "string" ? b2.error : `${what}: HTTP ${answer.status}`;
63047
+ throw new WireError(answer.status, code, error, answer.body);
63048
+ }
63049
+ async function readAttestation() {
63050
+ let res;
63051
+ try {
63052
+ res = await fetch(`${identityOrigin()}${LANE}/passwords/attestation`, {
63053
+ headers: { accept: "application/json", "user-agent": CLI_USER_AGENT },
63054
+ signal: AbortSignal.timeout(6e4)
63055
+ });
63056
+ } catch (err) {
63057
+ throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
63058
+ }
63059
+ const body = await res.json().catch(() => null);
63060
+ if (!res.ok || !body?.publicKey || !body?.keyId) {
63061
+ const error = body?.error ?? `the box's key could not be read: HTTP ${res.status}`;
63062
+ throw new WireError(res.status, body?.code ?? null, error, body);
63063
+ }
63064
+ return body;
63065
+ }
63066
+ async function listRows(wallet) {
63067
+ const out = expectOk(await signedFetch(wallet, "GET", `${LANE}/passwords`), "list");
63068
+ return { passwords: out.passwords ?? [], permitted: out.permitted ?? [] };
63069
+ }
63070
+ async function storeRow(wallet, body) {
63071
+ const out = expectOk(await signedFetch(wallet, "POST", `${LANE}/passwords`, body), "store");
63072
+ return out.password;
63073
+ }
63074
+ async function revealRow(wallet, id2) {
63075
+ const out = expectOk(await signedFetch(wallet, "POST", `${LANE}/passwords/${encodeURIComponent(id2)}/reveal`), "reveal");
63076
+ return out.passkeyBlob;
63077
+ }
63078
+ async function postPermit(wallet, signed2) {
63079
+ const out = expectOk(
63080
+ await signedFetch(wallet, "POST", `${LANE}/passwords/permits`, { typedData: signed2.typedData, signature: signed2.signature }),
63081
+ "permit"
63082
+ );
63083
+ return out.permit;
63084
+ }
63085
+ async function postUse(wallet, id2, body, timeoutMs = 2e5) {
63086
+ return signedFetch(wallet, "POST", `${LANE}/passwords/${encodeURIComponent(id2)}/use`, body, timeoutMs);
63087
+ }
63088
+ async function withdrawInvite(wallet, envelope, signature) {
63089
+ return expectOk(
63090
+ await signedFetch(wallet, "POST", `${LANE}/passwords/invites/withdraw`, { invite: { envelope, signature } }),
63091
+ "withdraw"
63092
+ );
63093
+ }
63094
+
63095
+ // src/lib/session-bridge.ts
63096
+ var BRIDGE_FRAGMENT_KEY = "agentgates-open";
63097
+ var CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
63098
+ function mintToken() {
63099
+ return randomBytes5(16).toString("hex");
63100
+ }
63101
+ function mintCode() {
63102
+ const bytes2 = randomBytes5(6);
63103
+ let out = "";
63104
+ for (let i = 0; i < 6; i++) out += CODE_ALPHABET[bytes2[i] % CODE_ALPHABET.length];
63105
+ return `${out.slice(0, 3)}-${out.slice(3)}`;
63106
+ }
63107
+ function openUrl(port, token) {
63108
+ return `http://127.0.0.1:${port}/open?token=${token}`;
63109
+ }
63110
+ function siteOpenUrl(origin, port, token) {
63111
+ return `${origin}/#${BRIDGE_FRAGMENT_KEY}=${port}.${token}`;
63112
+ }
63113
+ function readBody(req, limit = 4096) {
63114
+ return new Promise((resolve2, reject) => {
63115
+ let data4 = "";
63116
+ req.on("data", (chunk) => {
63117
+ data4 += chunk;
63118
+ if (data4.length > limit) {
63119
+ reject(new Error("body too large"));
63120
+ req.destroy();
63121
+ }
63122
+ });
63123
+ req.on("end", () => resolve2(data4));
63124
+ req.on("error", reject);
63125
+ });
63126
+ }
63127
+ function json(res, status3, body) {
63128
+ res.writeHead(status3, { "content-type": "application/json", "cache-control": "no-store" });
63129
+ res.end(JSON.stringify(body));
63130
+ }
63131
+ function html(res, status3, body) {
63132
+ res.writeHead(status3, {
63133
+ "content-type": "text/html; charset=utf-8",
63134
+ "cache-control": "no-store",
63135
+ "referrer-policy": "no-referrer",
63136
+ "x-frame-options": "DENY",
63137
+ "content-security-policy": "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'; form-action 'none'"
63138
+ });
63139
+ res.end(body);
63140
+ }
63141
+ var esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
63142
+ var PAGE_STYLE = "body{margin:0;background:#101216;color:#f2f3f5;font:15px/1.5 ui-sans-serif,system-ui,sans-serif;display:grid;place-items:center;min-height:100vh}main{max-width:440px;padding:28px;border:1px solid rgba(255,255,255,.09);border-radius:16px;background:#1a1c21}h1{font-size:20px;margin:0 0 8px}p{color:rgba(242,243,245,.6);margin:8px 0}code{font-family:ui-monospace,Menlo,monospace;color:#fff}button{margin-top:14px;height:40px;padding:0 16px;border:0;border-radius:11px;background:#0891b2;color:#fff;font:inherit;font-weight:650;cursor:pointer}button:disabled{opacity:.5;cursor:default}.ok{color:#4ade80}";
63143
+ function openPage(args) {
63144
+ const short2 = `${args.address.slice(0, 6)}\u2026${args.address.slice(-4)}`;
63145
+ const site = siteOpenUrl(args.origin, args.port, args.token);
63146
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Agentgates \xB7 continue as ${esc(short2)}</title><style>${PAGE_STYLE}</style></head><body><main>
63147
+ <h1>Continue as <code>${esc(short2)}</code></h1>
63148
+ <p>Your agent is handing you its session on agentgates.ai. Nothing leaves this machine: the words cross from this page to the site's window and nowhere else.</p>
63149
+ <button id="go" type="button">Continue to agentgates.ai</button>
63150
+ <p id="line"></p>
63151
+ <script>
63152
+ (function(){
63153
+ var ORIGIN=${JSON.stringify(args.origin)}, TOKEN=${JSON.stringify(args.token)}, WORDS=${JSON.stringify(args.words)}, ADDRESS=${JSON.stringify(args.address)}, SITE=${JSON.stringify(site)};
63154
+ var go=document.getElementById('go'), line=document.getElementById('line'), w=null, done=false;
63155
+ window.addEventListener('message',function(e){
63156
+ if(done||e.origin!==ORIGIN||!e.data||e.data.type!=='agentgates-open-ready'||e.data.token!==TOKEN)return;
63157
+ var target=w||e.source; if(!target)return;
63158
+ target.postMessage({type:'agentgates-open-words',token:TOKEN,words:WORDS,address:ADDRESS},ORIGIN);
63159
+ done=true; WORDS='';
63160
+ fetch('/taken?token='+encodeURIComponent(TOKEN),{cache:'no-store'}).catch(function(){});
63161
+ line.className='ok'; line.textContent='Handed over. You can close this tab.';
63162
+ go.disabled=true; setTimeout(function(){window.close();},1500);
63163
+ });
63164
+ go.addEventListener('click',function(){
63165
+ w=window.open(SITE,'_blank'); if(!w){line.textContent='The browser blocked the new tab; allow pop-ups for 127.0.0.1 and press again.';return;}
63166
+ go.disabled=true; line.textContent='Waiting for agentgates.ai to say it is ready\u2026';
63167
+ setTimeout(function(){ if(!done){ go.disabled=false; line.textContent='The site did not answer; press again.'; } },20000);
63168
+ });
63169
+ })();
63170
+ </script></main></body></html>`;
63171
+ }
63172
+ function receivePage(args) {
63173
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Agentgates \xB7 receiving</title><style>${PAGE_STYLE}</style></head><body><main>
63174
+ <h1>Receiving your session</h1>
63175
+ <p id="line">Waiting for agentgates.ai to hand the words over\u2026</p>
63176
+ <script>
63177
+ (function(){
63178
+ var ORIGIN=${JSON.stringify(args.origin)}, line=document.getElementById('line'), done=false;
63179
+ window.addEventListener('message',function(e){
63180
+ if(done||e.origin!==ORIGIN||!e.data||e.data.type!=='agentgates-receive-words')return;
63181
+ done=true;
63182
+ fetch('/receive',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({code:e.data.code,words:e.data.words})})
63183
+ .then(function(r){return r.json().then(function(b){return {ok:r.ok&&b.ok===true,error:b.error};});})
63184
+ .catch(function(){return {ok:false,error:'the agent did not take it'};})
63185
+ .then(function(out){
63186
+ if(e.source)e.source.postMessage({type:'agentgates-receive-done',ok:out.ok,error:out.error||null},ORIGIN);
63187
+ line.className=out.ok?'ok':''; line.textContent=out.ok?'Handed over. Your agent is this account now. This tab closes itself.':('Not taken: '+(out.error||'unknown'));
63188
+ if(out.ok)setTimeout(function(){window.close();},1200); else done=false;
63189
+ });
63190
+ });
63191
+ if(window.opener)window.opener.postMessage({type:'agentgates-receive-ready'},ORIGIN);
63192
+ else line.textContent='Open this from agentgates.ai: Top up \u2192 Hand this session to my agent.';
63193
+ })();
63194
+ </script></main></body></html>`;
63195
+ }
63196
+ async function listen(server) {
63197
+ await new Promise((resolve2, reject) => {
63198
+ server.once("error", reject);
63199
+ server.listen(0, "127.0.0.1", () => resolve2());
63200
+ });
63201
+ const addr = server.address();
63202
+ if (!addr || typeof addr === "string") throw new Error("listener has no port");
63203
+ return addr.port;
63204
+ }
63205
+ async function serveWordsOnce(args) {
63206
+ const token = mintToken();
63207
+ let served = false;
63208
+ let taken = false;
63209
+ let port = 0;
63210
+ let done = () => {
63211
+ };
63212
+ let fail3 = () => {
63213
+ };
63214
+ const settled = new Promise((resolve2, reject) => {
63215
+ done = resolve2;
63216
+ fail3 = reject;
63217
+ });
63218
+ const server = createServer((req, res) => {
63219
+ const url = new URL(req.url ?? "/", "http://127.0.0.1");
63220
+ if (req.method === "GET" && url.pathname === "/open") {
63221
+ if (served || url.searchParams.get("token") !== token) return html(res, 403, `<!doctype html><html><head><meta charset="utf-8"><style>${PAGE_STYLE}</style></head><body><main><h1>This link was already used</h1><p>Run <code>agentgates open</code> again for a fresh one.</p></main></body></html>`);
63222
+ served = true;
63223
+ return html(res, 200, openPage({ origin: siteOrigin(), port, token, words: args.words, address: args.address }));
63224
+ }
63225
+ if (req.method === "GET" && url.pathname === "/taken") {
63226
+ if (taken || url.searchParams.get("token") !== token) return json(res, 403, { error: "token spent or wrong" });
63227
+ taken = true;
63228
+ json(res, 200, { ok: true });
63229
+ setTimeout(() => {
63230
+ server.close();
63231
+ done();
63232
+ }, 50);
63233
+ return;
63234
+ }
63235
+ return json(res, 404, { error: "not found" });
63236
+ });
63237
+ port = await listen(server);
63238
+ args.onUrl(openUrl(port, token), port);
63239
+ const timer = setTimeout(() => {
63240
+ if (!taken) {
63241
+ server.close();
63242
+ fail3(new Error(`nobody took the session in ${Math.round(args.waitMs / 1e3)}s`));
63243
+ }
63244
+ }, args.waitMs);
63245
+ try {
63246
+ await settled;
63247
+ } finally {
63248
+ clearTimeout(timer);
63249
+ }
63250
+ }
63251
+ async function receiveWordsOnce(args) {
63252
+ const code = mintCode();
63253
+ let taken = false;
63254
+ let done = () => {
63255
+ };
63256
+ let fail3 = () => {
63257
+ };
63258
+ const settled = new Promise((resolve2, reject) => {
63259
+ done = resolve2;
63260
+ fail3 = reject;
63261
+ });
63262
+ const server = createServer(async (req, res) => {
63263
+ const url = new URL(req.url ?? "/", "http://127.0.0.1");
63264
+ if (req.method === "GET" && url.pathname === "/receive") return html(res, 200, receivePage({ origin: siteOrigin() }));
63265
+ if (req.method === "GET" && url.pathname === "/hello") return json(res, 200, { ok: true, receive: true });
63266
+ if (req.method !== "POST" || url.pathname !== "/receive") return json(res, 404, { error: "not found" });
63267
+ const origin = req.headers.origin;
63268
+ if (origin && origin !== `http://127.0.0.1:${server.address().port}`) return json(res, 403, { error: "origin not allowed" });
63269
+ let body;
63270
+ try {
63271
+ body = JSON.parse(await readBody(req));
63272
+ } catch {
63273
+ return json(res, 400, { error: "body must be JSON" });
63274
+ }
63275
+ if (taken || typeof body.code !== "string" || body.code.trim().toUpperCase() !== code) return json(res, 403, { error: "code spent or wrong" });
63276
+ const words7 = typeof body.words === "string" ? body.words.trim().toLowerCase().split(/\s+/).join(" ") : "";
63277
+ if (words7.split(" ").length !== 12) return json(res, 400, { error: "twelve words expected" });
63278
+ taken = true;
63279
+ json(res, 200, { ok: true });
63280
+ setTimeout(() => {
63281
+ server.close();
63282
+ done({ words: words7 });
63283
+ }, 1500);
63284
+ });
63285
+ const port = await listen(server);
63286
+ args.onCode(code, port);
63287
+ const timer = setTimeout(() => {
63288
+ if (!taken) {
63289
+ server.close();
63290
+ fail3(new Error(`nobody handed a session over in ${Math.round(args.waitMs / 1e3)}s`));
63291
+ }
63292
+ }, args.waitMs);
63293
+ try {
63294
+ return await settled;
63295
+ } finally {
63296
+ clearTimeout(timer);
63297
+ }
63298
+ }
63299
+ function handoffCode(code, port) {
63300
+ return `${code}-${port}`;
63301
+ }
63302
+
63303
+ // src/commands/session.ts
63304
+ var jsonMode = (opts) => opts.json === true || !process.stdout.isTTY;
63305
+ function refuse(opts, error, code = null) {
63306
+ if (jsonMode(opts)) process.stdout.write(JSON.stringify({ ok: false, code, error }, null, 2) + "\n");
63307
+ else process.stderr.write(` ${error}${code ? import_picocolors7.default.dim(` (${code})`) : ""}
63308
+ `);
63309
+ process.exit(1);
63310
+ }
63311
+ function humanHandoffLines(address) {
63312
+ const site = siteOrigin();
63313
+ return ` ${import_picocolors7.default.bold("For your human")}
63314
+ ${import_picocolors7.default.dim(`Log in as this account at ${site}: Log in \u2192 I have a seed \u2192 paste the twelve words.`)}
63315
+ ${import_picocolors7.default.dim(`Or hand it over live on this machine: agentgates open (opens the browser already logged in as ${address.slice(0, 6)}\u2026${address.slice(-4)})`)}
63316
+ `;
63317
+ }
63318
+ async function sessionOpen(opts) {
63319
+ const waitMs = Math.max(10, Number(opts.wait) || 300) * 1e3;
63320
+ let keys;
63321
+ try {
63322
+ keys = await requirePasswordsKey();
63323
+ } catch (err) {
63324
+ return refuse(opts, err.message, "no_key");
63325
+ }
63326
+ const words7 = keys.state.mnemonic;
63327
+ if (!words7) return refuse(opts, "this key was made without words (a bare key); only a twelve-word account can be handed to a browser. Mint one with init --replace.", "bare_key");
63328
+ const address = keys.wallet.address;
63329
+ try {
63330
+ await serveWordsOnce({
63331
+ words: words7,
63332
+ address,
63333
+ waitMs,
63334
+ onUrl: (url, port) => {
63335
+ if (jsonMode(opts)) {
63336
+ process.stdout.write(JSON.stringify({ ok: true, status: "waiting", url, port, address, waitSeconds: waitMs / 1e3 }) + "\n");
63337
+ } else {
63338
+ process.stdout.write(`
63339
+ ${import_picocolors7.default.bold("OPEN")} ${import_picocolors7.default.dim(`a page from this machine; press Continue there and the browser is ${address}`)}
63340
+ `);
63341
+ if (opts.printUrl || opts.browser === false) process.stdout.write(` ${import_picocolors7.default.cyan(url)}
63342
+ `);
63343
+ process.stdout.write(` ${import_picocolors7.default.dim(`waiting ${Math.round(waitMs / 1e3)}s; the page is served once and the link dies with it`)}
63344
+ `);
63345
+ }
63346
+ if (opts.browser !== false && !process.env.CI) void open_default(url).catch(() => {
63347
+ });
63348
+ }
63349
+ });
63350
+ if (jsonMode(opts)) process.stdout.write(JSON.stringify({ ok: true, status: "handed", address }) + "\n");
63351
+ else process.stdout.write(` ${import_picocolors7.default.green("\u2713")} handed over; the browser is this account now.
63352
+
63353
+ `);
63354
+ } catch (err) {
63355
+ return refuse(opts, err.message, "not_taken");
63356
+ }
63357
+ }
63358
+ async function sessionReceive(opts) {
63359
+ const waitMs = Math.max(10, Number(opts.wait) || 300) * 1e3;
63360
+ try {
63361
+ const { words: words7 } = await receiveWordsOnce({
63362
+ waitMs,
63363
+ onCode: (code, port) => {
63364
+ const typed = handoffCode(code, port);
63365
+ if (jsonMode(opts)) {
63366
+ process.stdout.write(JSON.stringify({ ok: true, status: "waiting", code: typed, port, waitSeconds: waitMs / 1e3 }) + "\n");
63367
+ } else {
63368
+ process.stdout.write(`
63369
+ ${import_picocolors7.default.bold("RECEIVE")} ${import_picocolors7.default.dim(`on ${siteOrigin()}: Top up \u2192 Hand this session to my agent, then type`)}
63370
+ `);
63371
+ process.stdout.write(` ${import_picocolors7.default.cyan(typed)}
63372
+ `);
63373
+ process.stdout.write(` ${import_picocolors7.default.dim(`waiting ${Math.round(waitMs / 1e3)}s; the code dies on first use`)}
63374
+ `);
63375
+ }
63376
+ }
63377
+ });
63378
+ const { state } = await importPasswordsSeed({ seed: words7, replace: opts.replace === true });
63379
+ if (jsonMode(opts)) process.stdout.write(JSON.stringify({ ok: true, status: "received", address: state.address, path: passwordsKeyPath() }) + "\n");
63380
+ else process.stdout.write(` ${import_picocolors7.default.green("\u2713")} this CLI is ${import_picocolors7.default.bold(state.address)} now
63381
+ ${import_picocolors7.default.dim(passwordsKeyPath())}
63382
+
63383
+ `);
63384
+ } catch (err) {
63385
+ const message = err.message;
63386
+ return refuse(opts, message, /already exists/.test(message) ? "key_exists" : "not_received");
63387
+ }
63388
+ }
63389
+
62995
63390
  // src/lib/passwords-seal.ts
62996
- import { createCipheriv, createDecipheriv, createECDH, createHash as createHash2, hkdfSync, randomBytes as randomBytes4, randomUUID } from "node:crypto";
63391
+ import { createCipheriv, createDecipheriv, createECDH, createHash as createHash2, hkdfSync, randomBytes as randomBytes6, randomUUID } from "node:crypto";
62997
63392
  var PASSWORDS_SUITE = "AGENTGATES-PASSWORDS-ECDH-P256-HKDF-SHA256-AESGCM-v1";
62998
63393
  var PASSWORDS_WIRE_VERSION = 1;
62999
63394
  var INFO_BLOB = "blob";
@@ -63135,7 +63530,7 @@ function vaultAesKeyFromSignature(signature, kdf = KDF_CURRENT) {
63135
63530
  }
63136
63531
  function sealDurable(plaintext, signature, address) {
63137
63532
  const aesKey = vaultAesKeyFromSignature(signature, KDF_CURRENT);
63138
- const iv = randomBytes4(IV_BYTES);
63533
+ const iv = randomBytes6(IV_BYTES);
63139
63534
  const c = createCipheriv("aes-256-gcm", aesKey, iv);
63140
63535
  const ct = Buffer.concat([c.update(plaintext), c.final(), c.getAuthTag()]);
63141
63536
  const sealed = {
@@ -63180,7 +63575,7 @@ function sealToBox(boxPublicKeyRaw, keyId, payloadJson, secretId, owner) {
63180
63575
  eph.generateKeys();
63181
63576
  const shared = eph.computeSecret(boxPublicKeyRaw);
63182
63577
  const aesKey = Buffer.from(hkdfSync("sha256", shared, Buffer.from(keyId, "utf8"), Buffer.from(`${PASSWORDS_SUITE}|${INFO_BLOB}`, "utf8"), 32));
63183
- const iv = randomBytes4(IV_BYTES);
63578
+ const iv = randomBytes6(IV_BYTES);
63184
63579
  const cipher = createCipheriv("aes-256-gcm", aesKey, iv);
63185
63580
  cipher.setAAD(blobAad(keyId, secretId, owner));
63186
63581
  const ct = Buffer.concat([cipher.update(Buffer.from(payloadJson, "utf8")), cipher.final(), cipher.getAuthTag()]);
@@ -63243,7 +63638,7 @@ function validatePermitRequest(owner, m, nowSeconds = Math.floor(Date.now() / 1e
63243
63638
  }
63244
63639
  async function signPermit(wallet, request) {
63245
63640
  const fields = validatePermitRequest(wallet.address, request);
63246
- const nonce = ethers_exports.hexlify(randomBytes4(32));
63641
+ const nonce = ethers_exports.hexlify(randomBytes6(32));
63247
63642
  const message = {
63248
63643
  owner: ethers_exports.getAddress(fields.owner),
63249
63644
  agent: ethers_exports.getAddress(fields.agent),
@@ -63290,7 +63685,7 @@ function capsuleKey(secret, nonce, rowId) {
63290
63685
  return Buffer.from(hkdfSync("sha256", secret, Buffer.from(INVITE_HKDF_SALT, "utf8"), Buffer.from(`capsule|${nonce}|${rowId}`, "utf8"), 32));
63291
63686
  }
63292
63687
  function sealCapsule(secret, nonce, rowId, payloadJson) {
63293
- const iv = randomBytes4(IV_BYTES);
63688
+ const iv = randomBytes6(IV_BYTES);
63294
63689
  const c = createCipheriv("aes-256-gcm", capsuleKey(secret, nonce, rowId), iv);
63295
63690
  c.setAAD(Buffer.from(`${nonce}|${rowId}`, "utf8"));
63296
63691
  const ct = Buffer.concat([c.update(Buffer.from(payloadJson, "utf8")), c.final(), c.getAuthTag()]);
@@ -63329,140 +63724,29 @@ function decodeInviteFragment(fragment) {
63329
63724
  return { envelope: parsed.envelope, signature: parsed.signature, secret: fromB64u(parsed.s) };
63330
63725
  }
63331
63726
 
63332
- // src/lib/passwords-wire.ts
63333
- import { randomBytes as randomBytes5 } from "node:crypto";
63334
- var trim2 = (v) => v ? v.replace(/\/$/, "") : "";
63335
- function identityOrigin() {
63336
- return trim2(process.env.AGENTGATES_IDENTITY_ORIGIN) || trim2(process.env.AGENTGATES_ORIGIN) || "https://agentgates.ai";
63337
- }
63338
- function siteOrigin() {
63339
- return trim2(process.env.AGENTGATES_ORIGIN) || "https://agentgates.ai";
63340
- }
63341
- var LANE = "/api/identity";
63342
- var WireError = class extends Error {
63343
- constructor(status2, code, message, body) {
63344
- super(message);
63345
- this.status = status2;
63346
- this.code = code;
63347
- this.body = body;
63348
- this.name = "WireError";
63349
- }
63350
- status;
63351
- code;
63352
- body;
63353
- };
63354
- async function ownerAuthHeader(wallet, method, path6) {
63355
- const timestamp = Math.floor(Date.now() / 1e3);
63356
- const nonce = randomBytes5(16).toString("hex");
63357
- const signature = await wallet.signMessage(`${method.toUpperCase()}
63358
- ${path6}
63359
- ${nonce}
63360
- ${timestamp}`);
63361
- return Buffer.from(JSON.stringify({ address: wallet.address, timestamp, nonce, signature })).toString("base64");
63362
- }
63363
- async function signedFetch(wallet, method, path6, body, timeoutMs = 13e4) {
63364
- const headers = {
63365
- accept: "application/json",
63366
- "user-agent": CLI_USER_AGENT,
63367
- "x-wallet-auth": await ownerAuthHeader(wallet, method, path6)
63368
- };
63369
- if (body !== void 0) headers["content-type"] = "application/json";
63370
- let res;
63371
- try {
63372
- res = await fetch(`${identityOrigin()}${path6}`, {
63373
- method,
63374
- headers,
63375
- body: body !== void 0 ? JSON.stringify(body) : void 0,
63376
- signal: AbortSignal.timeout(timeoutMs)
63377
- });
63378
- } catch (err) {
63379
- throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
63380
- }
63381
- const text = await res.text();
63382
- let json = null;
63383
- try {
63384
- json = text ? JSON.parse(text) : null;
63385
- } catch {
63386
- json = null;
63387
- }
63388
- return { status: res.status, body: json, text };
63389
- }
63390
- function expectOk(answer, what) {
63391
- if (answer.status >= 200 && answer.status < 300 && answer.body) return answer.body;
63392
- const b2 = answer.body ?? {};
63393
- const code = typeof b2.code === "string" ? b2.code : null;
63394
- const error = typeof b2.error === "string" ? b2.error : `${what}: HTTP ${answer.status}`;
63395
- throw new WireError(answer.status, code, error, answer.body);
63396
- }
63397
- async function readAttestation() {
63398
- let res;
63399
- try {
63400
- res = await fetch(`${identityOrigin()}${LANE}/passwords/attestation`, {
63401
- headers: { accept: "application/json", "user-agent": CLI_USER_AGENT },
63402
- signal: AbortSignal.timeout(6e4)
63403
- });
63404
- } catch (err) {
63405
- throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
63406
- }
63407
- const body = await res.json().catch(() => null);
63408
- if (!res.ok || !body?.publicKey || !body?.keyId) {
63409
- const error = body?.error ?? `the box's key could not be read: HTTP ${res.status}`;
63410
- throw new WireError(res.status, body?.code ?? null, error, body);
63411
- }
63412
- return body;
63413
- }
63414
- async function listRows(wallet) {
63415
- const out = expectOk(await signedFetch(wallet, "GET", `${LANE}/passwords`), "list");
63416
- return { passwords: out.passwords ?? [], permitted: out.permitted ?? [] };
63417
- }
63418
- async function storeRow(wallet, body) {
63419
- const out = expectOk(await signedFetch(wallet, "POST", `${LANE}/passwords`, body), "store");
63420
- return out.password;
63421
- }
63422
- async function revealRow(wallet, id2) {
63423
- const out = expectOk(await signedFetch(wallet, "POST", `${LANE}/passwords/${encodeURIComponent(id2)}/reveal`), "reveal");
63424
- return out.passkeyBlob;
63425
- }
63426
- async function postPermit(wallet, signed2) {
63427
- const out = expectOk(
63428
- await signedFetch(wallet, "POST", `${LANE}/passwords/permits`, { typedData: signed2.typedData, signature: signed2.signature }),
63429
- "permit"
63430
- );
63431
- return out.permit;
63432
- }
63433
- async function postUse(wallet, id2, body, timeoutMs = 2e5) {
63434
- return signedFetch(wallet, "POST", `${LANE}/passwords/${encodeURIComponent(id2)}/use`, body, timeoutMs);
63435
- }
63436
- async function withdrawInvite(wallet, envelope, signature) {
63437
- return expectOk(
63438
- await signedFetch(wallet, "POST", `${LANE}/passwords/invites/withdraw`, { invite: { envelope, signature } }),
63439
- "withdraw"
63440
- );
63441
- }
63442
-
63443
63727
  // src/commands/passwords.ts
63444
63728
  var SITE5 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
63445
- var jsonMode = (opts) => opts.json === true || !process.stdout.isTTY;
63729
+ var jsonMode2 = (opts) => opts.json === true || !process.stdout.isTTY;
63446
63730
  function emit2(opts, data4, human) {
63447
- if (jsonMode(opts)) {
63731
+ if (jsonMode2(opts)) {
63448
63732
  process.stdout.write(JSON.stringify(data4, null, 2) + "\n");
63449
63733
  return;
63450
63734
  }
63451
63735
  human();
63452
63736
  }
63453
- function refuse(opts, error, code, extra = {}) {
63454
- if (jsonMode(opts)) {
63737
+ function refuse2(opts, error, code, extra = {}) {
63738
+ if (jsonMode2(opts)) {
63455
63739
  process.stdout.write(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
63456
63740
  } else {
63457
- process.stderr.write(` ${error}${code ? import_picocolors7.default.dim(` (${code})`) : ""}
63741
+ process.stderr.write(` ${error}${code ? import_picocolors8.default.dim(` (${code})`) : ""}
63458
63742
  `);
63459
63743
  }
63460
63744
  process.exit(1);
63461
63745
  }
63462
63746
  function failFrom(opts, err) {
63463
- if (err instanceof WireError) return refuse(opts, err.message, err.code, { status: err.status });
63464
- if (err instanceof PasswordsSealError) return refuse(opts, err.message, "refused");
63465
- return refuse(opts, err.message ?? String(err), null);
63747
+ if (err instanceof WireError) return refuse2(opts, err.message, err.code, { status: err.status });
63748
+ if (err instanceof PasswordsSealError) return refuse2(opts, err.message, "refused");
63749
+ return refuse2(opts, err.message ?? String(err), null);
63466
63750
  }
63467
63751
  var short = (addr) => `${addr.slice(0, 6)}\u2026${addr.slice(-4)}`;
63468
63752
  var splitList = (v) => (v ?? "").split(",").map((s) => s.trim()).filter(Boolean);
@@ -63514,19 +63798,20 @@ async function passwordsPricing(opts) {
63514
63798
  return;
63515
63799
  }
63516
63800
  if (!product || product.available === false) {
63517
- process.stdout.write(` ${import_picocolors7.default.dim(product?.note || product?.brief || "Passwords are not on sale right now.")}
63801
+ process.stdout.write(` ${import_picocolors8.default.dim(product?.note || product?.brief || "Passwords are not on sale right now.")}
63518
63802
  `);
63519
63803
  process.exitCode = 1;
63520
63804
  return;
63521
63805
  }
63522
63806
  process.stdout.write(`
63523
- ${import_picocolors7.default.bold("PASSWORDS")} ${import_picocolors7.default.dim(product.brief || "logins your agent uses and never sees")}
63807
+ ${import_picocolors8.default.bold("PASSWORDS")} ${import_picocolors8.default.dim(product.brief || "logins your agent uses and never sees")}
63524
63808
 
63525
63809
  `);
63526
63810
  const freeRows = slice.payg?.passwords;
63811
+ const freeUses = slice.payg?.passwordsUsesPerDay ?? 0;
63527
63812
  if (freeRows) {
63528
63813
  process.stdout.write(
63529
- ` ${import_picocolors7.default.bold("free".padEnd(11))} ${import_picocolors7.default.cyan("$0".padStart(4))}${"".padEnd(11)} ${import_picocolors7.default.dim(`${freeRows} passwords, every use metered`)}
63814
+ ` ${import_picocolors8.default.bold("free".padEnd(11))} ${import_picocolors8.default.cyan("$0".padStart(4))}${"".padEnd(11)} ${import_picocolors8.default.dim(`${freeRows} login${freeRows === 1 ? "" : "s"}, ${freeUses > 0 ? `${freeUses} uses a day` : "every use metered"}; try it first`)}
63530
63815
  `
63531
63816
  );
63532
63817
  }
@@ -63543,16 +63828,16 @@ async function passwordsPricing(opts) {
63543
63828
  }
63544
63829
  for (const f2 of families) {
63545
63830
  const rows = byFamily.get(f2).sort((a, b2) => a.units - b2.units);
63546
- const cells = rows.map((p) => `${import_picocolors7.default.cyan(usd4(p.priceUsd).padStart(4))}${import_picocolors7.default.dim(`/${p.units} days`.padEnd(10))}`).join(" ");
63831
+ const cells = rows.map((p) => `${import_picocolors8.default.cyan(usd4(p.priceUsd).padStart(4))}${import_picocolors8.default.dim(`/${p.units} days`.padEnd(10))}`).join(" ");
63547
63832
  const lead = rows[0];
63548
63833
  const cap = [
63549
63834
  lead.passwords ? `${lead.passwords.toLocaleString()} passwords` : "",
63550
63835
  lead.usesPerDay ? `${lead.usesPerDay.toLocaleString()} uses/day` : ""
63551
63836
  ].filter(Boolean).join(" \xB7 ");
63552
- process.stdout.write(` ${import_picocolors7.default.bold(f2.padEnd(11))} ${cells} ${import_picocolors7.default.dim(cap)}
63837
+ process.stdout.write(` ${import_picocolors8.default.bold(f2.padEnd(11))} ${cells} ${import_picocolors8.default.dim(cap)}
63553
63838
  `);
63554
63839
  }
63555
- if (plans.length === 0) process.stdout.write(` ${import_picocolors7.default.dim("no plan rungs are priced right now")}
63840
+ if (plans.length === 0) process.stdout.write(` ${import_picocolors8.default.dim("no plan rungs are priced right now")}
63556
63841
  `);
63557
63842
  const use = slice.passwordsUsage?.useUsd;
63558
63843
  const login2 = slice.passwordsUsage?.loginUsd;
@@ -63561,16 +63846,16 @@ async function passwordsPricing(opts) {
63561
63846
  login2 ? `a login ${usd4(login2)}` : ""
63562
63847
  ].filter(Boolean).join(" \xB7 ");
63563
63848
  if (meter) process.stdout.write(`
63564
- ${import_picocolors7.default.dim(`past the daily uses, from the agent's prepaid balance: ${meter}`)}
63849
+ ${import_picocolors8.default.dim(`past the daily uses, from the agent's prepaid balance: ${meter}`)}
63565
63850
  `);
63566
- process.stdout.write(` ${import_picocolors7.default.dim("storing is free on every plan; we store ciphertext we cannot read")}
63851
+ process.stdout.write(` ${import_picocolors8.default.dim("storing is free on every plan; we store ciphertext we cannot read")}
63567
63852
  `);
63568
63853
  const bal = slice.balance;
63569
- if (bal?.note) process.stdout.write(` ${import_picocolors7.default.dim(bal.note)}
63854
+ if (bal?.note) process.stdout.write(` ${import_picocolors8.default.dim(bal.note)}
63570
63855
  `);
63571
63856
  const nets = [...new Set((plans[0]?.byNetwork ?? []).map((n2) => n2.network))];
63572
63857
  if (nets.length) process.stdout.write(`
63573
- ${import_picocolors7.default.dim(`USDC on ${nets.join(", ")}`)}
63858
+ ${import_picocolors8.default.dim(`USDC on ${nets.join(", ")}`)}
63574
63859
 
63575
63860
  `);
63576
63861
  else process.stdout.write("\n");
@@ -63581,60 +63866,53 @@ async function passwordsInit(opts) {
63581
63866
  const { state: state2 } = await importPasswordsKey(opts.import, opts.replace === true);
63582
63867
  emit2(opts, { ok: true, address: state2.address, created: false, imported: true, path: passwordsKeyPath() }, () => {
63583
63868
  process.stdout.write(`
63584
- ${import_picocolors7.default.green("\u2713")} key imported: ${import_picocolors7.default.bold(state2.address)}
63585
- ${import_picocolors7.default.dim(passwordsKeyPath())}
63869
+ ${import_picocolors8.default.green("\u2713")} key imported: ${import_picocolors8.default.bold(state2.address)}
63870
+ ${import_picocolors8.default.dim(passwordsKeyPath())}
63586
63871
 
63587
63872
  `);
63588
63873
  });
63589
63874
  return;
63590
63875
  }
63591
- if (opts.seed || opts.vaultSeed) {
63592
- const { state: state2, separateLock: separateLock2 } = await importPasswordsSeed({ seed: opts.seed, vaultSeed: opts.vaultSeed, replace: opts.replace === true });
63593
- emit2(opts, { ok: true, address: state2.address, vaultAddress: separateLock2 ? state2.vaultAddress : null, created: false, imported: true, words: SEED_WORDS, path: passwordsKeyPath() }, () => {
63594
- process.stdout.write(
63595
- `
63596
- ${import_picocolors7.default.green("\u2713")} twelve words taken: ${import_picocolors7.default.bold(state2.address)}` + (separateLock2 ? `
63597
- ${import_picocolors7.default.dim("the vault's twelve too, lock")} ${state2.vaultAddress}` : `
63598
- ${import_picocolors7.default.dim("no vault words: this key is its own lock")}`) + `
63599
- ${import_picocolors7.default.dim(passwordsKeyPath())}
63876
+ if (opts.seed) {
63877
+ const { state: state2 } = await importPasswordsSeed({ seed: opts.seed, replace: opts.replace === true });
63878
+ emit2(opts, { ok: true, address: state2.address, created: false, imported: true, words: SEED_WORDS, path: passwordsKeyPath() }, () => {
63879
+ process.stdout.write(`
63880
+ ${import_picocolors8.default.green("\u2713")} twelve words taken: ${import_picocolors8.default.bold(state2.address)}
63881
+ ${import_picocolors8.default.dim(passwordsKeyPath())}
63600
63882
 
63601
- `
63602
- );
63883
+ `);
63603
63884
  });
63604
63885
  return;
63605
63886
  }
63606
63887
  if (opts.revealSeed) {
63607
- const { state: state2, separateLock: separateLock2 } = await requirePasswordsKey();
63888
+ const { state: state2 } = await requirePasswordsKey();
63608
63889
  if (!state2.mnemonic) throw new Error("this key was made without words (a bare key); mint a new one with init --replace, or bring words with init --seed.");
63609
- emit2(opts, { ok: true, address: state2.address, seed: state2.mnemonic, ...separateLock2 ? { vaultAddress: state2.vaultAddress, vaultSeed: state2.vaultMnemonic } : {} }, () => {
63610
- process.stdout.write(
63611
- `
63612
- ${import_picocolors7.default.dim("signing")} ${state2.mnemonic}
63613
- ` + (separateLock2 ? ` ${import_picocolors7.default.dim("vault")} ${state2.vaultMnemonic}
63614
- ` : "") + `
63615
- ${import_picocolors7.default.dim(`the words behind ${state2.address}. Whoever holds the signing words is this account; whoever holds the vault words opens what it stores.`)}
63890
+ emit2(opts, { ok: true, address: state2.address, seed: state2.mnemonic }, () => {
63891
+ process.stdout.write(`
63892
+ ${state2.mnemonic}
63616
63893
 
63617
- `
63618
- );
63894
+ ${import_picocolors8.default.dim(`the words behind ${state2.address}. Whoever holds them is this account: they sign every call, hold its balance and open what it stores.`)}
63895
+
63896
+ ` + humanHandoffLines(state2.address) + "\n");
63619
63897
  });
63620
63898
  return;
63621
63899
  }
63622
- const { state, created, minted, separateLock } = await loadOrCreatePasswordsKey();
63623
- emit2(opts, { ok: true, address: state.address, vaultAddress: separateLock ? state.vaultAddress : null, created, path: passwordsKeyPath(), ...minted ? { seed: minted.seed, vaultSeed: minted.vaultSeed } : {} }, () => {
63900
+ const { state, created, minted } = await loadOrCreatePasswordsKey();
63901
+ emit2(opts, { ok: true, address: state.address, created, path: passwordsKeyPath(), ...minted ? { seed: minted.seed } : {} }, () => {
63624
63902
  process.stdout.write(
63625
63903
  `
63626
- ${import_picocolors7.default.green("\u2713")} ${created ? "keys minted" : "keys already here"}: ${import_picocolors7.default.bold(state.address)}
63627
- ${import_picocolors7.default.dim(passwordsKeyPath())}
63904
+ ${import_picocolors8.default.green("\u2713")} ${created ? "key minted" : "key already here"}: ${import_picocolors8.default.bold(state.address)}
63905
+ ${import_picocolors8.default.dim(passwordsKeyPath())}
63628
63906
  ` + (minted ? `
63629
- ${import_picocolors7.default.dim("signing")} ${import_picocolors7.default.bold(minted.seed)}
63630
- ${import_picocolors7.default.dim("vault")} ${import_picocolors7.default.bold(minted.vaultSeed)}
63907
+ ${import_picocolors8.default.bold(minted.seed)}
63631
63908
 
63632
- ${import_picocolors7.default.dim("Shown once. The signing words are this account on agentgates.ai; the vault words open what it stores. Write both down, or hand them to the person you work for.")}
63633
- ${import_picocolors7.default.dim("agentgates passwords init --reveal-seed \xB7 prints them again")}
63909
+ ${import_picocolors8.default.dim("Shown once. These twelve words are this account on agentgates.ai: they sign every call, hold its balance and open what it stores. Write them down, or hand them to the person you work for.")}
63910
+ ${import_picocolors8.default.dim("agentgates init --reveal-seed \xB7 prints them again")}
63634
63911
 
63635
- ` : ` ${import_picocolors7.default.dim(separateLock ? "The signing key signs every call; the vault key locks what it stores. Neither leaves this machine." : "It signs every call and locks your vault. It never leaves this machine.")}
63912
+ ` + humanHandoffLines(state.address) + "\n" : ` ${import_picocolors8.default.dim("It signs every call, holds this account's balance and locks its vault. It never leaves this machine.")}
63636
63913
 
63637
- `) + ` ${import_picocolors7.default.dim("agentgates passwords add --label <name> --host <site> --username <u> --password <p>")}
63914
+ `) + ` ${import_picocolors8.default.dim("agentgates browser balance \xB7 the balance and the address that tops it up")}
63915
+ ${import_picocolors8.default.dim("agentgates passwords add --label <name> --host <site> --username <u> --password <p>")}
63638
63916
 
63639
63917
  `
63640
63918
  );
@@ -63645,7 +63923,7 @@ async function passwordsInit(opts) {
63645
63923
  }
63646
63924
  async function passwordsAdd(opts) {
63647
63925
  try {
63648
- const { wallet, vaultWallet } = await requirePasswordsKey();
63926
+ const { wallet } = await requirePasswordsKey();
63649
63927
  const label = (opts.label ?? "").trim().slice(0, MAX_LABEL_CHARS);
63650
63928
  if (!label) throw new PasswordsSealError("--label names the login (what you will call it)");
63651
63929
  const hosts = [...opts.host ?? [], ...splitList(opts.hosts)];
@@ -63668,8 +63946,8 @@ async function passwordsAdd(opts) {
63668
63946
  const att = await readAttestation();
63669
63947
  const id2 = mintSecretId();
63670
63948
  const payloadJson = JSON.stringify(payload);
63671
- const signature = await signVaultMessage(vaultWallet);
63672
- const passkeyBlob = sealDurable(Buffer.from(payloadJson, "utf8"), signature, vaultWallet.address);
63949
+ const signature = await signVaultMessage(wallet);
63950
+ const passkeyBlob = sealDurable(Buffer.from(payloadJson, "utf8"), signature, wallet.address);
63673
63951
  const cvmBlob = sealToBox(Buffer.from(att.publicKey, "base64url"), att.keyId, payloadJson, id2, wallet.address);
63674
63952
  const row = await storeRow(wallet, {
63675
63953
  id: id2,
@@ -63677,7 +63955,7 @@ async function passwordsAdd(opts) {
63677
63955
  kind: payload.kind,
63678
63956
  hosts: payload.hosts,
63679
63957
  ...username ? { username } : {},
63680
- credentialId: `wallet:${vaultWallet.address.toLowerCase()}`,
63958
+ credentialId: `wallet:${wallet.address.toLowerCase()}`,
63681
63959
  passkeyBlob,
63682
63960
  cvmBlob,
63683
63961
  cvmKeyId: att.keyId
@@ -63685,12 +63963,12 @@ async function passwordsAdd(opts) {
63685
63963
  emit2(opts, { ok: true, id: row.id, label: row.label, kind: row.kind, hosts: row.hosts, username: row.username ?? null, owner: wallet.address }, () => {
63686
63964
  process.stdout.write(
63687
63965
  `
63688
- ${import_picocolors7.default.green("\u2713")} stored ${import_picocolors7.default.bold(row.label)} for ${row.hosts.join(", ")}
63689
- ${import_picocolors7.default.dim("row")} ${row.id}
63690
- ${import_picocolors7.default.dim("sealed on this machine; the server holds ciphertext it cannot open")}
63966
+ ${import_picocolors8.default.green("\u2713")} stored ${import_picocolors8.default.bold(row.label)} for ${row.hosts.join(", ")}
63967
+ ${import_picocolors8.default.dim("row")} ${row.id}
63968
+ ${import_picocolors8.default.dim("sealed on this machine; the server holds ciphertext it cannot open")}
63691
63969
 
63692
- ${import_picocolors7.default.dim(`agentgates passwords allow \xB7 permit yourself to use it`)}
63693
- ${import_picocolors7.default.dim(`agentgates passwords use --row ${row.id} --url https://${row.hosts[0]}/login`)}
63970
+ ${import_picocolors8.default.dim(`agentgates passwords allow \xB7 permit yourself to use it`)}
63971
+ ${import_picocolors8.default.dim(`agentgates passwords use --row ${row.id} --url https://${row.hosts[0]}/login`)}
63694
63972
 
63695
63973
  `
63696
63974
  );
@@ -63721,9 +63999,9 @@ async function passwordsAllow(opts) {
63721
63999
  emit2(opts, { ok: true, permitId: permit.id, agent: permit.agent, self: self2, secretIds: permit.secretIds, hosts: permit.hosts, uses: permit.uses, usesPerDay: permit.usesPerDay, approveEachUse: permit.approveEachUse, expiresAt: permit.expiresAt }, () => {
63722
64000
  process.stdout.write(
63723
64001
  `
63724
- ${import_picocolors7.default.green("\u2713")} ${self2 ? "you may use" : `${short(permit.agent)} may use`} ${permit.secretIds[0] === "*" ? "every login this key holds" : `${permit.secretIds.length} login${permit.secretIds.length === 1 ? "" : "s"}`} for ${permit.uses.join(", ")} until ${permit.expiresAt.slice(0, 10)}
63725
- ${import_picocolors7.default.dim("permit")} ${permit.id}
63726
- ` + (permit.approveEachUse ? ` ${import_picocolors7.default.dim(self2 ? "ask-me is on for a permit to yourself, which parks every use behind your own board; nobody is there to press approve" : "every use waits for the owner's signature")}
64002
+ ${import_picocolors8.default.green("\u2713")} ${self2 ? "you may use" : `${short(permit.agent)} may use`} ${permit.secretIds[0] === "*" ? "every login this key holds" : `${permit.secretIds.length} login${permit.secretIds.length === 1 ? "" : "s"}`} for ${permit.uses.join(", ")} until ${permit.expiresAt.slice(0, 10)}
64003
+ ${import_picocolors8.default.dim("permit")} ${permit.id}
64004
+ ` + (permit.approveEachUse ? ` ${import_picocolors8.default.dim(self2 ? "ask-me is on for a permit to yourself, which parks every use behind your own board; nobody is there to press approve" : "every use waits for the owner's signature")}
63727
64005
  ` : "") + "\n"
63728
64006
  );
63729
64007
  });
@@ -63737,25 +64015,25 @@ async function passwordsList(opts) {
63737
64015
  const { passwords: passwords2, permitted } = await listRows(wallet);
63738
64016
  emit2(opts, { ok: true, address: wallet.address, passwords: passwords2, permitted }, () => {
63739
64017
  process.stdout.write(`
63740
- ${import_picocolors7.default.bold(short(wallet.address))}
64018
+ ${import_picocolors8.default.bold(short(wallet.address))}
63741
64019
 
63742
64020
  `);
63743
64021
  if (passwords2.length === 0 && permitted.length === 0) {
63744
- process.stdout.write(` ${import_picocolors7.default.dim("nothing stored and nothing permitted yet")}
64022
+ process.stdout.write(` ${import_picocolors8.default.dim("nothing stored and nothing permitted yet")}
63745
64023
 
63746
64024
  `);
63747
64025
  return;
63748
64026
  }
63749
64027
  if (passwords2.length) {
63750
- process.stdout.write(` ${import_picocolors7.default.dim("yours")}
64028
+ process.stdout.write(` ${import_picocolors8.default.dim("yours")}
63751
64029
  `);
63752
- for (const r of passwords2) process.stdout.write(` ${import_picocolors7.default.cyan(r.id.padEnd(40))} ${r.label.padEnd(24)} ${import_picocolors7.default.dim(r.hosts.join(", "))}${r.stale ? import_picocolors7.default.dim(" (stale: re-seal on the board)") : ""}
64030
+ for (const r of passwords2) process.stdout.write(` ${import_picocolors8.default.cyan(r.id.padEnd(40))} ${r.label.padEnd(24)} ${import_picocolors8.default.dim(r.hosts.join(", "))}${r.stale ? import_picocolors8.default.dim(" (stale: re-seal on the board)") : ""}
63753
64031
  `);
63754
64032
  }
63755
64033
  if (permitted.length) {
63756
- process.stdout.write(` ${import_picocolors7.default.dim("permitted to you")}
64034
+ process.stdout.write(` ${import_picocolors8.default.dim("permitted to you")}
63757
64035
  `);
63758
- for (const r of permitted) process.stdout.write(` ${import_picocolors7.default.cyan(r.id.padEnd(40))} ${r.label.padEnd(24)} ${import_picocolors7.default.dim(`${r.hosts.join(", ")} \xB7 ${r.uses.join(", ")}`)}
64036
+ for (const r of permitted) process.stdout.write(` ${import_picocolors8.default.cyan(r.id.padEnd(40))} ${r.label.padEnd(24)} ${import_picocolors8.default.dim(`${r.hosts.join(", ")} \xB7 ${r.uses.join(", ")}`)}
63759
64037
  `);
63760
64038
  }
63761
64039
  process.stdout.write("\n");
@@ -63765,42 +64043,42 @@ async function passwordsList(opts) {
63765
64043
  }
63766
64044
  }
63767
64045
  async function rowForUrl(wallet, url) {
63768
- let host;
64046
+ let host2;
63769
64047
  try {
63770
- host = new URL(url).hostname.toLowerCase();
64048
+ host2 = new URL(url).hostname.toLowerCase();
63771
64049
  } catch {
63772
64050
  throw new PasswordsSealError("--url must be the https URL the use targets");
63773
64051
  }
63774
64052
  const { passwords: passwords2, permitted } = await listRows(wallet);
63775
- const covers = (hosts) => hosts.some((h) => host === h.toLowerCase() || host.endsWith(`.${h.toLowerCase()}`));
64053
+ const covers = (hosts) => hosts.some((h) => host2 === h.toLowerCase() || host2.endsWith(`.${h.toLowerCase()}`));
63776
64054
  const own = passwords2.find((r) => covers(r.hosts));
63777
64055
  if (own) return own.id;
63778
64056
  const lent = permitted.find((r) => covers(r.hosts));
63779
64057
  if (lent) return lent.id;
63780
- throw new PasswordsSealError(`no login this key holds or may use covers ${host}; pass --row <id>, or add one`);
64058
+ throw new PasswordsSealError(`no login this key holds or may use covers ${host2}; pass --row <id>, or add one`);
63781
64059
  }
63782
- function printUseAnswer(opts, status2, body) {
63783
- const data4 = { ok: body.ok === true, status: status2, ...body };
64060
+ function printUseAnswer(opts, status3, body) {
64061
+ const data4 = { ok: body.ok === true, status: status3, ...body };
63784
64062
  emit2(opts, data4, () => {
63785
- if (status2 === 200) {
64063
+ if (status3 === 200) {
63786
64064
  const result = body.result ?? {};
63787
64065
  const code = typeof result.code === "string" ? result.code : "ok";
63788
64066
  const digest = typeof result.digest === "string" ? result.digest : "";
63789
64067
  process.stdout.write(`
63790
- ${import_picocolors7.default.green("\u2713")} ${code}${body.seconds ? import_picocolors7.default.dim(` ${body.seconds}s`) : ""}${body.chargedUsd && body.chargedUsd !== "0.00" ? import_picocolors7.default.dim(` $${body.chargedUsd}`) : ""}
64068
+ ${import_picocolors8.default.green("\u2713")} ${code}${body.seconds ? import_picocolors8.default.dim(` ${body.seconds}s`) : ""}${body.chargedUsd && body.chargedUsd !== "0.00" ? import_picocolors8.default.dim(` $${body.chargedUsd}`) : ""}
63791
64069
  `);
63792
64070
  if (digest) process.stdout.write(`
63793
64071
  ${digest.split("\n").map((l) => ` ${l}`).join("\n")}
63794
64072
  `);
63795
64073
  const steps = Array.isArray(result.steps) ? result.steps : [];
63796
- for (const s of steps) process.stdout.write(` ${import_picocolors7.default.dim(JSON.stringify(s).slice(0, 200))}
64074
+ for (const s of steps) process.stdout.write(` ${import_picocolors8.default.dim(JSON.stringify(s).slice(0, 200))}
63797
64075
  `);
63798
64076
  process.stdout.write("\n");
63799
64077
  return;
63800
64078
  }
63801
64079
  process.stdout.write(`
63802
- ${body.error ?? `HTTP ${status2}`}${body.code ? import_picocolors7.default.dim(` (${body.code})`) : ""}
63803
- ${body.useId ? ` ${import_picocolors7.default.dim("use")} ${body.useId}
64080
+ ${body.error ?? `HTTP ${status3}`}${body.code ? import_picocolors8.default.dim(` (${body.code})`) : ""}
64081
+ ${body.useId ? ` ${import_picocolors8.default.dim("use")} ${body.useId}
63804
64082
  ` : ""}
63805
64083
  `);
63806
64084
  });
@@ -63840,7 +64118,7 @@ async function passwordsUse(opts) {
63840
64118
  waitCap !== null ? startedAt + waitCap * 1e3 : Number.POSITIVE_INFINITY
63841
64119
  );
63842
64120
  if (Date.now() >= deadline) break;
63843
- if (!jsonMode(opts)) process.stderr.write(` ${import_picocolors7.default.dim(body2.error ?? "waiting for the owner")}
64121
+ if (!jsonMode2(opts)) process.stderr.write(` ${import_picocolors8.default.dim(body2.error ?? "waiting for the owner")}
63844
64122
  `);
63845
64123
  answer = await postUse(wallet, rowId, { use, request: use === "totp" && Object.keys(request).length === 0 ? void 0 : request, useId: body2.useId, wait: 25 });
63846
64124
  }
@@ -63856,7 +64134,7 @@ function joinPath() {
63856
64134
  }
63857
64135
  async function passwordsInvite(opts) {
63858
64136
  try {
63859
- const { wallet, vaultWallet, separateLock } = await requirePasswordsKey();
64137
+ const { wallet, olderLock } = await requirePasswordsKey();
63860
64138
  if (opts.withdraw) {
63861
64139
  const hash2 = opts.withdraw.includes("#") ? opts.withdraw.slice(opts.withdraw.indexOf("#")) : opts.withdraw;
63862
64140
  const { envelope: envelope2, signature } = decodeInviteFragment(hash2);
@@ -63864,7 +64142,7 @@ async function passwordsInvite(opts) {
63864
64142
  const out = await withdrawInvite(wallet, envelope2, signature);
63865
64143
  emit2(opts, { ok: true, withdrawn: true, nonce: out.nonce }, () => {
63866
64144
  process.stdout.write(`
63867
- ${import_picocolors7.default.green("\u2713")} withdrawn; that link opens nothing now
64145
+ ${import_picocolors8.default.green("\u2713")} withdrawn; that link opens nothing now
63868
64146
 
63869
64147
  `);
63870
64148
  });
@@ -63878,10 +64156,10 @@ async function passwordsInvite(opts) {
63878
64156
  if (wanted.length === 0) throw new PasswordsSealError("this key holds no logins to hand over; add one first");
63879
64157
  if (wanted.length > MAX_SECRET_IDS_PER_PERMIT) throw new PasswordsSealError(`an invitation carries at most ${MAX_SECRET_IDS_PER_PERMIT} logins`);
63880
64158
  const rows = [];
63881
- const secret = randomBytes6(32);
63882
- const nonce = ethers_exports.hexlify(randomBytes6(32));
63883
- const locks = [await signVaultMessage(vaultWallet)];
63884
- if (separateLock) locks.push(await signVaultMessage(wallet));
64159
+ const secret = randomBytes7(32);
64160
+ const nonce = ethers_exports.hexlify(randomBytes7(32));
64161
+ const locks = [await signVaultMessage(wallet)];
64162
+ if (olderLock) locks.push(await signVaultMessage(olderLock));
63885
64163
  for (const id2 of wanted) {
63886
64164
  const row = passwords2.find((r) => r.id === id2);
63887
64165
  if (!row) throw new PasswordsSealError(`${id2} is not a row this key holds`);
@@ -63894,7 +64172,7 @@ async function passwordsInvite(opts) {
63894
64172
  } catch {
63895
64173
  }
63896
64174
  }
63897
- if (payloadJson === null) throw new PasswordsSealError(`${id2} is locked with words this key does not hold`);
64175
+ if (payloadJson === null) throw new PasswordsSealError(`${id2} is locked with a key this machine does not hold`);
63898
64176
  parseSecretPayload(payloadJson);
63899
64177
  rows.push({
63900
64178
  id: row.id,
@@ -63921,13 +64199,13 @@ async function passwordsInvite(opts) {
63921
64199
  emit2(opts, { ok: true, link, agent: envelope.agent, rows: rows.map((r) => ({ id: r.id, label: r.label })), expiresAt: new Date(envelope.expiresAt * 1e3).toISOString(), minutes }, () => {
63922
64200
  process.stdout.write(
63923
64201
  `
63924
- ${import_picocolors7.default.green("\u2713")} an invitation over ${rows.length} login${rows.length === 1 ? "" : "s"}, good for ${minutes} minutes
64202
+ ${import_picocolors8.default.green("\u2713")} an invitation over ${rows.length} login${rows.length === 1 ? "" : "s"}, good for ${minutes} minutes
63925
64203
 
63926
64204
  ${link}
63927
64205
 
63928
- ${import_picocolors7.default.dim("Whoever opens it takes the owner seat over these logins and sets the guardrails.")}
63929
- ${import_picocolors7.default.dim("The link is the key to them until it is used. Send it to one person, once.")}
63930
- ${import_picocolors7.default.dim("agentgates passwords invite --withdraw '<link>' \xB7 if it went to the wrong place")}
64206
+ ${import_picocolors8.default.dim("Whoever opens it takes these logins under their own wallet and sets the guardrails.")}
64207
+ ${import_picocolors8.default.dim("The link is the key to them until it is used. Send it to one person, once.")}
64208
+ ${import_picocolors8.default.dim("agentgates passwords invite --withdraw '<link>' \xB7 if it went to the wrong place")}
63931
64209
 
63932
64210
  `
63933
64211
  );
@@ -63937,6 +64215,353 @@ async function passwordsInvite(opts) {
63937
64215
  }
63938
64216
  }
63939
64217
 
64218
+ // src/commands/browser.ts
64219
+ var import_picocolors9 = __toESM(require_picocolors(), 1);
64220
+
64221
+ // src/lib/browser-wire.ts
64222
+ var BROWSER_LANE = "/api/identity/browser";
64223
+ var SETTLED = /* @__PURE__ */ new Set(["done", "failed", "cancelled"]);
64224
+ async function readBrowserCatalog() {
64225
+ let res;
64226
+ try {
64227
+ res = await fetch(`${siteOrigin()}/api/identity/catalog`, { headers: { accept: "application/json", "user-agent": CLI_USER_AGENT } });
64228
+ } catch (err) {
64229
+ throw new WireError(0, "network_error", `could not reach ${siteOrigin()}: ${err.message}`, null);
64230
+ }
64231
+ if (!res.ok) throw new WireError(res.status, null, `browser catalog: HTTP ${res.status}`, null);
64232
+ const body = await res.json();
64233
+ return {
64234
+ product: (body.products ?? []).find((p) => p.id === "browser") ?? null,
64235
+ usage: body.browserUsage ?? null,
64236
+ networks: body.payment?.networks ?? []
64237
+ };
64238
+ }
64239
+ function expect(answer, what) {
64240
+ if (answer.status >= 200 && answer.status < 300 && answer.body) return answer.body;
64241
+ const body = answer.body ?? null;
64242
+ const sentence = typeof body?.error === "string" ? body.error : answer.text.slice(0, 300) || `${what}: HTTP ${answer.status}`;
64243
+ const code = typeof body?.code === "string" ? body.code : null;
64244
+ throw new WireError(answer.status, code, sentence, answer.body);
64245
+ }
64246
+ async function postTask(wallet, args) {
64247
+ const body = { url: args.url, goal: args.goal };
64248
+ if (args.hosts?.length) body.hosts = args.hosts;
64249
+ if (typeof args.maxSteps === "number") body.maxSteps = args.maxSteps;
64250
+ if (typeof args.maxSeconds === "number") body.maxSeconds = args.maxSeconds;
64251
+ const answer = await signedFetch(wallet, "POST", `${BROWSER_LANE}/tasks`, body);
64252
+ return expect(answer, "task").task;
64253
+ }
64254
+ async function listTasks(wallet) {
64255
+ const answer = await signedFetch(wallet, "GET", `${BROWSER_LANE}/tasks`);
64256
+ return expect(answer, "tasks").tasks ?? [];
64257
+ }
64258
+ async function readTask(wallet, id2) {
64259
+ const answer = await signedFetch(wallet, "GET", `${BROWSER_LANE}/tasks/${encodeURIComponent(id2)}`);
64260
+ return expect(answer, "task").task;
64261
+ }
64262
+ async function readIdentityBalance(wallet) {
64263
+ const answer = await signedFetch(
64264
+ wallet,
64265
+ "GET",
64266
+ `${LANE}/credits`
64267
+ );
64268
+ const body = expect(answer, "balance");
64269
+ return { balance: body.balance ?? null, entries: body.entries ?? [], rungsUsd: body.rungsUsd ?? [] };
64270
+ }
64271
+ async function readDepositAddress(wallet) {
64272
+ const answer = await signedFetch(wallet, "GET", `${LANE}/deposit`);
64273
+ if (answer.status === 503) {
64274
+ const b2 = answer.body ?? {};
64275
+ return { deposit: null, dark: typeof b2.error === "string" ? b2.error : "deposit addresses are not open yet on this deployment" };
64276
+ }
64277
+ const body = expect(answer, "deposit address");
64278
+ const payToAll = Array.isArray(body.payToAll) ? body.payToAll : [];
64279
+ const chains = payToAll.filter((e) => e && typeof e.chainId === "number" && typeof e.address === "string").map((e) => ({ chainId: e.chainId, network: typeof e.network === "string" ? e.network : String(e.chainId), address: e.address }));
64280
+ if (typeof body.address !== "string" || chains.length === 0) throw new WireError(answer.status, "bad_wire", "the deposit address could not be read", answer.body);
64281
+ return {
64282
+ deposit: {
64283
+ address: body.address,
64284
+ chains,
64285
+ minConfirmations: typeof body.minConfirmations === "number" ? body.minConfirmations : 0,
64286
+ note: typeof body.note === "string" ? body.note : ""
64287
+ },
64288
+ dark: null
64289
+ };
64290
+ }
64291
+ async function scanDeposit(wallet) {
64292
+ const answer = await signedFetch(wallet, "POST", `${LANE}/deposit`, { scan: true });
64293
+ const body = answer.status === 429 ? answer.body ?? {} : expect(answer, "scan");
64294
+ return { scanned: body.scanned === true, credited: typeof body.credited === "number" ? body.credited : 0, balance: body.balance ?? null };
64295
+ }
64296
+ async function cancelTask(wallet, id2) {
64297
+ const answer = await signedFetch(wallet, "POST", `${BROWSER_LANE}/tasks/${encodeURIComponent(id2)}/cancel`);
64298
+ return expect(answer, "cancel").task;
64299
+ }
64300
+ async function waitForTask(wallet, id2, { maxSeconds = 900, everyMs = 5e3, onTick } = {}) {
64301
+ const until = Date.now() + maxSeconds * 1e3;
64302
+ for (; ; ) {
64303
+ const task = await readTask(wallet, id2);
64304
+ onTick?.(task);
64305
+ if (SETTLED.has(task.status) || Date.now() >= until) return task;
64306
+ await new Promise((r) => setTimeout(r, everyMs));
64307
+ }
64308
+ }
64309
+
64310
+ // src/commands/browser.ts
64311
+ var jsonMode3 = (opts) => opts.json === true || !process.stdout.isTTY;
64312
+ function emit3(opts, data4, human) {
64313
+ if (jsonMode3(opts)) {
64314
+ process.stdout.write(JSON.stringify(data4, null, 2) + "\n");
64315
+ return;
64316
+ }
64317
+ human();
64318
+ }
64319
+ function refuse3(opts, error, code, extra = {}) {
64320
+ if (jsonMode3(opts)) {
64321
+ process.stdout.write(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
64322
+ } else {
64323
+ process.stderr.write(` ${error}${code ? import_picocolors9.default.dim(` (${code})`) : ""}
64324
+ `);
64325
+ }
64326
+ process.exit(1);
64327
+ }
64328
+ function failFrom2(opts, err) {
64329
+ if (err instanceof WireError) return refuse3(opts, err.message, err.code, { status: err.status });
64330
+ return refuse3(opts, err.message ?? String(err), null);
64331
+ }
64332
+ var usd5 = (v) => {
64333
+ const n2 = Number(v);
64334
+ if (Number.isInteger(n2)) return `$${n2}`;
64335
+ const [whole, frac = ""] = n2.toFixed(6).replace(/0+$/, "").split(".");
64336
+ return `$${whole}.${frac.padEnd(2, "0")}`;
64337
+ };
64338
+ var host = (url) => {
64339
+ try {
64340
+ return new URL(url).host;
64341
+ } catch {
64342
+ return url;
64343
+ }
64344
+ };
64345
+ var when = (iso) => iso ? iso.replace("T", " ").slice(0, 16) : "";
64346
+ var STATUS_COLOR = {
64347
+ queued: import_picocolors9.default.dim,
64348
+ running: import_picocolors9.default.cyan,
64349
+ done: import_picocolors9.default.green,
64350
+ failed: import_picocolors9.default.red,
64351
+ cancelled: import_picocolors9.default.dim
64352
+ };
64353
+ var status = (s) => (STATUS_COLOR[s] ?? import_picocolors9.default.dim)(s.padEnd(9));
64354
+ function siteUrl(raw) {
64355
+ const t = raw.trim();
64356
+ return /^[a-z][a-z0-9+.-]*:\/\//i.test(t) ? t : `https://${t}`;
64357
+ }
64358
+ function printTask(t, full) {
64359
+ process.stdout.write(`
64360
+ ${status(t.status)} ${import_picocolors9.default.bold(t.id)} ${import_picocolors9.default.dim(host(t.url))} ${import_picocolors9.default.dim(`${t.stepsRun}/${t.maxSteps} steps`)}
64361
+ `);
64362
+ process.stdout.write(` ${t.goal}
64363
+ `);
64364
+ if (t.status === "done") process.stdout.write(` ${import_picocolors9.default.dim(`charged ${usd5(t.chargedUsd)}`)}
64365
+ `);
64366
+ else if (t.status === "queued" || t.status === "running") process.stdout.write(` ${import_picocolors9.default.dim(`reserved ${usd5(t.reservedUsd)}`)}
64367
+ `);
64368
+ if (t.answer) process.stdout.write(`
64369
+ ${import_picocolors9.default.bold("Answer")}
64370
+ ${t.answer.replace(/\n/g, "\n ")}
64371
+ `);
64372
+ if (t.status === "failed" && t.error) process.stdout.write(`
64373
+ ${import_picocolors9.default.red(t.error)}${t.code ? import_picocolors9.default.dim(` (${t.code})`) : ""}
64374
+ `);
64375
+ if (t.reached) process.stdout.write(` ${import_picocolors9.default.dim("reached:")} ${t.reached}
64376
+ `);
64377
+ if (t.wall) process.stdout.write(` ${import_picocolors9.default.dim("stopped by:")} ${t.wall}
64378
+ `);
64379
+ if (t.finalUrl) process.stdout.write(` ${import_picocolors9.default.dim("ended on:")} ${t.finalUrl}
64380
+ `);
64381
+ if (full && t.findings?.length) {
64382
+ process.stdout.write(`
64383
+ ${import_picocolors9.default.bold("Notes")}
64384
+ `);
64385
+ for (const f2 of t.findings) process.stdout.write(` - ${String(f2)}
64386
+ `);
64387
+ }
64388
+ if (full && t.transcript?.length) {
64389
+ process.stdout.write(`
64390
+ ${import_picocolors9.default.bold("What it did")}
64391
+ `);
64392
+ for (const s of t.transcript) process.stdout.write(` ${import_picocolors9.default.dim(s.line)}
64393
+ `);
64394
+ }
64395
+ process.stdout.write("\n");
64396
+ }
64397
+ async function browserPricing(opts) {
64398
+ try {
64399
+ const { product, usage, networks } = await readBrowserCatalog();
64400
+ emit3(opts, { ok: true, product, usage, networks }, () => {
64401
+ process.stdout.write(`
64402
+ ${import_picocolors9.default.bold("BROWSER")} ${import_picocolors9.default.dim(product?.brief ?? "a site and a task in words; it browses, then answers")}
64403
+
64404
+ `);
64405
+ if (!product || product.available === false) {
64406
+ process.stdout.write(` ${import_picocolors9.default.dim(product?.note ?? "the browser is not on sale right now")}
64407
+
64408
+ `);
64409
+ return;
64410
+ }
64411
+ if (usage?.stepUsd) process.stdout.write(` ${import_picocolors9.default.cyan(usd5(usage.stepUsd))} ${import_picocolors9.default.dim("a step, from the prepaid balance")}
64412
+ `);
64413
+ if (usage) {
64414
+ process.stdout.write(` ${import_picocolors9.default.dim(`steps 1 to ${usage.maxSteps} (default ${usage.defaultSteps}) \xB7 ${usage.minSeconds} to ${usage.maxSeconds} seconds \xB7 up to ${usage.maxHosts} extra hosts`)}
64415
+ `);
64416
+ process.stdout.write(` ${import_picocolors9.default.dim(usage.note)}
64417
+ `);
64418
+ }
64419
+ if (networks.length) process.stdout.write(`
64420
+ ${import_picocolors9.default.dim(`balance top-ups in USDC on ${networks.join(", ")}`)}
64421
+ `);
64422
+ process.stdout.write("\n");
64423
+ });
64424
+ } catch (err) {
64425
+ failFrom2(opts, err);
64426
+ }
64427
+ }
64428
+ async function browserBalance(opts) {
64429
+ try {
64430
+ const keys = await requirePasswordsKey();
64431
+ let balance2 = await readIdentityBalance(keys.wallet);
64432
+ const { deposit, dark } = await readDepositAddress(keys.wallet);
64433
+ let scan = null;
64434
+ if (opts.scan && deposit) {
64435
+ const out = await scanDeposit(keys.wallet);
64436
+ scan = { scanned: out.scanned, credited: out.credited };
64437
+ if (out.credited > 0) balance2 = await readIdentityBalance(keys.wallet);
64438
+ }
64439
+ emit3(opts, { ok: true, wallet: keys.wallet.address, balance: balance2.balance, rungsUsd: balance2.rungsUsd, deposit, ...dark ? { depositDark: dark } : {}, ...scan ? { scan } : {} }, () => {
64440
+ process.stdout.write(`
64441
+ ${import_picocolors9.default.bold("BALANCE")} ${import_picocolors9.default.dim(keys.wallet.address)}
64442
+
64443
+ `);
64444
+ if (balance2.balance) {
64445
+ process.stdout.write(` ${import_picocolors9.default.cyan(usd5(balance2.balance.availableUsd))} ${import_picocolors9.default.dim("available")}`);
64446
+ if (Number(balance2.balance.reservedUsd) > 0) process.stdout.write(import_picocolors9.default.dim(` \xB7 ${usd5(balance2.balance.reservedUsd)} reserved by tasks in flight`));
64447
+ process.stdout.write("\n");
64448
+ } else {
64449
+ process.stdout.write(` ${import_picocolors9.default.dim("no balance under this key yet; a top-up opens it")}
64450
+ `);
64451
+ }
64452
+ if (scan) process.stdout.write(` ${import_picocolors9.default.dim(scan.scanned ? `scanned now: ${scan.credited} arrival${scan.credited === 1 ? "" : "s"} credited` : "scanned moments ago; ask again in a few seconds")}
64453
+ `);
64454
+ process.stdout.write("\n");
64455
+ if (deposit) {
64456
+ const names2 = deposit.chains.map((c) => c.network).join(" or ");
64457
+ process.stdout.write(` ${import_picocolors9.default.bold("TOP UP")} ${import_picocolors9.default.dim(`send USDC on ${names2} to your own address`)}
64458
+ `);
64459
+ process.stdout.write(` ${import_picocolors9.default.cyan(deposit.address)}
64460
+ `);
64461
+ process.stdout.write(` ${import_picocolors9.default.dim(`credited after ${deposit.minConfirmations} confirmations; agentgates browser balance --scan credits a fresh arrival now`)}
64462
+ `);
64463
+ } else {
64464
+ process.stdout.write(` ${import_picocolors9.default.dim(dark ?? "deposit addresses are not open yet")}
64465
+ `);
64466
+ if (balance2.rungsUsd.length) process.stdout.write(` ${import_picocolors9.default.dim(`top up over x402: POST /api/identity/credits with {"amountUsd": ${balance2.rungsUsd[0]}} from a wallet that holds USDC`)}
64467
+ `);
64468
+ }
64469
+ process.stdout.write("\n");
64470
+ });
64471
+ } catch (err) {
64472
+ failFrom2(opts, err);
64473
+ }
64474
+ }
64475
+ async function browserRun(url, opts) {
64476
+ const goal = (opts.task ?? "").trim();
64477
+ if (!goal) return refuse3(opts, 'say what the browser agent should do: --task "<words>"', "bad_request");
64478
+ const maxSteps = opts.steps !== void 0 ? Number(opts.steps) : void 0;
64479
+ if (maxSteps !== void 0 && !Number.isInteger(maxSteps)) return refuse3(opts, "--steps must be a whole number", "bad_request");
64480
+ const maxSeconds = opts.seconds !== void 0 ? Number(opts.seconds) : void 0;
64481
+ if (maxSeconds !== void 0 && !Number.isInteger(maxSeconds)) return refuse3(opts, "--seconds must be a whole number", "bad_request");
64482
+ try {
64483
+ const keys = await requirePasswordsKey();
64484
+ const task = await postTask(keys.wallet, { url: siteUrl(url), goal, hosts: opts.host, maxSteps, maxSeconds });
64485
+ if (!opts.wait) {
64486
+ emit3(opts, { ok: true, task }, () => {
64487
+ printTask(task, false);
64488
+ process.stdout.write(` ${import_picocolors9.default.dim(`read it back: agentgates browser task ${task.id} --wait`)}
64489
+
64490
+ `);
64491
+ });
64492
+ return;
64493
+ }
64494
+ const waitSeconds = typeof opts.wait === "string" ? Math.max(5, Number(opts.wait) || 0) : Math.max(60, task.maxSeconds + 120);
64495
+ let lastStatus = "";
64496
+ const settled = await waitForTask(keys.wallet, task.id, {
64497
+ maxSeconds: waitSeconds,
64498
+ onTick: (t) => {
64499
+ if (jsonMode3(opts) || t.status === lastStatus) return;
64500
+ lastStatus = t.status;
64501
+ process.stderr.write(` ${import_picocolors9.default.dim(`${t.status}${t.status === "running" ? ` \xB7 ${t.stepsRun} steps` : ""}`)}
64502
+ `);
64503
+ }
64504
+ });
64505
+ emit3(opts, { ok: SETTLED.has(settled.status), task: settled }, () => {
64506
+ printTask(settled, true);
64507
+ if (!SETTLED.has(settled.status)) process.stdout.write(` ${import_picocolors9.default.dim(`still ${settled.status}; read it later: agentgates browser task ${settled.id} --wait`)}
64508
+
64509
+ `);
64510
+ });
64511
+ if (settled.status === "failed") process.exitCode = 1;
64512
+ } catch (err) {
64513
+ failFrom2(opts, err);
64514
+ }
64515
+ }
64516
+ async function browserTasks(opts) {
64517
+ try {
64518
+ const keys = await requirePasswordsKey();
64519
+ const tasks = await listTasks(keys.wallet);
64520
+ emit3(opts, { ok: true, wallet: keys.wallet.address, tasks }, () => {
64521
+ process.stdout.write(`
64522
+ ${import_picocolors9.default.bold("YOUR TASKS")} ${import_picocolors9.default.dim(keys.wallet.address)}
64523
+
64524
+ `);
64525
+ if (tasks.length === 0) {
64526
+ process.stdout.write(` ${import_picocolors9.default.dim('none yet: agentgates browser run <url> --task "\u2026"')}
64527
+
64528
+ `);
64529
+ return;
64530
+ }
64531
+ for (const t of tasks) {
64532
+ const money = t.status === "done" ? usd5(t.chargedUsd) : t.status === "queued" || t.status === "running" ? `${usd5(t.reservedUsd)} reserved` : "";
64533
+ process.stdout.write(` ${status(t.status)} ${t.id} ${import_picocolors9.default.dim(host(t.url).padEnd(24))} ${import_picocolors9.default.dim(`${t.stepsRun}/${t.maxSteps}`.padStart(6))} ${import_picocolors9.default.dim(money.padEnd(16))} ${import_picocolors9.default.dim(when(t.createdAt))}
64534
+ `);
64535
+ process.stdout.write(` ${t.goal.length > 90 ? `${t.goal.slice(0, 89)}\u2026` : t.goal}
64536
+ `);
64537
+ }
64538
+ process.stdout.write("\n");
64539
+ });
64540
+ } catch (err) {
64541
+ failFrom2(opts, err);
64542
+ }
64543
+ }
64544
+ async function browserTask(id2, opts) {
64545
+ try {
64546
+ const keys = await requirePasswordsKey();
64547
+ if (opts.cancel) {
64548
+ const task2 = await cancelTask(keys.wallet, id2);
64549
+ emit3(opts, { ok: true, task: task2 }, () => printTask(task2, false));
64550
+ return;
64551
+ }
64552
+ const task = opts.wait ? await waitForTask(keys.wallet, id2, {
64553
+ maxSeconds: typeof opts.wait === "string" ? Math.max(5, Number(opts.wait) || 0) : 900,
64554
+ onTick: (t) => {
64555
+ if (!jsonMode3(opts) && !SETTLED.has(t.status)) process.stderr.write(` ${import_picocolors9.default.dim(`${t.status} \xB7 ${t.stepsRun} steps`)}
64556
+ `);
64557
+ }
64558
+ }) : await readTask(keys.wallet, id2);
64559
+ emit3(opts, { ok: true, task }, () => printTask(task, true));
64560
+ } catch (err) {
64561
+ failFrom2(opts, err);
64562
+ }
64563
+ }
64564
+
63940
64565
  // src/commands/onboard.ts
63941
64566
  var WORDMARK = [
63942
64567
  " _ _",
@@ -63967,7 +64592,7 @@ async function staleLine() {
63967
64592
  if (!res.ok) return null;
63968
64593
  const { version: latest } = await res.json();
63969
64594
  if (!latest || !olderThan(LOCAL_VERSION, latest)) return null;
63970
- return ` ${import_picocolors8.default.yellow("\u2191")} ${latest} is out, this copy is ${LOCAL_VERSION} \xB7 curl -fsSL ${CREATORS_ORIGIN}/api/cli/install | sh
64595
+ return ` ${import_picocolors10.default.yellow("\u2191")} ${latest} is out, this copy is ${LOCAL_VERSION} \xB7 curl -fsSL ${CREATORS_ORIGIN}/api/cli/install | sh
63971
64596
 
63972
64597
  `;
63973
64598
  } catch {
@@ -63982,14 +64607,17 @@ function makePut(w) {
63982
64607
  }
63983
64608
  function banner() {
63984
64609
  const w = water();
63985
- if (!w) process.stdout.write("\n" + import_picocolors8.default.cyan(WORDMARK) + "\n\n");
64610
+ if (!w) process.stdout.write("\n" + import_picocolors10.default.cyan(WORDMARK) + "\n\n");
63986
64611
  const put = makePut(w);
63987
- put(` ${import_picocolors8.default.dim(TAGLINE)}
64612
+ put(` ${import_picocolors10.default.dim(TAGLINE)}
63988
64613
 
63989
64614
  `);
63990
64615
  return { w, put };
63991
64616
  }
63992
64617
  var MENU = {
64618
+ account: { label: "log in: mint my twelve words, or show my account", hint: "(agentgates init)" },
64619
+ seed: { label: "show my twelve words", hint: "(agentgates init --reveal-seed)" },
64620
+ balance: { label: "my balance and the address that tops it up", hint: "(agentgates browser balance)" },
63993
64621
  compute: { label: "see virtual machine pricing" },
63994
64622
  models: { label: "see inference pricing" },
63995
64623
  phone: { label: "see phone pricing" },
@@ -64014,16 +64642,17 @@ function lanesLedBy(lane) {
64014
64642
  const lead = leadLane(lane);
64015
64643
  return [lead, ...LANE_ORDER.filter((l) => l !== lead)];
64016
64644
  }
64017
- function menuOrder(lane) {
64645
+ function menuOrder(lane, hasAccount) {
64018
64646
  const browse = lanesLedBy(lane).map((l) => LANES[l].key);
64019
- return [...browse, "docs", "poke", "wallet"];
64647
+ const account = hasAccount ? ["account", "seed", "balance"] : ["account"];
64648
+ return [...account, ...browse, "docs", "poke", "wallet"];
64020
64649
  }
64021
64650
  function printMenu(put, order, first) {
64022
- put(` ${import_picocolors8.default.bold(first ? "choose how to start:" : "what next:")}
64651
+ put(` ${import_picocolors10.default.bold(first ? "choose how to start:" : "what next:")}
64023
64652
  `);
64024
64653
  order.forEach((k, i) => {
64025
64654
  const item = MENU[k];
64026
- put(` ${import_picocolors8.default.cyan(`${i + 1}.`)} ${item.label}${item.hint ? ` ${import_picocolors8.default.dim(item.hint)}` : ""}
64655
+ put(` ${import_picocolors10.default.cyan(`${i + 1}.`)} ${item.label}${item.hint ? ` ${import_picocolors10.default.dim(item.hint)}` : ""}
64027
64656
  `);
64028
64657
  });
64029
64658
  }
@@ -64035,17 +64664,17 @@ async function printDocs(put, lane) {
64035
64664
  if (!res.ok) throw new Error(String(res.status));
64036
64665
  const md = (await res.text()).replace(/\s+$/, "");
64037
64666
  put(`
64038
- ${import_picocolors8.default.bold(`THE ${LANES[lead].name.toUpperCase()} CONTRACT`)} ${import_picocolors8.default.dim(url(lead))}
64667
+ ${import_picocolors10.default.bold(`THE ${LANES[lead].name.toUpperCase()} CONTRACT`)} ${import_picocolors10.default.dim(url(lead))}
64039
64668
 
64040
64669
  `);
64041
64670
  put(md + "\n\n");
64042
- for (const other of others) put(` ${import_picocolors8.default.dim(`the ${LANES[other].name} contract:`)} ${url(other)}
64671
+ for (const other of others) put(` ${import_picocolors10.default.dim(`the ${LANES[other].name} contract:`)} ${url(other)}
64043
64672
  `);
64044
64673
  put("\n");
64045
64674
  } catch {
64046
- put(` ${import_picocolors8.default.red("\u2715")} could not fetch the contract; the URLs:
64675
+ put(` ${import_picocolors10.default.red("\u2715")} could not fetch the contract; the URLs:
64047
64676
  `);
64048
- for (const l of LANE_ORDER) put(` ${import_picocolors8.default.cyan(LANES[l].name.padEnd(16))} ${url(l)}
64677
+ for (const l of LANE_ORDER) put(` ${import_picocolors10.default.cyan(LANES[l].name.padEnd(16))} ${url(l)}
64049
64678
  `);
64050
64679
  put("\n");
64051
64680
  }
@@ -64055,7 +64684,16 @@ async function onboard(opts = {}) {
64055
64684
  const { w, put } = banner();
64056
64685
  const existing = await loadProfile(profileName).catch(() => null);
64057
64686
  if (existing) {
64058
- put(` ${import_picocolors8.default.green("\u2713")} already paired as ${import_picocolors8.default.bold(existing.walletAddress ?? existing.userId)}
64687
+ put(` ${import_picocolors10.default.green("\u2713")} already paired as ${import_picocolors10.default.bold(existing.walletAddress ?? existing.userId)}
64688
+ `);
64689
+ }
64690
+ const account = await loadPasswordsKey().catch(() => null);
64691
+ 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)")}
64693
+
64694
+ `);
64695
+ } else {
64696
+ put(` ${import_picocolors10.default.dim("no account on this machine yet: option 1 mints your twelve words")}
64059
64697
 
64060
64698
  `);
64061
64699
  }
@@ -64063,33 +64701,39 @@ async function onboard(opts = {}) {
64063
64701
  put(` No terminal attached, so no menu. The machine door:
64064
64702
 
64065
64703
  `);
64066
- put(` agentgates compute plans --json ${import_picocolors8.default.dim("\xB7 virtual machine pricing, JSON")}
64704
+ put(` agentgates compute plans --json ${import_picocolors10.default.dim("\xB7 virtual machine pricing, JSON")}
64067
64705
  `);
64068
- put(` agentgates inference models --json ${import_picocolors8.default.dim("\xB7 model pricing, JSON; --tier --tag --org --search filter it")}
64706
+ put(` agentgates inference models --json ${import_picocolors10.default.dim("\xB7 model pricing, JSON; --tier --tag --org --search filter it")}
64069
64707
  `);
64070
- put(` agentgates phone pricing --json ${import_picocolors8.default.dim("\xB7 number plans, usage and payphone windows, JSON")}
64708
+ put(` agentgates phone pricing --json ${import_picocolors10.default.dim("\xB7 number plans, usage and payphone windows, JSON")}
64071
64709
  `);
64072
- put(` agentgates email pricing --json ${import_picocolors8.default.dim("\xB7 the free inbox, plans and per-send price, JSON")}
64710
+ put(` agentgates email pricing --json ${import_picocolors10.default.dim("\xB7 the free inbox, plans and per-send price, JSON")}
64073
64711
  `);
64074
- put(` agentgates passwords pricing --json ${import_picocolors8.default.dim("\xB7 plans and per-use meter")}
64712
+ put(` agentgates passwords pricing --json ${import_picocolors10.default.dim("\xB7 plans and per-use meter")}
64075
64713
  `);
64076
- put(` agentgates passwords init ${import_picocolors8.default.dim("\xB7 mint your own key; then add, allow, use, invite. No human needed")}
64714
+ put(` agentgates init ${import_picocolors10.default.dim("\xB7 mint your twelve words: your account, printed once with what to tell your human")}
64077
64715
  `);
64078
- put(` ${CREATORS_ORIGIN}/api/compute/docs ${import_picocolors8.default.dim("\xB7 the buy/read/renew/destroy contract")}
64716
+ put(` agentgates init --reveal-seed ${import_picocolors10.default.dim("\xB7 print them again")}
64079
64717
  `);
64080
- put(` ${CREATORS_ORIGIN}/api/inference/docs ${import_picocolors8.default.dim("\xB7 the chat contract, x402 or Bearer")}
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)")}
64081
64719
  `);
64082
- put(` ${CREATORS_ORIGIN}/api/identity/docs/phone ${import_picocolors8.default.dim("\xB7 the phone contract: numbers, texts, calls, the payphone")}
64720
+ put(` agentgates open ${import_picocolors10.default.dim("\xB7 hand this session to a human's browser on this machine")}
64083
64721
  `);
64084
- put(` ${CREATORS_ORIGIN}/api/identity/docs/email ${import_picocolors8.default.dim("\xB7 the email contract: inboxes, plans, sends, wait-code")}
64722
+ put(` ${CREATORS_ORIGIN}/api/compute/docs ${import_picocolors10.default.dim("\xB7 the buy/read/renew/destroy contract")}
64085
64723
  `);
64086
- put(` ${CREATORS_ORIGIN}/api/identity/docs/passwords ${import_picocolors8.default.dim("\xB7 the passwords contract: store, permits, uses")}
64724
+ put(` ${CREATORS_ORIGIN}/api/inference/docs ${import_picocolors10.default.dim("\xB7 the chat contract, x402 or Bearer")}
64087
64725
  `);
64088
- put(` ${CREATORS_ORIGIN}/llms.txt ${import_picocolors8.default.dim("\xB7 the whole surface")}
64726
+ put(` ${CREATORS_ORIGIN}/api/identity/docs/phone ${import_picocolors10.default.dim("\xB7 the phone contract: numbers, texts, calls, the payphone")}
64727
+ `);
64728
+ put(` ${CREATORS_ORIGIN}/api/identity/docs/email ${import_picocolors10.default.dim("\xB7 the email contract: inboxes, plans, sends, wait-code")}
64729
+ `);
64730
+ put(` ${CREATORS_ORIGIN}/api/identity/docs/passwords ${import_picocolors10.default.dim("\xB7 the passwords contract: store, permits, uses")}
64731
+ `);
64732
+ put(` ${CREATORS_ORIGIN}/llms.txt ${import_picocolors10.default.dim("\xB7 the whole surface")}
64089
64733
 
64090
64734
  `);
64091
64735
  if (!existing) {
64092
- put(` Pairing a wallet needs a human at a browser: ${import_picocolors8.default.bold("agentgates onboard")} in a real terminal.
64736
+ put(` Pairing a wallet needs a human at a browser: ${import_picocolors10.default.bold("agentgates onboard")} in a real terminal.
64093
64737
 
64094
64738
  `);
64095
64739
  }
@@ -64099,7 +64743,7 @@ async function onboard(opts = {}) {
64099
64743
  }
64100
64744
  const stale = await staleLine();
64101
64745
  if (stale) put(stale);
64102
- const order = menuOrder(opts.lane).filter((k) => existing ? k !== "wallet" : true);
64746
+ const order = menuOrder(opts.lane, !!account).filter((k) => existing ? k !== "wallet" : true);
64103
64747
  printMenu(put, order, true);
64104
64748
  const rl = createInterface({ input: process.stdin, output: process.stdout });
64105
64749
  const exitDefault = String(order.indexOf("poke") + 1);
@@ -64110,7 +64754,7 @@ async function onboard(opts = {}) {
64110
64754
  const fallback = first ? "1" : exitDefault;
64111
64755
  let choice;
64112
64756
  try {
64113
- choice = (await rl.question(` ${import_picocolors8.default.dim(`choice [${fallback}]:`)} `)).trim() || fallback;
64757
+ choice = (await rl.question(` ${import_picocolors10.default.dim(`choice [${fallback}]:`)} `)).trim() || fallback;
64114
64758
  } catch {
64115
64759
  if (first) w?.stop();
64116
64760
  process.stdout.write("\n");
@@ -64134,7 +64778,34 @@ async function onboard(opts = {}) {
64134
64778
  await runLoginFlow({ profile: profileName, jsonMode: false, ttyHeader: "Pairing this terminal with your wallet\u2026" });
64135
64779
  process.stdout.write("\n");
64136
64780
  } catch {
64137
- plain(` ${import_picocolors8.default.red("\u2715")} pairing didn't complete
64781
+ plain(` ${import_picocolors10.default.red("\u2715")} pairing didn't complete
64782
+
64783
+ `);
64784
+ }
64785
+ break;
64786
+ case "account":
64787
+ try {
64788
+ await passwordsInit({});
64789
+ } catch {
64790
+ plain(` ${import_picocolors10.default.red("\u2715")} the account could not be read or minted
64791
+
64792
+ `);
64793
+ }
64794
+ break;
64795
+ case "seed":
64796
+ try {
64797
+ await passwordsInit({ revealSeed: true });
64798
+ } catch {
64799
+ plain(` ${import_picocolors10.default.red("\u2715")} the words could not be read
64800
+
64801
+ `);
64802
+ }
64803
+ break;
64804
+ case "balance":
64805
+ try {
64806
+ await browserBalance({});
64807
+ } catch {
64808
+ plain(` ${import_picocolors10.default.red("\u2715")} the balance could not be read
64138
64809
 
64139
64810
  `);
64140
64811
  }
@@ -64143,7 +64814,7 @@ async function onboard(opts = {}) {
64143
64814
  try {
64144
64815
  await computePlans({});
64145
64816
  } catch {
64146
- plain(` ${import_picocolors8.default.red("\u2715")} could not read the compute catalog
64817
+ plain(` ${import_picocolors10.default.red("\u2715")} could not read the compute catalog
64147
64818
 
64148
64819
  `);
64149
64820
  }
@@ -64152,7 +64823,7 @@ async function onboard(opts = {}) {
64152
64823
  try {
64153
64824
  await inferenceModels({});
64154
64825
  } catch {
64155
- plain(` ${import_picocolors8.default.red("\u2715")} could not read the model catalog
64826
+ plain(` ${import_picocolors10.default.red("\u2715")} could not read the model catalog
64156
64827
 
64157
64828
  `);
64158
64829
  }
@@ -64161,7 +64832,7 @@ async function onboard(opts = {}) {
64161
64832
  try {
64162
64833
  await phonePricing({});
64163
64834
  } catch {
64164
- plain(` ${import_picocolors8.default.red("\u2715")} could not read the phone catalog
64835
+ plain(` ${import_picocolors10.default.red("\u2715")} could not read the phone catalog
64165
64836
 
64166
64837
  `);
64167
64838
  }
@@ -64170,7 +64841,7 @@ async function onboard(opts = {}) {
64170
64841
  try {
64171
64842
  await emailPricing({});
64172
64843
  } catch {
64173
- plain(` ${import_picocolors8.default.red("\u2715")} could not read the email catalog
64844
+ plain(` ${import_picocolors10.default.red("\u2715")} could not read the email catalog
64174
64845
 
64175
64846
  `);
64176
64847
  }
@@ -64179,7 +64850,7 @@ async function onboard(opts = {}) {
64179
64850
  try {
64180
64851
  await passwordsPricing({});
64181
64852
  } catch {
64182
- plain(` ${import_picocolors8.default.red("\u2715")} could not read the passwords catalog
64853
+ plain(` ${import_picocolors10.default.red("\u2715")} could not read the passwords catalog
64183
64854
 
64184
64855
  `);
64185
64856
  }
@@ -64195,32 +64866,36 @@ async function onboard(opts = {}) {
64195
64866
  }
64196
64867
  }
64197
64868
  function printNext(put) {
64198
- put(` ${import_picocolors8.default.dim("agentgates compute plans")} ${import_picocolors8.default.dim("\xB7 virtual machines by the hour")}
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")}
64870
+ `);
64871
+ put(` ${import_picocolors10.default.dim("agentgates browser balance")} ${import_picocolors10.default.dim("\xB7 your balance and the address that tops it up")}
64199
64872
  `);
64200
- put(` ${import_picocolors8.default.dim("agentgates inference models")} ${import_picocolors8.default.dim("\xB7 models by the token")}
64873
+ put(` ${import_picocolors10.default.dim("agentgates compute plans")} ${import_picocolors10.default.dim("\xB7 virtual machines by the hour")}
64201
64874
  `);
64202
- put(` ${import_picocolors8.default.dim("agentgates phone pricing")} ${import_picocolors8.default.dim("\xB7 numbers by the month, calls by the minute")}
64875
+ put(` ${import_picocolors10.default.dim("agentgates inference models")} ${import_picocolors10.default.dim("\xB7 models by the token")}
64203
64876
  `);
64204
- put(` ${import_picocolors8.default.dim("agentgates email pricing")} ${import_picocolors8.default.dim("\xB7 inboxes free on a balance, sends per message")}
64877
+ put(` ${import_picocolors10.default.dim("agentgates phone pricing")} ${import_picocolors10.default.dim("\xB7 numbers by the month, calls by the minute")}
64205
64878
  `);
64206
- put(` ${import_picocolors8.default.dim("agentgates passwords pricing")} ${import_picocolors8.default.dim("\xB7 logins an agent uses and never sees")}
64879
+ put(` ${import_picocolors10.default.dim("agentgates email pricing")} ${import_picocolors10.default.dim("\xB7 inboxes free on a balance, sends per message")}
64207
64880
  `);
64208
- put(` ${import_picocolors8.default.dim("agentgates --help")} ${import_picocolors8.default.dim("\xB7 everything else")}
64881
+ put(` ${import_picocolors10.default.dim("agentgates passwords pricing")} ${import_picocolors10.default.dim("\xB7 logins an agent uses and never sees")}
64882
+ `);
64883
+ put(` ${import_picocolors10.default.dim("agentgates --help")} ${import_picocolors10.default.dim("\xB7 everything else")}
64209
64884
 
64210
64885
  `);
64211
64886
  }
64212
64887
 
64213
64888
  // src/commands/logout.ts
64214
- var import_picocolors9 = __toESM(require_picocolors(), 1);
64889
+ var import_picocolors11 = __toESM(require_picocolors(), 1);
64215
64890
  async function logout(opts) {
64216
64891
  const requested = opts.profile ?? DEFAULT_PROFILE;
64217
64892
  const resolved = await resolveProfile(requested);
64218
64893
  if (!resolved) {
64219
- process.stdout.write(import_picocolors9.default.dim("Not logged in \u2014 nothing to log out.\n"));
64894
+ process.stdout.write(import_picocolors11.default.dim("Not logged in \u2014 nothing to log out.\n"));
64220
64895
  return;
64221
64896
  }
64222
64897
  if (resolved.autoSelected) {
64223
- process.stderr.write(import_picocolors9.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
64898
+ process.stderr.write(import_picocolors11.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
64224
64899
  `));
64225
64900
  }
64226
64901
  const { profile, name: profileName } = resolved;
@@ -64245,15 +64920,15 @@ async function logout(opts) {
64245
64920
  const removed = await deleteProfile(profileName);
64246
64921
  if (removed) {
64247
64922
  process.stdout.write(
64248
- import_picocolors9.default.green(`\u2713 Logged out of profile ${import_picocolors9.default.bold(profileName)}.
64923
+ import_picocolors11.default.green(`\u2713 Logged out of profile ${import_picocolors11.default.bold(profileName)}.
64249
64924
  `)
64250
64925
  );
64251
64926
  }
64252
64927
  if (serverError) {
64253
64928
  process.stderr.write(
64254
- import_picocolors9.default.yellow(
64929
+ import_picocolors11.default.yellow(
64255
64930
  `\u26A0 Couldn't revoke server-side: ${serverError}
64256
- The local bearer is wiped. If the server still has it, revoke from ${import_picocolors9.default.bold("agentgates.ai/settings/pairings")}.
64931
+ The local bearer is wiped. If the server still has it, revoke from ${import_picocolors11.default.bold("agentgates.ai/settings/pairings")}.
64257
64932
  `
64258
64933
  )
64259
64934
  );
@@ -64261,49 +64936,49 @@ async function logout(opts) {
64261
64936
  }
64262
64937
 
64263
64938
  // src/commands/whoami.ts
64264
- var import_picocolors10 = __toESM(require_picocolors(), 1);
64939
+ var import_picocolors12 = __toESM(require_picocolors(), 1);
64265
64940
  async function whoami(opts) {
64266
64941
  const requested = opts.profile ?? DEFAULT_PROFILE;
64267
64942
  const resolved = await resolveProfile(requested);
64268
64943
  if (!resolved) {
64269
- process.stderr.write(import_picocolors10.default.red("Not logged in. Run agentgates login first.\n"));
64944
+ process.stderr.write(import_picocolors12.default.red("Not logged in. Run agentgates login first.\n"));
64270
64945
  process.exit(2);
64271
64946
  }
64272
64947
  if (resolved.autoSelected) {
64273
- process.stderr.write(import_picocolors10.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
64948
+ process.stderr.write(import_picocolors12.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
64274
64949
  `));
64275
64950
  }
64276
64951
  const { profile, name: profileName } = resolved;
64277
- const jsonMode2 = opts.json === true;
64952
+ const jsonMode4 = opts.json === true;
64278
64953
  const outcome = await callWithAutoRelogin({
64279
64954
  profile,
64280
64955
  profileName,
64281
- jsonMode: jsonMode2,
64282
- ttyHeader: import_picocolors10.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
64956
+ jsonMode: jsonMode4,
64957
+ ttyHeader: import_picocolors12.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
64283
64958
  fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
64284
64959
  });
64285
64960
  if (outcome.kind === "auth_failed") {
64286
- if (jsonMode2) {
64961
+ if (jsonMode4) {
64287
64962
  process.stdout.write(
64288
64963
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
64289
64964
  );
64290
64965
  process.exit(1);
64291
64966
  }
64292
- process.stderr.write(import_picocolors10.default.red(`\u2715 ${outcome.reason}.
64967
+ process.stderr.write(import_picocolors12.default.red(`\u2715 ${outcome.reason}.
64293
64968
  `));
64294
64969
  process.exit(1);
64295
64970
  }
64296
64971
  if (outcome.kind === "error") {
64297
64972
  const err = outcome.error;
64298
64973
  if (err instanceof ApiError) {
64299
- process.stderr.write(import_picocolors10.default.red(`\u2715 ${err.message} (HTTP ${err.status})
64974
+ process.stderr.write(import_picocolors12.default.red(`\u2715 ${err.message} (HTTP ${err.status})
64300
64975
  `));
64301
64976
  process.exit(1);
64302
64977
  }
64303
64978
  throw err;
64304
64979
  }
64305
64980
  const me = outcome.result;
64306
- if (jsonMode2) {
64981
+ if (jsonMode4) {
64307
64982
  process.stdout.write(JSON.stringify(me, null, 2) + "\n");
64308
64983
  return;
64309
64984
  }
@@ -64317,7 +64992,7 @@ async function whoami(opts) {
64317
64992
  process.stdout.write(`Solana ${me.solanaAddress}
64318
64993
  `);
64319
64994
  }
64320
- process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors10.default.dim("(none)")}
64995
+ process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors12.default.dim("(none)")}
64321
64996
  `);
64322
64997
  const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
64323
64998
  const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
@@ -64334,7 +65009,7 @@ async function whoami(opts) {
64334
65009
  `
64335
65010
  );
64336
65011
  process.stdout.write(
64337
- `Profile ${profileName === DEFAULT_PROFILE ? import_picocolors10.default.dim("(default)") : profileName}
65012
+ `Profile ${profileName === DEFAULT_PROFILE ? import_picocolors12.default.dim("(default)") : profileName}
64338
65013
  `
64339
65014
  );
64340
65015
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -64348,7 +65023,7 @@ function formatDate(iso) {
64348
65023
  }
64349
65024
 
64350
65025
  // src/commands/send.ts
64351
- var import_picocolors11 = __toESM(require_picocolors(), 1);
65026
+ var import_picocolors13 = __toESM(require_picocolors(), 1);
64352
65027
 
64353
65028
  // src/lib/status.ts
64354
65029
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
@@ -64498,20 +65173,20 @@ async function send(amount, asset, opts) {
64498
65173
  const requested = opts.profile ?? DEFAULT_PROFILE;
64499
65174
  const resolved = await resolveProfile(requested);
64500
65175
  if (!resolved) {
64501
- process.stderr.write(import_picocolors11.default.red("Not logged in. Run agentgates login first.\n"));
65176
+ process.stderr.write(import_picocolors13.default.red("Not logged in. Run agentgates login first.\n"));
64502
65177
  process.exit(2);
64503
65178
  }
64504
65179
  if (resolved.autoSelected) {
64505
- process.stderr.write(import_picocolors11.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65180
+ process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
64506
65181
  `));
64507
65182
  }
64508
65183
  const { profile, name: profileName } = resolved;
64509
65184
  const stdoutIsTty = process.stdout.isTTY === true;
64510
- const jsonMode2 = opts.json === true || !stdoutIsTty;
65185
+ const jsonMode4 = opts.json === true || !stdoutIsTty;
64511
65186
  const amountNumber = Number(amount);
64512
65187
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
64513
65188
  process.stderr.write(
64514
- import_picocolors11.default.red(`\u2715 amount must be a positive number (got ${import_picocolors11.default.bold(amount)}).
65189
+ import_picocolors13.default.red(`\u2715 amount must be a positive number (got ${import_picocolors13.default.bold(amount)}).
64515
65190
  `)
64516
65191
  );
64517
65192
  process.exit(2);
@@ -64519,23 +65194,23 @@ async function send(amount, asset, opts) {
64519
65194
  const assetNormalized = asset.toLowerCase();
64520
65195
  if (assetNormalized !== "native" && assetNormalized !== "usdc") {
64521
65196
  process.stderr.write(
64522
- import_picocolors11.default.red(
64523
- `\u2715 asset must be ${import_picocolors11.default.bold("native")} or ${import_picocolors11.default.bold("usdc")} (got ${import_picocolors11.default.bold(asset)}).
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)}).
64524
65199
  `
64525
65200
  )
64526
65201
  );
64527
65202
  process.exit(2);
64528
65203
  }
64529
65204
  if (!opts.to || opts.to.trim() === "") {
64530
- process.stderr.write(import_picocolors11.default.red(`\u2715 --to <address> is required.
65205
+ process.stderr.write(import_picocolors13.default.red(`\u2715 --to <address> is required.
64531
65206
  `));
64532
65207
  process.exit(2);
64533
65208
  }
64534
65209
  if (isSolanaChainAlias(opts.chain)) {
64535
65210
  if (EVM_ADDRESS_RE.test(opts.to)) {
64536
65211
  process.stderr.write(
64537
- import_picocolors11.default.red(
64538
- `\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors11.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
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.
64539
65214
  `
64540
65215
  )
64541
65216
  );
@@ -64543,10 +65218,10 @@ async function send(amount, asset, opts) {
64543
65218
  }
64544
65219
  if (!SOLANA_ADDRESS_RE.test(opts.to)) {
64545
65220
  process.stderr.write(
64546
- import_picocolors11.default.red(
64547
- `\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors11.default.bold(opts.to)}).
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)}).
64548
65223
  `
64549
- ) + import_picocolors11.default.dim(
65224
+ ) + import_picocolors13.default.dim(
64550
65225
  ` SNS resolution is deferred to a future server-side change;
64551
65226
  for now Solana sends require the literal pubkey.
64552
65227
  `
@@ -64557,8 +65232,8 @@ async function send(amount, asset, opts) {
64557
65232
  }
64558
65233
  if (!opts.userStated || opts.userStated.trim() === "") {
64559
65234
  process.stderr.write(
64560
- import_picocolors11.default.red(`\u2715 --user-stated <text> is required.
64561
- `) + import_picocolors11.default.dim(
65235
+ import_picocolors13.default.red(`\u2715 --user-stated <text> is required.
65236
+ `) + import_picocolors13.default.dim(
64562
65237
  ` This is the trust-gap defense: pass the verbatim user request so
64563
65238
  the approval modal can cross-check what the agent thinks the user
64564
65239
  asked for vs. the actual decoded transaction.
@@ -64576,7 +65251,7 @@ async function send(amount, asset, opts) {
64576
65251
  const n2 = Number(opts.maxUsd);
64577
65252
  if (!Number.isFinite(n2) || n2 <= 0) {
64578
65253
  process.stderr.write(
64579
- import_picocolors11.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
65254
+ import_picocolors13.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
64580
65255
  `)
64581
65256
  );
64582
65257
  process.exit(2);
@@ -64616,12 +65291,12 @@ async function send(amount, asset, opts) {
64616
65291
  try {
64617
65292
  activeProfile = await runLoginFlow({
64618
65293
  profile: profileName,
64619
- jsonMode: jsonMode2,
65294
+ jsonMode: jsonMode4,
64620
65295
  origin: activeProfile.mcpOrigin,
64621
- ttyHeader: import_picocolors11.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
65296
+ ttyHeader: import_picocolors13.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
64622
65297
  });
64623
65298
  } catch (reloginErr) {
64624
- if (jsonMode2) {
65299
+ if (jsonMode4) {
64625
65300
  emitNdjson({
64626
65301
  ok: false,
64627
65302
  status: "auth_failed",
@@ -64630,7 +65305,7 @@ async function send(amount, asset, opts) {
64630
65305
  process.exit(1);
64631
65306
  }
64632
65307
  process.stderr.write(
64633
- import_picocolors11.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65308
+ import_picocolors13.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
64634
65309
  `)
64635
65310
  );
64636
65311
  process.exit(1);
@@ -64644,7 +65319,7 @@ async function send(amount, asset, opts) {
64644
65319
  });
64645
65320
  } catch (retryErr) {
64646
65321
  if (retryErr instanceof ApiError) {
64647
- if (jsonMode2) {
65322
+ if (jsonMode4) {
64648
65323
  emitNdjson({
64649
65324
  ok: false,
64650
65325
  status: retryErr.status === 401 ? "auth_failed" : "propose_failed",
@@ -64654,7 +65329,7 @@ async function send(amount, asset, opts) {
64654
65329
  process.exit(1);
64655
65330
  }
64656
65331
  process.stderr.write(
64657
- import_picocolors11.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
65332
+ import_picocolors13.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
64658
65333
  `)
64659
65334
  );
64660
65335
  process.exit(1);
@@ -64662,7 +65337,7 @@ async function send(amount, asset, opts) {
64662
65337
  throw retryErr;
64663
65338
  }
64664
65339
  } else if (err instanceof ApiError) {
64665
- if (jsonMode2) {
65340
+ if (jsonMode4) {
64666
65341
  emitNdjson({
64667
65342
  ok: false,
64668
65343
  status: "propose_failed",
@@ -64671,7 +65346,7 @@ async function send(amount, asset, opts) {
64671
65346
  });
64672
65347
  process.exit(1);
64673
65348
  }
64674
- process.stderr.write(import_picocolors11.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65349
+ process.stderr.write(import_picocolors13.default.red(`\u2715 ${err.message} (HTTP ${err.status})
64675
65350
  `));
64676
65351
  process.exit(1);
64677
65352
  } else {
@@ -64679,7 +65354,7 @@ async function send(amount, asset, opts) {
64679
65354
  }
64680
65355
  }
64681
65356
  if (isBlocked(proposed)) {
64682
- if (jsonMode2) {
65357
+ if (jsonMode4) {
64683
65358
  const envelope = {
64684
65359
  ok: false,
64685
65360
  status: "blocked",
@@ -64697,17 +65372,17 @@ async function send(amount, asset, opts) {
64697
65372
  if (proposed.detail) {
64698
65373
  const d = proposed.detail;
64699
65374
  process.stderr.write(
64700
- import_picocolors11.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
65375
+ import_picocolors13.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
64701
65376
  `
64702
65377
  );
64703
65378
  } else {
64704
- process.stderr.write(import_picocolors11.default.red(`\u2715 ${proposed.reason}
65379
+ process.stderr.write(import_picocolors13.default.red(`\u2715 ${proposed.reason}
64705
65380
  `));
64706
65381
  }
64707
65382
  if (proposed.upgrade_url) {
64708
65383
  process.stderr.write(
64709
65384
  ` Open this to grant access, then re-run the command:
64710
- ${import_picocolors11.default.cyan(proposed.upgrade_url)}
65385
+ ${import_picocolors13.default.cyan(proposed.upgrade_url)}
64711
65386
  `
64712
65387
  );
64713
65388
  }
@@ -64717,21 +65392,21 @@ async function send(amount, asset, opts) {
64717
65392
  const a = proposed.recommended_actions[i];
64718
65393
  process.stderr.write(` ${i + 1}. ${a.label}
64719
65394
  `);
64720
- if (a.reasoning) process.stderr.write(import_picocolors11.default.dim(` ${a.reasoning}
65395
+ if (a.reasoning) process.stderr.write(import_picocolors13.default.dim(` ${a.reasoning}
64721
65396
  `));
64722
65397
  if (a.action_intent && a.action_intent.external_url) {
64723
65398
  process.stderr.write(
64724
- ` ${import_picocolors11.default.cyan(a.action_intent.external_url)}
65399
+ ` ${import_picocolors13.default.cyan(a.action_intent.external_url)}
64725
65400
  `
64726
65401
  );
64727
65402
  }
64728
65403
  }
64729
65404
  }
64730
65405
  if (proposed.suggestions && proposed.suggestions.length > 0) {
64731
- process.stderr.write(import_picocolors11.default.dim("\n Other ways to fund:\n"));
65406
+ process.stderr.write(import_picocolors13.default.dim("\n Other ways to fund:\n"));
64732
65407
  for (const s of proposed.suggestions) {
64733
65408
  if (s.kind === "ask_user") continue;
64734
- process.stderr.write(import_picocolors11.default.dim(` \u2022 ${s.label}
65409
+ process.stderr.write(import_picocolors13.default.dim(` \u2022 ${s.label}
64735
65410
  `));
64736
65411
  }
64737
65412
  }
@@ -64743,7 +65418,7 @@ async function send(amount, asset, opts) {
64743
65418
  if (process.env.CI === "1" || process.env.CI === "true") return false;
64744
65419
  return true;
64745
65420
  })();
64746
- if (jsonMode2) {
65421
+ if (jsonMode4) {
64747
65422
  emitNdjson({
64748
65423
  ok: true,
64749
65424
  status: "proposed",
@@ -64758,8 +65433,8 @@ async function send(amount, asset, opts) {
64758
65433
  } else {
64759
65434
  process.stdout.write(
64760
65435
  `
64761
- ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with biometric:
64762
- ${import_picocolors11.default.cyan(proposed.approval_url)}
65436
+ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with biometric:
65437
+ ${import_picocolors13.default.cyan(proposed.approval_url)}
64763
65438
 
64764
65439
  `
64765
65440
  );
@@ -64775,10 +65450,10 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
64775
65450
  intervalMs: POLL_INTERVAL_MS,
64776
65451
  giveUpMs: POLL_GIVEUP_MS,
64777
65452
  onTick: (s) => {
64778
- if (jsonMode2) {
65453
+ if (jsonMode4) {
64779
65454
  emitNdjson({ status: s.status, intent_id: s.approval_id });
64780
65455
  } else {
64781
- process.stdout.write(` ${describeStatus(s.status)}${import_picocolors11.default.dim("\u2026")}\r`);
65456
+ process.stdout.write(` ${describeStatus(s.status)}${import_picocolors13.default.dim("\u2026")}\r`);
64782
65457
  }
64783
65458
  }
64784
65459
  });
@@ -64790,12 +65465,12 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
64790
65465
  try {
64791
65466
  activeProfile = await runLoginFlow({
64792
65467
  profile: profileName,
64793
- jsonMode: jsonMode2,
65468
+ jsonMode: jsonMode4,
64794
65469
  origin: activeProfile.mcpOrigin,
64795
- ttyHeader: import_picocolors11.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
65470
+ ttyHeader: import_picocolors13.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
64796
65471
  });
64797
65472
  } catch (reloginErr) {
64798
- if (jsonMode2) {
65473
+ if (jsonMode4) {
64799
65474
  emitNdjson({
64800
65475
  ok: false,
64801
65476
  status: "auth_failed",
@@ -64805,7 +65480,7 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
64805
65480
  process.exit(1);
64806
65481
  }
64807
65482
  process.stderr.write(
64808
- "\n" + import_picocolors11.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65483
+ "\n" + import_picocolors13.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
64809
65484
  `)
64810
65485
  );
64811
65486
  process.exit(1);
@@ -64813,7 +65488,7 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
64813
65488
  try {
64814
65489
  final = await runPoll(activeProfile);
64815
65490
  } catch (retryErr) {
64816
- if (jsonMode2) {
65491
+ if (jsonMode4) {
64817
65492
  emitNdjson({
64818
65493
  ok: false,
64819
65494
  status: retryErr instanceof ApiError && retryErr.status === 401 ? "auth_failed" : "poll_failed",
@@ -64823,13 +65498,13 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
64823
65498
  process.exit(1);
64824
65499
  }
64825
65500
  process.stderr.write(
64826
- "\n" + import_picocolors11.default.red(`\u2715 Status poll failed: ${retryErr.message}
65501
+ "\n" + import_picocolors13.default.red(`\u2715 Status poll failed: ${retryErr.message}
64827
65502
  `)
64828
65503
  );
64829
65504
  process.exit(1);
64830
65505
  }
64831
65506
  } else {
64832
- if (jsonMode2) {
65507
+ if (jsonMode4) {
64833
65508
  emitNdjson({
64834
65509
  ok: false,
64835
65510
  status: "poll_failed",
@@ -64839,14 +65514,14 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
64839
65514
  process.exit(1);
64840
65515
  }
64841
65516
  process.stderr.write(
64842
- "\n" + import_picocolors11.default.red(`\u2715 Status poll failed: ${err.message}
65517
+ "\n" + import_picocolors13.default.red(`\u2715 Status poll failed: ${err.message}
64843
65518
  `)
64844
65519
  );
64845
65520
  process.exit(1);
64846
65521
  }
64847
65522
  }
64848
65523
  const explorer = final.tx_hash != null ? explorerUrl(final.chain_id, final.tx_hash) : null;
64849
- if (jsonMode2) {
65524
+ if (jsonMode4) {
64850
65525
  emitNdjson({
64851
65526
  ok: final.status === "mined",
64852
65527
  status: final.status,
@@ -64859,19 +65534,19 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
64859
65534
  }
64860
65535
  process.stdout.write("\n");
64861
65536
  if (final.status === "mined") {
64862
- process.stdout.write(import_picocolors11.default.green("\u2713 Mined.") + "\n");
65537
+ process.stdout.write(import_picocolors13.default.green("\u2713 Mined.") + "\n");
64863
65538
  if (final.tx_hash) {
64864
65539
  process.stdout.write(` Tx ${final.tx_hash}
64865
65540
  `);
64866
65541
  }
64867
65542
  if (explorer) {
64868
- process.stdout.write(` Explorer ${import_picocolors11.default.cyan(explorer)}
65543
+ process.stdout.write(` Explorer ${import_picocolors13.default.cyan(explorer)}
64869
65544
  `);
64870
65545
  }
64871
65546
  process.exit(0);
64872
65547
  }
64873
65548
  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}`;
64874
- process.stderr.write(import_picocolors11.default.red(`\u2715 ${label}.
65549
+ process.stderr.write(import_picocolors13.default.red(`\u2715 ${label}.
64875
65550
  `));
64876
65551
  process.exit(1);
64877
65552
  }
@@ -64899,7 +65574,7 @@ function describeStatus(s) {
64899
65574
  }
64900
65575
 
64901
65576
  // src/commands/status.ts
64902
- var import_picocolors12 = __toESM(require_picocolors(), 1);
65577
+ var import_picocolors14 = __toESM(require_picocolors(), 1);
64903
65578
  var WATCH_GIVEUP_MS = 10 * 6e4;
64904
65579
  function explorerUrl2(chainId, hash2) {
64905
65580
  switch (chainId) {
@@ -64915,38 +65590,38 @@ function explorerUrl2(chainId, hash2) {
64915
65590
  return null;
64916
65591
  }
64917
65592
  }
64918
- async function status(intentId, opts) {
65593
+ async function status2(intentId, opts) {
64919
65594
  if (!intentId || intentId.trim() === "") {
64920
- process.stderr.write(import_picocolors12.default.red("\u2715 Missing intent id.\n"));
65595
+ process.stderr.write(import_picocolors14.default.red("\u2715 Missing intent id.\n"));
64921
65596
  process.exit(2);
64922
65597
  }
64923
65598
  const requested = opts.profile ?? DEFAULT_PROFILE;
64924
65599
  const resolved = await resolveProfile(requested);
64925
65600
  if (!resolved) {
64926
- process.stderr.write(import_picocolors12.default.red("Not logged in. Run agentgates login first.\n"));
65601
+ process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
64927
65602
  process.exit(2);
64928
65603
  }
64929
65604
  if (resolved.autoSelected) {
64930
- process.stderr.write(import_picocolors12.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65605
+ process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
64931
65606
  `));
64932
65607
  }
64933
65608
  const { profile, name: profileName } = resolved;
64934
- const jsonMode2 = opts.json === true;
65609
+ const jsonMode4 = opts.json === true;
64935
65610
  const outcome = await callWithAutoRelogin({
64936
65611
  profile,
64937
65612
  profileName,
64938
- jsonMode: jsonMode2,
64939
- ttyHeader: import_picocolors12.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65613
+ jsonMode: jsonMode4,
65614
+ ttyHeader: import_picocolors14.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
64940
65615
  fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
64941
65616
  });
64942
65617
  if (outcome.kind === "auth_failed") {
64943
- if (jsonMode2) {
65618
+ if (jsonMode4) {
64944
65619
  process.stdout.write(
64945
65620
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
64946
65621
  );
64947
65622
  process.exit(1);
64948
65623
  }
64949
- process.stderr.write(import_picocolors12.default.red(`\u2715 ${outcome.reason}.
65624
+ process.stderr.write(import_picocolors14.default.red(`\u2715 ${outcome.reason}.
64950
65625
  `));
64951
65626
  process.exit(1);
64952
65627
  }
@@ -64954,11 +65629,11 @@ async function status(intentId, opts) {
64954
65629
  const err = outcome.error;
64955
65630
  if (err instanceof ApiError) {
64956
65631
  if (err.status === 404) {
64957
- process.stderr.write(import_picocolors12.default.red(`\u2715 No intent with id ${intentId}.
65632
+ process.stderr.write(import_picocolors14.default.red(`\u2715 No intent with id ${intentId}.
64958
65633
  `));
64959
65634
  process.exit(1);
64960
65635
  }
64961
- process.stderr.write(import_picocolors12.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65636
+ process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message} (HTTP ${err.status})
64962
65637
  `));
64963
65638
  process.exit(1);
64964
65639
  }
@@ -64967,9 +65642,9 @@ async function status(intentId, opts) {
64967
65642
  let snap = outcome.result;
64968
65643
  let activeProfile = outcome.profile;
64969
65644
  if (opts.watch && !isTerminalStatus(snap.status)) {
64970
- if (!jsonMode2) {
65645
+ if (!jsonMode4) {
64971
65646
  printSnap(snap);
64972
- process.stdout.write(import_picocolors12.default.dim("Watching\u2026\n"));
65647
+ process.stdout.write(import_picocolors14.default.dim("Watching\u2026\n"));
64973
65648
  }
64974
65649
  const runWatchPoll = (p) => streamStatusUntilTerminal({
64975
65650
  intentId,
@@ -64979,8 +65654,8 @@ async function status(intentId, opts) {
64979
65654
  intervalMs: 0,
64980
65655
  giveUpMs: WATCH_GIVEUP_MS,
64981
65656
  onTick: (s) => {
64982
- if (!jsonMode2) {
64983
- process.stdout.write(` ${import_picocolors12.default.dim("\u2192")} ${s.status}
65657
+ if (!jsonMode4) {
65658
+ process.stdout.write(` ${import_picocolors14.default.dim("\u2192")} ${s.status}
64984
65659
  `);
64985
65660
  }
64986
65661
  }
@@ -64993,12 +65668,12 @@ async function status(intentId, opts) {
64993
65668
  try {
64994
65669
  activeProfile = await runLoginFlow({
64995
65670
  profile: profileName,
64996
- jsonMode: jsonMode2,
65671
+ jsonMode: jsonMode4,
64997
65672
  origin: activeProfile.mcpOrigin,
64998
- ttyHeader: import_picocolors12.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
65673
+ ttyHeader: import_picocolors14.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
64999
65674
  });
65000
65675
  } catch (reloginErr) {
65001
- if (jsonMode2) {
65676
+ if (jsonMode4) {
65002
65677
  process.stdout.write(
65003
65678
  JSON.stringify({
65004
65679
  ok: false,
@@ -65009,7 +65684,7 @@ async function status(intentId, opts) {
65009
65684
  process.exit(1);
65010
65685
  }
65011
65686
  process.stderr.write(
65012
- import_picocolors12.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65687
+ import_picocolors14.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65013
65688
  `)
65014
65689
  );
65015
65690
  process.exit(1);
@@ -65017,24 +65692,24 @@ async function status(intentId, opts) {
65017
65692
  try {
65018
65693
  final = await runWatchPoll(activeProfile);
65019
65694
  } catch (retryErr) {
65020
- process.stderr.write(import_picocolors12.default.red(`\u2715 ${retryErr.message}
65695
+ process.stderr.write(import_picocolors14.default.red(`\u2715 ${retryErr.message}
65021
65696
  `));
65022
65697
  process.exit(1);
65023
65698
  }
65024
65699
  } else {
65025
- process.stderr.write(import_picocolors12.default.red(`\u2715 ${err.message}
65700
+ process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message}
65026
65701
  `));
65027
65702
  process.exit(1);
65028
65703
  }
65029
65704
  }
65030
- if (jsonMode2) {
65705
+ if (jsonMode4) {
65031
65706
  process.stdout.write(JSON.stringify(final, null, 2) + "\n");
65032
65707
  } else {
65033
65708
  printSnap(final);
65034
65709
  }
65035
65710
  process.exit(final.status === "mined" ? 0 : 1);
65036
65711
  }
65037
- if (jsonMode2) {
65712
+ if (jsonMode4) {
65038
65713
  process.stdout.write(JSON.stringify(snap, null, 2) + "\n");
65039
65714
  process.exit(snap.status === "mined" ? 0 : 0);
65040
65715
  }
@@ -65043,7 +65718,7 @@ async function status(intentId, opts) {
65043
65718
  }
65044
65719
  function printSnap(s) {
65045
65720
  const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
65046
- const colorFn = s.status === "mined" ? import_picocolors12.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors12.default.red : import_picocolors12.default.cyan;
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;
65047
65722
  process.stdout.write(`Intent ${s.approval_id}
65048
65723
  `);
65049
65724
  process.stdout.write(`Status ${colorFn(s.status)}
@@ -65058,12 +65733,12 @@ function printSnap(s) {
65058
65733
  process.stdout.write(`Tx ${s.tx_hash}
65059
65734
  `);
65060
65735
  if (explorer) {
65061
- process.stdout.write(`Explorer ${import_picocolors12.default.cyan(explorer)}
65736
+ process.stdout.write(`Explorer ${import_picocolors14.default.cyan(explorer)}
65062
65737
  `);
65063
65738
  }
65064
65739
  }
65065
65740
  if (!isTerminalStatus(s.status)) {
65066
- process.stdout.write(`Approve ${import_picocolors12.default.cyan(s.approval_url)}
65741
+ process.stdout.write(`Approve ${import_picocolors14.default.cyan(s.approval_url)}
65067
65742
  `);
65068
65743
  }
65069
65744
  process.stdout.write(`Created ${formatDate2(s.created_at)}
@@ -65080,7 +65755,7 @@ function formatDate2(iso) {
65080
65755
  }
65081
65756
 
65082
65757
  // src/commands/balance.ts
65083
- var import_picocolors13 = __toESM(require_picocolors(), 1);
65758
+ var import_picocolors15 = __toESM(require_picocolors(), 1);
65084
65759
  var CHAIN_ALIASES = {
65085
65760
  "1": 1,
65086
65761
  ethereum: 1,
@@ -65103,11 +65778,11 @@ async function balance(opts) {
65103
65778
  const requested = opts.profile ?? DEFAULT_PROFILE;
65104
65779
  const resolved = await resolveProfile(requested);
65105
65780
  if (!resolved) {
65106
- process.stderr.write(import_picocolors13.default.red("Not logged in. Run agentgates login first.\n"));
65781
+ process.stderr.write(import_picocolors15.default.red("Not logged in. Run agentgates login first.\n"));
65107
65782
  process.exit(2);
65108
65783
  }
65109
65784
  if (resolved.autoSelected) {
65110
- process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65785
+ process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65111
65786
  `));
65112
65787
  }
65113
65788
  const { profile, name: profileName } = resolved;
@@ -65117,8 +65792,8 @@ async function balance(opts) {
65117
65792
  const id2 = CHAIN_ALIASES[key];
65118
65793
  if (id2 === void 0) {
65119
65794
  process.stderr.write(
65120
- import_picocolors13.default.red(
65121
- `\u2715 Unknown chain ${import_picocolors13.default.bold(opts.chain)}. Supported: ${import_picocolors13.default.bold("1/ethereum")}, ${import_picocolors13.default.bold("137/polygon")}, ${import_picocolors13.default.bold("8453/base")}, ${import_picocolors13.default.bold("42161/arbitrum")}, ${import_picocolors13.default.bold("900/solana")}.
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")}.
65122
65797
  `
65123
65798
  )
65124
65799
  );
@@ -65126,29 +65801,29 @@ async function balance(opts) {
65126
65801
  }
65127
65802
  chainFilter = id2;
65128
65803
  }
65129
- const jsonMode2 = opts.json === true;
65804
+ const jsonMode4 = opts.json === true;
65130
65805
  const outcome = await callWithAutoRelogin({
65131
65806
  profile,
65132
65807
  profileName,
65133
- jsonMode: jsonMode2,
65134
- ttyHeader: import_picocolors13.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65808
+ jsonMode: jsonMode4,
65809
+ ttyHeader: import_picocolors15.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65135
65810
  fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
65136
65811
  });
65137
65812
  if (outcome.kind === "auth_failed") {
65138
- if (jsonMode2) {
65813
+ if (jsonMode4) {
65139
65814
  process.stdout.write(
65140
65815
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
65141
65816
  );
65142
65817
  process.exit(1);
65143
65818
  }
65144
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${outcome.reason}.
65819
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${outcome.reason}.
65145
65820
  `));
65146
65821
  process.exit(1);
65147
65822
  }
65148
65823
  if (outcome.kind === "error") {
65149
65824
  const err = outcome.error;
65150
65825
  if (err instanceof ApiError) {
65151
- process.stderr.write(import_picocolors13.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65826
+ process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65152
65827
  `));
65153
65828
  process.exit(1);
65154
65829
  }
@@ -65156,7 +65831,7 @@ async function balance(opts) {
65156
65831
  }
65157
65832
  const res = outcome.result;
65158
65833
  const filtered = chainFilter !== null ? res.chains.filter((c) => c.chainId === chainFilter) : res.chains;
65159
- if (jsonMode2) {
65834
+ if (jsonMode4) {
65160
65835
  process.stdout.write(
65161
65836
  JSON.stringify(
65162
65837
  chainFilter !== null ? { ...res, chains: filtered } : res,
@@ -65178,7 +65853,7 @@ async function balance(opts) {
65178
65853
  }
65179
65854
  if (filtered.length === 0) {
65180
65855
  process.stdout.write(
65181
- import_picocolors13.default.dim(
65856
+ import_picocolors15.default.dim(
65182
65857
  chainFilter !== null ? `No balances on chain ${chainFilter}.
65183
65858
  ` : `No chain balances returned.
65184
65859
  `
@@ -65190,7 +65865,7 @@ async function balance(opts) {
65190
65865
  const errorLines = [];
65191
65866
  for (const c of filtered) {
65192
65867
  if (c.error) {
65193
- errorLines.push(`${c.chainName} ${import_picocolors13.default.red(`(read failed: ${c.error})`)}`);
65868
+ errorLines.push(`${c.chainName} ${import_picocolors15.default.red(`(read failed: ${c.error})`)}`);
65194
65869
  continue;
65195
65870
  }
65196
65871
  if (c.native.balance > 0) {
@@ -65211,7 +65886,7 @@ async function balance(opts) {
65211
65886
  }
65212
65887
  }
65213
65888
  if (rows.length === 0 && errorLines.length === 0) {
65214
- process.stdout.write(import_picocolors13.default.dim(`All balances are zero.
65889
+ process.stdout.write(import_picocolors15.default.dim(`All balances are zero.
65215
65890
  `));
65216
65891
  process.stdout.write(AI_DIRECTIVE + "\n");
65217
65892
  return;
@@ -65221,7 +65896,7 @@ async function balance(opts) {
65221
65896
  const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
65222
65897
  const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
65223
65898
  const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
65224
- process.stdout.write(import_picocolors13.default.dim(header) + "\n");
65899
+ process.stdout.write(import_picocolors15.default.dim(header) + "\n");
65225
65900
  for (const r of rows) {
65226
65901
  process.stdout.write(
65227
65902
  r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
@@ -65234,7 +65909,7 @@ async function balance(opts) {
65234
65909
  `);
65235
65910
  }
65236
65911
  if (res.fetched_at) {
65237
- process.stdout.write("\n" + import_picocolors13.default.dim(`Fetched ${res.fetched_at}
65912
+ process.stdout.write("\n" + import_picocolors15.default.dim(`Fetched ${res.fetched_at}
65238
65913
  `));
65239
65914
  }
65240
65915
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -65247,18 +65922,18 @@ function formatBalance(value, decimals) {
65247
65922
  }
65248
65923
 
65249
65924
  // src/commands/history.ts
65250
- var import_picocolors14 = __toESM(require_picocolors(), 1);
65925
+ var import_picocolors16 = __toESM(require_picocolors(), 1);
65251
65926
  var DEFAULT_LIMIT = 20;
65252
65927
  var SERVER_MAX_LIMIT = 100;
65253
65928
  async function history(opts) {
65254
65929
  const requested = opts.profile ?? DEFAULT_PROFILE;
65255
65930
  const resolved = await resolveProfile(requested);
65256
65931
  if (!resolved) {
65257
- process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
65932
+ process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
65258
65933
  process.exit(2);
65259
65934
  }
65260
65935
  if (resolved.autoSelected) {
65261
- process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65936
+ process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65262
65937
  `));
65263
65938
  }
65264
65939
  const { profile, name: profileName } = resolved;
@@ -65267,14 +65942,14 @@ async function history(opts) {
65267
65942
  const n2 = Number(opts.limit);
65268
65943
  if (!Number.isFinite(n2) || n2 <= 0 || !Number.isInteger(n2)) {
65269
65944
  process.stderr.write(
65270
- import_picocolors14.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors14.default.bold(opts.limit)}).
65945
+ import_picocolors16.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors16.default.bold(opts.limit)}).
65271
65946
  `)
65272
65947
  );
65273
65948
  process.exit(2);
65274
65949
  }
65275
65950
  if (n2 > SERVER_MAX_LIMIT) {
65276
65951
  process.stderr.write(
65277
- import_picocolors14.default.red(
65952
+ import_picocolors16.default.red(
65278
65953
  `\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n2}.
65279
65954
  `
65280
65955
  )
@@ -65283,39 +65958,39 @@ async function history(opts) {
65283
65958
  }
65284
65959
  limit = n2;
65285
65960
  }
65286
- const jsonMode2 = opts.json === true;
65961
+ const jsonMode4 = opts.json === true;
65287
65962
  const outcome = await callWithAutoRelogin({
65288
65963
  profile,
65289
65964
  profileName,
65290
- jsonMode: jsonMode2,
65291
- ttyHeader: import_picocolors14.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65965
+ jsonMode: jsonMode4,
65966
+ ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
65292
65967
  fn: (bearer, origin) => apiFetch(
65293
65968
  `/api/history?limit=${encodeURIComponent(String(limit))}`,
65294
65969
  { bearer, origin }
65295
65970
  )
65296
65971
  });
65297
65972
  if (outcome.kind === "auth_failed") {
65298
- if (jsonMode2) {
65973
+ if (jsonMode4) {
65299
65974
  process.stdout.write(
65300
65975
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
65301
65976
  );
65302
65977
  process.exit(1);
65303
65978
  }
65304
- process.stderr.write(import_picocolors14.default.red(`\u2715 ${outcome.reason}.
65979
+ process.stderr.write(import_picocolors16.default.red(`\u2715 ${outcome.reason}.
65305
65980
  `));
65306
65981
  process.exit(1);
65307
65982
  }
65308
65983
  if (outcome.kind === "error") {
65309
65984
  const err = outcome.error;
65310
65985
  if (err instanceof ApiError) {
65311
- process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65986
+ process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65312
65987
  `));
65313
65988
  process.exit(1);
65314
65989
  }
65315
65990
  throw err;
65316
65991
  }
65317
65992
  const res = outcome.result;
65318
- if (jsonMode2) {
65993
+ if (jsonMode4) {
65319
65994
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
65320
65995
  return;
65321
65996
  }
@@ -65325,7 +66000,7 @@ async function history(opts) {
65325
66000
  return;
65326
66001
  }
65327
66002
  if (res.txs.length === 0) {
65328
- process.stdout.write(import_picocolors14.default.dim(`No activity yet.
66003
+ process.stdout.write(import_picocolors16.default.dim(`No activity yet.
65329
66004
  `));
65330
66005
  return;
65331
66006
  }
@@ -65345,7 +66020,7 @@ async function history(opts) {
65345
66020
  const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
65346
66021
  const colTo = Math.max(2, ...rows.map((r) => r.to.length));
65347
66022
  const header = "When".padEnd(colWhen) + " " + "Chain".padEnd(colChain) + " " + "Type".padEnd(colType) + " " + "Amount".padStart(colAmount) + " " + "Asset".padEnd(colAsset) + " " + "To".padEnd(colTo) + " Hash";
65348
- process.stdout.write(import_picocolors14.default.dim(header) + "\n");
66023
+ process.stdout.write(import_picocolors16.default.dim(header) + "\n");
65349
66024
  for (const r of rows) {
65350
66025
  process.stdout.write(
65351
66026
  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"
@@ -65353,7 +66028,7 @@ async function history(opts) {
65353
66028
  }
65354
66029
  if (res.fetched_at) {
65355
66030
  process.stdout.write(
65356
- "\n" + import_picocolors14.default.dim(
66031
+ "\n" + import_picocolors16.default.dim(
65357
66032
  `Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
65358
66033
  `
65359
66034
  )
@@ -65403,7 +66078,7 @@ function chainIdLabel(id2) {
65403
66078
  return `chain ${id2}`;
65404
66079
  }
65405
66080
  }
65406
- function prettyType(activityType, status2) {
66081
+ function prettyType(activityType, status3) {
65407
66082
  const base = (() => {
65408
66083
  switch (activityType) {
65409
66084
  case "received":
@@ -65433,17 +66108,17 @@ function prettyType(activityType, status2) {
65433
66108
  return activityType;
65434
66109
  }
65435
66110
  })();
65436
- if (status2 && status2 !== "confirmed" && status2 !== "complete") {
65437
- return `${base} \xB7 ${status2}`;
66111
+ if (status3 && status3 !== "confirmed" && status3 !== "complete") {
66112
+ return `${base} \xB7 ${status3}`;
65438
66113
  }
65439
66114
  return base;
65440
66115
  }
65441
66116
 
65442
66117
  // src/commands/swap.ts
65443
- var import_picocolors16 = __toESM(require_picocolors(), 1);
66118
+ var import_picocolors18 = __toESM(require_picocolors(), 1);
65444
66119
 
65445
66120
  // src/lib/intent-flow.ts
65446
- var import_picocolors15 = __toESM(require_picocolors(), 1);
66121
+ var import_picocolors17 = __toESM(require_picocolors(), 1);
65447
66122
  var STREAM_GIVEUP_MS = 10 * 6e4;
65448
66123
  var SOLANA_CHAIN_ID2 = 900;
65449
66124
  function isBlocked2(r) {
@@ -65518,7 +66193,7 @@ async function runIntentFlow(opts) {
65518
66193
  profile: opts.profileName,
65519
66194
  jsonMode: opts.jsonMode,
65520
66195
  origin: activeProfile.mcpOrigin,
65521
- ttyHeader: import_picocolors15.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
66196
+ ttyHeader: import_picocolors17.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
65522
66197
  });
65523
66198
  } catch (reloginErr) {
65524
66199
  if (opts.jsonMode) {
@@ -65530,7 +66205,7 @@ async function runIntentFlow(opts) {
65530
66205
  process.exit(1);
65531
66206
  }
65532
66207
  process.stderr.write(
65533
- import_picocolors15.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
66208
+ import_picocolors17.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65534
66209
  `)
65535
66210
  );
65536
66211
  process.exit(1);
@@ -65554,7 +66229,7 @@ async function runIntentFlow(opts) {
65554
66229
  process.exit(1);
65555
66230
  }
65556
66231
  process.stderr.write(
65557
- import_picocolors15.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
66232
+ import_picocolors17.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
65558
66233
  `)
65559
66234
  );
65560
66235
  process.exit(1);
@@ -65571,7 +66246,7 @@ async function runIntentFlow(opts) {
65571
66246
  });
65572
66247
  process.exit(1);
65573
66248
  }
65574
- process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message} (HTTP ${err.status})
66249
+ process.stderr.write(import_picocolors17.default.red(`\u2715 ${err.message} (HTTP ${err.status})
65575
66250
  `));
65576
66251
  process.exit(1);
65577
66252
  } else {
@@ -65593,18 +66268,18 @@ async function runIntentFlow(opts) {
65593
66268
  });
65594
66269
  process.exit(1);
65595
66270
  }
65596
- process.stderr.write(import_picocolors15.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
66271
+ process.stderr.write(import_picocolors17.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
65597
66272
  `));
65598
66273
  if (proposed.upgrade_url) {
65599
66274
  process.stderr.write(
65600
66275
  ` Open this to grant access, then re-run the command:
65601
- ${import_picocolors15.default.cyan(proposed.upgrade_url)}
66276
+ ${import_picocolors17.default.cyan(proposed.upgrade_url)}
65602
66277
  `
65603
66278
  );
65604
66279
  }
65605
66280
  if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
65606
66281
  process.stderr.write(
65607
- import_picocolors15.default.dim(
66282
+ import_picocolors17.default.dim(
65608
66283
  ` Suggested actions:
65609
66284
  ` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
65610
66285
  )
@@ -65627,8 +66302,8 @@ async function runIntentFlow(opts) {
65627
66302
  } else {
65628
66303
  process.stdout.write(
65629
66304
  `
65630
- ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with biometric:
65631
- ${import_picocolors15.default.cyan(proposed.approval_url)}
66305
+ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with biometric:
66306
+ ${import_picocolors17.default.cyan(proposed.approval_url)}
65632
66307
 
65633
66308
  `
65634
66309
  );
@@ -65650,7 +66325,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
65650
66325
  if (opts.jsonMode) {
65651
66326
  emitNdjson2({ status: s.status, intent_id: s.approval_id });
65652
66327
  } else {
65653
- process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors15.default.dim("\u2026")}\r`);
66328
+ process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors17.default.dim("\u2026")}\r`);
65654
66329
  }
65655
66330
  }
65656
66331
  });
@@ -65664,7 +66339,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
65664
66339
  profile: opts.profileName,
65665
66340
  jsonMode: opts.jsonMode,
65666
66341
  origin: activeProfile.mcpOrigin,
65667
- ttyHeader: import_picocolors15.default.dim(
66342
+ ttyHeader: import_picocolors17.default.dim(
65668
66343
  "Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
65669
66344
  )
65670
66345
  });
@@ -65679,7 +66354,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
65679
66354
  process.exit(1);
65680
66355
  }
65681
66356
  process.stderr.write(
65682
- "\n" + import_picocolors15.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
66357
+ "\n" + import_picocolors17.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
65683
66358
  `)
65684
66359
  );
65685
66360
  process.exit(1);
@@ -65697,7 +66372,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
65697
66372
  process.exit(1);
65698
66373
  }
65699
66374
  process.stderr.write(
65700
- "\n" + import_picocolors15.default.red(`\u2715 Status poll failed: ${retryErr.message}
66375
+ "\n" + import_picocolors17.default.red(`\u2715 Status poll failed: ${retryErr.message}
65701
66376
  `)
65702
66377
  );
65703
66378
  process.exit(1);
@@ -65713,7 +66388,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
65713
66388
  process.exit(1);
65714
66389
  }
65715
66390
  process.stderr.write(
65716
- "\n" + import_picocolors15.default.red(`\u2715 Status poll failed: ${err.message}
66391
+ "\n" + import_picocolors17.default.red(`\u2715 Status poll failed: ${err.message}
65717
66392
  `)
65718
66393
  );
65719
66394
  process.exit(1);
@@ -65754,39 +66429,39 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
65754
66429
  process.stdout.write("\n");
65755
66430
  const printLegJournal = () => {
65756
66431
  if (legs.length === 0) return;
65757
- process.stdout.write(import_picocolors15.default.bold(" Legs:\n"));
66432
+ process.stdout.write(import_picocolors17.default.bold(" Legs:\n"));
65758
66433
  for (const l of legs) {
65759
- const line = l.status === "mined" ? import_picocolors15.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors15.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors15.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors15.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors15.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
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}`);
65760
66435
  process.stdout.write(` ${line}
65761
66436
  `);
65762
66437
  }
65763
66438
  };
65764
66439
  if (final.status === "mined") {
65765
- process.stdout.write(import_picocolors15.default.green("\u2713 Mined.") + "\n");
66440
+ process.stdout.write(import_picocolors17.default.green("\u2713 Mined.") + "\n");
65766
66441
  if (final.tx_hash) {
65767
66442
  process.stdout.write(` Tx ${final.tx_hash}
65768
66443
  `);
65769
66444
  }
65770
66445
  if (explorer) {
65771
- process.stdout.write(` Explorer ${import_picocolors15.default.cyan(explorer)}
66446
+ process.stdout.write(` Explorer ${import_picocolors17.default.cyan(explorer)}
65772
66447
  `);
65773
66448
  }
65774
66449
  printLegJournal();
65775
66450
  process.exit(0);
65776
66451
  }
65777
66452
  if (final.status === "failed" && failure?.message) {
65778
- process.stderr.write(import_picocolors15.default.red(`\u2715 ${failure.message}
66453
+ process.stderr.write(import_picocolors17.default.red(`\u2715 ${failure.message}
65779
66454
  `));
65780
66455
  if (retryCommand) {
65781
66456
  process.stderr.write(` Retry:
65782
- ${import_picocolors15.default.cyan(retryCommand)}
66457
+ ${import_picocolors17.default.cyan(retryCommand)}
65783
66458
  `);
65784
66459
  }
65785
66460
  printLegJournal();
65786
66461
  process.exit(1);
65787
66462
  }
65788
66463
  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}`;
65789
- process.stderr.write(import_picocolors15.default.red(`\u2715 ${label}.
66464
+ process.stderr.write(import_picocolors17.default.red(`\u2715 ${label}.
65790
66465
  `));
65791
66466
  printLegJournal();
65792
66467
  process.exit(1);
@@ -65806,7 +66481,7 @@ function isAsset(v) {
65806
66481
  return ASSET_VALUES.has(v.toLowerCase());
65807
66482
  }
65808
66483
  function failArg(msg) {
65809
- process.stderr.write(import_picocolors16.default.red(`\u2715 ${msg}
66484
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${msg}
65810
66485
  `));
65811
66486
  process.exit(2);
65812
66487
  }
@@ -65814,24 +66489,24 @@ async function swap(amount, fromAsset, opts) {
65814
66489
  const requested = opts.profile ?? DEFAULT_PROFILE;
65815
66490
  const resolved = await resolveProfile(requested);
65816
66491
  if (!resolved) {
65817
- process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
66492
+ process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
65818
66493
  process.exit(2);
65819
66494
  }
65820
66495
  if (resolved.autoSelected) {
65821
- process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66496
+ process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
65822
66497
  `));
65823
66498
  }
65824
66499
  const { profile, name: profileName } = resolved;
65825
66500
  const stdoutIsTty = process.stdout.isTTY === true;
65826
- const jsonMode2 = opts.json === true || !stdoutIsTty;
66501
+ const jsonMode4 = opts.json === true || !stdoutIsTty;
65827
66502
  const amountNumber = Number(amount);
65828
66503
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
65829
- failArg(`amount must be a positive number (got ${import_picocolors16.default.bold(amount)}).`);
66504
+ failArg(`amount must be a positive number (got ${import_picocolors18.default.bold(amount)}).`);
65830
66505
  }
65831
66506
  const fromAssetNorm = fromAsset.toLowerCase();
65832
66507
  if (!isAsset(fromAssetNorm)) {
65833
66508
  failArg(
65834
- `from-asset must be ${import_picocolors16.default.bold("native")} or ${import_picocolors16.default.bold("usdc")} (got ${import_picocolors16.default.bold(fromAsset)}).`
66509
+ `from-asset must be ${import_picocolors18.default.bold("native")} or ${import_picocolors18.default.bold("usdc")} (got ${import_picocolors18.default.bold(fromAsset)}).`
65835
66510
  );
65836
66511
  }
65837
66512
  if (!opts.toAsset) {
@@ -65840,7 +66515,7 @@ async function swap(amount, fromAsset, opts) {
65840
66515
  const toAssetNorm = opts.toAsset.toLowerCase();
65841
66516
  if (!isAsset(toAssetNorm)) {
65842
66517
  failArg(
65843
- `--to-asset must be ${import_picocolors16.default.bold("native")} or ${import_picocolors16.default.bold("usdc")} (got ${import_picocolors16.default.bold(opts.toAsset)}).`
66518
+ `--to-asset must be ${import_picocolors18.default.bold("native")} or ${import_picocolors18.default.bold("usdc")} (got ${import_picocolors18.default.bold(opts.toAsset)}).`
65844
66519
  );
65845
66520
  }
65846
66521
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -65962,16 +66637,16 @@ async function swap(amount, fromAsset, opts) {
65962
66637
  body: proposeBody,
65963
66638
  profileName,
65964
66639
  initialProfile: profile,
65965
- jsonMode: jsonMode2,
66640
+ jsonMode: jsonMode4,
65966
66641
  shouldOpenBrowser,
65967
66642
  buildRetryCommand
65968
66643
  });
65969
66644
  }
65970
66645
 
65971
66646
  // src/commands/batch.ts
65972
- var import_picocolors17 = __toESM(require_picocolors(), 1);
66647
+ var import_picocolors19 = __toESM(require_picocolors(), 1);
65973
66648
  function failArg2(msg) {
65974
- process.stderr.write(import_picocolors17.default.red(`\u2715 ${msg}
66649
+ process.stderr.write(import_picocolors19.default.red(`\u2715 ${msg}
65975
66650
  `));
65976
66651
  process.exit(2);
65977
66652
  }
@@ -65979,11 +66654,11 @@ async function batch(opts) {
65979
66654
  const requested = opts.profile ?? DEFAULT_PROFILE;
65980
66655
  const resolved = await resolveProfile(requested);
65981
66656
  if (!resolved) {
65982
- process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
66657
+ process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
65983
66658
  process.exit(2);
65984
66659
  }
65985
66660
  const { name: profileName, profile } = resolved;
65986
- const jsonMode2 = opts.json === true || !process.stdout.isTTY;
66661
+ const jsonMode4 = opts.json === true || !process.stdout.isTTY;
65987
66662
  let legs;
65988
66663
  try {
65989
66664
  legs = JSON.parse(opts.legsJson);
@@ -66027,20 +66702,20 @@ async function batch(opts) {
66027
66702
  },
66028
66703
  profileName,
66029
66704
  initialProfile: profile,
66030
- jsonMode: jsonMode2,
66705
+ jsonMode: jsonMode4,
66031
66706
  shouldOpenBrowser
66032
66707
  });
66033
66708
  }
66034
66709
 
66035
66710
  // src/commands/fund-wallet.ts
66036
- var import_picocolors18 = __toESM(require_picocolors(), 1);
66711
+ var import_picocolors20 = __toESM(require_picocolors(), 1);
66037
66712
  var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
66038
66713
  var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
66039
66714
  function isAddressTarget(target) {
66040
66715
  return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
66041
66716
  }
66042
66717
  function failArg3(msg) {
66043
- process.stderr.write(import_picocolors18.default.red(`\u2715 ${msg}
66718
+ process.stderr.write(import_picocolors20.default.red(`\u2715 ${msg}
66044
66719
  `));
66045
66720
  process.exit(2);
66046
66721
  }
@@ -66048,11 +66723,11 @@ async function fundWallet(address, opts) {
66048
66723
  const requested = opts.profile ?? DEFAULT_PROFILE;
66049
66724
  const resolved = await resolveProfile(requested);
66050
66725
  if (!resolved) {
66051
- process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
66726
+ process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
66052
66727
  process.exit(2);
66053
66728
  }
66054
66729
  const { name: profileName, profile } = resolved;
66055
- const jsonMode2 = opts.json === true || !process.stdout.isTTY;
66730
+ const jsonMode4 = opts.json === true || !process.stdout.isTTY;
66056
66731
  if (!opts.chain) {
66057
66732
  failArg3("--chain is required (1/137/8453/42161/900 or shortName).");
66058
66733
  }
@@ -66104,7 +66779,7 @@ async function fundWallet(address, opts) {
66104
66779
  },
66105
66780
  profileName,
66106
66781
  initialProfile: profile,
66107
- jsonMode: jsonMode2,
66782
+ jsonMode: jsonMode4,
66108
66783
  shouldOpenBrowser
66109
66784
  });
66110
66785
  }
@@ -66119,17 +66794,17 @@ async function fundWallet(address, opts) {
66119
66794
  },
66120
66795
  profileName,
66121
66796
  initialProfile: profile,
66122
- jsonMode: jsonMode2,
66797
+ jsonMode: jsonMode4,
66123
66798
  shouldOpenBrowser
66124
66799
  });
66125
66800
  }
66126
66801
 
66127
66802
  // src/commands/earn-supply.ts
66128
- var import_picocolors19 = __toESM(require_picocolors(), 1);
66803
+ var import_picocolors21 = __toESM(require_picocolors(), 1);
66129
66804
  var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
66130
66805
  var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
66131
66806
  function failArg4(msg) {
66132
- process.stderr.write(import_picocolors19.default.red(`\u2715 ${msg}
66807
+ process.stderr.write(import_picocolors21.default.red(`\u2715 ${msg}
66133
66808
  `));
66134
66809
  process.exit(2);
66135
66810
  }
@@ -66137,24 +66812,24 @@ async function earnSupply(amount, asset, opts) {
66137
66812
  const requested = opts.profile ?? DEFAULT_PROFILE;
66138
66813
  const resolved = await resolveProfile(requested);
66139
66814
  if (!resolved) {
66140
- process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
66815
+ process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
66141
66816
  process.exit(2);
66142
66817
  }
66143
66818
  if (resolved.autoSelected) {
66144
- process.stderr.write(import_picocolors19.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66819
+ process.stderr.write(import_picocolors21.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66145
66820
  `));
66146
66821
  }
66147
66822
  const { profile, name: profileName } = resolved;
66148
66823
  const stdoutIsTty = process.stdout.isTTY === true;
66149
- const jsonMode2 = opts.json === true || !stdoutIsTty;
66824
+ const jsonMode4 = opts.json === true || !stdoutIsTty;
66150
66825
  const amountNumber = Number(amount);
66151
66826
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
66152
- failArg4(`amount must be a positive number (got ${import_picocolors19.default.bold(amount)}).`);
66827
+ failArg4(`amount must be a positive number (got ${import_picocolors21.default.bold(amount)}).`);
66153
66828
  }
66154
66829
  const assetNorm = asset.toLowerCase();
66155
66830
  if (!ASSET_VALUES2.has(assetNorm)) {
66156
66831
  failArg4(
66157
- `asset must be ${import_picocolors19.default.bold("native")} or ${import_picocolors19.default.bold("usdc")} (got ${import_picocolors19.default.bold(asset)}).`
66832
+ `asset must be ${import_picocolors21.default.bold("native")} or ${import_picocolors21.default.bold("usdc")} (got ${import_picocolors21.default.bold(asset)}).`
66158
66833
  );
66159
66834
  }
66160
66835
  if (!opts.chain) {
@@ -66166,7 +66841,7 @@ async function earnSupply(amount, asset, opts) {
66166
66841
  const protocolNorm = opts.protocol.toLowerCase();
66167
66842
  if (!PROTOCOLS.has(protocolNorm)) {
66168
66843
  failArg4(
66169
- `--protocol must be ${import_picocolors19.default.bold("aave_v3")} or ${import_picocolors19.default.bold("kamino_lend")} (got ${import_picocolors19.default.bold(opts.protocol)}).`
66844
+ `--protocol must be ${import_picocolors21.default.bold("aave_v3")} or ${import_picocolors21.default.bold("kamino_lend")} (got ${import_picocolors21.default.bold(opts.protocol)}).`
66170
66845
  );
66171
66846
  }
66172
66847
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -66212,17 +66887,17 @@ async function earnSupply(amount, asset, opts) {
66212
66887
  body: proposeBody,
66213
66888
  profileName,
66214
66889
  initialProfile: profile,
66215
- jsonMode: jsonMode2,
66890
+ jsonMode: jsonMode4,
66216
66891
  shouldOpenBrowser
66217
66892
  });
66218
66893
  }
66219
66894
 
66220
66895
  // src/commands/earn-withdraw.ts
66221
- var import_picocolors20 = __toESM(require_picocolors(), 1);
66896
+ var import_picocolors22 = __toESM(require_picocolors(), 1);
66222
66897
  var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
66223
66898
  var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
66224
66899
  function failArg5(msg) {
66225
- process.stderr.write(import_picocolors20.default.red(`\u2715 ${msg}
66900
+ process.stderr.write(import_picocolors22.default.red(`\u2715 ${msg}
66226
66901
  `));
66227
66902
  process.exit(2);
66228
66903
  }
@@ -66230,29 +66905,29 @@ async function earnWithdraw(amountOrMax, asset, opts) {
66230
66905
  const requested = opts.profile ?? DEFAULT_PROFILE;
66231
66906
  const resolved = await resolveProfile(requested);
66232
66907
  if (!resolved) {
66233
- process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
66908
+ process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
66234
66909
  process.exit(2);
66235
66910
  }
66236
66911
  if (resolved.autoSelected) {
66237
- process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66912
+ process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66238
66913
  `));
66239
66914
  }
66240
66915
  const { profile, name: profileName } = resolved;
66241
66916
  const stdoutIsTty = process.stdout.isTTY === true;
66242
- const jsonMode2 = opts.json === true || !stdoutIsTty;
66917
+ const jsonMode4 = opts.json === true || !stdoutIsTty;
66243
66918
  const isMax = amountOrMax.toLowerCase() === "max";
66244
66919
  if (!isMax) {
66245
66920
  const amountNumber = Number(amountOrMax);
66246
66921
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
66247
66922
  failArg5(
66248
- `<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors20.default.bold(amountOrMax)}).`
66923
+ `<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors22.default.bold(amountOrMax)}).`
66249
66924
  );
66250
66925
  }
66251
66926
  }
66252
66927
  const assetNorm = asset.toLowerCase();
66253
66928
  if (!ASSET_VALUES3.has(assetNorm)) {
66254
66929
  failArg5(
66255
- `asset must be ${import_picocolors20.default.bold("native")} or ${import_picocolors20.default.bold("usdc")} (got ${import_picocolors20.default.bold(asset)}).`
66930
+ `asset must be ${import_picocolors22.default.bold("native")} or ${import_picocolors22.default.bold("usdc")} (got ${import_picocolors22.default.bold(asset)}).`
66256
66931
  );
66257
66932
  }
66258
66933
  if (!opts.chain) {
@@ -66264,7 +66939,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
66264
66939
  const protocolNorm = opts.protocol.toLowerCase();
66265
66940
  if (!PROTOCOLS2.has(protocolNorm)) {
66266
66941
  failArg5(
66267
- `--protocol must be ${import_picocolors20.default.bold("aave_v3")} or ${import_picocolors20.default.bold("kamino_lend")} (got ${import_picocolors20.default.bold(opts.protocol)}).`
66942
+ `--protocol must be ${import_picocolors22.default.bold("aave_v3")} or ${import_picocolors22.default.bold("kamino_lend")} (got ${import_picocolors22.default.bold(opts.protocol)}).`
66268
66943
  );
66269
66944
  }
66270
66945
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -66310,13 +66985,13 @@ async function earnWithdraw(amountOrMax, asset, opts) {
66310
66985
  body: proposeBody,
66311
66986
  profileName,
66312
66987
  initialProfile: profile,
66313
- jsonMode: jsonMode2,
66988
+ jsonMode: jsonMode4,
66314
66989
  shouldOpenBrowser
66315
66990
  });
66316
66991
  }
66317
66992
 
66318
66993
  // src/commands/eat.ts
66319
- var import_picocolors21 = __toESM(require_picocolors(), 1);
66994
+ var import_picocolors23 = __toESM(require_picocolors(), 1);
66320
66995
  function parseLineJson(values) {
66321
66996
  const lines = [];
66322
66997
  for (const value of values) {
@@ -66343,27 +67018,27 @@ function parseLineJson(values) {
66343
67018
  async function loadResolvedProfile(requested) {
66344
67019
  const resolved = await resolveProfile(requested);
66345
67020
  if (!resolved) {
66346
- process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
67021
+ process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
66347
67022
  process.exit(2);
66348
67023
  }
66349
67024
  if (resolved.autoSelected) {
66350
- process.stderr.write(import_picocolors21.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67025
+ process.stderr.write(import_picocolors23.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66351
67026
  `));
66352
67027
  }
66353
67028
  return resolved;
66354
67029
  }
66355
- function printResult(res, jsonMode2) {
66356
- if (jsonMode2) {
67030
+ function printResult(res, jsonMode4) {
67031
+ if (jsonMode4) {
66357
67032
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
66358
67033
  return;
66359
67034
  }
66360
67035
  if (res.blocked) {
66361
- process.stderr.write(import_picocolors21.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
67036
+ process.stderr.write(import_picocolors23.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
66362
67037
  `));
66363
67038
  if (res.upgrade_url) {
66364
67039
  process.stderr.write(
66365
67040
  ` Open this to grant access, then re-run the command:
66366
- ${import_picocolors21.default.cyan(res.upgrade_url)}
67041
+ ${import_picocolors23.default.cyan(res.upgrade_url)}
66367
67042
  `
66368
67043
  );
66369
67044
  }
@@ -66389,35 +67064,35 @@ async function postRestaurantQuiet(path6, body, resolved) {
66389
67064
  return null;
66390
67065
  }
66391
67066
  }
66392
- async function postRestaurant(path6, body, resolved, jsonMode2) {
67067
+ async function postRestaurant(path6, body, resolved, jsonMode4) {
66393
67068
  const outcome = await callWithAutoRelogin({
66394
67069
  profile: resolved.profile,
66395
67070
  profileName: resolved.name,
66396
- jsonMode: jsonMode2,
66397
- ttyHeader: import_picocolors21.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67071
+ jsonMode: jsonMode4,
67072
+ ttyHeader: import_picocolors23.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
66398
67073
  fn: (bearer, origin) => apiFetch(path6, { method: "POST", bearer, origin, body })
66399
67074
  });
66400
67075
  if (outcome.kind === "auth_failed") {
66401
- if (jsonMode2) {
67076
+ if (jsonMode4) {
66402
67077
  process.stdout.write(
66403
67078
  JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
66404
67079
  );
66405
67080
  process.exit(1);
66406
67081
  }
66407
- process.stderr.write(import_picocolors21.default.red(`\u2715 ${outcome.reason}.
67082
+ process.stderr.write(import_picocolors23.default.red(`\u2715 ${outcome.reason}.
66408
67083
  `));
66409
67084
  process.exit(1);
66410
67085
  }
66411
67086
  if (outcome.kind === "error") {
66412
67087
  const err = outcome.error;
66413
67088
  if (err instanceof ApiError) {
66414
- if (jsonMode2) {
67089
+ if (jsonMode4) {
66415
67090
  process.stdout.write(
66416
67091
  JSON.stringify({ ok: false, status: "request_failed", error: err.message, http_status: err.status }) + "\n"
66417
67092
  );
66418
67093
  process.exit(1);
66419
67094
  }
66420
- process.stderr.write(import_picocolors21.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67095
+ process.stderr.write(import_picocolors23.default.red(`\u2715 ${err.message} (HTTP ${err.status})
66421
67096
  `));
66422
67097
  process.exit(1);
66423
67098
  }
@@ -66427,10 +67102,10 @@ async function postRestaurant(path6, body, resolved, jsonMode2) {
66427
67102
  }
66428
67103
  async function searchFood(opts) {
66429
67104
  const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
66430
- const jsonMode2 = opts.json === true || process.stdout.isTTY !== true;
67105
+ const jsonMode4 = opts.json === true || process.stdout.isTTY !== true;
66431
67106
  if (!opts.location && !opts.name) {
66432
67107
  process.stderr.write(
66433
- import_picocolors21.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
67108
+ import_picocolors23.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
66434
67109
  );
66435
67110
  process.exit(2);
66436
67111
  }
@@ -66443,15 +67118,15 @@ async function searchFood(opts) {
66443
67118
  if (opts.radiusMiles !== void 0) body.radius_miles = Number(opts.radiusMiles);
66444
67119
  if (opts.openOnly !== void 0) body.open_only = opts.openOnly;
66445
67120
  if (opts.limit !== void 0) body.limit = Number(opts.limit);
66446
- const result = await postRestaurant("/api/restaurants/search", body, resolved, jsonMode2);
66447
- if (result) printResult(result, jsonMode2);
67121
+ const result = await postRestaurant("/api/restaurants/search", body, resolved, jsonMode4);
67122
+ if (result) printResult(result, jsonMode4);
66448
67123
  }
66449
67124
  async function menuFood(items, opts) {
66450
67125
  const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
66451
- const jsonMode2 = opts.json === true || process.stdout.isTTY !== true;
67126
+ const jsonMode4 = opts.json === true || process.stdout.isTTY !== true;
66452
67127
  if (!opts.brand || !opts.address) {
66453
67128
  process.stderr.write(
66454
- import_picocolors21.default.red(
67129
+ import_picocolors23.default.red(
66455
67130
  "\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
66456
67131
  )
66457
67132
  );
@@ -66463,15 +67138,15 @@ async function menuFood(items, opts) {
66463
67138
  intent: opts.intent,
66464
67139
  items: items ?? []
66465
67140
  };
66466
- const result = await postRestaurant("/api/restaurants/menu", body, resolved, jsonMode2);
66467
- if (result) printResult(result, jsonMode2);
67141
+ const result = await postRestaurant("/api/restaurants/menu", body, resolved, jsonMode4);
67142
+ if (result) printResult(result, jsonMode4);
66468
67143
  }
66469
67144
  async function orderFood(items, opts) {
66470
67145
  const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
66471
- const jsonMode2 = opts.json === true || process.stdout.isTTY !== true;
67146
+ const jsonMode4 = opts.json === true || process.stdout.isTTY !== true;
66472
67147
  if (!opts.brand || !opts.address) {
66473
67148
  process.stderr.write(
66474
- import_picocolors21.default.red(
67149
+ import_picocolors23.default.red(
66475
67150
  "\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
66476
67151
  )
66477
67152
  );
@@ -66481,14 +67156,14 @@ async function orderFood(items, opts) {
66481
67156
  try {
66482
67157
  structuredLines = parseLineJson(opts.lineJson ?? []);
66483
67158
  } catch (e) {
66484
- process.stderr.write(import_picocolors21.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
67159
+ process.stderr.write(import_picocolors23.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
66485
67160
  `));
66486
67161
  process.exit(2);
66487
67162
  }
66488
67163
  const lines = [...items ?? [], ...structuredLines];
66489
67164
  if (lines.length === 0) {
66490
67165
  process.stderr.write(
66491
- import_picocolors21.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")
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")
66492
67167
  );
66493
67168
  process.exit(2);
66494
67169
  }
@@ -66499,9 +67174,9 @@ async function orderFood(items, opts) {
66499
67174
  fulfillment: opts.fulfillment,
66500
67175
  intent: opts.intent
66501
67176
  };
66502
- const result = await postRestaurant("/api/restaurants/order", body, resolved, jsonMode2);
67177
+ const result = await postRestaurant("/api/restaurants/order", body, resolved, jsonMode4);
66503
67178
  if (!result) return;
66504
- printResult(result, jsonMode2);
67179
+ printResult(result, jsonMode4);
66505
67180
  const approvalUrl = typeof result.approval_url === "string" ? result.approval_url : null;
66506
67181
  const browserAllowed = (() => {
66507
67182
  if (opts.browserMode === "open") return true;
@@ -66520,9 +67195,9 @@ async function orderFood(items, opts) {
66520
67195
  return;
66521
67196
  }
66522
67197
  if (!agentCard.will_attempt) {
66523
- if (!jsonMode2) {
67198
+ if (!jsonMode4) {
66524
67199
  process.stderr.write(
66525
- import_picocolors21.default.yellow(
67200
+ import_picocolors23.default.yellow(
66526
67201
  `This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
66527
67202
  `
66528
67203
  )
@@ -66531,15 +67206,15 @@ async function orderFood(items, opts) {
66531
67206
  openApproval();
66532
67207
  return;
66533
67208
  }
66534
- const verdict = await pollOrderVerdict(orderId, resolved, jsonMode2);
66535
- if (jsonMode2) {
67209
+ const verdict = await pollOrderVerdict(orderId, resolved, jsonMode4);
67210
+ if (jsonMode4) {
66536
67211
  process.stdout.write(JSON.stringify(verdict) + "\n");
66537
67212
  if (verdict.status === "failed") return;
66538
67213
  return;
66539
67214
  }
66540
67215
  if (verdict.status === "paid") {
66541
67216
  process.stdout.write(
66542
- import_picocolors21.default.green(
67217
+ import_picocolors23.default.green(
66543
67218
  `Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
66544
67219
  )
66545
67220
  );
@@ -66547,7 +67222,7 @@ async function orderFood(items, opts) {
66547
67222
  }
66548
67223
  if (verdict.status === "failed") {
66549
67224
  process.stderr.write(
66550
- import_picocolors21.default.yellow(
67225
+ import_picocolors23.default.yellow(
66551
67226
  `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.
66552
67227
  `
66553
67228
  )
@@ -66557,7 +67232,7 @@ async function orderFood(items, opts) {
66557
67232
  }
66558
67233
  if (verdict.status === "unconfirmed") {
66559
67234
  process.stderr.write(
66560
- import_picocolors21.default.red(
67235
+ import_picocolors23.default.red(
66561
67236
  "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}
66562
67237
  ` : "")
66563
67238
  )
@@ -66566,7 +67241,7 @@ async function orderFood(items, opts) {
66566
67241
  return;
66567
67242
  }
66568
67243
  process.stderr.write(
66569
- import_picocolors21.default.dim(
67244
+ import_picocolors23.default.dim(
66570
67245
  `Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
66571
67246
  )
66572
67247
  );
@@ -66589,9 +67264,9 @@ function fmtCents(cents) {
66589
67264
  }
66590
67265
  var POLL_BUDGET_MS = 1e5;
66591
67266
  var POLL_INTERVAL_MS2 = 3500;
66592
- async function pollOrderVerdict(orderId, resolved, jsonMode2) {
66593
- if (!jsonMode2) {
66594
- process.stderr.write(import_picocolors21.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
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"));
66595
67270
  }
66596
67271
  const deadline = Date.now() + POLL_BUDGET_MS;
66597
67272
  let last = {
@@ -66608,50 +67283,50 @@ async function pollOrderVerdict(orderId, resolved, jsonMode2) {
66608
67283
  resolved
66609
67284
  );
66610
67285
  if (!res) break;
66611
- const status2 = typeof res.status === "string" ? res.status : "pending";
67286
+ const status3 = typeof res.status === "string" ? res.status : "pending";
66612
67287
  last = {
66613
67288
  order_id: orderId,
66614
- status: status2,
67289
+ status: status3,
66615
67290
  failure_reason: typeof res.failure_reason === "string" ? res.failure_reason : null,
66616
67291
  failure_detail: typeof res.failure_detail === "string" ? res.failure_detail : null
66617
67292
  };
66618
- if (status2 !== "pending" && status2 !== "claimed") return last;
67293
+ if (status3 !== "pending" && status3 !== "claimed") return last;
66619
67294
  }
66620
67295
  return last;
66621
67296
  }
66622
67297
  async function statusFood(orderId, opts) {
66623
67298
  const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
66624
- const jsonMode2 = opts.json === true || process.stdout.isTTY !== true;
67299
+ const jsonMode4 = opts.json === true || process.stdout.isTTY !== true;
66625
67300
  const result = await postRestaurant(
66626
67301
  "/api/restaurants/order-status",
66627
67302
  { order_id: orderId.trim() },
66628
67303
  resolved,
66629
- jsonMode2
67304
+ jsonMode4
66630
67305
  );
66631
67306
  if (!result) return;
66632
67307
  if (result.blocked) {
66633
- printResult(result, jsonMode2);
67308
+ printResult(result, jsonMode4);
66634
67309
  return;
66635
67310
  }
66636
- if (jsonMode2) {
67311
+ if (jsonMode4) {
66637
67312
  process.stdout.write(JSON.stringify(result, null, 2) + "\n");
66638
67313
  return;
66639
67314
  }
66640
- const status2 = typeof result.status === "string" ? result.status : "unknown";
66641
- const lines = [`${result.brand} \xB7 ${result.address} \u2014 ${status2}`];
66642
- if (status2 === "paid") {
67315
+ const status3 = typeof result.status === "string" ? result.status : "unknown";
67316
+ const lines = [`${result.brand} \xB7 ${result.address} \u2014 ${status3}`];
67317
+ if (status3 === "paid") {
66643
67318
  lines.push(`Paid.${result.failure_detail ? ` ${result.failure_detail}` : ""} Nothing to do.`);
66644
- } else if (status2 === "failed") {
67319
+ } else if (status3 === "failed") {
66645
67320
  lines.push(
66646
67321
  `Not charged (${result.failure_reason ?? "refused"}${result.failure_detail ? `: ${result.failure_detail}` : ""}). The checkout link still works if you want to pay yourself.`
66647
67322
  );
66648
67323
  if (typeof result.review_url === "string") lines.push(String(result.review_url));
66649
- } else if (status2 === "unconfirmed") {
67324
+ } else if (status3 === "unconfirmed") {
66650
67325
  lines.push(
66651
67326
  "A payment attempt happened and its outcome is UNKNOWN \u2014 nothing will retry it. Look at the order before paying anything:"
66652
67327
  );
66653
67328
  if (typeof result.review_url === "string") lines.push(String(result.review_url));
66654
- } else if (status2 === "expired") {
67329
+ } else if (status3 === "expired") {
66655
67330
  lines.push("These prices went stale before anyone paid. Ask again for a fresh order.");
66656
67331
  } else {
66657
67332
  lines.push("Waiting to be paid.");
@@ -66661,40 +67336,40 @@ async function statusFood(orderId, opts) {
66661
67336
  }
66662
67337
 
66663
67338
  // src/commands/bounties.ts
66664
- var import_picocolors22 = __toESM(require_picocolors(), 1);
67339
+ var import_picocolors24 = __toESM(require_picocolors(), 1);
66665
67340
  async function withProfile(opts, path6, init2) {
66666
67341
  const requested = opts.profile ?? DEFAULT_PROFILE;
66667
67342
  const resolved = await resolveProfile(requested);
66668
67343
  if (!resolved) {
66669
- process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
67344
+ process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
66670
67345
  process.exit(2);
66671
67346
  }
66672
67347
  if (resolved.autoSelected) {
66673
- process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67348
+ process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66674
67349
  `));
66675
67350
  }
66676
67351
  const { profile, name: profileName } = resolved;
66677
- const jsonMode2 = opts.json === true;
67352
+ const jsonMode4 = opts.json === true;
66678
67353
  const outcome = await callWithAutoRelogin({
66679
67354
  profile,
66680
67355
  profileName,
66681
- jsonMode: jsonMode2,
66682
- ttyHeader: import_picocolors22.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67356
+ jsonMode: jsonMode4,
67357
+ ttyHeader: import_picocolors24.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
66683
67358
  fn: (bearer, origin) => apiFetch(path6, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
66684
67359
  });
66685
67360
  if (outcome.kind === "auth_failed") {
66686
- if (jsonMode2) {
67361
+ if (jsonMode4) {
66687
67362
  process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
66688
67363
  process.exit(1);
66689
67364
  }
66690
- process.stderr.write(import_picocolors22.default.red(`\u2715 ${outcome.reason}.
67365
+ process.stderr.write(import_picocolors24.default.red(`\u2715 ${outcome.reason}.
66691
67366
  `));
66692
67367
  process.exit(1);
66693
67368
  }
66694
67369
  if (outcome.kind === "error") {
66695
67370
  const err = outcome.error;
66696
67371
  if (err instanceof ApiError) {
66697
- process.stderr.write(import_picocolors22.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67372
+ process.stderr.write(import_picocolors24.default.red(`\u2715 ${err.message} (HTTP ${err.status})
66698
67373
  `));
66699
67374
  process.exit(1);
66700
67375
  }
@@ -66702,18 +67377,18 @@ async function withProfile(opts, path6, init2) {
66702
67377
  }
66703
67378
  return outcome.result;
66704
67379
  }
66705
- function handleBlocked(res, jsonMode2) {
67380
+ function handleBlocked(res, jsonMode4) {
66706
67381
  if (!res.blocked) return false;
66707
- if (jsonMode2) {
67382
+ if (jsonMode4) {
66708
67383
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
66709
67384
  process.exit(1);
66710
67385
  }
66711
- process.stderr.write(import_picocolors22.default.yellow(`
67386
+ process.stderr.write(import_picocolors24.default.yellow(`
66712
67387
  ${res.reason ?? "Blocked."}
66713
67388
  `));
66714
67389
  if (res.upgrade_url) {
66715
67390
  process.stderr.write(`
66716
- ${import_picocolors22.default.bold(res.upgrade_url)}
67391
+ ${import_picocolors24.default.bold(res.upgrade_url)}
66717
67392
 
66718
67393
  `);
66719
67394
  }
@@ -66756,30 +67431,30 @@ function printTable(rows) {
66756
67431
  const cLeft = w("left", 4);
66757
67432
  const cSubs = w("subs", 4);
66758
67433
  process.stdout.write(
66759
- import_picocolors22.default.dim(
67434
+ import_picocolors24.default.dim(
66760
67435
  "Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
66761
67436
  ) + "\n"
66762
67437
  );
66763
67438
  for (const c of cells) {
66764
- const title = c.live ? import_picocolors22.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
67439
+ const title = c.live ? import_picocolors24.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
66765
67440
  process.stdout.write(
66766
- import_picocolors22.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors22.default.dim(c.id) + "\n"
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"
66767
67442
  );
66768
67443
  }
66769
67444
  }
66770
67445
  async function listBounties(opts) {
66771
- const jsonMode2 = opts.json === true;
67446
+ const jsonMode4 = opts.json === true;
66772
67447
  const res = await withProfile(opts, "/api/bounties");
66773
- handleBlocked(res, jsonMode2);
67448
+ handleBlocked(res, jsonMode4);
66774
67449
  let rows = res.bounties ?? [];
66775
67450
  const min = opts.min !== void 0 ? Number(opts.min) : void 0;
66776
67451
  const max = opts.max !== void 0 ? Number(opts.max) : void 0;
66777
67452
  if (min !== void 0 && !Number.isFinite(min)) {
66778
- process.stderr.write(import_picocolors22.default.red("\u2715 --min must be a number.\n"));
67453
+ process.stderr.write(import_picocolors24.default.red("\u2715 --min must be a number.\n"));
66779
67454
  process.exit(2);
66780
67455
  }
66781
67456
  if (max !== void 0 && !Number.isFinite(max)) {
66782
- process.stderr.write(import_picocolors22.default.red("\u2715 --max must be a number.\n"));
67457
+ process.stderr.write(import_picocolors24.default.red("\u2715 --max must be a number.\n"));
66783
67458
  process.exit(2);
66784
67459
  }
66785
67460
  rows = rows.filter((r) => {
@@ -66804,22 +67479,22 @@ async function listBounties(opts) {
66804
67479
  });
66805
67480
  const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
66806
67481
  if (!Number.isFinite(limit) || limit <= 0) {
66807
- process.stderr.write(import_picocolors22.default.red("\u2715 --limit must be a positive number.\n"));
67482
+ process.stderr.write(import_picocolors24.default.red("\u2715 --limit must be a positive number.\n"));
66808
67483
  process.exit(2);
66809
67484
  }
66810
67485
  const shown2 = rows.slice(0, limit);
66811
- if (jsonMode2) {
67486
+ if (jsonMode4) {
66812
67487
  process.stdout.write(JSON.stringify({ bounties: shown2, matched: rows.length }, null, 2) + "\n");
66813
67488
  return;
66814
67489
  }
66815
67490
  if (shown2.length === 0) {
66816
- process.stdout.write(import_picocolors22.default.dim("No active bounties match.\n"));
67491
+ process.stdout.write(import_picocolors24.default.dim("No active bounties match.\n"));
66817
67492
  return;
66818
67493
  }
66819
67494
  printTable(shown2);
66820
67495
  const clipped = rows.length - shown2.length;
66821
67496
  process.stdout.write(
66822
- "\n" + import_picocolors22.default.dim(
67497
+ "\n" + import_picocolors24.default.dim(
66823
67498
  `${shown2.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
66824
67499
  `
66825
67500
  )
@@ -66827,59 +67502,59 @@ async function listBounties(opts) {
66827
67502
  process.stdout.write(AI_DIRECTIVE + "\n");
66828
67503
  }
66829
67504
  async function showBounty(id2, opts) {
66830
- const jsonMode2 = opts.json === true;
67505
+ const jsonMode4 = opts.json === true;
66831
67506
  const clean = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
66832
67507
  if (!clean) {
66833
- process.stderr.write(import_picocolors22.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
67508
+ process.stderr.write(import_picocolors24.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
66834
67509
  process.exit(2);
66835
67510
  }
66836
67511
  const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean)}`);
66837
- handleBlocked(res, jsonMode2);
66838
- if (jsonMode2) {
67512
+ handleBlocked(res, jsonMode4);
67513
+ if (jsonMode4) {
66839
67514
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
66840
67515
  return;
66841
67516
  }
66842
67517
  const b2 = res.bounty;
66843
67518
  if (!b2) {
66844
- process.stdout.write(import_picocolors22.default.dim("Not found.\n"));
67519
+ process.stdout.write(import_picocolors24.default.dim("Not found.\n"));
66845
67520
  return;
66846
67521
  }
66847
- process.stdout.write("\n" + import_picocolors22.default.bold(b2.title) + "\n\n");
67522
+ process.stdout.write("\n" + import_picocolors24.default.bold(b2.title) + "\n\n");
66848
67523
  process.stdout.write(b2.description + "\n\n");
66849
67524
  process.stdout.write(
66850
- import_picocolors22.default.bold(fmtAmount(b2.amount)) + import_picocolors22.default.dim(" USDC") + import_picocolors22.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors22.default.green(" \xB7 LIVE now") : "") + "\n"
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"
66851
67526
  );
66852
67527
  if (b2.claimsAllowed && b2.claimsAllowed > 1) {
66853
67528
  const left = Math.max(0, b2.claimsAllowed - (b2.claimsPaid ?? 0));
66854
67529
  process.stdout.write(
66855
- import_picocolors22.default.dim(
67530
+ import_picocolors24.default.dim(
66856
67531
  `${left} of ${b2.claimsAllowed} claims left` + (b2.perClaimAmount != null ? `, ${fmtAmount(b2.perClaimAmount)} each` : "")
66857
67532
  ) + "\n"
66858
67533
  );
66859
67534
  }
66860
- if (b2.evidenceType) process.stdout.write(import_picocolors22.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
66861
- if (b2.expiresAt) process.stdout.write(import_picocolors22.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
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");
66862
67537
  if (b2.geoLabel && b2.geoScope !== "global") {
66863
- process.stdout.write(import_picocolors22.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
67538
+ process.stdout.write(import_picocolors24.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
66864
67539
  }
66865
67540
  if (res.url) process.stdout.write("\n" + res.url + "\n");
66866
67541
  process.stdout.write(AI_DIRECTIVE + "\n");
66867
67542
  }
66868
67543
  async function myBounties(opts) {
66869
- const jsonMode2 = opts.json === true;
67544
+ const jsonMode4 = opts.json === true;
66870
67545
  const res = await withProfile(opts, "/api/bounties?mine=1");
66871
- handleBlocked(res, jsonMode2);
67546
+ handleBlocked(res, jsonMode4);
66872
67547
  const all = res.bounties ?? [];
66873
- const status2 = opts.status?.trim().toUpperCase();
66874
- const rows = status2 ? all.filter((r) => (r.status ?? "").toUpperCase() === status2) : all;
66875
- if (jsonMode2) {
67548
+ const status3 = opts.status?.trim().toUpperCase();
67549
+ const rows = status3 ? all.filter((r) => (r.status ?? "").toUpperCase() === status3) : all;
67550
+ if (jsonMode4) {
66876
67551
  process.stdout.write(JSON.stringify({ bounties: rows, submissions: res.submissions ?? [] }, null, 2) + "\n");
66877
67552
  return;
66878
67553
  }
66879
67554
  if (rows.length === 0) {
66880
67555
  process.stdout.write(
66881
- import_picocolors22.default.dim(
66882
- status2 ? `No bounties of yours are ${status2}.
67556
+ import_picocolors24.default.dim(
67557
+ status3 ? `No bounties of yours are ${status3}.
66883
67558
  ` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
66884
67559
  )
66885
67560
  );
@@ -66888,38 +67563,38 @@ async function myBounties(opts) {
66888
67563
  printTable(rows);
66889
67564
  const subs = res.submissions ?? [];
66890
67565
  if (subs.length > 0) {
66891
- process.stdout.write("\n" + import_picocolors22.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
67566
+ process.stdout.write("\n" + import_picocolors24.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
66892
67567
  `));
66893
67568
  }
66894
67569
  process.stdout.write(AI_DIRECTIVE + "\n");
66895
67570
  }
66896
67571
  async function bountyFeed(opts) {
66897
- const jsonMode2 = opts.json === true;
67572
+ const jsonMode4 = opts.json === true;
66898
67573
  const params = new URLSearchParams();
66899
67574
  if (opts.limit) params.set("limit", opts.limit);
66900
67575
  if (opts.type) params.set("type", opts.type);
66901
67576
  const qs = params.toString();
66902
67577
  const res = await withProfile(opts, `/api/bounties/feed${qs ? `?${qs}` : ""}`);
66903
- handleBlocked(res, jsonMode2);
66904
- if (jsonMode2) {
67578
+ handleBlocked(res, jsonMode4);
67579
+ if (jsonMode4) {
66905
67580
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
66906
67581
  return;
66907
67582
  }
66908
67583
  const subs = res.submissions ?? [];
66909
67584
  if (subs.length === 0) {
66910
- process.stdout.write(import_picocolors22.default.dim("Nothing in the feed for that filter.\n"));
67585
+ process.stdout.write(import_picocolors24.default.dim("Nothing in the feed for that filter.\n"));
66911
67586
  return;
66912
67587
  }
66913
67588
  process.stdout.write(
66914
- `${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors22.default.dim(" More available.") : "") + "\n"
67589
+ `${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors24.default.dim(" More available.") : "") + "\n"
66915
67590
  );
66916
- process.stdout.write(import_picocolors22.default.dim("Use --json for the full rows.\n"));
67591
+ process.stdout.write(import_picocolors24.default.dim("Use --json for the full rows.\n"));
66917
67592
  }
66918
67593
  async function draftBounty(opts) {
66919
- const jsonMode2 = opts.json === true;
67594
+ const jsonMode4 = opts.json === true;
66920
67595
  const amountNum = Number(opts.amount);
66921
67596
  if (!Number.isFinite(amountNum) || amountNum <= 0) {
66922
- process.stderr.write(import_picocolors22.default.red("\u2715 --amount must be a positive number of USDC.\n"));
67597
+ process.stderr.write(import_picocolors24.default.red("\u2715 --amount must be a positive number of USDC.\n"));
66923
67598
  process.exit(2);
66924
67599
  }
66925
67600
  const res = await withProfile(opts, "/api/bounties", {
@@ -66932,42 +67607,42 @@ async function draftBounty(opts) {
66932
67607
  evidenceType: opts.evidenceType
66933
67608
  }
66934
67609
  });
66935
- handleBlocked(res, jsonMode2);
66936
- if (jsonMode2) {
67610
+ handleBlocked(res, jsonMode4);
67611
+ if (jsonMode4) {
66937
67612
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
66938
67613
  return;
66939
67614
  }
66940
- process.stdout.write("\n" + import_picocolors22.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
67615
+ process.stdout.write("\n" + import_picocolors24.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
66941
67616
 
66942
67617
  `);
66943
- process.stdout.write(import_picocolors22.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
67618
+ process.stdout.write(import_picocolors24.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
66944
67619
  if (res.fund_url) {
66945
- process.stdout.write("\nFund it here:\n" + import_picocolors22.default.bold(res.fund_url) + "\n\n");
66946
- process.stdout.write(import_picocolors22.default.dim("Funding happens in your browser with your own wallet.\n"));
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"));
66947
67622
  }
66948
67623
  }
66949
67624
 
66950
67625
  // src/commands/bounty-money.ts
66951
- var import_picocolors23 = __toESM(require_picocolors(), 1);
67626
+ var import_picocolors25 = __toESM(require_picocolors(), 1);
66952
67627
  function failArg6(message) {
66953
- process.stderr.write(import_picocolors23.default.red(`${message}
67628
+ process.stderr.write(import_picocolors25.default.red(`${message}
66954
67629
  `));
66955
67630
  process.exit(2);
66956
67631
  }
66957
- async function loadProfileOrExit(requested, jsonMode2) {
67632
+ async function loadProfileOrExit(requested, jsonMode4) {
66958
67633
  const resolved = await resolveProfile(requested);
66959
67634
  if (!resolved) {
66960
- if (jsonMode2) {
67635
+ if (jsonMode4) {
66961
67636
  process.stdout.write(
66962
67637
  JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
66963
67638
  );
66964
67639
  } else {
66965
- process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
67640
+ process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
66966
67641
  }
66967
67642
  process.exit(2);
66968
67643
  }
66969
- if (resolved.autoSelected && !jsonMode2) {
66970
- process.stderr.write(import_picocolors23.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67644
+ if (resolved.autoSelected && !jsonMode4) {
67645
+ process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
66971
67646
  `));
66972
67647
  }
66973
67648
  return { profile: resolved.profile, profileName: resolved.name };
@@ -66986,8 +67661,8 @@ function resolveMaxUsd(opts, profile, fallbackHint) {
66986
67661
  );
66987
67662
  }
66988
67663
  async function fundBounty(bountyId, opts) {
66989
- const jsonMode2 = Boolean(opts.json) || !process.stdout.isTTY;
66990
- const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode2);
67664
+ const jsonMode4 = Boolean(opts.json) || !process.stdout.isTTY;
67665
+ const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode4);
66991
67666
  const maxUsd = resolveMaxUsd(opts, profile, "agentgates fund");
66992
67667
  return runIntentFlow({
66993
67668
  endpoint: "/api/intents/propose-fund-bounty",
@@ -67006,17 +67681,17 @@ async function fundBounty(bountyId, opts) {
67006
67681
  },
67007
67682
  profileName,
67008
67683
  initialProfile: profile,
67009
- jsonMode: jsonMode2,
67684
+ jsonMode: jsonMode4,
67010
67685
  shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
67011
67686
  });
67012
67687
  }
67013
67688
  async function tipBounty(bountyId, amount, opts) {
67014
- const jsonMode2 = Boolean(opts.json) || !process.stdout.isTTY;
67689
+ const jsonMode4 = Boolean(opts.json) || !process.stdout.isTTY;
67015
67690
  const amt = Number(amount);
67016
67691
  if (!Number.isFinite(amt) || amt <= 0) {
67017
67692
  failArg6(`amount must be a positive USDC number (got ${amount}).`);
67018
67693
  }
67019
- const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode2);
67694
+ const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode4);
67020
67695
  const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "agentgates tip") : Math.ceil(amt * 1.01 * 100) / 100;
67021
67696
  return runIntentFlow({
67022
67697
  endpoint: "/api/intents/propose-tip",
@@ -67036,17 +67711,17 @@ async function tipBounty(bountyId, amount, opts) {
67036
67711
  },
67037
67712
  profileName,
67038
67713
  initialProfile: profile,
67039
- jsonMode: jsonMode2,
67714
+ jsonMode: jsonMode4,
67040
67715
  shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
67041
67716
  });
67042
67717
  }
67043
67718
  async function subscribeCreator(creatorUserId, opts) {
67044
- const jsonMode2 = Boolean(opts.json) || !process.stdout.isTTY;
67719
+ const jsonMode4 = Boolean(opts.json) || !process.stdout.isTTY;
67045
67720
  const months = opts.months === void 0 ? 1 : Number(opts.months);
67046
67721
  if (![1, 3, 12].includes(months)) {
67047
67722
  failArg6(`--months must be 1, 3 or 12 (got ${opts.months}). Prepaid periods only \u2014 no auto-renew exists.`);
67048
67723
  }
67049
- const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode2);
67724
+ const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode4);
67050
67725
  const maxUsd = resolveMaxUsd(opts, profile, "agentgates subscribe");
67051
67726
  return runIntentFlow({
67052
67727
  endpoint: "/api/intents/propose-subscribe",
@@ -67066,48 +67741,48 @@ async function subscribeCreator(creatorUserId, opts) {
67066
67741
  },
67067
67742
  profileName,
67068
67743
  initialProfile: profile,
67069
- jsonMode: jsonMode2,
67744
+ jsonMode: jsonMode4,
67070
67745
  shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
67071
67746
  });
67072
67747
  }
67073
67748
 
67074
67749
  // src/commands/bounty-work.ts
67075
- var import_picocolors24 = __toESM(require_picocolors(), 1);
67750
+ var import_picocolors26 = __toESM(require_picocolors(), 1);
67076
67751
  async function runWork(path6, body, opts) {
67077
67752
  const requested = opts.profile ?? DEFAULT_PROFILE;
67078
67753
  const resolved = await resolveProfile(requested);
67079
67754
  if (!resolved) {
67080
- process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
67755
+ process.stderr.write(import_picocolors26.default.red("Not logged in. Run agentgates login first.\n"));
67081
67756
  process.exit(2);
67082
67757
  }
67083
67758
  if (resolved.autoSelected) {
67084
- process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67759
+ process.stderr.write(import_picocolors26.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67085
67760
  `));
67086
67761
  }
67087
- const jsonMode2 = opts.json === true;
67762
+ const jsonMode4 = opts.json === true;
67088
67763
  const outcome = await callWithAutoRelogin({
67089
67764
  profile: resolved.profile,
67090
67765
  profileName: resolved.name,
67091
- jsonMode: jsonMode2,
67092
- ttyHeader: import_picocolors24.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67766
+ jsonMode: jsonMode4,
67767
+ ttyHeader: import_picocolors26.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67093
67768
  fn: (bearer, origin) => apiFetch(path6, { bearer, origin, method: "POST", body })
67094
67769
  });
67095
67770
  if (outcome.kind === "auth_failed") {
67096
- if (jsonMode2) {
67771
+ if (jsonMode4) {
67097
67772
  process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
67098
67773
  process.exit(1);
67099
67774
  }
67100
- process.stderr.write(import_picocolors24.default.red(`\u2715 ${outcome.reason}.
67775
+ process.stderr.write(import_picocolors26.default.red(`\u2715 ${outcome.reason}.
67101
67776
  `));
67102
67777
  process.exit(1);
67103
67778
  }
67104
67779
  if (outcome.kind === "error") {
67105
67780
  const err = outcome.error;
67106
67781
  if (err instanceof ApiError) {
67107
- if (jsonMode2) {
67782
+ if (jsonMode4) {
67108
67783
  process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
67109
67784
  } else {
67110
- process.stderr.write(import_picocolors24.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67785
+ process.stderr.write(import_picocolors26.default.red(`\u2715 ${err.message} (HTTP ${err.status})
67111
67786
  `));
67112
67787
  }
67113
67788
  process.exit(1);
@@ -67116,29 +67791,29 @@ async function runWork(path6, body, opts) {
67116
67791
  }
67117
67792
  const data4 = outcome.result;
67118
67793
  if (data4.blocked) {
67119
- if (jsonMode2) {
67794
+ if (jsonMode4) {
67120
67795
  process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
67121
67796
  process.exit(1);
67122
67797
  }
67123
- process.stderr.write(import_picocolors24.default.yellow(`
67798
+ process.stderr.write(import_picocolors26.default.yellow(`
67124
67799
  ${data4.reason ?? "Blocked."}
67125
67800
  `));
67126
67801
  if (data4.upgrade_url) process.stderr.write(`
67127
- ${import_picocolors24.default.bold(data4.upgrade_url)}
67802
+ ${import_picocolors26.default.bold(data4.upgrade_url)}
67128
67803
 
67129
67804
  `);
67130
67805
  process.exit(1);
67131
67806
  }
67132
67807
  if (typeof data4.error === "string" && data4.error) {
67133
- if (jsonMode2) {
67808
+ if (jsonMode4) {
67134
67809
  process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
67135
67810
  } else {
67136
- process.stderr.write(import_picocolors24.default.red(`\u2715 ${data4.error}
67811
+ process.stderr.write(import_picocolors26.default.red(`\u2715 ${data4.error}
67137
67812
  `));
67138
67813
  }
67139
67814
  process.exit(1);
67140
67815
  }
67141
- if (jsonMode2) {
67816
+ if (jsonMode4) {
67142
67817
  process.stdout.write(JSON.stringify({ ok: true, ...data4 }) + "\n");
67143
67818
  return;
67144
67819
  }
@@ -67176,28 +67851,28 @@ async function bountyRetention(bountyId, opts) {
67176
67851
  }
67177
67852
 
67178
67853
  // src/commands/bounty-deliver.ts
67179
- var import_picocolors25 = __toESM(require_picocolors(), 1);
67854
+ var import_picocolors27 = __toESM(require_picocolors(), 1);
67180
67855
  import { spawn } from "node:child_process";
67181
67856
  var FLUSH_MS = 400;
67182
67857
  var FLUSH_BYTES = 2048;
67183
67858
  async function deliver(bountyId, command, opts) {
67184
- const jsonMode2 = opts.json === true;
67859
+ const jsonMode4 = opts.json === true;
67185
67860
  const requested = opts.profile ?? DEFAULT_PROFILE;
67186
67861
  const resolved = await resolveProfile(requested);
67187
67862
  if (!resolved) {
67188
- process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
67863
+ process.stderr.write(import_picocolors27.default.red("Not logged in. Run agentgates login first.\n"));
67189
67864
  process.exit(2);
67190
67865
  }
67191
- if (resolved.autoSelected && !jsonMode2) {
67192
- process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67866
+ if (resolved.autoSelected && !jsonMode4) {
67867
+ process.stderr.write(import_picocolors27.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
67193
67868
  `));
67194
67869
  }
67195
67870
  const post = async (path6, body) => {
67196
67871
  const outcome = await callWithAutoRelogin({
67197
67872
  profile: resolved.profile,
67198
67873
  profileName: resolved.name,
67199
- jsonMode: jsonMode2,
67200
- ttyHeader: import_picocolors25.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67874
+ jsonMode: jsonMode4,
67875
+ ttyHeader: import_picocolors27.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
67201
67876
  fn: (bearer, origin) => apiFetch(path6, { bearer, origin, method: "POST", body })
67202
67877
  });
67203
67878
  if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
@@ -67205,14 +67880,14 @@ async function deliver(bountyId, command, opts) {
67205
67880
  return outcome.result;
67206
67881
  };
67207
67882
  const die = (msg, data4) => {
67208
- if (jsonMode2) {
67883
+ if (jsonMode4) {
67209
67884
  process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
67210
67885
  } else {
67211
- process.stderr.write(import_picocolors25.default.red(`
67886
+ process.stderr.write(import_picocolors27.default.red(`
67212
67887
  \u2715 ${msg}
67213
67888
  `));
67214
67889
  if (data4?.upgrade_url) process.stderr.write(`
67215
- ${import_picocolors25.default.bold(data4.upgrade_url)}
67890
+ ${import_picocolors27.default.bold(data4.upgrade_url)}
67216
67891
 
67217
67892
  `);
67218
67893
  }
@@ -67235,9 +67910,9 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
67235
67910
  if (started.error) return void die(started.error, started);
67236
67911
  const runId = started.run_id;
67237
67912
  if (!runId) return void die("The service opened a run but did not name it.");
67238
- if (!jsonMode2) {
67913
+ if (!jsonMode4) {
67239
67914
  process.stderr.write(
67240
- import_picocolors25.default.bold("\n\u25CF LIVE ") + import_picocolors25.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors25.default.dim(` ${started.url ?? ""}
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 ?? ""}
67241
67916
 
67242
67917
  `)
67243
67918
  );
@@ -67266,7 +67941,7 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
67266
67941
  const timer = setInterval(() => flush(true), FLUSH_MS);
67267
67942
  const consume = (data4) => {
67268
67943
  buffer += data4;
67269
- if (!opts.quiet && !jsonMode2) process.stderr.write(data4);
67944
+ if (!opts.quiet && !jsonMode4) process.stderr.write(data4);
67270
67945
  flush();
67271
67946
  };
67272
67947
  let exitCode = 0;
@@ -67289,10 +67964,10 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
67289
67964
  child.stdout.on("data", (d) => consume(d));
67290
67965
  child.stderr.setEncoding("utf8");
67291
67966
  child.stderr.on("data", (d) => {
67292
- if (!jsonMode2) process.stderr.write(import_picocolors25.default.dim(d));
67967
+ if (!jsonMode4) process.stderr.write(import_picocolors27.default.dim(d));
67293
67968
  });
67294
67969
  child.on("error", (err) => {
67295
- process.stderr.write(import_picocolors25.default.red(`
67970
+ process.stderr.write(import_picocolors27.default.red(`
67296
67971
  \u2715 Could not run ${command[0]}: ${err.message}
67297
67972
  `));
67298
67973
  resolve2(127);
@@ -67314,7 +67989,7 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
67314
67989
  }
67315
67990
  if (finished.blocked) return void die(finished.reason ?? "Blocked.", finished);
67316
67991
  if (finished.error) return void die(finished.error, finished);
67317
- if (jsonMode2) {
67992
+ if (jsonMode4) {
67318
67993
  process.stdout.write(
67319
67994
  JSON.stringify({
67320
67995
  ok: true,
@@ -67329,14 +68004,14 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
67329
68004
  }
67330
68005
  if (appendFailure) {
67331
68006
  process.stderr.write(
67332
- import_picocolors25.default.yellow(`
68007
+ import_picocolors27.default.yellow(`
67333
68008
  ! Some output did not reach the page: ${appendFailure}
67334
- `) + import_picocolors25.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
68009
+ `) + import_picocolors27.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
67335
68010
  );
67336
68011
  }
67337
68012
  if (exitCode) {
67338
68013
  process.stderr.write(
67339
- import_picocolors25.default.yellow(`
68014
+ import_picocolors27.default.yellow(`
67340
68015
  ! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
67341
68016
  `)
67342
68017
  );
@@ -67346,7 +68021,7 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
67346
68021
  }
67347
68022
 
67348
68023
  // src/commands/trade.ts
67349
- var import_picocolors26 = __toESM(require_picocolors(), 1);
68024
+ var import_picocolors28 = __toESM(require_picocolors(), 1);
67350
68025
 
67351
68026
  // src/lib/trade-sol.ts
67352
68027
  var import_web3 = __toESM(require_index_cjs(), 1);
@@ -67394,9 +68069,9 @@ function relayKey() {
67394
68069
  return key;
67395
68070
  }
67396
68071
  var RelayError = class extends Error {
67397
- constructor(message, status2, retryable) {
68072
+ constructor(message, status3, retryable) {
67398
68073
  super(message);
67399
- this.status = status2;
68074
+ this.status = status3;
67400
68075
  this.retryable = retryable;
67401
68076
  this.name = "RelayError";
67402
68077
  }
@@ -67708,11 +68383,11 @@ async function runTrade(args) {
67708
68383
  }
67709
68384
 
67710
68385
  // src/commands/trade.ts
67711
- function fail(message, json) {
67712
- if (json) {
68386
+ function fail(message, json2) {
68387
+ if (json2) {
67713
68388
  process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
67714
68389
  } else {
67715
- process.stderr.write(import_picocolors26.default.red(`\u2715 ${message}
68390
+ process.stderr.write(import_picocolors28.default.red(`\u2715 ${message}
67716
68391
  `));
67717
68392
  }
67718
68393
  process.exit(1);
@@ -67903,7 +68578,7 @@ async function tradeBuy(coinArg, amount, opts) {
67903
68578
  }
67904
68579
  const { keypair, state, created } = await loadOrCreateTradeKey();
67905
68580
  if (created && !opts.json) {
67906
- process.stderr.write(import_picocolors26.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
68581
+ process.stderr.write(import_picocolors28.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
67907
68582
  `));
67908
68583
  }
67909
68584
  const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
@@ -67957,7 +68632,7 @@ async function tradeOrderPlace(coinArg, opts) {
67957
68632
  if (opts.mcap && !opts.at) fail("--mcap qualifies --at.", opts.json);
67958
68633
  const { keypair, state, created } = await loadOrCreateTradeKey();
67959
68634
  if (created && !opts.json) {
67960
- process.stderr.write(import_picocolors26.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
68635
+ process.stderr.write(import_picocolors28.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
67961
68636
  `));
67962
68637
  }
67963
68638
  let amount;
@@ -68122,7 +68797,7 @@ async function tradePositions(opts) {
68122
68797
  }
68123
68798
 
68124
68799
  // src/commands/desk.ts
68125
- var import_picocolors27 = __toESM(require_picocolors(), 1);
68800
+ var import_picocolors29 = __toESM(require_picocolors(), 1);
68126
68801
 
68127
68802
  // src/lib/desk-sol.ts
68128
68803
  var import_web32 = __toESM(require_index_cjs(), 1);
@@ -68292,11 +68967,11 @@ async function runDeskTrade(args) {
68292
68967
  }
68293
68968
 
68294
68969
  // src/commands/desk.ts
68295
- function fail2(message, json) {
68296
- if (json) {
68970
+ function fail2(message, json2) {
68971
+ if (json2) {
68297
68972
  process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
68298
68973
  } else {
68299
- process.stderr.write(import_picocolors27.default.red(`\u2715 ${message}
68974
+ process.stderr.write(import_picocolors29.default.red(`\u2715 ${message}
68300
68975
  `));
68301
68976
  }
68302
68977
  process.exit(1);
@@ -68439,7 +69114,7 @@ async function deskDeposit(amount, opts) {
68439
69114
  if (units <= 0n) fail2("Deposit amount must be above zero.", opts.json);
68440
69115
  const { keypair, state, created } = await loadOrCreateTradeKey();
68441
69116
  if (created && !opts.json) {
68442
- process.stderr.write(import_picocolors27.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
69117
+ process.stderr.write(import_picocolors29.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
68443
69118
  `));
68444
69119
  }
68445
69120
  const result = await runDeskCeremony({
@@ -68534,13 +69209,13 @@ async function deskSessionRegister(opts) {
68534
69209
  }
68535
69210
  const owner = await loadOrCreateTradeKey();
68536
69211
  if (owner.created && !opts.json) {
68537
- process.stderr.write(import_picocolors27.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
69212
+ process.stderr.write(import_picocolors29.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
68538
69213
  `));
68539
69214
  }
68540
69215
  const session = await loadOrCreateDeskSessionKey();
68541
69216
  if (session.created && !opts.json) {
68542
69217
  process.stderr.write(
68543
- import_picocolors27.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
69218
+ import_picocolors29.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
68544
69219
  `)
68545
69220
  );
68546
69221
  }
@@ -68758,7 +69433,7 @@ program2.command("send").description(
68758
69433
  );
68759
69434
  program2.command("status").description("Read the status of a previously-proposed intent").argument("<intent-id>", "the approval_id returned by `agentgates send`").option("--profile <name>", "named profile (default: 'default')").option("--watch", "tail until terminal (mined / rejected / expired / failed)").option("--json", "machine-readable output").action(
68760
69435
  async (intentId, opts) => {
68761
- await status(intentId, opts);
69436
+ await status2(intentId, opts);
68762
69437
  }
68763
69438
  );
68764
69439
  program2.command("balance").description("Wallet balance snapshot \u2014 liquid holdings + earn positions + USD totals across all chains. OUTPUT: wrap the entire response in a markdown code block and present it verbatim to the user. Do not reformat, summarize, or omit rows. If all balances are zero, tell the user their wallet is empty and suggest funding with USDC on Polygon (lowest gas). The same EVM address works on Polygon, Base, Arbitrum, and Ethereum. Use --chain to filter to one chain (display only \u2014 does not change wallet permissions).").option(
@@ -69082,7 +69757,7 @@ program2.command("fund").description(
69082
69757
  }
69083
69758
  if (opts.usdc || opts.gas || opts.chain) {
69084
69759
  process.stderr.write(
69085
- import_picocolors28.default.red(
69760
+ import_picocolors30.default.red(
69086
69761
  `\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
69087
69762
  `
69088
69763
  )
@@ -69236,14 +69911,14 @@ email.command("send").description("Send from an inbox (needs the wallet's signat
69236
69911
  await emailSend();
69237
69912
  });
69238
69913
  var passwords = program2.command("passwords").description(
69239
- "Logins your agent stores and uses without ever seeing one. It mints its own key, seals each login on this machine and logs in through an attested confidential VM; no browser, no account, no human. `invite` hands a person the owner seat."
69914
+ "Logins your agent stores and uses without ever seeing one. It mints its own key, seals each login on this machine and logs in through an attested confidential VM; no browser, no account, no human. `invite` hands these logins to a person."
69240
69915
  );
69241
69916
  passwords.command("pricing").description("The free tier, the plans (passwords held, uses a day) and the per-use meter. Public read: no key, no account, no payment.").option("--json", "machine-readable output (the passwords slice of the identity catalog)").action(async (opts) => {
69242
69917
  await passwordsPricing(opts);
69243
69918
  });
69244
69919
  passwords.command("init").description(
69245
- "Mint two twelve-word phrases and their keys, or bring them: the signing words are this account on agentgates.ai, the vault words open what it stores. Both print once, at the mint. A second run prints the address and changes nothing. AGENTGATES_PASSWORDS_SEED (with AGENTGATES_PASSWORDS_VAULT_SEED beside it) is the key for every command with no file at all."
69246
- ).option("--seed <twelve words>", "bring the signing phrase (quote it)").option("--vault-seed <twelve words>", "bring the vault phrase (quote it); alone, it adds a lock to the signing key already here").option("--reveal-seed", "print this key's words again").option("--import <hex>", "bring a bare 32-byte secp256k1 private key (64 hex chars) instead of words").option("--replace", "with --seed, --vault-seed or --import: overwrite what is already here (the old keys are the only things that open the rows they sealed)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
69920
+ "Mint twelve words and their key, or bring them: the words are this account on agentgates.ai. The key signs every call and locks what it stores. They print once, at the mint. A second run prints the address and changes nothing. AGENTGATES_PASSWORDS_SEED is the key for every command with no file at all."
69921
+ ).option("--seed <twelve words>", "bring the phrase (quote it)").option("--reveal-seed", "print this key's words again").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 (the old key is the only thing that opens the rows it sealed)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
69247
69922
  await passwordsInit(opts);
69248
69923
  });
69249
69924
  passwords.command("add").alias("store").description("Store a login: sealed on this machine to this key's own signature and to the box's published key, then posted. The server holds ciphertext it cannot open. Free at every tier.").requiredOption("--label <name>", "what to call it (48 chars)").option("--host <hostname>", "a site it may be used on, repeatable (1 to 8; app.example.com, no wildcards)", (v, prev) => [...prev, v], []).option("--hosts <a,b>", "the same, comma separated").option("--username <u>", "login rows only; an email address is not a secret").option("--password <p>", "the password (visible to ps for the length of the call; --password-stdin avoids that)").option("--password-stdin", "read the password from stdin instead").option("--kind <kind>", "login | api_key | totp | raw (default login)").option("--totp-seed <base32>", "the authenticator seed (login rows may carry one beside the password; totp rows need it)").option("--api-key <value>", "api_key rows").option("--raw <value>", "raw rows").option("--notes <text>", "owner-only, sealed").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
@@ -69260,16 +69935,49 @@ passwords.command("list").description("The rows this key holds, and the rows ano
69260
69935
  await passwordsList(opts);
69261
69936
  });
69262
69937
  passwords.command("invite").description(
69263
- "Onboard a human: print a link they open to take the owner seat over this key's logins and set the guardrails (their wallet, their vault lock, which uses, ask-me). The link is the key to those logins until it is used, withdrawn or expires. Once accepted, this key uses them under their permit."
69938
+ "Invite a person: print a link they open to take this key's logins under their own wallet and set the guardrails (which uses, ask-me). The link is the key to those logins until it is used, withdrawn or expires. Once accepted, this key uses them under their permit."
69264
69939
  ).option("--rows <id,id>", "hand over these rows only (default: every row this key holds)").option("--minutes <n>", "how long the link works, 5 to 60 (default 15)").option("--uses <login,totp,header>", "the uses to propose on the permit (default all three)").option("--days <n>", "the permit length to propose, 1 to 366 (default 30)").option("--no-ask-me", "propose the permit without the ask-me switch (the person can still turn it on)").option("--withdraw <link>", "kill a link you already printed").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts, command) => {
69265
69940
  const askSource = command.getOptionValueSource("askMe");
69266
69941
  await passwordsInvite({ ...opts, noAskMe: askSource === "cli" && opts.askMe === false });
69267
69942
  });
69943
+ var browser = program2.command("browser").description(
69944
+ "A browser agent: name a site and a task in words, get the answer back with the transcript. Signed by this machine's key (`agentgates passwords init`); steps meter from the prepaid balance."
69945
+ );
69946
+ browser.command("pricing").description("The step price and the ceilings. Public read: no key, no account, no payment.").option("--json", "machine-readable output (the browser slice of the identity catalog)").action(async (opts) => {
69947
+ await browserPricing(opts);
69948
+ });
69949
+ browser.command("run <url>").description("Queue a task at a site. With --wait, print the answer when it lands.").requiredOption("--task <words>", "what the browser agent should do there, in words").option("--steps <n>", "the most steps it may take (the catalog's default when absent)").option("--seconds <n>", "the most seconds it may run (the catalog's ceiling when absent)").option("--host <hostname>", "an extra hostname the task may visit (repeatable)", (v, prev = []) => [...prev, v]).option("--wait [seconds]", "wait for the answer (the task's own clock plus two minutes by default)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (url, opts) => {
69950
+ await browserRun(url, opts);
69951
+ });
69952
+ browser.command("tasks").description("The tasks this key owns, newest first.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
69953
+ await browserTasks(opts);
69954
+ });
69955
+ browser.command("task <id>").description("One task with its answer and the transcript of what it did.").option("--wait [seconds]", "wait until it settles (15 minutes by default)").option("--cancel", "cancel it while it is still queued; the reservation is released").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
69956
+ await browserTask(id2, opts);
69957
+ });
69958
+ program2.command("init").description(
69959
+ "Mint twelve words and their key, or bring them: the words are this account on agentgates.ai. They sign every call, hold the balance and lock the vault. Printed once, at the mint, with what to tell your human. AGENTGATES_PASSWORDS_SEED is the key for every command with no file at all."
69960
+ ).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
+ await passwordsInit(opts);
69962
+ });
69963
+ program2.command("open").description(
69964
+ "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
+ ).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) => {
69966
+ await sessionOpen(opts);
69967
+ });
69968
+ program2.command("receive").description(
69969
+ "Take a session from a human: prints a code; on agentgates.ai the human presses Top up \u2192 Hand this session to my agent and types it. The words arrive once over 127.0.0.1 and this CLI becomes that account."
69970
+ ).option("--wait <seconds>", "how long the code stays alive (300)").option("--replace", "overwrite the key already here (the old key is the only thing that opens the rows it sealed)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
69971
+ await sessionReceive(opts);
69972
+ });
69973
+ browser.command("balance").description("The prepaid balance every step draws from, and this key's own deposit address to top it up (USDC on Base or Polygon).").option("--scan", "ask the lane to credit a fresh arrival now instead of within five minutes").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
69974
+ await browserBalance(opts);
69975
+ });
69268
69976
  program2.parseAsync(process.argv).catch((err) => {
69269
- process.stderr.write(import_picocolors28.default.red(`\u2715 ${err.message}
69977
+ process.stderr.write(import_picocolors30.default.red(`\u2715 ${err.message}
69270
69978
  `));
69271
69979
  if (process.env.BOUNTY_DEBUG) {
69272
- process.stderr.write(import_picocolors28.default.dim((err.stack ?? "") + "\n"));
69980
+ process.stderr.write(import_picocolors30.default.dim((err.stack ?? "") + "\n"));
69273
69981
  }
69274
69982
  process.exit(1);
69275
69983
  });