@agentgates/cli 0.84.0 → 0.86.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 +237 -55
- package/package.json +1 -1
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.86.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",
|
|
@@ -64323,7 +64362,7 @@ async function* streamSse(url, opts = {}) {
|
|
|
64323
64362
|
let parsed = null;
|
|
64324
64363
|
if (text) {
|
|
64325
64364
|
try {
|
|
64326
|
-
parsed = JSON.parse(text);
|
|
64365
|
+
parsed = scrubDeep(JSON.parse(text));
|
|
64327
64366
|
} catch {
|
|
64328
64367
|
}
|
|
64329
64368
|
}
|
|
@@ -64357,7 +64396,7 @@ async function* streamSse(url, opts = {}) {
|
|
|
64357
64396
|
const payload = dataLines.join("\n");
|
|
64358
64397
|
dataLines = [];
|
|
64359
64398
|
try {
|
|
64360
|
-
yield JSON.parse(payload);
|
|
64399
|
+
yield scrubDeep(JSON.parse(payload));
|
|
64361
64400
|
} catch {
|
|
64362
64401
|
}
|
|
64363
64402
|
}
|
|
@@ -64602,7 +64641,7 @@ function shortAddress(addr) {
|
|
|
64602
64641
|
|
|
64603
64642
|
// src/commands/onboard.ts
|
|
64604
64643
|
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
64605
|
-
import { createInterface as
|
|
64644
|
+
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
64606
64645
|
init_constants();
|
|
64607
64646
|
|
|
64608
64647
|
// src/lib/water.ts
|
|
@@ -64925,10 +64964,11 @@ async function requirePasswordsKey() {
|
|
|
64925
64964
|
// src/lib/x402-pay.ts
|
|
64926
64965
|
init_lib2();
|
|
64927
64966
|
var EVM_CHAINS = {
|
|
64928
|
-
base: { chainId: 8453, rpcs: ["https://mainnet.base.org", "https://base.drpc.org"] },
|
|
64929
|
-
polygon: { chainId: 137, rpcs: ["https://polygon.drpc.org", "https://1rpc.io/matic"] },
|
|
64930
|
-
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"] }
|
|
64931
64970
|
};
|
|
64971
|
+
var MAX_PAYMENT_WINDOW_SECONDS = 900;
|
|
64932
64972
|
function evmLegs(body) {
|
|
64933
64973
|
const out = [];
|
|
64934
64974
|
for (const leg of body.accepts ?? []) {
|
|
@@ -64937,6 +64977,7 @@ function evmLegs(body) {
|
|
|
64937
64977
|
const chain = EVM_CHAINS[network];
|
|
64938
64978
|
if (!chain) continue;
|
|
64939
64979
|
if (!leg.payTo || !leg.asset || !leg.maxAmountRequired) continue;
|
|
64980
|
+
if (leg.asset.toLowerCase() !== chain.usdc.toLowerCase()) continue;
|
|
64940
64981
|
let amountMicro;
|
|
64941
64982
|
try {
|
|
64942
64983
|
amountMicro = BigInt(leg.maxAmountRequired);
|
|
@@ -64981,7 +65022,7 @@ async function chooseLeg(body, address) {
|
|
|
64981
65022
|
const offered = (body.accepts ?? []).map((a) => a.network ?? "?").join(", ") || "none";
|
|
64982
65023
|
return {
|
|
64983
65024
|
ok: false,
|
|
64984
|
-
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`,
|
|
64985
65026
|
needMicro: null,
|
|
64986
65027
|
bestHeldMicro: null
|
|
64987
65028
|
};
|
|
@@ -65023,7 +65064,8 @@ function usd(micro) {
|
|
|
65023
65064
|
async function signLeg(leg, privateKey) {
|
|
65024
65065
|
const wallet = new ethers_exports.Wallet(privateKey);
|
|
65025
65066
|
const now = Math.floor(Date.now() / 1e3);
|
|
65026
|
-
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);
|
|
65027
65069
|
const authorization = {
|
|
65028
65070
|
from: wallet.address,
|
|
65029
65071
|
to: leg.payTo,
|
|
@@ -65057,10 +65099,37 @@ async function signLeg(leg, privateKey) {
|
|
|
65057
65099
|
from: wallet.address
|
|
65058
65100
|
};
|
|
65059
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
|
+
}
|
|
65060
65128
|
|
|
65061
65129
|
// src/lib/compute-wire.ts
|
|
65062
65130
|
init_constants();
|
|
65063
65131
|
init_passwords_wire();
|
|
65132
|
+
init_terminal_text();
|
|
65064
65133
|
var trim3 = (v) => v ? v.trim().replace(/\/+$/, "") : "";
|
|
65065
65134
|
function computeOrigin() {
|
|
65066
65135
|
return trim3(process.env.AGENTGATES_COMPUTE_ORIGIN) || "https://api.agentgates.ai";
|
|
@@ -65093,17 +65162,32 @@ function parseEnvPairs(pairs) {
|
|
|
65093
65162
|
}
|
|
65094
65163
|
return out;
|
|
65095
65164
|
}
|
|
65165
|
+
var QUARTER_HOUR_MINUTES = [15, 30, 45];
|
|
65166
|
+
function quarterMinutes(value) {
|
|
65167
|
+
const n2 = typeof value === "number" ? value : Number(String(value ?? "").trim());
|
|
65168
|
+
if (!QUARTER_HOUR_MINUTES.includes(n2)) {
|
|
65169
|
+
throw new Error("--minutes takes 15, 30 or 45; for an hour or more use --hours");
|
|
65170
|
+
}
|
|
65171
|
+
return n2;
|
|
65172
|
+
}
|
|
65173
|
+
function timeBody(input) {
|
|
65174
|
+
if (input.minutes !== void 0) {
|
|
65175
|
+
if (input.hours !== void 0) throw new Error("send --hours or --minutes, not both");
|
|
65176
|
+
return { minutes: quarterMinutes(input.minutes) };
|
|
65177
|
+
}
|
|
65178
|
+
return { hours: positiveInt(input.hours, "--hours") };
|
|
65179
|
+
}
|
|
65096
65180
|
function createBody(input) {
|
|
65097
65181
|
const plan = (input.plan ?? "").trim();
|
|
65098
65182
|
if (!plan) throw new Error("say which plan: --plan <id> (agentgates compute plans lists them)");
|
|
65099
|
-
const
|
|
65183
|
+
const time = timeBody(input);
|
|
65100
65184
|
const image = input.image?.trim();
|
|
65101
65185
|
const compose = input.compose;
|
|
65102
65186
|
if (image && compose !== void 0) throw new Error("send --image or --compose, not both");
|
|
65103
65187
|
if (!image && (compose === void 0 || !compose.trim())) {
|
|
65104
65188
|
throw new Error("say what runs: --image <image> (one container) or --compose <file> (a docker-compose.yml)");
|
|
65105
65189
|
}
|
|
65106
|
-
const body = { plan,
|
|
65190
|
+
const body = { plan, ...time };
|
|
65107
65191
|
if (image) {
|
|
65108
65192
|
body.image = image;
|
|
65109
65193
|
if (input.port !== void 0) {
|
|
@@ -65144,7 +65228,7 @@ async function computeCall(args) {
|
|
|
65144
65228
|
const text = await res.text().catch(() => "");
|
|
65145
65229
|
let parsed = {};
|
|
65146
65230
|
try {
|
|
65147
|
-
parsed = text ? JSON.parse(text) : {};
|
|
65231
|
+
parsed = text ? scrubDeep(JSON.parse(text)) : {};
|
|
65148
65232
|
} catch {
|
|
65149
65233
|
parsed = { error: text.replace(/\s+/g, " ").trim().slice(0, 300) || `HTTP ${res.status}` };
|
|
65150
65234
|
}
|
|
@@ -65307,6 +65391,9 @@ async function computePlans(opts) {
|
|
|
65307
65391
|
`);
|
|
65308
65392
|
const ladder = p.pricing.map((r) => `${r.hoursPerPayment}h ${money(r.totalUsd)}`).join(" ");
|
|
65309
65393
|
if (ladder) say(` ${import_picocolors3.default.dim(ladder)}
|
|
65394
|
+
`);
|
|
65395
|
+
const quarter = (p.minutesPricing ?? []).filter((r) => r.totalUsd).map((r) => `${r.minutesPerPayment}m ${money(String(r.totalUsd))}`).join(" ");
|
|
65396
|
+
if (quarter) say(` ${import_picocolors3.default.dim(quarter)}
|
|
65310
65397
|
`);
|
|
65311
65398
|
say("\n");
|
|
65312
65399
|
}
|
|
@@ -65314,8 +65401,10 @@ async function computePlans(opts) {
|
|
|
65314
65401
|
if (nets.length) say(` ${import_picocolors3.default.dim(`USDC on ${nets.join(", ")}`)}
|
|
65315
65402
|
`);
|
|
65316
65403
|
say(` ${import_picocolors3.default.dim("rent one: agentgates compute buy --plan <id> --hours 1 --image <image> (--quote prices it, signs nothing)")}
|
|
65317
|
-
|
|
65318
65404
|
`);
|
|
65405
|
+
if (body.quarterHours) say(` ${import_picocolors3.default.dim("or by the quarter-hour: --minutes 15 (30, 45) in place of --hours")}
|
|
65406
|
+
`);
|
|
65407
|
+
say("\n");
|
|
65319
65408
|
}
|
|
65320
65409
|
async function readCompose(file) {
|
|
65321
65410
|
if (file === "-") {
|
|
@@ -65329,7 +65418,7 @@ async function readCompose(file) {
|
|
|
65329
65418
|
throw new Error(`could not read the compose file ${file}: ${err.code ?? err.message}`);
|
|
65330
65419
|
}
|
|
65331
65420
|
}
|
|
65332
|
-
function
|
|
65421
|
+
function microOfUsd2(raw) {
|
|
65333
65422
|
const m = /^\s*\$?(\d+)(?:\.(\d{1,6}))?\s*$/.exec(raw);
|
|
65334
65423
|
if (!m) throw new Error(`--max-usd takes dollars, like 1 or 0.5 (got "${raw}")`);
|
|
65335
65424
|
return BigInt(m[1]) * 1000000n + BigInt((m[2] ?? "").padEnd(6, "0"));
|
|
@@ -65357,6 +65446,7 @@ async function computeBuy(opts) {
|
|
|
65357
65446
|
body = createBody({
|
|
65358
65447
|
plan: opts.plan,
|
|
65359
65448
|
hours: opts.hours,
|
|
65449
|
+
minutes: opts.minutes,
|
|
65360
65450
|
image: opts.image,
|
|
65361
65451
|
port: opts.port,
|
|
65362
65452
|
compose,
|
|
@@ -65367,20 +65457,22 @@ async function computeBuy(opts) {
|
|
|
65367
65457
|
fail(opts, err.message, "bad_input");
|
|
65368
65458
|
return;
|
|
65369
65459
|
}
|
|
65370
|
-
const
|
|
65460
|
+
const time = body.minutes !== void 0 ? `${String(body.minutes)} min` : `${String(body.hours)} h`;
|
|
65461
|
+
const what = `${String(body.plan)}, ${time}, ${typeof body.image === "string" ? body.image : "your compose"}`;
|
|
65371
65462
|
await payFor(opts, { url: `${computeOrigin()}${DEPLOYMENTS_PATH}`, body, what, action: "buy" });
|
|
65372
65463
|
}
|
|
65373
65464
|
async function computeRenew(id2, opts) {
|
|
65374
65465
|
let path8;
|
|
65375
|
-
let
|
|
65466
|
+
let time;
|
|
65376
65467
|
try {
|
|
65377
65468
|
path8 = deploymentPath(id2, "renew");
|
|
65378
|
-
|
|
65469
|
+
time = timeBody({ hours: opts.hours, minutes: opts.minutes });
|
|
65379
65470
|
} catch (err) {
|
|
65380
65471
|
fail(opts, err.message, "bad_input");
|
|
65381
65472
|
return;
|
|
65382
65473
|
}
|
|
65383
|
-
|
|
65474
|
+
const what = "minutes" in time ? `${time.minutes} more min on ${id2}` : `${time.hours} more h on ${id2}`;
|
|
65475
|
+
await payFor(opts, { url: `${computeOrigin()}${path8}`, body: time, what, action: "renew" });
|
|
65384
65476
|
}
|
|
65385
65477
|
async function payFor(opts, args) {
|
|
65386
65478
|
let quote;
|
|
@@ -65446,10 +65538,14 @@ async function payFor(opts, args) {
|
|
|
65446
65538
|
return;
|
|
65447
65539
|
}
|
|
65448
65540
|
const price = usd(leg.amountMicro);
|
|
65541
|
+
if (opts.yes && opts.maxUsd === void 0) {
|
|
65542
|
+
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 });
|
|
65543
|
+
return;
|
|
65544
|
+
}
|
|
65449
65545
|
if (opts.maxUsd !== void 0) {
|
|
65450
65546
|
let ceiling;
|
|
65451
65547
|
try {
|
|
65452
|
-
ceiling =
|
|
65548
|
+
ceiling = microOfUsd2(opts.maxUsd);
|
|
65453
65549
|
} catch (err) {
|
|
65454
65550
|
fail(opts, err.message, "bad_input");
|
|
65455
65551
|
return;
|
|
@@ -65734,6 +65830,35 @@ function emitMachine(opts, machine, extra) {
|
|
|
65734
65830
|
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
65735
65831
|
init_passwords_wire();
|
|
65736
65832
|
init_constants();
|
|
65833
|
+
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
65834
|
+
async function mayPay(leg, what, opts) {
|
|
65835
|
+
const interactive = !opts.json && process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
65836
|
+
const consent = await consentToPay({
|
|
65837
|
+
leg,
|
|
65838
|
+
maxUsd: opts.maxUsd,
|
|
65839
|
+
interactive,
|
|
65840
|
+
what,
|
|
65841
|
+
ask: async (question) => {
|
|
65842
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
65843
|
+
try {
|
|
65844
|
+
return await rl.question(question);
|
|
65845
|
+
} catch {
|
|
65846
|
+
return "";
|
|
65847
|
+
} finally {
|
|
65848
|
+
rl.close();
|
|
65849
|
+
}
|
|
65850
|
+
}
|
|
65851
|
+
});
|
|
65852
|
+
if (consent.ok) return true;
|
|
65853
|
+
process.stdout.write(
|
|
65854
|
+
opts.json ? `${JSON.stringify({ ok: false, code: consent.code, error: consent.reason })}
|
|
65855
|
+
` : `
|
|
65856
|
+
${consent.code === "declined" ? import_picocolors4.default.dim(consent.reason) : `${import_picocolors4.default.red("\u2717")} ${consent.reason}`}
|
|
65857
|
+
|
|
65858
|
+
`
|
|
65859
|
+
);
|
|
65860
|
+
return false;
|
|
65861
|
+
}
|
|
65737
65862
|
var SITE = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
65738
65863
|
function applyFilters(models, f2) {
|
|
65739
65864
|
let out = models;
|
|
@@ -65941,6 +66066,7 @@ async function inferenceTopUp(amountUsd, opts = {}) {
|
|
|
65941
66066
|
`);
|
|
65942
66067
|
return;
|
|
65943
66068
|
}
|
|
66069
|
+
if (!await mayPay(choice.leg, `a ${usd(BigInt(Math.round(amountUsd * 1e6)))} top-up`, opts)) return;
|
|
65944
66070
|
if (!opts.json) process.stdout.write(`
|
|
65945
66071
|
${import_picocolors4.default.dim(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`)}
|
|
65946
66072
|
`);
|
|
@@ -66019,6 +66145,7 @@ async function inferenceAsk(words7, opts = {}) {
|
|
|
66019
66145
|
);
|
|
66020
66146
|
return;
|
|
66021
66147
|
}
|
|
66148
|
+
if (!await mayPay(choice.leg, "this ask", opts)) return;
|
|
66022
66149
|
if (!opts.json) process.stdout.write(`
|
|
66023
66150
|
${import_picocolors4.default.dim(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`)}
|
|
66024
66151
|
`);
|
|
@@ -66071,6 +66198,7 @@ init_passwords_wire();
|
|
|
66071
66198
|
// src/lib/phone-wire.ts
|
|
66072
66199
|
init_constants();
|
|
66073
66200
|
init_passwords_wire();
|
|
66201
|
+
init_terminal_text();
|
|
66074
66202
|
var INBOUND_ROLES = ["receptionist", "screener", "order-taker", "reservationist", "after-hours", "callback-line", "hotline", "answering-voicemail"];
|
|
66075
66203
|
async function createPersona(wallet, body) {
|
|
66076
66204
|
return expect(await signedFetch(wallet, "POST", lanePath(`/personas`), body), "the persona").persona;
|
|
@@ -66130,7 +66258,7 @@ async function readCallRecording(wallet, phoneId, id2, owner) {
|
|
|
66130
66258
|
const text = await res.text();
|
|
66131
66259
|
let json2 = null;
|
|
66132
66260
|
try {
|
|
66133
|
-
json2 = text ? JSON.parse(text) : null;
|
|
66261
|
+
json2 = text ? scrubDeep(JSON.parse(text)) : null;
|
|
66134
66262
|
} catch {
|
|
66135
66263
|
json2 = null;
|
|
66136
66264
|
}
|
|
@@ -66173,7 +66301,7 @@ function countryCodeFor(countries) {
|
|
|
66173
66301
|
function transcriptLines(raw) {
|
|
66174
66302
|
if (!raw) return [];
|
|
66175
66303
|
try {
|
|
66176
|
-
const parsed = JSON.parse(raw);
|
|
66304
|
+
const parsed = scrubDeep(JSON.parse(raw));
|
|
66177
66305
|
if (!Array.isArray(parsed)) return [];
|
|
66178
66306
|
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 }));
|
|
66179
66307
|
} catch {
|
|
@@ -69498,6 +69626,7 @@ function keyWrapAad(ownerWallet, keyId) {
|
|
|
69498
69626
|
}
|
|
69499
69627
|
|
|
69500
69628
|
// src/lib/mail-key.ts
|
|
69629
|
+
init_terminal_text();
|
|
69501
69630
|
var held = /* @__PURE__ */ new Map();
|
|
69502
69631
|
async function readSealKey(wallet) {
|
|
69503
69632
|
const out = expectOk(await signedFetch(wallet, "GET", lanePath("/seal-key")), "the mail key");
|
|
@@ -69574,9 +69703,9 @@ function openMessage(key, inboxId, m) {
|
|
|
69574
69703
|
id: m.id,
|
|
69575
69704
|
from: m.from ?? "",
|
|
69576
69705
|
to: m.to,
|
|
69577
|
-
subject: m.sealed.subject ? openSubject(key.dataKey, m.sealed.subject, inboxId) : "",
|
|
69578
|
-
text: body.text,
|
|
69579
|
-
html: body.html,
|
|
69706
|
+
subject: m.sealed.subject ? scrubText(openSubject(key.dataKey, m.sealed.subject, inboxId)) : "",
|
|
69707
|
+
text: scrubText(body.text),
|
|
69708
|
+
html: body.html === null ? null : scrubText(body.html),
|
|
69580
69709
|
receivedAt: m.receivedAt ?? ""
|
|
69581
69710
|
};
|
|
69582
69711
|
}
|
|
@@ -69648,6 +69777,7 @@ async function grantedKeyFor(wallet, owner) {
|
|
|
69648
69777
|
}
|
|
69649
69778
|
|
|
69650
69779
|
// src/lib/call-seal.ts
|
|
69780
|
+
init_terminal_text();
|
|
69651
69781
|
var SEALED_RE = /^v1\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
69652
69782
|
function isSealedCallBlob(value) {
|
|
69653
69783
|
return typeof value === "string" && SEALED_RE.test(value);
|
|
@@ -69668,7 +69798,7 @@ function parseSealedTranscript(text) {
|
|
|
69668
69798
|
}
|
|
69669
69799
|
function openCallTranscript(key, blob, callId) {
|
|
69670
69800
|
if (!isSealedCallBlob(blob)) throw new MailSealError("bad_blob", "This call carries no sealed transcript.");
|
|
69671
|
-
return parseSealedTranscript(openText(key.dataKey, blob, callTranscriptAad(callId)));
|
|
69801
|
+
return scrubDeep(parseSealedTranscript(openText(key.dataKey, blob, callTranscriptAad(callId))));
|
|
69672
69802
|
}
|
|
69673
69803
|
function openCallTranscriptQuietly(key, blob, callId) {
|
|
69674
69804
|
if (!key || !isSealedCallBlob(blob)) return null;
|
|
@@ -69807,6 +69937,8 @@ async function payphoneCall(args) {
|
|
|
69807
69937
|
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;
|
|
69808
69938
|
throw new WireError(402, "payphone_unfunded", shortfall, quote.json);
|
|
69809
69939
|
}
|
|
69940
|
+
const consent = await args.consent(choice.leg);
|
|
69941
|
+
if (!consent.ok) throw new WireError(402, consent.code, consent.reason, quote.json);
|
|
69810
69942
|
args.onQuote?.(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`);
|
|
69811
69943
|
const signed2 = await signLeg(choice.leg, args.privateKey);
|
|
69812
69944
|
const payer = new ethers_exports.Wallet(args.privateKey);
|
|
@@ -69845,6 +69977,7 @@ async function payphoneRead(payment, asked, what, privateKey) {
|
|
|
69845
69977
|
}
|
|
69846
69978
|
|
|
69847
69979
|
// src/commands/phone.ts
|
|
69980
|
+
import { createInterface as createInterface3 } from "node:readline/promises";
|
|
69848
69981
|
var SITE2 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
69849
69982
|
var jsonMode2 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
69850
69983
|
function emit2(opts, data4, human) {
|
|
@@ -70049,7 +70182,24 @@ async function walkUpToThePayphone(opts, args) {
|
|
|
70049
70182
|
onQuote: (note2) => {
|
|
70050
70183
|
if (!jsonMode2(opts)) process.stderr.write(` ${import_picocolors5.default.dim(note2)}
|
|
70051
70184
|
`);
|
|
70052
|
-
}
|
|
70185
|
+
},
|
|
70186
|
+
// The caller's --max-usd, or a person's yes at the terminal (M7).
|
|
70187
|
+
consent: (leg) => consentToPay({
|
|
70188
|
+
leg,
|
|
70189
|
+
maxUsd: opts.maxUsd,
|
|
70190
|
+
interactive: !jsonMode2(opts) && process.stdin.isTTY === true && process.stdout.isTTY === true,
|
|
70191
|
+
what: `a ${window2}-minute payphone call`,
|
|
70192
|
+
ask: async (question) => {
|
|
70193
|
+
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
70194
|
+
try {
|
|
70195
|
+
return await rl.question(question);
|
|
70196
|
+
} catch {
|
|
70197
|
+
return "";
|
|
70198
|
+
} finally {
|
|
70199
|
+
rl.close();
|
|
70200
|
+
}
|
|
70201
|
+
}
|
|
70202
|
+
})
|
|
70053
70203
|
});
|
|
70054
70204
|
const placed = walk.call;
|
|
70055
70205
|
const paid = usd(walk.paidMicro);
|
|
@@ -73319,7 +73469,7 @@ async function onboard(opts = {}) {
|
|
|
73319
73469
|
if (stale) put(stale);
|
|
73320
73470
|
const order = menuOrder(opts.lane, !!account, latestSeen !== null).filter((k) => existing ? k !== "wallet" : true);
|
|
73321
73471
|
printMenu(put, order, true);
|
|
73322
|
-
const rl =
|
|
73472
|
+
const rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
73323
73473
|
const exitDefault = String(order.indexOf("poke") + 1);
|
|
73324
73474
|
let first = true;
|
|
73325
73475
|
let plain = put;
|
|
@@ -73477,7 +73627,7 @@ init_passwords_wire();
|
|
|
73477
73627
|
init_passwords_seal();
|
|
73478
73628
|
|
|
73479
73629
|
// src/lib/mcp-stdio.ts
|
|
73480
|
-
import { createInterface as
|
|
73630
|
+
import { createInterface as createInterface5 } from "node:readline";
|
|
73481
73631
|
var MCP_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
73482
73632
|
var McpToolError = class extends Error {
|
|
73483
73633
|
constructor(message, detail = {}) {
|
|
@@ -73590,7 +73740,7 @@ async function serve(tools, info, { input = process.stdin, output: output2 = pro
|
|
|
73590
73740
|
`);
|
|
73591
73741
|
};
|
|
73592
73742
|
const inFlight = /* @__PURE__ */ new Set();
|
|
73593
|
-
const lines =
|
|
73743
|
+
const lines = createInterface5({ input, crlfDelay: Infinity });
|
|
73594
73744
|
for await (const line2 of lines) {
|
|
73595
73745
|
const parsed = parseLine(line2);
|
|
73596
73746
|
if (!parsed) continue;
|
|
@@ -74844,7 +74994,7 @@ async function filesRm(target, opts) {
|
|
|
74844
74994
|
|
|
74845
74995
|
// src/commands/card.ts
|
|
74846
74996
|
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
74847
|
-
import { createInterface as
|
|
74997
|
+
import { createInterface as createInterface6 } from "node:readline/promises";
|
|
74848
74998
|
|
|
74849
74999
|
// src/lib/memory-address.ts
|
|
74850
75000
|
var ADDRESS_FOLDER = "profile";
|
|
@@ -75386,7 +75536,7 @@ var QUESTIONS = [
|
|
|
75386
75536
|
{ field: "zip", ask: "ZIP code", abroad: "Postal code" }
|
|
75387
75537
|
];
|
|
75388
75538
|
async function askAddress() {
|
|
75389
|
-
const rl =
|
|
75539
|
+
const rl = createInterface6({ input: process.stdin, output: process.stdout });
|
|
75390
75540
|
const answers = { country: "US", line1: "", line2: "", city: "", region: "", zip: "" };
|
|
75391
75541
|
try {
|
|
75392
75542
|
process.stdout.write(`
|
|
@@ -76188,6 +76338,7 @@ init_passwords_wire();
|
|
|
76188
76338
|
init_lib2();
|
|
76189
76339
|
init_constants();
|
|
76190
76340
|
init_passwords_wire();
|
|
76341
|
+
init_terminal_text();
|
|
76191
76342
|
var path5 = (relative = "") => lanePath(`intents${relative}`);
|
|
76192
76343
|
function expect3(answer, what) {
|
|
76193
76344
|
if (answer.status >= 200 && answer.status < 300 && answer.body !== null) return answer.body;
|
|
@@ -76249,7 +76400,7 @@ async function readListingPublic(id2) {
|
|
|
76249
76400
|
const text = await res.text();
|
|
76250
76401
|
let body = null;
|
|
76251
76402
|
try {
|
|
76252
|
-
body = JSON.parse(text);
|
|
76403
|
+
body = scrubDeep(JSON.parse(text));
|
|
76253
76404
|
} catch {
|
|
76254
76405
|
}
|
|
76255
76406
|
return expect3({ status: res.status, body, text }, `GET /listings/${id2}`);
|
|
@@ -76260,7 +76411,7 @@ async function lookupListingByPhone(phone2) {
|
|
|
76260
76411
|
const text = await res.text();
|
|
76261
76412
|
let body = null;
|
|
76262
76413
|
try {
|
|
76263
|
-
body = JSON.parse(text);
|
|
76414
|
+
body = scrubDeep(JSON.parse(text));
|
|
76264
76415
|
} catch {
|
|
76265
76416
|
}
|
|
76266
76417
|
return expect3({ status: res.status, body, text }, "GET /listings?phone").listing;
|
|
@@ -76363,6 +76514,27 @@ async function signEscrow(wallet, group) {
|
|
|
76363
76514
|
});
|
|
76364
76515
|
return { chainId: group.chainId, payment: encodePayment(group.network, signature, authorization) };
|
|
76365
76516
|
}
|
|
76517
|
+
function releaseWordRefusal(toSign, leg, nowSeconds = Math.floor(Date.now() / 1e3)) {
|
|
76518
|
+
if (!toSign) return null;
|
|
76519
|
+
const fail11 = (why) => `refused to sign the release word: ${why}`;
|
|
76520
|
+
const d = toSign.domain;
|
|
76521
|
+
if (!d || d.name !== "Cov3nantIntent" || d.version !== "1") return fail11("it is not the intents escrow's domain");
|
|
76522
|
+
if (Object.keys(d).sort().join(",") !== "chainId,name,verifyingContract,version") return fail11("the domain carries fields the escrow's does not");
|
|
76523
|
+
const types = toSign.types;
|
|
76524
|
+
if (!types || Object.keys(types).join(",") !== "FunderRelease") return fail11("it is not a FunderRelease");
|
|
76525
|
+
const fields = types.FunderRelease ?? [];
|
|
76526
|
+
if (fields.map((f2) => `${f2.name}:${f2.type}`).join(",") !== "legIndex:uint256,nonce:uint256,deadline:uint256") return fail11("its fields are not the escrow's");
|
|
76527
|
+
const m = toSign.message;
|
|
76528
|
+
if (!m || Object.keys(m).sort().join(",") !== "deadline,legIndex,nonce") return fail11("its message carries fields the escrow's does not");
|
|
76529
|
+
if (![m.legIndex, m.nonce, m.deadline].every((v) => Number.isSafeInteger(v) && v >= 0)) return fail11("its numbers are not whole and non-negative");
|
|
76530
|
+
if (!leg || !leg.escrowAddress || leg.legIndex === null) return fail11("this leg is not held in escrow");
|
|
76531
|
+
if (typeof d.verifyingContract !== "string" || d.verifyingContract.toLowerCase() !== leg.escrowAddress.toLowerCase()) return fail11("it names another deal than this leg's");
|
|
76532
|
+
if (d.chainId !== leg.chainId) return fail11("it names another chain than this leg's");
|
|
76533
|
+
if (m.legIndex !== leg.legIndex) return fail11("it names another leg");
|
|
76534
|
+
const deadline = m.deadline;
|
|
76535
|
+
if (deadline <= nowSeconds || deadline > nowSeconds + 7200) return fail11("its deadline is not within the next two hours");
|
|
76536
|
+
return null;
|
|
76537
|
+
}
|
|
76366
76538
|
async function wordOnLeg(wallet, askId, offerId, happened, toSign) {
|
|
76367
76539
|
let signed2 = {};
|
|
76368
76540
|
if (happened && toSign) {
|
|
@@ -76646,6 +76818,11 @@ async function intentsWord(id2, opts) {
|
|
|
76646
76818
|
if (happened && said?.transaction) {
|
|
76647
76819
|
return refuse5(opts, "This leg is on Solana: its word is signed by a Solana wallet, which this key is not.", "svm_word");
|
|
76648
76820
|
}
|
|
76821
|
+
if (happened && said?.word) {
|
|
76822
|
+
const leg = detail.settlements.find((st) => st.offerId === opts.offer);
|
|
76823
|
+
const refusal = releaseWordRefusal(said.word, leg ? { chainId: leg.chainId, escrowAddress: leg.escrowAddress, legIndex: leg.legIndex } : void 0);
|
|
76824
|
+
if (refusal) return refuse5(opts, refusal, "word_refused");
|
|
76825
|
+
}
|
|
76649
76826
|
const settlement = await wordOnLeg(wallet, id2, opts.offer, happened, said?.word);
|
|
76650
76827
|
emit9(opts, { ok: true, settlement }, () => {
|
|
76651
76828
|
process.stdout.write(`
|
|
@@ -77063,6 +77240,7 @@ async function intentsNoShow(askId, opts) {
|
|
|
77063
77240
|
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
77064
77241
|
import { createHash as createHash6, randomBytes as randomBytes9 } from "node:crypto";
|
|
77065
77242
|
init_passwords_wire();
|
|
77243
|
+
init_terminal_text();
|
|
77066
77244
|
function emit10(opts, data4, human) {
|
|
77067
77245
|
if (opts.json || !process.stdout.isTTY) {
|
|
77068
77246
|
process.stdout.write(`${JSON.stringify(data4)}
|
|
@@ -77400,7 +77578,7 @@ function askOf(dataKey, owner, ask) {
|
|
|
77400
77578
|
const aad = `AGENTGATES-CONVERSATION-v1|turn|${normalizeOwner2(owner)}|${ask.conversationId}|${ask.seq}|${ask.role}${ask.author ? `|${ask.author}|${ask.channel ?? ""}` : ""}`;
|
|
77401
77579
|
const text = openText(dataKey, ask.ciphertext, aad);
|
|
77402
77580
|
if (ask.author === "card") {
|
|
77403
|
-
const words7 = JSON.parse(text).words ?? "";
|
|
77581
|
+
const words7 = scrubDeep(JSON.parse(text)).words ?? "";
|
|
77404
77582
|
return words7 ? `Fix: ${words7.split("\n")[0].trim()}` : null;
|
|
77405
77583
|
}
|
|
77406
77584
|
const m = /^Asked for a change on site [A-Za-z0-9_-]{22}: ([\s\S]*)$/.exec(text.trim());
|
|
@@ -80290,7 +80468,8 @@ async function orderFood(items, opts) {
|
|
|
80290
80468
|
if (!jsonMode8) {
|
|
80291
80469
|
process.stderr.write(
|
|
80292
80470
|
import_picocolors32.default.yellow(
|
|
80293
|
-
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
80471
|
+
agentCard.allowed ? `This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
80472
|
+
` : `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.
|
|
80294
80473
|
`
|
|
80295
80474
|
)
|
|
80296
80475
|
);
|
|
@@ -80348,6 +80527,7 @@ function readAgentCard(res) {
|
|
|
80348
80527
|
last4: c.last4,
|
|
80349
80528
|
max_per_order_cents: typeof c.max_per_order_cents === "number" ? c.max_per_order_cents : 0,
|
|
80350
80529
|
max_per_day_cents: typeof c.max_per_day_cents === "number" ? c.max_per_day_cents : 0,
|
|
80530
|
+
allowed: c.allowed !== false,
|
|
80351
80531
|
will_attempt: c.will_attempt === true
|
|
80352
80532
|
};
|
|
80353
80533
|
}
|
|
@@ -81122,6 +81302,7 @@ init_constants();
|
|
|
81122
81302
|
// src/lib/trade-sol.ts
|
|
81123
81303
|
var import_web3 = __toESM(require_index_cjs(), 1);
|
|
81124
81304
|
init_constants();
|
|
81305
|
+
init_terminal_text();
|
|
81125
81306
|
import { promises as fs9 } from "node:fs";
|
|
81126
81307
|
import * as path6 from "node:path";
|
|
81127
81308
|
import * as os3 from "node:os";
|
|
@@ -81188,7 +81369,7 @@ async function relayPost(pathname, body) {
|
|
|
81188
81369
|
const text = await res.text();
|
|
81189
81370
|
let parsed;
|
|
81190
81371
|
try {
|
|
81191
|
-
parsed = JSON.parse(text);
|
|
81372
|
+
parsed = scrubDeep(JSON.parse(text));
|
|
81192
81373
|
} catch {
|
|
81193
81374
|
parsed = { error: text.slice(0, 200) };
|
|
81194
81375
|
}
|
|
@@ -81204,7 +81385,7 @@ async function relayGet(pathname) {
|
|
|
81204
81385
|
const text = await res.text();
|
|
81205
81386
|
let parsed;
|
|
81206
81387
|
try {
|
|
81207
|
-
parsed = JSON.parse(text);
|
|
81388
|
+
parsed = scrubDeep(JSON.parse(text));
|
|
81208
81389
|
} catch {
|
|
81209
81390
|
parsed = { error: text.slice(0, 200) };
|
|
81210
81391
|
}
|
|
@@ -82486,6 +82667,7 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
82486
82667
|
}
|
|
82487
82668
|
|
|
82488
82669
|
// src/main.ts
|
|
82670
|
+
installServerTextScrub();
|
|
82489
82671
|
var { version: VERSION } = JSON.parse(readFileSync3(new URL("../package.json", import.meta.url), "utf8"));
|
|
82490
82672
|
var program2 = new Command();
|
|
82491
82673
|
program2.name("agentgates").description(
|
|
@@ -82987,10 +83169,10 @@ compute.command("plans").description("Live plans and the price ladder. Public re
|
|
|
82987
83169
|
});
|
|
82988
83170
|
compute.command("buy").description(
|
|
82989
83171
|
"Rent a machine: asks the price (free), signs the 402 with this machine's key (USDC on an EVM network, no gas), resends that same payment until the API answers, and prints the machine. The key that pays owns it."
|
|
82990
|
-
).option("--plan <id>", "a plan id (agentgates compute plans)").option("--hours <n>", "prepaid hours; the clock starts when the machine runs").option("--image <image>", "one container image, served on host port 8080").option("--port <n>", "with --image: the container port behind 8080 (default 80)").option("--compose <file>", "a docker-compose.yml that publishes a port (- reads stdin)").option("--env <KEY=VALUE>", "an env value, sealed to the machine and never stored; repeatable", (v, prev) => prev.concat(v), []).option("--name <name>", "a label for the machine").option("--network <name>", "pay on this network only; default: the cheapest one this key holds the USDC for").option("--max-usd <dollars>", "refuse to sign above this price").option("--quote", "print the price on every network and stop: nothing is signed").option("--yes", "pay without the prompt (needed when stdout is not a TTY)").option("--wait", "after paying, wait until the machine runs and print its endpoint").option("--timeout <minutes>", "with --wait: how long to wait (default 15)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
83172
|
+
).option("--plan <id>", "a plan id (agentgates compute plans)").option("--hours <n>", "prepaid hours; the clock starts when the machine runs").option("--minutes <n>", "a quarter-hour in place of --hours: 15, 30 or 45 (when the API sells them)").option("--image <image>", "one container image, served on host port 8080").option("--port <n>", "with --image: the container port behind 8080 (default 80)").option("--compose <file>", "a docker-compose.yml that publishes a port (- reads stdin)").option("--env <KEY=VALUE>", "an env value, sealed to the machine and never stored; repeatable", (v, prev) => prev.concat(v), []).option("--name <name>", "a label for the machine").option("--network <name>", "pay on this network only; default: the cheapest one this key holds the USDC for").option("--max-usd <dollars>", "refuse to sign above this price").option("--quote", "print the price on every network and stop: nothing is signed").option("--yes", "pay without the prompt (needed when stdout is not a TTY)").option("--wait", "after paying, wait until the machine runs and print its endpoint").option("--timeout <minutes>", "with --wait: how long to wait (default 15)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82991
83173
|
await computeBuy(opts);
|
|
82992
83174
|
});
|
|
82993
|
-
compute.command("renew <id>").description("Add paid hours to a machine: same price ask, same signature, same resend. Any wallet may pay; the owner stays the owner.").option("--hours <n>", "hours to add to the end of its clock").option("--network <name>", "pay on this network only").option("--max-usd <dollars>", "refuse to sign above this price").option("--quote", "print the price and stop: nothing is signed").option("--yes", "pay without the prompt (needed when stdout is not a TTY)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
|
|
83175
|
+
compute.command("renew <id>").description("Add paid hours to a machine: same price ask, same signature, same resend. Any wallet may pay; the owner stays the owner.").option("--hours <n>", "hours to add to the end of its clock").option("--minutes <n>", "a quarter-hour in place of --hours: 15, 30 or 45 (when the API sells them)").option("--network <name>", "pay on this network only").option("--max-usd <dollars>", "refuse to sign above this price").option("--quote", "print the price and stop: nothing is signed").option("--yes", "pay without the prompt (needed when stdout is not a TTY)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
|
|
82994
83176
|
await computeRenew(id2, opts);
|
|
82995
83177
|
});
|
|
82996
83178
|
compute.command("list").description("The machines this machine's key paid for (an owner read it signs).").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
@@ -83016,10 +83198,10 @@ inference.command("key").description("Mint a key that buys turns without the wor
|
|
|
83016
83198
|
}
|
|
83017
83199
|
await inferenceKeyCreate(opts);
|
|
83018
83200
|
});
|
|
83019
|
-
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) => {
|
|
83201
|
+
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) => {
|
|
83020
83202
|
await inferenceTopUp(usd6, opts);
|
|
83021
83203
|
});
|
|
83022
|
-
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) => {
|
|
83204
|
+
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) => {
|
|
83023
83205
|
await inferenceAsk(words7, opts);
|
|
83024
83206
|
});
|
|
83025
83207
|
var phone = program2.command("phone").description("Phone numbers on a plan, texts and calls metered, and a walk-up payphone, USDC over x402");
|
|
@@ -83027,7 +83209,7 @@ phone.command("pricing").description("Number plans, per-unit usage and the payph
|
|
|
83027
83209
|
await phonePricing(opts);
|
|
83028
83210
|
});
|
|
83029
83211
|
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";
|
|
83030
|
-
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) => {
|
|
83212
|
+
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) => {
|
|
83031
83213
|
await phoneCall(number2, task ?? [], opts);
|
|
83032
83214
|
});
|
|
83033
83215
|
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) => {
|