@agentgates/cli 0.74.0 → 0.84.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/README.md +31 -0
- package/dist/cli.mjs +1477 -426
- package/package.json +6 -2
package/dist/cli.mjs
CHANGED
|
@@ -982,7 +982,7 @@ var require_command = __commonJS({
|
|
|
982
982
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
983
983
|
var childProcess2 = __require("node:child_process");
|
|
984
984
|
var path8 = __require("node:path");
|
|
985
|
-
var
|
|
985
|
+
var fs11 = __require("node:fs");
|
|
986
986
|
var process8 = __require("node:process");
|
|
987
987
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
988
988
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -1915,10 +1915,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1915
1915
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1916
1916
|
function findFile2(baseDir, baseName2) {
|
|
1917
1917
|
const localBin = path8.resolve(baseDir, baseName2);
|
|
1918
|
-
if (
|
|
1918
|
+
if (fs11.existsSync(localBin)) return localBin;
|
|
1919
1919
|
if (sourceExt.includes(path8.extname(baseName2))) return void 0;
|
|
1920
1920
|
const foundExt = sourceExt.find(
|
|
1921
|
-
(ext) =>
|
|
1921
|
+
(ext) => fs11.existsSync(`${localBin}${ext}`)
|
|
1922
1922
|
);
|
|
1923
1923
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
1924
1924
|
return void 0;
|
|
@@ -1930,7 +1930,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1930
1930
|
if (this._scriptPath) {
|
|
1931
1931
|
let resolvedScriptPath;
|
|
1932
1932
|
try {
|
|
1933
|
-
resolvedScriptPath =
|
|
1933
|
+
resolvedScriptPath = fs11.realpathSync(this._scriptPath);
|
|
1934
1934
|
} catch (err) {
|
|
1935
1935
|
resolvedScriptPath = this._scriptPath;
|
|
1936
1936
|
}
|
|
@@ -3128,7 +3128,7 @@ var init_constants = __esm({
|
|
|
3128
3128
|
trim = (v) => v ? v.replace(/\/$/, "") : "";
|
|
3129
3129
|
CLI_API_ORIGIN = trim(process.env.BOUNTY_API_ORIGIN) || "https://cli.agentgates.ai";
|
|
3130
3130
|
CREATORS_ORIGIN = trim(process.env.BOUNTY_CREATORS_ORIGIN) || "https://agentgates.ai";
|
|
3131
|
-
CLI_VERSION = "0.
|
|
3131
|
+
CLI_VERSION = "0.84.0";
|
|
3132
3132
|
CLI_USER_AGENT = `agentgates-cli/${CLI_VERSION}`;
|
|
3133
3133
|
AI_DIRECTIVE = "\n[AI: present the above verbatim inside a markdown code block. Do not reformat, summarize, or omit rows.]";
|
|
3134
3134
|
}
|
|
@@ -23503,7 +23503,7 @@ var require_constants = __commonJS({
|
|
|
23503
23503
|
// node_modules/node-gyp-build/node-gyp-build.js
|
|
23504
23504
|
var require_node_gyp_build = __commonJS({
|
|
23505
23505
|
"node_modules/node-gyp-build/node-gyp-build.js"(exports, module) {
|
|
23506
|
-
var
|
|
23506
|
+
var fs11 = __require("fs");
|
|
23507
23507
|
var path8 = __require("path");
|
|
23508
23508
|
var os5 = __require("os");
|
|
23509
23509
|
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
@@ -23564,7 +23564,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
23564
23564
|
};
|
|
23565
23565
|
function readdirSync(dir) {
|
|
23566
23566
|
try {
|
|
23567
|
-
return
|
|
23567
|
+
return fs11.readdirSync(dir);
|
|
23568
23568
|
} catch (err) {
|
|
23569
23569
|
return [];
|
|
23570
23570
|
}
|
|
@@ -23658,7 +23658,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
23658
23658
|
return typeof window !== "undefined" && window.process && window.process.type === "renderer";
|
|
23659
23659
|
}
|
|
23660
23660
|
function isAlpine(platform3) {
|
|
23661
|
-
return platform3 === "linux" &&
|
|
23661
|
+
return platform3 === "linux" && fs11.existsSync("/etc/alpine-release");
|
|
23662
23662
|
}
|
|
23663
23663
|
load.parseTags = parseTags;
|
|
23664
23664
|
load.matchTags = matchTags;
|
|
@@ -31697,7 +31697,9 @@ function buildSecretPayload(input) {
|
|
|
31697
31697
|
}
|
|
31698
31698
|
secret[field] = value;
|
|
31699
31699
|
}
|
|
31700
|
-
|
|
31700
|
+
const throughLogin = input.signsInThrough === true && kind === "login";
|
|
31701
|
+
if (throughLogin && secret.password) throw new PasswordsSealError("a login that signs in through another row holds no password of its own");
|
|
31702
|
+
if (rules.required && !secret[rules.required] && !throughLogin) {
|
|
31701
31703
|
throw new PasswordsSealError(`a ${kind} row needs its ${rules.required}`);
|
|
31702
31704
|
}
|
|
31703
31705
|
const hosts = validateHosts(input.hosts);
|
|
@@ -32678,7 +32680,7 @@ var init_passwords_wire = __esm({
|
|
|
32678
32680
|
revokedNoticed = false;
|
|
32679
32681
|
keyOnly = false;
|
|
32680
32682
|
loginReading = null;
|
|
32681
|
-
SIGNED_DOORS = /\/keys(\/(?!me\/)|$)|\/passwords\/[A-Za-z0-9_-]{1,64}\/use$|\/seal-key$|\/ag\/(?:agent
|
|
32683
|
+
SIGNED_DOORS = /\/keys(\/(?!me\/)|$)|\/passwords\/[A-Za-z0-9_-]{1,64}\/use$|\/seal-key$|\/ag\/(?:agent(?:\?turnOn=1)?|bindings)$|\/integrations(\/|$)/;
|
|
32682
32684
|
PASSWORDS_BOX_APP_ID = "c8746c93771d337af3588872dcad76ddb1fccdb6";
|
|
32683
32685
|
PASSWORDS_REPORT_DATA_LABEL = "agentgates/passwords/seal-key/v1";
|
|
32684
32686
|
}
|
|
@@ -64299,6 +64301,7 @@ async function* streamSse(url, opts = {}) {
|
|
|
64299
64301
|
if (opts.bearer) {
|
|
64300
64302
|
headers["authorization"] = `Bearer ${opts.bearer}`;
|
|
64301
64303
|
}
|
|
64304
|
+
if (opts.headers) Object.assign(headers, opts.headers);
|
|
64302
64305
|
let res;
|
|
64303
64306
|
try {
|
|
64304
64307
|
res = await fetch(url, {
|
|
@@ -64387,7 +64390,7 @@ async function runLoginFlow(opts) {
|
|
|
64387
64390
|
const init2 = await apiFetch("/api/login-init", {
|
|
64388
64391
|
method: "POST",
|
|
64389
64392
|
origin,
|
|
64390
|
-
body: { clientLabel: defaultClientLabel() }
|
|
64393
|
+
body: { clientLabel: defaultClientLabel(), v: 2 }
|
|
64391
64394
|
});
|
|
64392
64395
|
const expiresAt = new Date(Date.now() + init2.expiresIn * 1e3).toISOString();
|
|
64393
64396
|
if (opts.jsonMode) {
|
|
@@ -64428,7 +64431,7 @@ ${opts.ttyHeader}
|
|
|
64428
64431
|
}
|
|
64429
64432
|
let sawAny = false;
|
|
64430
64433
|
try {
|
|
64431
|
-
for await (const ev of streamSse(streamUrl, {})) {
|
|
64434
|
+
for await (const ev of streamSse(streamUrl, init2.loginSecret ? { headers: { "x-login-secret": init2.loginSecret } } : {})) {
|
|
64432
64435
|
sawAny = true;
|
|
64433
64436
|
if (ev.status === "approved") {
|
|
64434
64437
|
approved = ev;
|
|
@@ -64599,7 +64602,7 @@ function shortAddress(addr) {
|
|
|
64599
64602
|
|
|
64600
64603
|
// src/commands/onboard.ts
|
|
64601
64604
|
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
64602
|
-
import { createInterface } from "node:readline/promises";
|
|
64605
|
+
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
64603
64606
|
init_constants();
|
|
64604
64607
|
|
|
64605
64608
|
// src/lib/water.ts
|
|
@@ -64736,55 +64739,8 @@ function water() {
|
|
|
64736
64739
|
|
|
64737
64740
|
// src/commands/compute.ts
|
|
64738
64741
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
64739
|
-
|
|
64740
|
-
|
|
64741
|
-
async function computePlans(opts) {
|
|
64742
|
-
const res = await fetch(`${SITE}/api/compute/catalog`, { headers: { accept: "application/json" } });
|
|
64743
|
-
if (!res.ok) throw new Error(`compute catalog: HTTP ${res.status}`);
|
|
64744
|
-
const body = await res.json();
|
|
64745
|
-
if (opts.json) {
|
|
64746
|
-
process.stdout.write(JSON.stringify(body, null, 2) + "\n");
|
|
64747
|
-
return;
|
|
64748
|
-
}
|
|
64749
|
-
const plans = body.plans ?? [];
|
|
64750
|
-
if (plans.length === 0) {
|
|
64751
|
-
process.stdout.write(` ${import_picocolors3.default.dim("No plans are on sale right now.")}
|
|
64752
|
-
`);
|
|
64753
|
-
return;
|
|
64754
|
-
}
|
|
64755
|
-
process.stdout.write(`
|
|
64756
|
-
${import_picocolors3.default.bold("CONFIDENTIAL VIRTUAL MACHINES")} ${import_picocolors3.default.dim("memory encrypted in use")}
|
|
64757
|
-
|
|
64758
|
-
`);
|
|
64759
|
-
for (const p of plans) {
|
|
64760
|
-
const spec = `${p.vcpu} vCPU \xB7 ${Math.round(p.memoryMb / 1024)} GB \xB7 ${p.diskGb}GB disk`;
|
|
64761
|
-
process.stdout.write(` ${import_picocolors3.default.bold(p.name.padEnd(10))} ${import_picocolors3.default.cyan(usd(p.priceUsdPerHour))}${import_picocolors3.default.dim("/hour")} ${import_picocolors3.default.dim(spec)}
|
|
64762
|
-
`);
|
|
64763
|
-
process.stdout.write(` ${import_picocolors3.default.dim(p.id.padEnd(10))} ${import_picocolors3.default.dim(`${p.egressQuotaGb} GB traffic`)}
|
|
64764
|
-
`);
|
|
64765
|
-
const ladder = p.pricing.map((r) => `${r.hoursPerPayment}h ${usd(r.totalUsd)}`).join(" ");
|
|
64766
|
-
if (ladder) process.stdout.write(` ${import_picocolors3.default.dim(ladder)}
|
|
64767
|
-
`);
|
|
64768
|
-
process.stdout.write("\n");
|
|
64769
|
-
}
|
|
64770
|
-
const nets = body.payment?.networks ?? [];
|
|
64771
|
-
if (nets.length) process.stdout.write(` ${import_picocolors3.default.dim(`USDC on ${nets.join(", ")}`)}
|
|
64772
|
-
|
|
64773
|
-
`);
|
|
64774
|
-
}
|
|
64775
|
-
async function computeBuy() {
|
|
64776
|
-
process.stdout.write(
|
|
64777
|
-
`
|
|
64778
|
-
Renting signs an x402 payment, and this CLI has no signer yet.
|
|
64779
|
-
Buy from the wallet, one biometric: ${import_picocolors3.default.cyan(`${SITE}/compute`)}
|
|
64780
|
-
Prices from here: ${import_picocolors3.default.dim("agentgates compute plans")}
|
|
64781
|
-
|
|
64782
|
-
`
|
|
64783
|
-
);
|
|
64784
|
-
}
|
|
64785
|
-
|
|
64786
|
-
// src/commands/inference.ts
|
|
64787
|
-
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
64742
|
+
import { promises as fs8 } from "node:fs";
|
|
64743
|
+
import { createInterface } from "node:readline/promises";
|
|
64788
64744
|
|
|
64789
64745
|
// src/lib/passwords-key.ts
|
|
64790
64746
|
init_lib2();
|
|
@@ -64966,9 +64922,6 @@ async function requirePasswordsKey() {
|
|
|
64966
64922
|
return existing;
|
|
64967
64923
|
}
|
|
64968
64924
|
|
|
64969
|
-
// src/commands/inference.ts
|
|
64970
|
-
init_passwords_wire();
|
|
64971
|
-
|
|
64972
64925
|
// src/lib/x402-pay.ts
|
|
64973
64926
|
init_lib2();
|
|
64974
64927
|
var EVM_CHAINS = {
|
|
@@ -65060,7 +65013,7 @@ async function chooseLeg(body, address) {
|
|
|
65060
65013
|
bestHeldMicro: bestHeld
|
|
65061
65014
|
};
|
|
65062
65015
|
}
|
|
65063
|
-
function
|
|
65016
|
+
function usd(micro) {
|
|
65064
65017
|
const neg = micro < 0n;
|
|
65065
65018
|
const v = neg ? -micro : micro;
|
|
65066
65019
|
const whole = v / 1000000n;
|
|
@@ -65105,9 +65058,683 @@ async function signLeg(leg, privateKey) {
|
|
|
65105
65058
|
};
|
|
65106
65059
|
}
|
|
65107
65060
|
|
|
65061
|
+
// src/lib/compute-wire.ts
|
|
65062
|
+
init_constants();
|
|
65063
|
+
init_passwords_wire();
|
|
65064
|
+
var trim3 = (v) => v ? v.trim().replace(/\/+$/, "") : "";
|
|
65065
|
+
function computeOrigin() {
|
|
65066
|
+
return trim3(process.env.AGENTGATES_COMPUTE_ORIGIN) || "https://api.agentgates.ai";
|
|
65067
|
+
}
|
|
65068
|
+
var DEPLOYMENTS_PATH = "/api/compute/deployments";
|
|
65069
|
+
var CATALOG_PATH = "/api/compute/catalog";
|
|
65070
|
+
var ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
65071
|
+
function deploymentPath(id2, action) {
|
|
65072
|
+
const clean3 = String(id2 ?? "").trim();
|
|
65073
|
+
if (!ID_RE.test(clean3)) throw new Error(`"${id2}" is not a machine id (agentgates compute list shows yours)`);
|
|
65074
|
+
return `${DEPLOYMENTS_PATH}/${clean3}${action ? `/${action}` : ""}`;
|
|
65075
|
+
}
|
|
65076
|
+
function positiveInt(value, what) {
|
|
65077
|
+
const n2 = typeof value === "number" ? value : Number(String(value ?? "").trim());
|
|
65078
|
+
if (!Number.isInteger(n2) || n2 <= 0) throw new Error(`${what} must be a whole number above 0`);
|
|
65079
|
+
return n2;
|
|
65080
|
+
}
|
|
65081
|
+
var ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
65082
|
+
function parseEnvPairs(pairs) {
|
|
65083
|
+
const out = {};
|
|
65084
|
+
for (const raw of pairs ?? []) {
|
|
65085
|
+
const at = raw.indexOf("=");
|
|
65086
|
+
const key = at > 0 ? raw.slice(0, at) : "";
|
|
65087
|
+
if (!ENV_KEY_RE.test(key)) {
|
|
65088
|
+
throw new Error(
|
|
65089
|
+
at > 0 ? `--env takes KEY=VALUE, and "${key.slice(0, 64)}" is not a variable name` : "--env takes KEY=VALUE: one --env has no NAME= in front (its text is not shown)"
|
|
65090
|
+
);
|
|
65091
|
+
}
|
|
65092
|
+
out[key] = raw.slice(at + 1);
|
|
65093
|
+
}
|
|
65094
|
+
return out;
|
|
65095
|
+
}
|
|
65096
|
+
function createBody(input) {
|
|
65097
|
+
const plan = (input.plan ?? "").trim();
|
|
65098
|
+
if (!plan) throw new Error("say which plan: --plan <id> (agentgates compute plans lists them)");
|
|
65099
|
+
const hours = positiveInt(input.hours, "--hours");
|
|
65100
|
+
const image = input.image?.trim();
|
|
65101
|
+
const compose = input.compose;
|
|
65102
|
+
if (image && compose !== void 0) throw new Error("send --image or --compose, not both");
|
|
65103
|
+
if (!image && (compose === void 0 || !compose.trim())) {
|
|
65104
|
+
throw new Error("say what runs: --image <image> (one container) or --compose <file> (a docker-compose.yml)");
|
|
65105
|
+
}
|
|
65106
|
+
const body = { plan, hours };
|
|
65107
|
+
if (image) {
|
|
65108
|
+
body.image = image;
|
|
65109
|
+
if (input.port !== void 0) {
|
|
65110
|
+
const port = positiveInt(input.port, "--port");
|
|
65111
|
+
if (port > 65535) throw new Error("--port must be a port number, 1 to 65535");
|
|
65112
|
+
body.port = port;
|
|
65113
|
+
}
|
|
65114
|
+
} else {
|
|
65115
|
+
if (input.port !== void 0) throw new Error("--port goes with --image; a compose publishes its own ports");
|
|
65116
|
+
body.compose = compose;
|
|
65117
|
+
}
|
|
65118
|
+
if (input.env && Object.keys(input.env).length > 0) body.env = input.env;
|
|
65119
|
+
const name = input.name?.trim();
|
|
65120
|
+
if (name) body.name = name;
|
|
65121
|
+
return body;
|
|
65122
|
+
}
|
|
65123
|
+
function legsOn(body, network) {
|
|
65124
|
+
const want = (network ?? "").trim().toLowerCase();
|
|
65125
|
+
if (!want) return body;
|
|
65126
|
+
return { ...body, accepts: (body.accepts ?? []).filter((leg) => (leg.network ?? "").toLowerCase() === want) };
|
|
65127
|
+
}
|
|
65128
|
+
function offeredNetworks(body) {
|
|
65129
|
+
return (body.accepts ?? []).map((leg) => leg.network ?? "?");
|
|
65130
|
+
}
|
|
65131
|
+
async function computeCall(args) {
|
|
65132
|
+
const f2 = args.fetchImpl ?? fetch;
|
|
65133
|
+
const res = await f2(args.url, {
|
|
65134
|
+
method: args.method,
|
|
65135
|
+
headers: {
|
|
65136
|
+
accept: "application/json",
|
|
65137
|
+
"user-agent": CLI_USER_AGENT,
|
|
65138
|
+
...args.body !== void 0 ? { "content-type": "application/json" } : {},
|
|
65139
|
+
...args.headers ?? {}
|
|
65140
|
+
},
|
|
65141
|
+
...args.body !== void 0 ? { body: JSON.stringify(args.body) } : {},
|
|
65142
|
+
signal: AbortSignal.timeout(args.timeoutMs)
|
|
65143
|
+
});
|
|
65144
|
+
const text = await res.text().catch(() => "");
|
|
65145
|
+
let parsed = {};
|
|
65146
|
+
try {
|
|
65147
|
+
parsed = text ? JSON.parse(text) : {};
|
|
65148
|
+
} catch {
|
|
65149
|
+
parsed = { error: text.replace(/\s+/g, " ").trim().slice(0, 300) || `HTTP ${res.status}` };
|
|
65150
|
+
}
|
|
65151
|
+
const json2 = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : { value: parsed };
|
|
65152
|
+
const retryAfter = Number(res.headers.get("retry-after"));
|
|
65153
|
+
return { status: res.status, json: json2, retryAfterSeconds: Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter : null };
|
|
65154
|
+
}
|
|
65155
|
+
function askPrice(url, body, fetchImpl) {
|
|
65156
|
+
return computeCall({ method: "POST", url, body, timeoutMs: 6e4, fetchImpl });
|
|
65157
|
+
}
|
|
65158
|
+
var BACKOFF_MS = [2e3, 4e3, 8e3, 15e3, 3e4];
|
|
65159
|
+
async function sendPaid(args) {
|
|
65160
|
+
const attempts = Math.max(1, args.attempts ?? 6);
|
|
65161
|
+
const sleep4 = args.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms)));
|
|
65162
|
+
let last = null;
|
|
65163
|
+
let why = "";
|
|
65164
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
65165
|
+
let answer = null;
|
|
65166
|
+
try {
|
|
65167
|
+
answer = await computeCall({
|
|
65168
|
+
method: "POST",
|
|
65169
|
+
url: args.url,
|
|
65170
|
+
body: args.body,
|
|
65171
|
+
headers: { "x-payment": args.payment },
|
|
65172
|
+
// A create waits for the chain, then the vendor: the API allows
|
|
65173
|
+
// itself 120 seconds.
|
|
65174
|
+
timeoutMs: args.timeoutMs ?? 15e4,
|
|
65175
|
+
fetchImpl: args.fetchImpl
|
|
65176
|
+
});
|
|
65177
|
+
} catch (err) {
|
|
65178
|
+
why = err?.message || String(err);
|
|
65179
|
+
}
|
|
65180
|
+
if (answer) {
|
|
65181
|
+
last = answer;
|
|
65182
|
+
if (answer.status >= 200 && answer.status < 300) return { kind: "served", answer, attempts: attempt };
|
|
65183
|
+
const inProgress = answer.status === 409 && answer.json?.code === "payment_in_progress";
|
|
65184
|
+
if (!(answer.status >= 500 || answer.status === 429 || inProgress)) return { kind: "refused", answer, attempts: attempt };
|
|
65185
|
+
why = typeof answer.json?.error === "string" ? answer.json.error : `HTTP ${answer.status}`;
|
|
65186
|
+
}
|
|
65187
|
+
if (attempt === attempts) break;
|
|
65188
|
+
const waitMs = answer?.retryAfterSeconds ? Math.min(answer.retryAfterSeconds, 60) * 1e3 : BACKOFF_MS[Math.min(attempt - 1, BACKOFF_MS.length - 1)];
|
|
65189
|
+
args.onRetry?.(why, attempt, waitMs);
|
|
65190
|
+
await sleep4(waitMs);
|
|
65191
|
+
}
|
|
65192
|
+
return { kind: "no_answer", error: why, attempts, last };
|
|
65193
|
+
}
|
|
65194
|
+
async function ownerGet(wallet, path8, opts = {}) {
|
|
65195
|
+
const header = await ownerAuthHeader(wallet, "GET", path8);
|
|
65196
|
+
return computeCall({
|
|
65197
|
+
method: "GET",
|
|
65198
|
+
url: `${computeOrigin()}${path8}`,
|
|
65199
|
+
headers: { "x-wallet-auth": header },
|
|
65200
|
+
timeoutMs: opts.timeoutMs ?? 6e4,
|
|
65201
|
+
fetchImpl: opts.fetchImpl
|
|
65202
|
+
});
|
|
65203
|
+
}
|
|
65204
|
+
function stillStarting(machine) {
|
|
65205
|
+
if (machine.status === "provisioning") return true;
|
|
65206
|
+
return machine.status === "stopped" && machine.stop?.starting === true;
|
|
65207
|
+
}
|
|
65208
|
+
async function waitUntilRunning(args) {
|
|
65209
|
+
const now = args.now ?? Date.now;
|
|
65210
|
+
const sleep4 = args.sleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms)));
|
|
65211
|
+
const started = now();
|
|
65212
|
+
let machine = null;
|
|
65213
|
+
for (; ; ) {
|
|
65214
|
+
let answer = null;
|
|
65215
|
+
try {
|
|
65216
|
+
answer = await args.read();
|
|
65217
|
+
} catch {
|
|
65218
|
+
answer = null;
|
|
65219
|
+
}
|
|
65220
|
+
if (answer && answer.status >= 400 && answer.status < 500) return { kind: "refused", answer };
|
|
65221
|
+
if (answer && answer.status >= 200 && answer.status < 300) {
|
|
65222
|
+
machine = answer.json;
|
|
65223
|
+
args.onTick?.(machine);
|
|
65224
|
+
if (machine.status === "running") return { kind: "running", machine };
|
|
65225
|
+
if (!stillStarting(machine)) return { kind: "ended", machine };
|
|
65226
|
+
}
|
|
65227
|
+
const elapsed = now() - started;
|
|
65228
|
+
if (elapsed >= args.timeoutMs) return { kind: "timeout", machine };
|
|
65229
|
+
await sleep4(Math.min(elapsed < 6e4 ? 5e3 : 1e4, Math.max(1, args.timeoutMs - elapsed)));
|
|
65230
|
+
}
|
|
65231
|
+
}
|
|
65232
|
+
|
|
65233
|
+
// src/commands/compute.ts
|
|
65234
|
+
var money = (v) => `$${String(v).replace(/(\.\d\d\d?)0+$/, "$1")}`;
|
|
65235
|
+
var jsonMode = (opts) => Boolean(opts.json) || !process.stdout.isTTY;
|
|
65236
|
+
var sink = null;
|
|
65237
|
+
function say(text) {
|
|
65238
|
+
if (sink) sink(text, "out");
|
|
65239
|
+
else process.stdout.write(text);
|
|
65240
|
+
}
|
|
65241
|
+
function sayErr(text) {
|
|
65242
|
+
if (sink) sink(text, "err");
|
|
65243
|
+
else process.stderr.write(text);
|
|
65244
|
+
}
|
|
65245
|
+
function fail(opts, error, code, extra = {}) {
|
|
65246
|
+
if (jsonMode(opts)) {
|
|
65247
|
+
say(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
|
|
65248
|
+
} else {
|
|
65249
|
+
const line2 = `
|
|
65250
|
+
${import_picocolors3.default.red("\u2717")} ${error}${code ? import_picocolors3.default.dim(` (${code})`) : ""}
|
|
65251
|
+
|
|
65252
|
+
`;
|
|
65253
|
+
if (sink) sink(line2, "err");
|
|
65254
|
+
else process.stderr.write(line2);
|
|
65255
|
+
}
|
|
65256
|
+
process.exitCode = 1;
|
|
65257
|
+
}
|
|
65258
|
+
function apiWords(answer) {
|
|
65259
|
+
const e = answer.json?.error;
|
|
65260
|
+
return typeof e === "string" && e ? e : `the compute API answered ${answer.status}`;
|
|
65261
|
+
}
|
|
65262
|
+
function apiCode(answer) {
|
|
65263
|
+
const c = answer.json?.code;
|
|
65264
|
+
return typeof c === "string" && c ? c : `http_${answer.status}`;
|
|
65265
|
+
}
|
|
65266
|
+
async function payingKey(opts) {
|
|
65267
|
+
let keys2;
|
|
65268
|
+
try {
|
|
65269
|
+
keys2 = await requirePasswordsKey();
|
|
65270
|
+
} catch (err) {
|
|
65271
|
+
fail(opts, err.message, "no_account");
|
|
65272
|
+
return null;
|
|
65273
|
+
}
|
|
65274
|
+
if (keys2.state.keyOnly) {
|
|
65275
|
+
fail(
|
|
65276
|
+
opts,
|
|
65277
|
+
"this machine runs on a login key with no words, and a machine is paid for and owned by a key that signs: run `agentgates init` here, or set AGENTGATES_PASSWORDS_SEED",
|
|
65278
|
+
"words_required"
|
|
65279
|
+
);
|
|
65280
|
+
return null;
|
|
65281
|
+
}
|
|
65282
|
+
return keys2.wallet;
|
|
65283
|
+
}
|
|
65284
|
+
async function computePlans(opts) {
|
|
65285
|
+
const res = await fetch(`${computeOrigin()}${CATALOG_PATH}`, { headers: { accept: "application/json" } });
|
|
65286
|
+
if (!res.ok) throw new Error(`compute catalog: HTTP ${res.status}`);
|
|
65287
|
+
const body = await res.json();
|
|
65288
|
+
if (opts.json) {
|
|
65289
|
+
say(JSON.stringify(body, null, 2) + "\n");
|
|
65290
|
+
return;
|
|
65291
|
+
}
|
|
65292
|
+
const plans = body.plans ?? [];
|
|
65293
|
+
if (plans.length === 0) {
|
|
65294
|
+
say(` ${import_picocolors3.default.dim("No plans are on sale right now.")}
|
|
65295
|
+
`);
|
|
65296
|
+
return;
|
|
65297
|
+
}
|
|
65298
|
+
say(`
|
|
65299
|
+
${import_picocolors3.default.bold("CONFIDENTIAL VIRTUAL MACHINES")} ${import_picocolors3.default.dim("memory encrypted in use")}
|
|
65300
|
+
|
|
65301
|
+
`);
|
|
65302
|
+
for (const p of plans) {
|
|
65303
|
+
const spec = `${p.vcpu} vCPU \xB7 ${Math.round(p.memoryMb / 1024)} GB \xB7 ${p.diskGb}GB disk`;
|
|
65304
|
+
say(` ${import_picocolors3.default.bold(p.name.padEnd(10))} ${import_picocolors3.default.cyan(money(p.priceUsdPerHour))}${import_picocolors3.default.dim("/hour")} ${import_picocolors3.default.dim(spec)}
|
|
65305
|
+
`);
|
|
65306
|
+
say(` ${import_picocolors3.default.dim(p.id.padEnd(10))} ${import_picocolors3.default.dim(`${p.egressQuotaGb} GB traffic`)}
|
|
65307
|
+
`);
|
|
65308
|
+
const ladder = p.pricing.map((r) => `${r.hoursPerPayment}h ${money(r.totalUsd)}`).join(" ");
|
|
65309
|
+
if (ladder) say(` ${import_picocolors3.default.dim(ladder)}
|
|
65310
|
+
`);
|
|
65311
|
+
say("\n");
|
|
65312
|
+
}
|
|
65313
|
+
const nets = body.payment?.networks ?? [];
|
|
65314
|
+
if (nets.length) say(` ${import_picocolors3.default.dim(`USDC on ${nets.join(", ")}`)}
|
|
65315
|
+
`);
|
|
65316
|
+
say(` ${import_picocolors3.default.dim("rent one: agentgates compute buy --plan <id> --hours 1 --image <image> (--quote prices it, signs nothing)")}
|
|
65317
|
+
|
|
65318
|
+
`);
|
|
65319
|
+
}
|
|
65320
|
+
async function readCompose(file) {
|
|
65321
|
+
if (file === "-") {
|
|
65322
|
+
const chunks = [];
|
|
65323
|
+
for await (const chunk of process.stdin) chunks.push(Buffer.from(chunk));
|
|
65324
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
65325
|
+
}
|
|
65326
|
+
try {
|
|
65327
|
+
return await fs8.readFile(file, "utf8");
|
|
65328
|
+
} catch (err) {
|
|
65329
|
+
throw new Error(`could not read the compose file ${file}: ${err.code ?? err.message}`);
|
|
65330
|
+
}
|
|
65331
|
+
}
|
|
65332
|
+
function microOfUsd(raw) {
|
|
65333
|
+
const m = /^\s*\$?(\d+)(?:\.(\d{1,6}))?\s*$/.exec(raw);
|
|
65334
|
+
if (!m) throw new Error(`--max-usd takes dollars, like 1 or 0.5 (got "${raw}")`);
|
|
65335
|
+
return BigInt(m[1]) * 1000000n + BigInt((m[2] ?? "").padEnd(6, "0"));
|
|
65336
|
+
}
|
|
65337
|
+
function legView(leg) {
|
|
65338
|
+
let amount = null;
|
|
65339
|
+
try {
|
|
65340
|
+
amount = leg.maxAmountRequired ? usd(BigInt(leg.maxAmountRequired)) : null;
|
|
65341
|
+
} catch {
|
|
65342
|
+
amount = null;
|
|
65343
|
+
}
|
|
65344
|
+
return {
|
|
65345
|
+
network: leg.network ?? "?",
|
|
65346
|
+
amountUsd: amount,
|
|
65347
|
+
amountAtomic: leg.maxAmountRequired ?? null,
|
|
65348
|
+
payTo: leg.payTo ?? null,
|
|
65349
|
+
asset: leg.asset ?? null,
|
|
65350
|
+
validSeconds: leg.maxTimeoutSeconds ?? null
|
|
65351
|
+
};
|
|
65352
|
+
}
|
|
65353
|
+
async function computeBuy(opts) {
|
|
65354
|
+
let body;
|
|
65355
|
+
try {
|
|
65356
|
+
const compose = opts.compose !== void 0 ? await readCompose(opts.compose) : void 0;
|
|
65357
|
+
body = createBody({
|
|
65358
|
+
plan: opts.plan,
|
|
65359
|
+
hours: opts.hours,
|
|
65360
|
+
image: opts.image,
|
|
65361
|
+
port: opts.port,
|
|
65362
|
+
compose,
|
|
65363
|
+
env: parseEnvPairs(opts.env),
|
|
65364
|
+
name: opts.name
|
|
65365
|
+
});
|
|
65366
|
+
} catch (err) {
|
|
65367
|
+
fail(opts, err.message, "bad_input");
|
|
65368
|
+
return;
|
|
65369
|
+
}
|
|
65370
|
+
const what = `${String(body.plan)}, ${String(body.hours)} h, ${typeof body.image === "string" ? body.image : "your compose"}`;
|
|
65371
|
+
await payFor(opts, { url: `${computeOrigin()}${DEPLOYMENTS_PATH}`, body, what, action: "buy" });
|
|
65372
|
+
}
|
|
65373
|
+
async function computeRenew(id2, opts) {
|
|
65374
|
+
let path8;
|
|
65375
|
+
let hours;
|
|
65376
|
+
try {
|
|
65377
|
+
path8 = deploymentPath(id2, "renew");
|
|
65378
|
+
hours = positiveInt(opts.hours, "--hours");
|
|
65379
|
+
} catch (err) {
|
|
65380
|
+
fail(opts, err.message, "bad_input");
|
|
65381
|
+
return;
|
|
65382
|
+
}
|
|
65383
|
+
await payFor(opts, { url: `${computeOrigin()}${path8}`, body: { hours }, what: `${hours} more h on ${id2}`, action: "renew" });
|
|
65384
|
+
}
|
|
65385
|
+
async function payFor(opts, args) {
|
|
65386
|
+
let quote;
|
|
65387
|
+
try {
|
|
65388
|
+
quote = await askPrice(args.url, args.body);
|
|
65389
|
+
} catch (err) {
|
|
65390
|
+
fail(opts, `the compute API did not answer: ${err.message}`, "unreachable");
|
|
65391
|
+
return;
|
|
65392
|
+
}
|
|
65393
|
+
if (quote.status !== 402) {
|
|
65394
|
+
if (quote.status >= 200 && quote.status < 300) {
|
|
65395
|
+
emitMachine(opts, quote.json, { note: "served without a payment" });
|
|
65396
|
+
return;
|
|
65397
|
+
}
|
|
65398
|
+
fail(opts, apiWords(quote), apiCode(quote), { status: quote.status });
|
|
65399
|
+
return;
|
|
65400
|
+
}
|
|
65401
|
+
const offer = quote.json;
|
|
65402
|
+
const legs = (offer.accepts ?? []).map(legView);
|
|
65403
|
+
const description = offer.accepts?.[0]?.description ?? null;
|
|
65404
|
+
if (opts.quote) {
|
|
65405
|
+
if (jsonMode(opts)) {
|
|
65406
|
+
say(JSON.stringify({ ok: true, quote: { description, resource: offer.accepts?.[0]?.resource ?? null, legs } }, null, 2) + "\n");
|
|
65407
|
+
return;
|
|
65408
|
+
}
|
|
65409
|
+
say(`
|
|
65410
|
+
${import_picocolors3.default.bold(description ?? args.what)} ${import_picocolors3.default.dim("nothing signed")}
|
|
65411
|
+
|
|
65412
|
+
`);
|
|
65413
|
+
for (const [i, l] of legs.entries()) {
|
|
65414
|
+
const evm = evmLegs({ accepts: [offer.accepts[i]] }).length > 0;
|
|
65415
|
+
say(` ${import_picocolors3.default.cyan((l.amountUsd ?? "?").padEnd(10))} ${l.network.padEnd(9)} ${import_picocolors3.default.dim(`to ${l.payTo ?? "?"}`)}${evm ? "" : import_picocolors3.default.dim(" (needs a Solana key; this CLI signs EVM legs)")}
|
|
65416
|
+
`);
|
|
65417
|
+
}
|
|
65418
|
+
say(`
|
|
65419
|
+
${import_picocolors3.default.dim("pay: the same command without --quote")}
|
|
65420
|
+
|
|
65421
|
+
`);
|
|
65422
|
+
return;
|
|
65423
|
+
}
|
|
65424
|
+
const wallet = await payingKey(opts);
|
|
65425
|
+
if (!wallet) return;
|
|
65426
|
+
const narrowed = legsOn(offer, opts.network);
|
|
65427
|
+
if (opts.network && !(narrowed.accepts ?? []).length) {
|
|
65428
|
+
fail(opts, `this price has no leg on ${opts.network} (offered: ${offeredNetworks(offer).join(", ") || "none"})`, "network_not_offered", { legs });
|
|
65429
|
+
return;
|
|
65430
|
+
}
|
|
65431
|
+
const choice = await chooseLeg(narrowed, wallet.address);
|
|
65432
|
+
let leg;
|
|
65433
|
+
let heldMicro;
|
|
65434
|
+
if (choice.ok) {
|
|
65435
|
+
leg = choice.leg;
|
|
65436
|
+
heldMicro = choice.heldMicro;
|
|
65437
|
+
} else if (choice.needMicro !== null && choice.bestHeldMicro === null) {
|
|
65438
|
+
leg = [...evmLegs(narrowed)].sort((a, b2) => a.amountMicro < b2.amountMicro ? -1 : a.amountMicro > b2.amountMicro ? 1 : 0)[0];
|
|
65439
|
+
heldMicro = null;
|
|
65440
|
+
} else {
|
|
65441
|
+
const need2 = choice.needMicro === null ? null : usd(choice.needMicro);
|
|
65442
|
+
const held3 = choice.bestHeldMicro === null ? null : usd(choice.bestHeldMicro);
|
|
65443
|
+
const evmNets = evmLegs(narrowed).map((l) => l.network);
|
|
65444
|
+
const sentence = need2 && held3 ? `${choice.reason}. It costs ${need2} and this key holds ${held3}. Send USDC to ${wallet.address} on ${evmNets.join(" or ") || "an offered network"}, then run this again` : choice.reason;
|
|
65445
|
+
fail(opts, sentence, need2 && held3 ? "insufficient_funds" : "no_signable_leg", { address: wallet.address, legs });
|
|
65446
|
+
return;
|
|
65447
|
+
}
|
|
65448
|
+
const price = usd(leg.amountMicro);
|
|
65449
|
+
if (opts.maxUsd !== void 0) {
|
|
65450
|
+
let ceiling;
|
|
65451
|
+
try {
|
|
65452
|
+
ceiling = microOfUsd(opts.maxUsd);
|
|
65453
|
+
} catch (err) {
|
|
65454
|
+
fail(opts, err.message, "bad_input");
|
|
65455
|
+
return;
|
|
65456
|
+
}
|
|
65457
|
+
if (leg.amountMicro > ceiling) {
|
|
65458
|
+
fail(opts, `the price is ${price} on ${leg.network}, over --max-usd ${usd(ceiling)}: nothing was signed`, "over_max", { legs });
|
|
65459
|
+
return;
|
|
65460
|
+
}
|
|
65461
|
+
}
|
|
65462
|
+
if (!opts.yes) {
|
|
65463
|
+
if (jsonMode(opts) || !process.stdin.isTTY) {
|
|
65464
|
+
fail(opts, `pass --yes to pay ${price} on ${leg.network} without a prompt: nothing was signed`, "confirm_required", { legs });
|
|
65465
|
+
return;
|
|
65466
|
+
}
|
|
65467
|
+
say(`
|
|
65468
|
+
${import_picocolors3.default.bold(description ?? args.what)}
|
|
65469
|
+
`);
|
|
65470
|
+
const holds = heldMicro === null ? "this key's balance could not be read" : `this key holds ${usd(heldMicro)} there`;
|
|
65471
|
+
say(` ${import_picocolors3.default.dim(`pay ${price} USDC on ${leg.network} to ${leg.payTo} \xB7 ${holds} \xB7 no gas`)}
|
|
65472
|
+
`);
|
|
65473
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
65474
|
+
let answer = "";
|
|
65475
|
+
try {
|
|
65476
|
+
answer = (await rl.question(` Pay? [y/N] `)).trim().toLowerCase();
|
|
65477
|
+
} catch {
|
|
65478
|
+
answer = "";
|
|
65479
|
+
} finally {
|
|
65480
|
+
rl.close();
|
|
65481
|
+
}
|
|
65482
|
+
if (answer !== "y" && answer !== "yes") {
|
|
65483
|
+
say(` ${import_picocolors3.default.dim("Nothing paid.")}
|
|
65484
|
+
|
|
65485
|
+
`);
|
|
65486
|
+
return;
|
|
65487
|
+
}
|
|
65488
|
+
}
|
|
65489
|
+
const signed2 = await signLeg(leg, wallet.privateKey);
|
|
65490
|
+
const paid = { network: leg.network, amountUsd: price, amountAtomic: leg.amountMicro.toString(), from: signed2.from, nonce: signed2.nonce };
|
|
65491
|
+
if (!jsonMode(opts)) say(` ${import_picocolors3.default.dim(`paying ${price} on ${leg.network}`)}
|
|
65492
|
+
`);
|
|
65493
|
+
else sayErr(`${JSON.stringify({ event: "paid", ...paid })}
|
|
65494
|
+
`);
|
|
65495
|
+
const outcome = await sendPaid({
|
|
65496
|
+
url: args.url,
|
|
65497
|
+
body: args.body,
|
|
65498
|
+
payment: signed2.header,
|
|
65499
|
+
onRetry: (why, attempt, waitMs) => {
|
|
65500
|
+
if (!jsonMode(opts)) {
|
|
65501
|
+
say(` ${import_picocolors3.default.dim(`no clear answer yet (${why}); sending the same payment again in ${Math.round(waitMs / 1e3)} s (${attempt})`)}
|
|
65502
|
+
`);
|
|
65503
|
+
}
|
|
65504
|
+
}
|
|
65505
|
+
});
|
|
65506
|
+
if (outcome.kind === "no_answer") {
|
|
65507
|
+
fail(
|
|
65508
|
+
opts,
|
|
65509
|
+
`no clear answer after ${outcome.attempts} tries (${outcome.error}). The payment may have settled: do not pay again. \`agentgates compute list\` shows what it bought`,
|
|
65510
|
+
"no_answer",
|
|
65511
|
+
{ paid }
|
|
65512
|
+
);
|
|
65513
|
+
return;
|
|
65514
|
+
}
|
|
65515
|
+
if (outcome.kind === "refused") {
|
|
65516
|
+
const a = outcome.answer;
|
|
65517
|
+
const resent = outcome.attempts > 1;
|
|
65518
|
+
const charged = resent ? "The first send may have settled: do not pay again; `agentgates compute list` shows what it bought" : "Nothing was charged";
|
|
65519
|
+
if (a.status === 402 && a.json?.code === "insufficient_funds") {
|
|
65520
|
+
const need2 = typeof a.json.needUsd === "string" ? `$${a.json.needUsd}` : price;
|
|
65521
|
+
const have = typeof a.json.haveUsd === "string" ? `$${a.json.haveUsd}` : null;
|
|
65522
|
+
fail(
|
|
65523
|
+
opts,
|
|
65524
|
+
`not enough USDC on ${a.json.network ?? leg.network}: it costs ${need2}${have ? ` and ${signed2.from} holds ${have}` : ""}. ${charged}`,
|
|
65525
|
+
"insufficient_funds",
|
|
65526
|
+
{ status: a.status, needUsd: a.json.needUsd ?? null, haveUsd: a.json.haveUsd ?? null, paid }
|
|
65527
|
+
);
|
|
65528
|
+
return;
|
|
65529
|
+
}
|
|
65530
|
+
if (a.status === 402) {
|
|
65531
|
+
fail(
|
|
65532
|
+
opts,
|
|
65533
|
+
resent ? `the payment was refused on a resend: ${apiWords(a)}. ${charged}` : `the payment was refused and nothing was charged: ${apiWords(a)}`,
|
|
65534
|
+
apiCode(a) === "http_402" ? "payment_refused" : apiCode(a),
|
|
65535
|
+
{ status: a.status, paid, resent }
|
|
65536
|
+
);
|
|
65537
|
+
return;
|
|
65538
|
+
}
|
|
65539
|
+
if (a.json?.code === "payment_already_spent") {
|
|
65540
|
+
fail(opts, `${apiWords(a)} (\`agentgates compute list\`)`, "payment_already_spent", { status: a.status, paid });
|
|
65541
|
+
return;
|
|
65542
|
+
}
|
|
65543
|
+
fail(opts, apiWords(a), apiCode(a), { status: a.status, paid });
|
|
65544
|
+
return;
|
|
65545
|
+
}
|
|
65546
|
+
const machine = outcome.answer.json;
|
|
65547
|
+
const note2 = machine.alreadyPaid === true ? "this payment had already bought it; nothing was charged again" : null;
|
|
65548
|
+
if (!(opts.wait && args.action === "buy" && machine.deploymentId)) {
|
|
65549
|
+
emitMachine(opts, machine, { paid, note: note2, next: args.action === "buy" });
|
|
65550
|
+
return;
|
|
65551
|
+
}
|
|
65552
|
+
if (!jsonMode(opts)) emitMachine(opts, machine, { paid, note: note2, next: false });
|
|
65553
|
+
else sayErr(`${JSON.stringify({ event: "machine", deploymentId: machine.deploymentId ?? null, status: machine.status ?? null })}
|
|
65554
|
+
`);
|
|
65555
|
+
await waitAndReport(opts, wallet, machine.deploymentId ?? "", { paid, deploymentId: machine.deploymentId ?? null });
|
|
65556
|
+
}
|
|
65557
|
+
function readRefused(opts, answer, wallet, extra = {}) {
|
|
65558
|
+
const words7 = apiWords(answer);
|
|
65559
|
+
const hint = answer.status === 404 ? ` (this key is ${wallet.address})` : "";
|
|
65560
|
+
fail(opts, `${words7}${hint}`, apiCode(answer), { status: answer.status, signer: wallet.address, ...extra });
|
|
65561
|
+
}
|
|
65562
|
+
async function computeList(opts) {
|
|
65563
|
+
const wallet = await payingKey(opts);
|
|
65564
|
+
if (!wallet) return;
|
|
65565
|
+
let answer;
|
|
65566
|
+
try {
|
|
65567
|
+
answer = await ownerGet(wallet, DEPLOYMENTS_PATH);
|
|
65568
|
+
} catch (err) {
|
|
65569
|
+
fail(opts, `the compute API did not answer: ${err.message}`, "unreachable");
|
|
65570
|
+
return;
|
|
65571
|
+
}
|
|
65572
|
+
if (answer.status !== 200) {
|
|
65573
|
+
readRefused(opts, answer, wallet);
|
|
65574
|
+
return;
|
|
65575
|
+
}
|
|
65576
|
+
const machines = Array.isArray(answer.json.deployments) ? answer.json.deployments : [];
|
|
65577
|
+
if (jsonMode(opts)) {
|
|
65578
|
+
say(JSON.stringify({ ok: true, owner: wallet.address, deployments: machines }, null, 2) + "\n");
|
|
65579
|
+
return;
|
|
65580
|
+
}
|
|
65581
|
+
say(`
|
|
65582
|
+
${import_picocolors3.default.bold("MACHINES")} ${import_picocolors3.default.dim(`owned by ${wallet.address}`)}
|
|
65583
|
+
|
|
65584
|
+
`);
|
|
65585
|
+
if (machines.length === 0) {
|
|
65586
|
+
say(` ${import_picocolors3.default.dim("None yet. Rent one: agentgates compute buy --plan <id> --hours 1 --image <image>")}
|
|
65587
|
+
|
|
65588
|
+
`);
|
|
65589
|
+
return;
|
|
65590
|
+
}
|
|
65591
|
+
for (const m of machines) say(`${machineLines(m)}
|
|
65592
|
+
|
|
65593
|
+
`);
|
|
65594
|
+
}
|
|
65595
|
+
async function computeStatus(id2, opts) {
|
|
65596
|
+
let path8;
|
|
65597
|
+
try {
|
|
65598
|
+
path8 = deploymentPath(id2);
|
|
65599
|
+
} catch (err) {
|
|
65600
|
+
fail(opts, err.message, "bad_input");
|
|
65601
|
+
return;
|
|
65602
|
+
}
|
|
65603
|
+
const wallet = await payingKey(opts);
|
|
65604
|
+
if (!wallet) return;
|
|
65605
|
+
let answer;
|
|
65606
|
+
try {
|
|
65607
|
+
answer = await ownerGet(wallet, path8);
|
|
65608
|
+
} catch (err) {
|
|
65609
|
+
fail(opts, `the compute API did not answer: ${err.message}`, "unreachable");
|
|
65610
|
+
return;
|
|
65611
|
+
}
|
|
65612
|
+
if (answer.status !== 200) {
|
|
65613
|
+
readRefused(opts, answer, wallet);
|
|
65614
|
+
return;
|
|
65615
|
+
}
|
|
65616
|
+
const machine = answer.json;
|
|
65617
|
+
if (jsonMode(opts)) {
|
|
65618
|
+
say(JSON.stringify({ ok: true, deployment: machine }, null, 2) + "\n");
|
|
65619
|
+
return;
|
|
65620
|
+
}
|
|
65621
|
+
say(`
|
|
65622
|
+
${machineLines(machine)}
|
|
65623
|
+
`);
|
|
65624
|
+
const invoices = Array.isArray(machine.invoices) ? machine.invoices.length : 0;
|
|
65625
|
+
if (invoices) say(` ${import_picocolors3.default.dim(`${invoices} payment${invoices === 1 ? "" : "s"} on record`)}
|
|
65626
|
+
`);
|
|
65627
|
+
if (machine.attestation) say(` ${import_picocolors3.default.dim("attestation: live (--json carries the quote)")}
|
|
65628
|
+
`);
|
|
65629
|
+
say("\n");
|
|
65630
|
+
}
|
|
65631
|
+
async function computeWait(id2, opts) {
|
|
65632
|
+
try {
|
|
65633
|
+
deploymentPath(id2);
|
|
65634
|
+
} catch (err) {
|
|
65635
|
+
fail(opts, err.message, "bad_input");
|
|
65636
|
+
return;
|
|
65637
|
+
}
|
|
65638
|
+
const wallet = await payingKey(opts);
|
|
65639
|
+
if (!wallet) return;
|
|
65640
|
+
await waitAndReport(opts, wallet, id2, {});
|
|
65641
|
+
}
|
|
65642
|
+
async function waitAndReport(opts, wallet, id2, extra) {
|
|
65643
|
+
let minutes;
|
|
65644
|
+
try {
|
|
65645
|
+
minutes = opts.timeout === void 0 ? 15 : positiveInt(opts.timeout, "--timeout");
|
|
65646
|
+
} catch (err) {
|
|
65647
|
+
fail(opts, err.message, "bad_input");
|
|
65648
|
+
return;
|
|
65649
|
+
}
|
|
65650
|
+
const path8 = deploymentPath(id2);
|
|
65651
|
+
let lastStatus = "";
|
|
65652
|
+
const started = Date.now();
|
|
65653
|
+
const outcome = await waitUntilRunning({
|
|
65654
|
+
read: () => ownerGet(wallet, path8),
|
|
65655
|
+
timeoutMs: minutes * 6e4,
|
|
65656
|
+
onTick: (m) => {
|
|
65657
|
+
if (jsonMode(opts) || m.status === lastStatus) return;
|
|
65658
|
+
lastStatus = m.status ?? "";
|
|
65659
|
+
say(` ${import_picocolors3.default.dim(`${lastStatus} \xB7 ${Math.round((Date.now() - started) / 1e3)} s`)}
|
|
65660
|
+
`);
|
|
65661
|
+
}
|
|
65662
|
+
});
|
|
65663
|
+
if (outcome.kind === "running") {
|
|
65664
|
+
emitMachine(opts, outcome.machine, { paid: extra.paid, note: "running", next: false });
|
|
65665
|
+
return;
|
|
65666
|
+
}
|
|
65667
|
+
if (outcome.kind === "refused") {
|
|
65668
|
+
readRefused(opts, outcome.answer, wallet, extra);
|
|
65669
|
+
return;
|
|
65670
|
+
}
|
|
65671
|
+
if (outcome.kind === "ended") {
|
|
65672
|
+
const m = outcome.machine;
|
|
65673
|
+
fail(opts, `the machine is ${m.status}${m.killReason ? ` (${m.killReason})` : ""}, and will not run by itself`, "not_running", { deployment: m, ...extra });
|
|
65674
|
+
return;
|
|
65675
|
+
}
|
|
65676
|
+
fail(
|
|
65677
|
+
opts,
|
|
65678
|
+
`still ${outcome.machine?.status ?? "unread"} after ${minutes} min; the clock starts only when it runs. Wait again: agentgates compute wait ${id2}`,
|
|
65679
|
+
"timeout",
|
|
65680
|
+
{ deployment: outcome.machine, ...extra }
|
|
65681
|
+
);
|
|
65682
|
+
}
|
|
65683
|
+
function statusWord(status4) {
|
|
65684
|
+
const s = status4 ?? "?";
|
|
65685
|
+
if (s === "running") return import_picocolors3.default.green(s);
|
|
65686
|
+
if (s === "provisioning" || s === "stopped") return import_picocolors3.default.yellow(s);
|
|
65687
|
+
if (s === "failed" || s === "destroyed" || s === "grace" || s === "suspended") return import_picocolors3.default.red(s);
|
|
65688
|
+
return s;
|
|
65689
|
+
}
|
|
65690
|
+
function inWords(iso) {
|
|
65691
|
+
if (!iso) return "";
|
|
65692
|
+
const ms = Date.parse(iso) - Date.now();
|
|
65693
|
+
if (!Number.isFinite(ms)) return "";
|
|
65694
|
+
const mins = Math.round(Math.abs(ms) / 6e4);
|
|
65695
|
+
const span = mins < 90 ? `${mins} min` : mins < 48 * 60 ? `${Math.round(mins / 60)} h` : `${Math.round(mins / 1440)} days`;
|
|
65696
|
+
return ms >= 0 ? `in ${span}` : `${span} ago`;
|
|
65697
|
+
}
|
|
65698
|
+
function machineLines(m) {
|
|
65699
|
+
const head = ` ${import_picocolors3.default.bold(m.deploymentId ?? "?")} ${statusWord(m.status)} ${import_picocolors3.default.dim(`${m.plan ?? ""}${m.name ? ` \xB7 ${m.name}` : ""}`)}`;
|
|
65700
|
+
const lines = [head];
|
|
65701
|
+
if (m.endpoint) lines.push(` endpoint ${import_picocolors3.default.cyan(m.endpoint)}`);
|
|
65702
|
+
if (m.expiresAt) lines.push(` paid to ${m.expiresAt} ${import_picocolors3.default.dim(inWords(m.expiresAt))}`);
|
|
65703
|
+
else if (m.status === "provisioning") lines.push(` ${import_picocolors3.default.dim("the clock starts when it runs")}`);
|
|
65704
|
+
if (m.killReason) lines.push(` ${import_picocolors3.default.dim(`ended: ${m.killReason}`)}`);
|
|
65705
|
+
if (m.verifyUrl) lines.push(` verify ${import_picocolors3.default.dim(`${computeOrigin()}${m.verifyUrl}`)}`);
|
|
65706
|
+
return lines.join("\n");
|
|
65707
|
+
}
|
|
65708
|
+
function emitMachine(opts, machine, extra) {
|
|
65709
|
+
if (jsonMode(opts)) {
|
|
65710
|
+
say(
|
|
65711
|
+
JSON.stringify(
|
|
65712
|
+
{ ok: true, deployment: machine, ...extra.paid ? { paid: extra.paid } : {}, ...extra.note ? { note: extra.note } : {} },
|
|
65713
|
+
null,
|
|
65714
|
+
2
|
|
65715
|
+
) + "\n"
|
|
65716
|
+
);
|
|
65717
|
+
return;
|
|
65718
|
+
}
|
|
65719
|
+
say(`
|
|
65720
|
+
${import_picocolors3.default.green("\u2713")} ${extra.note ?? (extra.paid ? `paid ${extra.paid.amountUsd} on ${extra.paid.network}` : "ready")}
|
|
65721
|
+
|
|
65722
|
+
`);
|
|
65723
|
+
say(`${machineLines(machine)}
|
|
65724
|
+
|
|
65725
|
+
`);
|
|
65726
|
+
if (extra.next && machine.deploymentId && machine.status !== "running") {
|
|
65727
|
+
say(` ${import_picocolors3.default.dim(`wait for it: agentgates compute wait ${machine.deploymentId}`)}
|
|
65728
|
+
|
|
65729
|
+
`);
|
|
65730
|
+
}
|
|
65731
|
+
}
|
|
65732
|
+
|
|
65108
65733
|
// src/commands/inference.ts
|
|
65734
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
65735
|
+
init_passwords_wire();
|
|
65109
65736
|
init_constants();
|
|
65110
|
-
var
|
|
65737
|
+
var SITE = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
65111
65738
|
function applyFilters(models, f2) {
|
|
65112
65739
|
let out = models;
|
|
65113
65740
|
if (f2.tier === "confidential") out = out.filter((m) => m.confidential);
|
|
@@ -65123,7 +65750,7 @@ function applyFilters(models, f2) {
|
|
|
65123
65750
|
var hasFilters = (f2) => Boolean(f2.tier || (f2.tag ?? []).length || f2.org || f2.search);
|
|
65124
65751
|
var ctx = (n2) => n2 >= 1e6 ? `${Math.round(n2 / 1e6)}M` : `${Math.round(n2 / 1e3)}k`;
|
|
65125
65752
|
async function inferenceModels(opts) {
|
|
65126
|
-
const res = await fetch(`${
|
|
65753
|
+
const res = await fetch(`${SITE}/api/inference/catalog`, { headers: { accept: "application/json" } });
|
|
65127
65754
|
if (!res.ok) throw new Error(`inference catalog: HTTP ${res.status}`);
|
|
65128
65755
|
const body = await res.json();
|
|
65129
65756
|
const all = body.models ?? [];
|
|
@@ -65304,8 +65931,8 @@ async function inferenceTopUp(amountUsd, opts = {}) {
|
|
|
65304
65931
|
}
|
|
65305
65932
|
const choice = await chooseLeg(quote.json, wallet.address);
|
|
65306
65933
|
if (!choice.ok) {
|
|
65307
|
-
const need2 = choice.needMicro === null ? null :
|
|
65308
|
-
const held3 = choice.bestHeldMicro === null ? null :
|
|
65934
|
+
const need2 = choice.needMicro === null ? null : usd(choice.needMicro);
|
|
65935
|
+
const held3 = choice.bestHeldMicro === null ? null : usd(choice.bestHeldMicro);
|
|
65309
65936
|
const sentence = need2 && held3 ? `${choice.reason}. The top-up costs ${need2} and this key holds ${held3}. Send USDC to ${wallet.address} on base, polygon or arbitrum` : choice.reason;
|
|
65310
65937
|
process.stdout.write(opts.json ? `${JSON.stringify({ ok: false, error: sentence })}
|
|
65311
65938
|
` : `
|
|
@@ -65315,7 +65942,7 @@ async function inferenceTopUp(amountUsd, opts = {}) {
|
|
|
65315
65942
|
return;
|
|
65316
65943
|
}
|
|
65317
65944
|
if (!opts.json) process.stdout.write(`
|
|
65318
|
-
${import_picocolors4.default.dim(`paying ${
|
|
65945
|
+
${import_picocolors4.default.dim(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`)}
|
|
65319
65946
|
`);
|
|
65320
65947
|
const signed2 = await signLeg(choice.leg, wallet.privateKey);
|
|
65321
65948
|
const paid = await post3(signed2.header);
|
|
@@ -65365,7 +65992,7 @@ async function inferenceAsk(words7, opts = {}) {
|
|
|
65365
65992
|
};
|
|
65366
65993
|
const quote = await post3(null);
|
|
65367
65994
|
if (quote.status === 200) {
|
|
65368
|
-
|
|
65995
|
+
say2(opts, quote.json);
|
|
65369
65996
|
return;
|
|
65370
65997
|
}
|
|
65371
65998
|
if (quote.status !== 402) {
|
|
@@ -65380,8 +66007,8 @@ async function inferenceAsk(words7, opts = {}) {
|
|
|
65380
66007
|
}
|
|
65381
66008
|
const choice = await chooseLeg(quote.json, wallet.address);
|
|
65382
66009
|
if (!choice.ok) {
|
|
65383
|
-
const need2 = choice.needMicro === null ? null :
|
|
65384
|
-
const held3 = choice.bestHeldMicro === null ? null :
|
|
66010
|
+
const need2 = choice.needMicro === null ? null : usd(choice.needMicro);
|
|
66011
|
+
const held3 = choice.bestHeldMicro === null ? null : usd(choice.bestHeldMicro);
|
|
65385
66012
|
const sentence = need2 && held3 ? `${choice.reason}. The ask costs ${need2} and this key holds ${held3}. Send USDC to ${wallet.address} on base, polygon or arbitrum and it pays for itself` : choice.reason;
|
|
65386
66013
|
process.stdout.write(
|
|
65387
66014
|
opts.json ? `${JSON.stringify({ ok: false, error: sentence })}
|
|
@@ -65393,7 +66020,7 @@ async function inferenceAsk(words7, opts = {}) {
|
|
|
65393
66020
|
return;
|
|
65394
66021
|
}
|
|
65395
66022
|
if (!opts.json) process.stdout.write(`
|
|
65396
|
-
${import_picocolors4.default.dim(`paying ${
|
|
66023
|
+
${import_picocolors4.default.dim(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`)}
|
|
65397
66024
|
`);
|
|
65398
66025
|
const signed2 = await signLeg(choice.leg, wallet.privateKey);
|
|
65399
66026
|
const paid = await post3(signed2.header);
|
|
@@ -65408,9 +66035,9 @@ async function inferenceAsk(words7, opts = {}) {
|
|
|
65408
66035
|
);
|
|
65409
66036
|
return;
|
|
65410
66037
|
}
|
|
65411
|
-
|
|
66038
|
+
say2(opts, paid.json);
|
|
65412
66039
|
}
|
|
65413
|
-
function
|
|
66040
|
+
function say2(opts, answer) {
|
|
65414
66041
|
if (opts.json || !process.stdout.isTTY) {
|
|
65415
66042
|
process.stdout.write(`${JSON.stringify(answer)}
|
|
65416
66043
|
`);
|
|
@@ -68967,14 +69594,18 @@ function codeFrom(text, pattern) {
|
|
|
68967
69594
|
return null;
|
|
68968
69595
|
}
|
|
68969
69596
|
}
|
|
68970
|
-
const
|
|
69597
|
+
const words7 = withoutLinks(haystack);
|
|
69598
|
+
const labeled = words7.split(/\r?\n/).filter((line2) => /\b(code|verification|verify|otp|pin|passcode|one[- ]time)\b/i.test(line2));
|
|
68971
69599
|
for (const line2 of labeled) {
|
|
68972
69600
|
const m = line2.match(/\b\d{4,8}\b/);
|
|
68973
69601
|
if (m) return m[0];
|
|
68974
69602
|
}
|
|
68975
|
-
const anywhere =
|
|
69603
|
+
const anywhere = words7.match(/\b\d{4,8}\b/);
|
|
68976
69604
|
return anywhere ? anywhere[0] : null;
|
|
68977
69605
|
}
|
|
69606
|
+
function withoutLinks(text) {
|
|
69607
|
+
return text.replace(/https?:\/\/[^\s"'<>]+/g, " ");
|
|
69608
|
+
}
|
|
68978
69609
|
|
|
68979
69610
|
// src/lib/seal-grants.ts
|
|
68980
69611
|
init_passwords_wire();
|
|
@@ -69126,6 +69757,7 @@ import { writeFileSync } from "node:fs";
|
|
|
69126
69757
|
|
|
69127
69758
|
// src/lib/payphone-wire.ts
|
|
69128
69759
|
init_constants();
|
|
69760
|
+
init_lib2();
|
|
69129
69761
|
init_passwords_wire();
|
|
69130
69762
|
async function wakeTheOperator() {
|
|
69131
69763
|
try {
|
|
@@ -69144,9 +69776,10 @@ function isWaking(status4, error) {
|
|
|
69144
69776
|
var WAKE_WAIT_MS = 24e4;
|
|
69145
69777
|
var WAKE_POLL_MS = 1e4;
|
|
69146
69778
|
var PAYPHONE_MINUTES = [1, 2, 5, 10];
|
|
69147
|
-
async function post(body, payment, timeoutMs) {
|
|
69779
|
+
async function post(body, payment, timeoutMs, payer) {
|
|
69148
69780
|
const headers = { "content-type": "application/json", "user-agent": CLI_USER_AGENT };
|
|
69149
69781
|
if (payment) headers["X-PAYMENT"] = payment;
|
|
69782
|
+
if (payment && payer) headers["X-Wallet-Auth"] = await ownerAuthHeader(payer, "POST", lanePath("/booth"));
|
|
69150
69783
|
const res = await fetch(`${siteOrigin()}${lanePath("/booth")}`, {
|
|
69151
69784
|
method: "POST",
|
|
69152
69785
|
headers,
|
|
@@ -69169,14 +69802,15 @@ async function payphoneCall(args) {
|
|
|
69169
69802
|
}
|
|
69170
69803
|
const choice = await chooseLeg(quote.json, args.address);
|
|
69171
69804
|
if (!choice.ok) {
|
|
69172
|
-
const need2 = choice.needMicro === null ? null :
|
|
69173
|
-
const held3 = choice.bestHeldMicro === null ? null :
|
|
69805
|
+
const need2 = choice.needMicro === null ? null : usd(choice.needMicro);
|
|
69806
|
+
const held3 = choice.bestHeldMicro === null ? null : usd(choice.bestHeldMicro);
|
|
69174
69807
|
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;
|
|
69175
69808
|
throw new WireError(402, "payphone_unfunded", shortfall, quote.json);
|
|
69176
69809
|
}
|
|
69177
|
-
args.onQuote?.(`paying ${
|
|
69810
|
+
args.onQuote?.(`paying ${usd(choice.leg.amountMicro)} on ${choice.leg.network}`);
|
|
69178
69811
|
const signed2 = await signLeg(choice.leg, args.privateKey);
|
|
69179
|
-
|
|
69812
|
+
const payer = new ethers_exports.Wallet(args.privateKey);
|
|
69813
|
+
let paid = await post(body, signed2.header, 18e4, payer);
|
|
69180
69814
|
if (paid.status >= 400) {
|
|
69181
69815
|
const first = typeof paid.json.error === "string" ? paid.json.error : "";
|
|
69182
69816
|
if (isWaking(paid.status, first)) {
|
|
@@ -69184,7 +69818,7 @@ async function payphoneCall(args) {
|
|
|
69184
69818
|
const deadline = Date.now() + WAKE_WAIT_MS;
|
|
69185
69819
|
while (Date.now() < deadline) {
|
|
69186
69820
|
await new Promise((r) => setTimeout(r, WAKE_POLL_MS));
|
|
69187
|
-
paid = await post(body, signed2.header, 18e4);
|
|
69821
|
+
paid = await post(body, signed2.header, 18e4, payer);
|
|
69188
69822
|
if (paid.status < 400) break;
|
|
69189
69823
|
const again = typeof paid.json.error === "string" ? paid.json.error : "";
|
|
69190
69824
|
if (!isWaking(paid.status, again)) break;
|
|
@@ -69199,10 +69833,10 @@ async function payphoneCall(args) {
|
|
|
69199
69833
|
const call = paid.json.call ?? paid.json.booth ?? paid.json ?? {};
|
|
69200
69834
|
return { call, payment: signed2.header, body, paidMicro: choice.leg.amountMicro, network: choice.leg.network, from: signed2.from };
|
|
69201
69835
|
}
|
|
69202
|
-
async function payphoneRead(payment, asked, what) {
|
|
69836
|
+
async function payphoneRead(payment, asked, what, privateKey) {
|
|
69203
69837
|
const body = { ...asked, kind: "call" };
|
|
69204
69838
|
body[what === "read" ? "read" : "hangup"] = true;
|
|
69205
|
-
const out = await post(body, payment, 6e4);
|
|
69839
|
+
const out = await post(body, payment, 6e4, new ethers_exports.Wallet(privateKey));
|
|
69206
69840
|
if (out.status >= 400) {
|
|
69207
69841
|
const error = typeof out.json.error === "string" ? out.json.error : `the payphone answered ${out.status}`;
|
|
69208
69842
|
throw new WireError(out.status, typeof out.json.code === "string" ? out.json.code : null, error, out.json);
|
|
@@ -69211,17 +69845,17 @@ async function payphoneRead(payment, asked, what) {
|
|
|
69211
69845
|
}
|
|
69212
69846
|
|
|
69213
69847
|
// src/commands/phone.ts
|
|
69214
|
-
var
|
|
69215
|
-
var
|
|
69848
|
+
var SITE2 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
69849
|
+
var jsonMode2 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
69216
69850
|
function emit2(opts, data4, human) {
|
|
69217
|
-
if (
|
|
69851
|
+
if (jsonMode2(opts)) {
|
|
69218
69852
|
process.stdout.write(JSON.stringify(data4, null, 2) + "\n");
|
|
69219
69853
|
return;
|
|
69220
69854
|
}
|
|
69221
69855
|
human();
|
|
69222
69856
|
}
|
|
69223
69857
|
function refuse(opts, error, code, extra = {}) {
|
|
69224
|
-
if (
|
|
69858
|
+
if (jsonMode2(opts)) {
|
|
69225
69859
|
process.stdout.write(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
|
|
69226
69860
|
} else {
|
|
69227
69861
|
process.stderr.write(` ${error}${code ? import_picocolors5.default.dim(` (${code})`) : ""}
|
|
@@ -69233,7 +69867,7 @@ function failFrom(opts, err) {
|
|
|
69233
69867
|
if (err instanceof WireError) return refuse(opts, err.message, err.code, { status: err.status });
|
|
69234
69868
|
return refuse(opts, err.message ?? String(err), null);
|
|
69235
69869
|
}
|
|
69236
|
-
var
|
|
69870
|
+
var usd2 = (v) => {
|
|
69237
69871
|
const n2 = Number(v);
|
|
69238
69872
|
if (Number.isInteger(n2)) return `$${n2}`;
|
|
69239
69873
|
const [whole, frac = ""] = n2.toFixed(6).replace(/0+$/, "").split(".");
|
|
@@ -69264,7 +69898,7 @@ function phoneSlice(body) {
|
|
|
69264
69898
|
return out;
|
|
69265
69899
|
}
|
|
69266
69900
|
async function phonePricing(opts) {
|
|
69267
|
-
const res = await fetch(`${
|
|
69901
|
+
const res = await fetch(`${SITE2}/api/account/catalog`, { headers: { accept: "application/json" } });
|
|
69268
69902
|
if (!res.ok) throw new Error(`phone catalog: HTTP ${res.status}`);
|
|
69269
69903
|
const body = await res.json();
|
|
69270
69904
|
const slice = phoneSlice(body);
|
|
@@ -69285,7 +69919,7 @@ async function phonePricing(opts) {
|
|
|
69285
69919
|
`);
|
|
69286
69920
|
for (const p of plans) {
|
|
69287
69921
|
const count = p.phones ?? 1;
|
|
69288
|
-
const price =
|
|
69922
|
+
const price = usd2(p.priceUsd).padStart(4);
|
|
69289
69923
|
const term = `/${p.units} days`.padEnd(9);
|
|
69290
69924
|
process.stdout.write(` ${import_picocolors5.default.bold(p.rung.padEnd(11))} ${import_picocolors5.default.cyan(price)}${import_picocolors5.default.dim(term)} ${import_picocolors5.default.dim(`${count} number${count === 1 ? "" : "s"}`)}
|
|
69291
69925
|
`);
|
|
@@ -69295,9 +69929,9 @@ async function phonePricing(opts) {
|
|
|
69295
69929
|
const u = slice.phoneUsage;
|
|
69296
69930
|
if (u) {
|
|
69297
69931
|
const meter = [
|
|
69298
|
-
u.textUsd ? `text ${
|
|
69299
|
-
u.minuteUsd ? `call minute ${
|
|
69300
|
-
u.waitCodeUsd !== void 0 ? `wait-code ${Number(u.waitCodeUsd) === 0 ? "free" :
|
|
69932
|
+
u.textUsd ? `text ${usd2(u.textUsd)}` : "",
|
|
69933
|
+
u.minuteUsd ? `call minute ${usd2(u.minuteUsd)}` : "",
|
|
69934
|
+
u.waitCodeUsd !== void 0 ? `wait-code ${Number(u.waitCodeUsd) === 0 ? "free" : usd2(u.waitCodeUsd)}` : ""
|
|
69301
69935
|
].filter(Boolean).join(" \xB7 ");
|
|
69302
69936
|
process.stdout.write(`
|
|
69303
69937
|
${import_picocolors5.default.dim(`usage, from the prepaid balance: ${meter}`)}
|
|
@@ -69311,7 +69945,7 @@ async function phonePricing(opts) {
|
|
|
69311
69945
|
${import_picocolors5.default.bold("THE OPERATOR")} ${import_picocolors5.default.dim("our brain, voice and ears on the line; the transcript and the outcome back")}
|
|
69312
69946
|
|
|
69313
69947
|
`);
|
|
69314
|
-
process.stdout.write(` ${import_picocolors5.default.cyan(
|
|
69948
|
+
process.stdout.write(` ${import_picocolors5.default.cyan(usd2(op.minuteUsd))} ${import_picocolors5.default.dim(`a minute, all in, ${op.minutes ?? op.maxMinutes ?? "?"} minutes a call by default (--minutes up to ${op.maxMinutes ?? "?"}), from the prepaid balance`)}
|
|
69315
69949
|
`);
|
|
69316
69950
|
process.stdout.write(` ${import_picocolors5.default.dim(op.house ? 'on your number, or from the house number with none: agentgates call <number> "<what to get done>"' : 'on your number: agentgates call <number> "<what to get done>"')}
|
|
69317
69951
|
`);
|
|
@@ -69329,7 +69963,7 @@ async function phonePricing(opts) {
|
|
|
69329
69963
|
${import_picocolors5.default.bold("PAYPHONE")} ${import_picocolors5.default.dim("no plan, no number, no account: one x402 payment, one call")}
|
|
69330
69964
|
|
|
69331
69965
|
`);
|
|
69332
|
-
const ladder = windows.map((w) => `${w.minutes} min ${
|
|
69966
|
+
const ladder = windows.map((w) => `${w.minutes} min ${usd2(w.priceUsd)}${w.operatorPriceUsd ? import_picocolors5.default.dim(` (${usd2(w.operatorPriceUsd)} with the operator)`) : ""}`).join(" ");
|
|
69333
69967
|
process.stdout.write(` ${ladder}
|
|
69334
69968
|
`);
|
|
69335
69969
|
}
|
|
@@ -69353,9 +69987,9 @@ function printCall(c, from, perMinuteUsd, full, key = null) {
|
|
|
69353
69987
|
const { task, lines, shut } = openedCall(c, key);
|
|
69354
69988
|
if (task) process.stdout.write(` ${task}
|
|
69355
69989
|
`);
|
|
69356
|
-
if (perMinuteUsd) process.stdout.write(` ${import_picocolors5.default.dim(`${
|
|
69990
|
+
if (perMinuteUsd) process.stdout.write(` ${import_picocolors5.default.dim(`${usd2(perMinuteUsd)} a minute, from the balance`)}
|
|
69357
69991
|
`);
|
|
69358
|
-
if (c.billedUsd) process.stdout.write(` ${import_picocolors5.default.dim(`billed ${
|
|
69992
|
+
if (c.billedUsd) process.stdout.write(` ${import_picocolors5.default.dim(`billed ${usd2(c.billedUsd)}`)}
|
|
69359
69993
|
`);
|
|
69360
69994
|
if (shut) process.stdout.write(` ${import_picocolors5.default.dim("sealed: this key does not open it (agentgates email seal-status)")}
|
|
69361
69995
|
`);
|
|
@@ -69413,12 +70047,12 @@ async function walkUpToThePayphone(opts, args) {
|
|
|
69413
70047
|
voice: opts.voice ?? null,
|
|
69414
70048
|
greeting: opts.greeting ?? null,
|
|
69415
70049
|
onQuote: (note2) => {
|
|
69416
|
-
if (!
|
|
70050
|
+
if (!jsonMode2(opts)) process.stderr.write(` ${import_picocolors5.default.dim(note2)}
|
|
69417
70051
|
`);
|
|
69418
70052
|
}
|
|
69419
70053
|
});
|
|
69420
70054
|
const placed = walk.call;
|
|
69421
|
-
const paid =
|
|
70055
|
+
const paid = usd(walk.paidMicro);
|
|
69422
70056
|
const render = (row2, full) => {
|
|
69423
70057
|
printCall(row2, "the payphone", null, full);
|
|
69424
70058
|
process.stdout.write(` ${import_picocolors5.default.dim(`${paid} paid on ${walk.network} for ${window2} ${window2 === 1 ? "minute" : "minutes"}, nothing held`)}
|
|
@@ -69440,11 +70074,11 @@ async function walkUpToThePayphone(opts, args) {
|
|
|
69440
70074
|
if (row?.status && TERMINAL.has(row.status)) break;
|
|
69441
70075
|
await new Promise((r) => setTimeout(r, 4e3));
|
|
69442
70076
|
try {
|
|
69443
|
-
row = await payphoneRead(walk.payment, walk.body, "read");
|
|
70077
|
+
row = await payphoneRead(walk.payment, walk.body, "read", args.privateKey);
|
|
69444
70078
|
} catch {
|
|
69445
70079
|
break;
|
|
69446
70080
|
}
|
|
69447
|
-
if (!
|
|
70081
|
+
if (!jsonMode2(opts) && row?.status && row.status !== last) {
|
|
69448
70082
|
last = row.status;
|
|
69449
70083
|
process.stderr.write(` ${import_picocolors5.default.dim(STATUS_WORD[row.status] ?? row.status)}
|
|
69450
70084
|
`);
|
|
@@ -69499,7 +70133,7 @@ async function phoneCall(toRaw, words7, opts) {
|
|
|
69499
70133
|
} catch (err) {
|
|
69500
70134
|
const empty2 = err instanceof WireError && (err.code === "balance_empty" || err.status === 402);
|
|
69501
70135
|
if (!empty2 || brain === "yours" || opts.webhook) throw err;
|
|
69502
|
-
if (!
|
|
70136
|
+
if (!jsonMode2(opts)) process.stderr.write(` ${import_picocolors5.default.dim("this account holds no balance; walking up to the payphone instead")}
|
|
69503
70137
|
`);
|
|
69504
70138
|
return await walkUpToThePayphone(opts, {
|
|
69505
70139
|
to,
|
|
@@ -69526,7 +70160,7 @@ async function phoneCall(toRaw, words7, opts) {
|
|
|
69526
70160
|
const ended = await waitForCall(keys2.wallet, phoneId, placed.callId, {
|
|
69527
70161
|
maxSeconds,
|
|
69528
70162
|
onTick: (c) => {
|
|
69529
|
-
if (
|
|
70163
|
+
if (jsonMode2(opts) || c.status === last) return;
|
|
69530
70164
|
last = c.status;
|
|
69531
70165
|
process.stderr.write(` ${import_picocolors5.default.dim(STATUS_WORD[c.status] ?? c.status)}
|
|
69532
70166
|
`);
|
|
@@ -69680,6 +70314,50 @@ var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
|
69680
70314
|
|
|
69681
70315
|
// src/lib/inbox-wire.ts
|
|
69682
70316
|
init_passwords_wire();
|
|
70317
|
+
|
|
70318
|
+
// src/lib/press-mail.ts
|
|
70319
|
+
function pressLinkAllowed(link, site) {
|
|
70320
|
+
if (typeof link !== "string" || link.length > 4096) return false;
|
|
70321
|
+
let url;
|
|
70322
|
+
try {
|
|
70323
|
+
url = new URL(link);
|
|
70324
|
+
} catch {
|
|
70325
|
+
return false;
|
|
70326
|
+
}
|
|
70327
|
+
if (url.protocol !== "https:" || url.username || url.password) return false;
|
|
70328
|
+
const host2 = url.hostname.toLowerCase();
|
|
70329
|
+
const bare = site.toLowerCase().replace(/^www\./, "");
|
|
70330
|
+
return host2 === bare || host2.endsWith(`.${bare}`);
|
|
70331
|
+
}
|
|
70332
|
+
function pressSenderAllowed(fromAddr, site, mailers = []) {
|
|
70333
|
+
const domain = (fromAddr.split("@").pop() ?? "").trim().toLowerCase().replace(/>$/, "");
|
|
70334
|
+
const bare = site.toLowerCase().replace(/^www\./, "");
|
|
70335
|
+
if (domain === bare || domain.endsWith(`.${bare}`)) return true;
|
|
70336
|
+
return mailers.map((m) => m.toLowerCase()).some((m) => domain === m || domain.endsWith(`.${m}`));
|
|
70337
|
+
}
|
|
70338
|
+
var LABELED_LINE_RE = /\b(code|verification|verify|otp|pin|passcode|one[- ]time)\b/i;
|
|
70339
|
+
function pressMailOf(mail, site) {
|
|
70340
|
+
const text = `${mail.subject ?? ""}
|
|
70341
|
+
${mail.text ?? ""}`.slice(0, 8e3).replace(/https?:\/\/[^\s"'<>]+/g, " ");
|
|
70342
|
+
let code = null;
|
|
70343
|
+
for (const line2 of text.split(/\r?\n/)) {
|
|
70344
|
+
if (!LABELED_LINE_RE.test(line2)) continue;
|
|
70345
|
+
const m = line2.match(/\b\d{4,8}\b/);
|
|
70346
|
+
if (m) {
|
|
70347
|
+
code = m[0];
|
|
70348
|
+
break;
|
|
70349
|
+
}
|
|
70350
|
+
}
|
|
70351
|
+
code = code ?? text.match(/\b\d{6}\b/)?.[0] ?? text.match(/\b\d{4,8}\b/)?.[0] ?? null;
|
|
70352
|
+
const blob = `${mail.text ?? ""}
|
|
70353
|
+
${mail.html ?? ""}`.slice(0, 2e5).replace(/&/g, "&");
|
|
70354
|
+
const links = [...blob.matchAll(/https:\/\/[^\s"'<>)\]]+/g)].map((m) => m[0].replace(/[.,;:!?]+$/, "")).filter((l) => pressLinkAllowed(l, site));
|
|
70355
|
+
const withToken = links.find((l) => /[?&](token|verificationToken)=/i.test(l));
|
|
70356
|
+
const pathLike = links.find((l) => /\/(login|signup|sign-up|verify|verification|confirm|otp|auth|magic)/i.test(new URL(l).pathname));
|
|
70357
|
+
return { code, link: withToken ?? pathLike ?? null };
|
|
70358
|
+
}
|
|
70359
|
+
|
|
70360
|
+
// src/lib/inbox-wire.ts
|
|
69683
70361
|
async function leaseInbox(wallet, args = {}) {
|
|
69684
70362
|
const body = {};
|
|
69685
70363
|
if (args.name) body.name = args.name;
|
|
@@ -69747,6 +70425,42 @@ ${opened.text}`, pattern);
|
|
|
69747
70425
|
}
|
|
69748
70426
|
}
|
|
69749
70427
|
}
|
|
70428
|
+
async function waitSiteMail(wallet, inboxId, { site, mailers = [], since, timeoutSeconds = 60 }) {
|
|
70429
|
+
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
70430
|
+
let after = since;
|
|
70431
|
+
let key = null;
|
|
70432
|
+
for (; ; ) {
|
|
70433
|
+
const remaining = Math.max(1, Math.ceil((deadline - Date.now()) / 1e3));
|
|
70434
|
+
const body = { timeoutSeconds: remaining };
|
|
70435
|
+
if (after) body.since = after;
|
|
70436
|
+
let out;
|
|
70437
|
+
try {
|
|
70438
|
+
out = expectOk(await signedFetch(wallet, "POST", lanePath(`/inboxes/${encodeURIComponent(inboxId)}/wait-code`), body, (remaining + 30) * 1e3), "the site's mail");
|
|
70439
|
+
} catch (err) {
|
|
70440
|
+
if (err instanceof WireError && err.status === 408) return null;
|
|
70441
|
+
throw err;
|
|
70442
|
+
}
|
|
70443
|
+
if (!out.sealed) return null;
|
|
70444
|
+
const rows = Array.isArray(out.messages) ? out.messages : [];
|
|
70445
|
+
key = key ?? await mailKeyFor(wallet);
|
|
70446
|
+
if (!key) throw new Error("this inbox is sealed and this account has no mail key registered");
|
|
70447
|
+
for (const row of rows) {
|
|
70448
|
+
if (row.direction === "out") continue;
|
|
70449
|
+
let opened;
|
|
70450
|
+
try {
|
|
70451
|
+
opened = openMessage(key, inboxId, row);
|
|
70452
|
+
} catch {
|
|
70453
|
+
continue;
|
|
70454
|
+
}
|
|
70455
|
+
if (!pressSenderAllowed(opened.from, site, mailers)) continue;
|
|
70456
|
+
const found = pressMailOf(opened, site);
|
|
70457
|
+
if (found.code || found.link) return { ...found, from: opened.from, receivedAt: opened.receivedAt };
|
|
70458
|
+
}
|
|
70459
|
+
const newest = rows.map((r) => r.receivedAt).filter(Boolean).sort().pop();
|
|
70460
|
+
if (newest) after = new Date(new Date(newest).getTime() + 1).toISOString();
|
|
70461
|
+
if (Date.now() >= deadline) return null;
|
|
70462
|
+
}
|
|
70463
|
+
}
|
|
69750
70464
|
async function inboxDomain() {
|
|
69751
70465
|
let res;
|
|
69752
70466
|
try {
|
|
@@ -69762,8 +70476,8 @@ async function inboxDomain() {
|
|
|
69762
70476
|
|
|
69763
70477
|
// src/commands/email.ts
|
|
69764
70478
|
init_passwords_wire();
|
|
69765
|
-
var
|
|
69766
|
-
var
|
|
70479
|
+
var SITE3 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
70480
|
+
var usd3 = (v) => {
|
|
69767
70481
|
const n2 = Number(v);
|
|
69768
70482
|
if (Number.isInteger(n2)) return `$${n2}`;
|
|
69769
70483
|
const [whole, frac = ""] = n2.toFixed(6).replace(/0+$/, "").split(".");
|
|
@@ -69786,7 +70500,7 @@ function emailSlice(body) {
|
|
|
69786
70500
|
return out;
|
|
69787
70501
|
}
|
|
69788
70502
|
async function emailPricing(opts) {
|
|
69789
|
-
const res = await fetch(`${
|
|
70503
|
+
const res = await fetch(`${SITE3}/api/account/catalog`, { headers: { accept: "application/json" } });
|
|
69790
70504
|
if (!res.ok) throw new Error(`email catalog: HTTP ${res.status}`);
|
|
69791
70505
|
const body = await res.json();
|
|
69792
70506
|
const slice = emailSlice(body);
|
|
@@ -69827,7 +70541,7 @@ async function emailPricing(opts) {
|
|
|
69827
70541
|
}
|
|
69828
70542
|
for (const f2 of families) {
|
|
69829
70543
|
const rows = byFamily.get(f2).sort((a, b2) => a.units - b2.units);
|
|
69830
|
-
const cells = rows.map((p) => `${import_picocolors6.default.cyan(
|
|
70544
|
+
const cells = rows.map((p) => `${import_picocolors6.default.cyan(usd3(p.priceUsd).padStart(4))}${import_picocolors6.default.dim(`/${p.units} days`.padEnd(10))}`).join(" ");
|
|
69831
70545
|
const lead = rows[0];
|
|
69832
70546
|
const cap = [
|
|
69833
70547
|
lead.inboxes ? `${lead.inboxes} inbox${lead.inboxes === 1 ? "" : "es"}` : "",
|
|
@@ -69841,8 +70555,8 @@ async function emailPricing(opts) {
|
|
|
69841
70555
|
const send2 = slice.sendOverflow?.priceUsd;
|
|
69842
70556
|
const wait2 = body.phoneUsage?.waitCodeUsd;
|
|
69843
70557
|
const meter = [
|
|
69844
|
-
send2 ? `send ${
|
|
69845
|
-
wait2 !== void 0 ? `wait-code ${Number(wait2) === 0 ? "free" :
|
|
70558
|
+
send2 ? `send ${usd3(send2)}` : "",
|
|
70559
|
+
wait2 !== void 0 ? `wait-code ${Number(wait2) === 0 ? "free" : usd3(wait2)}` : ""
|
|
69846
70560
|
].filter(Boolean).join(" \xB7 ");
|
|
69847
70561
|
if (meter) process.stdout.write(`
|
|
69848
70562
|
${import_picocolors6.default.dim(`usage, from the prepaid balance: ${meter}`)}
|
|
@@ -69852,7 +70566,7 @@ async function emailPricing(opts) {
|
|
|
69852
70566
|
const bal = slice.balance;
|
|
69853
70567
|
if (bal?.note) process.stdout.write(` ${import_picocolors6.default.dim(bal.note)}
|
|
69854
70568
|
`);
|
|
69855
|
-
else if (bal?.minTopUpUsd) process.stdout.write(` ${import_picocolors6.default.dim(`top up any amount from ${
|
|
70569
|
+
else if (bal?.minTopUpUsd) process.stdout.write(` ${import_picocolors6.default.dim(`top up any amount from ${usd3(bal.minTopUpUsd)}`)}
|
|
69856
70570
|
`);
|
|
69857
70571
|
const nets = [...new Set((plans[0]?.byNetwork ?? []).map((n2) => n2.network))];
|
|
69858
70572
|
if (nets.length) process.stdout.write(`
|
|
@@ -69865,7 +70579,7 @@ function emailDoor(first) {
|
|
|
69865
70579
|
process.stdout.write(
|
|
69866
70580
|
`
|
|
69867
70581
|
${first}, and this CLI has no signer yet.
|
|
69868
|
-
Do it from the wallet, one biometric: ${import_picocolors6.default.cyan(`${
|
|
70582
|
+
Do it from the wallet, one biometric: ${import_picocolors6.default.cyan(`${SITE3}/email`)}
|
|
69869
70583
|
Prices from here: ${import_picocolors6.default.dim("agentgates email pricing")}
|
|
69870
70584
|
|
|
69871
70585
|
`
|
|
@@ -70026,7 +70740,7 @@ function emit3(opts, data4, human) {
|
|
|
70026
70740
|
}
|
|
70027
70741
|
human();
|
|
70028
70742
|
}
|
|
70029
|
-
function
|
|
70743
|
+
function fail2(opts, err) {
|
|
70030
70744
|
const message = err instanceof Error ? err.message : String(err);
|
|
70031
70745
|
const code = err?.code;
|
|
70032
70746
|
if (opts.json || !process.stdout.isTTY) {
|
|
@@ -70084,7 +70798,7 @@ async function keysList(opts) {
|
|
|
70084
70798
|
const rows = await listLoginKeys(keys2.wallet);
|
|
70085
70799
|
emit3(opts, { ok: true, address: keys2.state.address, keys: rows, thisMachine: keys2.state.apiKeyPrefix ?? null }, () => printRows(rows, keys2.state.apiKeyPrefix ?? null));
|
|
70086
70800
|
} catch (err) {
|
|
70087
|
-
|
|
70801
|
+
fail2(opts, err);
|
|
70088
70802
|
}
|
|
70089
70803
|
}
|
|
70090
70804
|
async function keysCreate(opts) {
|
|
@@ -70132,7 +70846,7 @@ async function keysCreate(opts) {
|
|
|
70132
70846
|
);
|
|
70133
70847
|
});
|
|
70134
70848
|
} catch (err) {
|
|
70135
|
-
|
|
70849
|
+
fail2(opts, err);
|
|
70136
70850
|
}
|
|
70137
70851
|
}
|
|
70138
70852
|
async function keysFolders(id2, args, opts) {
|
|
@@ -70159,7 +70873,7 @@ async function keysFolders(id2, args, opts) {
|
|
|
70159
70873
|
`);
|
|
70160
70874
|
});
|
|
70161
70875
|
} catch (err) {
|
|
70162
|
-
|
|
70876
|
+
fail2(opts, err);
|
|
70163
70877
|
}
|
|
70164
70878
|
}
|
|
70165
70879
|
async function keysRevoke(id2, opts) {
|
|
@@ -70177,7 +70891,7 @@ async function keysRevoke(id2, opts) {
|
|
|
70177
70891
|
printRows(out.keys, wasMine ? null : keys2.state.apiKeyPrefix ?? null);
|
|
70178
70892
|
});
|
|
70179
70893
|
} catch (err) {
|
|
70180
|
-
|
|
70894
|
+
fail2(opts, err);
|
|
70181
70895
|
}
|
|
70182
70896
|
}
|
|
70183
70897
|
async function adoptKey(secret, name) {
|
|
@@ -70209,7 +70923,7 @@ async function keysUse(secret, opts) {
|
|
|
70209
70923
|
);
|
|
70210
70924
|
});
|
|
70211
70925
|
} catch (err) {
|
|
70212
|
-
|
|
70926
|
+
fail2(opts, err);
|
|
70213
70927
|
}
|
|
70214
70928
|
}
|
|
70215
70929
|
|
|
@@ -70338,11 +71052,11 @@ async function serveWordsOnce(args) {
|
|
|
70338
71052
|
let port = 0;
|
|
70339
71053
|
let done = () => {
|
|
70340
71054
|
};
|
|
70341
|
-
let
|
|
71055
|
+
let fail11 = () => {
|
|
70342
71056
|
};
|
|
70343
71057
|
const settled = new Promise((resolve3, reject) => {
|
|
70344
71058
|
done = resolve3;
|
|
70345
|
-
|
|
71059
|
+
fail11 = reject;
|
|
70346
71060
|
});
|
|
70347
71061
|
const server = createServer((req, res) => {
|
|
70348
71062
|
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
@@ -70368,7 +71082,7 @@ async function serveWordsOnce(args) {
|
|
|
70368
71082
|
const timer = setTimeout(() => {
|
|
70369
71083
|
if (!taken) {
|
|
70370
71084
|
server.close();
|
|
70371
|
-
|
|
71085
|
+
fail11(new Error(`nobody took the session in ${Math.round(args.waitMs / 1e3)}s`));
|
|
70372
71086
|
}
|
|
70373
71087
|
}, args.waitMs);
|
|
70374
71088
|
try {
|
|
@@ -70382,11 +71096,11 @@ async function receiveKeyOnce(args) {
|
|
|
70382
71096
|
let taken = false;
|
|
70383
71097
|
let done = () => {
|
|
70384
71098
|
};
|
|
70385
|
-
let
|
|
71099
|
+
let fail11 = () => {
|
|
70386
71100
|
};
|
|
70387
71101
|
const settled = new Promise((resolve3, reject) => {
|
|
70388
71102
|
done = resolve3;
|
|
70389
|
-
|
|
71103
|
+
fail11 = reject;
|
|
70390
71104
|
});
|
|
70391
71105
|
const server = createServer(async (req, res) => {
|
|
70392
71106
|
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
@@ -70416,7 +71130,7 @@ async function receiveKeyOnce(args) {
|
|
|
70416
71130
|
const timer = setTimeout(() => {
|
|
70417
71131
|
if (!taken) {
|
|
70418
71132
|
server.close();
|
|
70419
|
-
|
|
71133
|
+
fail11(new Error(`nobody handed a session over in ${Math.round(args.waitMs / 1e3)}s`));
|
|
70420
71134
|
}
|
|
70421
71135
|
}, args.waitMs);
|
|
70422
71136
|
try {
|
|
@@ -70431,9 +71145,9 @@ function handoffCode(code, port) {
|
|
|
70431
71145
|
|
|
70432
71146
|
// src/commands/session.ts
|
|
70433
71147
|
init_passwords_wire();
|
|
70434
|
-
var
|
|
71148
|
+
var jsonMode3 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
70435
71149
|
function refuse2(opts, error, code = null) {
|
|
70436
|
-
if (
|
|
71150
|
+
if (jsonMode3(opts)) process.stdout.write(JSON.stringify({ ok: false, code, error }, null, 2) + "\n");
|
|
70437
71151
|
else process.stderr.write(` ${error}${code ? import_picocolors8.default.dim(` (${code})`) : ""}
|
|
70438
71152
|
`);
|
|
70439
71153
|
process.exit(1);
|
|
@@ -70462,7 +71176,7 @@ async function sessionOpen(opts) {
|
|
|
70462
71176
|
address,
|
|
70463
71177
|
waitMs,
|
|
70464
71178
|
onUrl: (url, port) => {
|
|
70465
|
-
if (
|
|
71179
|
+
if (jsonMode3(opts)) {
|
|
70466
71180
|
process.stdout.write(JSON.stringify({ ok: true, status: "waiting", url, port, address, waitSeconds: waitMs / 1e3 }) + "\n");
|
|
70467
71181
|
} else {
|
|
70468
71182
|
process.stdout.write(`
|
|
@@ -70477,7 +71191,7 @@ async function sessionOpen(opts) {
|
|
|
70477
71191
|
});
|
|
70478
71192
|
}
|
|
70479
71193
|
});
|
|
70480
|
-
if (
|
|
71194
|
+
if (jsonMode3(opts)) process.stdout.write(JSON.stringify({ ok: true, status: "handed", address }) + "\n");
|
|
70481
71195
|
else process.stdout.write(` ${import_picocolors8.default.green("\u2713")} handed over; the browser is this account now.
|
|
70482
71196
|
|
|
70483
71197
|
`);
|
|
@@ -70492,7 +71206,7 @@ async function sessionReceive(opts) {
|
|
|
70492
71206
|
waitMs,
|
|
70493
71207
|
onCode: (code, port) => {
|
|
70494
71208
|
const typed = handoffCode(code, port);
|
|
70495
|
-
if (
|
|
71209
|
+
if (jsonMode3(opts)) {
|
|
70496
71210
|
process.stdout.write(JSON.stringify({ ok: true, status: "waiting", code: typed, port, waitSeconds: waitMs / 1e3 }) + "\n");
|
|
70497
71211
|
} else {
|
|
70498
71212
|
process.stdout.write(`
|
|
@@ -70506,7 +71220,7 @@ async function sessionReceive(opts) {
|
|
|
70506
71220
|
}
|
|
70507
71221
|
});
|
|
70508
71222
|
const { address, prefix, sealed, mode } = await adoptKey(key, `computer ${hostname2()}`);
|
|
70509
|
-
if (
|
|
71223
|
+
if (jsonMode3(opts)) process.stdout.write(JSON.stringify({ ok: true, status: "received", address, prefix, sealed, mode, path: passwordsKeyPath() }) + "\n");
|
|
70510
71224
|
else {
|
|
70511
71225
|
process.stdout.write(` ${import_picocolors8.default.green("\u2713")} this CLI runs on ${import_picocolors8.default.bold(prefix)} for ${address}
|
|
70512
71226
|
`);
|
|
@@ -70549,17 +71263,17 @@ function loginKeyLines(login2) {
|
|
|
70549
71263
|
` : ` ${import_picocolors9.default.dim(`login key here: ${login2.prefix}; every call sends it`)}
|
|
70550
71264
|
`;
|
|
70551
71265
|
}
|
|
70552
|
-
var
|
|
70553
|
-
var
|
|
71266
|
+
var SITE4 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
71267
|
+
var jsonMode4 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
70554
71268
|
function emit4(opts, data4, human) {
|
|
70555
|
-
if (
|
|
71269
|
+
if (jsonMode4(opts)) {
|
|
70556
71270
|
process.stdout.write(JSON.stringify(data4, null, 2) + "\n");
|
|
70557
71271
|
return;
|
|
70558
71272
|
}
|
|
70559
71273
|
human();
|
|
70560
71274
|
}
|
|
70561
71275
|
function refuse3(opts, error, code, extra = {}) {
|
|
70562
|
-
if (
|
|
71276
|
+
if (jsonMode4(opts)) {
|
|
70563
71277
|
process.stdout.write(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
|
|
70564
71278
|
} else {
|
|
70565
71279
|
process.stderr.write(` ${error}${code ? import_picocolors9.default.dim(` (${code})`) : ""}
|
|
@@ -70613,7 +71327,7 @@ function parseInt10(raw, name, dflt, min, max) {
|
|
|
70613
71327
|
if (!Number.isInteger(n2) || n2 < min || n2 > max) throw new PasswordsSealError(`${name} is a whole number from ${min} to ${max}`);
|
|
70614
71328
|
return n2;
|
|
70615
71329
|
}
|
|
70616
|
-
var
|
|
71330
|
+
var usd4 = (v) => {
|
|
70617
71331
|
const n2 = Number(v);
|
|
70618
71332
|
if (Number.isInteger(n2)) return `$${n2}`;
|
|
70619
71333
|
const [whole, frac = ""] = n2.toFixed(6).replace(/0+$/, "").split(".");
|
|
@@ -70636,7 +71350,7 @@ function passwordsSlice(body) {
|
|
|
70636
71350
|
return out;
|
|
70637
71351
|
}
|
|
70638
71352
|
async function passwordsPricing(opts) {
|
|
70639
|
-
const res = await fetch(`${
|
|
71353
|
+
const res = await fetch(`${SITE4}/api/account/catalog`, { headers: { accept: "application/json" } });
|
|
70640
71354
|
if (!res.ok) throw new Error(`passwords catalog: HTTP ${res.status}`);
|
|
70641
71355
|
const body = await res.json();
|
|
70642
71356
|
const slice = passwordsSlice(body);
|
|
@@ -70677,7 +71391,7 @@ async function passwordsPricing(opts) {
|
|
|
70677
71391
|
}
|
|
70678
71392
|
for (const f2 of families) {
|
|
70679
71393
|
const rows = byFamily.get(f2).sort((a, b2) => a.units - b2.units);
|
|
70680
|
-
const cells = rows.map((p) => `${import_picocolors9.default.cyan(
|
|
71394
|
+
const cells = rows.map((p) => `${import_picocolors9.default.cyan(usd4(p.priceUsd).padStart(4))}${import_picocolors9.default.dim(`/${p.units} days`.padEnd(10))}`).join(" ");
|
|
70681
71395
|
const lead = rows[0];
|
|
70682
71396
|
const cap = [
|
|
70683
71397
|
lead.passwords ? `${lead.passwords.toLocaleString()} passwords` : "",
|
|
@@ -70691,8 +71405,8 @@ async function passwordsPricing(opts) {
|
|
|
70691
71405
|
const use = slice.passwordsUsage?.useUsd;
|
|
70692
71406
|
const login2 = slice.passwordsUsage?.loginUsd;
|
|
70693
71407
|
const meter = [
|
|
70694
|
-
use ? `a code or key ${
|
|
70695
|
-
login2 ? `a login ${
|
|
71408
|
+
use ? `a code or key ${usd4(use)}` : "",
|
|
71409
|
+
login2 ? `a login ${usd4(login2)}` : ""
|
|
70696
71410
|
].filter(Boolean).join(" \xB7 ");
|
|
70697
71411
|
if (meter) process.stdout.write(`
|
|
70698
71412
|
${import_picocolors9.default.dim(`past the daily uses, from the agent's prepaid balance: ${meter}`)}
|
|
@@ -70789,6 +71503,14 @@ async function passwordsAdd(opts) {
|
|
|
70789
71503
|
const kind = opts.kind ?? "login";
|
|
70790
71504
|
let password = opts.password;
|
|
70791
71505
|
if (opts.passwordStdin) password = readFileSync(0, "utf8").replace(/\r?\n$/, "");
|
|
71506
|
+
if (opts.through) {
|
|
71507
|
+
if (kind !== "login") throw new PasswordsSealError("--through makes a login row");
|
|
71508
|
+
if (password !== void 0 || opts.passwordStdin) throw new PasswordsSealError("--through stores no password: the site signs in with the login row it names");
|
|
71509
|
+
const { passwords: passwords2 } = await listRows(wallet);
|
|
71510
|
+
const row2 = passwords2.find((r) => r.id === opts.through);
|
|
71511
|
+
if (!row2) throw new PasswordsSealError(`this key holds no row ${opts.through} (agentgates passwords list)`);
|
|
71512
|
+
if (row2.kind !== "login") throw new PasswordsSealError("--through names a login row: the account the site signs in through");
|
|
71513
|
+
}
|
|
70792
71514
|
const secret = {
|
|
70793
71515
|
password,
|
|
70794
71516
|
totpSeed: opts.totpSeed,
|
|
@@ -70822,7 +71544,7 @@ async function passwordsAdd(opts) {
|
|
|
70822
71544
|
if (!password || password === "-") throw new PasswordsSealError("a mailbox row needs --password, the app password (Gmail: myaccount.google.com/apppasswords, with 2-Step Verification on). An inbox leased here needs none: store the row on its own address instead.");
|
|
70823
71545
|
}
|
|
70824
71546
|
}
|
|
70825
|
-
const payload = buildSecretPayload({ kind, secret, hosts, notes: opts.notes, backupCodes: readArg(opts.backupCodes), device });
|
|
71547
|
+
const payload = buildSecretPayload({ kind, secret, hosts, notes: opts.notes, backupCodes: readArg(opts.backupCodes), device, signsInThrough: Boolean(opts.through) });
|
|
70826
71548
|
let username;
|
|
70827
71549
|
if (opts.username !== void 0 && opts.username !== "") {
|
|
70828
71550
|
if (kind !== "login" && kind !== "mailbox") throw new PasswordsSealError("only a login or a mailbox carries a username");
|
|
@@ -71037,6 +71759,16 @@ function printUseAnswer(opts, status4, body) {
|
|
|
71037
71759
|
if (typeof result.codesLeft === "number") process.stdout.write(` ${import_picocolors9.default.dim(`${result.codesLeft} backup code${result.codesLeft === 1 ? "" : "s"} left`)}
|
|
71038
71760
|
`);
|
|
71039
71761
|
if (result.device && typeof result.device === "object") process.stdout.write(` ${import_picocolors9.default.dim(`the site created a device credential for ${String(result.device.rpId ?? "")}; agentgates passwords device seals it into the row`)}
|
|
71762
|
+
`);
|
|
71763
|
+
if (result.apiKey && typeof result.apiKey === "object" && result.apiKey.kept === true) {
|
|
71764
|
+
process.stdout.write(` ${import_picocolors9.default.green("\u2713")} the key is kept inside the CVM in this row; a header use fills {apiKey} with it
|
|
71765
|
+
`);
|
|
71766
|
+
}
|
|
71767
|
+
for (const field of Array.isArray(result.sealed) ? result.sealed : []) {
|
|
71768
|
+
process.stdout.write(` ${import_picocolors9.default.dim(`${field} is sealed to the owner (agentgates passwords open-sealed opens it with the owner's key)`)}
|
|
71769
|
+
`);
|
|
71770
|
+
}
|
|
71771
|
+
if (result.withheld === true) process.stdout.write(` ${import_picocolors9.default.dim("the answer had no field where the seal looked for it, so none of it was handed back")}
|
|
71040
71772
|
`);
|
|
71041
71773
|
for (const s of Array.isArray(result.solved) ? result.solved : []) {
|
|
71042
71774
|
process.stdout.write(` ${import_picocolors9.default.dim(`passed a ${String(s.kind)} check ${s.how === "service" ? "through the solver service" : "by hand"} in ${Math.max(1, Math.round(Number(s.ms ?? 0) / 1e3))}s`)}
|
|
@@ -71117,6 +71849,10 @@ async function passwordsUse(opts) {
|
|
|
71117
71849
|
if (use !== "login" && use !== "session") throw new PasswordsSealError("--mailbox goes with the login or session use");
|
|
71118
71850
|
request.mailbox = opts.mailbox;
|
|
71119
71851
|
}
|
|
71852
|
+
if (opts.asRow) {
|
|
71853
|
+
if (use !== "login") throw new PasswordsSealError("--as-row goes with the login use");
|
|
71854
|
+
request.credential = opts.asRow;
|
|
71855
|
+
}
|
|
71120
71856
|
let workflowRow = null;
|
|
71121
71857
|
if (opts.workflow) {
|
|
71122
71858
|
if (use !== "login") throw new PasswordsSealError("--workflow goes with the login use");
|
|
@@ -71144,7 +71880,7 @@ function waitOptionsOf(opts) {
|
|
|
71144
71880
|
return {
|
|
71145
71881
|
waitSeconds: opts.wait !== void 0 ? parseInt10(opts.wait, "--wait", 0, 0, 3600) : null,
|
|
71146
71882
|
noWait: opts.noWait,
|
|
71147
|
-
note:
|
|
71883
|
+
note: jsonMode4(opts) ? void 0 : (line2) => process.stderr.write(` ${import_picocolors9.default.dim(line2)}
|
|
71148
71884
|
`)
|
|
71149
71885
|
};
|
|
71150
71886
|
}
|
|
@@ -71153,6 +71889,9 @@ async function postUseAndWait(wallet, rowId, firstBody, opts = {}) {
|
|
|
71153
71889
|
{
|
|
71154
71890
|
let lastBody = firstBody;
|
|
71155
71891
|
let broughtCode = null;
|
|
71892
|
+
let pressNamed = false;
|
|
71893
|
+
let pressBrought = false;
|
|
71894
|
+
let ownerNamed = false;
|
|
71156
71895
|
let answer = await postUse(wallet, rowId, firstBody);
|
|
71157
71896
|
const startedAt = Date.now();
|
|
71158
71897
|
const boxBudgetEnd = waitCap !== null ? startedAt + waitCap * 1e3 : startedAt + 24e4;
|
|
@@ -71160,13 +71899,46 @@ async function postUseAndWait(wallet, rowId, firstBody, opts = {}) {
|
|
|
71160
71899
|
const body = answer.body ?? {};
|
|
71161
71900
|
if (answer.status === 202) {
|
|
71162
71901
|
if (!body.useId) break;
|
|
71163
|
-
|
|
71902
|
+
const heldForOwner = body.code === "attend_pending" && !body.view;
|
|
71903
|
+
if (body.code === "attend_pending" && !heldForOwner) break;
|
|
71164
71904
|
const expiresAt = body.expiresAt ? Date.parse(body.expiresAt) : NaN;
|
|
71165
71905
|
const deadline = Math.min(
|
|
71166
71906
|
Number.isFinite(expiresAt) ? expiresAt : Date.now() + 6e5,
|
|
71167
71907
|
waitCap !== null ? startedAt + waitCap * 1e3 : Number.POSITIVE_INFINITY
|
|
71168
71908
|
);
|
|
71169
71909
|
if (Date.now() >= deadline) break;
|
|
71910
|
+
if (body.code === "press_pending") {
|
|
71911
|
+
const press = body;
|
|
71912
|
+
if (!pressNamed) {
|
|
71913
|
+
opts.note?.(`${press.site ?? "the site"} takes this press only from the owner's own browser: open ${press.open ?? "its sign-up page"} and press Continue`);
|
|
71914
|
+
pressNamed = true;
|
|
71915
|
+
}
|
|
71916
|
+
const asked = firstBody.request ?? {};
|
|
71917
|
+
const site = typeof asked.url === "string" ? siteOfUrl(asked.url) : null;
|
|
71918
|
+
if (!pressBrought && site && press.source?.sealed === true && press.source.kind === "inbox" && typeof press.source.id === "string") {
|
|
71919
|
+
try {
|
|
71920
|
+
const mail = await waitSiteMail(wallet, press.source.id, { site, since: press.askedAt ?? null, timeoutSeconds: Math.max(5, Math.min(60, Math.floor((deadline - Date.now()) / 1e3))) });
|
|
71921
|
+
if (mail?.link) {
|
|
71922
|
+
pressBrought = true;
|
|
71923
|
+
opts.note?.(`the site's mail is in; the CVM finishes the sign-up on its link`);
|
|
71924
|
+
lastBody = { ...firstBody, request: { ...asked, verifyUrl: mail.link, ...mail.code ? { otpCode: mail.code } : {} }, useId: body.useId };
|
|
71925
|
+
answer = await postUse(wallet, rowId, lastBody);
|
|
71926
|
+
continue;
|
|
71927
|
+
}
|
|
71928
|
+
if (mail?.code) {
|
|
71929
|
+
pressBrought = true;
|
|
71930
|
+
opts.note?.(`the site's mail carries no link the CVM may finish on: type ${mail.code} in the browser you pressed in`);
|
|
71931
|
+
lastBody = { ...firstBody, request: { ...asked, otpCode: mail.code }, useId: body.useId };
|
|
71932
|
+
answer = await postUse(wallet, rowId, lastBody);
|
|
71933
|
+
continue;
|
|
71934
|
+
}
|
|
71935
|
+
answer = await postUse(wallet, rowId, { ...firstBody, useId: body.useId });
|
|
71936
|
+
continue;
|
|
71937
|
+
} catch (err) {
|
|
71938
|
+
opts.note?.(`could not read the sealed inbox here (${err instanceof Error ? err.message : String(err)}); waiting on the owner`);
|
|
71939
|
+
}
|
|
71940
|
+
}
|
|
71941
|
+
}
|
|
71170
71942
|
const source = body.source;
|
|
71171
71943
|
if (body.code === "code_pending" && source?.sealed === true && source.kind === "inbox" && typeof source.id === "string" && !broughtCode) {
|
|
71172
71944
|
opts.note?.(`the site sent a code to a sealed inbox; reading it with this key`);
|
|
@@ -71181,7 +71953,15 @@ async function postUseAndWait(wallet, rowId, firstBody, opts = {}) {
|
|
|
71181
71953
|
opts.note?.(`could not read the sealed inbox here (${err instanceof Error ? err.message : String(err)}); waiting for the owner`);
|
|
71182
71954
|
}
|
|
71183
71955
|
}
|
|
71184
|
-
|
|
71956
|
+
if (heldForOwner) {
|
|
71957
|
+
if (!ownerNamed) {
|
|
71958
|
+
const wall = body.wall;
|
|
71959
|
+
opts.note?.(`a step only a person completes${typeof wall === "string" && wall ? ` (${wall})` : ""}: the page is on the owner's board; waiting for their Done`);
|
|
71960
|
+
ownerNamed = true;
|
|
71961
|
+
}
|
|
71962
|
+
} else {
|
|
71963
|
+
opts.note?.(body.error ?? "waiting for the owner");
|
|
71964
|
+
}
|
|
71185
71965
|
lastBody = { ...firstBody, useId: body.useId, wait: 25 };
|
|
71186
71966
|
answer = await postUse(wallet, rowId, lastBody);
|
|
71187
71967
|
continue;
|
|
@@ -71321,6 +72101,80 @@ async function storeSealedRow(wallet, input) {
|
|
|
71321
72101
|
cvmKeyId: att.keyId
|
|
71322
72102
|
});
|
|
71323
72103
|
}
|
|
72104
|
+
var AUTO_OWNER_HOPS = 8;
|
|
72105
|
+
var AUTO_OWNER_PAUSE_SECONDS = 10;
|
|
72106
|
+
var PHONE_FIELD = { x: 640, y: 438 };
|
|
72107
|
+
var DEVICE_FIELD = { x: 640, y: 363 };
|
|
72108
|
+
function nationalDigits(number2) {
|
|
72109
|
+
const digits = number2.replace(/\D/g, "");
|
|
72110
|
+
return digits.length === 11 && digits.startsWith("1") ? digits.slice(1) : digits;
|
|
72111
|
+
}
|
|
72112
|
+
async function heldCardOf(wallet, useId) {
|
|
72113
|
+
const out = expectOk(await signedFetch(wallet, "GET", lanePath("/passwords/pending")), "the waiting cards");
|
|
72114
|
+
const card2 = (out.pending ?? []).find((c) => c.id === useId);
|
|
72115
|
+
if (!card2 || !card2.secretId || !card2.attend?.token) throw new PasswordsSealError("the held page is not on this key's waiting cards");
|
|
72116
|
+
return { row: card2.secretId, useId, token: card2.attend.token };
|
|
72117
|
+
}
|
|
72118
|
+
async function heldInput(card2, input) {
|
|
72119
|
+
const res = await fetch(`${siteOrigin()}/api/passwords/${encodeURIComponent(card2.row)}/attend/${encodeURIComponent(card2.useId)}/input`, {
|
|
72120
|
+
method: "POST",
|
|
72121
|
+
headers: { authorization: `Bearer ${card2.token}`, "content-type": "application/json", accept: "application/json" },
|
|
72122
|
+
body: JSON.stringify({ ...input, view: card2.token })
|
|
72123
|
+
});
|
|
72124
|
+
if (!res.ok) throw new PasswordsSealError(`the held page refused an input (${res.status})`);
|
|
72125
|
+
}
|
|
72126
|
+
var sleepMs = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
72127
|
+
async function answerDeviceCheck(wallet, useId, inboxId, note2) {
|
|
72128
|
+
const card2 = await heldCardOf(wallet, useId);
|
|
72129
|
+
const since = Date.now() - 6e4;
|
|
72130
|
+
const deadline = Date.now() + 9e4;
|
|
72131
|
+
let code = null;
|
|
72132
|
+
while (Date.now() < deadline && !code) {
|
|
72133
|
+
try {
|
|
72134
|
+
const mailed = await waitInboxCode(wallet, inboxId, { timeoutSeconds: 8 });
|
|
72135
|
+
if (mailed.receivedAt && Date.parse(mailed.receivedAt) >= since) code = mailed.code;
|
|
72136
|
+
else await sleepMs(3e3);
|
|
72137
|
+
} catch (err) {
|
|
72138
|
+
if (err instanceof WireError && err.status !== 408) throw err;
|
|
72139
|
+
}
|
|
72140
|
+
}
|
|
72141
|
+
if (!code) throw new PasswordsSealError("no code reached the inbox in ninety seconds");
|
|
72142
|
+
await heldInput(card2, { kind: "click", x: DEVICE_FIELD.x, y: DEVICE_FIELD.y });
|
|
72143
|
+
await sleepMs(400);
|
|
72144
|
+
await heldInput(card2, { kind: "type", text: code });
|
|
72145
|
+
await sleepMs(400);
|
|
72146
|
+
await heldInput(card2, { kind: "key", key: "Enter" });
|
|
72147
|
+
note2?.("the device check's code is typed");
|
|
72148
|
+
}
|
|
72149
|
+
async function answerPhoneCheck(wallet, useId, sms, note2) {
|
|
72150
|
+
const card2 = await heldCardOf(wallet, useId);
|
|
72151
|
+
const digits = nationalDigits(sms.number);
|
|
72152
|
+
if (digits.length < 7) throw new PasswordsSealError("--sms-number is a phone number");
|
|
72153
|
+
await heldInput(card2, { kind: "click", x: PHONE_FIELD.x, y: PHONE_FIELD.y });
|
|
72154
|
+
await sleepMs(400);
|
|
72155
|
+
await heldInput(card2, { kind: "type", text: digits });
|
|
72156
|
+
await sleepMs(400);
|
|
72157
|
+
const typedAt = Date.now();
|
|
72158
|
+
await heldInput(card2, { kind: "key", key: "Enter" });
|
|
72159
|
+
note2?.(`the phone check has the number; waiting for its text at ${sms.id}`);
|
|
72160
|
+
const deadline = typedAt + 12e4;
|
|
72161
|
+
let code = null;
|
|
72162
|
+
while (Date.now() < deadline && !code) {
|
|
72163
|
+
try {
|
|
72164
|
+
const texted = await waitPhoneCode(wallet, sms.id, { timeoutSeconds: 6 });
|
|
72165
|
+
if (texted.receivedAt && Date.parse(texted.receivedAt) >= typedAt - 3e3) code = texted.code;
|
|
72166
|
+
else await sleepMs(3e3);
|
|
72167
|
+
} catch (err) {
|
|
72168
|
+
if (err instanceof WireError && err.status !== 408 && err.status !== 404) throw err;
|
|
72169
|
+
}
|
|
72170
|
+
}
|
|
72171
|
+
if (!code) throw new PasswordsSealError("no text reached the number in two minutes");
|
|
72172
|
+
await sleepMs(500);
|
|
72173
|
+
await heldInput(card2, { kind: "type", text: code });
|
|
72174
|
+
await sleepMs(400);
|
|
72175
|
+
await heldInput(card2, { kind: "key", key: "Enter" });
|
|
72176
|
+
note2?.("the text's code is typed");
|
|
72177
|
+
}
|
|
71324
72178
|
async function passwordsSignupFlow(wallet, args, wait2 = {}) {
|
|
71325
72179
|
let site;
|
|
71326
72180
|
try {
|
|
@@ -71332,21 +72186,55 @@ async function passwordsSignupFlow(wallet, args, wait2 = {}) {
|
|
|
71332
72186
|
const source = sourceOf(args);
|
|
71333
72187
|
if (source?.kind === "phone" && args.email) throw new PasswordsSealError("an account made on a number carries no --email: the number is the identity and the code comes by text");
|
|
71334
72188
|
const mailbox = source ? source.id : await mailboxRowFor(wallet);
|
|
71335
|
-
|
|
72189
|
+
let asRow = null;
|
|
72190
|
+
if (args.asRow) {
|
|
72191
|
+
if (args.password) throw new PasswordsSealError("--as-row brings its own password: leave --password out");
|
|
72192
|
+
if (!args.useId) {
|
|
72193
|
+
const { passwords: passwords2 } = await listRows(wallet);
|
|
72194
|
+
const row = passwords2.find((r) => r.id === args.asRow);
|
|
72195
|
+
if (!row) throw new PasswordsSealError(`this key holds no row ${args.asRow} (agentgates passwords list)`);
|
|
72196
|
+
if (row.kind !== "login") throw new PasswordsSealError("--as-row names a login: the account whose sign-in the site takes");
|
|
72197
|
+
const opened = parseSecretPayload(openDurable(await revealRow(wallet, row.id), await signVaultMessage(wallet)).toString("utf8"));
|
|
72198
|
+
const held3 = opened.secret.password;
|
|
72199
|
+
if (typeof held3 !== "string" || !held3) throw new PasswordsSealError("that login holds no password");
|
|
72200
|
+
asRow = { username: row.username ?? void 0, password: held3 };
|
|
72201
|
+
}
|
|
72202
|
+
}
|
|
72203
|
+
const password = asRow?.password ?? args.password ?? (args.useId ? void 0 : generatePassword());
|
|
71336
72204
|
const request = { url: args.url, ...password !== void 0 ? { password } : {} };
|
|
71337
72205
|
if (source && source.kind !== "mailbox") request.source = { kind: source.kind, id: source.id };
|
|
71338
72206
|
if (args.email) request.email = args.email;
|
|
71339
72207
|
if (args.name) request.name = args.name;
|
|
71340
72208
|
if (args.username) request.username = args.username;
|
|
72209
|
+
else if (asRow?.username) request.username = asRow.username;
|
|
71341
72210
|
if (args.steps !== void 0) request.steps = args.steps;
|
|
71342
72211
|
if (args.drive) request.drive = true;
|
|
71343
72212
|
if (args.birthday) request.birthday = args.birthday;
|
|
71344
72213
|
if (args.attend || args.useId) request.attend = true;
|
|
71345
|
-
|
|
72214
|
+
let answer = await postUseAndWait(wallet, mailbox, { use: "signup", request, ...args.useId ? { useId: args.useId } : {} }, wait2);
|
|
72215
|
+
if (args.autoOwner && (args.attend || args.useId)) {
|
|
72216
|
+
const { password: _sent, ...continued } = request;
|
|
72217
|
+
for (let hop = 0; hop < AUTO_OWNER_HOPS; hop += 1) {
|
|
72218
|
+
const held3 = answer.body ?? {};
|
|
72219
|
+
if (answer.status !== 202 || held3.code !== "attend_pending" || !held3.useId) break;
|
|
72220
|
+
const wall = String(held3.wall ?? "");
|
|
72221
|
+
if (/phone/i.test(wall) && args.smsId && args.smsNumber) {
|
|
72222
|
+
await answerPhoneCheck(wallet, held3.useId, { id: args.smsId, number: args.smsNumber }, args.note);
|
|
72223
|
+
} else if (/device/i.test(wall) && source?.kind === "inbox") {
|
|
72224
|
+
await answerDeviceCheck(wallet, held3.useId, source.id, args.note);
|
|
72225
|
+
} else if (/did not expect/i.test(wall)) {
|
|
72226
|
+
args.note?.(`a page had not drawn; continuing in ${AUTO_OWNER_PAUSE_SECONDS}s`);
|
|
72227
|
+
await sleepMs(AUTO_OWNER_PAUSE_SECONDS * 1e3);
|
|
72228
|
+
} else {
|
|
72229
|
+
break;
|
|
72230
|
+
}
|
|
72231
|
+
answer = await postUseAndWait(wallet, mailbox, { use: "signup", request: continued, useId: held3.useId }, wait2);
|
|
72232
|
+
}
|
|
72233
|
+
}
|
|
71346
72234
|
const body = answer.body ?? {};
|
|
71347
72235
|
const result = body.result ?? {};
|
|
71348
72236
|
const ok = answer.status === 200 && result.ok === true;
|
|
71349
|
-
const storedPassword = password ?? (typeof result.password === "string" ? result.password : void 0);
|
|
72237
|
+
const storedPassword = args.asRow ? void 0 : password ?? (typeof result.password === "string" ? result.password : void 0);
|
|
71350
72238
|
const email2 = typeof result.email === "string" && result.email ? result.email : args.email ?? null;
|
|
71351
72239
|
const phone2 = typeof result.phone === "string" ? result.phone : null;
|
|
71352
72240
|
const signInAs = typeof result.signInAs === "string" ? result.signInAs : null;
|
|
@@ -71392,6 +72280,7 @@ async function passwordsSignupFlow(wallet, args, wait2 = {}) {
|
|
|
71392
72280
|
// it on and the continue call signs in to the account you made there.
|
|
71393
72281
|
then: result.then === "signin" || body.then === "signin" ? "signin" : null,
|
|
71394
72282
|
drove: result.drove ?? body.drove ?? null,
|
|
72283
|
+
...typeof body.open === "string" ? { open: String(body.open) } : {},
|
|
71395
72284
|
passwordSet,
|
|
71396
72285
|
digest: typeof result.digest === "string" ? result.digest : "",
|
|
71397
72286
|
...result.cookies !== void 0 ? { cookies: result.cookies } : {},
|
|
@@ -71402,7 +72291,12 @@ async function passwordsSignupFlow(wallet, args, wait2 = {}) {
|
|
|
71402
72291
|
...body.chargedUsd !== void 0 ? { chargedUsd: body.chargedUsd } : {},
|
|
71403
72292
|
stored,
|
|
71404
72293
|
...storeError ? { storeError } : {},
|
|
71405
|
-
|
|
72294
|
+
// A sign-up that failed AFTER the password went into the form comes back
|
|
72295
|
+
// with it too: the site may still make the account (GitHub made one after
|
|
72296
|
+
// the CVM closed its page on 2026-09-27, and on 2026-09-28 the mailed
|
|
72297
|
+
// confirm link made livefire-agent), and this answer is then the only
|
|
72298
|
+
// place the password is left.
|
|
72299
|
+
...passwordSet && storedPassword !== void 0 && (ok ? !args.store || storeError : true) ? { password: storedPassword } : {}
|
|
71406
72300
|
};
|
|
71407
72301
|
}
|
|
71408
72302
|
function birthdayOf(raw) {
|
|
@@ -71427,10 +72321,23 @@ async function passwordsSignup(opts) {
|
|
|
71427
72321
|
}
|
|
71428
72322
|
const answer = await passwordsSignupFlow(
|
|
71429
72323
|
wallet,
|
|
71430
|
-
{ url: opts.url, email: opts.email, name: opts.name, username: opts.username, password: opts.password, mailbox: opts.mailbox, inbox: opts.inbox, phone: opts.phone, label: opts.label, store: opts.store !== false, steps, drive: opts.drive === true, birthday: birthdayOf(opts.birthday), attend: opts.attend
|
|
72324
|
+
{ url: opts.url, email: opts.email, name: opts.name, username: opts.username, password: opts.password, mailbox: opts.mailbox, inbox: opts.inbox, phone: opts.phone, label: opts.label, store: opts.store !== false, steps, drive: opts.drive === true, birthday: birthdayOf(opts.birthday), attend: opts.attend !== false, useId: opts.useId, asRow: opts.asRow, autoOwner: opts.autoOwner === true, smsId: opts.smsId, smsNumber: opts.smsNumber, note: jsonMode4(opts) ? void 0 : (line2) => process.stdout.write(` ${import_picocolors9.default.dim(line2)}
|
|
72325
|
+
`) },
|
|
71431
72326
|
waitOptionsOf(opts)
|
|
71432
72327
|
);
|
|
71433
72328
|
emit4(opts, answer, () => {
|
|
72329
|
+
if (answer.code === "press_pending" && answer.useId) {
|
|
72330
|
+
process.stdout.write(
|
|
72331
|
+
`
|
|
72332
|
+
${import_picocolors9.default.yellow("!")} ${import_picocolors9.default.bold(answer.site)} takes this press only from your own browser
|
|
72333
|
+
${import_picocolors9.default.dim("open")} ${answer.open ?? answer.url} ${import_picocolors9.default.dim("and press Continue")}
|
|
72334
|
+
${import_picocolors9.default.dim("use")} ${answer.useId}
|
|
72335
|
+
${import_picocolors9.default.dim(`then: agentgates passwords signup --url ${answer.url}${answer.source.kind !== "mailbox" ? ` --${answer.source.kind} ${answer.source.id}` : ""} --use-id ${answer.useId} (reads the site's mail; the CVM finishes the sign-up)`)}
|
|
72336
|
+
|
|
72337
|
+
`
|
|
72338
|
+
);
|
|
72339
|
+
return;
|
|
72340
|
+
}
|
|
71434
72341
|
if (answer.code === "attend_pending" && answer.useId) {
|
|
71435
72342
|
process.stdout.write(
|
|
71436
72343
|
`
|
|
@@ -71478,6 +72385,8 @@ ${answer.digest.split("\n").slice(0, 12).map((l) => ` ${l}`).join("\n")}
|
|
|
71478
72385
|
process.stdout.write(`
|
|
71479
72386
|
${answer.error ?? `HTTP ${answer.status}`}${answer.code ? import_picocolors9.default.dim(` (${answer.code})`) : ""}
|
|
71480
72387
|
${answer.useId ? ` ${import_picocolors9.default.dim("use")} ${answer.useId}
|
|
72388
|
+
` : ""}${answer.password ? ` ${import_picocolors9.default.dim("the form took this password; if the site makes the account anyway, it signs in with it:")}
|
|
72389
|
+
${answer.password}
|
|
71481
72390
|
` : ""}${answer.digest ? `
|
|
71482
72391
|
${answer.digest.split("\n").slice(0, 12).map((l) => ` ${l}`).join("\n")}
|
|
71483
72392
|
` : ""}
|
|
@@ -71636,6 +72545,42 @@ async function passwordsInvite(opts) {
|
|
|
71636
72545
|
failFrom2(opts, err);
|
|
71637
72546
|
}
|
|
71638
72547
|
}
|
|
72548
|
+
function sealedAnswerAad(rowId, field) {
|
|
72549
|
+
return `agentgates-passwords-sealed-answer-v1|${rowId}|${field}`;
|
|
72550
|
+
}
|
|
72551
|
+
async function passwordsOpenSealed(opts) {
|
|
72552
|
+
try {
|
|
72553
|
+
const { wallet } = await requirePasswordsKey();
|
|
72554
|
+
if (!opts.row || !opts.field || !opts.blob) throw new PasswordsSealError("--row, --field and --blob: the row the use ran on, the sealed field's name, and its {sealed} value (or @file)");
|
|
72555
|
+
const blob = (readArg(opts.blob) ?? "").trim();
|
|
72556
|
+
const key = await mailKeyFor(wallet);
|
|
72557
|
+
if (!key) throw new PasswordsSealError("this account has no data key: nothing was sealed to it");
|
|
72558
|
+
let value;
|
|
72559
|
+
try {
|
|
72560
|
+
value = openText(key.dataKey, blob, sealedAnswerAad(opts.row, opts.field));
|
|
72561
|
+
} catch {
|
|
72562
|
+
throw new PasswordsSealError("that blob does not open as this row's field under this account's key");
|
|
72563
|
+
}
|
|
72564
|
+
if (opts.out) {
|
|
72565
|
+
writeFileSync2(opts.out, value, { mode: 384 });
|
|
72566
|
+
emit4(opts, { ok: true, row: opts.row, field: opts.field, out: opts.out, chars: value.length }, () => {
|
|
72567
|
+
process.stdout.write(`
|
|
72568
|
+
${import_picocolors9.default.green("\u2713")} ${opts.field} opened: ${value.length} characters, written to ${opts.out}
|
|
72569
|
+
|
|
72570
|
+
`);
|
|
72571
|
+
});
|
|
72572
|
+
return;
|
|
72573
|
+
}
|
|
72574
|
+
emit4(opts, { ok: true, row: opts.row, field: opts.field, value }, () => {
|
|
72575
|
+
process.stdout.write(`
|
|
72576
|
+
${opts.field} ${value}
|
|
72577
|
+
|
|
72578
|
+
`);
|
|
72579
|
+
});
|
|
72580
|
+
} catch (err) {
|
|
72581
|
+
failFrom2(opts, err);
|
|
72582
|
+
}
|
|
72583
|
+
}
|
|
71639
72584
|
|
|
71640
72585
|
// src/commands/browser.ts
|
|
71641
72586
|
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
@@ -71738,16 +72683,16 @@ async function waitForTask(wallet, id2, { maxSeconds = 900, everyMs = 5e3, onTic
|
|
|
71738
72683
|
}
|
|
71739
72684
|
|
|
71740
72685
|
// src/commands/browser.ts
|
|
71741
|
-
var
|
|
72686
|
+
var jsonMode5 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
71742
72687
|
function emit5(opts, data4, human) {
|
|
71743
|
-
if (
|
|
72688
|
+
if (jsonMode5(opts)) {
|
|
71744
72689
|
process.stdout.write(JSON.stringify(data4, null, 2) + "\n");
|
|
71745
72690
|
return;
|
|
71746
72691
|
}
|
|
71747
72692
|
human();
|
|
71748
72693
|
}
|
|
71749
72694
|
function refuse4(opts, error, code, extra = {}) {
|
|
71750
|
-
if (
|
|
72695
|
+
if (jsonMode5(opts)) {
|
|
71751
72696
|
process.stdout.write(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
|
|
71752
72697
|
} else {
|
|
71753
72698
|
process.stderr.write(` ${error}${code ? import_picocolors10.default.dim(` (${code})`) : ""}
|
|
@@ -71759,7 +72704,7 @@ function failFrom3(opts, err) {
|
|
|
71759
72704
|
if (err instanceof WireError) return refuse4(opts, err.message, err.code, { status: err.status });
|
|
71760
72705
|
return refuse4(opts, err.message ?? String(err), null);
|
|
71761
72706
|
}
|
|
71762
|
-
var
|
|
72707
|
+
var usd5 = (v) => {
|
|
71763
72708
|
const n2 = Number(v);
|
|
71764
72709
|
if (Number.isInteger(n2)) return `$${n2}`;
|
|
71765
72710
|
const [whole, frac = ""] = n2.toFixed(6).replace(/0+$/, "").split(".");
|
|
@@ -71792,9 +72737,9 @@ function printTask(t, full) {
|
|
|
71792
72737
|
`);
|
|
71793
72738
|
process.stdout.write(` ${t.goal}
|
|
71794
72739
|
`);
|
|
71795
|
-
if (t.status === "done") process.stdout.write(` ${import_picocolors10.default.dim(`charged ${
|
|
72740
|
+
if (t.status === "done") process.stdout.write(` ${import_picocolors10.default.dim(`charged ${usd5(t.chargedUsd)}`)}
|
|
71796
72741
|
`);
|
|
71797
|
-
else if (t.status === "queued" || t.status === "running") process.stdout.write(` ${import_picocolors10.default.dim(`reserved ${
|
|
72742
|
+
else if (t.status === "queued" || t.status === "running") process.stdout.write(` ${import_picocolors10.default.dim(`reserved ${usd5(t.reservedUsd)}`)}
|
|
71798
72743
|
`);
|
|
71799
72744
|
if (t.answer) process.stdout.write(`
|
|
71800
72745
|
${import_picocolors10.default.bold("Answer")}
|
|
@@ -71839,7 +72784,7 @@ async function browserPricing(opts) {
|
|
|
71839
72784
|
`);
|
|
71840
72785
|
return;
|
|
71841
72786
|
}
|
|
71842
|
-
if (usage?.stepUsd) process.stdout.write(` ${import_picocolors10.default.cyan(
|
|
72787
|
+
if (usage?.stepUsd) process.stdout.write(` ${import_picocolors10.default.cyan(usd5(usage.stepUsd))} ${import_picocolors10.default.dim("a step, from the prepaid balance")}
|
|
71843
72788
|
`);
|
|
71844
72789
|
if (usage) {
|
|
71845
72790
|
process.stdout.write(` ${import_picocolors10.default.dim(`steps 1 to ${usage.maxSteps} (default ${usage.defaultSteps}) \xB7 ${usage.minSeconds} to ${usage.maxSeconds} seconds \xB7 up to ${usage.maxHosts} extra hosts`)}
|
|
@@ -71873,8 +72818,8 @@ async function browserBalance(opts) {
|
|
|
71873
72818
|
|
|
71874
72819
|
`);
|
|
71875
72820
|
if (balance2.balance) {
|
|
71876
|
-
process.stdout.write(` ${import_picocolors10.default.cyan(
|
|
71877
|
-
if (Number(balance2.balance.reservedUsd) > 0) process.stdout.write(import_picocolors10.default.dim(` \xB7 ${
|
|
72821
|
+
process.stdout.write(` ${import_picocolors10.default.cyan(usd5(balance2.balance.availableUsd))} ${import_picocolors10.default.dim("available")}`);
|
|
72822
|
+
if (Number(balance2.balance.reservedUsd) > 0) process.stdout.write(import_picocolors10.default.dim(` \xB7 ${usd5(balance2.balance.reservedUsd)} reserved by tasks in flight`));
|
|
71878
72823
|
process.stdout.write("\n");
|
|
71879
72824
|
} else {
|
|
71880
72825
|
process.stdout.write(` ${import_picocolors10.default.dim("no balance under this key yet; a top-up opens it")}
|
|
@@ -71997,7 +72942,7 @@ async function browserRun(url, opts) {
|
|
|
71997
72942
|
maxSteps,
|
|
71998
72943
|
maxSeconds,
|
|
71999
72944
|
loginRow: opts.login,
|
|
72000
|
-
note:
|
|
72945
|
+
note: jsonMode5(opts) ? void 0 : (line2) => process.stderr.write(` ${import_picocolors10.default.dim(line2)}
|
|
72001
72946
|
`)
|
|
72002
72947
|
});
|
|
72003
72948
|
if (!opts.wait) {
|
|
@@ -72014,7 +72959,7 @@ async function browserRun(url, opts) {
|
|
|
72014
72959
|
const settled = await waitForTask(keys2.wallet, task.id, {
|
|
72015
72960
|
maxSeconds: waitSeconds,
|
|
72016
72961
|
onTick: (t) => {
|
|
72017
|
-
if (
|
|
72962
|
+
if (jsonMode5(opts) || t.status === lastStatus) return;
|
|
72018
72963
|
lastStatus = t.status;
|
|
72019
72964
|
process.stderr.write(` ${import_picocolors10.default.dim(`${t.status}${t.status === "running" ? ` \xB7 ${t.stepsRun} steps` : ""}`)}
|
|
72020
72965
|
`);
|
|
@@ -72047,8 +72992,8 @@ async function browserTasks(opts) {
|
|
|
72047
72992
|
return;
|
|
72048
72993
|
}
|
|
72049
72994
|
for (const t of tasks) {
|
|
72050
|
-
const
|
|
72051
|
-
process.stdout.write(` ${status2(t.status)} ${t.id} ${import_picocolors10.default.dim(host(t.url).padEnd(24))} ${import_picocolors10.default.dim(`${t.stepsRun}/${t.maxSteps}`.padStart(6))} ${import_picocolors10.default.dim(
|
|
72995
|
+
const money2 = t.status === "done" ? usd5(t.chargedUsd) : t.status === "queued" || t.status === "running" ? `${usd5(t.reservedUsd)} reserved` : "";
|
|
72996
|
+
process.stdout.write(` ${status2(t.status)} ${t.id} ${import_picocolors10.default.dim(host(t.url).padEnd(24))} ${import_picocolors10.default.dim(`${t.stepsRun}/${t.maxSteps}`.padStart(6))} ${import_picocolors10.default.dim(money2.padEnd(16))} ${import_picocolors10.default.dim(when2(t.createdAt))}
|
|
72052
72997
|
`);
|
|
72053
72998
|
process.stdout.write(` ${t.goal.length > 90 ? `${t.goal.slice(0, 89)}\u2026` : t.goal}
|
|
72054
72999
|
`);
|
|
@@ -72070,7 +73015,7 @@ async function browserTask(id2, opts) {
|
|
|
72070
73015
|
const task = opts.wait ? await waitForTask(keys2.wallet, id2, {
|
|
72071
73016
|
maxSeconds: typeof opts.wait === "string" ? Math.max(5, Number(opts.wait) || 0) : 900,
|
|
72072
73017
|
onTick: (t) => {
|
|
72073
|
-
if (!
|
|
73018
|
+
if (!jsonMode5(opts) && !SETTLED.has(t.status)) process.stderr.write(` ${import_picocolors10.default.dim(`${t.status} \xB7 ${t.stepsRun} steps`)}
|
|
72074
73019
|
`);
|
|
72075
73020
|
}
|
|
72076
73021
|
}) : await readTask(keys2.wallet, id2);
|
|
@@ -72150,20 +73095,20 @@ function installedVersionAt(place) {
|
|
|
72150
73095
|
|
|
72151
73096
|
// src/commands/update.ts
|
|
72152
73097
|
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
72153
|
-
var
|
|
73098
|
+
var jsonMode6 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
72154
73099
|
async function update(opts = {}) {
|
|
72155
73100
|
const latest = await fetchLatest();
|
|
72156
73101
|
const place = installPlace();
|
|
72157
73102
|
const stale = !!latest && olderThan(LOCAL_VERSION, latest);
|
|
72158
73103
|
const base = { ok: true, package: PKG, current: LOCAL_VERSION, latest, stale, runsFrom: place.kind, ...place.kind === "home" ? { home: place.home } : place.kind === "checkout" ? { dir: place.dir } : {} };
|
|
72159
73104
|
if (!latest) {
|
|
72160
|
-
if (
|
|
73105
|
+
if (jsonMode6(opts)) process.stdout.write(JSON.stringify({ ...base, ok: false, code: "registry_unreachable", error: "npm's registry did not answer; try again in a moment" }, null, 2) + "\n");
|
|
72161
73106
|
else process.stderr.write(` ${import_picocolors11.default.red("\u2715")} npm's registry did not answer; try again in a moment
|
|
72162
73107
|
`);
|
|
72163
73108
|
process.exit(1);
|
|
72164
73109
|
}
|
|
72165
73110
|
if (opts.check || !stale) {
|
|
72166
|
-
if (
|
|
73111
|
+
if (jsonMode6(opts)) process.stdout.write(JSON.stringify(base, null, 2) + "\n");
|
|
72167
73112
|
else if (stale) process.stdout.write(`
|
|
72168
73113
|
${import_picocolors11.default.yellow("\u2191")} ${latest} is out; this copy is ${LOCAL_VERSION}. ${import_picocolors11.default.dim("agentgates update \xB7 installs it")}
|
|
72169
73114
|
|
|
@@ -72176,7 +73121,7 @@ async function update(opts = {}) {
|
|
|
72176
73121
|
}
|
|
72177
73122
|
if (place.kind === "checkout") {
|
|
72178
73123
|
const line2 = `cd ${place.dir} && git pull --ff-only && npm run build`;
|
|
72179
|
-
if (
|
|
73124
|
+
if (jsonMode6(opts)) process.stdout.write(JSON.stringify({ ...base, ok: false, code: "checkout", line: line2, error: "this copy runs from a repository checkout; pull it" }, null, 2) + "\n");
|
|
72180
73125
|
else process.stdout.write(`
|
|
72181
73126
|
this copy runs from a checkout at ${import_picocolors11.default.bold(place.dir)}; update it with
|
|
72182
73127
|
${import_picocolors11.default.cyan(line2)}
|
|
@@ -72184,7 +73129,7 @@ async function update(opts = {}) {
|
|
|
72184
73129
|
`);
|
|
72185
73130
|
return;
|
|
72186
73131
|
}
|
|
72187
|
-
if (!
|
|
73132
|
+
if (!jsonMode6(opts)) process.stdout.write(`
|
|
72188
73133
|
${import_picocolors11.default.bold("UPDATE")} ${LOCAL_VERSION} \u2192 ${latest} ${import_picocolors11.default.dim(place.kind === "home" ? `into ${place.home}` : "the global npm install")}
|
|
72189
73134
|
${import_picocolors11.default.dim(`npm ${place.command.join(" ")}`)}
|
|
72190
73135
|
|
|
@@ -72192,7 +73137,7 @@ async function update(opts = {}) {
|
|
|
72192
73137
|
const code = await runNpm(place.command);
|
|
72193
73138
|
const now = installedVersionAt(place);
|
|
72194
73139
|
const done = code === 0 && (place.kind !== "home" || now === latest);
|
|
72195
|
-
if (
|
|
73140
|
+
if (jsonMode6(opts)) {
|
|
72196
73141
|
process.stdout.write(JSON.stringify({ ...base, ok: done, code: done ? void 0 : "npm_failed", installed: now ?? void 0, exit: code }, null, 2) + "\n");
|
|
72197
73142
|
} else if (done) {
|
|
72198
73143
|
process.stdout.write(`
|
|
@@ -72374,7 +73319,7 @@ async function onboard(opts = {}) {
|
|
|
72374
73319
|
if (stale) put(stale);
|
|
72375
73320
|
const order = menuOrder(opts.lane, !!account, latestSeen !== null).filter((k) => existing ? k !== "wallet" : true);
|
|
72376
73321
|
printMenu(put, order, true);
|
|
72377
|
-
const rl =
|
|
73322
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
72378
73323
|
const exitDefault = String(order.indexOf("poke") + 1);
|
|
72379
73324
|
let first = true;
|
|
72380
73325
|
let plain = put;
|
|
@@ -72532,7 +73477,7 @@ init_passwords_wire();
|
|
|
72532
73477
|
init_passwords_seal();
|
|
72533
73478
|
|
|
72534
73479
|
// src/lib/mcp-stdio.ts
|
|
72535
|
-
import { createInterface as
|
|
73480
|
+
import { createInterface as createInterface3 } from "node:readline";
|
|
72536
73481
|
var MCP_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
72537
73482
|
var McpToolError = class extends Error {
|
|
72538
73483
|
constructor(message, detail = {}) {
|
|
@@ -72549,7 +73494,7 @@ var INVALID_PARAMS = -32602;
|
|
|
72549
73494
|
function reply(id2, result) {
|
|
72550
73495
|
return { jsonrpc: "2.0", id: id2, result };
|
|
72551
73496
|
}
|
|
72552
|
-
function
|
|
73497
|
+
function fail3(id2, code, message, data4) {
|
|
72553
73498
|
return { jsonrpc: "2.0", id: id2, error: data4 === void 0 ? { code, message } : { code, message, data: data4 } };
|
|
72554
73499
|
}
|
|
72555
73500
|
function parseLine(line2) {
|
|
@@ -72557,10 +73502,10 @@ function parseLine(line2) {
|
|
|
72557
73502
|
if (!trimmed) return null;
|
|
72558
73503
|
try {
|
|
72559
73504
|
const parsed = JSON.parse(trimmed);
|
|
72560
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return { response:
|
|
73505
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return { response: fail3(null, INVALID_REQUEST, "a JSON-RPC message is an object") };
|
|
72561
73506
|
return { message: parsed };
|
|
72562
73507
|
} catch {
|
|
72563
|
-
return { response:
|
|
73508
|
+
return { response: fail3(null, PARSE_ERROR, "the line is not JSON") };
|
|
72564
73509
|
}
|
|
72565
73510
|
}
|
|
72566
73511
|
var McpRich = class {
|
|
@@ -72595,7 +73540,7 @@ async function dispatch(message, tools, info) {
|
|
|
72595
73540
|
const id2 = message.id === void 0 ? null : message.id;
|
|
72596
73541
|
const isNotification = message.id === void 0;
|
|
72597
73542
|
if (typeof message.method !== "string") {
|
|
72598
|
-
return isNotification ? null :
|
|
73543
|
+
return isNotification ? null : fail3(id2, INVALID_REQUEST, "a request names a method");
|
|
72599
73544
|
}
|
|
72600
73545
|
const params = message.params && typeof message.params === "object" ? message.params : {};
|
|
72601
73546
|
switch (message.method) {
|
|
@@ -72621,7 +73566,7 @@ async function dispatch(message, tools, info) {
|
|
|
72621
73566
|
case "tools/call": {
|
|
72622
73567
|
const name = typeof params.name === "string" ? params.name : "";
|
|
72623
73568
|
const tool = tools.find((t) => t.name === name);
|
|
72624
|
-
if (!tool) return
|
|
73569
|
+
if (!tool) return fail3(id2, INVALID_PARAMS, `no tool named "${name}"`);
|
|
72625
73570
|
const args = params.arguments && typeof params.arguments === "object" && !Array.isArray(params.arguments) ? params.arguments : {};
|
|
72626
73571
|
try {
|
|
72627
73572
|
return reply(id2, toolResult(await tool.handler(args)));
|
|
@@ -72636,7 +73581,7 @@ async function dispatch(message, tools, info) {
|
|
|
72636
73581
|
case "prompts/list":
|
|
72637
73582
|
return reply(id2, { prompts: [] });
|
|
72638
73583
|
default:
|
|
72639
|
-
return isNotification ? null :
|
|
73584
|
+
return isNotification ? null : fail3(id2, METHOD_NOT_FOUND, `no method "${message.method}"`);
|
|
72640
73585
|
}
|
|
72641
73586
|
}
|
|
72642
73587
|
async function serve(tools, info, { input = process.stdin, output: output2 = process.stdout } = {}) {
|
|
@@ -72645,7 +73590,7 @@ async function serve(tools, info, { input = process.stdin, output: output2 = pro
|
|
|
72645
73590
|
`);
|
|
72646
73591
|
};
|
|
72647
73592
|
const inFlight = /* @__PURE__ */ new Set();
|
|
72648
|
-
const lines =
|
|
73593
|
+
const lines = createInterface3({ input, crlfDelay: Infinity });
|
|
72649
73594
|
for await (const line2 of lines) {
|
|
72650
73595
|
const parsed = parseLine(line2);
|
|
72651
73596
|
if (!parsed) continue;
|
|
@@ -72657,7 +73602,7 @@ async function serve(tools, info, { input = process.stdin, output: output2 = pro
|
|
|
72657
73602
|
if (response) send2(response);
|
|
72658
73603
|
}).catch((err) => {
|
|
72659
73604
|
const id2 = parsed.message.id === void 0 ? null : parsed.message.id;
|
|
72660
|
-
if (id2 !== null) send2(
|
|
73605
|
+
if (id2 !== null) send2(fail3(id2, -32603, err instanceof Error ? err.message : String(err)));
|
|
72661
73606
|
}).finally(() => {
|
|
72662
73607
|
inFlight.delete(job);
|
|
72663
73608
|
});
|
|
@@ -72949,7 +73894,7 @@ function emit6(opts, data4, human) {
|
|
|
72949
73894
|
}
|
|
72950
73895
|
human();
|
|
72951
73896
|
}
|
|
72952
|
-
function
|
|
73897
|
+
function fail4(opts, err) {
|
|
72953
73898
|
const message = err instanceof Error ? err.message : String(err);
|
|
72954
73899
|
const code = err?.code;
|
|
72955
73900
|
if (opts.json || !process.stdout.isTTY) {
|
|
@@ -73050,7 +73995,7 @@ async function memoryOverview(opts) {
|
|
|
73050
73995
|
process.stdout.write("\n");
|
|
73051
73996
|
});
|
|
73052
73997
|
} catch (err) {
|
|
73053
|
-
|
|
73998
|
+
fail4(opts, err);
|
|
73054
73999
|
}
|
|
73055
74000
|
}
|
|
73056
74001
|
async function memoryMkdir(folder, opts) {
|
|
@@ -73063,7 +74008,7 @@ async function memoryMkdir(folder, opts) {
|
|
|
73063
74008
|
|
|
73064
74009
|
`));
|
|
73065
74010
|
} catch (err) {
|
|
73066
|
-
|
|
74011
|
+
fail4(opts, err);
|
|
73067
74012
|
}
|
|
73068
74013
|
}
|
|
73069
74014
|
async function memoryRmdir(folder, opts) {
|
|
@@ -73076,7 +74021,7 @@ async function memoryRmdir(folder, opts) {
|
|
|
73076
74021
|
|
|
73077
74022
|
`));
|
|
73078
74023
|
} catch (err) {
|
|
73079
|
-
|
|
74024
|
+
fail4(opts, err);
|
|
73080
74025
|
}
|
|
73081
74026
|
}
|
|
73082
74027
|
async function memoryLs(target, opts) {
|
|
@@ -73130,7 +74075,7 @@ async function memoryLs(target, opts) {
|
|
|
73130
74075
|
process.stdout.write("\n");
|
|
73131
74076
|
});
|
|
73132
74077
|
} catch (err) {
|
|
73133
|
-
|
|
74078
|
+
fail4(opts, err);
|
|
73134
74079
|
}
|
|
73135
74080
|
}
|
|
73136
74081
|
async function memorySources(opts) {
|
|
@@ -73159,7 +74104,7 @@ async function memorySources(opts) {
|
|
|
73159
74104
|
process.stdout.write("\n");
|
|
73160
74105
|
});
|
|
73161
74106
|
} catch (err) {
|
|
73162
|
-
|
|
74107
|
+
fail4(opts, err);
|
|
73163
74108
|
}
|
|
73164
74109
|
}
|
|
73165
74110
|
async function memoryCat(path8, opts) {
|
|
@@ -73186,7 +74131,7 @@ async function memoryCat(path8, opts) {
|
|
|
73186
74131
|
emit6(opts, { ok: true, folder, name, id: row.id, version: row.version, updatedAt: row.updatedAt, text }, () => process.stdout.write(text.endsWith("\n") ? text : `${text}
|
|
73187
74132
|
`));
|
|
73188
74133
|
} catch (err) {
|
|
73189
|
-
|
|
74134
|
+
fail4(opts, err);
|
|
73190
74135
|
}
|
|
73191
74136
|
}
|
|
73192
74137
|
async function memoryPut(path8, opts) {
|
|
@@ -73209,7 +74154,7 @@ async function memoryPut(path8, opts) {
|
|
|
73209
74154
|
`)
|
|
73210
74155
|
);
|
|
73211
74156
|
} catch (err) {
|
|
73212
|
-
|
|
74157
|
+
fail4(opts, err);
|
|
73213
74158
|
}
|
|
73214
74159
|
}
|
|
73215
74160
|
async function memoryRm(path8, opts) {
|
|
@@ -73226,7 +74171,7 @@ async function memoryRm(path8, opts) {
|
|
|
73226
74171
|
|
|
73227
74172
|
`));
|
|
73228
74173
|
} catch (err) {
|
|
73229
|
-
|
|
74174
|
+
fail4(opts, err);
|
|
73230
74175
|
}
|
|
73231
74176
|
}
|
|
73232
74177
|
async function openAbout(wallet) {
|
|
@@ -73283,7 +74228,7 @@ async function memoryAbout(opts) {
|
|
|
73283
74228
|
process.stdout.write("\n");
|
|
73284
74229
|
});
|
|
73285
74230
|
} catch (err) {
|
|
73286
|
-
|
|
74231
|
+
fail4(opts, err);
|
|
73287
74232
|
}
|
|
73288
74233
|
}
|
|
73289
74234
|
async function grepMemory(wallet, key, pattern, folders) {
|
|
@@ -73332,7 +74277,7 @@ async function memoryGrep(patternRaw, folder, opts) {
|
|
|
73332
74277
|
`);
|
|
73333
74278
|
});
|
|
73334
74279
|
} catch (err) {
|
|
73335
|
-
|
|
74280
|
+
fail4(opts, err);
|
|
73336
74281
|
}
|
|
73337
74282
|
}
|
|
73338
74283
|
async function readStdin() {
|
|
@@ -73575,7 +74520,7 @@ function emit7(opts, data4, human) {
|
|
|
73575
74520
|
}
|
|
73576
74521
|
human();
|
|
73577
74522
|
}
|
|
73578
|
-
function
|
|
74523
|
+
function fail5(opts, err) {
|
|
73579
74524
|
const message = err instanceof Error ? err.message : String(err);
|
|
73580
74525
|
const code = err?.code;
|
|
73581
74526
|
if (opts.json || !process.stdout.isTTY) {
|
|
@@ -73804,7 +74749,7 @@ async function filesList(folderArg, opts) {
|
|
|
73804
74749
|
process.stdout.write("\n");
|
|
73805
74750
|
});
|
|
73806
74751
|
} catch (err) {
|
|
73807
|
-
|
|
74752
|
+
fail5(opts, err);
|
|
73808
74753
|
}
|
|
73809
74754
|
}
|
|
73810
74755
|
async function filesPut(path8, opts) {
|
|
@@ -73824,7 +74769,7 @@ async function filesPut(path8, opts) {
|
|
|
73824
74769
|
`)
|
|
73825
74770
|
);
|
|
73826
74771
|
} catch (err) {
|
|
73827
|
-
|
|
74772
|
+
fail5(opts, err);
|
|
73828
74773
|
}
|
|
73829
74774
|
}
|
|
73830
74775
|
async function filesGet(target, opts) {
|
|
@@ -73845,7 +74790,7 @@ async function filesGet(target, opts) {
|
|
|
73845
74790
|
`)
|
|
73846
74791
|
);
|
|
73847
74792
|
} catch (err) {
|
|
73848
|
-
|
|
74793
|
+
fail5(opts, err);
|
|
73849
74794
|
}
|
|
73850
74795
|
}
|
|
73851
74796
|
async function moveOpened(wallet, key, dataPublicKey, file, folder) {
|
|
@@ -73874,7 +74819,7 @@ async function filesMv(target, folderArg, opts) {
|
|
|
73874
74819
|
`)
|
|
73875
74820
|
);
|
|
73876
74821
|
} catch (err) {
|
|
73877
|
-
|
|
74822
|
+
fail5(opts, err);
|
|
73878
74823
|
}
|
|
73879
74824
|
}
|
|
73880
74825
|
async function filesRm(target, opts) {
|
|
@@ -73893,13 +74838,13 @@ async function filesRm(target, opts) {
|
|
|
73893
74838
|
`)
|
|
73894
74839
|
);
|
|
73895
74840
|
} catch (err) {
|
|
73896
|
-
|
|
74841
|
+
fail5(opts, err);
|
|
73897
74842
|
}
|
|
73898
74843
|
}
|
|
73899
74844
|
|
|
73900
74845
|
// src/commands/card.ts
|
|
73901
74846
|
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
73902
|
-
import { createInterface as
|
|
74847
|
+
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
73903
74848
|
|
|
73904
74849
|
// src/lib/memory-address.ts
|
|
73905
74850
|
var ADDRESS_FOLDER = "profile";
|
|
@@ -74377,7 +75322,7 @@ function emit8(opts, data4, human) {
|
|
|
74377
75322
|
}
|
|
74378
75323
|
human();
|
|
74379
75324
|
}
|
|
74380
|
-
function
|
|
75325
|
+
function fail6(opts, err) {
|
|
74381
75326
|
const message = err instanceof Error ? err.message : String(err);
|
|
74382
75327
|
const code = err?.code;
|
|
74383
75328
|
if (opts.json || !process.stdout.isTTY) {
|
|
@@ -74441,7 +75386,7 @@ var QUESTIONS = [
|
|
|
74441
75386
|
{ field: "zip", ask: "ZIP code", abroad: "Postal code" }
|
|
74442
75387
|
];
|
|
74443
75388
|
async function askAddress() {
|
|
74444
|
-
const rl =
|
|
75389
|
+
const rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
74445
75390
|
const answers = { country: "US", line1: "", line2: "", city: "", region: "", zip: "" };
|
|
74446
75391
|
try {
|
|
74447
75392
|
process.stdout.write(`
|
|
@@ -74523,7 +75468,7 @@ async function cardAddressSet(opts) {
|
|
|
74523
75468
|
`)
|
|
74524
75469
|
);
|
|
74525
75470
|
} catch (err) {
|
|
74526
|
-
|
|
75471
|
+
fail6(opts, err);
|
|
74527
75472
|
}
|
|
74528
75473
|
}
|
|
74529
75474
|
async function cardAddressShow(opts) {
|
|
@@ -74550,7 +75495,7 @@ ${lines.map((l) => ` ${l}`).join("\n")}
|
|
|
74550
75495
|
`)
|
|
74551
75496
|
);
|
|
74552
75497
|
} catch (err) {
|
|
74553
|
-
|
|
75498
|
+
fail6(opts, err);
|
|
74554
75499
|
}
|
|
74555
75500
|
}
|
|
74556
75501
|
async function cardAddressClear(opts) {
|
|
@@ -74566,7 +75511,7 @@ async function cardAddressClear(opts) {
|
|
|
74566
75511
|
`)
|
|
74567
75512
|
);
|
|
74568
75513
|
} catch (err) {
|
|
74569
|
-
|
|
75514
|
+
fail6(opts, err);
|
|
74570
75515
|
}
|
|
74571
75516
|
}
|
|
74572
75517
|
|
|
@@ -75437,9 +76382,9 @@ function usdOf(micro) {
|
|
|
75437
76382
|
const rest = (n2 % 1000000n).toString().padStart(6, "0").replace(/0+$/, "");
|
|
75438
76383
|
return rest ? `${whole}.${rest}` : `${whole}`;
|
|
75439
76384
|
}
|
|
75440
|
-
function microOf(
|
|
75441
|
-
const clean3 =
|
|
75442
|
-
if (!/^\d+(\.\d{1,6})?$/.test(clean3)) throw new Error(`a dollar amount, like 40 or 12.50 (got ${
|
|
76385
|
+
function microOf(usd6) {
|
|
76386
|
+
const clean3 = usd6.trim().replace(/^\$/, "");
|
|
76387
|
+
if (!/^\d+(\.\d{1,6})?$/.test(clean3)) throw new Error(`a dollar amount, like 40 or 12.50 (got ${usd6})`);
|
|
75443
76388
|
const [whole, frac = ""] = clean3.split(".");
|
|
75444
76389
|
return (BigInt(whole) * 1000000n + BigInt((frac + "000000").slice(0, 6))).toString();
|
|
75445
76390
|
}
|
|
@@ -75463,16 +76408,16 @@ function firstSentence(words7) {
|
|
|
75463
76408
|
}
|
|
75464
76409
|
|
|
75465
76410
|
// src/commands/intents.ts
|
|
75466
|
-
var
|
|
76411
|
+
var jsonMode7 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
75467
76412
|
function emit9(opts, data4, human) {
|
|
75468
|
-
if (
|
|
76413
|
+
if (jsonMode7(opts)) {
|
|
75469
76414
|
process.stdout.write(JSON.stringify(data4, null, 2) + "\n");
|
|
75470
76415
|
return;
|
|
75471
76416
|
}
|
|
75472
76417
|
human();
|
|
75473
76418
|
}
|
|
75474
76419
|
function refuse5(opts, error, code, extra = {}) {
|
|
75475
|
-
if (
|
|
76420
|
+
if (jsonMode7(opts)) {
|
|
75476
76421
|
process.stdout.write(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
|
|
75477
76422
|
} else {
|
|
75478
76423
|
process.stderr.write(` ${error}${code ? import_picocolors17.default.dim(` (${code})`) : ""}
|
|
@@ -76126,7 +77071,7 @@ function emit10(opts, data4, human) {
|
|
|
76126
77071
|
}
|
|
76127
77072
|
human();
|
|
76128
77073
|
}
|
|
76129
|
-
function
|
|
77074
|
+
function fail7(opts, err) {
|
|
76130
77075
|
const message = err instanceof Error ? err.message : String(err);
|
|
76131
77076
|
const code = err instanceof WireError ? err.code : err?.code;
|
|
76132
77077
|
if (opts.json || !process.stdout.isTTY) {
|
|
@@ -76189,7 +77134,7 @@ async function integrationsList(opts) {
|
|
|
76189
77134
|
}
|
|
76190
77135
|
});
|
|
76191
77136
|
} catch (err) {
|
|
76192
|
-
|
|
77137
|
+
fail7(opts, err);
|
|
76193
77138
|
}
|
|
76194
77139
|
}
|
|
76195
77140
|
var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -76249,7 +77194,7 @@ async function integrationsUse(integrationId, opts) {
|
|
|
76249
77194
|
return;
|
|
76250
77195
|
}
|
|
76251
77196
|
} catch (err) {
|
|
76252
|
-
|
|
77197
|
+
fail7(opts, err);
|
|
76253
77198
|
}
|
|
76254
77199
|
}
|
|
76255
77200
|
async function integrationsSignup(provider, opts) {
|
|
@@ -76268,7 +77213,7 @@ async function integrationsSignup(provider, opts) {
|
|
|
76268
77213
|
`);
|
|
76269
77214
|
});
|
|
76270
77215
|
} catch (err) {
|
|
76271
|
-
|
|
77216
|
+
fail7(opts, err);
|
|
76272
77217
|
}
|
|
76273
77218
|
}
|
|
76274
77219
|
async function integrationsSignupReport(signupId, opts) {
|
|
@@ -76283,7 +77228,7 @@ async function integrationsSignupReport(signupId, opts) {
|
|
|
76283
77228
|
`);
|
|
76284
77229
|
});
|
|
76285
77230
|
} catch (err) {
|
|
76286
|
-
|
|
77231
|
+
fail7(opts, err);
|
|
76287
77232
|
}
|
|
76288
77233
|
}
|
|
76289
77234
|
async function integrationsSignupHandoff(signupId, provider, opts) {
|
|
@@ -76308,7 +77253,7 @@ async function integrationsSignupHandoff(signupId, provider, opts) {
|
|
|
76308
77253
|
`);
|
|
76309
77254
|
});
|
|
76310
77255
|
} catch (err) {
|
|
76311
|
-
|
|
77256
|
+
fail7(opts, err);
|
|
76312
77257
|
}
|
|
76313
77258
|
}
|
|
76314
77259
|
async function sitesList(opts) {
|
|
@@ -76345,7 +77290,7 @@ async function sitesList(opts) {
|
|
|
76345
77290
|
}
|
|
76346
77291
|
});
|
|
76347
77292
|
} catch (err) {
|
|
76348
|
-
|
|
77293
|
+
fail7(opts, err);
|
|
76349
77294
|
}
|
|
76350
77295
|
}
|
|
76351
77296
|
var CHANGE_ID_RE = /^[A-Za-z0-9_-]{22}$/;
|
|
@@ -76379,7 +77324,7 @@ async function sitesChange(changeId, opts) {
|
|
|
76379
77324
|
process.stdout.write("\n");
|
|
76380
77325
|
});
|
|
76381
77326
|
} catch (err) {
|
|
76382
|
-
|
|
77327
|
+
fail7(opts, err);
|
|
76383
77328
|
}
|
|
76384
77329
|
}
|
|
76385
77330
|
async function sitesShip(changeId, opts) {
|
|
@@ -76397,7 +77342,7 @@ async function sitesShip(changeId, opts) {
|
|
|
76397
77342
|
`);
|
|
76398
77343
|
});
|
|
76399
77344
|
} catch (err) {
|
|
76400
|
-
|
|
77345
|
+
fail7(opts, err);
|
|
76401
77346
|
}
|
|
76402
77347
|
}
|
|
76403
77348
|
async function sitesSkip(changeId, opts) {
|
|
@@ -76412,7 +77357,7 @@ async function sitesSkip(changeId, opts) {
|
|
|
76412
77357
|
`);
|
|
76413
77358
|
});
|
|
76414
77359
|
} catch (err) {
|
|
76415
|
-
|
|
77360
|
+
fail7(opts, err);
|
|
76416
77361
|
}
|
|
76417
77362
|
}
|
|
76418
77363
|
async function sitesUndo(changeId, opts) {
|
|
@@ -76427,7 +77372,7 @@ async function sitesUndo(changeId, opts) {
|
|
|
76427
77372
|
`);
|
|
76428
77373
|
});
|
|
76429
77374
|
} catch (err) {
|
|
76430
|
-
|
|
77375
|
+
fail7(opts, err);
|
|
76431
77376
|
}
|
|
76432
77377
|
}
|
|
76433
77378
|
async function sitesFix(changeId, opts) {
|
|
@@ -76446,7 +77391,81 @@ async function sitesFix(changeId, opts) {
|
|
|
76446
77391
|
`);
|
|
76447
77392
|
});
|
|
76448
77393
|
} catch (err) {
|
|
76449
|
-
|
|
77394
|
+
fail7(opts, err);
|
|
77395
|
+
}
|
|
77396
|
+
}
|
|
77397
|
+
function askOf(dataKey, owner, ask) {
|
|
77398
|
+
if (!ask) return null;
|
|
77399
|
+
try {
|
|
77400
|
+
const aad = `AGENTGATES-CONVERSATION-v1|turn|${normalizeOwner2(owner)}|${ask.conversationId}|${ask.seq}|${ask.role}${ask.author ? `|${ask.author}|${ask.channel ?? ""}` : ""}`;
|
|
77401
|
+
const text = openText(dataKey, ask.ciphertext, aad);
|
|
77402
|
+
if (ask.author === "card") {
|
|
77403
|
+
const words7 = JSON.parse(text).words ?? "";
|
|
77404
|
+
return words7 ? `Fix: ${words7.split("\n")[0].trim()}` : null;
|
|
77405
|
+
}
|
|
77406
|
+
const m = /^Asked for a change on site [A-Za-z0-9_-]{22}: ([\s\S]*)$/.exec(text.trim());
|
|
77407
|
+
return (m ? m[1] : text).trim() || null;
|
|
77408
|
+
} catch {
|
|
77409
|
+
return null;
|
|
77410
|
+
}
|
|
77411
|
+
}
|
|
77412
|
+
async function sitesChanges(siteId, opts) {
|
|
77413
|
+
try {
|
|
77414
|
+
if (!CHANGE_ID_RE.test(siteId)) throw new Error("a site id is 22 characters (agentgates sites lists them)");
|
|
77415
|
+
if (opts.before && !CHANGE_ID_RE.test(opts.before)) throw new Error("--before takes the last change id of the page before");
|
|
77416
|
+
const { wallet } = await requirePasswordsKey();
|
|
77417
|
+
const q = opts.before ? `?before=${encodeURIComponent(opts.before)}` : "";
|
|
77418
|
+
const out = expectOk(await signedFetch(wallet, "GET", lanePath(`/sites/${siteId}/changes${q}`)), "sites changes");
|
|
77419
|
+
const key = await mailKeyFor(wallet).catch(() => null);
|
|
77420
|
+
const rows = (out.changes ?? []).map((c) => {
|
|
77421
|
+
let done = null;
|
|
77422
|
+
if (key && c.card) {
|
|
77423
|
+
try {
|
|
77424
|
+
done = (JSON.parse(openText(key.dataKey, c.card.ciphertext, cardAad(wallet.address, c.card))).words ?? "").split("\n")[0].trim() || null;
|
|
77425
|
+
} catch {
|
|
77426
|
+
done = null;
|
|
77427
|
+
}
|
|
77428
|
+
}
|
|
77429
|
+
const asked = key ? askOf(key.dataKey, wallet.address, c.ask) : null;
|
|
77430
|
+
return { id: c.id, state: c.state, code: c.code, round: c.round, costMicro: c.costMicro, updatedAt: c.updatedAt, title: done ?? asked ?? (c.round === 0 ? "Merged on GitHub" : null) };
|
|
77431
|
+
});
|
|
77432
|
+
emit10(opts, { ok: true, changes: rows, next: out.next ?? null }, () => {
|
|
77433
|
+
if (!rows.length) {
|
|
77434
|
+
process.stdout.write(`
|
|
77435
|
+
${import_picocolors18.default.dim("No changes yet.")}
|
|
77436
|
+
|
|
77437
|
+
`);
|
|
77438
|
+
return;
|
|
77439
|
+
}
|
|
77440
|
+
process.stdout.write("\n");
|
|
77441
|
+
for (const r of rows) {
|
|
77442
|
+
const state = r.state === "live" ? import_picocolors18.default.green("live") : r.state === "ready" ? import_picocolors18.default.cyan("ready") : import_picocolors18.default.yellow(r.code ?? r.state);
|
|
77443
|
+
process.stdout.write(` ${state} ${r.title ?? import_picocolors18.default.dim("(no words open here)")}
|
|
77444
|
+
${import_picocolors18.default.dim(`${r.id} ${r.updatedAt}`)}
|
|
77445
|
+
|
|
77446
|
+
`);
|
|
77447
|
+
}
|
|
77448
|
+
if (out.next) process.stdout.write(` ${import_picocolors18.default.dim(`older: agentgates sites changes ${siteId} --before ${out.next}`)}
|
|
77449
|
+
|
|
77450
|
+
`);
|
|
77451
|
+
});
|
|
77452
|
+
} catch (err) {
|
|
77453
|
+
fail7(opts, err);
|
|
77454
|
+
}
|
|
77455
|
+
}
|
|
77456
|
+
async function sitesRemove(siteId, opts) {
|
|
77457
|
+
try {
|
|
77458
|
+
if (!CHANGE_ID_RE.test(siteId)) throw new Error("a site id is 22 characters (agentgates sites lists them)");
|
|
77459
|
+
const { wallet } = await requirePasswordsKey();
|
|
77460
|
+
const out = expectOk(await signedFetch(wallet, "POST", lanePath(`/sites/${siteId}/remove`)), "sites remove");
|
|
77461
|
+
emit10(opts, { ok: true, id: out.id, state: out.state }, () => {
|
|
77462
|
+
process.stdout.write(`
|
|
77463
|
+
${import_picocolors18.default.yellow(out.state)} ${import_picocolors18.default.dim(out.id)}
|
|
77464
|
+
|
|
77465
|
+
`);
|
|
77466
|
+
});
|
|
77467
|
+
} catch (err) {
|
|
77468
|
+
fail7(opts, err);
|
|
76450
77469
|
}
|
|
76451
77470
|
}
|
|
76452
77471
|
|
|
@@ -76580,8 +77599,14 @@ async function readAgAttestation() {
|
|
|
76580
77599
|
if (!proven.ok) throw new WireError(0, "box_unproven", `the AG AI box did not prove itself (${proven.reason}), so nothing was sealed`, null);
|
|
76581
77600
|
return proven.value;
|
|
76582
77601
|
}
|
|
76583
|
-
async function readAgent(wallet) {
|
|
76584
|
-
return expectOk(await signedFetch(wallet, "GET", lanePath("/ag/agent")), "agent");
|
|
77602
|
+
async function readAgent(wallet, opts = {}) {
|
|
77603
|
+
return expectOk(await signedFetch(wallet, "GET", lanePath(opts.turnOn ? "/ag/agent?turnOn=1" : "/ag/agent")), "agent");
|
|
77604
|
+
}
|
|
77605
|
+
function agentProofMessage(ownerWallet, agentAddress, nonce) {
|
|
77606
|
+
return `Agentgates: turn on my agent
|
|
77607
|
+
account: ${normalizeAgOwner(ownerWallet)}
|
|
77608
|
+
agent: ${normalizeAgOwner(agentAddress)}
|
|
77609
|
+
nonce: ${nonce}`;
|
|
76585
77610
|
}
|
|
76586
77611
|
async function postAgentOn(wallet, body) {
|
|
76587
77612
|
return expectOk(await signedFetch(wallet, "POST", lanePath("/ag/agent"), body), "agent on");
|
|
@@ -76654,7 +77679,7 @@ function emit11(opts, data4, human) {
|
|
|
76654
77679
|
}
|
|
76655
77680
|
human();
|
|
76656
77681
|
}
|
|
76657
|
-
function
|
|
77682
|
+
function fail8(opts, err) {
|
|
76658
77683
|
const message = err instanceof Error ? err.message : String(err);
|
|
76659
77684
|
const code = err?.code;
|
|
76660
77685
|
if (opts.json || !process.stdout.isTTY) {
|
|
@@ -76710,7 +77735,7 @@ async function agentStatus(opts) {
|
|
|
76710
77735
|
process.stdout.write("\n");
|
|
76711
77736
|
});
|
|
76712
77737
|
} catch (err) {
|
|
76713
|
-
|
|
77738
|
+
fail8(opts, err);
|
|
76714
77739
|
}
|
|
76715
77740
|
}
|
|
76716
77741
|
async function agentOn(opts) {
|
|
@@ -76723,7 +77748,10 @@ async function agentOn(opts) {
|
|
|
76723
77748
|
if (!seal) throw new WireError(409, "seal_missing", "seal this account first (agentgates email seal): the agent's thread is written to your Memory, and Memory seals to your account's key", null);
|
|
76724
77749
|
const account = await mailKeyFor(wallet);
|
|
76725
77750
|
if (!account) throw new WireError(409, "no_key", "this machine holds no copy of the account's data key", null);
|
|
77751
|
+
const { turnOnNonce } = await readAgent(wallet, { turnOn: true });
|
|
77752
|
+
if (!turnOnNonce) throw new WireError(409, "turn_on_nonce", "the agent door gave no turn-on code, so nothing was turned on: try again", null);
|
|
76726
77753
|
const agent2 = ethers_exports.Wallet.createRandom();
|
|
77754
|
+
const proof = { nonce: turnOnNonce, signature: await agent2.signMessage(agentProofMessage(wallet.address, agent2.address, turnOnNonce)) };
|
|
76727
77755
|
const aad = agWalletKeyAad(wallet.address);
|
|
76728
77756
|
const keyOwnerBlob = sealText(seal.sealingPublicKey, agent2.privateKey, aad);
|
|
76729
77757
|
const keyBoxBlob = sealText(fleet.publicKey, agent2.privateKey, aad);
|
|
@@ -76733,7 +77761,7 @@ async function agentOn(opts) {
|
|
|
76733
77761
|
const pair = keySealingKeyFromParts({ wire: made.key, reading });
|
|
76734
77762
|
await putKeyWrap(wallet, made.created.id, { sealingPublicKey: pair.publicKey, wrap: sealTo(pair.publicKey, account.dataKey, keyWrapAad(keys2.state.address, made.created.id)) });
|
|
76735
77763
|
const memoryKeyBoxBlob = sealText(fleet.publicKey, JSON.stringify({ wire: made.key, reading }), agMemoryKeyAad(wallet.address, made.created.id));
|
|
76736
|
-
const out = await postAgentOn(wallet, { agentAddress: agent2.address, keyOwnerBlob, keyBoxBlob, memoryKeyId: made.created.id, memoryKeyBoxBlob });
|
|
77764
|
+
const out = await postAgentOn(wallet, { agentAddress: agent2.address, keyOwnerBlob, keyBoxBlob, memoryKeyId: made.created.id, memoryKeyBoxBlob, proof });
|
|
76737
77765
|
const note2 = opts.fund !== void 0 ? AGENT_PAYS_SENTENCE : null;
|
|
76738
77766
|
emit11(opts, { ok: true, agent: out.agent, memoryKeyId: made.created.id, fleet: { mode: fleet.mode, keyId: fleet.keyId }, ...note2 ? { note: note2 } : {} }, () => {
|
|
76739
77767
|
process.stdout.write(
|
|
@@ -76752,7 +77780,7 @@ async function agentOn(opts) {
|
|
|
76752
77780
|
throw err;
|
|
76753
77781
|
}
|
|
76754
77782
|
} catch (err) {
|
|
76755
|
-
|
|
77783
|
+
fail8(opts, err);
|
|
76756
77784
|
}
|
|
76757
77785
|
}
|
|
76758
77786
|
async function agentOff(opts) {
|
|
@@ -76777,14 +77805,14 @@ async function agentOff(opts) {
|
|
|
76777
77805
|
`);
|
|
76778
77806
|
});
|
|
76779
77807
|
} catch (err) {
|
|
76780
|
-
|
|
77808
|
+
fail8(opts, err);
|
|
76781
77809
|
}
|
|
76782
77810
|
}
|
|
76783
77811
|
async function agentFund(_amountUsd, opts) {
|
|
76784
|
-
|
|
77812
|
+
fail8(opts, agentPaysRefusal());
|
|
76785
77813
|
}
|
|
76786
77814
|
async function agentRefill(_action, opts) {
|
|
76787
|
-
|
|
77815
|
+
fail8(opts, agentPaysRefusal());
|
|
76788
77816
|
}
|
|
76789
77817
|
async function agentSay(text, opts) {
|
|
76790
77818
|
try {
|
|
@@ -76797,7 +77825,7 @@ async function agentSay(text, opts) {
|
|
|
76797
77825
|
`);
|
|
76798
77826
|
});
|
|
76799
77827
|
} catch (err) {
|
|
76800
|
-
|
|
77828
|
+
fail8(opts, err);
|
|
76801
77829
|
}
|
|
76802
77830
|
}
|
|
76803
77831
|
async function agentJournal(opts) {
|
|
@@ -76826,7 +77854,7 @@ async function agentJournal(opts) {
|
|
|
76826
77854
|
process.stdout.write("\n");
|
|
76827
77855
|
});
|
|
76828
77856
|
} catch (err) {
|
|
76829
|
-
|
|
77857
|
+
fail8(opts, err);
|
|
76830
77858
|
}
|
|
76831
77859
|
}
|
|
76832
77860
|
async function agentBind(channel, senderId, opts) {
|
|
@@ -76886,7 +77914,7 @@ async function agentBind(channel, senderId, opts) {
|
|
|
76886
77914
|
`);
|
|
76887
77915
|
});
|
|
76888
77916
|
} catch (err) {
|
|
76889
|
-
|
|
77917
|
+
fail8(opts, err);
|
|
76890
77918
|
}
|
|
76891
77919
|
}
|
|
76892
77920
|
async function agentBindings(opts) {
|
|
@@ -76907,7 +77935,7 @@ async function agentBindings(opts) {
|
|
|
76907
77935
|
process.stdout.write("\n");
|
|
76908
77936
|
});
|
|
76909
77937
|
} catch (err) {
|
|
76910
|
-
|
|
77938
|
+
fail8(opts, err);
|
|
76911
77939
|
}
|
|
76912
77940
|
}
|
|
76913
77941
|
async function agentUnbind(id2, opts) {
|
|
@@ -76922,7 +77950,7 @@ async function agentUnbind(id2, opts) {
|
|
|
76922
77950
|
`);
|
|
76923
77951
|
});
|
|
76924
77952
|
} catch (err) {
|
|
76925
|
-
|
|
77953
|
+
fail8(opts, err);
|
|
76926
77954
|
}
|
|
76927
77955
|
}
|
|
76928
77956
|
|
|
@@ -76991,16 +78019,16 @@ async function whoami(opts) {
|
|
|
76991
78019
|
`));
|
|
76992
78020
|
}
|
|
76993
78021
|
const { profile, name: profileName } = resolved;
|
|
76994
|
-
const
|
|
78022
|
+
const jsonMode8 = opts.json === true;
|
|
76995
78023
|
const outcome = await callWithAutoRelogin({
|
|
76996
78024
|
profile,
|
|
76997
78025
|
profileName,
|
|
76998
|
-
jsonMode:
|
|
78026
|
+
jsonMode: jsonMode8,
|
|
76999
78027
|
ttyHeader: import_picocolors21.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
77000
78028
|
fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
|
|
77001
78029
|
});
|
|
77002
78030
|
if (outcome.kind === "auth_failed") {
|
|
77003
|
-
if (
|
|
78031
|
+
if (jsonMode8) {
|
|
77004
78032
|
process.stdout.write(
|
|
77005
78033
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
77006
78034
|
);
|
|
@@ -77020,7 +78048,7 @@ async function whoami(opts) {
|
|
|
77020
78048
|
throw err;
|
|
77021
78049
|
}
|
|
77022
78050
|
const me = outcome.result;
|
|
77023
|
-
if (
|
|
78051
|
+
if (jsonMode8) {
|
|
77024
78052
|
process.stdout.write(JSON.stringify(me, null, 2) + "\n");
|
|
77025
78053
|
return;
|
|
77026
78054
|
}
|
|
@@ -77233,7 +78261,7 @@ async function send(amount, asset, opts) {
|
|
|
77233
78261
|
}
|
|
77234
78262
|
const { profile, name: profileName } = resolved;
|
|
77235
78263
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
77236
|
-
const
|
|
78264
|
+
const jsonMode8 = opts.json === true || !stdoutIsTty;
|
|
77237
78265
|
const amountNumber = Number(amount);
|
|
77238
78266
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
77239
78267
|
process.stderr.write(
|
|
@@ -77342,12 +78370,12 @@ async function send(amount, asset, opts) {
|
|
|
77342
78370
|
try {
|
|
77343
78371
|
activeProfile = await runLoginFlow({
|
|
77344
78372
|
profile: profileName,
|
|
77345
|
-
jsonMode:
|
|
78373
|
+
jsonMode: jsonMode8,
|
|
77346
78374
|
origin: activeProfile.mcpOrigin,
|
|
77347
78375
|
ttyHeader: import_picocolors22.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
77348
78376
|
});
|
|
77349
78377
|
} catch (reloginErr) {
|
|
77350
|
-
if (
|
|
78378
|
+
if (jsonMode8) {
|
|
77351
78379
|
emitNdjson({
|
|
77352
78380
|
ok: false,
|
|
77353
78381
|
status: "auth_failed",
|
|
@@ -77370,7 +78398,7 @@ async function send(amount, asset, opts) {
|
|
|
77370
78398
|
});
|
|
77371
78399
|
} catch (retryErr) {
|
|
77372
78400
|
if (retryErr instanceof ApiError) {
|
|
77373
|
-
if (
|
|
78401
|
+
if (jsonMode8) {
|
|
77374
78402
|
emitNdjson({
|
|
77375
78403
|
ok: false,
|
|
77376
78404
|
status: retryErr.status === 401 ? "auth_failed" : "propose_failed",
|
|
@@ -77388,7 +78416,7 @@ async function send(amount, asset, opts) {
|
|
|
77388
78416
|
throw retryErr;
|
|
77389
78417
|
}
|
|
77390
78418
|
} else if (err instanceof ApiError) {
|
|
77391
|
-
if (
|
|
78419
|
+
if (jsonMode8) {
|
|
77392
78420
|
emitNdjson({
|
|
77393
78421
|
ok: false,
|
|
77394
78422
|
status: "propose_failed",
|
|
@@ -77405,7 +78433,7 @@ async function send(amount, asset, opts) {
|
|
|
77405
78433
|
}
|
|
77406
78434
|
}
|
|
77407
78435
|
if (isBlocked(proposed)) {
|
|
77408
|
-
if (
|
|
78436
|
+
if (jsonMode8) {
|
|
77409
78437
|
const envelope = {
|
|
77410
78438
|
ok: false,
|
|
77411
78439
|
status: "blocked",
|
|
@@ -77469,7 +78497,7 @@ async function send(amount, asset, opts) {
|
|
|
77469
78497
|
if (process.env.CI === "1" || process.env.CI === "true") return false;
|
|
77470
78498
|
return true;
|
|
77471
78499
|
})();
|
|
77472
|
-
if (
|
|
78500
|
+
if (jsonMode8) {
|
|
77473
78501
|
emitNdjson({
|
|
77474
78502
|
ok: true,
|
|
77475
78503
|
status: "proposed",
|
|
@@ -77501,7 +78529,7 @@ ${import_picocolors22.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77501
78529
|
intervalMs: POLL_INTERVAL_MS,
|
|
77502
78530
|
giveUpMs: POLL_GIVEUP_MS,
|
|
77503
78531
|
onTick: (s) => {
|
|
77504
|
-
if (
|
|
78532
|
+
if (jsonMode8) {
|
|
77505
78533
|
emitNdjson({ status: s.status, intent_id: s.approval_id });
|
|
77506
78534
|
} else {
|
|
77507
78535
|
process.stdout.write(` ${describeStatus(s.status)}${import_picocolors22.default.dim("\u2026")}\r`);
|
|
@@ -77516,12 +78544,12 @@ ${import_picocolors22.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77516
78544
|
try {
|
|
77517
78545
|
activeProfile = await runLoginFlow({
|
|
77518
78546
|
profile: profileName,
|
|
77519
|
-
jsonMode:
|
|
78547
|
+
jsonMode: jsonMode8,
|
|
77520
78548
|
origin: activeProfile.mcpOrigin,
|
|
77521
78549
|
ttyHeader: import_picocolors22.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
|
|
77522
78550
|
});
|
|
77523
78551
|
} catch (reloginErr) {
|
|
77524
|
-
if (
|
|
78552
|
+
if (jsonMode8) {
|
|
77525
78553
|
emitNdjson({
|
|
77526
78554
|
ok: false,
|
|
77527
78555
|
status: "auth_failed",
|
|
@@ -77539,7 +78567,7 @@ ${import_picocolors22.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77539
78567
|
try {
|
|
77540
78568
|
final = await runPoll(activeProfile);
|
|
77541
78569
|
} catch (retryErr) {
|
|
77542
|
-
if (
|
|
78570
|
+
if (jsonMode8) {
|
|
77543
78571
|
emitNdjson({
|
|
77544
78572
|
ok: false,
|
|
77545
78573
|
status: retryErr instanceof ApiError && retryErr.status === 401 ? "auth_failed" : "poll_failed",
|
|
@@ -77555,7 +78583,7 @@ ${import_picocolors22.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77555
78583
|
process.exit(1);
|
|
77556
78584
|
}
|
|
77557
78585
|
} else {
|
|
77558
|
-
if (
|
|
78586
|
+
if (jsonMode8) {
|
|
77559
78587
|
emitNdjson({
|
|
77560
78588
|
ok: false,
|
|
77561
78589
|
status: "poll_failed",
|
|
@@ -77572,7 +78600,7 @@ ${import_picocolors22.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77572
78600
|
}
|
|
77573
78601
|
}
|
|
77574
78602
|
const explorer = final.tx_hash != null ? explorerUrl(final.chain_id, final.tx_hash) : null;
|
|
77575
|
-
if (
|
|
78603
|
+
if (jsonMode8) {
|
|
77576
78604
|
emitNdjson({
|
|
77577
78605
|
ok: final.status === "mined",
|
|
77578
78606
|
status: final.status,
|
|
@@ -77658,16 +78686,16 @@ async function status3(intentId, opts) {
|
|
|
77658
78686
|
`));
|
|
77659
78687
|
}
|
|
77660
78688
|
const { profile, name: profileName } = resolved;
|
|
77661
|
-
const
|
|
78689
|
+
const jsonMode8 = opts.json === true;
|
|
77662
78690
|
const outcome = await callWithAutoRelogin({
|
|
77663
78691
|
profile,
|
|
77664
78692
|
profileName,
|
|
77665
|
-
jsonMode:
|
|
78693
|
+
jsonMode: jsonMode8,
|
|
77666
78694
|
ttyHeader: import_picocolors23.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
77667
78695
|
fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
|
|
77668
78696
|
});
|
|
77669
78697
|
if (outcome.kind === "auth_failed") {
|
|
77670
|
-
if (
|
|
78698
|
+
if (jsonMode8) {
|
|
77671
78699
|
process.stdout.write(
|
|
77672
78700
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
77673
78701
|
);
|
|
@@ -77694,7 +78722,7 @@ async function status3(intentId, opts) {
|
|
|
77694
78722
|
let snap = outcome.result;
|
|
77695
78723
|
let activeProfile = outcome.profile;
|
|
77696
78724
|
if (opts.watch && !isTerminalStatus(snap.status)) {
|
|
77697
|
-
if (!
|
|
78725
|
+
if (!jsonMode8) {
|
|
77698
78726
|
printSnap(snap);
|
|
77699
78727
|
process.stdout.write(import_picocolors23.default.dim("Watching\u2026\n"));
|
|
77700
78728
|
}
|
|
@@ -77706,7 +78734,7 @@ async function status3(intentId, opts) {
|
|
|
77706
78734
|
intervalMs: 0,
|
|
77707
78735
|
giveUpMs: WATCH_GIVEUP_MS,
|
|
77708
78736
|
onTick: (s) => {
|
|
77709
|
-
if (!
|
|
78737
|
+
if (!jsonMode8) {
|
|
77710
78738
|
process.stdout.write(` ${import_picocolors23.default.dim("\u2192")} ${s.status}
|
|
77711
78739
|
`);
|
|
77712
78740
|
}
|
|
@@ -77720,12 +78748,12 @@ async function status3(intentId, opts) {
|
|
|
77720
78748
|
try {
|
|
77721
78749
|
activeProfile = await runLoginFlow({
|
|
77722
78750
|
profile: profileName,
|
|
77723
|
-
jsonMode:
|
|
78751
|
+
jsonMode: jsonMode8,
|
|
77724
78752
|
origin: activeProfile.mcpOrigin,
|
|
77725
78753
|
ttyHeader: import_picocolors23.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
|
|
77726
78754
|
});
|
|
77727
78755
|
} catch (reloginErr) {
|
|
77728
|
-
if (
|
|
78756
|
+
if (jsonMode8) {
|
|
77729
78757
|
process.stdout.write(
|
|
77730
78758
|
JSON.stringify({
|
|
77731
78759
|
ok: false,
|
|
@@ -77754,14 +78782,14 @@ async function status3(intentId, opts) {
|
|
|
77754
78782
|
process.exit(1);
|
|
77755
78783
|
}
|
|
77756
78784
|
}
|
|
77757
|
-
if (
|
|
78785
|
+
if (jsonMode8) {
|
|
77758
78786
|
process.stdout.write(JSON.stringify(final, null, 2) + "\n");
|
|
77759
78787
|
} else {
|
|
77760
78788
|
printSnap(final);
|
|
77761
78789
|
}
|
|
77762
78790
|
process.exit(final.status === "mined" ? 0 : 1);
|
|
77763
78791
|
}
|
|
77764
|
-
if (
|
|
78792
|
+
if (jsonMode8) {
|
|
77765
78793
|
process.stdout.write(JSON.stringify(snap, null, 2) + "\n");
|
|
77766
78794
|
process.exit(snap.status === "mined" ? 0 : 0);
|
|
77767
78795
|
}
|
|
@@ -77854,16 +78882,16 @@ async function balance(opts) {
|
|
|
77854
78882
|
}
|
|
77855
78883
|
chainFilter = id2;
|
|
77856
78884
|
}
|
|
77857
|
-
const
|
|
78885
|
+
const jsonMode8 = opts.json === true;
|
|
77858
78886
|
const outcome = await callWithAutoRelogin({
|
|
77859
78887
|
profile,
|
|
77860
78888
|
profileName,
|
|
77861
|
-
jsonMode:
|
|
78889
|
+
jsonMode: jsonMode8,
|
|
77862
78890
|
ttyHeader: import_picocolors24.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
77863
78891
|
fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
|
|
77864
78892
|
});
|
|
77865
78893
|
if (outcome.kind === "auth_failed") {
|
|
77866
|
-
if (
|
|
78894
|
+
if (jsonMode8) {
|
|
77867
78895
|
process.stdout.write(
|
|
77868
78896
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
77869
78897
|
);
|
|
@@ -77884,7 +78912,7 @@ async function balance(opts) {
|
|
|
77884
78912
|
}
|
|
77885
78913
|
const res = outcome.result;
|
|
77886
78914
|
const filtered = chainFilter !== null ? res.chains.filter((c) => c.chainId === chainFilter) : res.chains;
|
|
77887
|
-
if (
|
|
78915
|
+
if (jsonMode8) {
|
|
77888
78916
|
process.stdout.write(
|
|
77889
78917
|
JSON.stringify(
|
|
77890
78918
|
chainFilter !== null ? { ...res, chains: filtered } : res,
|
|
@@ -78012,11 +79040,11 @@ async function history(opts) {
|
|
|
78012
79040
|
}
|
|
78013
79041
|
limit = n2;
|
|
78014
79042
|
}
|
|
78015
|
-
const
|
|
79043
|
+
const jsonMode8 = opts.json === true;
|
|
78016
79044
|
const outcome = await callWithAutoRelogin({
|
|
78017
79045
|
profile,
|
|
78018
79046
|
profileName,
|
|
78019
|
-
jsonMode:
|
|
79047
|
+
jsonMode: jsonMode8,
|
|
78020
79048
|
ttyHeader: import_picocolors25.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
78021
79049
|
fn: (bearer, origin) => apiFetch(
|
|
78022
79050
|
`/api/history?limit=${encodeURIComponent(String(limit))}`,
|
|
@@ -78024,7 +79052,7 @@ async function history(opts) {
|
|
|
78024
79052
|
)
|
|
78025
79053
|
});
|
|
78026
79054
|
if (outcome.kind === "auth_failed") {
|
|
78027
|
-
if (
|
|
79055
|
+
if (jsonMode8) {
|
|
78028
79056
|
process.stdout.write(
|
|
78029
79057
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
78030
79058
|
);
|
|
@@ -78044,7 +79072,7 @@ async function history(opts) {
|
|
|
78044
79072
|
throw err;
|
|
78045
79073
|
}
|
|
78046
79074
|
const res = outcome.result;
|
|
78047
|
-
if (
|
|
79075
|
+
if (jsonMode8) {
|
|
78048
79076
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
78049
79077
|
return;
|
|
78050
79078
|
}
|
|
@@ -78562,7 +79590,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
78562
79590
|
}
|
|
78563
79591
|
const { profile, name: profileName } = resolved;
|
|
78564
79592
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
78565
|
-
const
|
|
79593
|
+
const jsonMode8 = opts.json === true || !stdoutIsTty;
|
|
78566
79594
|
const amountNumber = Number(amount);
|
|
78567
79595
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
78568
79596
|
failArg(`amount must be a positive number (got ${import_picocolors27.default.bold(amount)}).`);
|
|
@@ -78701,7 +79729,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
78701
79729
|
body: proposeBody,
|
|
78702
79730
|
profileName,
|
|
78703
79731
|
initialProfile: profile,
|
|
78704
|
-
jsonMode:
|
|
79732
|
+
jsonMode: jsonMode8,
|
|
78705
79733
|
shouldOpenBrowser,
|
|
78706
79734
|
buildRetryCommand
|
|
78707
79735
|
});
|
|
@@ -78722,7 +79750,7 @@ async function batch(opts) {
|
|
|
78722
79750
|
process.exit(2);
|
|
78723
79751
|
}
|
|
78724
79752
|
const { name: profileName, profile } = resolved;
|
|
78725
|
-
const
|
|
79753
|
+
const jsonMode8 = opts.json === true || !process.stdout.isTTY;
|
|
78726
79754
|
let legs;
|
|
78727
79755
|
try {
|
|
78728
79756
|
legs = JSON.parse(opts.legsJson);
|
|
@@ -78766,7 +79794,7 @@ async function batch(opts) {
|
|
|
78766
79794
|
},
|
|
78767
79795
|
profileName,
|
|
78768
79796
|
initialProfile: profile,
|
|
78769
|
-
jsonMode:
|
|
79797
|
+
jsonMode: jsonMode8,
|
|
78770
79798
|
shouldOpenBrowser
|
|
78771
79799
|
});
|
|
78772
79800
|
}
|
|
@@ -78791,7 +79819,7 @@ async function fundWallet(address, opts) {
|
|
|
78791
79819
|
process.exit(2);
|
|
78792
79820
|
}
|
|
78793
79821
|
const { name: profileName, profile } = resolved;
|
|
78794
|
-
const
|
|
79822
|
+
const jsonMode8 = opts.json === true || !process.stdout.isTTY;
|
|
78795
79823
|
if (!opts.chain) {
|
|
78796
79824
|
failArg3("--chain is required (1/137/8453/42161/900 or shortName).");
|
|
78797
79825
|
}
|
|
@@ -78843,7 +79871,7 @@ async function fundWallet(address, opts) {
|
|
|
78843
79871
|
},
|
|
78844
79872
|
profileName,
|
|
78845
79873
|
initialProfile: profile,
|
|
78846
|
-
jsonMode:
|
|
79874
|
+
jsonMode: jsonMode8,
|
|
78847
79875
|
shouldOpenBrowser
|
|
78848
79876
|
});
|
|
78849
79877
|
}
|
|
@@ -78858,7 +79886,7 @@ async function fundWallet(address, opts) {
|
|
|
78858
79886
|
},
|
|
78859
79887
|
profileName,
|
|
78860
79888
|
initialProfile: profile,
|
|
78861
|
-
jsonMode:
|
|
79889
|
+
jsonMode: jsonMode8,
|
|
78862
79890
|
shouldOpenBrowser
|
|
78863
79891
|
});
|
|
78864
79892
|
}
|
|
@@ -78885,7 +79913,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
78885
79913
|
}
|
|
78886
79914
|
const { profile, name: profileName } = resolved;
|
|
78887
79915
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
78888
|
-
const
|
|
79916
|
+
const jsonMode8 = opts.json === true || !stdoutIsTty;
|
|
78889
79917
|
const amountNumber = Number(amount);
|
|
78890
79918
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
78891
79919
|
failArg4(`amount must be a positive number (got ${import_picocolors30.default.bold(amount)}).`);
|
|
@@ -78951,7 +79979,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
78951
79979
|
body: proposeBody,
|
|
78952
79980
|
profileName,
|
|
78953
79981
|
initialProfile: profile,
|
|
78954
|
-
jsonMode:
|
|
79982
|
+
jsonMode: jsonMode8,
|
|
78955
79983
|
shouldOpenBrowser
|
|
78956
79984
|
});
|
|
78957
79985
|
}
|
|
@@ -78978,7 +80006,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
78978
80006
|
}
|
|
78979
80007
|
const { profile, name: profileName } = resolved;
|
|
78980
80008
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
78981
|
-
const
|
|
80009
|
+
const jsonMode8 = opts.json === true || !stdoutIsTty;
|
|
78982
80010
|
const isMax = amountOrMax.toLowerCase() === "max";
|
|
78983
80011
|
if (!isMax) {
|
|
78984
80012
|
const amountNumber = Number(amountOrMax);
|
|
@@ -79049,7 +80077,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
79049
80077
|
body: proposeBody,
|
|
79050
80078
|
profileName,
|
|
79051
80079
|
initialProfile: profile,
|
|
79052
|
-
jsonMode:
|
|
80080
|
+
jsonMode: jsonMode8,
|
|
79053
80081
|
shouldOpenBrowser
|
|
79054
80082
|
});
|
|
79055
80083
|
}
|
|
@@ -79091,8 +80119,8 @@ async function loadResolvedProfile(requested) {
|
|
|
79091
80119
|
}
|
|
79092
80120
|
return resolved;
|
|
79093
80121
|
}
|
|
79094
|
-
function printResult(res,
|
|
79095
|
-
if (
|
|
80122
|
+
function printResult(res, jsonMode8) {
|
|
80123
|
+
if (jsonMode8) {
|
|
79096
80124
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
79097
80125
|
return;
|
|
79098
80126
|
}
|
|
@@ -79128,16 +80156,16 @@ async function postRestaurantQuiet(path8, body, resolved) {
|
|
|
79128
80156
|
return null;
|
|
79129
80157
|
}
|
|
79130
80158
|
}
|
|
79131
|
-
async function postRestaurant(path8, body, resolved,
|
|
80159
|
+
async function postRestaurant(path8, body, resolved, jsonMode8) {
|
|
79132
80160
|
const outcome = await callWithAutoRelogin({
|
|
79133
80161
|
profile: resolved.profile,
|
|
79134
80162
|
profileName: resolved.name,
|
|
79135
|
-
jsonMode:
|
|
80163
|
+
jsonMode: jsonMode8,
|
|
79136
80164
|
ttyHeader: import_picocolors32.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
79137
80165
|
fn: (bearer, origin) => apiFetch(path8, { method: "POST", bearer, origin, body })
|
|
79138
80166
|
});
|
|
79139
80167
|
if (outcome.kind === "auth_failed") {
|
|
79140
|
-
if (
|
|
80168
|
+
if (jsonMode8) {
|
|
79141
80169
|
process.stdout.write(
|
|
79142
80170
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
79143
80171
|
);
|
|
@@ -79150,7 +80178,7 @@ async function postRestaurant(path8, body, resolved, jsonMode7) {
|
|
|
79150
80178
|
if (outcome.kind === "error") {
|
|
79151
80179
|
const err = outcome.error;
|
|
79152
80180
|
if (err instanceof ApiError) {
|
|
79153
|
-
if (
|
|
80181
|
+
if (jsonMode8) {
|
|
79154
80182
|
process.stdout.write(
|
|
79155
80183
|
JSON.stringify({ ok: false, status: "request_failed", error: err.message, http_status: err.status }) + "\n"
|
|
79156
80184
|
);
|
|
@@ -79166,7 +80194,7 @@ async function postRestaurant(path8, body, resolved, jsonMode7) {
|
|
|
79166
80194
|
}
|
|
79167
80195
|
async function searchFood(opts) {
|
|
79168
80196
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
79169
|
-
const
|
|
80197
|
+
const jsonMode8 = opts.json === true || process.stdout.isTTY !== true;
|
|
79170
80198
|
if (!opts.location && !opts.name) {
|
|
79171
80199
|
process.stderr.write(
|
|
79172
80200
|
import_picocolors32.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
|
|
@@ -79182,12 +80210,12 @@ async function searchFood(opts) {
|
|
|
79182
80210
|
if (opts.radiusMiles !== void 0) body.radius_miles = Number(opts.radiusMiles);
|
|
79183
80211
|
if (opts.openOnly !== void 0) body.open_only = opts.openOnly;
|
|
79184
80212
|
if (opts.limit !== void 0) body.limit = Number(opts.limit);
|
|
79185
|
-
const result = await postRestaurant("/api/restaurants/search", body, resolved,
|
|
79186
|
-
if (result) printResult(result,
|
|
80213
|
+
const result = await postRestaurant("/api/restaurants/search", body, resolved, jsonMode8);
|
|
80214
|
+
if (result) printResult(result, jsonMode8);
|
|
79187
80215
|
}
|
|
79188
80216
|
async function menuFood(items, opts) {
|
|
79189
80217
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
79190
|
-
const
|
|
80218
|
+
const jsonMode8 = opts.json === true || process.stdout.isTTY !== true;
|
|
79191
80219
|
if (!opts.brand || !opts.address) {
|
|
79192
80220
|
process.stderr.write(
|
|
79193
80221
|
import_picocolors32.default.red(
|
|
@@ -79202,12 +80230,12 @@ async function menuFood(items, opts) {
|
|
|
79202
80230
|
intent: opts.intent,
|
|
79203
80231
|
items: items ?? []
|
|
79204
80232
|
};
|
|
79205
|
-
const result = await postRestaurant("/api/restaurants/menu", body, resolved,
|
|
79206
|
-
if (result) printResult(result,
|
|
80233
|
+
const result = await postRestaurant("/api/restaurants/menu", body, resolved, jsonMode8);
|
|
80234
|
+
if (result) printResult(result, jsonMode8);
|
|
79207
80235
|
}
|
|
79208
80236
|
async function orderFood(items, opts) {
|
|
79209
80237
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
79210
|
-
const
|
|
80238
|
+
const jsonMode8 = opts.json === true || process.stdout.isTTY !== true;
|
|
79211
80239
|
if (!opts.brand || !opts.address) {
|
|
79212
80240
|
process.stderr.write(
|
|
79213
80241
|
import_picocolors32.default.red(
|
|
@@ -79238,9 +80266,9 @@ async function orderFood(items, opts) {
|
|
|
79238
80266
|
fulfillment: opts.fulfillment,
|
|
79239
80267
|
intent: opts.intent
|
|
79240
80268
|
};
|
|
79241
|
-
const result = await postRestaurant("/api/restaurants/order", body, resolved,
|
|
80269
|
+
const result = await postRestaurant("/api/restaurants/order", body, resolved, jsonMode8);
|
|
79242
80270
|
if (!result) return;
|
|
79243
|
-
printResult(result,
|
|
80271
|
+
printResult(result, jsonMode8);
|
|
79244
80272
|
const approvalUrl = typeof result.approval_url === "string" ? result.approval_url : null;
|
|
79245
80273
|
const browserAllowed = (() => {
|
|
79246
80274
|
if (opts.browserMode === "open") return true;
|
|
@@ -79259,7 +80287,7 @@ async function orderFood(items, opts) {
|
|
|
79259
80287
|
return;
|
|
79260
80288
|
}
|
|
79261
80289
|
if (!agentCard.will_attempt) {
|
|
79262
|
-
if (!
|
|
80290
|
+
if (!jsonMode8) {
|
|
79263
80291
|
process.stderr.write(
|
|
79264
80292
|
import_picocolors32.default.yellow(
|
|
79265
80293
|
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
@@ -79270,8 +80298,8 @@ async function orderFood(items, opts) {
|
|
|
79270
80298
|
openApproval();
|
|
79271
80299
|
return;
|
|
79272
80300
|
}
|
|
79273
|
-
const verdict = await pollOrderVerdict(orderId, resolved,
|
|
79274
|
-
if (
|
|
80301
|
+
const verdict = await pollOrderVerdict(orderId, resolved, jsonMode8);
|
|
80302
|
+
if (jsonMode8) {
|
|
79275
80303
|
process.stdout.write(JSON.stringify(verdict) + "\n");
|
|
79276
80304
|
if (verdict.status === "failed") return;
|
|
79277
80305
|
return;
|
|
@@ -79328,8 +80356,8 @@ function fmtCents(cents) {
|
|
|
79328
80356
|
}
|
|
79329
80357
|
var POLL_BUDGET_MS = 1e5;
|
|
79330
80358
|
var POLL_INTERVAL_MS2 = 3500;
|
|
79331
|
-
async function pollOrderVerdict(orderId, resolved,
|
|
79332
|
-
if (!
|
|
80359
|
+
async function pollOrderVerdict(orderId, resolved, jsonMode8) {
|
|
80360
|
+
if (!jsonMode8) {
|
|
79333
80361
|
process.stderr.write(import_picocolors32.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
|
|
79334
80362
|
}
|
|
79335
80363
|
const deadline = Date.now() + POLL_BUDGET_MS;
|
|
@@ -79360,19 +80388,19 @@ async function pollOrderVerdict(orderId, resolved, jsonMode7) {
|
|
|
79360
80388
|
}
|
|
79361
80389
|
async function statusFood(orderId, opts) {
|
|
79362
80390
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
79363
|
-
const
|
|
80391
|
+
const jsonMode8 = opts.json === true || process.stdout.isTTY !== true;
|
|
79364
80392
|
const result = await postRestaurant(
|
|
79365
80393
|
"/api/restaurants/order-status",
|
|
79366
80394
|
{ order_id: orderId.trim() },
|
|
79367
80395
|
resolved,
|
|
79368
|
-
|
|
80396
|
+
jsonMode8
|
|
79369
80397
|
);
|
|
79370
80398
|
if (!result) return;
|
|
79371
80399
|
if (result.blocked) {
|
|
79372
|
-
printResult(result,
|
|
80400
|
+
printResult(result, jsonMode8);
|
|
79373
80401
|
return;
|
|
79374
80402
|
}
|
|
79375
|
-
if (
|
|
80403
|
+
if (jsonMode8) {
|
|
79376
80404
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
79377
80405
|
return;
|
|
79378
80406
|
}
|
|
@@ -79414,16 +80442,16 @@ async function withProfile(opts, path8, init2) {
|
|
|
79414
80442
|
`));
|
|
79415
80443
|
}
|
|
79416
80444
|
const { profile, name: profileName } = resolved;
|
|
79417
|
-
const
|
|
80445
|
+
const jsonMode8 = opts.json === true;
|
|
79418
80446
|
const outcome = await callWithAutoRelogin({
|
|
79419
80447
|
profile,
|
|
79420
80448
|
profileName,
|
|
79421
|
-
jsonMode:
|
|
80449
|
+
jsonMode: jsonMode8,
|
|
79422
80450
|
ttyHeader: import_picocolors33.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
79423
80451
|
fn: (bearer, origin) => apiFetch(path8, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
|
|
79424
80452
|
});
|
|
79425
80453
|
if (outcome.kind === "auth_failed") {
|
|
79426
|
-
if (
|
|
80454
|
+
if (jsonMode8) {
|
|
79427
80455
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
79428
80456
|
process.exit(1);
|
|
79429
80457
|
}
|
|
@@ -79442,9 +80470,9 @@ async function withProfile(opts, path8, init2) {
|
|
|
79442
80470
|
}
|
|
79443
80471
|
return outcome.result;
|
|
79444
80472
|
}
|
|
79445
|
-
function handleBlocked(res,
|
|
80473
|
+
function handleBlocked(res, jsonMode8) {
|
|
79446
80474
|
if (!res.blocked) return false;
|
|
79447
|
-
if (
|
|
80475
|
+
if (jsonMode8) {
|
|
79448
80476
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
79449
80477
|
process.exit(1);
|
|
79450
80478
|
}
|
|
@@ -79508,9 +80536,9 @@ function printTable(rows) {
|
|
|
79508
80536
|
}
|
|
79509
80537
|
}
|
|
79510
80538
|
async function listBounties(opts) {
|
|
79511
|
-
const
|
|
80539
|
+
const jsonMode8 = opts.json === true;
|
|
79512
80540
|
const res = await withProfile(opts, "/api/bounties");
|
|
79513
|
-
handleBlocked(res,
|
|
80541
|
+
handleBlocked(res, jsonMode8);
|
|
79514
80542
|
let rows = res.bounties ?? [];
|
|
79515
80543
|
const min = opts.min !== void 0 ? Number(opts.min) : void 0;
|
|
79516
80544
|
const max = opts.max !== void 0 ? Number(opts.max) : void 0;
|
|
@@ -79548,7 +80576,7 @@ async function listBounties(opts) {
|
|
|
79548
80576
|
process.exit(2);
|
|
79549
80577
|
}
|
|
79550
80578
|
const shown2 = rows.slice(0, limit);
|
|
79551
|
-
if (
|
|
80579
|
+
if (jsonMode8) {
|
|
79552
80580
|
process.stdout.write(JSON.stringify({ bounties: shown2, matched: rows.length }, null, 2) + "\n");
|
|
79553
80581
|
return;
|
|
79554
80582
|
}
|
|
@@ -79567,15 +80595,15 @@ async function listBounties(opts) {
|
|
|
79567
80595
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
79568
80596
|
}
|
|
79569
80597
|
async function showBounty(id2, opts) {
|
|
79570
|
-
const
|
|
80598
|
+
const jsonMode8 = opts.json === true;
|
|
79571
80599
|
const clean3 = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
|
|
79572
80600
|
if (!clean3) {
|
|
79573
80601
|
process.stderr.write(import_picocolors33.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
|
|
79574
80602
|
process.exit(2);
|
|
79575
80603
|
}
|
|
79576
80604
|
const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean3)}`);
|
|
79577
|
-
handleBlocked(res,
|
|
79578
|
-
if (
|
|
80605
|
+
handleBlocked(res, jsonMode8);
|
|
80606
|
+
if (jsonMode8) {
|
|
79579
80607
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
79580
80608
|
return;
|
|
79581
80609
|
}
|
|
@@ -79606,13 +80634,13 @@ async function showBounty(id2, opts) {
|
|
|
79606
80634
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
79607
80635
|
}
|
|
79608
80636
|
async function myBounties(opts) {
|
|
79609
|
-
const
|
|
80637
|
+
const jsonMode8 = opts.json === true;
|
|
79610
80638
|
const res = await withProfile(opts, "/api/bounties?mine=1");
|
|
79611
|
-
handleBlocked(res,
|
|
80639
|
+
handleBlocked(res, jsonMode8);
|
|
79612
80640
|
const all = res.bounties ?? [];
|
|
79613
80641
|
const status4 = opts.status?.trim().toUpperCase();
|
|
79614
80642
|
const rows = status4 ? all.filter((r) => (r.status ?? "").toUpperCase() === status4) : all;
|
|
79615
|
-
if (
|
|
80643
|
+
if (jsonMode8) {
|
|
79616
80644
|
process.stdout.write(JSON.stringify({ bounties: rows, submissions: res.submissions ?? [] }, null, 2) + "\n");
|
|
79617
80645
|
return;
|
|
79618
80646
|
}
|
|
@@ -79634,14 +80662,14 @@ async function myBounties(opts) {
|
|
|
79634
80662
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
79635
80663
|
}
|
|
79636
80664
|
async function bountyFeed(opts) {
|
|
79637
|
-
const
|
|
80665
|
+
const jsonMode8 = opts.json === true;
|
|
79638
80666
|
const params = new URLSearchParams();
|
|
79639
80667
|
if (opts.limit) params.set("limit", opts.limit);
|
|
79640
80668
|
if (opts.type) params.set("type", opts.type);
|
|
79641
80669
|
const qs = params.toString();
|
|
79642
80670
|
const res = await withProfile(opts, `/api/bounties/feed${qs ? `?${qs}` : ""}`);
|
|
79643
|
-
handleBlocked(res,
|
|
79644
|
-
if (
|
|
80671
|
+
handleBlocked(res, jsonMode8);
|
|
80672
|
+
if (jsonMode8) {
|
|
79645
80673
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
79646
80674
|
return;
|
|
79647
80675
|
}
|
|
@@ -79656,7 +80684,7 @@ async function bountyFeed(opts) {
|
|
|
79656
80684
|
process.stdout.write(import_picocolors33.default.dim("Use --json for the full rows.\n"));
|
|
79657
80685
|
}
|
|
79658
80686
|
async function draftBounty(opts) {
|
|
79659
|
-
const
|
|
80687
|
+
const jsonMode8 = opts.json === true;
|
|
79660
80688
|
const amountNum = Number(opts.amount);
|
|
79661
80689
|
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
79662
80690
|
process.stderr.write(import_picocolors33.default.red("\u2715 --amount must be a positive number of USDC.\n"));
|
|
@@ -79672,8 +80700,8 @@ async function draftBounty(opts) {
|
|
|
79672
80700
|
evidenceType: opts.evidenceType
|
|
79673
80701
|
}
|
|
79674
80702
|
});
|
|
79675
|
-
handleBlocked(res,
|
|
79676
|
-
if (
|
|
80703
|
+
handleBlocked(res, jsonMode8);
|
|
80704
|
+
if (jsonMode8) {
|
|
79677
80705
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
79678
80706
|
return;
|
|
79679
80707
|
}
|
|
@@ -79694,10 +80722,10 @@ function failArg6(message) {
|
|
|
79694
80722
|
`));
|
|
79695
80723
|
process.exit(2);
|
|
79696
80724
|
}
|
|
79697
|
-
async function loadProfileOrExit(requested,
|
|
80725
|
+
async function loadProfileOrExit(requested, jsonMode8) {
|
|
79698
80726
|
const resolved = await resolveProfile(requested);
|
|
79699
80727
|
if (!resolved) {
|
|
79700
|
-
if (
|
|
80728
|
+
if (jsonMode8) {
|
|
79701
80729
|
process.stdout.write(
|
|
79702
80730
|
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
|
|
79703
80731
|
);
|
|
@@ -79706,7 +80734,7 @@ async function loadProfileOrExit(requested, jsonMode7) {
|
|
|
79706
80734
|
}
|
|
79707
80735
|
process.exit(2);
|
|
79708
80736
|
}
|
|
79709
|
-
if (resolved.autoSelected && !
|
|
80737
|
+
if (resolved.autoSelected && !jsonMode8) {
|
|
79710
80738
|
process.stderr.write(import_picocolors34.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
79711
80739
|
`));
|
|
79712
80740
|
}
|
|
@@ -79726,8 +80754,8 @@ function resolveMaxUsd(opts, profile, fallbackHint) {
|
|
|
79726
80754
|
);
|
|
79727
80755
|
}
|
|
79728
80756
|
async function fundBounty(bountyId, opts) {
|
|
79729
|
-
const
|
|
79730
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
80757
|
+
const jsonMode8 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
80758
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode8);
|
|
79731
80759
|
const maxUsd = resolveMaxUsd(opts, profile, "agentgates fund");
|
|
79732
80760
|
return runIntentFlow({
|
|
79733
80761
|
endpoint: "/api/intents/propose-fund-bounty",
|
|
@@ -79746,17 +80774,17 @@ async function fundBounty(bountyId, opts) {
|
|
|
79746
80774
|
},
|
|
79747
80775
|
profileName,
|
|
79748
80776
|
initialProfile: profile,
|
|
79749
|
-
jsonMode:
|
|
80777
|
+
jsonMode: jsonMode8,
|
|
79750
80778
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
79751
80779
|
});
|
|
79752
80780
|
}
|
|
79753
80781
|
async function tipBounty(bountyId, amount, opts) {
|
|
79754
|
-
const
|
|
80782
|
+
const jsonMode8 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
79755
80783
|
const amt = Number(amount);
|
|
79756
80784
|
if (!Number.isFinite(amt) || amt <= 0) {
|
|
79757
80785
|
failArg6(`amount must be a positive USDC number (got ${amount}).`);
|
|
79758
80786
|
}
|
|
79759
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
80787
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode8);
|
|
79760
80788
|
const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "agentgates tip") : Math.ceil(amt * 1.01 * 100) / 100;
|
|
79761
80789
|
return runIntentFlow({
|
|
79762
80790
|
endpoint: "/api/intents/propose-tip",
|
|
@@ -79776,17 +80804,17 @@ async function tipBounty(bountyId, amount, opts) {
|
|
|
79776
80804
|
},
|
|
79777
80805
|
profileName,
|
|
79778
80806
|
initialProfile: profile,
|
|
79779
|
-
jsonMode:
|
|
80807
|
+
jsonMode: jsonMode8,
|
|
79780
80808
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
79781
80809
|
});
|
|
79782
80810
|
}
|
|
79783
80811
|
async function subscribeCreator(creatorUserId, opts) {
|
|
79784
|
-
const
|
|
80812
|
+
const jsonMode8 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
79785
80813
|
const months = opts.months === void 0 ? 1 : Number(opts.months);
|
|
79786
80814
|
if (![1, 3, 12].includes(months)) {
|
|
79787
80815
|
failArg6(`--months must be 1, 3 or 12 (got ${opts.months}). Prepaid periods only \u2014 no auto-renew exists.`);
|
|
79788
80816
|
}
|
|
79789
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
80817
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode8);
|
|
79790
80818
|
const maxUsd = resolveMaxUsd(opts, profile, "agentgates subscribe");
|
|
79791
80819
|
return runIntentFlow({
|
|
79792
80820
|
endpoint: "/api/intents/propose-subscribe",
|
|
@@ -79806,7 +80834,7 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
79806
80834
|
},
|
|
79807
80835
|
profileName,
|
|
79808
80836
|
initialProfile: profile,
|
|
79809
|
-
jsonMode:
|
|
80837
|
+
jsonMode: jsonMode8,
|
|
79810
80838
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
79811
80839
|
});
|
|
79812
80840
|
}
|
|
@@ -79825,16 +80853,16 @@ async function runWork(path8, body, opts) {
|
|
|
79825
80853
|
process.stderr.write(import_picocolors35.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
79826
80854
|
`));
|
|
79827
80855
|
}
|
|
79828
|
-
const
|
|
80856
|
+
const jsonMode8 = opts.json === true;
|
|
79829
80857
|
const outcome = await callWithAutoRelogin({
|
|
79830
80858
|
profile: resolved.profile,
|
|
79831
80859
|
profileName: resolved.name,
|
|
79832
|
-
jsonMode:
|
|
80860
|
+
jsonMode: jsonMode8,
|
|
79833
80861
|
ttyHeader: import_picocolors35.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
79834
80862
|
fn: (bearer, origin) => apiFetch(path8, { bearer, origin, method: "POST", body })
|
|
79835
80863
|
});
|
|
79836
80864
|
if (outcome.kind === "auth_failed") {
|
|
79837
|
-
if (
|
|
80865
|
+
if (jsonMode8) {
|
|
79838
80866
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
79839
80867
|
process.exit(1);
|
|
79840
80868
|
}
|
|
@@ -79845,7 +80873,7 @@ async function runWork(path8, body, opts) {
|
|
|
79845
80873
|
if (outcome.kind === "error") {
|
|
79846
80874
|
const err = outcome.error;
|
|
79847
80875
|
if (err instanceof ApiError) {
|
|
79848
|
-
if (
|
|
80876
|
+
if (jsonMode8) {
|
|
79849
80877
|
process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
|
|
79850
80878
|
} else {
|
|
79851
80879
|
process.stderr.write(import_picocolors35.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
@@ -79857,7 +80885,7 @@ async function runWork(path8, body, opts) {
|
|
|
79857
80885
|
}
|
|
79858
80886
|
const data4 = outcome.result;
|
|
79859
80887
|
if (data4.blocked) {
|
|
79860
|
-
if (
|
|
80888
|
+
if (jsonMode8) {
|
|
79861
80889
|
process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
|
|
79862
80890
|
process.exit(1);
|
|
79863
80891
|
}
|
|
@@ -79871,7 +80899,7 @@ ${import_picocolors35.default.bold(data4.upgrade_url)}
|
|
|
79871
80899
|
process.exit(1);
|
|
79872
80900
|
}
|
|
79873
80901
|
if (typeof data4.error === "string" && data4.error) {
|
|
79874
|
-
if (
|
|
80902
|
+
if (jsonMode8) {
|
|
79875
80903
|
process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
|
|
79876
80904
|
} else {
|
|
79877
80905
|
process.stderr.write(import_picocolors35.default.red(`\u2715 ${data4.error}
|
|
@@ -79879,7 +80907,7 @@ ${import_picocolors35.default.bold(data4.upgrade_url)}
|
|
|
79879
80907
|
}
|
|
79880
80908
|
process.exit(1);
|
|
79881
80909
|
}
|
|
79882
|
-
if (
|
|
80910
|
+
if (jsonMode8) {
|
|
79883
80911
|
process.stdout.write(JSON.stringify({ ok: true, ...data4 }) + "\n");
|
|
79884
80912
|
return;
|
|
79885
80913
|
}
|
|
@@ -79923,14 +80951,14 @@ init_constants();
|
|
|
79923
80951
|
var FLUSH_MS = 400;
|
|
79924
80952
|
var FLUSH_BYTES = 2048;
|
|
79925
80953
|
async function deliver(bountyId, command, opts) {
|
|
79926
|
-
const
|
|
80954
|
+
const jsonMode8 = opts.json === true;
|
|
79927
80955
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
79928
80956
|
const resolved = await resolveProfile(requested);
|
|
79929
80957
|
if (!resolved) {
|
|
79930
80958
|
process.stderr.write(import_picocolors36.default.red("Not logged in. Run agentgates login first.\n"));
|
|
79931
80959
|
process.exit(2);
|
|
79932
80960
|
}
|
|
79933
|
-
if (resolved.autoSelected && !
|
|
80961
|
+
if (resolved.autoSelected && !jsonMode8) {
|
|
79934
80962
|
process.stderr.write(import_picocolors36.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
79935
80963
|
`));
|
|
79936
80964
|
}
|
|
@@ -79938,7 +80966,7 @@ async function deliver(bountyId, command, opts) {
|
|
|
79938
80966
|
const outcome = await callWithAutoRelogin({
|
|
79939
80967
|
profile: resolved.profile,
|
|
79940
80968
|
profileName: resolved.name,
|
|
79941
|
-
jsonMode:
|
|
80969
|
+
jsonMode: jsonMode8,
|
|
79942
80970
|
ttyHeader: import_picocolors36.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
79943
80971
|
fn: (bearer, origin) => apiFetch(path8, { bearer, origin, method: "POST", body })
|
|
79944
80972
|
});
|
|
@@ -79947,7 +80975,7 @@ async function deliver(bountyId, command, opts) {
|
|
|
79947
80975
|
return outcome.result;
|
|
79948
80976
|
};
|
|
79949
80977
|
const die = (msg, data4) => {
|
|
79950
|
-
if (
|
|
80978
|
+
if (jsonMode8) {
|
|
79951
80979
|
process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
|
|
79952
80980
|
} else {
|
|
79953
80981
|
process.stderr.write(import_picocolors36.default.red(`
|
|
@@ -79977,7 +81005,7 @@ ${import_picocolors36.default.bold(data4.upgrade_url)}
|
|
|
79977
81005
|
if (started.error) return void die(started.error, started);
|
|
79978
81006
|
const runId = started.run_id;
|
|
79979
81007
|
if (!runId) return void die("The service opened a run but did not name it.");
|
|
79980
|
-
if (!
|
|
81008
|
+
if (!jsonMode8) {
|
|
79981
81009
|
process.stderr.write(
|
|
79982
81010
|
import_picocolors36.default.bold("\n\u25CF LIVE ") + import_picocolors36.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors36.default.dim(` ${started.url ?? ""}
|
|
79983
81011
|
|
|
@@ -80008,7 +81036,7 @@ ${import_picocolors36.default.bold(data4.upgrade_url)}
|
|
|
80008
81036
|
const timer = setInterval(() => flush(true), FLUSH_MS);
|
|
80009
81037
|
const consume = (data4) => {
|
|
80010
81038
|
buffer += data4;
|
|
80011
|
-
if (!opts.quiet && !
|
|
81039
|
+
if (!opts.quiet && !jsonMode8) process.stderr.write(data4);
|
|
80012
81040
|
flush();
|
|
80013
81041
|
};
|
|
80014
81042
|
let exitCode = 0;
|
|
@@ -80031,7 +81059,7 @@ ${import_picocolors36.default.bold(data4.upgrade_url)}
|
|
|
80031
81059
|
child.stdout.on("data", (d) => consume(d));
|
|
80032
81060
|
child.stderr.setEncoding("utf8");
|
|
80033
81061
|
child.stderr.on("data", (d) => {
|
|
80034
|
-
if (!
|
|
81062
|
+
if (!jsonMode8) process.stderr.write(import_picocolors36.default.dim(d));
|
|
80035
81063
|
});
|
|
80036
81064
|
child.on("error", (err) => {
|
|
80037
81065
|
process.stderr.write(import_picocolors36.default.red(`
|
|
@@ -80056,7 +81084,7 @@ ${import_picocolors36.default.bold(data4.upgrade_url)}
|
|
|
80056
81084
|
}
|
|
80057
81085
|
if (finished.blocked) return void die(finished.reason ?? "Blocked.", finished);
|
|
80058
81086
|
if (finished.error) return void die(finished.error, finished);
|
|
80059
|
-
if (
|
|
81087
|
+
if (jsonMode8) {
|
|
80060
81088
|
process.stdout.write(
|
|
80061
81089
|
JSON.stringify({
|
|
80062
81090
|
ok: true,
|
|
@@ -80094,7 +81122,7 @@ init_constants();
|
|
|
80094
81122
|
// src/lib/trade-sol.ts
|
|
80095
81123
|
var import_web3 = __toESM(require_index_cjs(), 1);
|
|
80096
81124
|
init_constants();
|
|
80097
|
-
import { promises as
|
|
81125
|
+
import { promises as fs9 } from "node:fs";
|
|
80098
81126
|
import * as path6 from "node:path";
|
|
80099
81127
|
import * as os3 from "node:os";
|
|
80100
81128
|
var TRADE_CHAIN_ID = 901;
|
|
@@ -80191,7 +81219,7 @@ function tradeSolPath() {
|
|
|
80191
81219
|
async function loadTradeKey() {
|
|
80192
81220
|
let raw;
|
|
80193
81221
|
try {
|
|
80194
|
-
raw = await
|
|
81222
|
+
raw = await fs9.readFile(tradeSolPath(), "utf8");
|
|
80195
81223
|
} catch (err) {
|
|
80196
81224
|
if (err.code === "ENOENT") return null;
|
|
80197
81225
|
throw err;
|
|
@@ -80219,11 +81247,11 @@ async function loadOrCreateTradeKey() {
|
|
|
80219
81247
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
80220
81248
|
};
|
|
80221
81249
|
const dir = path6.dirname(tradeSolPath());
|
|
80222
|
-
await
|
|
80223
|
-
await
|
|
81250
|
+
await fs9.mkdir(dir, { recursive: true, mode: 448 });
|
|
81251
|
+
await fs9.chmod(dir, 448).catch(() => {
|
|
80224
81252
|
});
|
|
80225
|
-
await
|
|
80226
|
-
await
|
|
81253
|
+
await fs9.writeFile(tradeSolPath(), JSON.stringify(state, null, 2), { mode: 384 });
|
|
81254
|
+
await fs9.chmod(tradeSolPath(), 384).catch(() => {
|
|
80227
81255
|
});
|
|
80228
81256
|
return { state, keypair, created: true };
|
|
80229
81257
|
}
|
|
@@ -80452,7 +81480,7 @@ async function runTrade(args) {
|
|
|
80452
81480
|
}
|
|
80453
81481
|
|
|
80454
81482
|
// src/commands/trade.ts
|
|
80455
|
-
function
|
|
81483
|
+
function fail9(message, json2) {
|
|
80456
81484
|
if (json2) {
|
|
80457
81485
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
80458
81486
|
} else {
|
|
@@ -80466,7 +81494,7 @@ async function withContext(opts, fn) {
|
|
|
80466
81494
|
const ctx2 = await resolveTradeContext();
|
|
80467
81495
|
return await fn(ctx2);
|
|
80468
81496
|
} catch (err) {
|
|
80469
|
-
|
|
81497
|
+
fail9(err.message, opts.json);
|
|
80470
81498
|
}
|
|
80471
81499
|
}
|
|
80472
81500
|
function servedFloorUnits(ctx2) {
|
|
@@ -80492,7 +81520,7 @@ async function tradeKey(opts) {
|
|
|
80492
81520
|
];
|
|
80493
81521
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
80494
81522
|
} catch (err) {
|
|
80495
|
-
|
|
81523
|
+
fail9(err.message, opts.json);
|
|
80496
81524
|
}
|
|
80497
81525
|
}
|
|
80498
81526
|
async function tradeStatus(opts) {
|
|
@@ -80549,7 +81577,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
80549
81577
|
const coin = await resolveCoin(coinArg);
|
|
80550
81578
|
const amountNumber = Number(amount);
|
|
80551
81579
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
80552
|
-
|
|
81580
|
+
fail9(`Amount "${amount}" is not a positive number.`, opts.json);
|
|
80553
81581
|
}
|
|
80554
81582
|
const res = await fetch(`${CREATORS_ORIGIN}/api/launch-quote`, {
|
|
80555
81583
|
method: "POST",
|
|
@@ -80563,7 +81591,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
80563
81591
|
});
|
|
80564
81592
|
const body = await res.json().catch(() => null);
|
|
80565
81593
|
if (!res.ok || !body) {
|
|
80566
|
-
|
|
81594
|
+
fail9(`Quote failed: ${body?.error ?? `HTTP ${res.status}`}`, opts.json);
|
|
80567
81595
|
}
|
|
80568
81596
|
const floor = servedFloorUnits(ctx2);
|
|
80569
81597
|
const belowFloor = side === "buy" && floor !== null && parseDecimalToUnits(amount, USDC_DECIMALS, "Amount") < floor.units;
|
|
@@ -80638,12 +81666,12 @@ async function tradeBuy(coinArg, amount, opts) {
|
|
|
80638
81666
|
try {
|
|
80639
81667
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
|
|
80640
81668
|
} catch (err) {
|
|
80641
|
-
|
|
81669
|
+
fail9(err.message, opts.json);
|
|
80642
81670
|
}
|
|
80643
|
-
if (units <= 0n)
|
|
81671
|
+
if (units <= 0n) fail9("Buy amount must be above zero.", opts.json);
|
|
80644
81672
|
const floor = servedFloorUnits(ctx2);
|
|
80645
81673
|
if (floor && units < floor.units) {
|
|
80646
|
-
|
|
81674
|
+
fail9(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
80647
81675
|
}
|
|
80648
81676
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
80649
81677
|
if (created && !opts.json) {
|
|
@@ -80658,23 +81686,23 @@ async function tradeSell(coinArg, amount, opts) {
|
|
|
80658
81686
|
await withContext(opts, async (ctx2) => {
|
|
80659
81687
|
const coin = await resolveCoin(coinArg);
|
|
80660
81688
|
const key = await loadTradeKey();
|
|
80661
|
-
if (!key)
|
|
81689
|
+
if (!key) fail9("No agent trading key yet (nothing to sell with). Run: agentgates trade key", opts.json);
|
|
80662
81690
|
let sellAmount = amount.trim();
|
|
80663
81691
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
80664
81692
|
if (sellAmount === "all" || pct) {
|
|
80665
81693
|
const bal = await readTokenBalance(rpcConnection(), key.state.address, coin.mint);
|
|
80666
|
-
if (!bal)
|
|
80667
|
-
if (bal.units <= 0n)
|
|
81694
|
+
if (!bal) fail9("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
|
|
81695
|
+
if (bal.units <= 0n) fail9("This key holds none of that coin.", opts.json);
|
|
80668
81696
|
let units = bal.units;
|
|
80669
81697
|
if (pct) {
|
|
80670
81698
|
const p = BigInt(pct[1]);
|
|
80671
|
-
if (p <= 0n || p > 100n)
|
|
81699
|
+
if (p <= 0n || p > 100n) fail9(`Percentage must be 1-100, got "${amount}".`, opts.json);
|
|
80672
81700
|
units = bal.units * p / 100n;
|
|
80673
81701
|
}
|
|
80674
|
-
if (units <= 0n)
|
|
81702
|
+
if (units <= 0n) fail9("Sell amount rounds to zero.", opts.json);
|
|
80675
81703
|
sellAmount = formatUnits2(units, bal.decimals);
|
|
80676
81704
|
} else if (!/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
80677
|
-
|
|
81705
|
+
fail9(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
80678
81706
|
}
|
|
80679
81707
|
const result = await runTrade({ ctx: ctx2, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
|
|
80680
81708
|
await reportTrade(ctx2, opts, { side: "sell", coin, address: key.state.address, amount: sellAmount, result });
|
|
@@ -80689,16 +81717,16 @@ function describeOrder(o) {
|
|
|
80689
81717
|
async function tradeOrderPlace(coinArg, opts) {
|
|
80690
81718
|
await withContext(opts, async (ctx2) => {
|
|
80691
81719
|
if (opts.buy === void 0 === (opts.sell === void 0)) {
|
|
80692
|
-
|
|
81720
|
+
fail9("Pass exactly one of --buy <usdc> or --sell <amount|N%|all>.", opts.json);
|
|
80693
81721
|
}
|
|
80694
81722
|
if (opts.at === void 0 === (opts.onGraduation !== true)) {
|
|
80695
|
-
|
|
81723
|
+
fail9("Pass exactly one trigger: --at <value> (price, or mcap with --mcap) or --on-graduation.", opts.json);
|
|
80696
81724
|
}
|
|
80697
81725
|
const coin = await resolveCoin(coinArg);
|
|
80698
81726
|
const side = opts.buy !== void 0 ? "buy" : "sell";
|
|
80699
81727
|
const kind = opts.onGraduation ? side === "buy" ? "buy_on_graduation" : "sell_on_graduation" : side === "buy" ? "buy_at" : "sell_at";
|
|
80700
|
-
if (opts.stop && kind !== "sell_at")
|
|
80701
|
-
if (opts.mcap && !opts.at)
|
|
81728
|
+
if (opts.stop && kind !== "sell_at") fail9("--stop only applies to a --sell order with --at.", opts.json);
|
|
81729
|
+
if (opts.mcap && !opts.at) fail9("--mcap qualifies --at.", opts.json);
|
|
80702
81730
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
80703
81731
|
if (created && !opts.json) {
|
|
80704
81732
|
process.stderr.write(import_picocolors37.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
@@ -80710,11 +81738,11 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
80710
81738
|
try {
|
|
80711
81739
|
units = parseDecimalToUnits(opts.buy, USDC_DECIMALS, "Buy amount");
|
|
80712
81740
|
} catch (err) {
|
|
80713
|
-
|
|
81741
|
+
fail9(err.message, opts.json);
|
|
80714
81742
|
}
|
|
80715
81743
|
const floor = servedFloorUnits(ctx2);
|
|
80716
81744
|
if (floor && units < floor.units) {
|
|
80717
|
-
|
|
81745
|
+
fail9(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
80718
81746
|
}
|
|
80719
81747
|
amount = opts.buy;
|
|
80720
81748
|
} else {
|
|
@@ -80722,24 +81750,24 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
80722
81750
|
const pct = amount.match(/^(\d+)%$/);
|
|
80723
81751
|
if (amount === "all" || pct) {
|
|
80724
81752
|
const bal = await readTokenBalance(rpcConnection(), state.address, coin.mint);
|
|
80725
|
-
if (!bal)
|
|
80726
|
-
if (bal.units <= 0n)
|
|
81753
|
+
if (!bal) fail9("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
|
|
81754
|
+
if (bal.units <= 0n) fail9("This key holds none of that coin.", opts.json);
|
|
80727
81755
|
let units = bal.units;
|
|
80728
81756
|
if (pct) {
|
|
80729
81757
|
const p = BigInt(pct[1]);
|
|
80730
|
-
if (p <= 0n || p > 100n)
|
|
81758
|
+
if (p <= 0n || p > 100n) fail9(`Percentage must be 1-100, got "${opts.sell}".`, opts.json);
|
|
80731
81759
|
units = bal.units * p / 100n;
|
|
80732
81760
|
}
|
|
80733
|
-
if (units <= 0n)
|
|
81761
|
+
if (units <= 0n) fail9("Sell amount rounds to zero.", opts.json);
|
|
80734
81762
|
amount = formatUnits2(units, bal.decimals);
|
|
80735
81763
|
} else if (!/^\d+(\.\d+)?$/.test(amount)) {
|
|
80736
|
-
|
|
81764
|
+
fail9(`Sell amount "${opts.sell}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
80737
81765
|
}
|
|
80738
81766
|
}
|
|
80739
81767
|
let expiresInDays;
|
|
80740
81768
|
if (opts.expiresDays !== void 0) {
|
|
80741
81769
|
const n2 = Number(opts.expiresDays);
|
|
80742
|
-
if (!Number.isInteger(n2) || n2 < 1)
|
|
81770
|
+
if (!Number.isInteger(n2) || n2 < 1) fail9(`--expires-days must be a positive integer, got "${opts.expiresDays}".`, opts.json);
|
|
80743
81771
|
expiresInDays = n2;
|
|
80744
81772
|
}
|
|
80745
81773
|
const prepared = await prepareOrder({
|
|
@@ -80775,7 +81803,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
80775
81803
|
async function tradeOrdersList(opts) {
|
|
80776
81804
|
await withContext(opts, async (ctx2) => {
|
|
80777
81805
|
const key = await loadTradeKey();
|
|
80778
|
-
if (!key)
|
|
81806
|
+
if (!key) fail9("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
80779
81807
|
const token = opts.coin ? (await resolveCoin(opts.coin)).mint : void 0;
|
|
80780
81808
|
const res = await listOrders(key.state.address, token);
|
|
80781
81809
|
if (opts.json) {
|
|
@@ -80795,15 +81823,15 @@ async function tradeOrdersList(opts) {
|
|
|
80795
81823
|
async function tradeOrderCancel(id2, opts) {
|
|
80796
81824
|
await withContext(opts, async (_ctx) => {
|
|
80797
81825
|
const key = await loadTradeKey();
|
|
80798
|
-
if (!key)
|
|
81826
|
+
if (!key) fail9("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
80799
81827
|
try {
|
|
80800
81828
|
await cancelOrder(id2, key.state.address);
|
|
80801
81829
|
} catch (err) {
|
|
80802
81830
|
if (err instanceof RelayError && err.status === 409) {
|
|
80803
|
-
|
|
81831
|
+
fail9(`Order ${id2} already fired or ended; nothing to cancel.`, opts.json);
|
|
80804
81832
|
}
|
|
80805
81833
|
if (err instanceof RelayError && err.status === 404) {
|
|
80806
|
-
|
|
81834
|
+
fail9(`No order ${id2} for this key (already canceled, or never placed).`, opts.json);
|
|
80807
81835
|
}
|
|
80808
81836
|
throw err;
|
|
80809
81837
|
}
|
|
@@ -80818,12 +81846,12 @@ async function tradeOrderCancel(id2, opts) {
|
|
|
80818
81846
|
async function tradePositions(opts) {
|
|
80819
81847
|
await withContext(opts, async (ctx2) => {
|
|
80820
81848
|
const key = await loadTradeKey();
|
|
80821
|
-
if (!key)
|
|
81849
|
+
if (!key) fail9("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
80822
81850
|
let body;
|
|
80823
81851
|
try {
|
|
80824
81852
|
body = await relayGet(`/launch-portfolio?address=${encodeURIComponent(key.state.address)}`);
|
|
80825
81853
|
} catch (err) {
|
|
80826
|
-
if (err instanceof RelayError)
|
|
81854
|
+
if (err instanceof RelayError) fail9(`Positions read failed: ${err.message}`, opts.json);
|
|
80827
81855
|
throw err;
|
|
80828
81856
|
}
|
|
80829
81857
|
const rows = body?.tokens ?? [];
|
|
@@ -80871,7 +81899,7 @@ init_constants();
|
|
|
80871
81899
|
|
|
80872
81900
|
// src/lib/desk-sol.ts
|
|
80873
81901
|
var import_web32 = __toESM(require_index_cjs(), 1);
|
|
80874
|
-
import { promises as
|
|
81902
|
+
import { promises as fs10 } from "node:fs";
|
|
80875
81903
|
import * as path7 from "node:path";
|
|
80876
81904
|
import * as os4 from "node:os";
|
|
80877
81905
|
async function resolveDeskContext() {
|
|
@@ -80893,7 +81921,7 @@ function deskSessionKeyPath() {
|
|
|
80893
81921
|
async function loadDeskSessionKey() {
|
|
80894
81922
|
let raw;
|
|
80895
81923
|
try {
|
|
80896
|
-
raw = await
|
|
81924
|
+
raw = await fs10.readFile(deskSessionPath(), "utf8");
|
|
80897
81925
|
} catch (err) {
|
|
80898
81926
|
if (err.code === "ENOENT") return null;
|
|
80899
81927
|
throw err;
|
|
@@ -80922,11 +81950,11 @@ async function loadOrCreateDeskSessionKey() {
|
|
|
80922
81950
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
80923
81951
|
};
|
|
80924
81952
|
const dir = path7.dirname(deskSessionPath());
|
|
80925
|
-
await
|
|
80926
|
-
await
|
|
81953
|
+
await fs10.mkdir(dir, { recursive: true, mode: 448 });
|
|
81954
|
+
await fs10.chmod(dir, 448).catch(() => {
|
|
80927
81955
|
});
|
|
80928
|
-
await
|
|
80929
|
-
await
|
|
81956
|
+
await fs10.writeFile(deskSessionPath(), JSON.stringify(state, null, 2), { mode: 384 });
|
|
81957
|
+
await fs10.chmod(deskSessionPath(), 384).catch(() => {
|
|
80930
81958
|
});
|
|
80931
81959
|
return { state, keypair, created: true };
|
|
80932
81960
|
}
|
|
@@ -81037,7 +82065,7 @@ async function runDeskTrade(args) {
|
|
|
81037
82065
|
}
|
|
81038
82066
|
|
|
81039
82067
|
// src/commands/desk.ts
|
|
81040
|
-
function
|
|
82068
|
+
function fail10(message, json2) {
|
|
81041
82069
|
if (json2) {
|
|
81042
82070
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
81043
82071
|
} else {
|
|
@@ -81051,7 +82079,7 @@ async function withDesk(opts, fn) {
|
|
|
81051
82079
|
const ctx2 = await resolveDeskContext();
|
|
81052
82080
|
return await fn(ctx2);
|
|
81053
82081
|
} catch (err) {
|
|
81054
|
-
|
|
82082
|
+
fail10(err.message, opts.json);
|
|
81055
82083
|
}
|
|
81056
82084
|
}
|
|
81057
82085
|
function servedFloorUnits2(ctx2) {
|
|
@@ -81062,7 +82090,7 @@ function servedFloorUnits2(ctx2) {
|
|
|
81062
82090
|
async function requireOwner(opts) {
|
|
81063
82091
|
const key = await loadTradeKey();
|
|
81064
82092
|
if (!key) {
|
|
81065
|
-
|
|
82093
|
+
fail10("No agent trading key yet (the desk's owner). Run: agentgates trade key", opts.json);
|
|
81066
82094
|
}
|
|
81067
82095
|
return key;
|
|
81068
82096
|
}
|
|
@@ -81131,7 +82159,7 @@ async function deskStatus(opts) {
|
|
|
81131
82159
|
if (opts.fills !== void 0) {
|
|
81132
82160
|
const n2 = Number(opts.fills);
|
|
81133
82161
|
if (!Number.isInteger(n2) || n2 <= 0) {
|
|
81134
|
-
|
|
82162
|
+
fail10(`--fills must be a positive integer, got "${opts.fills}".`, opts.json);
|
|
81135
82163
|
}
|
|
81136
82164
|
fillsLimit = n2;
|
|
81137
82165
|
}
|
|
@@ -81179,9 +82207,9 @@ async function deskDeposit(amount, opts) {
|
|
|
81179
82207
|
try {
|
|
81180
82208
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Deposit amount");
|
|
81181
82209
|
} catch (err) {
|
|
81182
|
-
|
|
82210
|
+
fail10(err.message, opts.json);
|
|
81183
82211
|
}
|
|
81184
|
-
if (units <= 0n)
|
|
82212
|
+
if (units <= 0n) fail10("Deposit amount must be above zero.", opts.json);
|
|
81185
82213
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
81186
82214
|
if (created && !opts.json) {
|
|
81187
82215
|
process.stderr.write(import_picocolors38.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
@@ -81225,7 +82253,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
81225
82253
|
const trimmed = amount.trim();
|
|
81226
82254
|
if (trimmed !== "all") {
|
|
81227
82255
|
if (!/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
81228
|
-
|
|
82256
|
+
fail10(`Withdraw amount "${amount}" is not a decimal amount or "all".`, opts.json);
|
|
81229
82257
|
}
|
|
81230
82258
|
}
|
|
81231
82259
|
const result = await runDeskCeremony({
|
|
@@ -81264,18 +82292,18 @@ async function deskWithdraw(amount, opts) {
|
|
|
81264
82292
|
}
|
|
81265
82293
|
async function deskSessionRegister(opts) {
|
|
81266
82294
|
await withDesk(opts, async (ctx2) => {
|
|
81267
|
-
if (!opts.cap)
|
|
81268
|
-
if (!opts.minutes)
|
|
82295
|
+
if (!opts.cap) fail10("--cap <usdc> is required: the per-trade cap is your risk statement, never defaulted.", opts.json);
|
|
82296
|
+
if (!opts.minutes) fail10("--minutes <n> is required: the session expiry is your risk statement, never defaulted.", opts.json);
|
|
81269
82297
|
let capUnits;
|
|
81270
82298
|
try {
|
|
81271
82299
|
capUnits = parseDecimalToUnits(opts.cap, USDC_DECIMALS, "Per-trade cap");
|
|
81272
82300
|
} catch (err) {
|
|
81273
|
-
|
|
82301
|
+
fail10(err.message, opts.json);
|
|
81274
82302
|
}
|
|
81275
|
-
if (capUnits <= 0n)
|
|
82303
|
+
if (capUnits <= 0n) fail10("Per-trade cap must be above zero.", opts.json);
|
|
81276
82304
|
const minutes = Number(opts.minutes);
|
|
81277
82305
|
if (!Number.isInteger(minutes) || minutes <= 0) {
|
|
81278
|
-
|
|
82306
|
+
fail10(`--minutes must be a positive integer, got "${opts.minutes}".`, opts.json);
|
|
81279
82307
|
}
|
|
81280
82308
|
const owner = await loadOrCreateTradeKey();
|
|
81281
82309
|
if (owner.created && !opts.json) {
|
|
@@ -81359,7 +82387,7 @@ async function deskSessionRevoke(opts) {
|
|
|
81359
82387
|
async function requireSessionKeypair(opts) {
|
|
81360
82388
|
const session = await loadDeskSessionKey();
|
|
81361
82389
|
if (!session) {
|
|
81362
|
-
|
|
82390
|
+
fail10(
|
|
81363
82391
|
"No desk session key on this terminal. Register one: agentgates desk session register --cap <usdc> --minutes <n>",
|
|
81364
82392
|
opts.json
|
|
81365
82393
|
);
|
|
@@ -81403,12 +82431,12 @@ async function deskBuy(coinArg, amount, opts) {
|
|
|
81403
82431
|
try {
|
|
81404
82432
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
|
|
81405
82433
|
} catch (err) {
|
|
81406
|
-
|
|
82434
|
+
fail10(err.message, opts.json);
|
|
81407
82435
|
}
|
|
81408
|
-
if (units <= 0n)
|
|
82436
|
+
if (units <= 0n) fail10("Buy amount must be above zero.", opts.json);
|
|
81409
82437
|
const floor = servedFloorUnits2(ctx2);
|
|
81410
82438
|
if (floor && units < floor.units) {
|
|
81411
|
-
|
|
82439
|
+
fail10(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
81412
82440
|
}
|
|
81413
82441
|
const owner = await requireOwner(opts);
|
|
81414
82442
|
const session = await requireSessionKeypair(opts);
|
|
@@ -81433,16 +82461,16 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
81433
82461
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
81434
82462
|
if (pct) {
|
|
81435
82463
|
const state = await deskState(owner.state.address, coin.mint);
|
|
81436
|
-
if (!state.coin)
|
|
82464
|
+
if (!state.coin) fail10("The desk holds none of that coin for this owner.", opts.json);
|
|
81437
82465
|
const credit = BigInt(state.coin.creditUnits);
|
|
81438
|
-
if (credit <= 0n)
|
|
82466
|
+
if (credit <= 0n) fail10("The desk holds none of that coin for this owner.", opts.json);
|
|
81439
82467
|
const p = BigInt(pct[1]);
|
|
81440
|
-
if (p <= 0n || p > 100n)
|
|
82468
|
+
if (p <= 0n || p > 100n) fail10(`Percentage must be 1-100, got "${amount}".`, opts.json);
|
|
81441
82469
|
const units = credit * p / 100n;
|
|
81442
|
-
if (units <= 0n)
|
|
82470
|
+
if (units <= 0n) fail10("Sell amount rounds to zero.", opts.json);
|
|
81443
82471
|
sellAmount = formatUnits2(units, state.coin.decimals);
|
|
81444
82472
|
} else if (sellAmount !== "all" && !/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
81445
|
-
|
|
82473
|
+
fail10(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
81446
82474
|
}
|
|
81447
82475
|
const result = await runDeskTrade({
|
|
81448
82476
|
ctx: ctx2,
|
|
@@ -81957,8 +82985,22 @@ var compute = program2.command("compute").description("Confidential virtual mach
|
|
|
81957
82985
|
compute.command("plans").description("Live plans and the price ladder. Public read: no key, no account, no payment.").option("--json", "machine-readable output (the raw catalog)").action(async (opts) => {
|
|
81958
82986
|
await computePlans(opts);
|
|
81959
82987
|
});
|
|
81960
|
-
compute.command("buy").description(
|
|
81961
|
-
|
|
82988
|
+
compute.command("buy").description(
|
|
82989
|
+
"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) => {
|
|
82991
|
+
await computeBuy(opts);
|
|
82992
|
+
});
|
|
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) => {
|
|
82994
|
+
await computeRenew(id2, opts);
|
|
82995
|
+
});
|
|
82996
|
+
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) => {
|
|
82997
|
+
await computeList(opts);
|
|
82998
|
+
});
|
|
82999
|
+
compute.command("status <id>").description("One machine: status, endpoint, paid time, payments, live attestation (an owner read).").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
|
|
83000
|
+
await computeStatus(id2, opts);
|
|
83001
|
+
});
|
|
83002
|
+
compute.command("wait <id>").description("Wait until a machine runs, then print its endpoint. The clock starts when it runs.").option("--timeout <minutes>", "how long to wait (default 15)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
|
|
83003
|
+
await computeWait(id2, opts);
|
|
81962
83004
|
});
|
|
81963
83005
|
var inference = program2.command("inference").description("Attested confidential models, plus an open tier, USDC per request");
|
|
81964
83006
|
inference.command("models").description("Live models and per-token prices. Public read: no key, no account, no payment.").option("--all", "every model, not just the attested tier").option("--tier <tier>", "confidential | open").option("--tag <tag>", "filter by tag, repeatable (the board carries: reasoning, multimodal, frontier)", (v, prev) => prev.concat(v), []).option("--org <org>", "filter by maker org (openai, anthropic, qwen, ...)").option("--search <text>", "match against model id and name").option("--json", "machine-readable output (the catalog, filters applied)").action(async (opts) => {
|
|
@@ -81974,8 +83016,8 @@ inference.command("key").description("Mint a key that buys turns without the wor
|
|
|
81974
83016
|
}
|
|
81975
83017
|
await inferenceKeyCreate(opts);
|
|
81976
83018
|
});
|
|
81977
|
-
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 (
|
|
81978
|
-
await inferenceTopUp(
|
|
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) => {
|
|
83020
|
+
await inferenceTopUp(usd6, opts);
|
|
81979
83021
|
});
|
|
81980
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) => {
|
|
81981
83023
|
await inferenceAsk(words7, opts);
|
|
@@ -82026,23 +83068,26 @@ passwords.command("init").description(
|
|
|
82026
83068
|
).option("--seed <twelve words>", "bring the phrase (quote it)").option("--reveal-seed", "print this key's words again").option("--import <hex>", "bring a bare 32-byte secp256k1 private key (64 hex chars) instead of words").option("--replace", "with --seed or --import: overwrite what is already here (the old key is the only thing that opens the rows it sealed)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82027
83069
|
await passwordsInit(opts);
|
|
82028
83070
|
});
|
|
82029
|
-
passwords.command("add").alias("store").description("Store a login: sealed on this machine to this key's own signature and to the CVM's published key, then posted. The server holds ciphertext it cannot open. Free at every tier.").requiredOption("--label <name>", "what to call it (48 chars)").option("--host <hostname>", "a site it may be used on, repeatable (1 to 8; app.example.com, no wildcards)", (v, prev) => [...prev, v], []).option("--hosts <a,b>", "the same, comma separated").option("--username <u>", "login rows: the username; mailbox rows: the address the codes arrive at").option("--password <p>", "the password (visible to ps for the length of the call; --password-stdin avoids that)").option("--password-stdin", "read the password from stdin instead").option("--kind <kind>", "login | api_key | totp | raw | mailbox (default login); mailbox = your own mailbox, read by the box for the codes sites email (--username the address, --password the app password, --host the mail server; Gmail's is known). An address leased here (agentgates passwords inbox lease) needs no app password: --password -").option("--totp-seed <base32>", "the authenticator seed (login rows may carry one beside the password; totp rows need it)").option("--api-key <value>", "api_key rows").option("--raw <value>", "raw rows").option("--notes <text>", "owner-only, sealed").option("--backup-codes <codes|@file>", "login rows: the account's own backup codes, comma separated or one per line in a file; the CVM spends one when the site asks for a code and a permit lists codes").option("--device-json <json|@file>", "login rows: a device credential your own browser holds for the account (rpId, credentialId, privateKey, userHandle, signCount); agentgates passwords device provisions one through the CVM instead").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
83071
|
+
passwords.command("add").alias("store").description("Store a login: sealed on this machine to this key's own signature and to the CVM's published key, then posted. The server holds ciphertext it cannot open. Free at every tier.").requiredOption("--label <name>", "what to call it (48 chars)").option("--host <hostname>", "a site it may be used on, repeatable (1 to 8; app.example.com, no wildcards)", (v, prev) => [...prev, v], []).option("--hosts <a,b>", "the same, comma separated").option("--username <u>", "login rows: the username; mailbox rows: the address the codes arrive at").option("--password <p>", "the password (visible to ps for the length of the call; --password-stdin avoids that)").option("--password-stdin", "read the password from stdin instead").option("--kind <kind>", "login | api_key | totp | raw | mailbox (default login); mailbox = your own mailbox, read by the box for the codes sites email (--username the address, --password the app password, --host the mail server; Gmail's is known). An address leased here (agentgates passwords inbox lease) needs no app password: --password -").option("--totp-seed <base32>", "the authenticator seed (login rows may carry one beside the password; totp rows need it)").option("--api-key <value>", "api_key rows").option("--raw <value>", "raw rows").option("--notes <text>", "owner-only, sealed").option("--backup-codes <codes|@file>", "login rows: the account's own backup codes, comma separated or one per line in a file; the CVM spends one when the site asks for a code and a permit lists codes").option("--device-json <json|@file>", "login rows: a device credential your own browser holds for the account (rpId, credentialId, privateKey, userHandle, signCount); agentgates passwords device provisions one through the CVM instead").option("--through <row>", "a site that signs in through another site's account (Resend through GitHub): the new login holds no password of its own; its uses name that login row (passwords use --as-row) and the CVM types it on that row's own sites").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82030
83072
|
await passwordsAdd(opts);
|
|
82031
83073
|
});
|
|
82032
83074
|
passwords.command("allow").description("Sign a permit: which agent may use which rows on which sites, how many times a day, until when. Default: yourself, every row, every use, 30 days.").option("--agent <address>", "the key that will sign uses (default: this key)").option("--rows <id,id|*>", "row ids, or * for every row this key holds (default *)").option("--hosts <a,b>", "narrow to these hostnames (default: the rows' own)").option("--uses <login,totp,header>", "which uses (default all three)").option("--gets <session|password>", "what the agent gets: session = the site's cookies after the CVM logs in (default); password = the secret itself; cvm = the acting uses alone, for an agent that works inside the CVM over the API").option("--per-day <n>", "hard daily cap; 0 = the plan allowance (default 0)").option("--days <n>", "how long, 1 to 366 (default 30)").option("--ask-me", "every use waits for the owner's signature on their board (the brake)").option("--factors <device,codes,mail,sms>", "the account's sign-in verification step the agent may complete: device = the stored device credential answers the site's device step; codes = one of the stored backup codes is spent; mail = a code the site emails is read from your mailbox row or an inbox this key holds (allow the mailbox row too); sms = a code the site texts is read from a number this key holds").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82033
83075
|
await passwordsAllow(opts);
|
|
82034
83076
|
});
|
|
82035
|
-
passwords.command("use").description("Log in through the CVM with a stored login and get the page's digest back, never the password. Pass --row, or just --url and the matching row is picked, or --workflow to run a task the owner taught the CVM. A parked use (the owner has to approve, or type a code) is waited on until it answers.").option("--row <id>", "the row to use (default: the one whose hosts cover --url)").option("--url <https://site/login>", "the page the use targets").option("--use <login|header|totp|session|reveal>", "which use (default login); session hands this key the site's cookies, reveal the secret, when the permit says so").option("--cookies-out <file>", "session only: write the cookies to this file (Playwright addCookies / Puppeteer setCookie shape)").option("--steps-json <json>", "login only: steps the CVM runs inside the session after the login lands (goto, fill, click, wait, read, press; a click may name the control's text instead of a selector)").option("--workflow <name>", "login only: run a workflow the owner taught the CVM on the row, by its name (passwords list shows them); --url may be left out").option("--input <name=value>", "a value the workflow takes, by its name; repeat for each (a value you leave out types what the owner typed)", (v, prev = []) => [...prev, v]).option("--code-steps-json <json>", "login only: the clicks that reach a code field the site keeps behind a 'try another way' menu (at most 4, click and wait), run before the code is typed").option("--enroll-device", "login only, your own key: provision a device credential for the account on this sign-in (the steps reach the page where the account adds a device); agentgates passwords device does this and seals it into the row").option("--attend", "login only, your own key: the CVM fills the password and holds the page for you at the controls (finish it on your board's live view); prints the use id and the view token").option("--use-id <id>", "continue a parked use by its id (Done on an attended sign-in, or a use the owner answered)").option("--mailbox <row>", "login and session: the mailbox row the box reads an emailed sign-in code from (default: your one mailbox row, when the permit covers it and lists mail)").option("--solve", "login and session, your own key: the CVM passes a bot check it meets (Cloudflare, Turnstile, reCAPTCHA, hCaptcha) by ticking it, then through its solver service").option("--request-json <json>", "the whole request object for header and totp uses (spec \xA75.1)").option("--wait <seconds>", "cap on how long to wait for the owner's answer (default: the owner's window)").option("--no-wait", "answer the parked use's id and return at once").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts, command) => {
|
|
83077
|
+
passwords.command("use").description("Log in through the CVM with a stored login and get the page's digest back, never the password. Pass --row, or just --url and the matching row is picked, or --workflow to run a task the owner taught the CVM. A parked use (the owner has to approve, or type a code) is waited on until it answers.").option("--row <id>", "the row to use (default: the one whose hosts cover --url)").option("--url <https://site/login>", "the page the use targets").option("--use <login|header|totp|session|reveal>", "which use (default login); session hands this key the site's cookies, reveal the secret, when the permit says so").option("--cookies-out <file>", "session only: write the cookies to this file (Playwright addCookies / Puppeteer setCookie shape)").option("--steps-json <json>", "login only: steps the CVM runs inside the session after the login lands (goto, fill, click, wait, read, press; a click may name the control's text instead of a selector; key reads the key a site shows once, {kind: key, label|selector, prefix?}, and keeps it in the row for {apiKey})").option("--workflow <name>", "login only: run a workflow the owner taught the CVM on the row, by its name (passwords list shows them); --url may be left out").option("--input <name=value>", "a value the workflow takes, by its name; repeat for each (a value you leave out types what the owner typed)", (v, prev = []) => [...prev, v]).option("--code-steps-json <json>", "login only: the clicks that reach a code field the site keeps behind a 'try another way' menu (at most 4, click and wait), run before the code is typed").option("--enroll-device", "login only, your own key: provision a device credential for the account on this sign-in (the steps reach the page where the account adds a device); agentgates passwords device does this and seals it into the row").option("--attend", "login only, your own key: the CVM fills the password and holds the page for you at the controls (finish it on your board's live view); prints the use id and the view token").option("--use-id <id>", "continue a parked use by its id (Done on an attended sign-in, or a use the owner answered)").option("--mailbox <row>", "login and session: the mailbox row the box reads an emailed sign-in code from (default: your one mailbox row, when the permit covers it and lists mail)").option("--as-row <row>", "login only: sign in through another site's account (Resend through GitHub): the login row whose username and password the CVM types, on that row's own sites only; the password never leaves the CVM").option("--solve", "login and session, your own key: the CVM passes a bot check it meets (Cloudflare, Turnstile, reCAPTCHA, hCaptcha) by ticking it, then through its solver service").option("--request-json <json>", "the whole request object for header and totp uses (spec \xA75.1); a header request's seal {json: <field>} seals that field of the JSON answer to the owner (a webhook's signing secret)").option("--wait <seconds>", "cap on how long to wait for the owner's answer (default: the owner's window)").option("--no-wait", "answer the parked use's id and return at once").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts, command) => {
|
|
82036
83078
|
const waitSource = command.getOptionValueSource("wait");
|
|
82037
83079
|
await passwordsUse({ ...opts, noWait: waitSource === "cli" && opts.wait === false, wait: typeof opts.wait === "string" ? opts.wait : void 0 });
|
|
82038
83080
|
});
|
|
82039
83081
|
passwords.command("checks [word]").description("Bot checks (Cloudflare, Turnstile, reCAPTCHA, hCaptcha): ask = an agent's use that meets one waits for your answer on the board (default); solve = the CVM passes every one it can without asking. No word prints the current one.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (word, opts) => {
|
|
82040
83082
|
await passwordsChecks(word, opts);
|
|
82041
83083
|
});
|
|
83084
|
+
passwords.command("open-sealed").description("Open a field the CVM sealed to you in a header use's answer (a webhook's signing secret): only the account owner's key opens it, the same key that opens the account's sealed mail.").option("--row <id>", "the row the header use ran on").option("--field <name>", "the sealed field's name (signing_secret)").option("--blob <value|@file>", "the field's {sealed} value from the answer").option("--out <file>", "write the value to this file (read by you alone) and print its length, not the value").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
83085
|
+
await passwordsOpenSealed(opts);
|
|
83086
|
+
});
|
|
82042
83087
|
passwords.command("code").description("Fetch a verification code one of the account's own contacts received, for an account the owner is registering or signing into elsewhere: the newest message from a site in your mailbox row (an app password, or a Gmail login you connected on your board; the permit lists mail), or the newest code that reached an inbox or a number this key holds, read through its own door (a sealed inbox is opened with your own key). One source: --mailbox, --inbox or --phone.").option("--from <domain>", "the site the code comes from, e.g. etsy.com (a mailbox row reads that sender)").option("--mailbox <row>", "the mailbox row (default: your one mailbox row, or your one Gmail login)").option("--inbox <id>", "an inbox this key holds (agentgates passwords inbox list): the newest code that reached it").option("--phone <id>", "a number this key holds (agentgates phone list): the newest code texted to it").option("--timeout <seconds>", "--inbox and --phone: how long the door waits for a code (default 60)").option("--since <minutes>", "how far back to look (default 10)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82043
83088
|
await passwordsCode(opts);
|
|
82044
83089
|
});
|
|
82045
|
-
passwords.command("signup").description("Register the account owner on a site through the CVM, under a permit the owner signed: the CVM completes the site's own sign-up form with the owner's chosen identity and a password generated here, the site's verification code is read from a contact the account already holds, and the new login is saved as a row under this key. The source is one of your mailbox row (the CVM reads it), an inbox this key holds (--inbox: the code is read through the inbox's own door; a sealed inbox is opened with your own key) or a number this key holds (--phone: the code is read through the number's own door). The permit lists signup, and mail or sms for the source. Priced as a login; the code read is the wait-code door's own draw, reported in the answer.").requiredOption("--url <url>", "the https address of the site's sign-up page (or its sign-in page with a Sign up link)").option("--email <address>", "the address to sign up with: the source's own by default, or a plus alias of it (you+shop@gmail.com); none with --phone").option("--name <name>", "the name the form asks for").option("--username <name>", "the username when the form asks for one (the CVM derives one otherwise)").option("--password <password>", "the password to use (generated here when absent)").option("--mailbox <row>", "the mailbox row (default: your one mailbox row, or your one Gmail login)").option("--inbox <id>", "an inbox this key holds (agentgates passwords inbox list): the account is made with its address").option("--phone <id>", "a number this key holds (agentgates phone list): the account is made on the number, the code comes by text").option("--label <label>", "the stored row's label (default: the site)").option("--no-store", "do not store the new login as a row; the password prints once instead").option("--steps-json <json>", "steps to run at the site once the account exists (the login use's steps shape)").option("--drive", "let the CVM's own model update a step of the site book's recipe that no longer matches the form; a step only you can complete in person stops the run and names it").option("--birthday <yyyy-mm-dd>", "the date of birth a sign-up form asks for; typed, never kept").option("--attend", "
|
|
83090
|
+
passwords.command("signup").description("Register the account owner on a site through the CVM, under a permit the owner signed: the CVM completes the site's own sign-up form with the owner's chosen identity and a password generated here, the site's verification code is read from a contact the account already holds, and the new login is saved as a row under this key. The source is one of your mailbox row (the CVM reads it), an inbox this key holds (--inbox: the code is read through the inbox's own door; a sealed inbox is opened with your own key) or a number this key holds (--phone: the code is read through the number's own door). The permit lists signup, and mail or sms for the source. Priced as a login; the code read is the wait-code door's own draw, reported in the answer.").requiredOption("--url <url>", "the https address of the site's sign-up page (or its sign-in page with a Sign up link)").option("--email <address>", "the address to sign up with: the source's own by default, or a plus alias of it (you+shop@gmail.com); none with --phone").option("--name <name>", "the name the form asks for").option("--username <name>", "the username when the form asks for one (the CVM derives one otherwise)").option("--password <password>", "the password to use (generated here when absent)").option("--mailbox <row>", "the mailbox row (default: your one mailbox row, or your one Gmail login)").option("--inbox <id>", "an inbox this key holds (agentgates passwords inbox list): the account is made with its address").option("--phone <id>", "a number this key holds (agentgates phone list): the account is made on the number, the code comes by text").option("--label <label>", "the stored row's label (default: the site)").option("--no-store", "do not store the new login as a row; the password prints once instead").option("--steps-json <json>", "steps to run at the site once the account exists (the login use's steps shape)").option("--drive", "let the CVM's own model update a step of the site book's recipe that no longer matches the form; a step only you can complete in person stops the run and names it").option("--birthday <yyyy-mm-dd>", "the date of birth a sign-up form asks for; typed, never kept").option("--attend", "the default: a step only a person completes (a puzzle, a verification the site shows) holds the page for the account owner at the controls of their board's live view. Your own key: finish it there, or continue here with --use-id. An agent's key: this run waits for the owner's Done, then goes on").option("--no-attend", "a step only a person completes ends the run with the step named, and nothing is held").option("--use-id <id>", "continue a sign-up the CVM is holding for you (Done): the steps after the one you completed run on").option("--as-row <row>", "sign up THROUGH another site's account (Vercel's Continue with GitHub): the login row whose account the run signs in as; its username and password are opened here under your key, sent with the request, never printed and never stored again").option("--auto-owner", "your own key plays the owner at the walls it can answer and continues the run: a page that has not drawn gets a moment, and a phone check is answered with --sms-id and --sms-number; any other wall stays held for you").option("--sms-id <phoneId>", "with --auto-owner: the number this key may read a text from (the house's pool number is listed in poolSmsReaders); the phone check's code is read there").option("--sms-number <+15551234567>", "with --auto-owner: the phone number typed into the phone check (the number behind --sms-id)").option("--wait <seconds>", "how long to wait on a parked use or a starting CVM (default: the use's own window)").option("--no-wait", "print the first answer and leave").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82046
83091
|
await passwordsSignup(opts);
|
|
82047
83092
|
});
|
|
82048
83093
|
passwords.command("device").description("Provision a device credential for an account through the CVM: the CVM logs in with your stored login, the steps reach the page where the account adds a device, the site's own ceremony creates the credential inside the CVM, and it is sealed into the row (both copies). From then on a permit that lists device lets the CVM complete the account's device step with it. Your own key only.").requiredOption("--row <id>", "the login to provision it on (agentgates passwords list)").requiredOption("--url <https://site/login>", "the account's sign-in page").option("--page <https://site/security>", "the page where the account adds a device (a passkey)").option("--click <text>", "the text on that page's add-a-device button").option("--steps-json <json>", "instead of --page and --click: the steps that reach and press it").option("--wait <seconds>", "cap on how long to wait for a parked sign-in (a code the site sent you)").option("--no-wait", "answer the parked use's id and return at once").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts, command) => {
|
|
@@ -82223,6 +83268,12 @@ sites.command("undo <changeId>").description("Take back the site's latest live c
|
|
|
82223
83268
|
sites.command("fix <changeId>").description("A change Agentgates' live check stopped: the agent builds a new change whose ask is what failed.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (changeId, opts) => {
|
|
82224
83269
|
await sitesFix(changeId, opts);
|
|
82225
83270
|
});
|
|
83271
|
+
sites.command("changes <siteId>").description("One site's changes, newest first: what each did (its card) or what was asked, where it stands.").option("--before <changeId>", "the page before's last change id (the older page)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (siteId, opts) => {
|
|
83272
|
+
await sitesChanges(siteId, opts);
|
|
83273
|
+
});
|
|
83274
|
+
sites.command("remove <siteId>").description("Take a site off Agentgates. Its GitHub repo, Vercel project and connections stay yours.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (siteId, opts) => {
|
|
83275
|
+
await sitesRemove(siteId, opts);
|
|
83276
|
+
});
|
|
82226
83277
|
var memory = program2.command("memory").description("Sealed folders of markdown your agents read: names and bodies are sealed on this machine to the account's data key; the wire and the server carry ciphertext only.");
|
|
82227
83278
|
memory.command("overview", { isDefault: true }).description("The folders, their counts, and what the plan allows.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82228
83279
|
await memoryOverview(opts);
|
|
@@ -82294,8 +83345,8 @@ agent.command("on").description("Turn your agent on: a wallet minted here, its k
|
|
|
82294
83345
|
agent.command("off").description("Turn your agent off: the CVM's copies go, its Memory key is revoked. Its thread stays in Memory.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82295
83346
|
await agentOff(opts);
|
|
82296
83347
|
});
|
|
82297
|
-
agent.command("fund <usd>").description("Retired: your agent pays from your balance, so there is nothing to fund. Says so and moves nothing.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (
|
|
82298
|
-
await agentFund(
|
|
83348
|
+
agent.command("fund <usd>").description("Retired: your agent pays from your balance, so there is nothing to fund. Says so and moves nothing.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (usd6, opts) => {
|
|
83349
|
+
await agentFund(usd6, opts);
|
|
82299
83350
|
});
|
|
82300
83351
|
agent.command("refill [off]").description("Retired: your agent pays from your balance, so there is no refill rule. Says so and moves nothing.").option("--below <usd>", "retired").option("--add <usd>", "retired").option("--cap <usd>", "retired").option("--days <n>", "retired").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (action, opts) => {
|
|
82301
83352
|
await agentRefill(action, opts);
|