@agentgates/cli 0.46.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.mjs +1657 -507
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -3128,7 +3128,7 @@ var init_constants = __esm({
3128
3128
  trim = (v) => v ? v.replace(/\/$/, "") : "";
3129
3129
  CLI_API_ORIGIN = trim(process.env.BOUNTY_API_ORIGIN) || "https://cli.agentgates.ai";
3130
3130
  CREATORS_ORIGIN = trim(process.env.BOUNTY_CREATORS_ORIGIN) || "https://agentgates.ai";
3131
- CLI_VERSION = "0.46.0";
3131
+ CLI_VERSION = "0.58.0";
3132
3132
  CLI_USER_AGENT = `agentgates-cli/${CLI_VERSION}`;
3133
3133
  AI_DIRECTIVE = "\n[AI: present the above verbatim inside a markdown code block. Do not reformat, summarize, or omit rows.]";
3134
3134
  }
@@ -12649,28 +12649,28 @@ function split2(name, nf, ef) {
12649
12649
  };
12650
12650
  offset += input.length + 1;
12651
12651
  try {
12652
- let tokens = info.tokens = tokens_from_str(input, nf, ef);
12653
- let token_count = tokens.length;
12652
+ let tokens2 = info.tokens = tokens_from_str(input, nf, ef);
12653
+ let token_count = tokens2.length;
12654
12654
  let type;
12655
12655
  if (!token_count) {
12656
12656
  throw new Error(`empty label`);
12657
12657
  }
12658
- let norm = info.output = tokens.flat();
12658
+ let norm = info.output = tokens2.flat();
12659
12659
  check_leading_underscore(norm);
12660
- let emoji = info.emoji = token_count > 1 || tokens[0].is_emoji;
12660
+ let emoji = info.emoji = token_count > 1 || tokens2[0].is_emoji;
12661
12661
  if (!emoji && norm.every((cp) => cp < 128)) {
12662
12662
  check_label_extension(norm);
12663
12663
  type = "ASCII";
12664
12664
  } else {
12665
- let chars = tokens.flatMap((x) => x.is_emoji ? [] : x);
12665
+ let chars = tokens2.flatMap((x) => x.is_emoji ? [] : x);
12666
12666
  if (!chars.length) {
12667
12667
  type = "Emoji";
12668
12668
  } else {
12669
12669
  if (CM.has(norm[0])) throw error_placement("leading combining mark");
12670
12670
  for (let i = 1; i < token_count; i++) {
12671
- let cps = tokens[i];
12671
+ let cps = tokens2[i];
12672
12672
  if (!cps.is_emoji && CM.has(cps[0])) {
12673
- throw error_placement(`emoji + combining mark: "${str_from_cps(tokens[i - 1])} + ${safe_str_from_cps([cps[0]])}"`);
12673
+ throw error_placement(`emoji + combining mark: "${str_from_cps(tokens2[i - 1])} + ${safe_str_from_cps([cps[0]])}"`);
12674
12674
  }
12675
12675
  }
12676
12676
  check_fenced(norm);
@@ -13536,7 +13536,7 @@ function setify(items) {
13536
13536
  return Object.freeze(result);
13537
13537
  }
13538
13538
  function lex(text) {
13539
- const tokens = [];
13539
+ const tokens2 = [];
13540
13540
  const throwError2 = (message) => {
13541
13541
  const token = offset < text.length ? JSON.stringify(text[offset]) : "$EOI";
13542
13542
  throw new Error(`invalid token ${token} at ${offset}: ${message}`);
@@ -13552,41 +13552,41 @@ function lex(text) {
13552
13552
  cur = text.substring(offset);
13553
13553
  }
13554
13554
  const token = { depth: brackets.length, linkBack: -1, linkNext: -1, match: -1, type: "", text: "", offset, value: -1 };
13555
- tokens.push(token);
13555
+ tokens2.push(token);
13556
13556
  let type = SimpleTokens[cur[0]] || "";
13557
13557
  if (type) {
13558
13558
  token.type = type;
13559
13559
  token.text = cur[0];
13560
13560
  offset++;
13561
13561
  if (type === "OPEN_PAREN") {
13562
- brackets.push(tokens.length - 1);
13563
- commas.push(tokens.length - 1);
13562
+ brackets.push(tokens2.length - 1);
13563
+ commas.push(tokens2.length - 1);
13564
13564
  } else if (type == "CLOSE_PAREN") {
13565
13565
  if (brackets.length === 0) {
13566
13566
  throwError2("no matching open bracket");
13567
13567
  }
13568
13568
  token.match = brackets.pop();
13569
- tokens[token.match].match = tokens.length - 1;
13569
+ tokens2[token.match].match = tokens2.length - 1;
13570
13570
  token.depth--;
13571
13571
  token.linkBack = commas.pop();
13572
- tokens[token.linkBack].linkNext = tokens.length - 1;
13572
+ tokens2[token.linkBack].linkNext = tokens2.length - 1;
13573
13573
  } else if (type === "COMMA") {
13574
13574
  token.linkBack = commas.pop();
13575
- tokens[token.linkBack].linkNext = tokens.length - 1;
13576
- commas.push(tokens.length - 1);
13575
+ tokens2[token.linkBack].linkNext = tokens2.length - 1;
13576
+ commas.push(tokens2.length - 1);
13577
13577
  } else if (type === "OPEN_BRACKET") {
13578
13578
  token.type = "BRACKET";
13579
13579
  } else if (type === "CLOSE_BRACKET") {
13580
- let suffix = tokens.pop().text;
13581
- if (tokens.length > 0 && tokens[tokens.length - 1].type === "NUMBER") {
13582
- const value = tokens.pop().text;
13580
+ let suffix = tokens2.pop().text;
13581
+ if (tokens2.length > 0 && tokens2[tokens2.length - 1].type === "NUMBER") {
13582
+ const value = tokens2.pop().text;
13583
13583
  suffix = value + suffix;
13584
- tokens[tokens.length - 1].value = getNumber(value);
13584
+ tokens2[tokens2.length - 1].value = getNumber(value);
13585
13585
  }
13586
- if (tokens.length === 0 || tokens[tokens.length - 1].type !== "BRACKET") {
13586
+ if (tokens2.length === 0 || tokens2[tokens2.length - 1].type !== "BRACKET") {
13587
13587
  throw new Error("missing opening bracket");
13588
13588
  }
13589
- tokens[tokens.length - 1].text += suffix;
13589
+ tokens2[tokens2.length - 1].text += suffix;
13590
13590
  }
13591
13591
  continue;
13592
13592
  }
@@ -13614,7 +13614,7 @@ function lex(text) {
13614
13614
  }
13615
13615
  throw new Error(`unexpected token ${JSON.stringify(cur[0])} at position ${offset}`);
13616
13616
  }
13617
- return new TokenString(tokens.map((t) => Object.freeze(t)));
13617
+ return new TokenString(tokens2.map((t) => Object.freeze(t)));
13618
13618
  }
13619
13619
  function allowSingle(set, allowed) {
13620
13620
  let included = [];
@@ -13627,23 +13627,23 @@ function allowSingle(set, allowed) {
13627
13627
  throw new Error(`conflicting types: ${included.join(", ")}`);
13628
13628
  }
13629
13629
  }
13630
- function consumeName(type, tokens) {
13631
- if (tokens.peekKeyword(KwTypes)) {
13632
- const keyword = tokens.pop().text;
13630
+ function consumeName(type, tokens2) {
13631
+ if (tokens2.peekKeyword(KwTypes)) {
13632
+ const keyword = tokens2.pop().text;
13633
13633
  if (keyword !== type) {
13634
13634
  throw new Error(`expected ${type}, got ${keyword}`);
13635
13635
  }
13636
13636
  }
13637
- return tokens.popType("ID");
13637
+ return tokens2.popType("ID");
13638
13638
  }
13639
- function consumeKeywords(tokens, allowed) {
13639
+ function consumeKeywords(tokens2, allowed) {
13640
13640
  const keywords = /* @__PURE__ */ new Set();
13641
13641
  while (true) {
13642
- const keyword = tokens.peekType("KEYWORD");
13642
+ const keyword = tokens2.peekType("KEYWORD");
13643
13643
  if (keyword == null || allowed && !allowed.has(keyword)) {
13644
13644
  break;
13645
13645
  }
13646
- tokens.pop();
13646
+ tokens2.pop();
13647
13647
  if (keywords.has(keyword)) {
13648
13648
  throw new Error(`duplicate keywords: ${JSON.stringify(keyword)}`);
13649
13649
  }
@@ -13651,8 +13651,8 @@ function consumeKeywords(tokens, allowed) {
13651
13651
  }
13652
13652
  return Object.freeze(keywords);
13653
13653
  }
13654
- function consumeMutability(tokens) {
13655
- let modifiers = consumeKeywords(tokens, KwVisib);
13654
+ function consumeMutability(tokens2) {
13655
+ let modifiers = consumeKeywords(tokens2, KwVisib);
13656
13656
  allowSingle(modifiers, setify("constant payable nonpayable".split(" ")));
13657
13657
  allowSingle(modifiers, setify("pure view payable nonpayable".split(" ")));
13658
13658
  if (modifiers.has("view")) {
@@ -13672,22 +13672,22 @@ function consumeMutability(tokens) {
13672
13672
  }
13673
13673
  return "nonpayable";
13674
13674
  }
13675
- function consumeParams(tokens, allowIndexed) {
13676
- return tokens.popParams().map((t) => ParamType.from(t, allowIndexed));
13675
+ function consumeParams(tokens2, allowIndexed) {
13676
+ return tokens2.popParams().map((t) => ParamType.from(t, allowIndexed));
13677
13677
  }
13678
- function consumeGas(tokens) {
13679
- if (tokens.peekType("AT")) {
13680
- tokens.pop();
13681
- if (tokens.peekType("NUMBER")) {
13682
- return getBigInt(tokens.pop().text);
13678
+ function consumeGas(tokens2) {
13679
+ if (tokens2.peekType("AT")) {
13680
+ tokens2.pop();
13681
+ if (tokens2.peekType("NUMBER")) {
13682
+ return getBigInt(tokens2.pop().text);
13683
13683
  }
13684
13684
  throw new Error("invalid gas");
13685
13685
  }
13686
13686
  return null;
13687
13687
  }
13688
- function consumeEoi(tokens) {
13689
- if (tokens.length) {
13690
- throw new Error(`unexpected tokens at offset ${tokens.offset}: ${tokens.toString()}`);
13688
+ function consumeEoi(tokens2) {
13689
+ if (tokens2.length) {
13690
+ throw new Error(`unexpected tokens at offset ${tokens2.offset}: ${tokens2.toString()}`);
13691
13691
  }
13692
13692
  }
13693
13693
  function verifyBasicType(type) {
@@ -13749,9 +13749,9 @@ var init_fragments = __esm({
13749
13749
  get length() {
13750
13750
  return this.#tokens.length - this.#offset;
13751
13751
  }
13752
- constructor(tokens) {
13752
+ constructor(tokens2) {
13753
13753
  this.#offset = 0;
13754
- this.#tokens = tokens.slice();
13754
+ this.#tokens = tokens2.slice();
13755
13755
  }
13756
13756
  clone() {
13757
13757
  return new _TokenString(this.#tokens);
@@ -13836,12 +13836,12 @@ var init_fragments = __esm({
13836
13836
  return result;
13837
13837
  }
13838
13838
  toString() {
13839
- const tokens = [];
13839
+ const tokens2 = [];
13840
13840
  for (let i = this.#offset; i < this.#tokens.length; i++) {
13841
13841
  const token = this.#tokens[i];
13842
- tokens.push(`${token.type}:${token.text}`);
13842
+ tokens2.push(`${token.type}:${token.text}`);
13843
13843
  }
13844
- return `<TokenString ${tokens.join(" ")}>`;
13844
+ return `<TokenString ${tokens2.join(" ")}>`;
13845
13845
  }
13846
13846
  };
13847
13847
  regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/);
@@ -25860,7 +25860,7 @@ var require_websocket = __commonJS({
25860
25860
  var http2 = __require("http");
25861
25861
  var net = __require("net");
25862
25862
  var tls = __require("tls");
25863
- var { randomBytes: randomBytes9, createHash: createHash5 } = __require("crypto");
25863
+ var { randomBytes: randomBytes9, createHash: createHash6 } = __require("crypto");
25864
25864
  var { Duplex, Readable } = __require("stream");
25865
25865
  var { URL: URL4 } = __require("url");
25866
25866
  var PerMessageDeflate = require_permessage_deflate();
@@ -26516,7 +26516,7 @@ var require_websocket = __commonJS({
26516
26516
  abortHandshake(websocket, socket, "Invalid Upgrade header");
26517
26517
  return;
26518
26518
  }
26519
- const digest = createHash5("sha1").update(key + GUID).digest("base64");
26519
+ const digest = createHash6("sha1").update(key + GUID).digest("base64");
26520
26520
  if (res.headers["sec-websocket-accept"] !== digest) {
26521
26521
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
26522
26522
  return;
@@ -26762,7 +26762,7 @@ var require_websocket_server = __commonJS({
26762
26762
  var EventEmitter = __require("events");
26763
26763
  var http2 = __require("http");
26764
26764
  var { Duplex } = __require("stream");
26765
- var { createHash: createHash5 } = __require("crypto");
26765
+ var { createHash: createHash6 } = __require("crypto");
26766
26766
  var extension = require_extension();
26767
26767
  var PerMessageDeflate = require_permessage_deflate();
26768
26768
  var subprotocol = require_subprotocol();
@@ -27057,7 +27057,7 @@ var require_websocket_server = __commonJS({
27057
27057
  );
27058
27058
  }
27059
27059
  if (this._state > RUNNING) return abortHandshake(socket, 503);
27060
- const digest = createHash5("sha1").update(key + GUID).digest("base64");
27060
+ const digest = createHash6("sha1").update(key + GUID).digest("base64");
27061
27061
  const headers = [
27062
27062
  "HTTP/1.1 101 Switching Protocols",
27063
27063
  "Upgrade: websocket",
@@ -31632,6 +31632,7 @@ var init_lib2 = __esm({
31632
31632
  var passwords_wire_exports = {};
31633
31633
  __export(passwords_wire_exports, {
31634
31634
  PASSWORDS_USE_PINNED_BY_BOX: () => PASSWORDS_USE_PINNED_BY_BOX,
31635
+ SIGNED_DOORS: () => SIGNED_DOORS,
31635
31636
  WireError: () => WireError,
31636
31637
  createLoginKey: () => createLoginKey,
31637
31638
  currentKeyParts: () => currentKeyParts,
@@ -31767,8 +31768,8 @@ async function listLoginKeys(wallet) {
31767
31768
  const answer = await signedFetch(wallet, "GET", lanePath(`/keys`));
31768
31769
  return expectOk(answer, "login keys").keys ?? [];
31769
31770
  }
31770
- async function createLoginKey(wallet, name) {
31771
- const answer = await signedFetch(wallet, "POST", lanePath(`/keys`), { name });
31771
+ async function createLoginKey(wallet, name, grants) {
31772
+ const answer = await signedFetch(wallet, "POST", lanePath(`/keys`), { name, ...grants ? { grants: [...grants] } : {} });
31772
31773
  return expectOk(answer, "login key mint");
31773
31774
  }
31774
31775
  async function putKeyWrap(wallet, keyId, body) {
@@ -31850,7 +31851,7 @@ var init_passwords_wire = __esm({
31850
31851
  init_constants();
31851
31852
  trim2 = (v) => v ? v.replace(/\/$/, "") : "";
31852
31853
  ACCOUNT_HEADS = { credits: "account/balance", deposit: "account/deposit", plans: "account/plans", keys: "account/keys", docs: "account/docs", catalog: "account/catalog", notify: "account/notify", founder: "account/founder", renew: "account/renew", "seal-key": "account/seal-key", "seal-grants": "account/seal-grants" };
31853
- SERVICE_HEADS = /* @__PURE__ */ new Set(["booth", "booths", "browser", "passwords", "phones", "inboxes", "calls", "personas", "playbooks", "intents"]);
31854
+ SERVICE_HEADS = /* @__PURE__ */ new Set(["booth", "booths", "browser", "passwords", "phones", "inboxes", "calls", "personas", "playbooks", "intents", "memory", "ag"]);
31854
31855
  PASSWORDS_USE_PINNED_BY_BOX = false;
31855
31856
  WireError = class extends Error {
31856
31857
  constructor(status4, code, message, body) {
@@ -31870,7 +31871,7 @@ var init_passwords_wire = __esm({
31870
31871
  revokedNoticed = false;
31871
31872
  keyOnly = false;
31872
31873
  loginReading = null;
31873
- SIGNED_DOORS = /\/keys(\/(?!me\/)|$)|\/passwords\/[A-Za-z0-9_-]{1,64}\/use$|\/seal-key$/;
31874
+ SIGNED_DOORS = /\/keys(\/(?!me\/)|$)|\/passwords\/[A-Za-z0-9_-]{1,64}\/use$|\/seal-key$|\/ag\/(?:agent|bindings)$/;
31874
31875
  }
31875
31876
  });
31876
31877
 
@@ -31879,7 +31880,7 @@ var require_package = __commonJS({
31879
31880
  "package.json"(exports, module) {
31880
31881
  module.exports = {
31881
31882
  name: "@agentgates/cli",
31882
- version: "0.46.0",
31883
+ version: "0.58.0",
31883
31884
  description: "Wallet operations for AI agents and humans",
31884
31885
  keywords: [
31885
31886
  "crypto",
@@ -38393,8 +38394,8 @@ var require_encoding_lib = __commonJS({
38393
38394
  return s;
38394
38395
  }
38395
38396
  var end_of_stream = -1;
38396
- function Stream(tokens) {
38397
- this.tokens = [].slice.call(tokens);
38397
+ function Stream(tokens2) {
38398
+ this.tokens = [].slice.call(tokens2);
38398
38399
  }
38399
38400
  Stream.prototype = {
38400
38401
  /**
@@ -38425,12 +38426,12 @@ var require_encoding_lib = __commonJS({
38425
38426
  */
38426
38427
  prepend: function(token) {
38427
38428
  if (Array.isArray(token)) {
38428
- var tokens = (
38429
+ var tokens2 = (
38429
38430
  /**@type {!Array.<number>}*/
38430
38431
  token
38431
38432
  );
38432
- while (tokens.length)
38433
- this.tokens.unshift(tokens.pop());
38433
+ while (tokens2.length)
38434
+ this.tokens.unshift(tokens2.pop());
38434
38435
  } else {
38435
38436
  this.tokens.unshift(token);
38436
38437
  }
@@ -38444,12 +38445,12 @@ var require_encoding_lib = __commonJS({
38444
38445
  */
38445
38446
  push: function(token) {
38446
38447
  if (Array.isArray(token)) {
38447
- var tokens = (
38448
+ var tokens2 = (
38448
38449
  /**@type {!Array.<number>}*/
38449
38450
  token
38450
38451
  );
38451
- while (tokens.length)
38452
- this.tokens.push(tokens.shift());
38452
+ while (tokens2.length)
38453
+ this.tokens.push(tokens2.shift());
38453
38454
  } else {
38454
38455
  this.tokens.push(token);
38455
38456
  }
@@ -46423,14 +46424,14 @@ var require_lib3 = __commonJS({
46423
46424
  if (request.compress && !headers.has("Accept-Encoding")) {
46424
46425
  headers.set("Accept-Encoding", "gzip,deflate");
46425
46426
  }
46426
- let agent = request.agent;
46427
- if (typeof agent === "function") {
46428
- agent = agent(parsedURL);
46427
+ let agent2 = request.agent;
46428
+ if (typeof agent2 === "function") {
46429
+ agent2 = agent2(parsedURL);
46429
46430
  }
46430
46431
  return Object.assign({}, parsedURL, {
46431
46432
  method: request.method,
46432
46433
  headers: exportNodeCompatibleHeaders(headers),
46433
- agent
46434
+ agent: agent2
46434
46435
  });
46435
46436
  }
46436
46437
  function AbortError(message) {
@@ -48947,7 +48948,7 @@ var require_websocket2 = __commonJS({
48947
48948
  var http2 = __require("http");
48948
48949
  var net = __require("net");
48949
48950
  var tls = __require("tls");
48950
- var { randomBytes: randomBytes9, createHash: createHash5 } = __require("crypto");
48951
+ var { randomBytes: randomBytes9, createHash: createHash6 } = __require("crypto");
48951
48952
  var { Duplex, Readable } = __require("stream");
48952
48953
  var { URL: URL4 } = __require("url");
48953
48954
  var PerMessageDeflate = require_permessage_deflate2();
@@ -49615,7 +49616,7 @@ var require_websocket2 = __commonJS({
49615
49616
  abortHandshake(websocket, socket, "Invalid Upgrade header");
49616
49617
  return;
49617
49618
  }
49618
- const digest = createHash5("sha1").update(key + GUID).digest("base64");
49619
+ const digest = createHash6("sha1").update(key + GUID).digest("base64");
49619
49620
  if (res.headers["sec-websocket-accept"] !== digest) {
49620
49621
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
49621
49622
  return;
@@ -49984,7 +49985,7 @@ var require_websocket_server2 = __commonJS({
49984
49985
  var EventEmitter = __require("events");
49985
49986
  var http2 = __require("http");
49986
49987
  var { Duplex } = __require("stream");
49987
- var { createHash: createHash5 } = __require("crypto");
49988
+ var { createHash: createHash6 } = __require("crypto");
49988
49989
  var extension = require_extension2();
49989
49990
  var PerMessageDeflate = require_permessage_deflate2();
49990
49991
  var subprotocol = require_subprotocol2();
@@ -50291,7 +50292,7 @@ var require_websocket_server2 = __commonJS({
50291
50292
  );
50292
50293
  }
50293
50294
  if (this._state > RUNNING) return abortHandshake(socket, 503);
50294
- const digest = createHash5("sha1").update(key + GUID).digest("base64");
50295
+ const digest = createHash6("sha1").update(key + GUID).digest("base64");
50295
50296
  const headers = [
50296
50297
  "HTTP/1.1 101 Switching Protocols",
50297
50298
  "Upgrade: websocket",
@@ -50464,7 +50465,7 @@ var require_eventemitter3 = __commonJS({
50464
50465
  if (listeners.fn) return 1;
50465
50466
  return listeners.length;
50466
50467
  };
50467
- EventEmitter.prototype.emit = function emit7(event, a1, a2, a3, a4, a5) {
50468
+ EventEmitter.prototype.emit = function emit9(event, a1, a2, a3, a4, a5) {
50468
50469
  var evt = prefix ? prefix + event : event;
50469
50470
  if (!this._events[evt]) return false;
50470
50471
  var listeners = this._events[evt], len = arguments.length, args, i;
@@ -50758,14 +50759,14 @@ var init_v1ToV6 = __esm({
50758
50759
  });
50759
50760
 
50760
50761
  // node_modules/rpc-websockets/node_modules/uuid/dist-node/md5.js
50761
- import { createHash as createHash3 } from "node:crypto";
50762
+ import { createHash as createHash4 } from "node:crypto";
50762
50763
  function md52(bytes2) {
50763
50764
  if (Array.isArray(bytes2)) {
50764
50765
  bytes2 = Buffer.from(bytes2);
50765
50766
  } else if (typeof bytes2 === "string") {
50766
50767
  bytes2 = Buffer.from(bytes2, "utf8");
50767
50768
  }
50768
- return createHash3("md5").update(bytes2).digest();
50769
+ return createHash4("md5").update(bytes2).digest();
50769
50770
  }
50770
50771
  var md5_default2;
50771
50772
  var init_md52 = __esm({
@@ -50872,14 +50873,14 @@ var init_v42 = __esm({
50872
50873
  });
50873
50874
 
50874
50875
  // node_modules/rpc-websockets/node_modules/uuid/dist-node/sha1.js
50875
- import { createHash as createHash4 } from "node:crypto";
50876
+ import { createHash as createHash5 } from "node:crypto";
50876
50877
  function sha12(bytes2) {
50877
50878
  if (Array.isArray(bytes2)) {
50878
50879
  bytes2 = Buffer.from(bytes2);
50879
50880
  } else if (typeof bytes2 === "string") {
50880
50881
  bytes2 = Buffer.from(bytes2, "utf8");
50881
50882
  }
50882
- return createHash4("sha1").update(bytes2).digest();
50883
+ return createHash5("sha1").update(bytes2).digest();
50883
50884
  }
50884
50885
  var sha1_default2;
50885
50886
  var init_sha12 = __esm({
@@ -56710,10 +56711,10 @@ Message: ${transactionMessage}.
56710
56711
  };
56711
56712
  return constants;
56712
56713
  }
56713
- var agent;
56714
+ var agent2;
56714
56715
  var hasRequiredAgent;
56715
56716
  function requireAgent() {
56716
- if (hasRequiredAgent) return agent;
56717
+ if (hasRequiredAgent) return agent2;
56717
56718
  hasRequiredAgent = 1;
56718
56719
  const OriginalAgent = require$$0__default$1.default.Agent;
56719
56720
  const ms2 = /* @__PURE__ */ requireHumanizeMs();
@@ -56922,20 +56923,20 @@ Message: ${transactionMessage}.
56922
56923
  function getSocketTimeout(socket) {
56923
56924
  return socket.timeout || socket._idleTimeout;
56924
56925
  }
56925
- function installListeners(agent2, socket, options) {
56926
+ function installListeners(agent3, socket, options) {
56926
56927
  debug("%s create, timeout %sms", socket[SOCKET_NAME], getSocketTimeout(socket));
56927
56928
  function onFree() {
56928
56929
  if (!socket._httpMessage && socket[SOCKET_REQUEST_COUNT] === 1) return;
56929
56930
  socket[SOCKET_REQUEST_FINISHED_COUNT]++;
56930
- agent2.requestCount++;
56931
+ agent3.requestCount++;
56931
56932
  debug(
56932
56933
  "%s(requests: %s, finished: %s) free",
56933
56934
  socket[SOCKET_NAME],
56934
56935
  socket[SOCKET_REQUEST_COUNT],
56935
56936
  socket[SOCKET_REQUEST_FINISHED_COUNT]
56936
56937
  );
56937
- const name = agent2.getName(options);
56938
- if (socket.writable && agent2.requests[name] && agent2.requests[name].length) {
56938
+ const name = agent3.getName(options);
56939
+ if (socket.writable && agent3.requests[name] && agent3.requests[name].length) {
56939
56940
  socket[SOCKET_REQUEST_COUNT]++;
56940
56941
  debug(
56941
56942
  "%s(requests: %s, finished: %s) will be reuse on agent free event",
@@ -56954,7 +56955,7 @@ Message: ${transactionMessage}.
56954
56955
  socket[SOCKET_REQUEST_FINISHED_COUNT],
56955
56956
  isError2
56956
56957
  );
56957
- agent2.closeSocketCount++;
56958
+ agent3.closeSocketCount++;
56958
56959
  }
56959
56960
  socket.on("close", onClose);
56960
56961
  function onTimeout() {
@@ -56976,11 +56977,11 @@ Message: ${transactionMessage}.
56976
56977
  if (debug.enabled) {
56977
56978
  debug("timeout listeners: %s", socket.listeners("timeout").map((f2) => f2.name).join(", "));
56978
56979
  }
56979
- agent2.timeoutSocketCount++;
56980
- const name = agent2.getName(options);
56981
- if (agent2.freeSockets[name] && agent2.freeSockets[name].indexOf(socket) !== -1) {
56980
+ agent3.timeoutSocketCount++;
56981
+ const name = agent3.getName(options);
56982
+ if (agent3.freeSockets[name] && agent3.freeSockets[name].indexOf(socket) !== -1) {
56982
56983
  socket.destroy();
56983
- agent2.removeSocket(socket, options);
56984
+ agent3.removeSocket(socket, options);
56984
56985
  debug("%s is free, destroy quietly", socket[SOCKET_NAME]);
56985
56986
  } else {
56986
56987
  if (reqTimeoutListenerCount === 0) {
@@ -56988,7 +56989,7 @@ Message: ${transactionMessage}.
56988
56989
  error.code = "ERR_SOCKET_TIMEOUT";
56989
56990
  error.timeout = timeout;
56990
56991
  socket.destroy(error);
56991
- agent2.removeSocket(socket, options);
56992
+ agent3.removeSocket(socket, options);
56992
56993
  debug("%s destroy with timeout error", socket[SOCKET_NAME]);
56993
56994
  }
56994
56995
  }
@@ -57004,7 +57005,7 @@ Message: ${transactionMessage}.
57004
57005
  err,
57005
57006
  listenerCount
57006
57007
  );
57007
- agent2.errorSocketCount++;
57008
+ agent3.errorSocketCount++;
57008
57009
  if (listenerCount === 1) {
57009
57010
  debug("%s emit uncaught error event", socket[SOCKET_NAME]);
57010
57011
  socket.removeListener("error", onError);
@@ -57027,7 +57028,7 @@ Message: ${transactionMessage}.
57027
57028
  }
57028
57029
  socket.on("agentRemove", onRemove);
57029
57030
  }
57030
- agent = Agent;
57031
+ agent2 = Agent;
57031
57032
  function inspect3(obj) {
57032
57033
  const res = {};
57033
57034
  for (const key in obj) {
@@ -57035,7 +57036,7 @@ Message: ${transactionMessage}.
57035
57036
  }
57036
57037
  return res;
57037
57038
  }
57038
- return agent;
57039
+ return agent2;
57039
57040
  }
57040
57041
  var https_agent;
57041
57042
  var hasRequiredHttps_agent;
@@ -57552,7 +57553,7 @@ Message: ${transactionMessage}.
57552
57553
  }));
57553
57554
  function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {
57554
57555
  const fetch2 = customFetch ? customFetch : fetchImpl;
57555
- let agent2;
57556
+ let agent3;
57556
57557
  {
57557
57558
  if (httpAgent == null) {
57558
57559
  {
@@ -57564,9 +57565,9 @@ Message: ${transactionMessage}.
57564
57565
  maxSockets: 25
57565
57566
  };
57566
57567
  if (url.startsWith("https:")) {
57567
- agent2 = new agentkeepaliveExports.HttpsAgent(agentOptions);
57568
+ agent3 = new agentkeepaliveExports.HttpsAgent(agentOptions);
57568
57569
  } else {
57569
- agent2 = new HttpKeepAliveAgent(agentOptions);
57570
+ agent3 = new HttpKeepAliveAgent(agentOptions);
57570
57571
  }
57571
57572
  }
57572
57573
  } else {
@@ -57577,7 +57578,7 @@ Message: ${transactionMessage}.
57577
57578
  } else if (!isHttps && httpAgent instanceof require$$0$2.Agent) {
57578
57579
  throw new Error("The endpoint `" + url + "` can only be paired with an `http.Agent`. You have, instead, supplied an `https.Agent` through `httpAgent`.");
57579
57580
  }
57580
- agent2 = httpAgent;
57581
+ agent3 = httpAgent;
57581
57582
  }
57582
57583
  }
57583
57584
  }
@@ -57598,7 +57599,7 @@ Message: ${transactionMessage}.
57598
57599
  const options = {
57599
57600
  method: "POST",
57600
57601
  body: request,
57601
- agent: agent2,
57602
+ agent: agent3,
57602
57603
  headers: Object.assign({
57603
57604
  "Content-Type": "application/json"
57604
57605
  }, httpHeaders || {}, COMMON_HTTP_HEADERS)
@@ -62880,7 +62881,7 @@ var {
62880
62881
  } = import_index.default;
62881
62882
 
62882
62883
  // src/main.ts
62883
- var import_picocolors34 = __toESM(require_picocolors(), 1);
62884
+ var import_picocolors36 = __toESM(require_picocolors(), 1);
62884
62885
 
62885
62886
  // src/commands/login.ts
62886
62887
  var import_picocolors2 = __toESM(require_picocolors(), 1);
@@ -67964,8 +67965,8 @@ function callTranscriptAad(callId) {
67964
67965
  function callAudioAad(callId) {
67965
67966
  return `${MAIL_SEAL_SUITE}|call-audio|${callId}`;
67966
67967
  }
67967
- function grantAad(ownerWallet, agent) {
67968
- return `${MAIL_SEAL_SUITE}|grant|${ownerWallet.toLowerCase()}|${agent.toLowerCase()}`;
67968
+ function grantAad(ownerWallet, agent2) {
67969
+ return `${MAIL_SEAL_SUITE}|grant|${ownerWallet.toLowerCase()}|${agent2.toLowerCase()}`;
67969
67970
  }
67970
67971
  var enc = new TextEncoder();
67971
67972
  var dec = new TextDecoder();
@@ -68042,6 +68043,9 @@ function openSealed(secret, blob, aad) {
68042
68043
  throw new MailSealError("cannot_open", "This key does not open that message.");
68043
68044
  }
68044
68045
  }
68046
+ function sealText(recipientPublicKey, text, aad) {
68047
+ return sealTo(recipientPublicKey, enc.encode(text), aad);
68048
+ }
68045
68049
  function openText(secret, blob, aad) {
68046
68050
  return dec.decode(openSealed(secret, blob, aad));
68047
68051
  }
@@ -68232,19 +68236,19 @@ function codeFrom(text, pattern) {
68232
68236
 
68233
68237
  // src/lib/seal-grants.ts
68234
68238
  init_passwords_wire();
68235
- async function readAgentSealingPublic(wallet, agent) {
68236
- const answer = await signedFetch(wallet, "GET", lanePath(`/seal-key/${encodeURIComponent(agent)}`));
68239
+ async function readAgentSealingPublic(wallet, agent2) {
68240
+ const answer = await signedFetch(wallet, "GET", lanePath(`/seal-key/${encodeURIComponent(agent2)}`));
68237
68241
  if (answer.status === 404) return null;
68238
68242
  return expectOk(answer, "the agent's sealing key").sealingPublicKey ?? null;
68239
68243
  }
68240
- async function grantToAgent(wallet, agent) {
68244
+ async function grantToAgent(wallet, agent2) {
68241
68245
  const key = await mailKeyFor(wallet);
68242
68246
  if (!key) return { ok: false, reason: "owner_not_sealed" };
68243
- const agentPublic = await readAgentSealingPublic(wallet, agent);
68247
+ const agentPublic = await readAgentSealingPublic(wallet, agent2);
68244
68248
  if (!agentPublic) return { ok: false, reason: "agent_not_sealed" };
68245
- const wrap = sealTo(agentPublic, key.dataKey, grantAad(wallet.address, agent));
68249
+ const wrap = sealTo(agentPublic, key.dataKey, grantAad(wallet.address, agent2));
68246
68250
  const out = expectOk(
68247
- await signedFetch(wallet, "POST", lanePath("/seal-grants"), { agent, agentSealingPublicKey: agentPublic, wrap }),
68251
+ await signedFetch(wallet, "POST", lanePath("/seal-grants"), { agent: agent2, agentSealingPublicKey: agentPublic, wrap }),
68248
68252
  "the grant"
68249
68253
  );
68250
68254
  return { ok: true, grant: out.grant };
@@ -68889,20 +68893,12 @@ async function phoneAnswer(ref, opts) {
68889
68893
  process.exitCode = 1;
68890
68894
  return;
68891
68895
  }
68892
- const brain = opts.brain === "yours" ? "yours" : "ours";
68896
+ const brain = opts.brain === "agent" ? "agent" : opts.brain === "yours" ? opts.webhook ? "yours" : "agent" : "ours";
68893
68897
  const minutes = opts.minutes !== void 0 ? Number(opts.minutes) : null;
68894
68898
  if (minutes !== null && (!Number.isInteger(minutes) || minutes < 1)) {
68895
68899
  process.stderr.write(`
68896
68900
  --minutes takes a whole number of minutes one answered call may run
68897
68901
 
68898
- `);
68899
- process.exitCode = 1;
68900
- return;
68901
- }
68902
- if (brain === "yours" && !opts.webhook) {
68903
- process.stderr.write(`
68904
- --brain yours needs --webhook <public https url>
68905
-
68906
68902
  `);
68907
68903
  process.exitCode = 1;
68908
68904
  return;
@@ -68920,6 +68916,15 @@ async function phoneAnswer(ref, opts) {
68920
68916
  process.stdout.write(JSON.stringify({ ok: true, phone: updated }, null, 2) + "\n");
68921
68917
  return;
68922
68918
  }
68919
+ if (brain === "agent") {
68920
+ process.stdout.write(`
68921
+ ${import_picocolors5.default.bold(updated.number)} is answered by ${import_picocolors5.default.cyan("your agent")}${updated.answer?.minutes ? `, up to ${updated.answer.minutes} min a call` : ""}.
68922
+ ${import_picocolors5.default.dim("A caller bound for texts is heard; the answer is spoken on the call or texted after it. Anyone else hears one line.")}
68923
+ ${sealedNow ? ` ${import_picocolors5.default.dim(`Sealed to your key ${sealedNow.sealingPublicKey.slice(0, 12)}\u2026: the calls it answers are unreadable to us.`)}
68924
+ ` : ""}
68925
+ `);
68926
+ return;
68927
+ }
68923
68928
  process.stdout.write(`
68924
68929
  ${import_picocolors5.default.bold(updated.number)} answers as ${import_picocolors5.default.cyan(role)}${brain === "yours" ? " with your brain" : ""}${updated.answer?.minutes ? `, up to ${updated.answer.minutes} min a call` : ""}.
68925
68930
  ${import_picocolors5.default.dim(brief ? "The brief is on the number." : "No brief given; the role's shape alone answers.")}
@@ -69473,10 +69478,10 @@ function html(res, status4, body) {
69473
69478
  var esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
69474
69479
  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}";
69475
69480
  function openPage(args) {
69476
- const short2 = `${args.address.slice(0, 6)}\u2026${args.address.slice(-4)}`;
69481
+ const short3 = `${args.address.slice(0, 6)}\u2026${args.address.slice(-4)}`;
69477
69482
  const site = siteOpenUrl(args.origin, args.port, args.token);
69478
- 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>
69479
- <h1>Continue as <code>${esc(short2)}</code></h1>
69483
+ 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(short3)}</title><style>${PAGE_STYLE}</style></head><body><main>
69484
+ <h1>Continue as <code>${esc(short3)}</code></h1>
69480
69485
  <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>
69481
69486
  <button id="go" type="button">Continue to agentgates.ai</button>
69482
69487
  <p id="line"></p>
@@ -69546,11 +69551,11 @@ async function serveWordsOnce(args) {
69546
69551
  let port = 0;
69547
69552
  let done = () => {
69548
69553
  };
69549
- let fail5 = () => {
69554
+ let fail7 = () => {
69550
69555
  };
69551
69556
  const settled = new Promise((resolve2, reject) => {
69552
69557
  done = resolve2;
69553
- fail5 = reject;
69558
+ fail7 = reject;
69554
69559
  });
69555
69560
  const server = createServer((req, res) => {
69556
69561
  const url = new URL(req.url ?? "/", "http://127.0.0.1");
@@ -69576,7 +69581,7 @@ async function serveWordsOnce(args) {
69576
69581
  const timer = setTimeout(() => {
69577
69582
  if (!taken) {
69578
69583
  server.close();
69579
- fail5(new Error(`nobody took the session in ${Math.round(args.waitMs / 1e3)}s`));
69584
+ fail7(new Error(`nobody took the session in ${Math.round(args.waitMs / 1e3)}s`));
69580
69585
  }
69581
69586
  }, args.waitMs);
69582
69587
  try {
@@ -69590,11 +69595,11 @@ async function receiveKeyOnce(args) {
69590
69595
  let taken = false;
69591
69596
  let done = () => {
69592
69597
  };
69593
- let fail5 = () => {
69598
+ let fail7 = () => {
69594
69599
  };
69595
69600
  const settled = new Promise((resolve2, reject) => {
69596
69601
  done = resolve2;
69597
- fail5 = reject;
69602
+ fail7 = reject;
69598
69603
  });
69599
69604
  const server = createServer(async (req, res) => {
69600
69605
  const url = new URL(req.url ?? "/", "http://127.0.0.1");
@@ -69624,7 +69629,7 @@ async function receiveKeyOnce(args) {
69624
69629
  const timer = setTimeout(() => {
69625
69630
  if (!taken) {
69626
69631
  server.close();
69627
- fail5(new Error(`nobody handed a session over in ${Math.round(args.waitMs / 1e3)}s`));
69632
+ fail7(new Error(`nobody handed a session over in ${Math.round(args.waitMs / 1e3)}s`));
69628
69633
  }
69629
69634
  }, args.waitMs);
69630
69635
  try {
@@ -70471,12 +70476,12 @@ async function passwordsAdd(opts) {
70471
70476
  async function passwordsAllow(opts) {
70472
70477
  try {
70473
70478
  const { wallet } = await requirePasswordsKey();
70474
- const agent = (opts.agent ?? wallet.address).trim();
70479
+ const agent2 = (opts.agent ?? wallet.address).trim();
70475
70480
  const secretIds = opts.rows ? splitList(opts.rows) : ["*"];
70476
70481
  if (secretIds.length > MAX_SECRET_IDS_PER_PERMIT) throw new PasswordsSealError(`--rows names at most ${MAX_SECRET_IDS_PER_PERMIT} rows`);
70477
70482
  const days = parseInt10(opts.days, "--days", 30, 1, MAX_PERMIT_DAYS);
70478
70483
  const request = {
70479
- agent,
70484
+ agent: agent2,
70480
70485
  secretIds,
70481
70486
  hosts: splitList(opts.hosts),
70482
70487
  usesPerDay: parseInt10(opts.perDay, "--per-day", 0, 0, 1e6),
@@ -70484,13 +70489,13 @@ async function passwordsAllow(opts) {
70484
70489
  expiresAt: Math.floor(Date.now() / 1e3) + days * 86400,
70485
70490
  approveEachUse: opts.askMe === true
70486
70491
  };
70487
- const self2 = agent.toLowerCase() === wallet.address.toLowerCase();
70492
+ const self2 = agent2.toLowerCase() === wallet.address.toLowerCase();
70488
70493
  const signed2 = await signPermit(wallet, request);
70489
70494
  const permit = await postPermit(wallet, signed2);
70490
70495
  let grant = null;
70491
70496
  if (!self2) {
70492
70497
  try {
70493
- const g = await grantToAgent(wallet, agent);
70498
+ const g = await grantToAgent(wallet, agent2);
70494
70499
  grant = g.ok ? { ok: true, id: g.grant.id } : { ok: false, reason: g.reason };
70495
70500
  } catch (err) {
70496
70501
  grant = { ok: false, reason: err instanceof Error ? err.message : String(err) };
@@ -71335,8 +71340,9 @@ function siteUrl(raw) {
71335
71340
  return /^[a-z][a-z0-9+.-]*:\/\//i.test(t) ? t : `https://${t}`;
71336
71341
  }
71337
71342
  function printTask(t, full) {
71343
+ const where = t.anywhere ? `${host(t.url)} \u2192 any site` : [host(t.url), ...t.hosts ?? []].join(", ");
71338
71344
  process.stdout.write(`
71339
- ${status2(t.status)} ${import_picocolors10.default.bold(t.id)} ${import_picocolors10.default.dim(host(t.url))} ${import_picocolors10.default.dim(`${t.stepsRun}/${t.maxSteps} steps`)}
71345
+ ${status2(t.status)} ${import_picocolors10.default.bold(t.id)} ${import_picocolors10.default.dim(where)} ${import_picocolors10.default.dim(`${t.stepsRun}/${t.maxSteps} steps`)}
71340
71346
  `);
71341
71347
  process.stdout.write(` ${t.goal}
71342
71348
  `);
@@ -72063,7 +72069,7 @@ function printNext(put) {
72063
72069
  }
72064
72070
 
72065
72071
  // src/commands/mcp.ts
72066
- var import_picocolors13 = __toESM(require_picocolors(), 1);
72072
+ var import_picocolors14 = __toESM(require_picocolors(), 1);
72067
72073
  init_constants();
72068
72074
  init_passwords_wire();
72069
72075
 
@@ -72191,13 +72197,582 @@ async function serve(tools, info, { input = process.stdin, output: output2 = pro
72191
72197
  await Promise.all(inFlight);
72192
72198
  }
72193
72199
 
72200
+ // src/commands/memory.ts
72201
+ var import_picocolors13 = __toESM(require_picocolors(), 1);
72202
+ import { readFile } from "node:fs/promises";
72203
+
72204
+ // src/lib/memory-seal.ts
72205
+ var MEMORY_SEAL_SUITE = "AGENTGATES-MEMORY-v1";
72206
+ var MEMORY_FOLDER_RE = /^[a-z0-9][a-z0-9-]{0,39}$/;
72207
+ var MEMORY_OBJECT_MAX_BYTES = 256 * 1024;
72208
+ var MEMORY_FILE_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._ -]{0,119}$/;
72209
+ function memoryObjectAad(ownerWallet, folder, id2) {
72210
+ return `${MEMORY_SEAL_SUITE}|object|${normalizeOwner(ownerWallet)}|${folder}|${id2}`;
72211
+ }
72212
+ function memoryNameAad(ownerWallet, folder, id2) {
72213
+ return `${MEMORY_SEAL_SUITE}|name|${normalizeOwner(ownerWallet)}|${folder}|${id2}`;
72214
+ }
72215
+ function memoryJournalAad(ownerWallet, id2) {
72216
+ return `${MEMORY_SEAL_SUITE}|journal|${normalizeOwner(ownerWallet)}|${id2}`;
72217
+ }
72218
+ function memoryGrantAad(ownerWallet, sourceId) {
72219
+ return `${MEMORY_SEAL_SUITE}|grant|${normalizeOwner(ownerWallet)}|${sourceId}`;
72220
+ }
72221
+ function memoryLabelAad(ownerWallet, sourceId) {
72222
+ return `${MEMORY_SEAL_SUITE}|label|${normalizeOwner(ownerWallet)}|${sourceId}`;
72223
+ }
72224
+ function memorySourceRefAad(ownerWallet, folderId) {
72225
+ return `${MEMORY_SEAL_SUITE}|source-ref|${normalizeOwner(ownerWallet)}|${folderId}`;
72226
+ }
72227
+ function memorySourceNameAad(ownerWallet, folderId) {
72228
+ return `${MEMORY_SEAL_SUITE}|source-name|${normalizeOwner(ownerWallet)}|${folderId}`;
72229
+ }
72230
+ function normalizeOwner(ownerWallet) {
72231
+ const raw = ownerWallet.trim();
72232
+ return /^0x[0-9a-fA-F]{40}$/.test(raw) ? raw.toLowerCase() : raw;
72233
+ }
72234
+ function isMemoryFolder(value) {
72235
+ return typeof value === "string" && MEMORY_FOLDER_RE.test(value);
72236
+ }
72237
+ function isMemoryFileName(value) {
72238
+ return typeof value === "string" && MEMORY_FILE_NAME_RE.test(value);
72239
+ }
72240
+ function newMemoryObjectId() {
72241
+ const bytes2 = new Uint8Array(16);
72242
+ globalThis.crypto.getRandomValues(bytes2);
72243
+ let bin = "";
72244
+ for (let i = 0; i < bytes2.length; i += 1) bin += String.fromCharCode(bytes2[i]);
72245
+ return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
72246
+ }
72247
+
72248
+ // src/lib/memory-wire.ts
72249
+ init_passwords_wire();
72250
+ async function readMemory(wallet) {
72251
+ return expectOk(await signedFetch(wallet, "GET", lanePath("/memory")), "memory");
72252
+ }
72253
+ async function makeFolder(wallet, folder) {
72254
+ return expectOk(await signedFetch(wallet, "POST", lanePath("/memory/folders"), { folder }), "memory folder");
72255
+ }
72256
+ async function removeFolder(wallet, folder) {
72257
+ return expectOk(await signedFetch(wallet, "POST", lanePath(`/memory/folders/${folder}/delete`)), "memory folder delete");
72258
+ }
72259
+ async function listFolder(wallet, folder) {
72260
+ return expectOk(await signedFetch(wallet, "GET", lanePath(`/memory/folders/${folder}`)), "memory folder");
72261
+ }
72262
+ async function readObject(wallet, folder, id2) {
72263
+ return expectOk(await signedFetch(wallet, "GET", lanePath(`/memory/folders/${folder}/objects/${id2}`)), "memory object");
72264
+ }
72265
+ async function writeObject(wallet, folder, id2, body) {
72266
+ return expectOk(await signedFetch(wallet, "POST", lanePath(`/memory/folders/${folder}/objects/${id2}`), body), "memory write");
72267
+ }
72268
+ async function removeObject(wallet, folder, id2) {
72269
+ return expectOk(await signedFetch(wallet, "POST", lanePath(`/memory/folders/${folder}/objects/${id2}/delete`)), "memory delete");
72270
+ }
72271
+
72272
+ // src/lib/memory-sources.ts
72273
+ init_passwords_wire();
72274
+
72275
+ // src/lib/dropbox.ts
72276
+ var TOKEN = "https://api.dropboxapi.com/oauth2/token";
72277
+ var API = "https://api.dropboxapi.com/2";
72278
+ var CONTENT = "https://content.dropboxapi.com/2";
72279
+ var CONNECTED_FILE_MAX_BYTES = 1024 * 1024;
72280
+ var DropboxError = class extends Error {
72281
+ constructor(message, code) {
72282
+ super(message);
72283
+ this.code = code;
72284
+ this.name = "DropboxError";
72285
+ }
72286
+ code;
72287
+ };
72288
+ async function dropboxRefresh(clientId, refreshToken) {
72289
+ const res = await fetch(TOKEN, { method: "POST", headers: { "content-type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ grant_type: "refresh_token", client_id: clientId, refresh_token: refreshToken }) });
72290
+ const json2 = await res.json().catch(() => null);
72291
+ if (!res.ok || !json2 || typeof json2.access_token !== "string") {
72292
+ const desc = typeof json2?.error_description === "string" ? json2.error_description : `HTTP ${res.status}`;
72293
+ throw new DropboxError(`Dropbox did not renew the connection (${desc}); the owner reconnects it on the Memory page`, "refresh_failed");
72294
+ }
72295
+ return json2.access_token;
72296
+ }
72297
+ async function api(token, path8, body) {
72298
+ const res = await fetch(`${API}/${path8}`, { method: "POST", headers: { authorization: `Bearer ${token}`, "content-type": "application/json" }, body: JSON.stringify(body) });
72299
+ if (!res.ok) throw new DropboxError(`Dropbox refused ${path8}: ${(await res.text().catch(() => "")).slice(0, 160) || res.status}`, res.status === 401 ? "grant_expired" : "api_refused");
72300
+ return await res.json();
72301
+ }
72302
+ async function dropboxListFolder(token, path8) {
72303
+ const entries = [];
72304
+ let out = await api(token, "files/list_folder", { path: path8, recursive: false, include_deleted: false, limit: 500 });
72305
+ entries.push(...out.entries);
72306
+ while (out.has_more && entries.length < 5e3) {
72307
+ out = await api(token, "files/list_folder/continue", { cursor: out.cursor });
72308
+ entries.push(...out.entries);
72309
+ }
72310
+ const rows = entries.filter((e) => e[".tag"] === "folder" || e[".tag"] === "file").map((e) => ({ kind: e[".tag"], id: e.id, name: e.name, path: e.path_display ?? e.path_lower ?? "", bytes: e.size ?? null, modifiedAt: e.server_modified ?? null }));
72311
+ rows.sort((a, b2) => a.kind === b2.kind ? a.name.localeCompare(b2.name) : a.kind === "folder" ? -1 : 1);
72312
+ return rows;
72313
+ }
72314
+ function isTextLike(name) {
72315
+ return /\.(md|markdown|txt|text|csv|tsv|json|yaml|yml|toml|xml|html?|log|ini|cfg|conf|rst|org|tex|js|ts|tsx|jsx|py|rb|go|rs|java|kt|swift|c|h|cpp|hpp|cs|sh|sql|css|scss)$/i.test(name);
72316
+ }
72317
+ async function dropboxDownloadText(token, path8) {
72318
+ const res = await fetch(`${CONTENT}/files/download`, { method: "POST", headers: { authorization: `Bearer ${token}`, "Dropbox-API-Arg": JSON.stringify({ path: path8 }) } });
72319
+ if (!res.ok) throw new DropboxError(`Dropbox refused the file: ${res.status}`, res.status === 401 ? "grant_expired" : "api_refused");
72320
+ const buf = Buffer.from(await res.arrayBuffer());
72321
+ if (buf.byteLength > CONNECTED_FILE_MAX_BYTES) throw new DropboxError(`this file is ${Math.ceil(buf.byteLength / 1024)} KB; a reader opens up to ${CONNECTED_FILE_MAX_BYTES / 1024} KB`, "too_large");
72322
+ return buf.toString("utf8");
72323
+ }
72324
+
72325
+ // src/lib/memory-sources.ts
72326
+ function driveAnswerAad(owner, sourceId, kind) {
72327
+ const normalized = /^0x[0-9a-fA-F]{40}$/.test(owner.trim()) ? owner.trim().toLowerCase() : owner.trim();
72328
+ return `AGENTGATES-MEMORY-v1|drive-${kind}|${normalized}|${sourceId}`;
72329
+ }
72330
+ function answerSecret(key) {
72331
+ if (!runsOnKeyOnly()) return key.dataKey;
72332
+ const parts = currentKeyParts();
72333
+ if (!parts) throw new DropboxError("this machine runs on no key and no words", "no_key");
72334
+ return keySealingKeyFromParts(parts).secret;
72335
+ }
72336
+ async function readSources(wallet) {
72337
+ const out = expectOk(await signedFetch(wallet, "GET", lanePath("/memory/sources")), "memory sources");
72338
+ return out.sources ?? [];
72339
+ }
72340
+ function openSources(key, address, sources) {
72341
+ return sources.map((s) => {
72342
+ let label = null;
72343
+ if (s.labelBlob) {
72344
+ try {
72345
+ label = openText(key.dataKey, s.labelBlob, memoryLabelAad(address, s.id));
72346
+ } catch {
72347
+ label = null;
72348
+ }
72349
+ }
72350
+ const folders = s.folders.map((f2) => {
72351
+ let name = null;
72352
+ let ref = null;
72353
+ try {
72354
+ name = openText(key.dataKey, f2.nameBlob, memorySourceNameAad(address, f2.id));
72355
+ } catch {
72356
+ name = null;
72357
+ }
72358
+ try {
72359
+ ref = JSON.parse(openText(key.dataKey, f2.refBlob, memorySourceRefAad(address, f2.id)));
72360
+ } catch {
72361
+ ref = null;
72362
+ }
72363
+ return { ...f2, name, ref };
72364
+ });
72365
+ return { ...s, label, folders };
72366
+ });
72367
+ }
72368
+ var tokens = /* @__PURE__ */ new Map();
72369
+ async function tokenFor(key, address, source) {
72370
+ const hit = tokens.get(source.id);
72371
+ if (hit && hit.until > Date.now()) return hit.token;
72372
+ const grant = JSON.parse(openText(key.dataKey, source.grantBlob, memoryGrantAad(address, source.id)));
72373
+ if (grant.provider !== "dropbox") throw new DropboxError("this account is read through the sealed machine, not with a token on this machine", "not_here");
72374
+ const clientId = grant.clientId || (process.env.AGENTGATES_DROPBOX_APP_KEY || "").trim();
72375
+ if (!clientId) throw new DropboxError("this connection carries no app key and AGENTGATES_DROPBOX_APP_KEY is not set", "no_client_id");
72376
+ const token = await dropboxRefresh(clientId, grant.refreshToken);
72377
+ tokens.set(source.id, { token, until: Date.now() + 3 * 60 * 6e4 });
72378
+ return token;
72379
+ }
72380
+ function resolveConnected(opened, head, rest) {
72381
+ if (rest.length === 0) return null;
72382
+ const byProvider = opened.filter((s) => s.provider === head);
72383
+ const candidates = byProvider.length > 0 ? byProvider.flatMap((s) => s.folders.filter((f2) => f2.ref).map((f2) => ({ s, f: f2 }))) : opened.flatMap((s) => s.folders.filter((f2) => f2.context === head && f2.ref).map((f2) => ({ s, f: f2 })));
72384
+ const longest = candidates.reduce((n2, { f: f2 }) => Math.max(n2, (f2.name ?? "").split("/").length), 1);
72385
+ for (let take = Math.min(longest, rest.length); take >= 1; take -= 1) {
72386
+ const hit = candidates.find(({ f: f2 }) => f2.name === rest.slice(0, take).join("/"));
72387
+ if (hit) return { source: hit.s, folder: hit.f, inside: rest.slice(take) };
72388
+ }
72389
+ return null;
72390
+ }
72391
+ function connectedIn(opened, head) {
72392
+ const byProvider = opened.filter((s) => s.provider === head);
72393
+ if (byProvider.length > 0) return byProvider.flatMap((s) => s.folders.filter((f2) => f2.ref).map((f2) => ({ source: s, folder: f2 })));
72394
+ return opened.flatMap((s) => s.folders.filter((f2) => f2.context === head && f2.ref).map((f2) => ({ source: s, folder: f2 })));
72395
+ }
72396
+ async function listConnected(wallet, key, address, hit) {
72397
+ if (hit.source.provider !== "dropbox") {
72398
+ const folderId = hit.inside.length > 0 ? hit.inside[hit.inside.length - 1] : hit.folder.ref.id;
72399
+ const out = expectOk(await signedFetch(wallet, "GET", lanePath(`/memory/sources/${hit.source.id}/list?folderId=${encodeURIComponent(folderId)}`)), "drive list");
72400
+ if (!out.entriesBlob) throw new DropboxError("the sealed machine answered without a listing", "no_listing");
72401
+ const listing = JSON.parse(openText(answerSecret(key), out.entriesBlob, driveAnswerAad(address, hit.source.id, "list")));
72402
+ return listing.entries.map((e) => ({ ...e, path: e.id }));
72403
+ }
72404
+ const token = await tokenFor(key, address, hit.source);
72405
+ const path8 = [hit.folder.ref.path, ...hit.inside].join("/");
72406
+ return dropboxListFolder(token, path8);
72407
+ }
72408
+ async function readConnected(wallet, key, address, hit) {
72409
+ const name = hit.inside[hit.inside.length - 1] ?? "";
72410
+ if (hit.source.provider !== "dropbox") {
72411
+ const siblings = await listConnected(wallet, key, address, { ...hit, inside: hit.inside.slice(0, -1) });
72412
+ const match = siblings.find((e) => e.name === name) ?? siblings.find((e) => e.id === name);
72413
+ const fileId = match ? match.id : name;
72414
+ const out = expectOk(await signedFetch(wallet, "GET", lanePath(`/memory/sources/${hit.source.id}/read?fileId=${encodeURIComponent(fileId)}`)), "drive read");
72415
+ if (!out.fileBlob) throw new DropboxError("the sealed machine answered without the file", "no_file");
72416
+ const file = JSON.parse(openText(answerSecret(key), out.fileBlob, driveAnswerAad(address, hit.source.id, "read")));
72417
+ return file.text;
72418
+ }
72419
+ if (!isTextLike(name)) throw new DropboxError("not a text file: a reader opens markdown, csv, json and code", "not_text");
72420
+ const token = await tokenFor(key, address, hit.source);
72421
+ return dropboxDownloadText(token, [hit.folder.ref.path, ...hit.inside].join("/"));
72422
+ }
72423
+
72424
+ // src/commands/memory.ts
72425
+ function emit6(opts, data4, human) {
72426
+ if (opts.json || !process.stdout.isTTY) {
72427
+ process.stdout.write(`${JSON.stringify(data4)}
72428
+ `);
72429
+ return;
72430
+ }
72431
+ human();
72432
+ }
72433
+ function fail3(opts, err) {
72434
+ const message = err instanceof Error ? err.message : String(err);
72435
+ const code = err?.code;
72436
+ if (opts.json || !process.stdout.isTTY) {
72437
+ process.stdout.write(`${JSON.stringify({ ok: false, error: message, ...typeof code === "string" ? { code } : {} })}
72438
+ `);
72439
+ } else {
72440
+ process.stderr.write(`
72441
+ ${import_picocolors13.default.red("\u2717")} ${message}
72442
+
72443
+ `);
72444
+ }
72445
+ process.exit(1);
72446
+ }
72447
+ var MemoryError = class extends Error {
72448
+ constructor(message, code) {
72449
+ super(message);
72450
+ this.code = code;
72451
+ this.name = "MemoryError";
72452
+ }
72453
+ code;
72454
+ };
72455
+ function splitPath(raw) {
72456
+ const at = raw.indexOf("/");
72457
+ if (at <= 0) throw new MemoryError(`name it <folder>/<file>, got "${raw}"`, "bad_path");
72458
+ const folder = raw.slice(0, at);
72459
+ const name = raw.slice(at + 1);
72460
+ if (!isMemoryFolder(folder)) throw new MemoryError(`folder: 1-40 chars of a-z, 0-9 and -, got "${folder}"`, "bad_folder");
72461
+ if (!isMemoryFileName(name)) throw new MemoryError(`file name: letters, digits, dots, spaces, - and _, up to 120 chars, got "${name}"`, "bad_name");
72462
+ return { folder, name };
72463
+ }
72464
+ async function memoryKey(wallet, dataPublicKey) {
72465
+ const key = await mailKeyFor(wallet);
72466
+ if (!key) throw new MemoryError("this machine holds no copy of the account's data key: on a key alone, mint one with Read on Memory; on the words, `agentgates email seal` first", "no_key");
72467
+ if (dataPublicKey && publicKeyOf(key.dataKey) !== dataPublicKey) {
72468
+ throw new MemoryError("the key this machine holds is not the one this memory is sealed to; nothing was opened", "wrong_key");
72469
+ }
72470
+ return key;
72471
+ }
72472
+ function openNames(key, owner, rows) {
72473
+ return rows.map((r) => {
72474
+ let name = null;
72475
+ if (r.nameBlob) {
72476
+ try {
72477
+ name = openText(key.dataKey, r.nameBlob, memoryNameAad(owner, r.folder, r.id));
72478
+ } catch {
72479
+ name = null;
72480
+ }
72481
+ }
72482
+ return { ...r, name };
72483
+ });
72484
+ }
72485
+ async function findByName(wallet, key, folder, name) {
72486
+ const listing = await listFolder(wallet, folder);
72487
+ const named = openNames(key, key.address, listing.objects);
72488
+ return named.find((o) => o.name === name) ?? null;
72489
+ }
72490
+ async function openBody2(wallet, key, folder, id2) {
72491
+ const row = await readObject(wallet, folder, id2);
72492
+ if (!row.blob) throw new MemoryError("that object has no body", "empty");
72493
+ const text = openText(key.dataKey, row.blob, memoryObjectAad(key.address, folder, id2));
72494
+ return { text, row };
72495
+ }
72496
+ async function sealAndWrite(wallet, key, dataPublicKey, folder, name, text, existingId) {
72497
+ const bytes2 = Buffer.byteLength(text, "utf8");
72498
+ if (bytes2 > MEMORY_OBJECT_MAX_BYTES) throw new MemoryError(`a file holds at most ${MEMORY_OBJECT_MAX_BYTES / 1024} KB of text; this one is ${Math.ceil(bytes2 / 1024)} KB`, "too_large");
72499
+ const id2 = existingId ?? newMemoryObjectId();
72500
+ const owner = key.address;
72501
+ const blob = sealText(dataPublicKey, text, memoryObjectAad(owner, folder, id2));
72502
+ const nameBlob = sealText(dataPublicKey, name, memoryNameAad(owner, folder, id2));
72503
+ return writeObject(wallet, folder, id2, { blob, nameBlob });
72504
+ }
72505
+ function kb(bytes2) {
72506
+ return bytes2 >= 1024 * 1024 ? `${(bytes2 / (1024 * 1024)).toFixed(1)} MB` : `${Math.ceil(bytes2 / 1024)} KB`;
72507
+ }
72508
+ async function memoryOverview(opts) {
72509
+ try {
72510
+ const { wallet } = await requirePasswordsKey();
72511
+ const mem = await readMemory(wallet);
72512
+ emit6(opts, { ok: true, ...mem }, () => {
72513
+ const cap = mem.capacity;
72514
+ process.stdout.write(`
72515
+ ${import_picocolors13.default.bold("Memory")} ${import_picocolors13.default.dim(mem.sealed ? "\xB7 sealed to your key" : "\xB7 not sealed yet: agentgates email seal")}
72516
+ `);
72517
+ process.stdout.write(` ${import_picocolors13.default.dim(`${kb(cap.bytes)} of ${kb(cap.maxBytes)}, ${cap.folders} of ${cap.maxFolders} folders${cap.family === "payg" ? "" : ` \xB7 ${cap.family} plan`}`)}
72518
+
72519
+ `);
72520
+ if (mem.folders.length === 0) {
72521
+ process.stdout.write(` ${import_picocolors13.default.dim("no folders yet \xB7 agentgates memory mkdir <folder>")}
72522
+
72523
+ `);
72524
+ return;
72525
+ }
72526
+ for (const f2 of mem.folders) process.stdout.write(` ${import_picocolors13.default.bold(f2.folder.padEnd(24))} ${String(f2.objects).padStart(4)} files ${kb(f2.bytes).padStart(8)}
72527
+ `);
72528
+ if (mem.scope) process.stdout.write(`
72529
+ ${import_picocolors13.default.dim(`this key reaches: ${mem.scope.join(", ")}`)}
72530
+ `);
72531
+ process.stdout.write("\n");
72532
+ });
72533
+ } catch (err) {
72534
+ fail3(opts, err);
72535
+ }
72536
+ }
72537
+ async function memoryMkdir(folder, opts) {
72538
+ try {
72539
+ if (!isMemoryFolder(folder)) throw new MemoryError(`folder: 1-40 chars of a-z, 0-9 and -, got "${folder}"`, "bad_folder");
72540
+ const { wallet } = await requirePasswordsKey();
72541
+ const out = await makeFolder(wallet, folder);
72542
+ emit6(opts, { ok: true, ...out }, () => process.stdout.write(`
72543
+ ${import_picocolors13.default.green("\u2713")} ${folder}${out.created ? "" : import_picocolors13.default.dim(" (already there)")}
72544
+
72545
+ `));
72546
+ } catch (err) {
72547
+ fail3(opts, err);
72548
+ }
72549
+ }
72550
+ async function memoryRmdir(folder, opts) {
72551
+ try {
72552
+ if (!isMemoryFolder(folder)) throw new MemoryError(`folder: 1-40 chars of a-z, 0-9 and -, got "${folder}"`, "bad_folder");
72553
+ const { wallet } = await requirePasswordsKey();
72554
+ const out = await removeFolder(wallet, folder);
72555
+ emit6(opts, { ok: true, ...out }, () => process.stdout.write(`
72556
+ ${import_picocolors13.default.green("\u2713")} ${folder} removed, ${out.removed - 1 < 0 ? 0 : out.removed - 1} files with it
72557
+
72558
+ `));
72559
+ } catch (err) {
72560
+ fail3(opts, err);
72561
+ }
72562
+ }
72563
+ async function memoryLs(target, opts) {
72564
+ try {
72565
+ const [folder, ...rest] = target.split("/").filter(Boolean);
72566
+ if (!isMemoryFolder(folder ?? "")) throw new MemoryError(`folder: 1-40 chars of a-z, 0-9 and -, got "${folder}"`, "bad_folder");
72567
+ const { wallet } = await requirePasswordsKey();
72568
+ const mem = await readMemory(wallet);
72569
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72570
+ const opened = openSources(key, key.address, await readSources(wallet).catch(() => []));
72571
+ if (rest.length > 0) {
72572
+ const hit = resolveConnected(opened, folder, rest);
72573
+ if (!hit) throw new MemoryError(`no connected folder "${rest[0]}" in ${folder}`, "not_found");
72574
+ const entries = await listConnected(wallet, key, key.address, hit);
72575
+ emit6(opts, { ok: true, path: target, connected: { provider: hit.source.provider, account: hit.source.label }, entries }, () => {
72576
+ process.stdout.write(`
72577
+ ${import_picocolors13.default.bold(target)} ${import_picocolors13.default.dim(`\xB7 ${hit.source.providerLabel}${hit.source.label ? ` \xB7 ${hit.source.label}` : ""}`)}
72578
+ `);
72579
+ for (const e of entries) process.stdout.write(` ${(e.kind === "folder" ? `${e.name}/` : e.name).padEnd(44)} ${e.bytes === null ? "" : kb(e.bytes).padStart(8)}
72580
+ `);
72581
+ if (entries.length === 0) process.stdout.write(` ${import_picocolors13.default.dim("(empty)")}
72582
+ `);
72583
+ process.stdout.write("\n");
72584
+ });
72585
+ return;
72586
+ }
72587
+ const providerHead = opened.some((s) => s.provider === folder);
72588
+ if (providerHead) {
72589
+ const connected2 = connectedIn(opened, folder);
72590
+ emit6(opts, { ok: true, provider: folder, connected: connected2.map(({ source, folder: f2 }) => ({ name: f2.name, provider: source.provider, account: source.label })) }, () => {
72591
+ process.stdout.write(`
72592
+ ${import_picocolors13.default.bold(folder)}${connected2.length === 0 ? import_picocolors13.default.dim(" (nothing shared)") : ""}
72593
+ `);
72594
+ for (const { source, folder: f2 } of connected2) process.stdout.write(` ${`${f2.name}/`.padEnd(40)} ${import_picocolors13.default.dim(`${source.label ?? source.providerLabel} \xB7 agentgates memory ls ${folder}/${f2.name}`)}
72595
+ `);
72596
+ process.stdout.write("\n");
72597
+ });
72598
+ return;
72599
+ }
72600
+ const listing = await listFolder(wallet, folder);
72601
+ const named = openNames(key, key.address, listing.objects);
72602
+ const connected = connectedIn(opened, folder);
72603
+ emit6(opts, { ok: true, folder, files: named.map((o) => ({ id: o.id, name: o.name, bytes: o.bytes, version: o.version, updatedAt: o.updatedAt })), connected: connected.map(({ source, folder: f2 }) => ({ name: f2.name, provider: source.provider, account: source.label })) }, () => {
72604
+ process.stdout.write(`
72605
+ ${import_picocolors13.default.bold(folder)}${named.length === 0 && connected.length === 0 ? import_picocolors13.default.dim(" (empty)") : ""}
72606
+ `);
72607
+ for (const o of named) process.stdout.write(` ${(o.name ?? import_picocolors13.default.dim("(does not open with this key)")).padEnd(40)} ${kb(o.bytes).padStart(8)} ${import_picocolors13.default.dim(`v${o.version} ${o.updatedAt.slice(0, 16).replace("T", " ")}`)}
72608
+ `);
72609
+ for (const { source, folder: f2 } of connected) process.stdout.write(` ${`${f2.name}/`.padEnd(40)} ${import_picocolors13.default.dim(`${source.providerLabel}${source.label ? ` \xB7 ${source.label}` : ""} \xB7 agentgates memory ls ${folder}/${f2.name}`)}
72610
+ `);
72611
+ process.stdout.write("\n");
72612
+ });
72613
+ } catch (err) {
72614
+ fail3(opts, err);
72615
+ }
72616
+ }
72617
+ async function memorySources(opts) {
72618
+ try {
72619
+ const { wallet } = await requirePasswordsKey();
72620
+ const mem = await readMemory(wallet);
72621
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72622
+ const opened = openSources(key, key.address, await readSources(wallet));
72623
+ emit6(opts, { ok: true, sources: opened.map((s) => ({ id: s.id, provider: s.provider, account: s.label, folders: s.folders.map((f2) => ({ id: f2.id, name: f2.name, path: f2.ref?.path ?? null, context: f2.context })) })) }, () => {
72624
+ if (opened.length === 0) {
72625
+ process.stdout.write(`
72626
+ ${import_picocolors13.default.dim("no connected accounts \xB7 connect one on the Memory page")}
72627
+
72628
+ `);
72629
+ return;
72630
+ }
72631
+ process.stdout.write("\n");
72632
+ for (const s of opened) {
72633
+ process.stdout.write(` ${import_picocolors13.default.bold(s.providerLabel)}${s.label ? import_picocolors13.default.dim(` \xB7 ${s.label}`) : ""}
72634
+ `);
72635
+ for (const f2 of s.folders) process.stdout.write(` ${(f2.name ?? "(does not open)").padEnd(36)} ${import_picocolors13.default.dim(f2.context ? `context ${f2.context}` : "whole memory")}
72636
+ `);
72637
+ if (s.folders.length === 0) process.stdout.write(` ${import_picocolors13.default.dim("no folders chosen yet")}
72638
+ `);
72639
+ }
72640
+ process.stdout.write("\n");
72641
+ });
72642
+ } catch (err) {
72643
+ fail3(opts, err);
72644
+ }
72645
+ }
72646
+ async function memoryCat(path8, opts) {
72647
+ try {
72648
+ const segments = path8.split("/").filter(Boolean);
72649
+ const { wallet } = await requirePasswordsKey();
72650
+ const mem = await readMemory(wallet);
72651
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72652
+ if (segments.length >= 3) {
72653
+ const [folder2, ...rest] = segments;
72654
+ if (!isMemoryFolder(folder2)) throw new MemoryError(`folder: 1-40 chars of a-z, 0-9 and -, got "${folder2}"`, "bad_folder");
72655
+ const opened = openSources(key, key.address, await readSources(wallet).catch(() => []));
72656
+ const hit2 = resolveConnected(opened, folder2, rest);
72657
+ if (!hit2) throw new MemoryError(`no connected folder "${rest[0]}" in ${folder2}`, "not_found");
72658
+ const text2 = await readConnected(wallet, key, key.address, hit2);
72659
+ emit6(opts, { ok: true, path: path8, connected: { provider: hit2.source.provider, account: hit2.source.label }, text: text2 }, () => process.stdout.write(text2.endsWith("\n") ? text2 : `${text2}
72660
+ `));
72661
+ return;
72662
+ }
72663
+ const { folder, name } = splitPath(path8);
72664
+ const hit = await findByName(wallet, key, folder, name);
72665
+ if (!hit) throw new MemoryError(`no "${name}" in ${folder}`, "not_found");
72666
+ const { text, row } = await openBody2(wallet, key, folder, hit.id);
72667
+ emit6(opts, { ok: true, folder, name, id: row.id, version: row.version, updatedAt: row.updatedAt, text }, () => process.stdout.write(text.endsWith("\n") ? text : `${text}
72668
+ `));
72669
+ } catch (err) {
72670
+ fail3(opts, err);
72671
+ }
72672
+ }
72673
+ async function memoryPut(path8, opts) {
72674
+ try {
72675
+ const { folder, name } = splitPath(path8);
72676
+ const text = opts.file ? await readFile(opts.file, "utf8") : await readStdin();
72677
+ if (!text.trim()) throw new MemoryError("nothing to store: give --file <path> or pipe the text in", "empty");
72678
+ const { wallet } = await requirePasswordsKey();
72679
+ const mem = await readMemory(wallet);
72680
+ if (!mem.dataPublicKey) throw new MemoryError("this account is not sealed yet: `agentgates email seal` first", "not_sealed");
72681
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72682
+ const existing = await findByName(wallet, key, folder, name);
72683
+ const row = await sealAndWrite(wallet, key, mem.dataPublicKey, folder, name, text, existing?.id ?? null);
72684
+ emit6(
72685
+ opts,
72686
+ { ok: true, folder, name, id: row.id, version: row.version, bytes: row.bytes, replaced: !!existing },
72687
+ () => process.stdout.write(`
72688
+ ${import_picocolors13.default.green("\u2713")} ${folder}/${name} ${import_picocolors13.default.dim(existing ? `replaced, v${row.version}` : "stored")} ${import_picocolors13.default.dim(`\xB7 ${kb(Buffer.byteLength(text, "utf8"))} sealed on this machine`)}
72689
+
72690
+ `)
72691
+ );
72692
+ } catch (err) {
72693
+ fail3(opts, err);
72694
+ }
72695
+ }
72696
+ async function memoryRm(path8, opts) {
72697
+ try {
72698
+ const { folder, name } = splitPath(path8);
72699
+ const { wallet } = await requirePasswordsKey();
72700
+ const mem = await readMemory(wallet);
72701
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72702
+ const hit = await findByName(wallet, key, folder, name);
72703
+ if (!hit) throw new MemoryError(`no "${name}" in ${folder}`, "not_found");
72704
+ await removeObject(wallet, folder, hit.id);
72705
+ emit6(opts, { ok: true, folder, name, id: hit.id, removed: true }, () => process.stdout.write(`
72706
+ ${import_picocolors13.default.green("\u2713")} ${folder}/${name} removed
72707
+
72708
+ `));
72709
+ } catch (err) {
72710
+ fail3(opts, err);
72711
+ }
72712
+ }
72713
+ async function grepMemory(wallet, key, pattern, folders) {
72714
+ const hits = [];
72715
+ for (const folder of folders) {
72716
+ const listing = await listFolder(wallet, folder);
72717
+ for (const o of openNames(key, key.address, listing.objects)) {
72718
+ if (!o.name) continue;
72719
+ let text;
72720
+ try {
72721
+ text = (await openBody2(wallet, key, folder, o.id)).text;
72722
+ } catch {
72723
+ continue;
72724
+ }
72725
+ text.split("\n").forEach((line2, i) => {
72726
+ if (pattern.test(line2)) hits.push({ folder, name: o.name, line: i + 1, text: line2 });
72727
+ pattern.lastIndex = 0;
72728
+ });
72729
+ }
72730
+ }
72731
+ return hits;
72732
+ }
72733
+ async function memoryGrep(patternRaw, folder, opts) {
72734
+ try {
72735
+ let pattern;
72736
+ try {
72737
+ pattern = new RegExp(patternRaw, opts.ignoreCase ? "i" : "");
72738
+ } catch {
72739
+ throw new MemoryError(`"${patternRaw}" is not a pattern this grep reads (a JavaScript regular expression)`, "bad_pattern");
72740
+ }
72741
+ if (folder && !isMemoryFolder(folder)) throw new MemoryError(`folder: 1-40 chars of a-z, 0-9 and -, got "${folder}"`, "bad_folder");
72742
+ const { wallet } = await requirePasswordsKey();
72743
+ const mem = await readMemory(wallet);
72744
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72745
+ const folders = folder ? [folder] : mem.folders.map((f2) => f2.folder);
72746
+ const hits = await grepMemory(wallet, key, pattern, folders);
72747
+ emit6(opts, { ok: true, pattern: patternRaw, folders, hits }, () => {
72748
+ if (hits.length === 0) {
72749
+ process.stdout.write(`
72750
+ ${import_picocolors13.default.dim(`nothing matches ${patternRaw} in ${folders.join(", ") || "no folders"}`)}
72751
+
72752
+ `);
72753
+ return;
72754
+ }
72755
+ for (const h of hits) process.stdout.write(`${import_picocolors13.default.bold(`${h.folder}/${h.name}`)}${import_picocolors13.default.dim(`:${h.line}:`)} ${h.text}
72756
+ `);
72757
+ });
72758
+ } catch (err) {
72759
+ fail3(opts, err);
72760
+ }
72761
+ }
72762
+ async function readStdin() {
72763
+ if (process.stdin.isTTY) return "";
72764
+ const chunks = [];
72765
+ for await (const chunk of process.stdin) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
72766
+ return Buffer.concat(chunks).toString("utf8");
72767
+ }
72768
+
72194
72769
  // src/commands/mcp.ts
72195
72770
  var MCP_SERVER_NAME = "agentgates";
72196
72771
  var WAIT_DEFAULT_S = 120;
72197
72772
  var WAIT_MAX_S = 600;
72198
72773
  var CODE_WAIT_DEFAULT_S = 60;
72199
72774
  var CODE_WAIT_MAX_S = 110;
72200
- var INSTRUCTIONS = "Agentgates: an agent's own logins, browser, phone numbers and inboxes, signed by the key on this machine. Start with `whoami` to learn this key's address; a person allows it on their Passwords board (agentgates passwords allow --agent <address>), or the key holds its own logins (agentgates passwords add). `passwords_list` shows the rows this key holds and may use. `passwords_use` logs in through the confidential VM and returns the page; `passwords_code` reads the newest sign-in code a site mailed the owner's Gmail. `browser_run` works a site toward a goal in a real browser; `phone_sms_wait` and `inbox_wait_code` wait for a code texted or mailed to a number or inbox the account leases. Every use meters from the account's prepaid balance past the plan's allowance; a refusal is the lane's own sentence with its code.";
72775
+ var INSTRUCTIONS = "Agentgates: an agent's own logins, browser, phone numbers and inboxes, signed by the key on this machine. Start with `whoami` to learn this key's address; a person allows it on their Passwords board (agentgates passwords allow --agent <address>), or the key holds its own logins (agentgates passwords add). `passwords_list` shows the rows this key holds and may use. `passwords_use` logs in through the confidential VM and returns the page; `passwords_code` reads the newest sign-in code a site mailed the owner's Gmail. `browser_run` works a site toward a goal in a real browser; `phone_sms_wait` and `inbox_wait_code` wait for a code texted or mailed to a number or inbox the account leases. `memory_list`, `memory_read`, `memory_write` and `memory_grep` are the account's sealed memory: markdown files opened and sealed on this machine with the key's own copy of the data key, so the server never sees a word. Every use meters from the account's prepaid balance past the plan's allowance; a refusal is the lane's own sentence with its code.";
72201
72776
  function str(args, name) {
72202
72777
  const v = args[name];
72203
72778
  return typeof v === "string" && v.trim() ? v.trim() : void 0;
@@ -72240,6 +72815,135 @@ function mcpTools() {
72240
72815
  };
72241
72816
  }
72242
72817
  },
72818
+ {
72819
+ name: "memory_sources",
72820
+ description: "The connected accounts (Dropbox, Google Drive) and the folders the owner chose on them, each with its context. A connected folder reads live: memory_list with folder <context>/<folder> lists inside it, memory_read with <context>/<folder>/<file> opens a text file. Free.",
72821
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
72822
+ handler: async () => {
72823
+ const { wallet } = await requirePasswordsKey();
72824
+ const mem = await readMemory(wallet);
72825
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72826
+ const opened = openSources(key, key.address, await readSources(wallet));
72827
+ return { ok: true, sources: opened.map((s) => ({ id: s.id, provider: s.provider, account: s.label, folders: s.folders.map((f2) => ({ name: f2.name, context: f2.context })) })) };
72828
+ }
72829
+ },
72830
+ {
72831
+ name: "memory_list",
72832
+ description: "The account's sealed memory: every folder with its counts, or one folder's files with their names opened here. Free. No folder = the folders; a folder = its files.",
72833
+ inputSchema: { type: "object", properties: { folder: { type: "string", description: "a folder slug (a-z, 0-9, -), or <context>/<connected folder>[/<inside>] to list inside a connected account; omit for the folders" } }, additionalProperties: false },
72834
+ handler: async (args) => {
72835
+ const { wallet } = await requirePasswordsKey();
72836
+ const mem = await readMemory(wallet);
72837
+ const target = str(args, "folder");
72838
+ if (!target) return { ok: true, sealed: mem.sealed, folders: mem.folders, capacity: mem.capacity, scope: mem.scope };
72839
+ const [folder, ...rest] = target.split("/").filter(Boolean);
72840
+ if (!isMemoryFolder(folder ?? "")) throw new McpToolError("folder is a slug: a-z, 0-9 and -, up to 40 chars");
72841
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72842
+ const opened = openSources(key, key.address, await readSources(wallet).catch(() => []));
72843
+ if (rest.length > 0) {
72844
+ const hit = resolveConnected(opened, folder, rest);
72845
+ if (!hit) throw new McpToolError(`no connected folder "${rest[0]}" under ${folder}`);
72846
+ return { ok: true, path: target, connected: { provider: hit.source.provider, account: hit.source.label }, entries: await listConnected(wallet, key, key.address, hit) };
72847
+ }
72848
+ if (opened.some((x) => x.provider === folder)) {
72849
+ return { ok: true, provider: folder, connected: connectedIn(opened, folder).map(({ source, folder: f2 }) => ({ name: f2.name, account: source.label })) };
72850
+ }
72851
+ const listing = await listFolder(wallet, folder);
72852
+ const files = openNames(key, key.address, listing.objects).map((o) => ({ name: o.name, bytes: o.bytes, version: o.version, updatedAt: o.updatedAt }));
72853
+ const connected = connectedIn(opened, folder).map(({ source, folder: f2 }) => ({ name: f2.name, provider: source.provider, account: source.label }));
72854
+ return { ok: true, folder, files, connected };
72855
+ }
72856
+ },
72857
+ {
72858
+ name: "memory_read",
72859
+ description: "One memory file's text, <folder>/<name>, opened on this machine. Free.",
72860
+ inputSchema: { type: "object", properties: { path: { type: "string", description: "<folder>/<name>" } }, required: ["path"], additionalProperties: false },
72861
+ handler: async (args) => {
72862
+ const path8 = need(args, "path", "<folder>/<name>");
72863
+ const { wallet } = await requirePasswordsKey();
72864
+ const mem = await readMemory(wallet);
72865
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72866
+ const segments = path8.split("/").filter(Boolean);
72867
+ if (segments.length >= 3) {
72868
+ const [folder2, ...rest] = segments;
72869
+ if (!isMemoryFolder(folder2)) throw new McpToolError("folder is a slug: a-z, 0-9 and -, up to 40 chars");
72870
+ const opened = openSources(key, key.address, await readSources(wallet).catch(() => []));
72871
+ const hit2 = resolveConnected(opened, folder2, rest);
72872
+ if (!hit2) throw new McpToolError(`no connected folder "${rest[0]}" in ${folder2}`);
72873
+ return { ok: true, path: path8, connected: { provider: hit2.source.provider, account: hit2.source.label }, text: await readConnected(wallet, key, key.address, hit2) };
72874
+ }
72875
+ const { folder, name } = splitPath(path8);
72876
+ const hit = await findByName(wallet, key, folder, name);
72877
+ if (!hit) throw new McpToolError(`no "${name}" in ${folder}`);
72878
+ const { text, row } = await openBody2(wallet, key, folder, hit.id);
72879
+ return { ok: true, folder, name, version: row.version, updatedAt: row.updatedAt, text };
72880
+ }
72881
+ },
72882
+ {
72883
+ name: "memory_write",
72884
+ description: "Store or replace a memory file, <folder>/<name>, from its text (markdown with front matter: id, type, aliases, dated facts). Sealed here before it leaves; up to 256 KB. Makes the folder when it is missing. Free inside the plan's capacity.",
72885
+ inputSchema: {
72886
+ type: "object",
72887
+ properties: { path: { type: "string", description: "<folder>/<name>" }, text: { type: "string", description: "the whole file" } },
72888
+ required: ["path", "text"],
72889
+ additionalProperties: false
72890
+ },
72891
+ handler: async (args) => {
72892
+ const { folder, name } = splitPath(need(args, "path", "<folder>/<name>"));
72893
+ const text = typeof args.text === "string" ? args.text : "";
72894
+ if (!text.trim()) throw new McpToolError("text is the whole file");
72895
+ const { wallet } = await requirePasswordsKey();
72896
+ const mem = await readMemory(wallet);
72897
+ if (!mem.dataPublicKey) throw new McpToolError("this account is not sealed yet: `agentgates email seal` first");
72898
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72899
+ if (!mem.folders.some((f2) => f2.folder === folder)) await makeFolder(wallet, folder);
72900
+ const existing = await findByName(wallet, key, folder, name);
72901
+ const row = await sealAndWrite(wallet, key, mem.dataPublicKey, folder, name, text, existing?.id ?? null);
72902
+ return { ok: true, folder, name, version: row.version, bytes: row.bytes, replaced: !!existing };
72903
+ }
72904
+ },
72905
+ {
72906
+ name: "memory_remove",
72907
+ description: "Remove one memory file, <folder>/<name>. The row is the only copy.",
72908
+ inputSchema: { type: "object", properties: { path: { type: "string", description: "<folder>/<name>" } }, required: ["path"], additionalProperties: false },
72909
+ handler: async (args) => {
72910
+ const { folder, name } = splitPath(need(args, "path", "<folder>/<name>"));
72911
+ const { wallet } = await requirePasswordsKey();
72912
+ const mem = await readMemory(wallet);
72913
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72914
+ const hit = await findByName(wallet, key, folder, name);
72915
+ if (!hit) throw new McpToolError(`no "${name}" in ${folder}`);
72916
+ await removeObject(wallet, folder, hit.id);
72917
+ return { ok: true, folder, name, removed: true };
72918
+ }
72919
+ },
72920
+ {
72921
+ name: "memory_grep",
72922
+ description: "Search the memory with a regular expression: every file this key opens (or one folder), opened and matched on this machine. Returns folder, name, line and text per hit. Free.",
72923
+ inputSchema: {
72924
+ type: "object",
72925
+ properties: { pattern: { type: "string", description: "a JavaScript regular expression" }, folder: { type: "string", description: "one folder; omit for all" }, ignoreCase: { type: "boolean" } },
72926
+ required: ["pattern"],
72927
+ additionalProperties: false
72928
+ },
72929
+ handler: async (args) => {
72930
+ const raw = need(args, "pattern", "a regular expression");
72931
+ let pattern;
72932
+ try {
72933
+ pattern = new RegExp(raw, args.ignoreCase === true ? "i" : "");
72934
+ } catch {
72935
+ throw new McpToolError(`"${raw}" is not a pattern this grep reads`);
72936
+ }
72937
+ const folder = str(args, "folder");
72938
+ if (folder && !isMemoryFolder(folder)) throw new McpToolError("folder is a slug: a-z, 0-9 and -, up to 40 chars");
72939
+ const { wallet } = await requirePasswordsKey();
72940
+ const mem = await readMemory(wallet);
72941
+ const key = await memoryKey(wallet, mem.dataPublicKey);
72942
+ const folders = folder ? [folder] : mem.folders.map((f2) => f2.folder);
72943
+ const hits = await grepMemory(wallet, key, pattern, folders);
72944
+ return { ok: true, pattern: raw, folders, hits };
72945
+ }
72946
+ },
72243
72947
  {
72244
72948
  name: "passwords_list",
72245
72949
  description: "The saved logins this key holds and the ones it may use under a permit: id, label, kind, hosts, username. Clear fields only; no secret ever rides. Free.",
@@ -72402,14 +73106,14 @@ function mcpTools() {
72402
73106
  },
72403
73107
  {
72404
73108
  name: "browser_run",
72405
- description: "Queue a browser task: a real Chrome works the site toward the goal, in words, and answers with what it reached. With loginRow, the task runs INSIDE that saved login's own browser on the confidential VM (nothing copied; the site meets the browser it trusts), or starts from its copied session on an older deployment; the answer's join says which. Waits up to waitSeconds (default 120) for the answer; a task still running comes back with its id for browser_task. Steps meter from the prepaid balance; the login meters the login sticker.",
73109
+ description: "Queue a browser task: a real Chrome starts at url, goes to any public site the goal leads to (name hosts to fence it to the site and those hosts), and answers with what it reached. With loginRow, the task runs INSIDE that saved login's own browser on the confidential VM (nothing copied; the site meets the browser it trusts; it may act inside that account), or starts from its copied session on an older deployment; the answer's join says which. Queue several to run several browsers at once. Waits up to waitSeconds (default 120) for the answer; a task still running comes back with its id for browser_task. Steps meter from the prepaid balance; the login meters the login sticker.",
72406
73110
  inputSchema: {
72407
73111
  type: "object",
72408
73112
  properties: {
72409
73113
  url: { type: "string", description: "where the task starts" },
72410
73114
  goal: { type: "string", description: "what the browser agent should do there, in words" },
72411
73115
  loginRow: { type: "string", description: "start signed in with this saved login's row id (passwords_list)" },
72412
- hosts: { type: "array", items: { type: "string" }, description: "extra hostnames the task may visit" },
73116
+ hosts: { type: "array", items: { type: "string" }, description: "a fence: the task stays on the site and these hostnames; absent, it goes to any public site" },
72413
73117
  maxSteps: { type: "integer", minimum: 1, description: "the most steps it may take (the catalog's default when absent)" },
72414
73118
  maxSeconds: { type: "integer", minimum: 1, description: "the most seconds it may run (the catalog's ceiling when absent)" },
72415
73119
  waitSeconds: { type: "integer", minimum: 0, maximum: WAIT_MAX_S, description: `how long to wait for the answer (default ${WAIT_DEFAULT_S}; 0 queues and returns)` }
@@ -72550,20 +73254,20 @@ function mcpInstall() {
72550
73254
  const config = JSON.stringify({ mcpServers: { agentgates: { command: "agentgates", args: ["mcp"] } } }, null, 2);
72551
73255
  process.stdout.write(
72552
73256
  `
72553
- ${import_picocolors13.default.bold("Claude Code")}
73257
+ ${import_picocolors14.default.bold("Claude Code")}
72554
73258
  claude mcp add agentgates -- agentgates mcp
72555
73259
 
72556
- ${import_picocolors13.default.bold("Cursor, Windsurf, any MCP client")} ${import_picocolors13.default.dim("(its mcp config file)")}
73260
+ ${import_picocolors14.default.bold("Cursor, Windsurf, any MCP client")} ${import_picocolors14.default.dim("(its mcp config file)")}
72557
73261
  ${config.split("\n").map((l) => ` ${l}`).join("\n")}
72558
73262
 
72559
- ${import_picocolors13.default.dim("The server signs with this machine's key (agentgates init). Tools: " + mcpTools().map((t) => t.name).join(", ") + ".")}
73263
+ ${import_picocolors14.default.dim("The server signs with this machine's key (agentgates init). Tools: " + mcpTools().map((t) => t.name).join(", ") + ".")}
72560
73264
 
72561
73265
  `
72562
73266
  );
72563
73267
  }
72564
73268
 
72565
73269
  // src/commands/intents.ts
72566
- var import_picocolors14 = __toESM(require_picocolors(), 1);
73270
+ var import_picocolors15 = __toESM(require_picocolors(), 1);
72567
73271
  init_passwords_wire();
72568
73272
 
72569
73273
  // src/lib/intents-wire.ts
@@ -72791,7 +73495,7 @@ function firstSentence(words7) {
72791
73495
 
72792
73496
  // src/commands/intents.ts
72793
73497
  var jsonMode6 = (opts) => opts.json === true || !process.stdout.isTTY;
72794
- function emit6(opts, data4, human) {
73498
+ function emit7(opts, data4, human) {
72795
73499
  if (jsonMode6(opts)) {
72796
73500
  process.stdout.write(JSON.stringify(data4, null, 2) + "\n");
72797
73501
  return;
@@ -72802,7 +73506,7 @@ function refuse5(opts, error, code, extra = {}) {
72802
73506
  if (jsonMode6(opts)) {
72803
73507
  process.stdout.write(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
72804
73508
  } else {
72805
- process.stderr.write(` ${error}${code ? import_picocolors14.default.dim(` (${code})`) : ""}
73509
+ process.stderr.write(` ${error}${code ? import_picocolors15.default.dim(` (${code})`) : ""}
72806
73510
  `);
72807
73511
  if (typeof extra.hint === "string") process.stderr.write(` ${extra.hint}
72808
73512
  `);
@@ -72813,7 +73517,7 @@ function failFrom4(opts, err) {
72813
73517
  if (err instanceof WireError) return refuse5(opts, err.message, err.code, { status: err.status });
72814
73518
  return refuse5(opts, err.message ?? String(err), null);
72815
73519
  }
72816
- var line = (label, value) => void process.stdout.write(` ${import_picocolors14.default.dim(label.padEnd(11))}${value}
73520
+ var line = (label, value) => void process.stdout.write(` ${import_picocolors15.default.dim(label.padEnd(11))}${value}
72817
73521
  `);
72818
73522
  function whenOf(value, what) {
72819
73523
  const raw = value.trim();
@@ -72821,19 +73525,19 @@ function whenOf(value, what) {
72821
73525
  if (!Number.isFinite(ms)) throw new Error(`${what}: a time like "2026-09-11 20:00" (got ${value})`);
72822
73526
  return new Date(ms).toISOString();
72823
73527
  }
72824
- var shortAsk = (a) => `${import_picocolors14.default.dim(a.id)} ${a.state.padEnd(9)} ${a.city.padEnd(16)} ${new Date(a.windowFrom).toLocaleString()} ${import_picocolors14.default.dim(`$${usdOf(a.capMicro)}`)}
73528
+ var shortAsk = (a) => `${import_picocolors15.default.dim(a.id)} ${a.state.padEnd(9)} ${a.city.padEnd(16)} ${new Date(a.windowFrom).toLocaleString()} ${import_picocolors15.default.dim(`$${usdOf(a.capMicro)}`)}
72825
73529
  ${a.derived?.publicText ?? a.text}`;
72826
73530
  var shortOffer = (o) => {
72827
73531
  const price = o.kind === "mutual" ? "mutual" : o.house === true ? "at the venue" : `$${usdOf(o.priceMicro)}`;
72828
- const by = o.house === true ? "Agentgates books it" : import_picocolors14.default.dim(o.offerer);
72829
- return `${import_picocolors14.default.dim(o.id)} ${o.state.padEnd(10)} ${o.role.padEnd(12)} ${price.padEnd(12)} ${new Date(o.startsAt).toLocaleString()}
73532
+ const by = o.house === true ? "Agentgates books it" : import_picocolors15.default.dim(o.offerer);
73533
+ return `${import_picocolors15.default.dim(o.id)} ${o.state.padEnd(10)} ${o.role.padEnd(12)} ${price.padEnd(12)} ${new Date(o.startsAt).toLocaleString()}
72830
73534
  ${o.text}
72831
73535
  ${by}`;
72832
73536
  };
72833
73537
  var shortStep = (s) => {
72834
73538
  const { who, what, when: when3 } = stepWords(s);
72835
73539
  const tail = [when3 ? new Date(when3).toLocaleString() : "", s.costUsd ? `$${s.costUsd}` : ""].filter(Boolean).join(" ");
72836
- return `${s.state.padEnd(8)} ${who.padEnd(18)} ${what}${tail ? ` ${import_picocolors14.default.dim(tail)}` : ""}`;
73540
+ return `${s.state.padEnd(8)} ${who.padEnd(18)} ${what}${tail ? ` ${import_picocolors15.default.dim(tail)}` : ""}`;
72837
73541
  };
72838
73542
  async function intentsPost(text, opts) {
72839
73543
  try {
@@ -72852,9 +73556,9 @@ async function intentsPost(text, opts) {
72852
73556
  ...opts.publicText ? { publicText: opts.publicText } : {},
72853
73557
  ...bookingName ? { bookingName } : {}
72854
73558
  });
72855
- emit6(opts, { ok: true, ask }, () => {
73559
+ emit7(opts, { ok: true, ask }, () => {
72856
73560
  process.stdout.write(`
72857
- ${import_picocolors14.default.bold("Posted.")} Offers come in until your agent decides.
73561
+ ${import_picocolors15.default.bold("Posted.")} Offers come in until your agent decides.
72858
73562
 
72859
73563
  `);
72860
73564
  line("ask", ask.id);
@@ -72864,7 +73568,7 @@ async function intentsPost(text, opts) {
72864
73568
  line("decides", new Date(ask.decideAt).toLocaleString());
72865
73569
  if (ask.derived?.publicText) line("public", ask.derived.publicText);
72866
73570
  process.stdout.write(`
72867
- ${import_picocolors14.default.dim(`agentgates intents show ${ask.id}`)}
73571
+ ${import_picocolors15.default.dim(`agentgates intents show ${ask.id}`)}
72868
73572
 
72869
73573
  `);
72870
73574
  });
@@ -72876,10 +73580,10 @@ async function intentsList(opts) {
72876
73580
  try {
72877
73581
  const { wallet } = await requirePasswordsKey();
72878
73582
  const asks = await listAsks(wallet);
72879
- emit6(opts, { ok: true, asks }, () => {
73583
+ emit7(opts, { ok: true, asks }, () => {
72880
73584
  if (asks.length === 0) {
72881
73585
  process.stdout.write(`
72882
- Nothing posted yet. ${import_picocolors14.default.dim('agentgates intents post "\u2026"')}
73586
+ Nothing posted yet. ${import_picocolors15.default.dim('agentgates intents post "\u2026"')}
72883
73587
 
72884
73588
  `);
72885
73589
  return;
@@ -72897,9 +73601,9 @@ async function intentsShow(id2, opts) {
72897
73601
  try {
72898
73602
  const { wallet } = await requirePasswordsKey();
72899
73603
  const d = await readAsk(wallet, id2);
72900
- emit6(opts, { ok: true, ...d }, () => {
73604
+ emit7(opts, { ok: true, ...d }, () => {
72901
73605
  process.stdout.write(`
72902
- ${import_picocolors14.default.bold(d.ask.text)}
73606
+ ${import_picocolors15.default.bold(d.ask.text)}
72903
73607
 
72904
73608
  `);
72905
73609
  line("ask", d.ask.id);
@@ -72908,17 +73612,17 @@ async function intentsShow(id2, opts) {
72908
73612
  line("budget", `$${usdOf(d.ask.capMicro)}`);
72909
73613
  if (d.plan) {
72910
73614
  process.stdout.write(`
72911
- ${import_picocolors14.default.bold("The plan")} ${import_picocolors14.default.dim(`(${d.plan.state}, decided by ${d.plan.decidedBy})`)}
73615
+ ${import_picocolors15.default.bold("The plan")} ${import_picocolors15.default.dim(`(${d.plan.state}, decided by ${d.plan.decidedBy})`)}
72912
73616
  `);
72913
73617
  if (d.plan.rationale) process.stdout.write(` ${d.plan.rationale}
72914
73618
  `);
72915
73619
  line("total", `$${usdOf(d.plan.totalMicro)}`);
72916
- for (const q of d.plan.questions) process.stdout.write(` ${import_picocolors14.default.dim("asks you")} ${q.why}
73620
+ for (const q of d.plan.questions) process.stdout.write(` ${import_picocolors15.default.dim("asks you")} ${q.why}
72917
73621
  `);
72918
73622
  }
72919
73623
  if (d.offers.length) {
72920
73624
  process.stdout.write(`
72921
- ${import_picocolors14.default.bold("Offers")}
73625
+ ${import_picocolors15.default.bold("Offers")}
72922
73626
  `);
72923
73627
  for (const o of d.offers) process.stdout.write(` ${shortOffer(o)}
72924
73628
 
@@ -72926,18 +73630,18 @@ async function intentsShow(id2, opts) {
72926
73630
  }
72927
73631
  const steps = d.steps ?? [];
72928
73632
  if (steps.length) {
72929
- process.stdout.write(` ${import_picocolors14.default.bold("What your agent did")}
73633
+ process.stdout.write(` ${import_picocolors15.default.bold("What your agent did")}
72930
73634
  `);
72931
73635
  for (const s of steps) process.stdout.write(` ${shortStep(s)}
72932
73636
  `);
72933
73637
  process.stdout.write("\n");
72934
73638
  }
72935
73639
  if (d.settlements.length) {
72936
- process.stdout.write(` ${import_picocolors14.default.bold("Money")}
73640
+ process.stdout.write(` ${import_picocolors15.default.bold("Money")}
72937
73641
  `);
72938
73642
  for (const s of d.settlements) {
72939
- const tx = s.settledTx ? import_picocolors14.default.dim(` ${s.settledTx}`) : "";
72940
- process.stdout.write(` ${import_picocolors14.default.dim(s.offerId)} ${s.state.padEnd(10)} $${usdOf(s.valueMicro)} \u2192 ${s.toAddr}${tx}
73643
+ const tx = s.settledTx ? import_picocolors15.default.dim(` ${s.settledTx}`) : "";
73644
+ process.stdout.write(` ${import_picocolors15.default.dim(s.offerId)} ${s.state.padEnd(10)} $${usdOf(s.valueMicro)} \u2192 ${s.toAddr}${tx}
72941
73645
  `);
72942
73646
  }
72943
73647
  process.stdout.write("\n");
@@ -72951,9 +73655,9 @@ async function intentsDecide(id2, opts) {
72951
73655
  try {
72952
73656
  const { wallet } = await requirePasswordsKey();
72953
73657
  const out = await decideAsk(wallet, id2);
72954
- emit6(opts, { ok: true, ...out }, () => {
73658
+ emit7(opts, { ok: true, ...out }, () => {
72955
73659
  process.stdout.write(`
72956
- ${import_picocolors14.default.bold("Your agent decided.")} ${import_picocolors14.default.dim(`(${out.plan.decidedBy})`)}
73660
+ ${import_picocolors15.default.bold("Your agent decided.")} ${import_picocolors15.default.dim(`(${out.plan.decidedBy})`)}
72957
73661
 
72958
73662
  `);
72959
73663
  if (out.plan.rationale) process.stdout.write(` ${out.plan.rationale}
@@ -72961,10 +73665,10 @@ async function intentsDecide(id2, opts) {
72961
73665
  `);
72962
73666
  line("picks", out.plan.offerIds.join(", ") || "none");
72963
73667
  line("total", `$${usdOf(out.plan.totalMicro)}`);
72964
- for (const q of out.plan.questions) process.stdout.write(` ${import_picocolors14.default.dim("asks you")} ${q.why}
73668
+ for (const q of out.plan.questions) process.stdout.write(` ${import_picocolors15.default.dim("asks you")} ${q.why}
72965
73669
  `);
72966
73670
  process.stdout.write(`
72967
- ${import_picocolors14.default.dim(`agentgates intents pay ${id2} --pick <offerId>`)}
73671
+ ${import_picocolors15.default.dim(`agentgates intents pay ${id2} --pick <offerId>`)}
72968
73672
 
72969
73673
  `);
72970
73674
  });
@@ -72991,20 +73695,20 @@ async function intentsPay(id2, opts) {
72991
73695
  const group = escrowGroupToSign(answered.escrow ?? [], opts.network);
72992
73696
  if (group) escrowPayments.push(await signEscrow(wallet, group));
72993
73697
  const committed = await commitAsk(wallet, id2, payments, escrowPayments, bookingName);
72994
- emit6(opts, { ok: true, ...committed, signed: payments.length, bound: escrowPayments.length, ...bookingName ? { bookingName } : {} }, () => {
73698
+ emit7(opts, { ok: true, ...committed, signed: payments.length, bound: escrowPayments.length, ...bookingName ? { bookingName } : {} }, () => {
72995
73699
  process.stdout.write(`
72996
- ${import_picocolors14.default.bold("Committed.")} ${committed.picked.length} picked, ${committed.passed} passed.
73700
+ ${import_picocolors15.default.bold("Committed.")} ${committed.picked.length} picked, ${committed.passed} passed.
72997
73701
 
72998
73702
  `);
72999
73703
  for (const s of committed.settlements) {
73000
73704
  const how = s.state === "escrowed" ? `bound in ${s.escrowAddress}` : "signed, settles when it happens";
73001
- process.stdout.write(` ${import_picocolors14.default.dim(s.offerId)} $${usdOf(s.valueMicro)} \u2192 ${s.toAddr} ${import_picocolors14.default.dim(how)}
73705
+ process.stdout.write(` ${import_picocolors15.default.dim(s.offerId)} $${usdOf(s.valueMicro)} \u2192 ${s.toAddr} ${import_picocolors15.default.dim(how)}
73002
73706
  `);
73003
73707
  }
73004
- if (bookingName) process.stdout.write(` ${import_picocolors14.default.dim(`Agentgates books under ${bookingName}.`)}
73708
+ if (bookingName) process.stdout.write(` ${import_picocolors15.default.dim(`Agentgates books under ${bookingName}.`)}
73005
73709
  `);
73006
73710
  process.stdout.write(`
73007
- ${import_picocolors14.default.dim("Nothing left your wallet yet. Each provider settles its own when it delivers.")}
73711
+ ${import_picocolors15.default.dim("Nothing left your wallet yet. Each provider settles its own when it delivers.")}
73008
73712
 
73009
73713
  `);
73010
73714
  });
@@ -73029,11 +73733,11 @@ async function intentsWord(id2, opts) {
73029
73733
  return refuse5(opts, "This leg is on Solana: its word is signed by a Solana wallet, which this key is not.", "svm_word");
73030
73734
  }
73031
73735
  const settlement = await wordOnLeg(wallet, id2, opts.offer, happened, said?.word);
73032
- emit6(opts, { ok: true, settlement }, () => {
73736
+ emit7(opts, { ok: true, settlement }, () => {
73033
73737
  process.stdout.write(`
73034
- ${happened ? "It happened." : "It did not happen."} ${import_picocolors14.default.dim(settlement.state)}
73738
+ ${happened ? "It happened." : "It did not happen."} ${import_picocolors15.default.dim(settlement.state)}
73035
73739
  `);
73036
- if (settlement.settledTx) process.stdout.write(` ${import_picocolors14.default.dim(settlement.settledTx)}
73740
+ if (settlement.settledTx) process.stdout.write(` ${import_picocolors15.default.dim(settlement.settledTx)}
73037
73741
  `);
73038
73742
  process.stdout.write("\n");
73039
73743
  });
@@ -73045,8 +73749,8 @@ async function intentsClose(id2, opts) {
73045
73749
  try {
73046
73750
  const { wallet } = await requirePasswordsKey();
73047
73751
  const ask = await closeAsk(wallet, id2);
73048
- emit6(opts, { ok: true, ask }, () => process.stdout.write(`
73049
- Closed. ${import_picocolors14.default.dim(ask.state)}
73752
+ emit7(opts, { ok: true, ask }, () => process.stdout.write(`
73753
+ Closed. ${import_picocolors15.default.dim(ask.state)}
73050
73754
 
73051
73755
  `));
73052
73756
  } catch (err) {
@@ -73059,14 +73763,14 @@ async function intentsContext(opts) {
73059
73763
  const writing = opts.note !== void 0 || opts.learned !== void 0;
73060
73764
  const current = await readContext(wallet);
73061
73765
  const context = writing ? await putContext(wallet, opts.note ?? current.note, opts.learned ?? current.learned) : current;
73062
- emit6(opts, { ok: true, context }, () => {
73766
+ emit7(opts, { ok: true, context }, () => {
73063
73767
  process.stdout.write(`
73064
- ${import_picocolors14.default.bold("What your agent knows")} ${import_picocolors14.default.dim("(read by your agent only)")}
73768
+ ${import_picocolors15.default.bold("What your agent knows")} ${import_picocolors15.default.dim("(read by your agent only)")}
73065
73769
 
73066
73770
  `);
73067
- process.stdout.write(` ${context.note || import_picocolors14.default.dim("nothing written yet")}
73771
+ process.stdout.write(` ${context.note || import_picocolors15.default.dim("nothing written yet")}
73068
73772
  `);
73069
- for (const l of context.learned) process.stdout.write(` ${import_picocolors14.default.dim("learned")} ${l}
73773
+ for (const l of context.learned) process.stdout.write(` ${import_picocolors15.default.dim("learned")} ${l}
73070
73774
  `);
73071
73775
  process.stdout.write("\n");
73072
73776
  });
@@ -73079,7 +73783,7 @@ async function intentsOpen(opts) {
73079
73783
  const { wallet } = await requirePasswordsKey();
73080
73784
  if (!opts.city) return refuse5(opts, "--city: where you can serve", "no_city");
73081
73785
  const asks = await openAsks(wallet, opts.city);
73082
- emit6(opts, { ok: true, asks }, () => {
73786
+ emit7(opts, { ok: true, asks }, () => {
73083
73787
  if (asks.length === 0) {
73084
73788
  process.stdout.write(`
73085
73789
  Nothing open in ${opts.city} right now.
@@ -73090,7 +73794,7 @@ async function intentsOpen(opts) {
73090
73794
  process.stdout.write("\n");
73091
73795
  for (const a of asks) {
73092
73796
  process.stdout.write(
73093
- ` ${import_picocolors14.default.dim(a.id)} ${new Date(a.windowFrom).toLocaleString()} ${import_picocolors14.default.dim(`up to $${usdOf(a.capMicro)}`)}
73797
+ ` ${import_picocolors15.default.dim(a.id)} ${new Date(a.windowFrom).toLocaleString()} ${import_picocolors15.default.dim(`up to $${usdOf(a.capMicro)}`)}
73094
73798
  ${a.text}
73095
73799
 
73096
73800
  `
@@ -73130,9 +73834,9 @@ async function intentsOffer(askId, opts) {
73130
73834
  ...charge === "at_service" ? {} : { charge: { mode: charge } },
73131
73835
  ...opts.place || opts.address ? { place: { ...opts.place ? { name: opts.place } : {}, ...opts.address ? { address: opts.address } : {} } } : {}
73132
73836
  });
73133
- emit6(opts, { ok: true, offer }, () => {
73837
+ emit7(opts, { ok: true, offer }, () => {
73134
73838
  process.stdout.write(`
73135
- ${import_picocolors14.default.bold("Offered.")}
73839
+ ${import_picocolors15.default.bold("Offered.")}
73136
73840
 
73137
73841
  `);
73138
73842
  line("offer", offer.id);
@@ -73151,10 +73855,10 @@ async function intentsOffers(opts) {
73151
73855
  try {
73152
73856
  const { wallet } = await requirePasswordsKey();
73153
73857
  const offers = await listMyOffers(wallet);
73154
- emit6(opts, { ok: true, offers }, () => {
73858
+ emit7(opts, { ok: true, offers }, () => {
73155
73859
  if (offers.length === 0) {
73156
73860
  process.stdout.write(`
73157
- You have made no offers. ${import_picocolors14.default.dim("agentgates intents open --city \u2026")}
73861
+ You have made no offers. ${import_picocolors15.default.dim("agentgates intents open --city \u2026")}
73158
73862
 
73159
73863
  `);
73160
73864
  return;
@@ -73173,8 +73877,8 @@ async function intentsConfirm(askId, opts) {
73173
73877
  const { wallet } = await requirePasswordsKey();
73174
73878
  if (!opts.offer) return refuse5(opts, "--offer <offerId>: the offer of yours that was picked", "no_offer");
73175
73879
  const offer = await confirmOffer(wallet, askId, opts.offer);
73176
- emit6(opts, { ok: true, offer }, () => process.stdout.write(`
73177
- Confirmed. ${import_picocolors14.default.dim(offer.state)}
73880
+ emit7(opts, { ok: true, offer }, () => process.stdout.write(`
73881
+ Confirmed. ${import_picocolors15.default.dim(offer.state)}
73178
73882
 
73179
73883
  `));
73180
73884
  } catch (err) {
@@ -73186,11 +73890,11 @@ async function intentsSettle(askId, opts) {
73186
73890
  const { wallet } = await requirePasswordsKey();
73187
73891
  if (!opts.offer) return refuse5(opts, "--offer <offerId>: the leg you delivered", "no_offer");
73188
73892
  const out = await settleOffer(wallet, askId, opts.offer);
73189
- emit6(opts, { ok: true, ...out }, () => {
73893
+ emit7(opts, { ok: true, ...out }, () => {
73190
73894
  process.stdout.write(`
73191
- ${import_picocolors14.default.bold("Settled.")} $${usdOf(out.settlement.valueMicro)} to ${out.settlement.toAddr}
73895
+ ${import_picocolors15.default.bold("Settled.")} $${usdOf(out.settlement.valueMicro)} to ${out.settlement.toAddr}
73192
73896
  `);
73193
- process.stdout.write(` ${import_picocolors14.default.dim(out.txHash)}
73897
+ process.stdout.write(` ${import_picocolors15.default.dim(out.txHash)}
73194
73898
 
73195
73899
  `);
73196
73900
  });
@@ -73209,7 +73913,7 @@ function claimLines(c) {
73209
73913
  }
73210
73914
  function rulesLines(r) {
73211
73915
  line("agent", r.mode === "auto" ? "offers on its own" : "asks you first");
73212
- for (const l of r.lines) line(l.label.toLowerCase(), `${l.words}${l.fixed ? import_picocolors14.default.dim(" (fixed)") : ""}`);
73916
+ for (const l of r.lines) line(l.label.toLowerCase(), `${l.words}${l.fixed ? import_picocolors15.default.dim(" (fixed)") : ""}`);
73213
73917
  }
73214
73918
  async function intentsListing(id2, opts) {
73215
73919
  try {
@@ -73221,9 +73925,9 @@ async function intentsListing(id2, opts) {
73221
73925
  }
73222
73926
  if (!listingId) return refuse5(opts, "a listing id, or --phone <number> to find one", "no_listing");
73223
73927
  const { listing, near } = await readListingPublic(listingId);
73224
- emit6(opts, { ok: true, listing, near }, () => {
73928
+ emit7(opts, { ok: true, listing, near }, () => {
73225
73929
  process.stdout.write(`
73226
- ${import_picocolors14.default.bold(listing.name)} ${import_picocolors14.default.dim(listing.id)}
73930
+ ${import_picocolors15.default.bold(listing.name)} ${import_picocolors15.default.dim(listing.id)}
73227
73931
 
73228
73932
  `);
73229
73933
  line("address", [listing.address, listing.city].filter(Boolean).join(", "));
@@ -73234,14 +73938,14 @@ async function intentsListing(id2, opts) {
73234
73938
  line("rating", listing.ratingWords ?? ratingWordsOf(listing.rating));
73235
73939
  if (near.length) {
73236
73940
  process.stdout.write(`
73237
- ${import_picocolors14.default.dim(`open asks in ${listing.city}`)}
73941
+ ${import_picocolors15.default.dim(`open asks in ${listing.city}`)}
73238
73942
  `);
73239
- for (const a of near) process.stdout.write(` ${import_picocolors14.default.dim(a.id)} ${new Date(a.windowFrom).toLocaleString()} up to $${usdOf(a.capMicro)}
73943
+ for (const a of near) process.stdout.write(` ${import_picocolors15.default.dim(a.id)} ${new Date(a.windowFrom).toLocaleString()} up to $${usdOf(a.capMicro)}
73240
73944
  ${a.text}
73241
73945
  `);
73242
73946
  }
73243
73947
  process.stdout.write(`
73244
- ${import_picocolors14.default.dim(`agentgates intents claim ${listing.id} --by phone`)}
73948
+ ${import_picocolors15.default.dim(`agentgates intents claim ${listing.id} --by phone`)}
73245
73949
 
73246
73950
  `);
73247
73951
  });
@@ -73256,14 +73960,14 @@ async function intentsClaim(listingId, opts) {
73256
73960
  if (by !== "phone" && by !== "domain" && by !== "dns") return refuse5(opts, "--by phone, domain or dns", "bad_method");
73257
73961
  if (by === "domain" && !opts.mailbox) return refuse5(opts, "--mailbox <name>: the name before the @ at the listed domain", "no_mailbox");
73258
73962
  const out = await startClaim(wallet, listingId, by, opts.mailbox);
73259
- emit6(opts, { ok: true, ...out }, () => {
73963
+ emit7(opts, { ok: true, ...out }, () => {
73260
73964
  process.stdout.write(`
73261
- ${import_picocolors14.default.bold(out.listing.name)}
73965
+ ${import_picocolors15.default.bold(out.listing.name)}
73262
73966
 
73263
73967
  `);
73264
73968
  claimLines(out.claim);
73265
73969
  process.stdout.write(`
73266
- ${import_picocolors14.default.dim(by === "dns" ? `set the record, then: agentgates intents verify ${listingId}` : `agentgates intents verify ${listingId} --code <six digits>`)}
73970
+ ${import_picocolors15.default.dim(by === "dns" ? `set the record, then: agentgates intents verify ${listingId}` : `agentgates intents verify ${listingId} --code <six digits>`)}
73267
73971
 
73268
73972
  `);
73269
73973
  });
@@ -73275,11 +73979,11 @@ async function intentsVerify(listingId, opts) {
73275
73979
  try {
73276
73980
  const { wallet } = await requirePasswordsKey();
73277
73981
  const out = await verifyClaim(wallet, listingId, opts.code);
73278
- emit6(opts, { ok: true, ...out }, () => {
73982
+ emit7(opts, { ok: true, ...out }, () => {
73279
73983
  process.stdout.write(`
73280
- ${import_picocolors14.default.bold("Yours.")} ${out.listing.name} \xB7 ${verifiedWords(out.listing.verified)}${out.unbound ? " \xB7 the key that held it before was unbound and told" : ""}
73984
+ ${import_picocolors15.default.bold("Yours.")} ${out.listing.name} \xB7 ${verifiedWords(out.listing.verified)}${out.unbound ? " \xB7 the key that held it before was unbound and told" : ""}
73281
73985
  `);
73282
- process.stdout.write(` ${import_picocolors14.default.dim(`agentgates intents rules ${listingId} "<what you offer, when, the price, for how many, how you are paid, cancellation>"`)}
73986
+ process.stdout.write(` ${import_picocolors15.default.dim(`agentgates intents rules ${listingId} "<what you offer, when, the price, for how many, how you are paid, cancellation>"`)}
73283
73987
 
73284
73988
  `);
73285
73989
  });
@@ -73310,11 +74014,11 @@ async function intentsRules(listingId, words7, opts) {
73310
74014
  rules = board.rules;
73311
74015
  }
73312
74016
  if (!rules) return refuse5(opts, "no rules yet: say them in your words", "no_rules");
73313
- emit6(opts, { ok: true, rules }, () => {
74017
+ emit7(opts, { ok: true, rules }, () => {
73314
74018
  process.stdout.write("\n");
73315
74019
  rulesLines(rules);
73316
74020
  process.stdout.write(`
73317
- ${import_picocolors14.default.dim(`fix a line: agentgates intents rules ${listingId} --fix "price=$95 per person"`)}
74021
+ ${import_picocolors15.default.dim(`fix a line: agentgates intents rules ${listingId} --fix "price=$95 per person"`)}
73318
74022
 
73319
74023
  `);
73320
74024
  });
@@ -73327,10 +74031,10 @@ async function intentsBoard(listingId, opts) {
73327
74031
  const { wallet } = await requirePasswordsKey();
73328
74032
  const board = await readBoard(wallet, listingId);
73329
74033
  const claim = await readMyClaim(wallet, listingId, "payout").catch(() => null);
73330
- emit6(opts, { ok: true, board, payoutClaim: claim }, () => {
74034
+ emit7(opts, { ok: true, board, payoutClaim: claim }, () => {
73331
74035
  const l = board.listing;
73332
74036
  process.stdout.write(`
73333
- ${import_picocolors14.default.bold(l.name)} ${import_picocolors14.default.dim(l.id)}
74037
+ ${import_picocolors15.default.bold(l.name)} ${import_picocolors15.default.dim(l.id)}
73334
74038
 
73335
74039
  `);
73336
74040
  line("status", `${verifiedWords(l.verified)}${l.contested ? " \xB7 a claim is being decided" : ""}`);
@@ -73338,30 +74042,30 @@ async function intentsBoard(listingId, opts) {
73338
74042
  line("paid to", board.payout.kind === "venue" ? "at the venue" : board.payout.kind === "address" ? `an address on ${Object.keys(board.payout.payTo).join(", ")}` : "this account");
73339
74043
  if (board.rules) rulesLines(board.rules);
73340
74044
  process.stdout.write(`
73341
- ${import_picocolors14.default.dim("picks")}
74045
+ ${import_picocolors15.default.dim("picks")}
73342
74046
  `);
73343
74047
  if (board.picks.length === 0) process.stdout.write(" none yet\n");
73344
- for (const p of board.picks) process.stdout.write(` ${import_picocolors14.default.dim(p.offer.id)} ${p.offer.role.padEnd(10)} ${new Date(p.offer.startsAt).toLocaleString()} ${p.offer.priceMicro === "0" ? "at the venue" : `$${usdOf(p.offer.priceMicro)}`} ${p.settlement?.state ?? p.offer.state}
74048
+ for (const p of board.picks) process.stdout.write(` ${import_picocolors15.default.dim(p.offer.id)} ${p.offer.role.padEnd(10)} ${new Date(p.offer.startsAt).toLocaleString()} ${p.offer.priceMicro === "0" ? "at the venue" : `$${usdOf(p.offer.priceMicro)}`} ${p.settlement?.state ?? p.offer.state}
73345
74049
  ${p.ask?.text ?? ""}
73346
74050
  `);
73347
74051
  if (board.open.length) {
73348
74052
  process.stdout.write(`
73349
- ${import_picocolors14.default.dim("offers out")}
74053
+ ${import_picocolors15.default.dim("offers out")}
73350
74054
  `);
73351
- for (const o of board.open) process.stdout.write(` ${import_picocolors14.default.dim(o.offer.id)} ${o.offer.role.padEnd(10)} ${new Date(o.offer.startsAt).toLocaleString()} $${usdOf(o.offer.priceMicro)}
74055
+ for (const o of board.open) process.stdout.write(` ${import_picocolors15.default.dim(o.offer.id)} ${o.offer.role.padEnd(10)} ${new Date(o.offer.startsAt).toLocaleString()} $${usdOf(o.offer.priceMicro)}
73352
74056
  ${o.ask?.text ?? ""}
73353
74057
  `);
73354
74058
  }
73355
74059
  if (board.rating.rows.length) {
73356
74060
  process.stdout.write(`
73357
- ${import_picocolors14.default.dim("ratings")}
74061
+ ${import_picocolors15.default.dim("ratings")}
73358
74062
  `);
73359
- for (const r of board.rating.rows) process.stdout.write(` ${"\u2605".repeat(r.stars)} ${r.words} ${import_picocolors14.default.dim(new Date(r.at).toLocaleDateString())}
74063
+ for (const r of board.rating.rows) process.stdout.write(` ${"\u2605".repeat(r.stars)} ${r.words} ${import_picocolors15.default.dim(new Date(r.at).toLocaleDateString())}
73360
74064
  `);
73361
74065
  }
73362
74066
  if (board.texts.length) {
73363
74067
  process.stdout.write(`
73364
- ${import_picocolors14.default.dim(`texts to ${l.phone ?? "the listed phone"}`)}
74068
+ ${import_picocolors15.default.dim(`texts to ${l.phone ?? "the listed phone"}`)}
73365
74069
  `);
73366
74070
  for (const t of board.texts) process.stdout.write(` ${t.what} ${new Date(t.at).toLocaleString()} ${t.ok ? "sent" : `did not go: ${t.reason ?? "refused"}`}
73367
74071
  `);
@@ -73378,14 +74082,14 @@ async function intentsPayout(listingId, opts) {
73378
74082
  const wantsSet = opts.venue === true || Boolean(opts.to);
73379
74083
  if (!wantsSet) {
73380
74084
  const out2 = await setPayout(wallet, listingId, {});
73381
- emit6(opts, { ok: true, ...out2 }, () => {
74085
+ emit7(opts, { ok: true, ...out2 }, () => {
73382
74086
  process.stdout.write(`
73383
74087
  A code is on its way to the listed phone.
73384
74088
 
73385
74089
  `);
73386
74090
  if (out2.claim) claimLines(out2.claim);
73387
74091
  process.stdout.write(`
73388
- ${import_picocolors14.default.dim(`agentgates intents payout ${listingId} --code <six digits> --to <USDC address> (or --venue)`)}
74092
+ ${import_picocolors15.default.dim(`agentgates intents payout ${listingId} --code <six digits> --to <USDC address> (or --venue)`)}
73389
74093
 
73390
74094
  `);
73391
74095
  });
@@ -73396,9 +74100,9 @@ async function intentsPayout(listingId, opts) {
73396
74100
  const payTo = {};
73397
74101
  if (opts.to) for (const c of chains) payTo[c] = opts.to;
73398
74102
  const out = await setPayout(wallet, listingId, { code: opts.code, ...opts.venue ? { venue: true } : { payTo } });
73399
- emit6(opts, { ok: true, ...out }, () => {
74103
+ emit7(opts, { ok: true, ...out }, () => {
73400
74104
  process.stdout.write(`
73401
- ${import_picocolors14.default.bold("Set.")} Paid ${out.payout.kind === "venue" ? "at the venue" : `to your address on ${Object.keys(out.payout.payTo).join(", ")}`}.
74105
+ ${import_picocolors15.default.bold("Set.")} Paid ${out.payout.kind === "venue" ? "at the venue" : `to your address on ${Object.keys(out.payout.payTo).join(", ")}`}.
73402
74106
 
73403
74107
  `);
73404
74108
  });
@@ -73413,11 +74117,11 @@ async function intentsRate(askId, opts) {
73413
74117
  const stars = Number(opts.stars);
73414
74118
  if (!Number.isInteger(stars) || stars < 1 || stars > 5) return refuse5(opts, "--stars 1 to 5", "bad_stars");
73415
74119
  const out = await rateLeg(wallet, askId, { offerId: opts.offer, stars, words: opts.words ?? "", ...opts.edit ? { edit: true } : {} });
73416
- emit6(opts, { ok: true, ...out }, () => {
74120
+ emit7(opts, { ok: true, ...out }, () => {
73417
74121
  process.stdout.write(`
73418
- ${import_picocolors14.default.bold(out.rating.edited ? "Changed." : "Rated.")} ${out.listing.name}: ${out.listing.ratingWords}
74122
+ ${import_picocolors15.default.bold(out.rating.edited ? "Changed." : "Rated.")} ${out.listing.name}: ${out.listing.ratingWords}
73419
74123
  `);
73420
- if (out.rating.words) process.stdout.write(` ${import_picocolors14.default.dim(`"${out.rating.words}"`)}
74124
+ if (out.rating.words) process.stdout.write(` ${import_picocolors15.default.dim(`"${out.rating.words}"`)}
73421
74125
  `);
73422
74126
  process.stdout.write("\n");
73423
74127
  });
@@ -73430,9 +74134,9 @@ async function intentsNoShow(askId, opts) {
73430
74134
  const { wallet } = await requirePasswordsKey();
73431
74135
  if (!opts.offer) return refuse5(opts, "--offer <offerId>: your committed leg the poster did not show for", "no_offer");
73432
74136
  const out = await markNoShow(wallet, askId, opts.offer);
73433
- emit6(opts, { ok: true, ...out }, () => {
74137
+ emit7(opts, { ok: true, ...out }, () => {
73434
74138
  process.stdout.write(`
73435
- ${import_picocolors14.default.bold("Marked.")} This poster: ${out.poster.settled} settled, ${out.poster.confirmed} confirmed, ${out.poster.noShows} no-show${out.poster.noShows === 1 ? "" : "s"}. Sellers see it; posters never do.
74139
+ ${import_picocolors15.default.bold("Marked.")} This poster: ${out.poster.settled} settled, ${out.poster.confirmed} confirmed, ${out.poster.noShows} no-show${out.poster.noShows === 1 ? "" : "s"}. Sellers see it; posters never do.
73436
74140
 
73437
74141
  `);
73438
74142
  });
@@ -73441,17 +74145,404 @@ async function intentsNoShow(askId, opts) {
73441
74145
  }
73442
74146
  }
73443
74147
 
74148
+ // src/commands/agent.ts
74149
+ init_lib2();
74150
+ var import_picocolors16 = __toESM(require_picocolors(), 1);
74151
+ init_passwords_wire();
74152
+
74153
+ // src/lib/ag-wire.ts
74154
+ init_constants();
74155
+ import { createHash as createHash3 } from "node:crypto";
74156
+ init_passwords_wire();
74157
+ var AG_SEAL_SUITE = "AGENTGATES-AG-v1";
74158
+ var AG_REPORT_DATA_LABEL = "agentgates/ag/fleet-key/v1";
74159
+ var AG_JOURNAL_LANE = "agent";
74160
+ var AG_MEMORY_KEY_NAME = "Your agent";
74161
+ var AGENT_KEY_GRANTS = ["memory:read", "memory:write", "browser:write", "logins:write", "phone:write", "mail:write"];
74162
+ function normalizeAgOwner(ownerWallet) {
74163
+ const raw = ownerWallet.trim();
74164
+ return /^0x[0-9a-fA-F]{40}$/.test(raw) ? raw.toLowerCase() : raw;
74165
+ }
74166
+ function agWalletKeyAad(ownerWallet) {
74167
+ return `${AG_SEAL_SUITE}|wallet-key|${normalizeAgOwner(ownerWallet)}`;
74168
+ }
74169
+ function agMemoryKeyAad(ownerWallet, keyId) {
74170
+ return `${AG_SEAL_SUITE}|memory-key|${normalizeAgOwner(ownerWallet)}|${keyId}`;
74171
+ }
74172
+ function fleetBindingReportData(publicKey) {
74173
+ return createHash3("sha512").update(Buffer.from(AG_REPORT_DATA_LABEL, "utf8")).update(Buffer.from(fromB64u(publicKey))).digest("hex");
74174
+ }
74175
+ function parseAgAttestation(raw) {
74176
+ const a = raw && typeof raw === "object" ? raw : null;
74177
+ if (!a) return { ok: false, error: "the attestation is not an object" };
74178
+ if (typeof a.publicKey !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(a.publicKey) || fromB64u(a.publicKey).length !== 32) {
74179
+ return { ok: false, error: "the attestation carries no x25519 public key" };
74180
+ }
74181
+ if (a.suite !== AG_SEAL_SUITE) return { ok: false, error: `the attestation names another suite (${String(a.suite)})` };
74182
+ if (typeof a.reportData !== "string" || a.reportData.length !== 128 || !/^[0-9a-f]+$/.test(a.reportData.toLowerCase())) {
74183
+ return { ok: false, error: "the attestation carries no report data" };
74184
+ }
74185
+ if (a.reportData.toLowerCase() !== fleetBindingReportData(a.publicKey)) return { ok: false, error: "the fleet key does not match its attestation binding" };
74186
+ const mode = a.mode === "tee" || a.mode === "dev" ? a.mode : null;
74187
+ if (!mode) return { ok: false, error: "the attestation names no mode" };
74188
+ const quote = typeof a.quote === "string" && a.quote ? a.quote : null;
74189
+ if (mode === "tee" && !quote) return { ok: false, error: "a TEE attestation carries a quote; this one does not" };
74190
+ return {
74191
+ ok: true,
74192
+ attestation: { suite: a.suite, mode, publicKey: a.publicKey, keyId: typeof a.keyId === "string" ? a.keyId : "", reportData: a.reportData.toLowerCase(), quote, source: a.source === "live" || a.source === "cached" ? a.source : null }
74193
+ };
74194
+ }
74195
+ async function readAgAttestation() {
74196
+ let res;
74197
+ try {
74198
+ res = await fetch(`${identityOrigin()}${lanePath("/ag/attestation")}`, { headers: { accept: "application/json", "user-agent": CLI_USER_AGENT }, signal: AbortSignal.timeout(3e4) });
74199
+ } catch (err) {
74200
+ throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
74201
+ }
74202
+ const body = await res.json().catch(() => null);
74203
+ if (!res.ok) throw new WireError(res.status, typeof body?.code === "string" ? body.code : null, typeof body?.error === "string" ? body.error : `the attestation door answered ${res.status}`, body);
74204
+ const parsed = parseAgAttestation(body);
74205
+ if (!parsed.ok) throw new WireError(0, "bad_attestation", parsed.error, body);
74206
+ return parsed.attestation;
74207
+ }
74208
+ async function readAgent(wallet) {
74209
+ return expectOk(await signedFetch(wallet, "GET", lanePath("/ag/agent")), "agent");
74210
+ }
74211
+ async function postAgentOn(wallet, body) {
74212
+ return expectOk(await signedFetch(wallet, "POST", lanePath("/ag/agent"), body), "agent on");
74213
+ }
74214
+ async function postAgentOff(wallet) {
74215
+ return expectOk(await signedFetch(wallet, "POST", lanePath("/ag/agent"), { off: true }), "agent off");
74216
+ }
74217
+ var AGENT_PAYS_CODE = "agent_pays_from_balance";
74218
+ var AGENT_PAYS_SENTENCE = "Your agent pays from your balance, so there is nothing to fund or refill: top up your balance on the site.";
74219
+ function agentPaysRefusal() {
74220
+ return new WireError(410, AGENT_PAYS_CODE, AGENT_PAYS_SENTENCE, null);
74221
+ }
74222
+ async function sayToAgent(wallet, text) {
74223
+ const out = expectOk(await signedFetch(wallet, "POST", lanePath("/ag/messages"), { text }), "agent message");
74224
+ return { queued: out.queued, woke: out.woke === true };
74225
+ }
74226
+ async function readJournalTail(wallet, lane, tail) {
74227
+ const out = expectOk(await signedFetch(wallet, "GET", lanePath(`/memory/journal/${encodeURIComponent(lane)}?tail=${Math.max(1, Math.min(200, Math.floor(tail)))}`)), "journal");
74228
+ return { owner: out.owner, rows: Array.isArray(out.entries) ? out.entries : [] };
74229
+ }
74230
+ async function mintTelegramLink(wallet) {
74231
+ return expectOk(await signedFetch(wallet, "POST", lanePath("/ag/bindings"), { channel: "telegram" }), "bind");
74232
+ }
74233
+ async function mintWhatsAppLink(wallet) {
74234
+ return expectOk(await signedFetch(wallet, "POST", lanePath("/ag/bindings"), { channel: "whatsapp" }), "bind");
74235
+ }
74236
+ async function listBindings(wallet) {
74237
+ const out = expectOk(await signedFetch(wallet, "GET", lanePath("/ag/bindings")), "bindings");
74238
+ return { ownerWallet: out.ownerWallet, bindings: Array.isArray(out.bindings) ? out.bindings : [], to: out.to ?? { number: null, address: null } };
74239
+ }
74240
+ async function mintBinding(wallet, channel, senderId) {
74241
+ const out = expectOk(await signedFetch(wallet, "POST", lanePath("/ag/bindings"), { channel, senderId }), "bind");
74242
+ return { binding: out.binding, to: out.to ?? { number: null, address: null }, sent: out.sent === true };
74243
+ }
74244
+ async function revokeBinding(wallet, id2) {
74245
+ expectOk(await signedFetch(wallet, "POST", lanePath("/ag/bindings"), { revoke: id2 }), "unbind");
74246
+ }
74247
+
74248
+ // src/commands/agent.ts
74249
+ function emit8(opts, data4, human) {
74250
+ if (opts.json || !process.stdout.isTTY) {
74251
+ process.stdout.write(`${JSON.stringify(data4)}
74252
+ `);
74253
+ return;
74254
+ }
74255
+ human();
74256
+ }
74257
+ function fail4(opts, err) {
74258
+ const message = err instanceof Error ? err.message : String(err);
74259
+ const code = err?.code;
74260
+ if (opts.json || !process.stdout.isTTY) {
74261
+ process.stdout.write(`${JSON.stringify({ ok: false, error: message, ...typeof code === "string" ? { code } : {} })}
74262
+ `);
74263
+ } else {
74264
+ process.stderr.write(`
74265
+ ${import_picocolors16.default.red("\u2717")} ${message}
74266
+
74267
+ `);
74268
+ }
74269
+ process.exit(1);
74270
+ }
74271
+ function short2(address) {
74272
+ return `${address.slice(0, 6)}\u2026${address.slice(-4)}`;
74273
+ }
74274
+ function agentLine(agent2) {
74275
+ if (!agent2 || agent2.state !== "on") return import_picocolors16.default.dim("off");
74276
+ const reach = agent2.reach;
74277
+ const where = [reach?.number, reach?.address].filter(Boolean).join(" ");
74278
+ return `${import_picocolors16.default.bold(short2(agent2.agentAddress))} ${import_picocolors16.default.dim("pays from your balance")}${where ? ` ${import_picocolors16.default.dim(where)}` : ""}`;
74279
+ }
74280
+ function sendTo(channel, to) {
74281
+ const target = channel === "sms" ? to.house?.number ?? to.number : to.address;
74282
+ if (target) return `${channel === "sms" ? "text" : "mail"} it to ${target}`;
74283
+ return channel === "sms" ? "the agent has no number yet: get it one on the site, then text the code there" : "the agent has no inbox yet: make it one on the site, then mail the code there";
74284
+ }
74285
+ function bindingLine(b2, to) {
74286
+ if (b2.channel === "telegram" || b2.channel === "whatsapp") {
74287
+ const state2 = b2.bound ? import_picocolors16.default.green("bound") : b2.expired ? import_picocolors16.default.dim(`the link lapsed: agentgates agent bind ${b2.channel}`) : import_picocolors16.default.dim(`link open until ${(b2.expiresAt ?? "").slice(11, 16)} UTC`);
74288
+ return ` ${import_picocolors16.default.dim(b2.id)} ${b2.channel} ${b2.senderId ?? ""} ${state2}`;
74289
+ }
74290
+ if (b2.confirm && !b2.bound) {
74291
+ const state2 = b2.expired ? import_picocolors16.default.dim(`the link lapsed: agentgates agent bind mail ${b2.senderId}`) : import_picocolors16.default.dim(`check its mail for the link, until ${(b2.expiresAt ?? "").slice(11, 16)} UTC`);
74292
+ return ` ${import_picocolors16.default.dim(b2.id)} ${b2.channel} ${b2.senderId} ${state2}`;
74293
+ }
74294
+ if (b2.bound && b2.channel === "mail" && to.house?.mail) return ` ${import_picocolors16.default.dim(b2.id)} mail ${b2.senderId} ${import_picocolors16.default.green("bound")} ${import_picocolors16.default.dim(`write to ${to.house.mail}`)}`;
74295
+ const state = b2.bound ? import_picocolors16.default.green("bound") : b2.code ? `${import_picocolors16.default.bold(b2.code)} ${import_picocolors16.default.dim(sendTo(b2.channel, to))}` : import_picocolors16.default.dim("open");
74296
+ return ` ${import_picocolors16.default.dim(b2.id)} ${b2.channel} ${b2.senderId} ${state}`;
74297
+ }
74298
+ async function agentStatus(opts) {
74299
+ try {
74300
+ const { wallet } = await requirePasswordsKey();
74301
+ const read = await readAgent(wallet);
74302
+ emit8(opts, { ok: true, ...read }, () => {
74303
+ process.stdout.write(`
74304
+ your agent: ${agentLine(read.agent)}
74305
+ `);
74306
+ if (read.agent?.state === "on") process.stdout.write(` ${import_picocolors16.default.dim(`address ${read.agent.agentAddress}`)}
74307
+ `);
74308
+ if (!read.fleet.keyPublished) process.stdout.write(` ${import_picocolors16.default.dim("the AG AI CVM has not published its key on this deployment yet")}
74309
+ `);
74310
+ process.stdout.write("\n");
74311
+ });
74312
+ } catch (err) {
74313
+ fail4(opts, err);
74314
+ }
74315
+ }
74316
+ async function agentOn(opts) {
74317
+ try {
74318
+ const keys2 = await requirePasswordsKey();
74319
+ if (runsOnKeyOnly()) throw new WireError(401, "words_required", "turning an agent on takes the account's words, and this machine runs on a key alone: run it where the words are", null);
74320
+ const wallet = keys2.wallet;
74321
+ const fleet = await readAgAttestation();
74322
+ const seal = await readSealKey(wallet);
74323
+ if (!seal) throw new WireError(409, "seal_missing", "seal this account first (agentgates email seal): the agent's thread is written to your Memory, and Memory seals to your account's key", null);
74324
+ const account = await mailKeyFor(wallet);
74325
+ if (!account) throw new WireError(409, "no_key", "this machine holds no copy of the account's data key", null);
74326
+ const agent2 = ethers_exports.Wallet.createRandom();
74327
+ const aad = agWalletKeyAad(wallet.address);
74328
+ const keyOwnerBlob = sealText(seal.sealingPublicKey, agent2.privateKey, aad);
74329
+ const keyBoxBlob = sealText(fleet.publicKey, agent2.privateKey, aad);
74330
+ const made = await createLoginKey(wallet, AG_MEMORY_KEY_NAME, AGENT_KEY_GRANTS);
74331
+ const reading = newReadingPart();
74332
+ try {
74333
+ const pair = keySealingKeyFromParts({ wire: made.key, reading });
74334
+ await putKeyWrap(wallet, made.created.id, { sealingPublicKey: pair.publicKey, wrap: sealTo(pair.publicKey, account.dataKey, keyWrapAad(keys2.state.address, made.created.id)) });
74335
+ const memoryKeyBoxBlob = sealText(fleet.publicKey, JSON.stringify({ wire: made.key, reading }), agMemoryKeyAad(wallet.address, made.created.id));
74336
+ const out = await postAgentOn(wallet, { agentAddress: agent2.address, keyOwnerBlob, keyBoxBlob, memoryKeyId: made.created.id, memoryKeyBoxBlob });
74337
+ const note2 = opts.fund !== void 0 ? AGENT_PAYS_SENTENCE : null;
74338
+ emit8(opts, { ok: true, agent: out.agent, memoryKeyId: made.created.id, fleet: { mode: fleet.mode, keyId: fleet.keyId }, ...note2 ? { note: note2 } : {} }, () => {
74339
+ process.stdout.write(
74340
+ `
74341
+ ${import_picocolors16.default.green("\u2713")} your agent is on: ${import_picocolors16.default.bold(agent2.address)}, paying from your balance
74342
+ ${import_picocolors16.default.dim(`its key is sealed to you and to the CVM (${fleet.mode}, key ${fleet.keyId.slice(0, 12)}\u2026); its Memory key is ${made.created.prefix}`)}
74343
+ ` + (note2 ? ` ${import_picocolors16.default.dim(note2)}
74344
+ ` : "") + ` ${import_picocolors16.default.dim(`agentgates passwords allow --agent ${agent2.address} \u2026 \xB7 lets it use your saved logins`)}
74345
+ ${import_picocolors16.default.dim('agentgates agent say "\u2026" \xB7 tells it what to do')}
74346
+
74347
+ `
74348
+ );
74349
+ });
74350
+ } catch (err) {
74351
+ await revokeLoginKey(wallet, made.created.id).catch(() => void 0);
74352
+ throw err;
74353
+ }
74354
+ } catch (err) {
74355
+ fail4(opts, err);
74356
+ }
74357
+ }
74358
+ async function agentOff(opts) {
74359
+ try {
74360
+ const { wallet } = await requirePasswordsKey();
74361
+ if (runsOnKeyOnly()) throw new WireError(401, "words_required", "turning an agent off takes the account's words, and this machine runs on a key alone: run it where the words are", null);
74362
+ const before = await readAgent(wallet);
74363
+ const out = await postAgentOff(wallet);
74364
+ let revokedKey = null;
74365
+ if (before.agent?.memoryKeyId) {
74366
+ await revokeLoginKey(wallet, before.agent.memoryKeyId).then(() => {
74367
+ revokedKey = before.agent.memoryKeyId;
74368
+ }).catch(() => void 0);
74369
+ }
74370
+ emit8(opts, { ok: true, agent: out.agent, sweptBackUsd: out.sweptBackUsd, revokedKey }, () => {
74371
+ const swept = Number(out.sweptBackUsd) > 0 ? `$${out.sweptBackUsd} it held came back to your balance` : "";
74372
+ const said = [swept, revokedKey ? "its Memory key is revoked" : ""].filter(Boolean).join("; ");
74373
+ process.stdout.write(`
74374
+ ${import_picocolors16.default.green("\u2713")} your agent is off.${said ? ` ${import_picocolors16.default.dim(`${said}.`)}` : ""}
74375
+ ${import_picocolors16.default.dim("agentgates passwords permits \xB7 shows any permit still standing for it")}
74376
+
74377
+ `);
74378
+ });
74379
+ } catch (err) {
74380
+ fail4(opts, err);
74381
+ }
74382
+ }
74383
+ async function agentFund(_amountUsd, opts) {
74384
+ fail4(opts, agentPaysRefusal());
74385
+ }
74386
+ async function agentRefill(_action, opts) {
74387
+ fail4(opts, agentPaysRefusal());
74388
+ }
74389
+ async function agentSay(text, opts) {
74390
+ try {
74391
+ const { wallet } = await requirePasswordsKey();
74392
+ const said = await sayToAgent(wallet, text);
74393
+ emit8(opts, { ok: true, ...said }, () => {
74394
+ process.stdout.write(`
74395
+ ${import_picocolors16.default.green("\u2713")} sent${said.woke ? "" : " (the CVM was not woken; the sweep will)"}. ${import_picocolors16.default.dim("agentgates agent journal \xB7 reads the thread")}
74396
+
74397
+ `);
74398
+ });
74399
+ } catch (err) {
74400
+ fail4(opts, err);
74401
+ }
74402
+ }
74403
+ async function agentJournal(opts) {
74404
+ try {
74405
+ const { wallet } = await requirePasswordsKey();
74406
+ const key = await mailKeyFor(wallet);
74407
+ if (!key) throw new WireError(409, "no_key", "this machine holds no copy of the account's data key; the thread stays sealed", null);
74408
+ const tail = Number.parseInt(opts.tail ?? "40", 10);
74409
+ const { owner, rows } = await readJournalTail(wallet, AG_JOURNAL_LANE, Number.isFinite(tail) && tail > 0 ? tail : 40);
74410
+ const lines = rows.map((r) => {
74411
+ try {
74412
+ const e = JSON.parse(openText(key.dataKey, r.blob, memoryJournalAad(owner, r.id)));
74413
+ return { id: r.id, at: typeof e.at === "string" ? e.at : r.createdAt, subject: typeof e.subject === "string" ? e.subject : "", words: typeof e.words === "string" ? e.words : "" };
74414
+ } catch {
74415
+ return { id: r.id, at: r.createdAt, subject: "", words: null };
74416
+ }
74417
+ });
74418
+ emit8(opts, { ok: true, lane: AG_JOURNAL_LANE, lines }, () => {
74419
+ if (lines.length === 0) {
74420
+ process.stdout.write(`
74421
+ ${import_picocolors16.default.dim("nothing in the thread yet")}
74422
+
74423
+ `);
74424
+ return;
74425
+ }
74426
+ process.stdout.write("\n");
74427
+ for (const l of lines) {
74428
+ const who = l.subject.startsWith("agent:") ? import_picocolors16.default.bold("agent") : l.subject.startsWith("step:") ? import_picocolors16.default.dim("act") : "you";
74429
+ process.stdout.write(` ${import_picocolors16.default.dim(l.at.slice(11, 16))} ${who} ${l.words ?? import_picocolors16.default.dim("(does not open with this key)")}
74430
+ `);
74431
+ }
74432
+ process.stdout.write("\n");
74433
+ });
74434
+ } catch (err) {
74435
+ fail4(opts, err);
74436
+ }
74437
+ }
74438
+ async function agentBind(channel, senderId, opts) {
74439
+ try {
74440
+ if (channel !== "sms" && channel !== "mail" && channel !== "telegram" && channel !== "whatsapp") throw new WireError(400, "bad_request", "channel: sms, mail, telegram or whatsapp", null);
74441
+ if (channel !== "telegram" && channel !== "whatsapp" && !senderId) throw new WireError(400, "bad_request", channel === "sms" ? "the cell to bind: agentgates agent bind sms +15551234567" : "the address to bind: agentgates agent bind mail you@example.com", null);
74442
+ const { wallet } = await requirePasswordsKey();
74443
+ if (runsOnKeyOnly()) throw new WireError(401, "words_required", "binding a sender takes the account's words, and this machine runs on a key alone: run it where the words are", null);
74444
+ if (channel === "telegram") {
74445
+ const link = await mintTelegramLink(wallet);
74446
+ emit8(opts, { ok: true, ...link }, () => {
74447
+ process.stdout.write(`
74448
+ ${import_picocolors16.default.green("\u2713")} open this in your Telegram and press Start: ${import_picocolors16.default.bold(link.link)}
74449
+ ${import_picocolors16.default.dim(`It works once, until ${link.expiresAt.slice(11, 16)} UTC. Then write to @${link.to.telegram ?? "the bot"} to reach your agent.`)}
74450
+
74451
+ `);
74452
+ });
74453
+ return;
74454
+ }
74455
+ if (channel === "whatsapp") {
74456
+ const link = await mintWhatsAppLink(wallet);
74457
+ emit8(opts, { ok: true, ...link }, () => {
74458
+ process.stdout.write(`
74459
+ ${import_picocolors16.default.green("\u2713")} open this on your phone and press send: ${import_picocolors16.default.bold(link.link)}
74460
+ ${import_picocolors16.default.dim(`It works once, until ${link.expiresAt.slice(11, 16)} UTC. Then write to ${link.to.whatsapp ?? "the house number"} on WhatsApp to reach your agent.`)}
74461
+
74462
+ `);
74463
+ });
74464
+ return;
74465
+ }
74466
+ const out = await mintBinding(wallet, channel, senderId);
74467
+ emit8(opts, { ok: true, ...out }, () => {
74468
+ const b2 = out.binding;
74469
+ if (b2.bound) {
74470
+ process.stdout.write(`
74471
+ ${import_picocolors16.default.green("\u2713")} ${b2.senderId} is already bound to this agent.
74472
+
74473
+ `);
74474
+ return;
74475
+ }
74476
+ if (b2.confirm) {
74477
+ const house = out.to.house?.mail ?? "the house address";
74478
+ process.stdout.write(out.sent ? `
74479
+ ${import_picocolors16.default.green("\u2713")} a link went to ${b2.senderId} from ${house}: open it and press Confirm.
74480
+ ${import_picocolors16.default.dim(`It works once, until ${(b2.expiresAt ?? "").slice(11, 16)} UTC. Then write to ${house} from that address to reach your agent.`)}
74481
+
74482
+ ` : `
74483
+ ${import_picocolors16.default.green("\u2713")} a link went to ${b2.senderId} a moment ago: check its mail and press Confirm.
74484
+
74485
+ `);
74486
+ return;
74487
+ }
74488
+ process.stdout.write(`
74489
+ ${import_picocolors16.default.green("\u2713")} code ${import_picocolors16.default.bold(b2.code ?? "")} for ${b2.senderId}: ${sendTo(channel, out.to)}.
74490
+ ${import_picocolors16.default.dim("Until the code arrives from that " + (channel === "sms" ? "number" : "address") + ", its messages land nothing and get one line back.")}
74491
+
74492
+ `);
74493
+ });
74494
+ } catch (err) {
74495
+ fail4(opts, err);
74496
+ }
74497
+ }
74498
+ async function agentBindings(opts) {
74499
+ try {
74500
+ const { wallet } = await requirePasswordsKey();
74501
+ const read = await listBindings(wallet);
74502
+ emit8(opts, { ok: true, ...read }, () => {
74503
+ if (read.bindings.length === 0) {
74504
+ process.stdout.write(`
74505
+ ${import_picocolors16.default.dim("nobody is bound yet")} ${import_picocolors16.default.dim("agentgates agent bind sms <number> | mail <address> | telegram | whatsapp")}
74506
+
74507
+ `);
74508
+ return;
74509
+ }
74510
+ process.stdout.write("\n");
74511
+ for (const b2 of read.bindings) process.stdout.write(`${bindingLine(b2, read.to)}
74512
+ `);
74513
+ process.stdout.write("\n");
74514
+ });
74515
+ } catch (err) {
74516
+ fail4(opts, err);
74517
+ }
74518
+ }
74519
+ async function agentUnbind(id2, opts) {
74520
+ try {
74521
+ const { wallet } = await requirePasswordsKey();
74522
+ if (runsOnKeyOnly()) throw new WireError(401, "words_required", "unbinding a sender takes the account's words, and this machine runs on a key alone: run it where the words are", null);
74523
+ await revokeBinding(wallet, id2);
74524
+ emit8(opts, { ok: true, revoked: id2 }, () => {
74525
+ process.stdout.write(`
74526
+ ${import_picocolors16.default.green("\u2713")} ${id2} is revoked; that sender is a stranger to the agent again.
74527
+
74528
+ `);
74529
+ });
74530
+ } catch (err) {
74531
+ fail4(opts, err);
74532
+ }
74533
+ }
74534
+
73444
74535
  // src/commands/logout.ts
73445
- var import_picocolors15 = __toESM(require_picocolors(), 1);
74536
+ var import_picocolors17 = __toESM(require_picocolors(), 1);
73446
74537
  async function logout(opts) {
73447
74538
  const requested = opts.profile ?? DEFAULT_PROFILE;
73448
74539
  const resolved = await resolveProfile(requested);
73449
74540
  if (!resolved) {
73450
- process.stdout.write(import_picocolors15.default.dim("Not logged in \u2014 nothing to log out.\n"));
74541
+ process.stdout.write(import_picocolors17.default.dim("Not logged in \u2014 nothing to log out.\n"));
73451
74542
  return;
73452
74543
  }
73453
74544
  if (resolved.autoSelected) {
73454
- process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
74545
+ process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
73455
74546
  `));
73456
74547
  }
73457
74548
  const { profile, name: profileName } = resolved;
@@ -73476,15 +74567,15 @@ async function logout(opts) {
73476
74567
  const removed = await deleteProfile(profileName);
73477
74568
  if (removed) {
73478
74569
  process.stdout.write(
73479
- import_picocolors15.default.green(`\u2713 Logged out of profile ${import_picocolors15.default.bold(profileName)}.
74570
+ import_picocolors17.default.green(`\u2713 Logged out of profile ${import_picocolors17.default.bold(profileName)}.
73480
74571
  `)
73481
74572
  );
73482
74573
  }
73483
74574
  if (serverError) {
73484
74575
  process.stderr.write(
73485
- import_picocolors15.default.yellow(
74576
+ import_picocolors17.default.yellow(
73486
74577
  `\u26A0 Couldn't revoke server-side: ${serverError}
73487
- The local bearer is wiped. If the server still has it, revoke from ${import_picocolors15.default.bold("agentgates.ai/settings/pairings")}.
74578
+ The local bearer is wiped. If the server still has it, revoke from ${import_picocolors17.default.bold("agentgates.ai/settings/pairings")}.
73488
74579
  `
73489
74580
  )
73490
74581
  );
@@ -73492,17 +74583,17 @@ async function logout(opts) {
73492
74583
  }
73493
74584
 
73494
74585
  // src/commands/whoami.ts
73495
- var import_picocolors16 = __toESM(require_picocolors(), 1);
74586
+ var import_picocolors18 = __toESM(require_picocolors(), 1);
73496
74587
  init_constants();
73497
74588
  async function whoami(opts) {
73498
74589
  const requested = opts.profile ?? DEFAULT_PROFILE;
73499
74590
  const resolved = await resolveProfile(requested);
73500
74591
  if (!resolved) {
73501
- process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
74592
+ process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
73502
74593
  process.exit(2);
73503
74594
  }
73504
74595
  if (resolved.autoSelected) {
73505
- process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
74596
+ process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
73506
74597
  `));
73507
74598
  }
73508
74599
  const { profile, name: profileName } = resolved;
@@ -73511,7 +74602,7 @@ async function whoami(opts) {
73511
74602
  profile,
73512
74603
  profileName,
73513
74604
  jsonMode: jsonMode7,
73514
- ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
74605
+ ttyHeader: import_picocolors18.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
73515
74606
  fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
73516
74607
  });
73517
74608
  if (outcome.kind === "auth_failed") {
@@ -73521,14 +74612,14 @@ async function whoami(opts) {
73521
74612
  );
73522
74613
  process.exit(1);
73523
74614
  }
73524
- process.stderr.write(import_picocolors16.default.red(`\u2715 ${outcome.reason}.
74615
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${outcome.reason}.
73525
74616
  `));
73526
74617
  process.exit(1);
73527
74618
  }
73528
74619
  if (outcome.kind === "error") {
73529
74620
  const err = outcome.error;
73530
74621
  if (err instanceof ApiError) {
73531
- process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
74622
+ process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message} (HTTP ${err.status})
73532
74623
  `));
73533
74624
  process.exit(1);
73534
74625
  }
@@ -73549,7 +74640,7 @@ async function whoami(opts) {
73549
74640
  process.stdout.write(`Solana ${me.solanaAddress}
73550
74641
  `);
73551
74642
  }
73552
- process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors16.default.dim("(none)")}
74643
+ process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors18.default.dim("(none)")}
73553
74644
  `);
73554
74645
  const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
73555
74646
  const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
@@ -73566,7 +74657,7 @@ async function whoami(opts) {
73566
74657
  `
73567
74658
  );
73568
74659
  process.stdout.write(
73569
- `Profile ${profileName === DEFAULT_PROFILE ? import_picocolors16.default.dim("(default)") : profileName}
74660
+ `Profile ${profileName === DEFAULT_PROFILE ? import_picocolors18.default.dim("(default)") : profileName}
73570
74661
  `
73571
74662
  );
73572
74663
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -73580,7 +74671,7 @@ function formatDate(iso) {
73580
74671
  }
73581
74672
 
73582
74673
  // src/commands/send.ts
73583
- var import_picocolors17 = __toESM(require_picocolors(), 1);
74674
+ var import_picocolors19 = __toESM(require_picocolors(), 1);
73584
74675
 
73585
74676
  // src/lib/status.ts
73586
74677
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
@@ -73739,11 +74830,11 @@ async function send(amount, asset, opts) {
73739
74830
  const requested = opts.profile ?? DEFAULT_PROFILE;
73740
74831
  const resolved = await resolveProfile(requested);
73741
74832
  if (!resolved) {
73742
- process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
74833
+ process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
73743
74834
  process.exit(2);
73744
74835
  }
73745
74836
  if (resolved.autoSelected) {
73746
- process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
74837
+ process.stderr.write(import_picocolors19.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
73747
74838
  `));
73748
74839
  }
73749
74840
  const { profile, name: profileName } = resolved;
@@ -73752,7 +74843,7 @@ async function send(amount, asset, opts) {
73752
74843
  const amountNumber = Number(amount);
73753
74844
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
73754
74845
  process.stderr.write(
73755
- import_picocolors17.default.red(`\u2715 amount must be a positive number (got ${import_picocolors17.default.bold(amount)}).
74846
+ import_picocolors19.default.red(`\u2715 amount must be a positive number (got ${import_picocolors19.default.bold(amount)}).
73756
74847
  `)
73757
74848
  );
73758
74849
  process.exit(2);
@@ -73760,23 +74851,23 @@ async function send(amount, asset, opts) {
73760
74851
  const assetNormalized = asset.toLowerCase();
73761
74852
  if (assetNormalized !== "native" && assetNormalized !== "usdc") {
73762
74853
  process.stderr.write(
73763
- import_picocolors17.default.red(
73764
- `\u2715 asset must be ${import_picocolors17.default.bold("native")} or ${import_picocolors17.default.bold("usdc")} (got ${import_picocolors17.default.bold(asset)}).
74854
+ import_picocolors19.default.red(
74855
+ `\u2715 asset must be ${import_picocolors19.default.bold("native")} or ${import_picocolors19.default.bold("usdc")} (got ${import_picocolors19.default.bold(asset)}).
73765
74856
  `
73766
74857
  )
73767
74858
  );
73768
74859
  process.exit(2);
73769
74860
  }
73770
74861
  if (!opts.to || opts.to.trim() === "") {
73771
- process.stderr.write(import_picocolors17.default.red(`\u2715 --to <address> is required.
74862
+ process.stderr.write(import_picocolors19.default.red(`\u2715 --to <address> is required.
73772
74863
  `));
73773
74864
  process.exit(2);
73774
74865
  }
73775
74866
  if (isSolanaChainAlias(opts.chain)) {
73776
74867
  if (EVM_ADDRESS_RE.test(opts.to)) {
73777
74868
  process.stderr.write(
73778
- import_picocolors17.default.red(
73779
- `\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors17.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
74869
+ import_picocolors19.default.red(
74870
+ `\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors19.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
73780
74871
  `
73781
74872
  )
73782
74873
  );
@@ -73784,10 +74875,10 @@ async function send(amount, asset, opts) {
73784
74875
  }
73785
74876
  if (!SOLANA_ADDRESS_RE.test(opts.to)) {
73786
74877
  process.stderr.write(
73787
- import_picocolors17.default.red(
73788
- `\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors17.default.bold(opts.to)}).
74878
+ import_picocolors19.default.red(
74879
+ `\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors19.default.bold(opts.to)}).
73789
74880
  `
73790
- ) + import_picocolors17.default.dim(
74881
+ ) + import_picocolors19.default.dim(
73791
74882
  ` SNS resolution is deferred to a future server-side change;
73792
74883
  for now Solana sends require the literal pubkey.
73793
74884
  `
@@ -73798,8 +74889,8 @@ async function send(amount, asset, opts) {
73798
74889
  }
73799
74890
  if (!opts.userStated || opts.userStated.trim() === "") {
73800
74891
  process.stderr.write(
73801
- import_picocolors17.default.red(`\u2715 --user-stated <text> is required.
73802
- `) + import_picocolors17.default.dim(
74892
+ import_picocolors19.default.red(`\u2715 --user-stated <text> is required.
74893
+ `) + import_picocolors19.default.dim(
73803
74894
  ` This is the trust-gap defense: pass the verbatim user request so
73804
74895
  the approval modal can cross-check what the agent thinks the user
73805
74896
  asked for vs. the actual decoded transaction.
@@ -73817,7 +74908,7 @@ async function send(amount, asset, opts) {
73817
74908
  const n2 = Number(opts.maxUsd);
73818
74909
  if (!Number.isFinite(n2) || n2 <= 0) {
73819
74910
  process.stderr.write(
73820
- import_picocolors17.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
74911
+ import_picocolors19.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
73821
74912
  `)
73822
74913
  );
73823
74914
  process.exit(2);
@@ -73859,7 +74950,7 @@ async function send(amount, asset, opts) {
73859
74950
  profile: profileName,
73860
74951
  jsonMode: jsonMode7,
73861
74952
  origin: activeProfile.mcpOrigin,
73862
- ttyHeader: import_picocolors17.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
74953
+ ttyHeader: import_picocolors19.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
73863
74954
  });
73864
74955
  } catch (reloginErr) {
73865
74956
  if (jsonMode7) {
@@ -73871,7 +74962,7 @@ async function send(amount, asset, opts) {
73871
74962
  process.exit(1);
73872
74963
  }
73873
74964
  process.stderr.write(
73874
- import_picocolors17.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
74965
+ import_picocolors19.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
73875
74966
  `)
73876
74967
  );
73877
74968
  process.exit(1);
@@ -73895,7 +74986,7 @@ async function send(amount, asset, opts) {
73895
74986
  process.exit(1);
73896
74987
  }
73897
74988
  process.stderr.write(
73898
- import_picocolors17.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
74989
+ import_picocolors19.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
73899
74990
  `)
73900
74991
  );
73901
74992
  process.exit(1);
@@ -73912,7 +75003,7 @@ async function send(amount, asset, opts) {
73912
75003
  });
73913
75004
  process.exit(1);
73914
75005
  }
73915
- process.stderr.write(import_picocolors17.default.red(`\u2715 ${err.message} (HTTP ${err.status})
75006
+ process.stderr.write(import_picocolors19.default.red(`\u2715 ${err.message} (HTTP ${err.status})
73916
75007
  `));
73917
75008
  process.exit(1);
73918
75009
  } else {
@@ -73938,17 +75029,17 @@ async function send(amount, asset, opts) {
73938
75029
  if (proposed.detail) {
73939
75030
  const d = proposed.detail;
73940
75031
  process.stderr.write(
73941
- import_picocolors17.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
75032
+ import_picocolors19.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
73942
75033
  `
73943
75034
  );
73944
75035
  } else {
73945
- process.stderr.write(import_picocolors17.default.red(`\u2715 ${proposed.reason}
75036
+ process.stderr.write(import_picocolors19.default.red(`\u2715 ${proposed.reason}
73946
75037
  `));
73947
75038
  }
73948
75039
  if (proposed.upgrade_url) {
73949
75040
  process.stderr.write(
73950
75041
  ` Open this to grant access, then re-run the command:
73951
- ${import_picocolors17.default.cyan(proposed.upgrade_url)}
75042
+ ${import_picocolors19.default.cyan(proposed.upgrade_url)}
73952
75043
  `
73953
75044
  );
73954
75045
  }
@@ -73958,21 +75049,21 @@ async function send(amount, asset, opts) {
73958
75049
  const a = proposed.recommended_actions[i];
73959
75050
  process.stderr.write(` ${i + 1}. ${a.label}
73960
75051
  `);
73961
- if (a.reasoning) process.stderr.write(import_picocolors17.default.dim(` ${a.reasoning}
75052
+ if (a.reasoning) process.stderr.write(import_picocolors19.default.dim(` ${a.reasoning}
73962
75053
  `));
73963
75054
  if (a.action_intent && a.action_intent.external_url) {
73964
75055
  process.stderr.write(
73965
- ` ${import_picocolors17.default.cyan(a.action_intent.external_url)}
75056
+ ` ${import_picocolors19.default.cyan(a.action_intent.external_url)}
73966
75057
  `
73967
75058
  );
73968
75059
  }
73969
75060
  }
73970
75061
  }
73971
75062
  if (proposed.suggestions && proposed.suggestions.length > 0) {
73972
- process.stderr.write(import_picocolors17.default.dim("\n Other ways to fund:\n"));
75063
+ process.stderr.write(import_picocolors19.default.dim("\n Other ways to fund:\n"));
73973
75064
  for (const s of proposed.suggestions) {
73974
75065
  if (s.kind === "ask_user") continue;
73975
- process.stderr.write(import_picocolors17.default.dim(` \u2022 ${s.label}
75066
+ process.stderr.write(import_picocolors19.default.dim(` \u2022 ${s.label}
73976
75067
  `));
73977
75068
  }
73978
75069
  }
@@ -73999,8 +75090,8 @@ async function send(amount, asset, opts) {
73999
75090
  } else {
74000
75091
  process.stdout.write(
74001
75092
  `
74002
- ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with biometric:
74003
- ${import_picocolors17.default.cyan(proposed.approval_url)}
75093
+ ${import_picocolors19.default.bold("Proposed.")} Open this URL to approve with biometric:
75094
+ ${import_picocolors19.default.cyan(proposed.approval_url)}
74004
75095
 
74005
75096
  `
74006
75097
  );
@@ -74019,7 +75110,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
74019
75110
  if (jsonMode7) {
74020
75111
  emitNdjson({ status: s.status, intent_id: s.approval_id });
74021
75112
  } else {
74022
- process.stdout.write(` ${describeStatus(s.status)}${import_picocolors17.default.dim("\u2026")}\r`);
75113
+ process.stdout.write(` ${describeStatus(s.status)}${import_picocolors19.default.dim("\u2026")}\r`);
74023
75114
  }
74024
75115
  }
74025
75116
  });
@@ -74033,7 +75124,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
74033
75124
  profile: profileName,
74034
75125
  jsonMode: jsonMode7,
74035
75126
  origin: activeProfile.mcpOrigin,
74036
- ttyHeader: import_picocolors17.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
75127
+ ttyHeader: import_picocolors19.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
74037
75128
  });
74038
75129
  } catch (reloginErr) {
74039
75130
  if (jsonMode7) {
@@ -74046,7 +75137,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
74046
75137
  process.exit(1);
74047
75138
  }
74048
75139
  process.stderr.write(
74049
- "\n" + import_picocolors17.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
75140
+ "\n" + import_picocolors19.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
74050
75141
  `)
74051
75142
  );
74052
75143
  process.exit(1);
@@ -74064,7 +75155,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
74064
75155
  process.exit(1);
74065
75156
  }
74066
75157
  process.stderr.write(
74067
- "\n" + import_picocolors17.default.red(`\u2715 Status poll failed: ${retryErr.message}
75158
+ "\n" + import_picocolors19.default.red(`\u2715 Status poll failed: ${retryErr.message}
74068
75159
  `)
74069
75160
  );
74070
75161
  process.exit(1);
@@ -74080,7 +75171,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
74080
75171
  process.exit(1);
74081
75172
  }
74082
75173
  process.stderr.write(
74083
- "\n" + import_picocolors17.default.red(`\u2715 Status poll failed: ${err.message}
75174
+ "\n" + import_picocolors19.default.red(`\u2715 Status poll failed: ${err.message}
74084
75175
  `)
74085
75176
  );
74086
75177
  process.exit(1);
@@ -74100,19 +75191,19 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
74100
75191
  }
74101
75192
  process.stdout.write("\n");
74102
75193
  if (final.status === "mined") {
74103
- process.stdout.write(import_picocolors17.default.green("\u2713 Mined.") + "\n");
75194
+ process.stdout.write(import_picocolors19.default.green("\u2713 Mined.") + "\n");
74104
75195
  if (final.tx_hash) {
74105
75196
  process.stdout.write(` Tx ${final.tx_hash}
74106
75197
  `);
74107
75198
  }
74108
75199
  if (explorer) {
74109
- process.stdout.write(` Explorer ${import_picocolors17.default.cyan(explorer)}
75200
+ process.stdout.write(` Explorer ${import_picocolors19.default.cyan(explorer)}
74110
75201
  `);
74111
75202
  }
74112
75203
  process.exit(0);
74113
75204
  }
74114
75205
  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}`;
74115
- process.stderr.write(import_picocolors17.default.red(`\u2715 ${label}.
75206
+ process.stderr.write(import_picocolors19.default.red(`\u2715 ${label}.
74116
75207
  `));
74117
75208
  process.exit(1);
74118
75209
  }
@@ -74140,7 +75231,7 @@ function describeStatus(s) {
74140
75231
  }
74141
75232
 
74142
75233
  // src/commands/status.ts
74143
- var import_picocolors18 = __toESM(require_picocolors(), 1);
75234
+ var import_picocolors20 = __toESM(require_picocolors(), 1);
74144
75235
  init_constants();
74145
75236
  var WATCH_GIVEUP_MS = 10 * 6e4;
74146
75237
  function explorerUrl2(chainId, hash2) {
@@ -74159,17 +75250,17 @@ function explorerUrl2(chainId, hash2) {
74159
75250
  }
74160
75251
  async function status3(intentId, opts) {
74161
75252
  if (!intentId || intentId.trim() === "") {
74162
- process.stderr.write(import_picocolors18.default.red("\u2715 Missing intent id.\n"));
75253
+ process.stderr.write(import_picocolors20.default.red("\u2715 Missing intent id.\n"));
74163
75254
  process.exit(2);
74164
75255
  }
74165
75256
  const requested = opts.profile ?? DEFAULT_PROFILE;
74166
75257
  const resolved = await resolveProfile(requested);
74167
75258
  if (!resolved) {
74168
- process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
75259
+ process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
74169
75260
  process.exit(2);
74170
75261
  }
74171
75262
  if (resolved.autoSelected) {
74172
- process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
75263
+ process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
74173
75264
  `));
74174
75265
  }
74175
75266
  const { profile, name: profileName } = resolved;
@@ -74178,7 +75269,7 @@ async function status3(intentId, opts) {
74178
75269
  profile,
74179
75270
  profileName,
74180
75271
  jsonMode: jsonMode7,
74181
- ttyHeader: import_picocolors18.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
75272
+ ttyHeader: import_picocolors20.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
74182
75273
  fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
74183
75274
  });
74184
75275
  if (outcome.kind === "auth_failed") {
@@ -74188,7 +75279,7 @@ async function status3(intentId, opts) {
74188
75279
  );
74189
75280
  process.exit(1);
74190
75281
  }
74191
- process.stderr.write(import_picocolors18.default.red(`\u2715 ${outcome.reason}.
75282
+ process.stderr.write(import_picocolors20.default.red(`\u2715 ${outcome.reason}.
74192
75283
  `));
74193
75284
  process.exit(1);
74194
75285
  }
@@ -74196,11 +75287,11 @@ async function status3(intentId, opts) {
74196
75287
  const err = outcome.error;
74197
75288
  if (err instanceof ApiError) {
74198
75289
  if (err.status === 404) {
74199
- process.stderr.write(import_picocolors18.default.red(`\u2715 No intent with id ${intentId}.
75290
+ process.stderr.write(import_picocolors20.default.red(`\u2715 No intent with id ${intentId}.
74200
75291
  `));
74201
75292
  process.exit(1);
74202
75293
  }
74203
- process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message} (HTTP ${err.status})
75294
+ process.stderr.write(import_picocolors20.default.red(`\u2715 ${err.message} (HTTP ${err.status})
74204
75295
  `));
74205
75296
  process.exit(1);
74206
75297
  }
@@ -74211,7 +75302,7 @@ async function status3(intentId, opts) {
74211
75302
  if (opts.watch && !isTerminalStatus(snap.status)) {
74212
75303
  if (!jsonMode7) {
74213
75304
  printSnap(snap);
74214
- process.stdout.write(import_picocolors18.default.dim("Watching\u2026\n"));
75305
+ process.stdout.write(import_picocolors20.default.dim("Watching\u2026\n"));
74215
75306
  }
74216
75307
  const runWatchPoll = (p) => streamStatusUntilTerminal({
74217
75308
  intentId,
@@ -74222,7 +75313,7 @@ async function status3(intentId, opts) {
74222
75313
  giveUpMs: WATCH_GIVEUP_MS,
74223
75314
  onTick: (s) => {
74224
75315
  if (!jsonMode7) {
74225
- process.stdout.write(` ${import_picocolors18.default.dim("\u2192")} ${s.status}
75316
+ process.stdout.write(` ${import_picocolors20.default.dim("\u2192")} ${s.status}
74226
75317
  `);
74227
75318
  }
74228
75319
  }
@@ -74237,7 +75328,7 @@ async function status3(intentId, opts) {
74237
75328
  profile: profileName,
74238
75329
  jsonMode: jsonMode7,
74239
75330
  origin: activeProfile.mcpOrigin,
74240
- ttyHeader: import_picocolors18.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
75331
+ ttyHeader: import_picocolors20.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
74241
75332
  });
74242
75333
  } catch (reloginErr) {
74243
75334
  if (jsonMode7) {
@@ -74251,7 +75342,7 @@ async function status3(intentId, opts) {
74251
75342
  process.exit(1);
74252
75343
  }
74253
75344
  process.stderr.write(
74254
- import_picocolors18.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
75345
+ import_picocolors20.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
74255
75346
  `)
74256
75347
  );
74257
75348
  process.exit(1);
@@ -74259,12 +75350,12 @@ async function status3(intentId, opts) {
74259
75350
  try {
74260
75351
  final = await runWatchPoll(activeProfile);
74261
75352
  } catch (retryErr) {
74262
- process.stderr.write(import_picocolors18.default.red(`\u2715 ${retryErr.message}
75353
+ process.stderr.write(import_picocolors20.default.red(`\u2715 ${retryErr.message}
74263
75354
  `));
74264
75355
  process.exit(1);
74265
75356
  }
74266
75357
  } else {
74267
- process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message}
75358
+ process.stderr.write(import_picocolors20.default.red(`\u2715 ${err.message}
74268
75359
  `));
74269
75360
  process.exit(1);
74270
75361
  }
@@ -74285,7 +75376,7 @@ async function status3(intentId, opts) {
74285
75376
  }
74286
75377
  function printSnap(s) {
74287
75378
  const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
74288
- const colorFn = s.status === "mined" ? import_picocolors18.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors18.default.red : import_picocolors18.default.cyan;
75379
+ const colorFn = s.status === "mined" ? import_picocolors20.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors20.default.red : import_picocolors20.default.cyan;
74289
75380
  process.stdout.write(`Intent ${s.approval_id}
74290
75381
  `);
74291
75382
  process.stdout.write(`Status ${colorFn(s.status)}
@@ -74300,12 +75391,12 @@ function printSnap(s) {
74300
75391
  process.stdout.write(`Tx ${s.tx_hash}
74301
75392
  `);
74302
75393
  if (explorer) {
74303
- process.stdout.write(`Explorer ${import_picocolors18.default.cyan(explorer)}
75394
+ process.stdout.write(`Explorer ${import_picocolors20.default.cyan(explorer)}
74304
75395
  `);
74305
75396
  }
74306
75397
  }
74307
75398
  if (!isTerminalStatus(s.status)) {
74308
- process.stdout.write(`Approve ${import_picocolors18.default.cyan(s.approval_url)}
75399
+ process.stdout.write(`Approve ${import_picocolors20.default.cyan(s.approval_url)}
74309
75400
  `);
74310
75401
  }
74311
75402
  process.stdout.write(`Created ${formatDate2(s.created_at)}
@@ -74322,7 +75413,7 @@ function formatDate2(iso) {
74322
75413
  }
74323
75414
 
74324
75415
  // src/commands/balance.ts
74325
- var import_picocolors19 = __toESM(require_picocolors(), 1);
75416
+ var import_picocolors21 = __toESM(require_picocolors(), 1);
74326
75417
  init_constants();
74327
75418
  var CHAIN_ALIASES = {
74328
75419
  "1": 1,
@@ -74346,11 +75437,11 @@ async function balance(opts) {
74346
75437
  const requested = opts.profile ?? DEFAULT_PROFILE;
74347
75438
  const resolved = await resolveProfile(requested);
74348
75439
  if (!resolved) {
74349
- process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
75440
+ process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
74350
75441
  process.exit(2);
74351
75442
  }
74352
75443
  if (resolved.autoSelected) {
74353
- process.stderr.write(import_picocolors19.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
75444
+ process.stderr.write(import_picocolors21.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
74354
75445
  `));
74355
75446
  }
74356
75447
  const { profile, name: profileName } = resolved;
@@ -74360,8 +75451,8 @@ async function balance(opts) {
74360
75451
  const id2 = CHAIN_ALIASES[key];
74361
75452
  if (id2 === void 0) {
74362
75453
  process.stderr.write(
74363
- import_picocolors19.default.red(
74364
- `\u2715 Unknown chain ${import_picocolors19.default.bold(opts.chain)}. Supported: ${import_picocolors19.default.bold("1/ethereum")}, ${import_picocolors19.default.bold("137/polygon")}, ${import_picocolors19.default.bold("8453/base")}, ${import_picocolors19.default.bold("42161/arbitrum")}, ${import_picocolors19.default.bold("900/solana")}.
75454
+ import_picocolors21.default.red(
75455
+ `\u2715 Unknown chain ${import_picocolors21.default.bold(opts.chain)}. Supported: ${import_picocolors21.default.bold("1/ethereum")}, ${import_picocolors21.default.bold("137/polygon")}, ${import_picocolors21.default.bold("8453/base")}, ${import_picocolors21.default.bold("42161/arbitrum")}, ${import_picocolors21.default.bold("900/solana")}.
74365
75456
  `
74366
75457
  )
74367
75458
  );
@@ -74374,7 +75465,7 @@ async function balance(opts) {
74374
75465
  profile,
74375
75466
  profileName,
74376
75467
  jsonMode: jsonMode7,
74377
- ttyHeader: import_picocolors19.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
75468
+ ttyHeader: import_picocolors21.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
74378
75469
  fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
74379
75470
  });
74380
75471
  if (outcome.kind === "auth_failed") {
@@ -74384,14 +75475,14 @@ async function balance(opts) {
74384
75475
  );
74385
75476
  process.exit(1);
74386
75477
  }
74387
- process.stderr.write(import_picocolors19.default.red(`\u2715 ${outcome.reason}.
75478
+ process.stderr.write(import_picocolors21.default.red(`\u2715 ${outcome.reason}.
74388
75479
  `));
74389
75480
  process.exit(1);
74390
75481
  }
74391
75482
  if (outcome.kind === "error") {
74392
75483
  const err = outcome.error;
74393
75484
  if (err instanceof ApiError) {
74394
- process.stderr.write(import_picocolors19.default.red(`\u2715 ${err.message} (HTTP ${err.status})
75485
+ process.stderr.write(import_picocolors21.default.red(`\u2715 ${err.message} (HTTP ${err.status})
74395
75486
  `));
74396
75487
  process.exit(1);
74397
75488
  }
@@ -74421,7 +75512,7 @@ async function balance(opts) {
74421
75512
  }
74422
75513
  if (filtered.length === 0) {
74423
75514
  process.stdout.write(
74424
- import_picocolors19.default.dim(
75515
+ import_picocolors21.default.dim(
74425
75516
  chainFilter !== null ? `No balances on chain ${chainFilter}.
74426
75517
  ` : `No chain balances returned.
74427
75518
  `
@@ -74433,7 +75524,7 @@ async function balance(opts) {
74433
75524
  const errorLines = [];
74434
75525
  for (const c of filtered) {
74435
75526
  if (c.error) {
74436
- errorLines.push(`${c.chainName} ${import_picocolors19.default.red(`(read failed: ${c.error})`)}`);
75527
+ errorLines.push(`${c.chainName} ${import_picocolors21.default.red(`(read failed: ${c.error})`)}`);
74437
75528
  continue;
74438
75529
  }
74439
75530
  if (c.native.balance > 0) {
@@ -74454,7 +75545,7 @@ async function balance(opts) {
74454
75545
  }
74455
75546
  }
74456
75547
  if (rows.length === 0 && errorLines.length === 0) {
74457
- process.stdout.write(import_picocolors19.default.dim(`All balances are zero.
75548
+ process.stdout.write(import_picocolors21.default.dim(`All balances are zero.
74458
75549
  `));
74459
75550
  process.stdout.write(AI_DIRECTIVE + "\n");
74460
75551
  return;
@@ -74464,7 +75555,7 @@ async function balance(opts) {
74464
75555
  const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
74465
75556
  const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
74466
75557
  const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
74467
- process.stdout.write(import_picocolors19.default.dim(header) + "\n");
75558
+ process.stdout.write(import_picocolors21.default.dim(header) + "\n");
74468
75559
  for (const r of rows) {
74469
75560
  process.stdout.write(
74470
75561
  r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
@@ -74477,7 +75568,7 @@ async function balance(opts) {
74477
75568
  `);
74478
75569
  }
74479
75570
  if (res.fetched_at) {
74480
- process.stdout.write("\n" + import_picocolors19.default.dim(`Fetched ${res.fetched_at}
75571
+ process.stdout.write("\n" + import_picocolors21.default.dim(`Fetched ${res.fetched_at}
74481
75572
  `));
74482
75573
  }
74483
75574
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -74490,7 +75581,7 @@ function formatBalance(value, decimals) {
74490
75581
  }
74491
75582
 
74492
75583
  // src/commands/history.ts
74493
- var import_picocolors20 = __toESM(require_picocolors(), 1);
75584
+ var import_picocolors22 = __toESM(require_picocolors(), 1);
74494
75585
  init_constants();
74495
75586
  var DEFAULT_LIMIT = 20;
74496
75587
  var SERVER_MAX_LIMIT = 100;
@@ -74498,11 +75589,11 @@ async function history(opts) {
74498
75589
  const requested = opts.profile ?? DEFAULT_PROFILE;
74499
75590
  const resolved = await resolveProfile(requested);
74500
75591
  if (!resolved) {
74501
- process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
75592
+ process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
74502
75593
  process.exit(2);
74503
75594
  }
74504
75595
  if (resolved.autoSelected) {
74505
- process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
75596
+ process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
74506
75597
  `));
74507
75598
  }
74508
75599
  const { profile, name: profileName } = resolved;
@@ -74511,14 +75602,14 @@ async function history(opts) {
74511
75602
  const n2 = Number(opts.limit);
74512
75603
  if (!Number.isFinite(n2) || n2 <= 0 || !Number.isInteger(n2)) {
74513
75604
  process.stderr.write(
74514
- import_picocolors20.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors20.default.bold(opts.limit)}).
75605
+ import_picocolors22.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors22.default.bold(opts.limit)}).
74515
75606
  `)
74516
75607
  );
74517
75608
  process.exit(2);
74518
75609
  }
74519
75610
  if (n2 > SERVER_MAX_LIMIT) {
74520
75611
  process.stderr.write(
74521
- import_picocolors20.default.red(
75612
+ import_picocolors22.default.red(
74522
75613
  `\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n2}.
74523
75614
  `
74524
75615
  )
@@ -74532,7 +75623,7 @@ async function history(opts) {
74532
75623
  profile,
74533
75624
  profileName,
74534
75625
  jsonMode: jsonMode7,
74535
- ttyHeader: import_picocolors20.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
75626
+ ttyHeader: import_picocolors22.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
74536
75627
  fn: (bearer, origin) => apiFetch(
74537
75628
  `/api/history?limit=${encodeURIComponent(String(limit))}`,
74538
75629
  { bearer, origin }
@@ -74545,14 +75636,14 @@ async function history(opts) {
74545
75636
  );
74546
75637
  process.exit(1);
74547
75638
  }
74548
- process.stderr.write(import_picocolors20.default.red(`\u2715 ${outcome.reason}.
75639
+ process.stderr.write(import_picocolors22.default.red(`\u2715 ${outcome.reason}.
74549
75640
  `));
74550
75641
  process.exit(1);
74551
75642
  }
74552
75643
  if (outcome.kind === "error") {
74553
75644
  const err = outcome.error;
74554
75645
  if (err instanceof ApiError) {
74555
- process.stderr.write(import_picocolors20.default.red(`\u2715 ${err.message} (HTTP ${err.status})
75646
+ process.stderr.write(import_picocolors22.default.red(`\u2715 ${err.message} (HTTP ${err.status})
74556
75647
  `));
74557
75648
  process.exit(1);
74558
75649
  }
@@ -74569,7 +75660,7 @@ async function history(opts) {
74569
75660
  return;
74570
75661
  }
74571
75662
  if (res.txs.length === 0) {
74572
- process.stdout.write(import_picocolors20.default.dim(`No activity yet.
75663
+ process.stdout.write(import_picocolors22.default.dim(`No activity yet.
74573
75664
  `));
74574
75665
  return;
74575
75666
  }
@@ -74589,7 +75680,7 @@ async function history(opts) {
74589
75680
  const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
74590
75681
  const colTo = Math.max(2, ...rows.map((r) => r.to.length));
74591
75682
  const header = "When".padEnd(colWhen) + " " + "Chain".padEnd(colChain) + " " + "Type".padEnd(colType) + " " + "Amount".padStart(colAmount) + " " + "Asset".padEnd(colAsset) + " " + "To".padEnd(colTo) + " Hash";
74592
- process.stdout.write(import_picocolors20.default.dim(header) + "\n");
75683
+ process.stdout.write(import_picocolors22.default.dim(header) + "\n");
74593
75684
  for (const r of rows) {
74594
75685
  process.stdout.write(
74595
75686
  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"
@@ -74597,7 +75688,7 @@ async function history(opts) {
74597
75688
  }
74598
75689
  if (res.fetched_at) {
74599
75690
  process.stdout.write(
74600
- "\n" + import_picocolors20.default.dim(
75691
+ "\n" + import_picocolors22.default.dim(
74601
75692
  `Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
74602
75693
  `
74603
75694
  )
@@ -74684,10 +75775,10 @@ function prettyType(activityType, status4) {
74684
75775
  }
74685
75776
 
74686
75777
  // src/commands/swap.ts
74687
- var import_picocolors22 = __toESM(require_picocolors(), 1);
75778
+ var import_picocolors24 = __toESM(require_picocolors(), 1);
74688
75779
 
74689
75780
  // src/lib/intent-flow.ts
74690
- var import_picocolors21 = __toESM(require_picocolors(), 1);
75781
+ var import_picocolors23 = __toESM(require_picocolors(), 1);
74691
75782
  var STREAM_GIVEUP_MS = 10 * 6e4;
74692
75783
  var SOLANA_CHAIN_ID2 = 900;
74693
75784
  function isBlocked2(r) {
@@ -74762,7 +75853,7 @@ async function runIntentFlow(opts) {
74762
75853
  profile: opts.profileName,
74763
75854
  jsonMode: opts.jsonMode,
74764
75855
  origin: activeProfile.mcpOrigin,
74765
- ttyHeader: import_picocolors21.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
75856
+ ttyHeader: import_picocolors23.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
74766
75857
  });
74767
75858
  } catch (reloginErr) {
74768
75859
  if (opts.jsonMode) {
@@ -74774,7 +75865,7 @@ async function runIntentFlow(opts) {
74774
75865
  process.exit(1);
74775
75866
  }
74776
75867
  process.stderr.write(
74777
- import_picocolors21.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
75868
+ import_picocolors23.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
74778
75869
  `)
74779
75870
  );
74780
75871
  process.exit(1);
@@ -74798,7 +75889,7 @@ async function runIntentFlow(opts) {
74798
75889
  process.exit(1);
74799
75890
  }
74800
75891
  process.stderr.write(
74801
- import_picocolors21.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
75892
+ import_picocolors23.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
74802
75893
  `)
74803
75894
  );
74804
75895
  process.exit(1);
@@ -74815,7 +75906,7 @@ async function runIntentFlow(opts) {
74815
75906
  });
74816
75907
  process.exit(1);
74817
75908
  }
74818
- process.stderr.write(import_picocolors21.default.red(`\u2715 ${err.message} (HTTP ${err.status})
75909
+ process.stderr.write(import_picocolors23.default.red(`\u2715 ${err.message} (HTTP ${err.status})
74819
75910
  `));
74820
75911
  process.exit(1);
74821
75912
  } else {
@@ -74837,18 +75928,18 @@ async function runIntentFlow(opts) {
74837
75928
  });
74838
75929
  process.exit(1);
74839
75930
  }
74840
- process.stderr.write(import_picocolors21.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
75931
+ process.stderr.write(import_picocolors23.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
74841
75932
  `));
74842
75933
  if (proposed.upgrade_url) {
74843
75934
  process.stderr.write(
74844
75935
  ` Open this to grant access, then re-run the command:
74845
- ${import_picocolors21.default.cyan(proposed.upgrade_url)}
75936
+ ${import_picocolors23.default.cyan(proposed.upgrade_url)}
74846
75937
  `
74847
75938
  );
74848
75939
  }
74849
75940
  if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
74850
75941
  process.stderr.write(
74851
- import_picocolors21.default.dim(
75942
+ import_picocolors23.default.dim(
74852
75943
  ` Suggested actions:
74853
75944
  ` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
74854
75945
  )
@@ -74871,8 +75962,8 @@ async function runIntentFlow(opts) {
74871
75962
  } else {
74872
75963
  process.stdout.write(
74873
75964
  `
74874
- ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with biometric:
74875
- ${import_picocolors21.default.cyan(proposed.approval_url)}
75965
+ ${import_picocolors23.default.bold("Proposed.")} Open this URL to approve with biometric:
75966
+ ${import_picocolors23.default.cyan(proposed.approval_url)}
74876
75967
 
74877
75968
  `
74878
75969
  );
@@ -74901,10 +75992,10 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
74901
75992
  });
74902
75993
  } else if (retryable) {
74903
75994
  process.stdout.write(
74904
- ` ${import_picocolors21.default.red("\u2715 failed")} \u2014 retry it on the approve page: ${import_picocolors21.default.cyan(proposed.approval_url)} ` + import_picocolors21.default.dim(`(until ${new Date(proposed.expires_at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })})`) + "\n"
75995
+ ` ${import_picocolors23.default.red("\u2715 failed")} \u2014 retry it on the approve page: ${import_picocolors23.default.cyan(proposed.approval_url)} ` + import_picocolors23.default.dim(`(until ${new Date(proposed.expires_at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })})`) + "\n"
74905
75996
  );
74906
75997
  } else {
74907
- process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors21.default.dim("\u2026")}\r`);
75998
+ process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors23.default.dim("\u2026")}\r`);
74908
75999
  }
74909
76000
  }
74910
76001
  });
@@ -74918,7 +76009,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
74918
76009
  profile: opts.profileName,
74919
76010
  jsonMode: opts.jsonMode,
74920
76011
  origin: activeProfile.mcpOrigin,
74921
- ttyHeader: import_picocolors21.default.dim(
76012
+ ttyHeader: import_picocolors23.default.dim(
74922
76013
  "Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
74923
76014
  )
74924
76015
  });
@@ -74933,7 +76024,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
74933
76024
  process.exit(1);
74934
76025
  }
74935
76026
  process.stderr.write(
74936
- "\n" + import_picocolors21.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
76027
+ "\n" + import_picocolors23.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
74937
76028
  `)
74938
76029
  );
74939
76030
  process.exit(1);
@@ -74951,7 +76042,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
74951
76042
  process.exit(1);
74952
76043
  }
74953
76044
  process.stderr.write(
74954
- "\n" + import_picocolors21.default.red(`\u2715 Status poll failed: ${retryErr.message}
76045
+ "\n" + import_picocolors23.default.red(`\u2715 Status poll failed: ${retryErr.message}
74955
76046
  `)
74956
76047
  );
74957
76048
  process.exit(1);
@@ -74967,7 +76058,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
74967
76058
  process.exit(1);
74968
76059
  }
74969
76060
  process.stderr.write(
74970
- "\n" + import_picocolors21.default.red(`\u2715 Status poll failed: ${err.message}
76061
+ "\n" + import_picocolors23.default.red(`\u2715 Status poll failed: ${err.message}
74971
76062
  `)
74972
76063
  );
74973
76064
  process.exit(1);
@@ -75008,39 +76099,39 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
75008
76099
  process.stdout.write("\n");
75009
76100
  const printLegJournal = () => {
75010
76101
  if (legs.length === 0) return;
75011
- process.stdout.write(import_picocolors21.default.bold(" Legs:\n"));
76102
+ process.stdout.write(import_picocolors23.default.bold(" Legs:\n"));
75012
76103
  for (const l of legs) {
75013
- const line2 = l.status === "mined" ? import_picocolors21.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors21.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors21.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors21.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors21.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
76104
+ const line2 = l.status === "mined" ? import_picocolors23.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors23.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors23.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors23.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors23.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
75014
76105
  process.stdout.write(` ${line2}
75015
76106
  `);
75016
76107
  }
75017
76108
  };
75018
76109
  if (final.status === "mined") {
75019
- process.stdout.write(import_picocolors21.default.green("\u2713 Mined.") + "\n");
76110
+ process.stdout.write(import_picocolors23.default.green("\u2713 Mined.") + "\n");
75020
76111
  if (final.tx_hash) {
75021
76112
  process.stdout.write(` Tx ${final.tx_hash}
75022
76113
  `);
75023
76114
  }
75024
76115
  if (explorer) {
75025
- process.stdout.write(` Explorer ${import_picocolors21.default.cyan(explorer)}
76116
+ process.stdout.write(` Explorer ${import_picocolors23.default.cyan(explorer)}
75026
76117
  `);
75027
76118
  }
75028
76119
  printLegJournal();
75029
76120
  process.exit(0);
75030
76121
  }
75031
76122
  if (final.status === "failed" && failure?.message) {
75032
- process.stderr.write(import_picocolors21.default.red(`\u2715 ${failure.message}
76123
+ process.stderr.write(import_picocolors23.default.red(`\u2715 ${failure.message}
75033
76124
  `));
75034
76125
  if (retryCommand) {
75035
76126
  process.stderr.write(` Retry:
75036
- ${import_picocolors21.default.cyan(retryCommand)}
76127
+ ${import_picocolors23.default.cyan(retryCommand)}
75037
76128
  `);
75038
76129
  }
75039
76130
  printLegJournal();
75040
76131
  process.exit(1);
75041
76132
  }
75042
76133
  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, and the approval window has closed. Re-run the command to propose it again" : `Ended in unexpected status: ${final.status}`;
75043
- process.stderr.write(import_picocolors21.default.red(`\u2715 ${label}.
76134
+ process.stderr.write(import_picocolors23.default.red(`\u2715 ${label}.
75044
76135
  `));
75045
76136
  printLegJournal();
75046
76137
  process.exit(1);
@@ -75060,7 +76151,7 @@ function isAsset(v) {
75060
76151
  return ASSET_VALUES.has(v.toLowerCase());
75061
76152
  }
75062
76153
  function failArg(msg) {
75063
- process.stderr.write(import_picocolors22.default.red(`\u2715 ${msg}
76154
+ process.stderr.write(import_picocolors24.default.red(`\u2715 ${msg}
75064
76155
  `));
75065
76156
  process.exit(2);
75066
76157
  }
@@ -75068,11 +76159,11 @@ async function swap(amount, fromAsset, opts) {
75068
76159
  const requested = opts.profile ?? DEFAULT_PROFILE;
75069
76160
  const resolved = await resolveProfile(requested);
75070
76161
  if (!resolved) {
75071
- process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
76162
+ process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
75072
76163
  process.exit(2);
75073
76164
  }
75074
76165
  if (resolved.autoSelected) {
75075
- process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
76166
+ process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
75076
76167
  `));
75077
76168
  }
75078
76169
  const { profile, name: profileName } = resolved;
@@ -75080,12 +76171,12 @@ async function swap(amount, fromAsset, opts) {
75080
76171
  const jsonMode7 = opts.json === true || !stdoutIsTty;
75081
76172
  const amountNumber = Number(amount);
75082
76173
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
75083
- failArg(`amount must be a positive number (got ${import_picocolors22.default.bold(amount)}).`);
76174
+ failArg(`amount must be a positive number (got ${import_picocolors24.default.bold(amount)}).`);
75084
76175
  }
75085
76176
  const fromAssetNorm = fromAsset.toLowerCase();
75086
76177
  if (!isAsset(fromAssetNorm)) {
75087
76178
  failArg(
75088
- `from-asset must be ${import_picocolors22.default.bold("native")} or ${import_picocolors22.default.bold("usdc")} (got ${import_picocolors22.default.bold(fromAsset)}).`
76179
+ `from-asset must be ${import_picocolors24.default.bold("native")} or ${import_picocolors24.default.bold("usdc")} (got ${import_picocolors24.default.bold(fromAsset)}).`
75089
76180
  );
75090
76181
  }
75091
76182
  if (!opts.toAsset) {
@@ -75094,7 +76185,7 @@ async function swap(amount, fromAsset, opts) {
75094
76185
  const toAssetNorm = opts.toAsset.toLowerCase();
75095
76186
  if (!isAsset(toAssetNorm)) {
75096
76187
  failArg(
75097
- `--to-asset must be ${import_picocolors22.default.bold("native")} or ${import_picocolors22.default.bold("usdc")} (got ${import_picocolors22.default.bold(opts.toAsset)}).`
76188
+ `--to-asset must be ${import_picocolors24.default.bold("native")} or ${import_picocolors24.default.bold("usdc")} (got ${import_picocolors24.default.bold(opts.toAsset)}).`
75098
76189
  );
75099
76190
  }
75100
76191
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -75223,9 +76314,9 @@ async function swap(amount, fromAsset, opts) {
75223
76314
  }
75224
76315
 
75225
76316
  // src/commands/batch.ts
75226
- var import_picocolors23 = __toESM(require_picocolors(), 1);
76317
+ var import_picocolors25 = __toESM(require_picocolors(), 1);
75227
76318
  function failArg2(msg) {
75228
- process.stderr.write(import_picocolors23.default.red(`\u2715 ${msg}
76319
+ process.stderr.write(import_picocolors25.default.red(`\u2715 ${msg}
75229
76320
  `));
75230
76321
  process.exit(2);
75231
76322
  }
@@ -75233,7 +76324,7 @@ async function batch(opts) {
75233
76324
  const requested = opts.profile ?? DEFAULT_PROFILE;
75234
76325
  const resolved = await resolveProfile(requested);
75235
76326
  if (!resolved) {
75236
- process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
76327
+ process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
75237
76328
  process.exit(2);
75238
76329
  }
75239
76330
  const { name: profileName, profile } = resolved;
@@ -75287,14 +76378,14 @@ async function batch(opts) {
75287
76378
  }
75288
76379
 
75289
76380
  // src/commands/fund-wallet.ts
75290
- var import_picocolors24 = __toESM(require_picocolors(), 1);
76381
+ var import_picocolors26 = __toESM(require_picocolors(), 1);
75291
76382
  var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
75292
76383
  var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
75293
76384
  function isAddressTarget(target) {
75294
76385
  return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
75295
76386
  }
75296
76387
  function failArg3(msg) {
75297
- process.stderr.write(import_picocolors24.default.red(`\u2715 ${msg}
76388
+ process.stderr.write(import_picocolors26.default.red(`\u2715 ${msg}
75298
76389
  `));
75299
76390
  process.exit(2);
75300
76391
  }
@@ -75302,7 +76393,7 @@ async function fundWallet(address, opts) {
75302
76393
  const requested = opts.profile ?? DEFAULT_PROFILE;
75303
76394
  const resolved = await resolveProfile(requested);
75304
76395
  if (!resolved) {
75305
- process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
76396
+ process.stderr.write(import_picocolors26.default.red("Not logged in. Run agentgates login first.\n"));
75306
76397
  process.exit(2);
75307
76398
  }
75308
76399
  const { name: profileName, profile } = resolved;
@@ -75379,11 +76470,11 @@ async function fundWallet(address, opts) {
75379
76470
  }
75380
76471
 
75381
76472
  // src/commands/earn-supply.ts
75382
- var import_picocolors25 = __toESM(require_picocolors(), 1);
76473
+ var import_picocolors27 = __toESM(require_picocolors(), 1);
75383
76474
  var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
75384
76475
  var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
75385
76476
  function failArg4(msg) {
75386
- process.stderr.write(import_picocolors25.default.red(`\u2715 ${msg}
76477
+ process.stderr.write(import_picocolors27.default.red(`\u2715 ${msg}
75387
76478
  `));
75388
76479
  process.exit(2);
75389
76480
  }
@@ -75391,11 +76482,11 @@ async function earnSupply(amount, asset, opts) {
75391
76482
  const requested = opts.profile ?? DEFAULT_PROFILE;
75392
76483
  const resolved = await resolveProfile(requested);
75393
76484
  if (!resolved) {
75394
- process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
76485
+ process.stderr.write(import_picocolors27.default.red("Not logged in. Run agentgates login first.\n"));
75395
76486
  process.exit(2);
75396
76487
  }
75397
76488
  if (resolved.autoSelected) {
75398
- process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
76489
+ process.stderr.write(import_picocolors27.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
75399
76490
  `));
75400
76491
  }
75401
76492
  const { profile, name: profileName } = resolved;
@@ -75403,12 +76494,12 @@ async function earnSupply(amount, asset, opts) {
75403
76494
  const jsonMode7 = opts.json === true || !stdoutIsTty;
75404
76495
  const amountNumber = Number(amount);
75405
76496
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
75406
- failArg4(`amount must be a positive number (got ${import_picocolors25.default.bold(amount)}).`);
76497
+ failArg4(`amount must be a positive number (got ${import_picocolors27.default.bold(amount)}).`);
75407
76498
  }
75408
76499
  const assetNorm = asset.toLowerCase();
75409
76500
  if (!ASSET_VALUES2.has(assetNorm)) {
75410
76501
  failArg4(
75411
- `asset must be ${import_picocolors25.default.bold("native")} or ${import_picocolors25.default.bold("usdc")} (got ${import_picocolors25.default.bold(asset)}).`
76502
+ `asset must be ${import_picocolors27.default.bold("native")} or ${import_picocolors27.default.bold("usdc")} (got ${import_picocolors27.default.bold(asset)}).`
75412
76503
  );
75413
76504
  }
75414
76505
  if (!opts.chain) {
@@ -75420,7 +76511,7 @@ async function earnSupply(amount, asset, opts) {
75420
76511
  const protocolNorm = opts.protocol.toLowerCase();
75421
76512
  if (!PROTOCOLS.has(protocolNorm)) {
75422
76513
  failArg4(
75423
- `--protocol must be ${import_picocolors25.default.bold("aave_v3")} or ${import_picocolors25.default.bold("kamino_lend")} (got ${import_picocolors25.default.bold(opts.protocol)}).`
76514
+ `--protocol must be ${import_picocolors27.default.bold("aave_v3")} or ${import_picocolors27.default.bold("kamino_lend")} (got ${import_picocolors27.default.bold(opts.protocol)}).`
75424
76515
  );
75425
76516
  }
75426
76517
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -75472,11 +76563,11 @@ async function earnSupply(amount, asset, opts) {
75472
76563
  }
75473
76564
 
75474
76565
  // src/commands/earn-withdraw.ts
75475
- var import_picocolors26 = __toESM(require_picocolors(), 1);
76566
+ var import_picocolors28 = __toESM(require_picocolors(), 1);
75476
76567
  var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
75477
76568
  var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
75478
76569
  function failArg5(msg) {
75479
- process.stderr.write(import_picocolors26.default.red(`\u2715 ${msg}
76570
+ process.stderr.write(import_picocolors28.default.red(`\u2715 ${msg}
75480
76571
  `));
75481
76572
  process.exit(2);
75482
76573
  }
@@ -75484,11 +76575,11 @@ async function earnWithdraw(amountOrMax, asset, opts) {
75484
76575
  const requested = opts.profile ?? DEFAULT_PROFILE;
75485
76576
  const resolved = await resolveProfile(requested);
75486
76577
  if (!resolved) {
75487
- process.stderr.write(import_picocolors26.default.red("Not logged in. Run agentgates login first.\n"));
76578
+ process.stderr.write(import_picocolors28.default.red("Not logged in. Run agentgates login first.\n"));
75488
76579
  process.exit(2);
75489
76580
  }
75490
76581
  if (resolved.autoSelected) {
75491
- process.stderr.write(import_picocolors26.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
76582
+ process.stderr.write(import_picocolors28.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
75492
76583
  `));
75493
76584
  }
75494
76585
  const { profile, name: profileName } = resolved;
@@ -75499,14 +76590,14 @@ async function earnWithdraw(amountOrMax, asset, opts) {
75499
76590
  const amountNumber = Number(amountOrMax);
75500
76591
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
75501
76592
  failArg5(
75502
- `<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors26.default.bold(amountOrMax)}).`
76593
+ `<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors28.default.bold(amountOrMax)}).`
75503
76594
  );
75504
76595
  }
75505
76596
  }
75506
76597
  const assetNorm = asset.toLowerCase();
75507
76598
  if (!ASSET_VALUES3.has(assetNorm)) {
75508
76599
  failArg5(
75509
- `asset must be ${import_picocolors26.default.bold("native")} or ${import_picocolors26.default.bold("usdc")} (got ${import_picocolors26.default.bold(asset)}).`
76600
+ `asset must be ${import_picocolors28.default.bold("native")} or ${import_picocolors28.default.bold("usdc")} (got ${import_picocolors28.default.bold(asset)}).`
75510
76601
  );
75511
76602
  }
75512
76603
  if (!opts.chain) {
@@ -75518,7 +76609,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
75518
76609
  const protocolNorm = opts.protocol.toLowerCase();
75519
76610
  if (!PROTOCOLS2.has(protocolNorm)) {
75520
76611
  failArg5(
75521
- `--protocol must be ${import_picocolors26.default.bold("aave_v3")} or ${import_picocolors26.default.bold("kamino_lend")} (got ${import_picocolors26.default.bold(opts.protocol)}).`
76612
+ `--protocol must be ${import_picocolors28.default.bold("aave_v3")} or ${import_picocolors28.default.bold("kamino_lend")} (got ${import_picocolors28.default.bold(opts.protocol)}).`
75522
76613
  );
75523
76614
  }
75524
76615
  if (!opts.userStated || opts.userStated.trim() === "") {
@@ -75570,7 +76661,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
75570
76661
  }
75571
76662
 
75572
76663
  // src/commands/eat.ts
75573
- var import_picocolors27 = __toESM(require_picocolors(), 1);
76664
+ var import_picocolors29 = __toESM(require_picocolors(), 1);
75574
76665
  function parseLineJson(values) {
75575
76666
  const lines = [];
75576
76667
  for (const value of values) {
@@ -75597,11 +76688,11 @@ function parseLineJson(values) {
75597
76688
  async function loadResolvedProfile(requested) {
75598
76689
  const resolved = await resolveProfile(requested);
75599
76690
  if (!resolved) {
75600
- process.stderr.write(import_picocolors27.default.red("Not logged in. Run agentgates login first.\n"));
76691
+ process.stderr.write(import_picocolors29.default.red("Not logged in. Run agentgates login first.\n"));
75601
76692
  process.exit(2);
75602
76693
  }
75603
76694
  if (resolved.autoSelected) {
75604
- process.stderr.write(import_picocolors27.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
76695
+ process.stderr.write(import_picocolors29.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
75605
76696
  `));
75606
76697
  }
75607
76698
  return resolved;
@@ -75612,12 +76703,12 @@ function printResult(res, jsonMode7) {
75612
76703
  return;
75613
76704
  }
75614
76705
  if (res.blocked) {
75615
- process.stderr.write(import_picocolors27.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
76706
+ process.stderr.write(import_picocolors29.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
75616
76707
  `));
75617
76708
  if (res.upgrade_url) {
75618
76709
  process.stderr.write(
75619
76710
  ` Open this to grant access, then re-run the command:
75620
- ${import_picocolors27.default.cyan(res.upgrade_url)}
76711
+ ${import_picocolors29.default.cyan(res.upgrade_url)}
75621
76712
  `
75622
76713
  );
75623
76714
  }
@@ -75648,7 +76739,7 @@ async function postRestaurant(path8, body, resolved, jsonMode7) {
75648
76739
  profile: resolved.profile,
75649
76740
  profileName: resolved.name,
75650
76741
  jsonMode: jsonMode7,
75651
- ttyHeader: import_picocolors27.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
76742
+ ttyHeader: import_picocolors29.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
75652
76743
  fn: (bearer, origin) => apiFetch(path8, { method: "POST", bearer, origin, body })
75653
76744
  });
75654
76745
  if (outcome.kind === "auth_failed") {
@@ -75658,7 +76749,7 @@ async function postRestaurant(path8, body, resolved, jsonMode7) {
75658
76749
  );
75659
76750
  process.exit(1);
75660
76751
  }
75661
- process.stderr.write(import_picocolors27.default.red(`\u2715 ${outcome.reason}.
76752
+ process.stderr.write(import_picocolors29.default.red(`\u2715 ${outcome.reason}.
75662
76753
  `));
75663
76754
  process.exit(1);
75664
76755
  }
@@ -75671,7 +76762,7 @@ async function postRestaurant(path8, body, resolved, jsonMode7) {
75671
76762
  );
75672
76763
  process.exit(1);
75673
76764
  }
75674
- process.stderr.write(import_picocolors27.default.red(`\u2715 ${err.message} (HTTP ${err.status})
76765
+ process.stderr.write(import_picocolors29.default.red(`\u2715 ${err.message} (HTTP ${err.status})
75675
76766
  `));
75676
76767
  process.exit(1);
75677
76768
  }
@@ -75684,7 +76775,7 @@ async function searchFood(opts) {
75684
76775
  const jsonMode7 = opts.json === true || process.stdout.isTTY !== true;
75685
76776
  if (!opts.location && !opts.name) {
75686
76777
  process.stderr.write(
75687
- import_picocolors27.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
76778
+ import_picocolors29.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
75688
76779
  );
75689
76780
  process.exit(2);
75690
76781
  }
@@ -75705,7 +76796,7 @@ async function menuFood(items, opts) {
75705
76796
  const jsonMode7 = opts.json === true || process.stdout.isTTY !== true;
75706
76797
  if (!opts.brand || !opts.address) {
75707
76798
  process.stderr.write(
75708
- import_picocolors27.default.red(
76799
+ import_picocolors29.default.red(
75709
76800
  "\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
75710
76801
  )
75711
76802
  );
@@ -75725,7 +76816,7 @@ async function orderFood(items, opts) {
75725
76816
  const jsonMode7 = opts.json === true || process.stdout.isTTY !== true;
75726
76817
  if (!opts.brand || !opts.address) {
75727
76818
  process.stderr.write(
75728
- import_picocolors27.default.red(
76819
+ import_picocolors29.default.red(
75729
76820
  "\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
75730
76821
  )
75731
76822
  );
@@ -75735,14 +76826,14 @@ async function orderFood(items, opts) {
75735
76826
  try {
75736
76827
  structuredLines = parseLineJson(opts.lineJson ?? []);
75737
76828
  } catch (e) {
75738
- process.stderr.write(import_picocolors27.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
76829
+ process.stderr.write(import_picocolors29.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
75739
76830
  `));
75740
76831
  process.exit(2);
75741
76832
  }
75742
76833
  const lines = [...items ?? [], ...structuredLines];
75743
76834
  if (lines.length === 0) {
75744
76835
  process.stderr.write(
75745
- import_picocolors27.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")
76836
+ import_picocolors29.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")
75746
76837
  );
75747
76838
  process.exit(2);
75748
76839
  }
@@ -75776,7 +76867,7 @@ async function orderFood(items, opts) {
75776
76867
  if (!agentCard.will_attempt) {
75777
76868
  if (!jsonMode7) {
75778
76869
  process.stderr.write(
75779
- import_picocolors27.default.yellow(
76870
+ import_picocolors29.default.yellow(
75780
76871
  `This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
75781
76872
  `
75782
76873
  )
@@ -75793,7 +76884,7 @@ async function orderFood(items, opts) {
75793
76884
  }
75794
76885
  if (verdict.status === "paid") {
75795
76886
  process.stdout.write(
75796
- import_picocolors27.default.green(
76887
+ import_picocolors29.default.green(
75797
76888
  `Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
75798
76889
  )
75799
76890
  );
@@ -75801,7 +76892,7 @@ async function orderFood(items, opts) {
75801
76892
  }
75802
76893
  if (verdict.status === "failed") {
75803
76894
  process.stderr.write(
75804
- import_picocolors27.default.yellow(
76895
+ import_picocolors29.default.yellow(
75805
76896
  `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.
75806
76897
  `
75807
76898
  )
@@ -75811,7 +76902,7 @@ async function orderFood(items, opts) {
75811
76902
  }
75812
76903
  if (verdict.status === "unconfirmed") {
75813
76904
  process.stderr.write(
75814
- import_picocolors27.default.red(
76905
+ import_picocolors29.default.red(
75815
76906
  "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}
75816
76907
  ` : "")
75817
76908
  )
@@ -75820,7 +76911,7 @@ async function orderFood(items, opts) {
75820
76911
  return;
75821
76912
  }
75822
76913
  process.stderr.write(
75823
- import_picocolors27.default.dim(
76914
+ import_picocolors29.default.dim(
75824
76915
  `Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
75825
76916
  )
75826
76917
  );
@@ -75845,7 +76936,7 @@ var POLL_BUDGET_MS = 1e5;
75845
76936
  var POLL_INTERVAL_MS2 = 3500;
75846
76937
  async function pollOrderVerdict(orderId, resolved, jsonMode7) {
75847
76938
  if (!jsonMode7) {
75848
- process.stderr.write(import_picocolors27.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
76939
+ process.stderr.write(import_picocolors29.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
75849
76940
  }
75850
76941
  const deadline = Date.now() + POLL_BUDGET_MS;
75851
76942
  let last = {
@@ -75915,17 +77006,17 @@ async function statusFood(orderId, opts) {
75915
77006
  }
75916
77007
 
75917
77008
  // src/commands/bounties.ts
75918
- var import_picocolors28 = __toESM(require_picocolors(), 1);
77009
+ var import_picocolors30 = __toESM(require_picocolors(), 1);
75919
77010
  init_constants();
75920
77011
  async function withProfile(opts, path8, init2) {
75921
77012
  const requested = opts.profile ?? DEFAULT_PROFILE;
75922
77013
  const resolved = await resolveProfile(requested);
75923
77014
  if (!resolved) {
75924
- process.stderr.write(import_picocolors28.default.red("Not logged in. Run agentgates login first.\n"));
77015
+ process.stderr.write(import_picocolors30.default.red("Not logged in. Run agentgates login first.\n"));
75925
77016
  process.exit(2);
75926
77017
  }
75927
77018
  if (resolved.autoSelected) {
75928
- process.stderr.write(import_picocolors28.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
77019
+ process.stderr.write(import_picocolors30.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
75929
77020
  `));
75930
77021
  }
75931
77022
  const { profile, name: profileName } = resolved;
@@ -75934,7 +77025,7 @@ async function withProfile(opts, path8, init2) {
75934
77025
  profile,
75935
77026
  profileName,
75936
77027
  jsonMode: jsonMode7,
75937
- ttyHeader: import_picocolors28.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
77028
+ ttyHeader: import_picocolors30.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
75938
77029
  fn: (bearer, origin) => apiFetch(path8, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
75939
77030
  });
75940
77031
  if (outcome.kind === "auth_failed") {
@@ -75942,14 +77033,14 @@ async function withProfile(opts, path8, init2) {
75942
77033
  process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
75943
77034
  process.exit(1);
75944
77035
  }
75945
- process.stderr.write(import_picocolors28.default.red(`\u2715 ${outcome.reason}.
77036
+ process.stderr.write(import_picocolors30.default.red(`\u2715 ${outcome.reason}.
75946
77037
  `));
75947
77038
  process.exit(1);
75948
77039
  }
75949
77040
  if (outcome.kind === "error") {
75950
77041
  const err = outcome.error;
75951
77042
  if (err instanceof ApiError) {
75952
- process.stderr.write(import_picocolors28.default.red(`\u2715 ${err.message} (HTTP ${err.status})
77043
+ process.stderr.write(import_picocolors30.default.red(`\u2715 ${err.message} (HTTP ${err.status})
75953
77044
  `));
75954
77045
  process.exit(1);
75955
77046
  }
@@ -75963,12 +77054,12 @@ function handleBlocked(res, jsonMode7) {
75963
77054
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
75964
77055
  process.exit(1);
75965
77056
  }
75966
- process.stderr.write(import_picocolors28.default.yellow(`
77057
+ process.stderr.write(import_picocolors30.default.yellow(`
75967
77058
  ${res.reason ?? "Blocked."}
75968
77059
  `));
75969
77060
  if (res.upgrade_url) {
75970
77061
  process.stderr.write(`
75971
- ${import_picocolors28.default.bold(res.upgrade_url)}
77062
+ ${import_picocolors30.default.bold(res.upgrade_url)}
75972
77063
 
75973
77064
  `);
75974
77065
  }
@@ -76011,14 +77102,14 @@ function printTable(rows) {
76011
77102
  const cLeft = w("left", 4);
76012
77103
  const cSubs = w("subs", 4);
76013
77104
  process.stdout.write(
76014
- import_picocolors28.default.dim(
77105
+ import_picocolors30.default.dim(
76015
77106
  "Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
76016
77107
  ) + "\n"
76017
77108
  );
76018
77109
  for (const c of cells) {
76019
- const title = c.live ? import_picocolors28.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
77110
+ const title = c.live ? import_picocolors30.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
76020
77111
  process.stdout.write(
76021
- import_picocolors28.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors28.default.dim(c.id) + "\n"
77112
+ import_picocolors30.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors30.default.dim(c.id) + "\n"
76022
77113
  );
76023
77114
  }
76024
77115
  }
@@ -76030,11 +77121,11 @@ async function listBounties(opts) {
76030
77121
  const min = opts.min !== void 0 ? Number(opts.min) : void 0;
76031
77122
  const max = opts.max !== void 0 ? Number(opts.max) : void 0;
76032
77123
  if (min !== void 0 && !Number.isFinite(min)) {
76033
- process.stderr.write(import_picocolors28.default.red("\u2715 --min must be a number.\n"));
77124
+ process.stderr.write(import_picocolors30.default.red("\u2715 --min must be a number.\n"));
76034
77125
  process.exit(2);
76035
77126
  }
76036
77127
  if (max !== void 0 && !Number.isFinite(max)) {
76037
- process.stderr.write(import_picocolors28.default.red("\u2715 --max must be a number.\n"));
77128
+ process.stderr.write(import_picocolors30.default.red("\u2715 --max must be a number.\n"));
76038
77129
  process.exit(2);
76039
77130
  }
76040
77131
  rows = rows.filter((r) => {
@@ -76059,7 +77150,7 @@ async function listBounties(opts) {
76059
77150
  });
76060
77151
  const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
76061
77152
  if (!Number.isFinite(limit) || limit <= 0) {
76062
- process.stderr.write(import_picocolors28.default.red("\u2715 --limit must be a positive number.\n"));
77153
+ process.stderr.write(import_picocolors30.default.red("\u2715 --limit must be a positive number.\n"));
76063
77154
  process.exit(2);
76064
77155
  }
76065
77156
  const shown2 = rows.slice(0, limit);
@@ -76068,13 +77159,13 @@ async function listBounties(opts) {
76068
77159
  return;
76069
77160
  }
76070
77161
  if (shown2.length === 0) {
76071
- process.stdout.write(import_picocolors28.default.dim("No active bounties match.\n"));
77162
+ process.stdout.write(import_picocolors30.default.dim("No active bounties match.\n"));
76072
77163
  return;
76073
77164
  }
76074
77165
  printTable(shown2);
76075
77166
  const clipped = rows.length - shown2.length;
76076
77167
  process.stdout.write(
76077
- "\n" + import_picocolors28.default.dim(
77168
+ "\n" + import_picocolors30.default.dim(
76078
77169
  `${shown2.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
76079
77170
  `
76080
77171
  )
@@ -76085,7 +77176,7 @@ async function showBounty(id2, opts) {
76085
77176
  const jsonMode7 = opts.json === true;
76086
77177
  const clean3 = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
76087
77178
  if (!clean3) {
76088
- process.stderr.write(import_picocolors28.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
77179
+ process.stderr.write(import_picocolors30.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
76089
77180
  process.exit(2);
76090
77181
  }
76091
77182
  const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean3)}`);
@@ -76096,26 +77187,26 @@ async function showBounty(id2, opts) {
76096
77187
  }
76097
77188
  const b2 = res.bounty;
76098
77189
  if (!b2) {
76099
- process.stdout.write(import_picocolors28.default.dim("Not found.\n"));
77190
+ process.stdout.write(import_picocolors30.default.dim("Not found.\n"));
76100
77191
  return;
76101
77192
  }
76102
- process.stdout.write("\n" + import_picocolors28.default.bold(b2.title) + "\n\n");
77193
+ process.stdout.write("\n" + import_picocolors30.default.bold(b2.title) + "\n\n");
76103
77194
  process.stdout.write(b2.description + "\n\n");
76104
77195
  process.stdout.write(
76105
- import_picocolors28.default.bold(fmtAmount(b2.amount)) + import_picocolors28.default.dim(" USDC") + import_picocolors28.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors28.default.green(" \xB7 LIVE now") : "") + "\n"
77196
+ import_picocolors30.default.bold(fmtAmount(b2.amount)) + import_picocolors30.default.dim(" USDC") + import_picocolors30.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors30.default.green(" \xB7 LIVE now") : "") + "\n"
76106
77197
  );
76107
77198
  if (b2.claimsAllowed && b2.claimsAllowed > 1) {
76108
77199
  const left = Math.max(0, b2.claimsAllowed - (b2.claimsPaid ?? 0));
76109
77200
  process.stdout.write(
76110
- import_picocolors28.default.dim(
77201
+ import_picocolors30.default.dim(
76111
77202
  `${left} of ${b2.claimsAllowed} claims left` + (b2.perClaimAmount != null ? `, ${fmtAmount(b2.perClaimAmount)} each` : "")
76112
77203
  ) + "\n"
76113
77204
  );
76114
77205
  }
76115
- if (b2.evidenceType) process.stdout.write(import_picocolors28.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
76116
- if (b2.expiresAt) process.stdout.write(import_picocolors28.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
77206
+ if (b2.evidenceType) process.stdout.write(import_picocolors30.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
77207
+ if (b2.expiresAt) process.stdout.write(import_picocolors30.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
76117
77208
  if (b2.geoLabel && b2.geoScope !== "global") {
76118
- process.stdout.write(import_picocolors28.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
77209
+ process.stdout.write(import_picocolors30.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
76119
77210
  }
76120
77211
  if (res.url) process.stdout.write("\n" + res.url + "\n");
76121
77212
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -76133,7 +77224,7 @@ async function myBounties(opts) {
76133
77224
  }
76134
77225
  if (rows.length === 0) {
76135
77226
  process.stdout.write(
76136
- import_picocolors28.default.dim(
77227
+ import_picocolors30.default.dim(
76137
77228
  status4 ? `No bounties of yours are ${status4}.
76138
77229
  ` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
76139
77230
  )
@@ -76143,7 +77234,7 @@ async function myBounties(opts) {
76143
77234
  printTable(rows);
76144
77235
  const subs = res.submissions ?? [];
76145
77236
  if (subs.length > 0) {
76146
- process.stdout.write("\n" + import_picocolors28.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
77237
+ process.stdout.write("\n" + import_picocolors30.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
76147
77238
  `));
76148
77239
  }
76149
77240
  process.stdout.write(AI_DIRECTIVE + "\n");
@@ -76162,19 +77253,19 @@ async function bountyFeed(opts) {
76162
77253
  }
76163
77254
  const subs = res.submissions ?? [];
76164
77255
  if (subs.length === 0) {
76165
- process.stdout.write(import_picocolors28.default.dim("Nothing in the feed for that filter.\n"));
77256
+ process.stdout.write(import_picocolors30.default.dim("Nothing in the feed for that filter.\n"));
76166
77257
  return;
76167
77258
  }
76168
77259
  process.stdout.write(
76169
- `${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors28.default.dim(" More available.") : "") + "\n"
77260
+ `${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors30.default.dim(" More available.") : "") + "\n"
76170
77261
  );
76171
- process.stdout.write(import_picocolors28.default.dim("Use --json for the full rows.\n"));
77262
+ process.stdout.write(import_picocolors30.default.dim("Use --json for the full rows.\n"));
76172
77263
  }
76173
77264
  async function draftBounty(opts) {
76174
77265
  const jsonMode7 = opts.json === true;
76175
77266
  const amountNum = Number(opts.amount);
76176
77267
  if (!Number.isFinite(amountNum) || amountNum <= 0) {
76177
- process.stderr.write(import_picocolors28.default.red("\u2715 --amount must be a positive number of USDC.\n"));
77268
+ process.stderr.write(import_picocolors30.default.red("\u2715 --amount must be a positive number of USDC.\n"));
76178
77269
  process.exit(2);
76179
77270
  }
76180
77271
  const res = await withProfile(opts, "/api/bounties", {
@@ -76192,20 +77283,20 @@ async function draftBounty(opts) {
76192
77283
  process.stdout.write(JSON.stringify(res, null, 2) + "\n");
76193
77284
  return;
76194
77285
  }
76195
- process.stdout.write("\n" + import_picocolors28.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
77286
+ process.stdout.write("\n" + import_picocolors30.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
76196
77287
 
76197
77288
  `);
76198
- process.stdout.write(import_picocolors28.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
77289
+ process.stdout.write(import_picocolors30.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
76199
77290
  if (res.fund_url) {
76200
- process.stdout.write("\nFund it here:\n" + import_picocolors28.default.bold(res.fund_url) + "\n\n");
76201
- process.stdout.write(import_picocolors28.default.dim("Funding happens in your browser with your own wallet.\n"));
77291
+ process.stdout.write("\nFund it here:\n" + import_picocolors30.default.bold(res.fund_url) + "\n\n");
77292
+ process.stdout.write(import_picocolors30.default.dim("Funding happens in your browser with your own wallet.\n"));
76202
77293
  }
76203
77294
  }
76204
77295
 
76205
77296
  // src/commands/bounty-money.ts
76206
- var import_picocolors29 = __toESM(require_picocolors(), 1);
77297
+ var import_picocolors31 = __toESM(require_picocolors(), 1);
76207
77298
  function failArg6(message) {
76208
- process.stderr.write(import_picocolors29.default.red(`${message}
77299
+ process.stderr.write(import_picocolors31.default.red(`${message}
76209
77300
  `));
76210
77301
  process.exit(2);
76211
77302
  }
@@ -76217,12 +77308,12 @@ async function loadProfileOrExit(requested, jsonMode7) {
76217
77308
  JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
76218
77309
  );
76219
77310
  } else {
76220
- process.stderr.write(import_picocolors29.default.red("Not logged in. Run agentgates login first.\n"));
77311
+ process.stderr.write(import_picocolors31.default.red("Not logged in. Run agentgates login first.\n"));
76221
77312
  }
76222
77313
  process.exit(2);
76223
77314
  }
76224
77315
  if (resolved.autoSelected && !jsonMode7) {
76225
- process.stderr.write(import_picocolors29.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
77316
+ process.stderr.write(import_picocolors31.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
76226
77317
  `));
76227
77318
  }
76228
77319
  return { profile: resolved.profile, profileName: resolved.name };
@@ -76327,17 +77418,17 @@ async function subscribeCreator(creatorUserId, opts) {
76327
77418
  }
76328
77419
 
76329
77420
  // src/commands/bounty-work.ts
76330
- var import_picocolors30 = __toESM(require_picocolors(), 1);
77421
+ var import_picocolors32 = __toESM(require_picocolors(), 1);
76331
77422
  init_constants();
76332
77423
  async function runWork(path8, body, opts) {
76333
77424
  const requested = opts.profile ?? DEFAULT_PROFILE;
76334
77425
  const resolved = await resolveProfile(requested);
76335
77426
  if (!resolved) {
76336
- process.stderr.write(import_picocolors30.default.red("Not logged in. Run agentgates login first.\n"));
77427
+ process.stderr.write(import_picocolors32.default.red("Not logged in. Run agentgates login first.\n"));
76337
77428
  process.exit(2);
76338
77429
  }
76339
77430
  if (resolved.autoSelected) {
76340
- process.stderr.write(import_picocolors30.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
77431
+ process.stderr.write(import_picocolors32.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
76341
77432
  `));
76342
77433
  }
76343
77434
  const jsonMode7 = opts.json === true;
@@ -76345,7 +77436,7 @@ async function runWork(path8, body, opts) {
76345
77436
  profile: resolved.profile,
76346
77437
  profileName: resolved.name,
76347
77438
  jsonMode: jsonMode7,
76348
- ttyHeader: import_picocolors30.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
77439
+ ttyHeader: import_picocolors32.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
76349
77440
  fn: (bearer, origin) => apiFetch(path8, { bearer, origin, method: "POST", body })
76350
77441
  });
76351
77442
  if (outcome.kind === "auth_failed") {
@@ -76353,7 +77444,7 @@ async function runWork(path8, body, opts) {
76353
77444
  process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
76354
77445
  process.exit(1);
76355
77446
  }
76356
- process.stderr.write(import_picocolors30.default.red(`\u2715 ${outcome.reason}.
77447
+ process.stderr.write(import_picocolors32.default.red(`\u2715 ${outcome.reason}.
76357
77448
  `));
76358
77449
  process.exit(1);
76359
77450
  }
@@ -76363,7 +77454,7 @@ async function runWork(path8, body, opts) {
76363
77454
  if (jsonMode7) {
76364
77455
  process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
76365
77456
  } else {
76366
- process.stderr.write(import_picocolors30.default.red(`\u2715 ${err.message} (HTTP ${err.status})
77457
+ process.stderr.write(import_picocolors32.default.red(`\u2715 ${err.message} (HTTP ${err.status})
76367
77458
  `));
76368
77459
  }
76369
77460
  process.exit(1);
@@ -76376,11 +77467,11 @@ async function runWork(path8, body, opts) {
76376
77467
  process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
76377
77468
  process.exit(1);
76378
77469
  }
76379
- process.stderr.write(import_picocolors30.default.yellow(`
77470
+ process.stderr.write(import_picocolors32.default.yellow(`
76380
77471
  ${data4.reason ?? "Blocked."}
76381
77472
  `));
76382
77473
  if (data4.upgrade_url) process.stderr.write(`
76383
- ${import_picocolors30.default.bold(data4.upgrade_url)}
77474
+ ${import_picocolors32.default.bold(data4.upgrade_url)}
76384
77475
 
76385
77476
  `);
76386
77477
  process.exit(1);
@@ -76389,7 +77480,7 @@ ${import_picocolors30.default.bold(data4.upgrade_url)}
76389
77480
  if (jsonMode7) {
76390
77481
  process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
76391
77482
  } else {
76392
- process.stderr.write(import_picocolors30.default.red(`\u2715 ${data4.error}
77483
+ process.stderr.write(import_picocolors32.default.red(`\u2715 ${data4.error}
76393
77484
  `));
76394
77485
  }
76395
77486
  process.exit(1);
@@ -76432,7 +77523,7 @@ async function bountyRetention(bountyId, opts) {
76432
77523
  }
76433
77524
 
76434
77525
  // src/commands/bounty-deliver.ts
76435
- var import_picocolors31 = __toESM(require_picocolors(), 1);
77526
+ var import_picocolors33 = __toESM(require_picocolors(), 1);
76436
77527
  import { spawn as spawn2 } from "node:child_process";
76437
77528
  init_constants();
76438
77529
  var FLUSH_MS = 400;
@@ -76442,11 +77533,11 @@ async function deliver(bountyId, command, opts) {
76442
77533
  const requested = opts.profile ?? DEFAULT_PROFILE;
76443
77534
  const resolved = await resolveProfile(requested);
76444
77535
  if (!resolved) {
76445
- process.stderr.write(import_picocolors31.default.red("Not logged in. Run agentgates login first.\n"));
77536
+ process.stderr.write(import_picocolors33.default.red("Not logged in. Run agentgates login first.\n"));
76446
77537
  process.exit(2);
76447
77538
  }
76448
77539
  if (resolved.autoSelected && !jsonMode7) {
76449
- process.stderr.write(import_picocolors31.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
77540
+ process.stderr.write(import_picocolors33.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
76450
77541
  `));
76451
77542
  }
76452
77543
  const post3 = async (path8, body) => {
@@ -76454,7 +77545,7 @@ async function deliver(bountyId, command, opts) {
76454
77545
  profile: resolved.profile,
76455
77546
  profileName: resolved.name,
76456
77547
  jsonMode: jsonMode7,
76457
- ttyHeader: import_picocolors31.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
77548
+ ttyHeader: import_picocolors33.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
76458
77549
  fn: (bearer, origin) => apiFetch(path8, { bearer, origin, method: "POST", body })
76459
77550
  });
76460
77551
  if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
@@ -76465,11 +77556,11 @@ async function deliver(bountyId, command, opts) {
76465
77556
  if (jsonMode7) {
76466
77557
  process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
76467
77558
  } else {
76468
- process.stderr.write(import_picocolors31.default.red(`
77559
+ process.stderr.write(import_picocolors33.default.red(`
76469
77560
  \u2715 ${msg}
76470
77561
  `));
76471
77562
  if (data4?.upgrade_url) process.stderr.write(`
76472
- ${import_picocolors31.default.bold(data4.upgrade_url)}
77563
+ ${import_picocolors33.default.bold(data4.upgrade_url)}
76473
77564
 
76474
77565
  `);
76475
77566
  }
@@ -76494,7 +77585,7 @@ ${import_picocolors31.default.bold(data4.upgrade_url)}
76494
77585
  if (!runId) return void die("The service opened a run but did not name it.");
76495
77586
  if (!jsonMode7) {
76496
77587
  process.stderr.write(
76497
- import_picocolors31.default.bold("\n\u25CF LIVE ") + import_picocolors31.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors31.default.dim(` ${started.url ?? ""}
77588
+ import_picocolors33.default.bold("\n\u25CF LIVE ") + import_picocolors33.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors33.default.dim(` ${started.url ?? ""}
76498
77589
 
76499
77590
  `)
76500
77591
  );
@@ -76546,10 +77637,10 @@ ${import_picocolors31.default.bold(data4.upgrade_url)}
76546
77637
  child.stdout.on("data", (d) => consume(d));
76547
77638
  child.stderr.setEncoding("utf8");
76548
77639
  child.stderr.on("data", (d) => {
76549
- if (!jsonMode7) process.stderr.write(import_picocolors31.default.dim(d));
77640
+ if (!jsonMode7) process.stderr.write(import_picocolors33.default.dim(d));
76550
77641
  });
76551
77642
  child.on("error", (err) => {
76552
- process.stderr.write(import_picocolors31.default.red(`
77643
+ process.stderr.write(import_picocolors33.default.red(`
76553
77644
  \u2715 Could not run ${command[0]}: ${err.message}
76554
77645
  `));
76555
77646
  resolve2(127);
@@ -76586,14 +77677,14 @@ ${import_picocolors31.default.bold(data4.upgrade_url)}
76586
77677
  }
76587
77678
  if (appendFailure) {
76588
77679
  process.stderr.write(
76589
- import_picocolors31.default.yellow(`
77680
+ import_picocolors33.default.yellow(`
76590
77681
  ! Some output did not reach the page: ${appendFailure}
76591
- `) + import_picocolors31.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
77682
+ `) + import_picocolors33.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
76592
77683
  );
76593
77684
  }
76594
77685
  if (exitCode) {
76595
77686
  process.stderr.write(
76596
- import_picocolors31.default.yellow(`
77687
+ import_picocolors33.default.yellow(`
76597
77688
  ! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
76598
77689
  `)
76599
77690
  );
@@ -76603,7 +77694,7 @@ ${import_picocolors31.default.bold(data4.upgrade_url)}
76603
77694
  }
76604
77695
 
76605
77696
  // src/commands/trade.ts
76606
- var import_picocolors32 = __toESM(require_picocolors(), 1);
77697
+ var import_picocolors34 = __toESM(require_picocolors(), 1);
76607
77698
  init_constants();
76608
77699
 
76609
77700
  // src/lib/trade-sol.ts
@@ -76967,11 +78058,11 @@ async function runTrade(args) {
76967
78058
  }
76968
78059
 
76969
78060
  // src/commands/trade.ts
76970
- function fail3(message, json2) {
78061
+ function fail5(message, json2) {
76971
78062
  if (json2) {
76972
78063
  process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
76973
78064
  } else {
76974
- process.stderr.write(import_picocolors32.default.red(`\u2715 ${message}
78065
+ process.stderr.write(import_picocolors34.default.red(`\u2715 ${message}
76975
78066
  `));
76976
78067
  }
76977
78068
  process.exit(1);
@@ -76981,7 +78072,7 @@ async function withContext(opts, fn) {
76981
78072
  const ctx2 = await resolveTradeContext();
76982
78073
  return await fn(ctx2);
76983
78074
  } catch (err) {
76984
- fail3(err.message, opts.json);
78075
+ fail5(err.message, opts.json);
76985
78076
  }
76986
78077
  }
76987
78078
  function servedFloorUnits(ctx2) {
@@ -77007,7 +78098,7 @@ async function tradeKey(opts) {
77007
78098
  ];
77008
78099
  process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
77009
78100
  } catch (err) {
77010
- fail3(err.message, opts.json);
78101
+ fail5(err.message, opts.json);
77011
78102
  }
77012
78103
  }
77013
78104
  async function tradeStatus(opts) {
@@ -77064,7 +78155,7 @@ async function tradeQuote(coinArg, amount, opts) {
77064
78155
  const coin = await resolveCoin(coinArg);
77065
78156
  const amountNumber = Number(amount);
77066
78157
  if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
77067
- fail3(`Amount "${amount}" is not a positive number.`, opts.json);
78158
+ fail5(`Amount "${amount}" is not a positive number.`, opts.json);
77068
78159
  }
77069
78160
  const res = await fetch(`${CREATORS_ORIGIN}/api/launch-quote`, {
77070
78161
  method: "POST",
@@ -77078,7 +78169,7 @@ async function tradeQuote(coinArg, amount, opts) {
77078
78169
  });
77079
78170
  const body = await res.json().catch(() => null);
77080
78171
  if (!res.ok || !body) {
77081
- fail3(`Quote failed: ${body?.error ?? `HTTP ${res.status}`}`, opts.json);
78172
+ fail5(`Quote failed: ${body?.error ?? `HTTP ${res.status}`}`, opts.json);
77082
78173
  }
77083
78174
  const floor = servedFloorUnits(ctx2);
77084
78175
  const belowFloor = side === "buy" && floor !== null && parseDecimalToUnits(amount, USDC_DECIMALS, "Amount") < floor.units;
@@ -77153,16 +78244,16 @@ async function tradeBuy(coinArg, amount, opts) {
77153
78244
  try {
77154
78245
  units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
77155
78246
  } catch (err) {
77156
- fail3(err.message, opts.json);
78247
+ fail5(err.message, opts.json);
77157
78248
  }
77158
- if (units <= 0n) fail3("Buy amount must be above zero.", opts.json);
78249
+ if (units <= 0n) fail5("Buy amount must be above zero.", opts.json);
77159
78250
  const floor = servedFloorUnits(ctx2);
77160
78251
  if (floor && units < floor.units) {
77161
- fail3(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
78252
+ fail5(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
77162
78253
  }
77163
78254
  const { keypair, state, created } = await loadOrCreateTradeKey();
77164
78255
  if (created && !opts.json) {
77165
- process.stderr.write(import_picocolors32.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
78256
+ process.stderr.write(import_picocolors34.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
77166
78257
  `));
77167
78258
  }
77168
78259
  const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
@@ -77173,23 +78264,23 @@ async function tradeSell(coinArg, amount, opts) {
77173
78264
  await withContext(opts, async (ctx2) => {
77174
78265
  const coin = await resolveCoin(coinArg);
77175
78266
  const key = await loadTradeKey();
77176
- if (!key) fail3("No agent trading key yet (nothing to sell with). Run: agentgates trade key", opts.json);
78267
+ if (!key) fail5("No agent trading key yet (nothing to sell with). Run: agentgates trade key", opts.json);
77177
78268
  let sellAmount = amount.trim();
77178
78269
  const pct = sellAmount.match(/^(\d+)%$/);
77179
78270
  if (sellAmount === "all" || pct) {
77180
78271
  const bal = await readTokenBalance(rpcConnection(), key.state.address, coin.mint);
77181
- if (!bal) fail3("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
77182
- if (bal.units <= 0n) fail3("This key holds none of that coin.", opts.json);
78272
+ if (!bal) fail5("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
78273
+ if (bal.units <= 0n) fail5("This key holds none of that coin.", opts.json);
77183
78274
  let units = bal.units;
77184
78275
  if (pct) {
77185
78276
  const p = BigInt(pct[1]);
77186
- if (p <= 0n || p > 100n) fail3(`Percentage must be 1-100, got "${amount}".`, opts.json);
78277
+ if (p <= 0n || p > 100n) fail5(`Percentage must be 1-100, got "${amount}".`, opts.json);
77187
78278
  units = bal.units * p / 100n;
77188
78279
  }
77189
- if (units <= 0n) fail3("Sell amount rounds to zero.", opts.json);
78280
+ if (units <= 0n) fail5("Sell amount rounds to zero.", opts.json);
77190
78281
  sellAmount = formatUnits2(units, bal.decimals);
77191
78282
  } else if (!/^\d+(\.\d+)?$/.test(sellAmount)) {
77192
- fail3(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
78283
+ fail5(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
77193
78284
  }
77194
78285
  const result = await runTrade({ ctx: ctx2, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
77195
78286
  await reportTrade(ctx2, opts, { side: "sell", coin, address: key.state.address, amount: sellAmount, result });
@@ -77204,19 +78295,19 @@ function describeOrder(o) {
77204
78295
  async function tradeOrderPlace(coinArg, opts) {
77205
78296
  await withContext(opts, async (ctx2) => {
77206
78297
  if (opts.buy === void 0 === (opts.sell === void 0)) {
77207
- fail3("Pass exactly one of --buy <usdc> or --sell <amount|N%|all>.", opts.json);
78298
+ fail5("Pass exactly one of --buy <usdc> or --sell <amount|N%|all>.", opts.json);
77208
78299
  }
77209
78300
  if (opts.at === void 0 === (opts.onGraduation !== true)) {
77210
- fail3("Pass exactly one trigger: --at <value> (price, or mcap with --mcap) or --on-graduation.", opts.json);
78301
+ fail5("Pass exactly one trigger: --at <value> (price, or mcap with --mcap) or --on-graduation.", opts.json);
77211
78302
  }
77212
78303
  const coin = await resolveCoin(coinArg);
77213
78304
  const side = opts.buy !== void 0 ? "buy" : "sell";
77214
78305
  const kind = opts.onGraduation ? side === "buy" ? "buy_on_graduation" : "sell_on_graduation" : side === "buy" ? "buy_at" : "sell_at";
77215
- if (opts.stop && kind !== "sell_at") fail3("--stop only applies to a --sell order with --at.", opts.json);
77216
- if (opts.mcap && !opts.at) fail3("--mcap qualifies --at.", opts.json);
78306
+ if (opts.stop && kind !== "sell_at") fail5("--stop only applies to a --sell order with --at.", opts.json);
78307
+ if (opts.mcap && !opts.at) fail5("--mcap qualifies --at.", opts.json);
77217
78308
  const { keypair, state, created } = await loadOrCreateTradeKey();
77218
78309
  if (created && !opts.json) {
77219
- process.stderr.write(import_picocolors32.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
78310
+ process.stderr.write(import_picocolors34.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
77220
78311
  `));
77221
78312
  }
77222
78313
  let amount;
@@ -77225,11 +78316,11 @@ async function tradeOrderPlace(coinArg, opts) {
77225
78316
  try {
77226
78317
  units = parseDecimalToUnits(opts.buy, USDC_DECIMALS, "Buy amount");
77227
78318
  } catch (err) {
77228
- fail3(err.message, opts.json);
78319
+ fail5(err.message, opts.json);
77229
78320
  }
77230
78321
  const floor = servedFloorUnits(ctx2);
77231
78322
  if (floor && units < floor.units) {
77232
- fail3(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
78323
+ fail5(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
77233
78324
  }
77234
78325
  amount = opts.buy;
77235
78326
  } else {
@@ -77237,24 +78328,24 @@ async function tradeOrderPlace(coinArg, opts) {
77237
78328
  const pct = amount.match(/^(\d+)%$/);
77238
78329
  if (amount === "all" || pct) {
77239
78330
  const bal = await readTokenBalance(rpcConnection(), state.address, coin.mint);
77240
- if (!bal) fail3("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
77241
- if (bal.units <= 0n) fail3("This key holds none of that coin.", opts.json);
78331
+ if (!bal) fail5("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
78332
+ if (bal.units <= 0n) fail5("This key holds none of that coin.", opts.json);
77242
78333
  let units = bal.units;
77243
78334
  if (pct) {
77244
78335
  const p = BigInt(pct[1]);
77245
- if (p <= 0n || p > 100n) fail3(`Percentage must be 1-100, got "${opts.sell}".`, opts.json);
78336
+ if (p <= 0n || p > 100n) fail5(`Percentage must be 1-100, got "${opts.sell}".`, opts.json);
77246
78337
  units = bal.units * p / 100n;
77247
78338
  }
77248
- if (units <= 0n) fail3("Sell amount rounds to zero.", opts.json);
78339
+ if (units <= 0n) fail5("Sell amount rounds to zero.", opts.json);
77249
78340
  amount = formatUnits2(units, bal.decimals);
77250
78341
  } else if (!/^\d+(\.\d+)?$/.test(amount)) {
77251
- fail3(`Sell amount "${opts.sell}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
78342
+ fail5(`Sell amount "${opts.sell}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
77252
78343
  }
77253
78344
  }
77254
78345
  let expiresInDays;
77255
78346
  if (opts.expiresDays !== void 0) {
77256
78347
  const n2 = Number(opts.expiresDays);
77257
- if (!Number.isInteger(n2) || n2 < 1) fail3(`--expires-days must be a positive integer, got "${opts.expiresDays}".`, opts.json);
78348
+ if (!Number.isInteger(n2) || n2 < 1) fail5(`--expires-days must be a positive integer, got "${opts.expiresDays}".`, opts.json);
77258
78349
  expiresInDays = n2;
77259
78350
  }
77260
78351
  const prepared = await prepareOrder({
@@ -77290,7 +78381,7 @@ async function tradeOrderPlace(coinArg, opts) {
77290
78381
  async function tradeOrdersList(opts) {
77291
78382
  await withContext(opts, async (ctx2) => {
77292
78383
  const key = await loadTradeKey();
77293
- if (!key) fail3("No agent trading key yet. Run: agentgates trade key", opts.json);
78384
+ if (!key) fail5("No agent trading key yet. Run: agentgates trade key", opts.json);
77294
78385
  const token = opts.coin ? (await resolveCoin(opts.coin)).mint : void 0;
77295
78386
  const res = await listOrders(key.state.address, token);
77296
78387
  if (opts.json) {
@@ -77310,15 +78401,15 @@ async function tradeOrdersList(opts) {
77310
78401
  async function tradeOrderCancel(id2, opts) {
77311
78402
  await withContext(opts, async (_ctx) => {
77312
78403
  const key = await loadTradeKey();
77313
- if (!key) fail3("No agent trading key yet. Run: agentgates trade key", opts.json);
78404
+ if (!key) fail5("No agent trading key yet. Run: agentgates trade key", opts.json);
77314
78405
  try {
77315
78406
  await cancelOrder(id2, key.state.address);
77316
78407
  } catch (err) {
77317
78408
  if (err instanceof RelayError && err.status === 409) {
77318
- fail3(`Order ${id2} already fired or ended; nothing to cancel.`, opts.json);
78409
+ fail5(`Order ${id2} already fired or ended; nothing to cancel.`, opts.json);
77319
78410
  }
77320
78411
  if (err instanceof RelayError && err.status === 404) {
77321
- fail3(`No order ${id2} for this key (already canceled, or never placed).`, opts.json);
78412
+ fail5(`No order ${id2} for this key (already canceled, or never placed).`, opts.json);
77322
78413
  }
77323
78414
  throw err;
77324
78415
  }
@@ -77333,12 +78424,12 @@ async function tradeOrderCancel(id2, opts) {
77333
78424
  async function tradePositions(opts) {
77334
78425
  await withContext(opts, async (ctx2) => {
77335
78426
  const key = await loadTradeKey();
77336
- if (!key) fail3("No agent trading key yet. Run: agentgates trade key", opts.json);
78427
+ if (!key) fail5("No agent trading key yet. Run: agentgates trade key", opts.json);
77337
78428
  let body;
77338
78429
  try {
77339
78430
  body = await relayGet(`/launch-portfolio?address=${encodeURIComponent(key.state.address)}`);
77340
78431
  } catch (err) {
77341
- if (err instanceof RelayError) fail3(`Positions read failed: ${err.message}`, opts.json);
78432
+ if (err instanceof RelayError) fail5(`Positions read failed: ${err.message}`, opts.json);
77342
78433
  throw err;
77343
78434
  }
77344
78435
  const rows = body?.tokens ?? [];
@@ -77381,7 +78472,7 @@ async function tradePositions(opts) {
77381
78472
  }
77382
78473
 
77383
78474
  // src/commands/desk.ts
77384
- var import_picocolors33 = __toESM(require_picocolors(), 1);
78475
+ var import_picocolors35 = __toESM(require_picocolors(), 1);
77385
78476
  init_constants();
77386
78477
 
77387
78478
  // src/lib/desk-sol.ts
@@ -77552,11 +78643,11 @@ async function runDeskTrade(args) {
77552
78643
  }
77553
78644
 
77554
78645
  // src/commands/desk.ts
77555
- function fail4(message, json2) {
78646
+ function fail6(message, json2) {
77556
78647
  if (json2) {
77557
78648
  process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
77558
78649
  } else {
77559
- process.stderr.write(import_picocolors33.default.red(`\u2715 ${message}
78650
+ process.stderr.write(import_picocolors35.default.red(`\u2715 ${message}
77560
78651
  `));
77561
78652
  }
77562
78653
  process.exit(1);
@@ -77566,7 +78657,7 @@ async function withDesk(opts, fn) {
77566
78657
  const ctx2 = await resolveDeskContext();
77567
78658
  return await fn(ctx2);
77568
78659
  } catch (err) {
77569
- fail4(err.message, opts.json);
78660
+ fail6(err.message, opts.json);
77570
78661
  }
77571
78662
  }
77572
78663
  function servedFloorUnits2(ctx2) {
@@ -77577,7 +78668,7 @@ function servedFloorUnits2(ctx2) {
77577
78668
  async function requireOwner(opts) {
77578
78669
  const key = await loadTradeKey();
77579
78670
  if (!key) {
77580
- fail4("No agent trading key yet (the desk's owner). Run: agentgates trade key", opts.json);
78671
+ fail6("No agent trading key yet (the desk's owner). Run: agentgates trade key", opts.json);
77581
78672
  }
77582
78673
  return key;
77583
78674
  }
@@ -77646,7 +78737,7 @@ async function deskStatus(opts) {
77646
78737
  if (opts.fills !== void 0) {
77647
78738
  const n2 = Number(opts.fills);
77648
78739
  if (!Number.isInteger(n2) || n2 <= 0) {
77649
- fail4(`--fills must be a positive integer, got "${opts.fills}".`, opts.json);
78740
+ fail6(`--fills must be a positive integer, got "${opts.fills}".`, opts.json);
77650
78741
  }
77651
78742
  fillsLimit = n2;
77652
78743
  }
@@ -77694,12 +78785,12 @@ async function deskDeposit(amount, opts) {
77694
78785
  try {
77695
78786
  units = parseDecimalToUnits(amount, USDC_DECIMALS, "Deposit amount");
77696
78787
  } catch (err) {
77697
- fail4(err.message, opts.json);
78788
+ fail6(err.message, opts.json);
77698
78789
  }
77699
- if (units <= 0n) fail4("Deposit amount must be above zero.", opts.json);
78790
+ if (units <= 0n) fail6("Deposit amount must be above zero.", opts.json);
77700
78791
  const { keypair, state, created } = await loadOrCreateTradeKey();
77701
78792
  if (created && !opts.json) {
77702
- process.stderr.write(import_picocolors33.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
78793
+ process.stderr.write(import_picocolors35.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
77703
78794
  `));
77704
78795
  }
77705
78796
  const result = await runDeskCeremony({
@@ -77740,7 +78831,7 @@ async function deskWithdraw(amount, opts) {
77740
78831
  const trimmed = amount.trim();
77741
78832
  if (trimmed !== "all") {
77742
78833
  if (!/^\d+(\.\d+)?$/.test(trimmed)) {
77743
- fail4(`Withdraw amount "${amount}" is not a decimal amount or "all".`, opts.json);
78834
+ fail6(`Withdraw amount "${amount}" is not a decimal amount or "all".`, opts.json);
77744
78835
  }
77745
78836
  }
77746
78837
  const result = await runDeskCeremony({
@@ -77779,28 +78870,28 @@ async function deskWithdraw(amount, opts) {
77779
78870
  }
77780
78871
  async function deskSessionRegister(opts) {
77781
78872
  await withDesk(opts, async (ctx2) => {
77782
- if (!opts.cap) fail4("--cap <usdc> is required: the per-trade cap is your risk statement, never defaulted.", opts.json);
77783
- if (!opts.minutes) fail4("--minutes <n> is required: the session expiry is your risk statement, never defaulted.", opts.json);
78873
+ if (!opts.cap) fail6("--cap <usdc> is required: the per-trade cap is your risk statement, never defaulted.", opts.json);
78874
+ if (!opts.minutes) fail6("--minutes <n> is required: the session expiry is your risk statement, never defaulted.", opts.json);
77784
78875
  let capUnits;
77785
78876
  try {
77786
78877
  capUnits = parseDecimalToUnits(opts.cap, USDC_DECIMALS, "Per-trade cap");
77787
78878
  } catch (err) {
77788
- fail4(err.message, opts.json);
78879
+ fail6(err.message, opts.json);
77789
78880
  }
77790
- if (capUnits <= 0n) fail4("Per-trade cap must be above zero.", opts.json);
78881
+ if (capUnits <= 0n) fail6("Per-trade cap must be above zero.", opts.json);
77791
78882
  const minutes = Number(opts.minutes);
77792
78883
  if (!Number.isInteger(minutes) || minutes <= 0) {
77793
- fail4(`--minutes must be a positive integer, got "${opts.minutes}".`, opts.json);
78884
+ fail6(`--minutes must be a positive integer, got "${opts.minutes}".`, opts.json);
77794
78885
  }
77795
78886
  const owner = await loadOrCreateTradeKey();
77796
78887
  if (owner.created && !opts.json) {
77797
- process.stderr.write(import_picocolors33.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
78888
+ process.stderr.write(import_picocolors35.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
77798
78889
  `));
77799
78890
  }
77800
78891
  const session = await loadOrCreateDeskSessionKey();
77801
78892
  if (session.created && !opts.json) {
77802
78893
  process.stderr.write(
77803
- import_picocolors33.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
78894
+ import_picocolors35.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
77804
78895
  `)
77805
78896
  );
77806
78897
  }
@@ -77874,7 +78965,7 @@ async function deskSessionRevoke(opts) {
77874
78965
  async function requireSessionKeypair(opts) {
77875
78966
  const session = await loadDeskSessionKey();
77876
78967
  if (!session) {
77877
- fail4(
78968
+ fail6(
77878
78969
  "No desk session key on this terminal. Register one: agentgates desk session register --cap <usdc> --minutes <n>",
77879
78970
  opts.json
77880
78971
  );
@@ -77918,12 +79009,12 @@ async function deskBuy(coinArg, amount, opts) {
77918
79009
  try {
77919
79010
  units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
77920
79011
  } catch (err) {
77921
- fail4(err.message, opts.json);
79012
+ fail6(err.message, opts.json);
77922
79013
  }
77923
- if (units <= 0n) fail4("Buy amount must be above zero.", opts.json);
79014
+ if (units <= 0n) fail6("Buy amount must be above zero.", opts.json);
77924
79015
  const floor = servedFloorUnits2(ctx2);
77925
79016
  if (floor && units < floor.units) {
77926
- fail4(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
79017
+ fail6(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
77927
79018
  }
77928
79019
  const owner = await requireOwner(opts);
77929
79020
  const session = await requireSessionKeypair(opts);
@@ -77948,16 +79039,16 @@ async function deskSell(coinArg, amount, opts) {
77948
79039
  const pct = sellAmount.match(/^(\d+)%$/);
77949
79040
  if (pct) {
77950
79041
  const state = await deskState(owner.state.address, coin.mint);
77951
- if (!state.coin) fail4("The desk holds none of that coin for this owner.", opts.json);
79042
+ if (!state.coin) fail6("The desk holds none of that coin for this owner.", opts.json);
77952
79043
  const credit = BigInt(state.coin.creditUnits);
77953
- if (credit <= 0n) fail4("The desk holds none of that coin for this owner.", opts.json);
79044
+ if (credit <= 0n) fail6("The desk holds none of that coin for this owner.", opts.json);
77954
79045
  const p = BigInt(pct[1]);
77955
- if (p <= 0n || p > 100n) fail4(`Percentage must be 1-100, got "${amount}".`, opts.json);
79046
+ if (p <= 0n || p > 100n) fail6(`Percentage must be 1-100, got "${amount}".`, opts.json);
77956
79047
  const units = credit * p / 100n;
77957
- if (units <= 0n) fail4("Sell amount rounds to zero.", opts.json);
79048
+ if (units <= 0n) fail6("Sell amount rounds to zero.", opts.json);
77958
79049
  sellAmount = formatUnits2(units, state.coin.decimals);
77959
79050
  } else if (sellAmount !== "all" && !/^\d+(\.\d+)?$/.test(sellAmount)) {
77960
- fail4(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
79051
+ fail6(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
77961
79052
  }
77962
79053
  const result = await runDeskTrade({
77963
79054
  ctx: ctx2,
@@ -77978,7 +79069,7 @@ var program2 = new Command();
77978
79069
  program2.name("agentgates").description(
77979
79070
  "Drive your non-custodial Agentgates wallet from the terminal.\nPair once with biometric; every send still requires biometric in your browser."
77980
79071
  ).version(VERSION);
77981
- program2.command("login").description("Log in. With an API key from Agent APIs (agk_\u2026): run this machine on that account, no browser, what the key's grid allows. With nothing: pair this terminal with your Agentgates wallet (one-time)").argument("[key]", "an API key minted on agentgates.ai, the whole string (agk_\u2026.<reading part>): the same as agentgates keys use. The part after the dot stays on this machine").option("--profile <name>", "named profile (default: 'default')").option("--no-browser", "don't auto-open the approval URL \u2014 print it only").option("--json", "machine-readable output (with a key)").action(async (key, opts) => {
79072
+ program2.command("login").description("Log in. With an API key from Agent access (agk_\u2026): run this machine on that account, no browser, what the key's grid allows. With nothing: pair this terminal with your Agentgates wallet (one-time)").argument("[key]", "an API key minted on agentgates.ai, the whole string (agk_\u2026.<reading part>): the same as agentgates keys use. The part after the dot stays on this machine").option("--profile <name>", "named profile (default: 'default')").option("--no-browser", "don't auto-open the approval URL \u2014 print it only").option("--json", "machine-readable output (with a key)").action(async (key, opts) => {
77982
79073
  if (key) {
77983
79074
  await keysUse(key, { json: opts.json });
77984
79075
  return;
@@ -78346,7 +79437,7 @@ program2.command("fund").description(
78346
79437
  }
78347
79438
  if (opts.usdc || opts.gas || opts.chain) {
78348
79439
  process.stderr.write(
78349
- import_picocolors34.default.red(
79440
+ import_picocolors36.default.red(
78350
79441
  `\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
78351
79442
  `
78352
79443
  )
@@ -78508,7 +79599,7 @@ var registerCalls = (parent, name) => parent.command(`${name} [id]`).description
78508
79599
  });
78509
79600
  registerCall(phone, "call");
78510
79601
  registerCalls(phone, "calls");
78511
- phone.command("answer <number>").description("how one of your numbers answers when it rings: the role (receptionist, screener, order-taker, reservationist, after-hours, callback-line, hotline, answering-voicemail) and the brief").option("--role <role>", "the inbound role (default receptionist)").option("--brief <text>", "the brief: the business, the hours, who gets messages; kept on a persona named after the number").option("--persona <id>", "a persona of yours to answer with instead").option("--brain <ours|yours>", "who writes the lines (default ours)").option("--webhook <url>", "with --brain yours: your public https door").option("--minutes <n>", "the minutes one answered call may run on this number (default: the lane's window); the first seconds are free either way").option("--json", "machine-readable output").action((number2, opts) => phoneAnswer(number2, opts));
79602
+ phone.command("answer <number>").description("how one of your numbers answers when it rings: the role (receptionist, screener, order-taker, reservationist, after-hours, callback-line, hotline, answering-voicemail) and the brief").option("--role <role>", "the inbound role (default receptionist)").option("--brief <text>", "the brief: the business, the hours, who gets messages; kept on a persona named after the number").option("--persona <id>", "a persona of yours to answer with instead").option("--brain <ours|yours|agent>", "who writes the lines: ours (default), yours over --webhook, or agent (your agent answers; also --brain yours with no --webhook)").option("--webhook <url>", "with --brain yours: your public https door").option("--minutes <n>", "the minutes one answered call may run on this number (default: the lane's window); the first seconds are free either way").option("--json", "machine-readable output").action((number2, opts) => phoneAnswer(number2, opts));
78512
79603
  registerCall(program2, "call");
78513
79604
  registerCalls(program2, "calls");
78514
79605
  var email = program2.command("email").description("Inboxes on your wallet: free to hold on a funded balance, receiving free, sends per message, USDC over x402");
@@ -78586,7 +79677,7 @@ var browser = program2.command("browser").description(
78586
79677
  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 account catalog)").action(async (opts) => {
78587
79678
  await browserPricing(opts);
78588
79679
  });
78589
- 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("--login <row id>", "start signed in with this saved password (agentgates passwords list): the CVM logs in, the session rides the task; Passwords charges the login, Browser the steps").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) => {
79680
+ 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("--login <row id>", "start signed in with this saved password (agentgates passwords list): the task runs inside that login's own browser on the passwords CVM, starting on the row's site; Passwords charges the login, Browser the steps").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>", "fence the task to the site and this hostname (repeatable); without --host the task goes to any public site the task leads to", (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) => {
78590
79681
  await browserRun(url, opts);
78591
79682
  });
78592
79683
  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) => {
@@ -78600,7 +79691,7 @@ program2.command("init").description(
78600
79691
  ).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) => {
78601
79692
  await passwordsInit(opts);
78602
79693
  });
78603
- var keys = program2.command("keys").description("The login keys on this account (Agent APIs): what this machine sends on every call instead of the words. Signed by the words; a key never mints a key.");
79694
+ var keys = program2.command("keys").description("The login keys on this account (Agent access): what this machine sends on every call instead of the words. Signed by the words; a key never mints a key.");
78604
79695
  keys.command("list", { isDefault: true }).description("List the account's login keys with their last use; marks this machine's.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
78605
79696
  await keysList(opts);
78606
79697
  });
@@ -78697,6 +79788,65 @@ intents.command("rate <askId>").description("Rate a business's leg that settled
78697
79788
  intents.command("noshow <askId>").description("Mark a no-show on a committed leg of yours: a fact on the poster's record that sellers see.").requiredOption("--offer <offerId>", "your committed leg").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (askId, opts) => {
78698
79789
  await intentsNoShow(askId, opts);
78699
79790
  });
79791
+ var memory = program2.command("memory").description("Sealed folders of markdown your agents read: names and bodies are sealed on this machine to the account's data key; the wire and the server carry ciphertext only.");
79792
+ memory.command("overview", { isDefault: true }).description("The folders, their counts, and what the plan allows.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
79793
+ await memoryOverview(opts);
79794
+ });
79795
+ memory.command("mkdir <folder>").description("Make a folder (a slug: a-z, 0-9, -). A folder is the unit a key is granted.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (folder, opts) => {
79796
+ await memoryMkdir(folder, opts);
79797
+ });
79798
+ memory.command("rmdir <folder>").description("Remove a folder and every file in it. The rows are the only copy. Takes the words.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (folder, opts) => {
79799
+ await memoryRmdir(folder, opts);
79800
+ });
79801
+ memory.command("sources").description("The connected accounts (Dropbox, Google Drive) and the folders chosen on them, each with its context. Opened here.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
79802
+ await memorySources(opts);
79803
+ });
79804
+ memory.command("ls <folder>").description("The files in a folder plus the connected folders in that context; <context>/<connected folder>[/<inside>] lists inside a connected account, live.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (folder, opts) => {
79805
+ await memoryLs(folder, opts);
79806
+ });
79807
+ memory.command("cat <path>").description("Print one file: <folder>/<name>, or <context>/<connected folder>/<path> read live from the connected account.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (path8, opts) => {
79808
+ await memoryCat(path8, opts);
79809
+ });
79810
+ memory.command("put <path>").description("Store or replace a file, <folder>/<name>, from --file or stdin. Up to 256 KB of text, sealed here before it leaves.").option("--file <path>", "the file to store; without it the text is read from stdin").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (path8, opts) => {
79811
+ await memoryPut(path8, opts);
79812
+ });
79813
+ memory.command("rm <path>").description("Remove one file, <folder>/<name>.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (path8, opts) => {
79814
+ await memoryRm(path8, opts);
79815
+ });
79816
+ memory.command("grep <pattern> [folder]").description("Search every file this machine can open (or one folder) with a regular expression, opened and matched here. Prints folder/name:line: text.").option("-i, --ignore-case", "case-insensitive").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (pattern, folder, opts) => {
79817
+ await memoryGrep(pattern, folder, opts);
79818
+ });
79819
+ var agent = program2.command("agent").description("Your agent on the AG AI CVM: turn it on (its key sealed to you and to the CVM), tell it what to do, read its thread. It pays from your balance. Turning it on and off takes the words.");
79820
+ agent.command("status", { isDefault: true }).description("Whether your agent is on and its address. It pays from your balance.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
79821
+ await agentStatus(opts);
79822
+ });
79823
+ agent.command("on").description("Turn your agent on: a wallet minted here, its key sealed to your account's key and to the CVM's fleet key, a Memory key with its copy of the data key. Takes the words and a sealed account (agentgates email seal).").option("--fund <usd>", "retired: your agent pays from your balance, nothing is moved to it").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
79824
+ await agentOn(opts);
79825
+ });
79826
+ agent.command("off").description("Turn your agent off: the CVM's copies go, its Memory key is revoked. Its thread stays in Memory.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
79827
+ await agentOff(opts);
79828
+ });
79829
+ agent.command("fund <usd>").description("Retired: your agent pays from your balance, so there is nothing to fund. Says so and moves nothing.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (usd7, opts) => {
79830
+ await agentFund(usd7, opts);
79831
+ });
79832
+ agent.command("refill [off]").description("Retired: your agent pays from your balance, so there is no refill rule. Says so and moves nothing.").option("--below <usd>", "retired").option("--add <usd>", "retired").option("--cap <usd>", "retired").option("--days <n>", "retired").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (action, opts) => {
79833
+ await agentRefill(action, opts);
79834
+ });
79835
+ agent.command("say <text>").description("Tell your agent what to do. The words are sealed to the CVM on the way; the reply lands in the thread.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (text, opts) => {
79836
+ await agentSay(text, opts);
79837
+ });
79838
+ agent.command("journal").description("The thread: what you said, what it answered, what it did. Opened here with the account's data key.").option("--tail <n>", "how many lines from the end (default 40, at most 200)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
79839
+ await agentJournal(opts);
79840
+ });
79841
+ agent.command("bind <channel> [sender]").description("Let a cell (sms <+15551234567>) or an address (mail <you@example.com>) reach your agent: a code you then text or mail to the agent's own number or inbox from it. Or your Telegram (telegram) or WhatsApp (whatsapp): a link you open there once. Takes the words.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (channel, sender, opts) => {
79842
+ await agentBind(channel, sender, opts);
79843
+ });
79844
+ agent.command("bindings").description("Who may reach your agent: bound senders, and the open codes still to be sent.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
79845
+ await agentBindings(opts);
79846
+ });
79847
+ agent.command("unbind <id>").description("Drop a sender: its messages land nothing from now on. Takes the words.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
79848
+ await agentUnbind(id2, opts);
79849
+ });
78700
79850
  var mcp = program2.command("mcp").description(
78701
79851
  "Serve this machine's lanes to an MCP client over stdio: passwords, browser, phone and inbox tools, signed by the key `agentgates init` minted. Add it with `agentgates mcp install`."
78702
79852
  ).action(async () => {
@@ -78706,10 +79856,10 @@ mcp.command("install").description("Print the lines that add this server to Clau
78706
79856
  mcpInstall();
78707
79857
  });
78708
79858
  program2.parseAsync(process.argv).catch((err) => {
78709
- process.stderr.write(import_picocolors34.default.red(`\u2715 ${err.message}
79859
+ process.stderr.write(import_picocolors36.default.red(`\u2715 ${err.message}
78710
79860
  `));
78711
79861
  if (process.env.BOUNTY_DEBUG) {
78712
- process.stderr.write(import_picocolors34.default.dim((err.stack ?? "") + "\n"));
79862
+ process.stderr.write(import_picocolors36.default.dim((err.stack ?? "") + "\n"));
78713
79863
  }
78714
79864
  process.exit(1);
78715
79865
  });