@agentgates/cli 0.83.0 → 0.85.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.
- package/dist/cli.mjs +217 -54
- package/package.json +3 -3
package/dist/cli.mjs
CHANGED
|
@@ -3041,6 +3041,41 @@ var require_commander = __commonJS({
|
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
3044
|
+
// src/lib/terminal-text.ts
|
|
3045
|
+
function scrubText(text) {
|
|
3046
|
+
return text.replace(UNSAFE, "");
|
|
3047
|
+
}
|
|
3048
|
+
function scrubDeep(value) {
|
|
3049
|
+
if (typeof value === "string") return scrubText(value);
|
|
3050
|
+
if (Array.isArray(value)) return value.map((v) => scrubDeep(v));
|
|
3051
|
+
if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
3052
|
+
const out = {};
|
|
3053
|
+
for (const [k, v] of Object.entries(value)) out[scrubText(k)] = scrubDeep(v);
|
|
3054
|
+
return out;
|
|
3055
|
+
}
|
|
3056
|
+
return value;
|
|
3057
|
+
}
|
|
3058
|
+
function installServerTextScrub() {
|
|
3059
|
+
if (installed || typeof Response === "undefined") return;
|
|
3060
|
+
installed = true;
|
|
3061
|
+
const json2 = Response.prototype.json;
|
|
3062
|
+
Object.defineProperty(Response.prototype, "json", {
|
|
3063
|
+
configurable: true,
|
|
3064
|
+
writable: true,
|
|
3065
|
+
value: async function scrubbedJson() {
|
|
3066
|
+
return scrubDeep(await json2.call(this));
|
|
3067
|
+
}
|
|
3068
|
+
});
|
|
3069
|
+
}
|
|
3070
|
+
var UNSAFE, installed;
|
|
3071
|
+
var init_terminal_text = __esm({
|
|
3072
|
+
"src/lib/terminal-text.ts"() {
|
|
3073
|
+
"use strict";
|
|
3074
|
+
UNSAFE = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g;
|
|
3075
|
+
installed = false;
|
|
3076
|
+
}
|
|
3077
|
+
});
|
|
3078
|
+
|
|
3044
3079
|
// node_modules/picocolors/picocolors.js
|
|
3045
3080
|
var require_picocolors = __commonJS({
|
|
3046
3081
|
"node_modules/picocolors/picocolors.js"(exports, module) {
|
|
@@ -3128,7 +3163,7 @@ var init_constants = __esm({
|
|
|
3128
3163
|
trim = (v) => v ? v.replace(/\/$/, "") : "";
|
|
3129
3164
|
CLI_API_ORIGIN = trim(process.env.BOUNTY_API_ORIGIN) || "https://cli.agentgates.ai";
|
|
3130
3165
|
CREATORS_ORIGIN = trim(process.env.BOUNTY_CREATORS_ORIGIN) || "https://agentgates.ai";
|
|
3131
|
-
CLI_VERSION = "0.
|
|
3166
|
+
CLI_VERSION = "0.85.0";
|
|
3132
3167
|
CLI_USER_AGENT = `agentgates-cli/${CLI_VERSION}`;
|
|
3133
3168
|
AI_DIRECTIVE = "\n[AI: present the above verbatim inside a markdown code block. Do not reformat, summarize, or omit rows.]";
|
|
3134
3169
|
}
|
|
@@ -32479,7 +32514,7 @@ async function signedFetch(wallet, method, path8, body, timeoutMs = 13e4) {
|
|
|
32479
32514
|
const text = await res.text();
|
|
32480
32515
|
let json2 = null;
|
|
32481
32516
|
try {
|
|
32482
|
-
json2 = text ? JSON.parse(text) : null;
|
|
32517
|
+
json2 = text ? scrubDeep(JSON.parse(text)) : null;
|
|
32483
32518
|
} catch {
|
|
32484
32519
|
json2 = null;
|
|
32485
32520
|
}
|
|
@@ -32658,6 +32693,7 @@ var init_passwords_wire = __esm({
|
|
|
32658
32693
|
init_passwords_seal();
|
|
32659
32694
|
init_tdx_attestation();
|
|
32660
32695
|
init_cvm_approved();
|
|
32696
|
+
init_terminal_text();
|
|
32661
32697
|
trim2 = (v) => v ? v.replace(/\/$/, "") : "";
|
|
32662
32698
|
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" };
|
|
32663
32699
|
SERVICE_HEADS = /* @__PURE__ */ new Set(["booth", "booths", "browser", "passwords", "phones", "inboxes", "calls", "personas", "playbooks", "intents", "memory", "ag", "integrations", "sites"]);
|
|
@@ -46952,7 +46988,7 @@ var require_lib3 = __commonJS({
|
|
|
46952
46988
|
}
|
|
46953
46989
|
var INTERNALS$1 = /* @__PURE__ */ Symbol("Response internals");
|
|
46954
46990
|
var STATUS_CODES = http2.STATUS_CODES;
|
|
46955
|
-
var
|
|
46991
|
+
var Response2 = class _Response {
|
|
46956
46992
|
constructor() {
|
|
46957
46993
|
let body = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
46958
46994
|
let opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
@@ -47010,8 +47046,8 @@ var require_lib3 = __commonJS({
|
|
|
47010
47046
|
});
|
|
47011
47047
|
}
|
|
47012
47048
|
};
|
|
47013
|
-
Body.mixIn(
|
|
47014
|
-
Object.defineProperties(
|
|
47049
|
+
Body.mixIn(Response2.prototype);
|
|
47050
|
+
Object.defineProperties(Response2.prototype, {
|
|
47015
47051
|
url: { enumerable: true },
|
|
47016
47052
|
status: { enumerable: true },
|
|
47017
47053
|
ok: { enumerable: true },
|
|
@@ -47020,7 +47056,7 @@ var require_lib3 = __commonJS({
|
|
|
47020
47056
|
headers: { enumerable: true },
|
|
47021
47057
|
clone: { enumerable: true }
|
|
47022
47058
|
});
|
|
47023
|
-
Object.defineProperty(
|
|
47059
|
+
Object.defineProperty(Response2.prototype, Symbol.toStringTag, {
|
|
47024
47060
|
value: "Response",
|
|
47025
47061
|
writable: false,
|
|
47026
47062
|
enumerable: false,
|
|
@@ -47354,7 +47390,7 @@ var require_lib3 = __commonJS({
|
|
|
47354
47390
|
};
|
|
47355
47391
|
const codings = headers.get("Content-Encoding");
|
|
47356
47392
|
if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
47357
|
-
response = new
|
|
47393
|
+
response = new Response2(body, response_options);
|
|
47358
47394
|
resolve3(response);
|
|
47359
47395
|
return;
|
|
47360
47396
|
}
|
|
@@ -47364,7 +47400,7 @@ var require_lib3 = __commonJS({
|
|
|
47364
47400
|
};
|
|
47365
47401
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
47366
47402
|
body = body.pipe(zlib.createGunzip(zlibOptions));
|
|
47367
|
-
response = new
|
|
47403
|
+
response = new Response2(body, response_options);
|
|
47368
47404
|
resolve3(response);
|
|
47369
47405
|
return;
|
|
47370
47406
|
}
|
|
@@ -47376,12 +47412,12 @@ var require_lib3 = __commonJS({
|
|
|
47376
47412
|
} else {
|
|
47377
47413
|
body = body.pipe(zlib.createInflateRaw());
|
|
47378
47414
|
}
|
|
47379
|
-
response = new
|
|
47415
|
+
response = new Response2(body, response_options);
|
|
47380
47416
|
resolve3(response);
|
|
47381
47417
|
});
|
|
47382
47418
|
raw.on("end", function() {
|
|
47383
47419
|
if (!response) {
|
|
47384
|
-
response = new
|
|
47420
|
+
response = new Response2(body, response_options);
|
|
47385
47421
|
resolve3(response);
|
|
47386
47422
|
}
|
|
47387
47423
|
});
|
|
@@ -47389,11 +47425,11 @@ var require_lib3 = __commonJS({
|
|
|
47389
47425
|
}
|
|
47390
47426
|
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
|
|
47391
47427
|
body = body.pipe(zlib.createBrotliDecompress());
|
|
47392
|
-
response = new
|
|
47428
|
+
response = new Response2(body, response_options);
|
|
47393
47429
|
resolve3(response);
|
|
47394
47430
|
return;
|
|
47395
47431
|
}
|
|
47396
|
-
response = new
|
|
47432
|
+
response = new Response2(body, response_options);
|
|
47397
47433
|
resolve3(response);
|
|
47398
47434
|
});
|
|
47399
47435
|
writeToStream(req, request);
|
|
@@ -47435,7 +47471,7 @@ var require_lib3 = __commonJS({
|
|
|
47435
47471
|
exports.default = exports;
|
|
47436
47472
|
exports.Headers = Headers;
|
|
47437
47473
|
exports.Request = Request;
|
|
47438
|
-
exports.Response =
|
|
47474
|
+
exports.Response = Response2;
|
|
47439
47475
|
exports.FetchError = FetchError;
|
|
47440
47476
|
exports.AbortError = AbortError;
|
|
47441
47477
|
}
|
|
@@ -63625,6 +63661,7 @@ var {
|
|
|
63625
63661
|
} = import_index.default;
|
|
63626
63662
|
|
|
63627
63663
|
// src/main.ts
|
|
63664
|
+
init_terminal_text();
|
|
63628
63665
|
var import_picocolors39 = __toESM(require_picocolors(), 1);
|
|
63629
63666
|
|
|
63630
63667
|
// src/commands/login.ts
|
|
@@ -63632,6 +63669,7 @@ var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
|
63632
63669
|
|
|
63633
63670
|
// src/lib/api.ts
|
|
63634
63671
|
init_constants();
|
|
63672
|
+
init_terminal_text();
|
|
63635
63673
|
var ApiError = class extends Error {
|
|
63636
63674
|
constructor(status4, code, message, body) {
|
|
63637
63675
|
super(message);
|
|
@@ -63680,7 +63718,7 @@ async function apiFetch(pathname, opts = {}) {
|
|
|
63680
63718
|
let parsed = null;
|
|
63681
63719
|
if (text) {
|
|
63682
63720
|
try {
|
|
63683
|
-
parsed = JSON.parse(text);
|
|
63721
|
+
parsed = scrubDeep(JSON.parse(text));
|
|
63684
63722
|
} catch {
|
|
63685
63723
|
}
|
|
63686
63724
|
}
|
|
@@ -64292,6 +64330,7 @@ init_constants();
|
|
|
64292
64330
|
|
|
64293
64331
|
// src/lib/sse-client.ts
|
|
64294
64332
|
init_constants();
|
|
64333
|
+
init_terminal_text();
|
|
64295
64334
|
async function* streamSse(url, opts = {}) {
|
|
64296
64335
|
const headers = {
|
|
64297
64336
|
accept: "text/event-stream",
|
|
@@ -64301,6 +64340,7 @@ async function* streamSse(url, opts = {}) {
|
|
|
64301
64340
|
if (opts.bearer) {
|
|
64302
64341
|
headers["authorization"] = `Bearer ${opts.bearer}`;
|
|
64303
64342
|
}
|
|
64343
|
+
if (opts.headers) Object.assign(headers, opts.headers);
|
|
64304
64344
|
let res;
|
|
64305
64345
|
try {
|
|
64306
64346
|
res = await fetch(url, {
|
|
@@ -64322,7 +64362,7 @@ async function* streamSse(url, opts = {}) {
|
|
|
64322
64362
|
let parsed = null;
|
|
64323
64363
|
if (text) {
|
|
64324
64364
|
try {
|
|
64325
|
-
parsed = JSON.parse(text);
|
|
64365
|
+
parsed = scrubDeep(JSON.parse(text));
|
|
64326
64366
|
} catch {
|
|
64327
64367
|
}
|
|
64328
64368
|
}
|
|
@@ -64356,7 +64396,7 @@ async function* streamSse(url, opts = {}) {
|
|
|
64356
64396
|
const payload = dataLines.join("\n");
|
|
64357
64397
|
dataLines = [];
|
|
64358
64398
|
try {
|
|
64359
|
-
yield JSON.parse(payload);
|
|
64399
|
+
yield scrubDeep(JSON.parse(payload));
|
|
64360
64400
|
} catch {
|
|
64361
64401
|
}
|
|
64362
64402
|
}
|
|
@@ -64389,7 +64429,7 @@ async function runLoginFlow(opts) {
|
|
|
64389
64429
|
const init2 = await apiFetch("/api/login-init", {
|
|
64390
64430
|
method: "POST",
|
|
64391
64431
|
origin,
|
|
64392
|
-
body: { clientLabel: defaultClientLabel() }
|
|
64432
|
+
body: { clientLabel: defaultClientLabel(), v: 2 }
|
|
64393
64433
|
});
|
|
64394
64434
|
const expiresAt = new Date(Date.now() + init2.expiresIn * 1e3).toISOString();
|
|
64395
64435
|
if (opts.jsonMode) {
|
|
@@ -64430,7 +64470,7 @@ ${opts.ttyHeader}
|
|
|
64430
64470
|
}
|
|
64431
64471
|
let sawAny = false;
|
|
64432
64472
|
try {
|
|
64433
|
-
for await (const ev of streamSse(streamUrl, {})) {
|
|
64473
|
+
for await (const ev of streamSse(streamUrl, init2.loginSecret ? { headers: { "x-login-secret": init2.loginSecret } } : {})) {
|
|
64434
64474
|
sawAny = true;
|
|
64435
64475
|
if (ev.status === "approved") {
|
|
64436
64476
|
approved = ev;
|
|
@@ -64601,7 +64641,7 @@ function shortAddress(addr) {
|
|
|
64601
64641
|
|
|
64602
64642
|
// src/commands/onboard.ts
|
|
64603
64643
|
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
64604
|
-
import { createInterface as
|
|
64644
|
+
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
64605
64645
|
init_constants();
|
|
64606
64646
|
|
|
64607
64647
|
// src/lib/water.ts
|
|
@@ -64924,10 +64964,11 @@ async function requirePasswordsKey() {
|
|
|
64924
64964
|
// src/lib/x402-pay.ts
|
|
64925
64965
|
init_lib2();
|
|
64926
64966
|
var EVM_CHAINS = {
|
|
64927
|
-
base: { chainId: 8453, rpcs: ["https://mainnet.base.org", "https://base.drpc.org"] },
|
|
64928
|
-
polygon: { chainId: 137, rpcs: ["https://polygon.drpc.org", "https://1rpc.io/matic"] },
|
|
64929
|
-
arbitrum: { chainId: 42161, rpcs: ["https://arb1.arbitrum.io/rpc", "https://arbitrum.drpc.org"] }
|
|
64967
|
+
base: { chainId: 8453, usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", rpcs: ["https://mainnet.base.org", "https://base.drpc.org"] },
|
|
64968
|
+
polygon: { chainId: 137, usdc: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", rpcs: ["https://polygon.drpc.org", "https://1rpc.io/matic"] },
|
|
64969
|
+
arbitrum: { chainId: 42161, usdc: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", rpcs: ["https://arb1.arbitrum.io/rpc", "https://arbitrum.drpc.org"] }
|
|
64930
64970
|
};
|
|
64971
|
+
var MAX_PAYMENT_WINDOW_SECONDS = 900;
|
|
64931
64972
|
function evmLegs(body) {
|
|
64932
64973
|
const out = [];
|
|
64933
64974
|
for (const leg of body.accepts ?? []) {
|
|
@@ -64936,6 +64977,7 @@ function evmLegs(body) {
|
|
|
64936
64977
|
const chain = EVM_CHAINS[network];
|
|
64937
64978
|
if (!chain) continue;
|
|
64938
64979
|
if (!leg.payTo || !leg.asset || !leg.maxAmountRequired) continue;
|
|
64980
|
+
if (leg.asset.toLowerCase() !== chain.usdc.toLowerCase()) continue;
|
|
64939
64981
|
let amountMicro;
|
|
64940
64982
|
try {
|
|
64941
64983
|
amountMicro = BigInt(leg.maxAmountRequired);
|
|
@@ -64980,7 +65022,7 @@ async function chooseLeg(body, address) {
|
|
|
64980
65022
|
const offered = (body.accepts ?? []).map((a) => a.network ?? "?").join(", ") || "none";
|
|
64981
65023
|
return {
|
|
64982
65024
|
ok: false,
|
|
64983
|
-
reason: `this 402 offers no EVM \`exact\` leg this key can sign (offered: ${offered}). A solana leg needs the compute lane's partially-signed transaction`,
|
|
65025
|
+
reason: `this 402 offers no EVM \`exact\` USDC leg this key can sign (offered: ${offered}). A solana leg needs the compute lane's partially-signed transaction; a leg naming any token but Circle's USDC is never signed`,
|
|
64984
65026
|
needMicro: null,
|
|
64985
65027
|
bestHeldMicro: null
|
|
64986
65028
|
};
|
|
@@ -65022,7 +65064,8 @@ function usd(micro) {
|
|
|
65022
65064
|
async function signLeg(leg, privateKey) {
|
|
65023
65065
|
const wallet = new ethers_exports.Wallet(privateKey);
|
|
65024
65066
|
const now = Math.floor(Date.now() / 1e3);
|
|
65025
|
-
const
|
|
65067
|
+
const asked = typeof leg.leg.maxTimeoutSeconds === "number" && leg.leg.maxTimeoutSeconds > 0 ? leg.leg.maxTimeoutSeconds : 600;
|
|
65068
|
+
const window2 = Math.min(asked, MAX_PAYMENT_WINDOW_SECONDS);
|
|
65026
65069
|
const authorization = {
|
|
65027
65070
|
from: wallet.address,
|
|
65028
65071
|
to: leg.payTo,
|
|
@@ -65056,10 +65099,37 @@ async function signLeg(leg, privateKey) {
|
|
|
65056
65099
|
from: wallet.address
|
|
65057
65100
|
};
|
|
65058
65101
|
}
|
|
65102
|
+
function microOfUsd(raw) {
|
|
65103
|
+
const m = /^\s*\$?(\d+)(?:\.(\d{1,6}))?\s*$/.exec(raw);
|
|
65104
|
+
if (!m) throw new Error(`--max-usd takes dollars, like 1 or 0.5 (got "${raw}")`);
|
|
65105
|
+
return BigInt(m[1]) * 1000000n + BigInt((m[2] ?? "").padEnd(6, "0"));
|
|
65106
|
+
}
|
|
65107
|
+
async function consentToPay(args) {
|
|
65108
|
+
const price = usd(args.leg.amountMicro);
|
|
65109
|
+
if (args.maxUsd !== void 0) {
|
|
65110
|
+
let ceiling;
|
|
65111
|
+
try {
|
|
65112
|
+
ceiling = microOfUsd(args.maxUsd);
|
|
65113
|
+
} catch (err) {
|
|
65114
|
+
return { ok: false, code: "bad_input", reason: err.message };
|
|
65115
|
+
}
|
|
65116
|
+
if (args.leg.amountMicro > ceiling) {
|
|
65117
|
+
return { ok: false, code: "over_max", reason: `${args.what} costs ${price} on ${args.leg.network}, over --max-usd ${usd(ceiling)}: nothing was signed` };
|
|
65118
|
+
}
|
|
65119
|
+
return { ok: true };
|
|
65120
|
+
}
|
|
65121
|
+
if (!args.interactive || !args.ask) {
|
|
65122
|
+
return { ok: false, code: "max_usd_required", reason: `${args.what} costs ${price} on ${args.leg.network}: pass --max-usd with the most it may pay. Nothing was signed` };
|
|
65123
|
+
}
|
|
65124
|
+
const answer = (await args.ask(` Pay ${price} USDC on ${args.leg.network} for ${args.what}? [y/N] `)).trim().toLowerCase();
|
|
65125
|
+
if (answer === "y" || answer === "yes") return { ok: true };
|
|
65126
|
+
return { ok: false, code: "declined", reason: "Nothing paid." };
|
|
65127
|
+
}
|
|
65059
65128
|
|
|
65060
65129
|
// src/lib/compute-wire.ts
|
|
65061
65130
|
init_constants();
|
|
65062
65131
|
init_passwords_wire();
|
|
65132
|
+
init_terminal_text();
|
|
65063
65133
|
var trim3 = (v) => v ? v.trim().replace(/\/+$/, "") : "";
|
|
65064
65134
|
function computeOrigin() {
|
|
65065
65135
|
return trim3(process.env.AGENTGATES_COMPUTE_ORIGIN) || "https://api.agentgates.ai";
|
|
@@ -65143,7 +65213,7 @@ async function computeCall(args) {
|
|
|
65143
65213
|
const text = await res.text().catch(() => "");
|
|
65144
65214
|
let parsed = {};
|
|
65145
65215
|
try {
|
|
65146
|
-
parsed = text ? JSON.parse(text) : {};
|
|
65216
|
+
parsed = text ? scrubDeep(JSON.parse(text)) : {};
|
|
65147
65217
|
} catch {
|
|
65148
65218
|
parsed = { error: text.replace(/\s+/g, " ").trim().slice(0, 300) || `HTTP ${res.status}` };
|
|
65149
65219
|
}
|
|
@@ -65328,7 +65398,7 @@ async function readCompose(file) {
|
|
|
65328
65398
|
throw new Error(`could not read the compose file ${file}: ${err.code ?? err.message}`);
|
|
65329
65399
|
}
|
|
65330
65400
|
}
|
|
65331
|
-
function
|
|
65401
|
+
function microOfUsd2(raw) {
|
|
65332
65402
|
const m = /^\s*\$?(\d+)(?:\.(\d{1,6}))?\s*$/.exec(raw);
|
|
65333
65403
|
if (!m) throw new Error(`--max-usd takes dollars, like 1 or 0.5 (got "${raw}")`);
|
|
65334
65404
|
return BigInt(m[1]) * 1000000n + BigInt((m[2] ?? "").padEnd(6, "0"));
|
|
@@ -65445,10 +65515,14 @@ async function payFor(opts, args) {
|
|
|
65445
65515
|
return;
|
|
65446
65516
|
}
|
|
65447
65517
|
const price = usd(leg.amountMicro);
|
|
65518
|
+
if (opts.yes && opts.maxUsd === void 0) {
|
|
65519
|
+
fail(opts, `--yes needs --max-usd, the most this may pay (the price is ${price} on ${leg.network}): nothing was signed`, "max_usd_required", { legs });
|
|
65520
|
+
return;
|
|
65521
|
+
}
|
|
65448
65522
|
if (opts.maxUsd !== void 0) {
|
|
65449
65523
|
let ceiling;
|
|
65450
65524
|
try {
|
|
65451
|
-
ceiling =
|
|
65525
|
+
ceiling = microOfUsd2(opts.maxUsd);
|
|
65452
65526
|
} catch (err) {
|
|
65453
65527
|
fail(opts, err.message, "bad_input");
|
|
65454
65528
|
return;
|
|
@@ -65733,6 +65807,35 @@ function emitMachine(opts, machine, extra) {
|
|
|
65733
65807
|
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
65734
65808
|
init_passwords_wire();
|
|
65735
65809
|
init_constants();
|
|
65810
|
+
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
65811
|
+
async function mayPay(leg, what, opts) {
|
|
65812
|
+
const interactive = !opts.json && process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
65813
|
+
const consent = await consentToPay({
|
|
65814
|
+
leg,
|
|
65815
|
+
maxUsd: opts.maxUsd,
|
|
65816
|
+
interactive,
|
|
65817
|
+
what,
|
|
65818
|
+
ask: async (question) => {
|
|
65819
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
65820
|
+
try {
|
|
65821
|
+
return await rl.question(question);
|
|
65822
|
+
} catch {
|
|
65823
|
+
return "";
|
|
65824
|
+
} finally {
|
|
65825
|
+
rl.close();
|
|
65826
|
+
}
|
|
65827
|
+
}
|
|
65828
|
+
});
|
|
65829
|
+
if (consent.ok) return true;
|
|
65830
|
+
process.stdout.write(
|
|
65831
|
+
opts.json ? `${JSON.stringify({ ok: false, code: consent.code, error: consent.reason })}
|
|
65832
|
+
` : `
|
|
65833
|
+
${consent.code === "declined" ? import_picocolors4.default.dim(consent.reason) : `${import_picocolors4.default.red("\u2717")} ${consent.reason}`}
|
|
65834
|
+
|
|
65835
|
+
`
|
|
65836
|
+
);
|
|
65837
|
+
return false;
|
|
65838
|
+
}
|
|
65736
65839
|
var SITE = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
65737
65840
|
function applyFilters(models, f2) {
|
|
65738
65841
|
let out = models;
|
|
@@ -65940,6 +66043,7 @@ async function inferenceTopUp(amountUsd, opts = {}) {
|
|
|
65940
66043
|
`);
|
|
65941
66044
|
return;
|
|
65942
66045
|
}
|
|
66046
|
+
if (!await mayPay(choice.leg, `a ${usd(BigInt(Math.round(amountUsd * 1e6)))} top-up`, opts)) return;
|
|
65943
66047
|
if (!opts.json) process.stdout.write(`
|
|
65944
66048
|
${import_picocolors4.default.dim(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`)}
|
|
65945
66049
|
`);
|
|
@@ -66018,6 +66122,7 @@ async function inferenceAsk(words7, opts = {}) {
|
|
|
66018
66122
|
);
|
|
66019
66123
|
return;
|
|
66020
66124
|
}
|
|
66125
|
+
if (!await mayPay(choice.leg, "this ask", opts)) return;
|
|
66021
66126
|
if (!opts.json) process.stdout.write(`
|
|
66022
66127
|
${import_picocolors4.default.dim(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`)}
|
|
66023
66128
|
`);
|
|
@@ -66070,6 +66175,7 @@ init_passwords_wire();
|
|
|
66070
66175
|
// src/lib/phone-wire.ts
|
|
66071
66176
|
init_constants();
|
|
66072
66177
|
init_passwords_wire();
|
|
66178
|
+
init_terminal_text();
|
|
66073
66179
|
var INBOUND_ROLES = ["receptionist", "screener", "order-taker", "reservationist", "after-hours", "callback-line", "hotline", "answering-voicemail"];
|
|
66074
66180
|
async function createPersona(wallet, body) {
|
|
66075
66181
|
return expect(await signedFetch(wallet, "POST", lanePath(`/personas`), body), "the persona").persona;
|
|
@@ -66129,7 +66235,7 @@ async function readCallRecording(wallet, phoneId, id2, owner) {
|
|
|
66129
66235
|
const text = await res.text();
|
|
66130
66236
|
let json2 = null;
|
|
66131
66237
|
try {
|
|
66132
|
-
json2 = text ? JSON.parse(text) : null;
|
|
66238
|
+
json2 = text ? scrubDeep(JSON.parse(text)) : null;
|
|
66133
66239
|
} catch {
|
|
66134
66240
|
json2 = null;
|
|
66135
66241
|
}
|
|
@@ -66172,7 +66278,7 @@ function countryCodeFor(countries) {
|
|
|
66172
66278
|
function transcriptLines(raw) {
|
|
66173
66279
|
if (!raw) return [];
|
|
66174
66280
|
try {
|
|
66175
|
-
const parsed = JSON.parse(raw);
|
|
66281
|
+
const parsed = scrubDeep(JSON.parse(raw));
|
|
66176
66282
|
if (!Array.isArray(parsed)) return [];
|
|
66177
66283
|
return parsed.filter((l) => !!l && typeof l === "object" && typeof l.role === "string" && typeof l.text === "string" && l.text.length > 0).map((l) => ({ role: l.role, text: l.text }));
|
|
66178
66284
|
} catch {
|
|
@@ -69497,6 +69603,7 @@ function keyWrapAad(ownerWallet, keyId) {
|
|
|
69497
69603
|
}
|
|
69498
69604
|
|
|
69499
69605
|
// src/lib/mail-key.ts
|
|
69606
|
+
init_terminal_text();
|
|
69500
69607
|
var held = /* @__PURE__ */ new Map();
|
|
69501
69608
|
async function readSealKey(wallet) {
|
|
69502
69609
|
const out = expectOk(await signedFetch(wallet, "GET", lanePath("/seal-key")), "the mail key");
|
|
@@ -69573,9 +69680,9 @@ function openMessage(key, inboxId, m) {
|
|
|
69573
69680
|
id: m.id,
|
|
69574
69681
|
from: m.from ?? "",
|
|
69575
69682
|
to: m.to,
|
|
69576
|
-
subject: m.sealed.subject ? openSubject(key.dataKey, m.sealed.subject, inboxId) : "",
|
|
69577
|
-
text: body.text,
|
|
69578
|
-
html: body.html,
|
|
69683
|
+
subject: m.sealed.subject ? scrubText(openSubject(key.dataKey, m.sealed.subject, inboxId)) : "",
|
|
69684
|
+
text: scrubText(body.text),
|
|
69685
|
+
html: body.html === null ? null : scrubText(body.html),
|
|
69579
69686
|
receivedAt: m.receivedAt ?? ""
|
|
69580
69687
|
};
|
|
69581
69688
|
}
|
|
@@ -69647,6 +69754,7 @@ async function grantedKeyFor(wallet, owner) {
|
|
|
69647
69754
|
}
|
|
69648
69755
|
|
|
69649
69756
|
// src/lib/call-seal.ts
|
|
69757
|
+
init_terminal_text();
|
|
69650
69758
|
var SEALED_RE = /^v1\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
69651
69759
|
function isSealedCallBlob(value) {
|
|
69652
69760
|
return typeof value === "string" && SEALED_RE.test(value);
|
|
@@ -69667,7 +69775,7 @@ function parseSealedTranscript(text) {
|
|
|
69667
69775
|
}
|
|
69668
69776
|
function openCallTranscript(key, blob, callId) {
|
|
69669
69777
|
if (!isSealedCallBlob(blob)) throw new MailSealError("bad_blob", "This call carries no sealed transcript.");
|
|
69670
|
-
return parseSealedTranscript(openText(key.dataKey, blob, callTranscriptAad(callId)));
|
|
69778
|
+
return scrubDeep(parseSealedTranscript(openText(key.dataKey, blob, callTranscriptAad(callId))));
|
|
69671
69779
|
}
|
|
69672
69780
|
function openCallTranscriptQuietly(key, blob, callId) {
|
|
69673
69781
|
if (!key || !isSealedCallBlob(blob)) return null;
|
|
@@ -69756,6 +69864,7 @@ import { writeFileSync } from "node:fs";
|
|
|
69756
69864
|
|
|
69757
69865
|
// src/lib/payphone-wire.ts
|
|
69758
69866
|
init_constants();
|
|
69867
|
+
init_lib2();
|
|
69759
69868
|
init_passwords_wire();
|
|
69760
69869
|
async function wakeTheOperator() {
|
|
69761
69870
|
try {
|
|
@@ -69774,9 +69883,10 @@ function isWaking(status4, error) {
|
|
|
69774
69883
|
var WAKE_WAIT_MS = 24e4;
|
|
69775
69884
|
var WAKE_POLL_MS = 1e4;
|
|
69776
69885
|
var PAYPHONE_MINUTES = [1, 2, 5, 10];
|
|
69777
|
-
async function post(body, payment, timeoutMs) {
|
|
69886
|
+
async function post(body, payment, timeoutMs, payer) {
|
|
69778
69887
|
const headers = { "content-type": "application/json", "user-agent": CLI_USER_AGENT };
|
|
69779
69888
|
if (payment) headers["X-PAYMENT"] = payment;
|
|
69889
|
+
if (payment && payer) headers["X-Wallet-Auth"] = await ownerAuthHeader(payer, "POST", lanePath("/booth"));
|
|
69780
69890
|
const res = await fetch(`${siteOrigin()}${lanePath("/booth")}`, {
|
|
69781
69891
|
method: "POST",
|
|
69782
69892
|
headers,
|
|
@@ -69804,9 +69914,12 @@ async function payphoneCall(args) {
|
|
|
69804
69914
|
const shortfall = need2 && held3 ? `${choice.reason}. The window costs ${need2} and this key holds ${held3}. Send USDC to ${args.address} on base, polygon or arbitrum and it pays for itself` : need2 ? `${choice.reason}. The window costs ${need2}` : choice.reason;
|
|
69805
69915
|
throw new WireError(402, "payphone_unfunded", shortfall, quote.json);
|
|
69806
69916
|
}
|
|
69917
|
+
const consent = await args.consent(choice.leg);
|
|
69918
|
+
if (!consent.ok) throw new WireError(402, consent.code, consent.reason, quote.json);
|
|
69807
69919
|
args.onQuote?.(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`);
|
|
69808
69920
|
const signed2 = await signLeg(choice.leg, args.privateKey);
|
|
69809
|
-
|
|
69921
|
+
const payer = new ethers_exports.Wallet(args.privateKey);
|
|
69922
|
+
let paid = await post(body, signed2.header, 18e4, payer);
|
|
69810
69923
|
if (paid.status >= 400) {
|
|
69811
69924
|
const first = typeof paid.json.error === "string" ? paid.json.error : "";
|
|
69812
69925
|
if (isWaking(paid.status, first)) {
|
|
@@ -69814,7 +69927,7 @@ async function payphoneCall(args) {
|
|
|
69814
69927
|
const deadline = Date.now() + WAKE_WAIT_MS;
|
|
69815
69928
|
while (Date.now() < deadline) {
|
|
69816
69929
|
await new Promise((r) => setTimeout(r, WAKE_POLL_MS));
|
|
69817
|
-
paid = await post(body, signed2.header, 18e4);
|
|
69930
|
+
paid = await post(body, signed2.header, 18e4, payer);
|
|
69818
69931
|
if (paid.status < 400) break;
|
|
69819
69932
|
const again = typeof paid.json.error === "string" ? paid.json.error : "";
|
|
69820
69933
|
if (!isWaking(paid.status, again)) break;
|
|
@@ -69829,10 +69942,10 @@ async function payphoneCall(args) {
|
|
|
69829
69942
|
const call = paid.json.call ?? paid.json.booth ?? paid.json ?? {};
|
|
69830
69943
|
return { call, payment: signed2.header, body, paidMicro: choice.leg.amountMicro, network: choice.leg.network, from: signed2.from };
|
|
69831
69944
|
}
|
|
69832
|
-
async function payphoneRead(payment, asked, what) {
|
|
69945
|
+
async function payphoneRead(payment, asked, what, privateKey) {
|
|
69833
69946
|
const body = { ...asked, kind: "call" };
|
|
69834
69947
|
body[what === "read" ? "read" : "hangup"] = true;
|
|
69835
|
-
const out = await post(body, payment, 6e4);
|
|
69948
|
+
const out = await post(body, payment, 6e4, new ethers_exports.Wallet(privateKey));
|
|
69836
69949
|
if (out.status >= 400) {
|
|
69837
69950
|
const error = typeof out.json.error === "string" ? out.json.error : `the payphone answered ${out.status}`;
|
|
69838
69951
|
throw new WireError(out.status, typeof out.json.code === "string" ? out.json.code : null, error, out.json);
|
|
@@ -69841,6 +69954,7 @@ async function payphoneRead(payment, asked, what) {
|
|
|
69841
69954
|
}
|
|
69842
69955
|
|
|
69843
69956
|
// src/commands/phone.ts
|
|
69957
|
+
import { createInterface as createInterface3 } from "node:readline/promises";
|
|
69844
69958
|
var SITE2 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
69845
69959
|
var jsonMode2 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
69846
69960
|
function emit2(opts, data4, human) {
|
|
@@ -70045,7 +70159,24 @@ async function walkUpToThePayphone(opts, args) {
|
|
|
70045
70159
|
onQuote: (note2) => {
|
|
70046
70160
|
if (!jsonMode2(opts)) process.stderr.write(` ${import_picocolors5.default.dim(note2)}
|
|
70047
70161
|
`);
|
|
70048
|
-
}
|
|
70162
|
+
},
|
|
70163
|
+
// The caller's --max-usd, or a person's yes at the terminal (M7).
|
|
70164
|
+
consent: (leg) => consentToPay({
|
|
70165
|
+
leg,
|
|
70166
|
+
maxUsd: opts.maxUsd,
|
|
70167
|
+
interactive: !jsonMode2(opts) && process.stdin.isTTY === true && process.stdout.isTTY === true,
|
|
70168
|
+
what: `a ${window2}-minute payphone call`,
|
|
70169
|
+
ask: async (question) => {
|
|
70170
|
+
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
70171
|
+
try {
|
|
70172
|
+
return await rl.question(question);
|
|
70173
|
+
} catch {
|
|
70174
|
+
return "";
|
|
70175
|
+
} finally {
|
|
70176
|
+
rl.close();
|
|
70177
|
+
}
|
|
70178
|
+
}
|
|
70179
|
+
})
|
|
70049
70180
|
});
|
|
70050
70181
|
const placed = walk.call;
|
|
70051
70182
|
const paid = usd(walk.paidMicro);
|
|
@@ -70070,7 +70201,7 @@ async function walkUpToThePayphone(opts, args) {
|
|
|
70070
70201
|
if (row?.status && TERMINAL.has(row.status)) break;
|
|
70071
70202
|
await new Promise((r) => setTimeout(r, 4e3));
|
|
70072
70203
|
try {
|
|
70073
|
-
row = await payphoneRead(walk.payment, walk.body, "read");
|
|
70204
|
+
row = await payphoneRead(walk.payment, walk.body, "read", args.privateKey);
|
|
70074
70205
|
} catch {
|
|
70075
70206
|
break;
|
|
70076
70207
|
}
|
|
@@ -73315,7 +73446,7 @@ async function onboard(opts = {}) {
|
|
|
73315
73446
|
if (stale) put(stale);
|
|
73316
73447
|
const order = menuOrder(opts.lane, !!account, latestSeen !== null).filter((k) => existing ? k !== "wallet" : true);
|
|
73317
73448
|
printMenu(put, order, true);
|
|
73318
|
-
const rl =
|
|
73449
|
+
const rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
73319
73450
|
const exitDefault = String(order.indexOf("poke") + 1);
|
|
73320
73451
|
let first = true;
|
|
73321
73452
|
let plain = put;
|
|
@@ -73473,7 +73604,7 @@ init_passwords_wire();
|
|
|
73473
73604
|
init_passwords_seal();
|
|
73474
73605
|
|
|
73475
73606
|
// src/lib/mcp-stdio.ts
|
|
73476
|
-
import { createInterface as
|
|
73607
|
+
import { createInterface as createInterface5 } from "node:readline";
|
|
73477
73608
|
var MCP_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
73478
73609
|
var McpToolError = class extends Error {
|
|
73479
73610
|
constructor(message, detail = {}) {
|
|
@@ -73586,7 +73717,7 @@ async function serve(tools, info, { input = process.stdin, output: output2 = pro
|
|
|
73586
73717
|
`);
|
|
73587
73718
|
};
|
|
73588
73719
|
const inFlight = /* @__PURE__ */ new Set();
|
|
73589
|
-
const lines =
|
|
73720
|
+
const lines = createInterface5({ input, crlfDelay: Infinity });
|
|
73590
73721
|
for await (const line2 of lines) {
|
|
73591
73722
|
const parsed = parseLine(line2);
|
|
73592
73723
|
if (!parsed) continue;
|
|
@@ -74840,7 +74971,7 @@ async function filesRm(target, opts) {
|
|
|
74840
74971
|
|
|
74841
74972
|
// src/commands/card.ts
|
|
74842
74973
|
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
74843
|
-
import { createInterface as
|
|
74974
|
+
import { createInterface as createInterface6 } from "node:readline/promises";
|
|
74844
74975
|
|
|
74845
74976
|
// src/lib/memory-address.ts
|
|
74846
74977
|
var ADDRESS_FOLDER = "profile";
|
|
@@ -75382,7 +75513,7 @@ var QUESTIONS = [
|
|
|
75382
75513
|
{ field: "zip", ask: "ZIP code", abroad: "Postal code" }
|
|
75383
75514
|
];
|
|
75384
75515
|
async function askAddress() {
|
|
75385
|
-
const rl =
|
|
75516
|
+
const rl = createInterface6({ input: process.stdin, output: process.stdout });
|
|
75386
75517
|
const answers = { country: "US", line1: "", line2: "", city: "", region: "", zip: "" };
|
|
75387
75518
|
try {
|
|
75388
75519
|
process.stdout.write(`
|
|
@@ -76184,6 +76315,7 @@ init_passwords_wire();
|
|
|
76184
76315
|
init_lib2();
|
|
76185
76316
|
init_constants();
|
|
76186
76317
|
init_passwords_wire();
|
|
76318
|
+
init_terminal_text();
|
|
76187
76319
|
var path5 = (relative = "") => lanePath(`intents${relative}`);
|
|
76188
76320
|
function expect3(answer, what) {
|
|
76189
76321
|
if (answer.status >= 200 && answer.status < 300 && answer.body !== null) return answer.body;
|
|
@@ -76245,7 +76377,7 @@ async function readListingPublic(id2) {
|
|
|
76245
76377
|
const text = await res.text();
|
|
76246
76378
|
let body = null;
|
|
76247
76379
|
try {
|
|
76248
|
-
body = JSON.parse(text);
|
|
76380
|
+
body = scrubDeep(JSON.parse(text));
|
|
76249
76381
|
} catch {
|
|
76250
76382
|
}
|
|
76251
76383
|
return expect3({ status: res.status, body, text }, `GET /listings/${id2}`);
|
|
@@ -76256,7 +76388,7 @@ async function lookupListingByPhone(phone2) {
|
|
|
76256
76388
|
const text = await res.text();
|
|
76257
76389
|
let body = null;
|
|
76258
76390
|
try {
|
|
76259
|
-
body = JSON.parse(text);
|
|
76391
|
+
body = scrubDeep(JSON.parse(text));
|
|
76260
76392
|
} catch {
|
|
76261
76393
|
}
|
|
76262
76394
|
return expect3({ status: res.status, body, text }, "GET /listings?phone").listing;
|
|
@@ -76359,6 +76491,27 @@ async function signEscrow(wallet, group) {
|
|
|
76359
76491
|
});
|
|
76360
76492
|
return { chainId: group.chainId, payment: encodePayment(group.network, signature, authorization) };
|
|
76361
76493
|
}
|
|
76494
|
+
function releaseWordRefusal(toSign, leg, nowSeconds = Math.floor(Date.now() / 1e3)) {
|
|
76495
|
+
if (!toSign) return null;
|
|
76496
|
+
const fail11 = (why) => `refused to sign the release word: ${why}`;
|
|
76497
|
+
const d = toSign.domain;
|
|
76498
|
+
if (!d || d.name !== "Cov3nantIntent" || d.version !== "1") return fail11("it is not the intents escrow's domain");
|
|
76499
|
+
if (Object.keys(d).sort().join(",") !== "chainId,name,verifyingContract,version") return fail11("the domain carries fields the escrow's does not");
|
|
76500
|
+
const types = toSign.types;
|
|
76501
|
+
if (!types || Object.keys(types).join(",") !== "FunderRelease") return fail11("it is not a FunderRelease");
|
|
76502
|
+
const fields = types.FunderRelease ?? [];
|
|
76503
|
+
if (fields.map((f2) => `${f2.name}:${f2.type}`).join(",") !== "legIndex:uint256,nonce:uint256,deadline:uint256") return fail11("its fields are not the escrow's");
|
|
76504
|
+
const m = toSign.message;
|
|
76505
|
+
if (!m || Object.keys(m).sort().join(",") !== "deadline,legIndex,nonce") return fail11("its message carries fields the escrow's does not");
|
|
76506
|
+
if (![m.legIndex, m.nonce, m.deadline].every((v) => Number.isSafeInteger(v) && v >= 0)) return fail11("its numbers are not whole and non-negative");
|
|
76507
|
+
if (!leg || !leg.escrowAddress || leg.legIndex === null) return fail11("this leg is not held in escrow");
|
|
76508
|
+
if (typeof d.verifyingContract !== "string" || d.verifyingContract.toLowerCase() !== leg.escrowAddress.toLowerCase()) return fail11("it names another deal than this leg's");
|
|
76509
|
+
if (d.chainId !== leg.chainId) return fail11("it names another chain than this leg's");
|
|
76510
|
+
if (m.legIndex !== leg.legIndex) return fail11("it names another leg");
|
|
76511
|
+
const deadline = m.deadline;
|
|
76512
|
+
if (deadline <= nowSeconds || deadline > nowSeconds + 7200) return fail11("its deadline is not within the next two hours");
|
|
76513
|
+
return null;
|
|
76514
|
+
}
|
|
76362
76515
|
async function wordOnLeg(wallet, askId, offerId, happened, toSign) {
|
|
76363
76516
|
let signed2 = {};
|
|
76364
76517
|
if (happened && toSign) {
|
|
@@ -76642,6 +76795,11 @@ async function intentsWord(id2, opts) {
|
|
|
76642
76795
|
if (happened && said?.transaction) {
|
|
76643
76796
|
return refuse5(opts, "This leg is on Solana: its word is signed by a Solana wallet, which this key is not.", "svm_word");
|
|
76644
76797
|
}
|
|
76798
|
+
if (happened && said?.word) {
|
|
76799
|
+
const leg = detail.settlements.find((st) => st.offerId === opts.offer);
|
|
76800
|
+
const refusal = releaseWordRefusal(said.word, leg ? { chainId: leg.chainId, escrowAddress: leg.escrowAddress, legIndex: leg.legIndex } : void 0);
|
|
76801
|
+
if (refusal) return refuse5(opts, refusal, "word_refused");
|
|
76802
|
+
}
|
|
76645
76803
|
const settlement = await wordOnLeg(wallet, id2, opts.offer, happened, said?.word);
|
|
76646
76804
|
emit9(opts, { ok: true, settlement }, () => {
|
|
76647
76805
|
process.stdout.write(`
|
|
@@ -77059,6 +77217,7 @@ async function intentsNoShow(askId, opts) {
|
|
|
77059
77217
|
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
77060
77218
|
import { createHash as createHash6, randomBytes as randomBytes9 } from "node:crypto";
|
|
77061
77219
|
init_passwords_wire();
|
|
77220
|
+
init_terminal_text();
|
|
77062
77221
|
function emit10(opts, data4, human) {
|
|
77063
77222
|
if (opts.json || !process.stdout.isTTY) {
|
|
77064
77223
|
process.stdout.write(`${JSON.stringify(data4)}
|
|
@@ -77396,7 +77555,7 @@ function askOf(dataKey, owner, ask) {
|
|
|
77396
77555
|
const aad = `AGENTGATES-CONVERSATION-v1|turn|${normalizeOwner2(owner)}|${ask.conversationId}|${ask.seq}|${ask.role}${ask.author ? `|${ask.author}|${ask.channel ?? ""}` : ""}`;
|
|
77397
77556
|
const text = openText(dataKey, ask.ciphertext, aad);
|
|
77398
77557
|
if (ask.author === "card") {
|
|
77399
|
-
const words7 = JSON.parse(text).words ?? "";
|
|
77558
|
+
const words7 = scrubDeep(JSON.parse(text)).words ?? "";
|
|
77400
77559
|
return words7 ? `Fix: ${words7.split("\n")[0].trim()}` : null;
|
|
77401
77560
|
}
|
|
77402
77561
|
const m = /^Asked for a change on site [A-Za-z0-9_-]{22}: ([\s\S]*)$/.exec(text.trim());
|
|
@@ -80286,7 +80445,8 @@ async function orderFood(items, opts) {
|
|
|
80286
80445
|
if (!jsonMode8) {
|
|
80287
80446
|
process.stderr.write(
|
|
80288
80447
|
import_picocolors32.default.yellow(
|
|
80289
|
-
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
80448
|
+
agentCard.allowed ? `This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
80449
|
+
` : `You have not allowed this login to pay for food with your saved card, so it needs you. Allow "Pay for food" on this agent's page in your Agentgates wallet to let it pay the next ones.
|
|
80290
80450
|
`
|
|
80291
80451
|
)
|
|
80292
80452
|
);
|
|
@@ -80344,6 +80504,7 @@ function readAgentCard(res) {
|
|
|
80344
80504
|
last4: c.last4,
|
|
80345
80505
|
max_per_order_cents: typeof c.max_per_order_cents === "number" ? c.max_per_order_cents : 0,
|
|
80346
80506
|
max_per_day_cents: typeof c.max_per_day_cents === "number" ? c.max_per_day_cents : 0,
|
|
80507
|
+
allowed: c.allowed !== false,
|
|
80347
80508
|
will_attempt: c.will_attempt === true
|
|
80348
80509
|
};
|
|
80349
80510
|
}
|
|
@@ -81118,6 +81279,7 @@ init_constants();
|
|
|
81118
81279
|
// src/lib/trade-sol.ts
|
|
81119
81280
|
var import_web3 = __toESM(require_index_cjs(), 1);
|
|
81120
81281
|
init_constants();
|
|
81282
|
+
init_terminal_text();
|
|
81121
81283
|
import { promises as fs9 } from "node:fs";
|
|
81122
81284
|
import * as path6 from "node:path";
|
|
81123
81285
|
import * as os3 from "node:os";
|
|
@@ -81184,7 +81346,7 @@ async function relayPost(pathname, body) {
|
|
|
81184
81346
|
const text = await res.text();
|
|
81185
81347
|
let parsed;
|
|
81186
81348
|
try {
|
|
81187
|
-
parsed = JSON.parse(text);
|
|
81349
|
+
parsed = scrubDeep(JSON.parse(text));
|
|
81188
81350
|
} catch {
|
|
81189
81351
|
parsed = { error: text.slice(0, 200) };
|
|
81190
81352
|
}
|
|
@@ -81200,7 +81362,7 @@ async function relayGet(pathname) {
|
|
|
81200
81362
|
const text = await res.text();
|
|
81201
81363
|
let parsed;
|
|
81202
81364
|
try {
|
|
81203
|
-
parsed = JSON.parse(text);
|
|
81365
|
+
parsed = scrubDeep(JSON.parse(text));
|
|
81204
81366
|
} catch {
|
|
81205
81367
|
parsed = { error: text.slice(0, 200) };
|
|
81206
81368
|
}
|
|
@@ -82482,6 +82644,7 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
82482
82644
|
}
|
|
82483
82645
|
|
|
82484
82646
|
// src/main.ts
|
|
82647
|
+
installServerTextScrub();
|
|
82485
82648
|
var { version: VERSION } = JSON.parse(readFileSync3(new URL("../package.json", import.meta.url), "utf8"));
|
|
82486
82649
|
var program2 = new Command();
|
|
82487
82650
|
program2.name("agentgates").description(
|
|
@@ -83012,10 +83175,10 @@ inference.command("key").description("Mint a key that buys turns without the wor
|
|
|
83012
83175
|
}
|
|
83013
83176
|
await inferenceKeyCreate(opts);
|
|
83014
83177
|
});
|
|
83015
|
-
inference.command("topup").argument("<usd>", "dollars to add to the account balance", (v) => Number(v)).description("Buy prepaid balance with one x402 payment from this machine's key. A streamed turn can only be served from a balance.").option("--json", "machine-readable output").action(async (usd6, opts) => {
|
|
83178
|
+
inference.command("topup").argument("<usd>", "dollars to add to the account balance", (v) => Number(v)).description("Buy prepaid balance with one x402 payment from this machine's key. A streamed turn can only be served from a balance.").option("--max-usd <dollars>", "the most this top-up may cost; without it, a person confirms at the terminal").option("--json", "machine-readable output").action(async (usd6, opts) => {
|
|
83016
83179
|
await inferenceTopUp(usd6, opts);
|
|
83017
83180
|
});
|
|
83018
|
-
inference.command("ask").argument("[words...]", "what to ask, in words").description("One paid ask, signed by this machine's key: the prepaid balance if it covers it, else one x402 payment.").option("--model <id>", "a catalog id (agentgates inference models)").option("--max-tokens <n>", "output ceiling", (v) => parseInt(v, 10)).option("--json", "machine-readable output").action(async (words7, opts) => {
|
|
83181
|
+
inference.command("ask").argument("[words...]", "what to ask, in words").description("One paid ask, signed by this machine's key: the prepaid balance if it covers it, else one x402 payment.").option("--model <id>", "a catalog id (agentgates inference models)").option("--max-tokens <n>", "output ceiling", (v) => parseInt(v, 10)).option("--max-usd <dollars>", "the most an x402-paid ask may cost; without it, a person confirms at the terminal").option("--json", "machine-readable output").action(async (words7, opts) => {
|
|
83019
83182
|
await inferenceAsk(words7, opts);
|
|
83020
83183
|
});
|
|
83021
83184
|
var phone = program2.command("phone").description("Phone numbers on a plan, texts and calls metered, and a walk-up payphone, USDC over x402");
|
|
@@ -83023,7 +83186,7 @@ phone.command("pricing").description("Number plans, per-unit usage and the payph
|
|
|
83023
83186
|
await phonePricing(opts);
|
|
83024
83187
|
});
|
|
83025
83188
|
var callDescription = "Put the AI operator on a real phone call: the number, then what to get done, in words. On your number, or from the house number with none; metered from your balance";
|
|
83026
|
-
var registerCall = (parent, name) => parent.command(`${name} <number> [task...]`).description(callDescription).option("--from <phone id or number>", "one of your numbers (default: your first; the house number with none)").option("--house", "force the house number").option("--greeting <line>", "spoken the instant the call connects (up to 300 chars)").option("--voice <name>", "one of the catalog's operator voices").option("--brain <ours|yours>", "who runs the call: our brain (default) or yours over --webhook").option("--webhook <url>", "your brain's door when --brain yours: the transcript is POSTed there, the reply is the next sentence").option("--minutes <n>", "the window this call holds and is cut off at (default: the catalog's operator.minutes)").option("--wait [seconds]", "wait for the call to end and print the transcript and the outcome").option("--payphone", "walk up and pay for the call in USDC: no account, no balance, no sign-in. Used on its own when the balance is empty").option("--json", "machine-readable output").action(async (number2, task, opts) => {
|
|
83189
|
+
var registerCall = (parent, name) => parent.command(`${name} <number> [task...]`).description(callDescription).option("--from <phone id or number>", "one of your numbers (default: your first; the house number with none)").option("--house", "force the house number").option("--greeting <line>", "spoken the instant the call connects (up to 300 chars)").option("--voice <name>", "one of the catalog's operator voices").option("--brain <ours|yours>", "who runs the call: our brain (default) or yours over --webhook").option("--webhook <url>", "your brain's door when --brain yours: the transcript is POSTed there, the reply is the next sentence").option("--minutes <n>", "the window this call holds and is cut off at (default: the catalog's operator.minutes)").option("--wait [seconds]", "wait for the call to end and print the transcript and the outcome").option("--payphone", "walk up and pay for the call in USDC: no account, no balance, no sign-in. Used on its own when the balance is empty").option("--max-usd <dollars>", "the most the payphone may charge; without it, a person confirms at the terminal").option("--json", "machine-readable output").action(async (number2, task, opts) => {
|
|
83027
83190
|
await phoneCall(number2, task ?? [], opts);
|
|
83028
83191
|
});
|
|
83029
83192
|
var registerCalls = (parent, name) => parent.command(`${name} [id]`).description("Your recent calls, or one call with its transcript and outcome (--wait until it ends)").option("--from <phone id or number>", "the number whose calls to read (default: your first; the house calls with none)").option("--house", "the house calls").option("--wait [seconds]", "wait for the call to end").option("--owner <address>", "another account's calls, under a grant it gave this key (the owner runs agentgates passwords allow --agent <you>)").option("--audio <file.wav>", "one call: save its recording (a sealed one is opened with your key and written as PCM16)").option("--did <yes|partly|no>", "one call: did it do what you asked (stored beside the call)").option("--json", "machine-readable output").action(async (id2, opts) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentgates/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"description": "Wallet operations for AI agents and humans",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crypto",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"homepage": "https://agentgates.ai",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/
|
|
21
|
+
"url": "git+https://github.com/agentgates-ai/agentgates.git"
|
|
22
22
|
},
|
|
23
23
|
"bugs": {
|
|
24
|
-
"url": "https://github.com/
|
|
24
|
+
"url": "https://github.com/agentgates-ai/agentgates/issues",
|
|
25
25
|
"email": "support@agentgates.ai"
|
|
26
26
|
},
|
|
27
27
|
"author": "Agentgates",
|