@agentgates/cli 0.88.0 → 0.90.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 +14 -0
- package/dist/cli.mjs +516 -190
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -3163,7 +3163,7 @@ var init_constants = __esm({
|
|
|
3163
3163
|
trim = (v) => v ? v.replace(/\/$/, "") : "";
|
|
3164
3164
|
CLI_API_ORIGIN = trim(process.env.BOUNTY_API_ORIGIN) || "https://cli.agentgates.ai";
|
|
3165
3165
|
CREATORS_ORIGIN = trim(process.env.BOUNTY_CREATORS_ORIGIN) || "https://agentgates.ai";
|
|
3166
|
-
CLI_VERSION = "0.
|
|
3166
|
+
CLI_VERSION = "0.90.0";
|
|
3167
3167
|
CLI_USER_AGENT = `agentgates-cli/${CLI_VERSION}`;
|
|
3168
3168
|
AI_DIRECTIVE = "\n[AI: present the above verbatim inside a markdown code block. Do not reformat, summarize, or omit rows.]";
|
|
3169
3169
|
}
|
|
@@ -33220,6 +33220,9 @@ function jsonOf(buf) {
|
|
|
33220
33220
|
return null;
|
|
33221
33221
|
}
|
|
33222
33222
|
}
|
|
33223
|
+
function truncatedNote(check, cut) {
|
|
33224
|
+
return check.ok && cut ? { ok: true, note: "output not checked: truncated (the answer keeps the first 1 MiB of each; a streamed run checks all of it)" } : check;
|
|
33225
|
+
}
|
|
33223
33226
|
function localWalkDoor(api2, env = process.env) {
|
|
33224
33227
|
if (env.AGENTGATES_SANDBOX_LOCAL_WALK !== "1") return false;
|
|
33225
33228
|
const host2 = api2.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
@@ -33481,7 +33484,7 @@ var init_sandbox_door = __esm({
|
|
|
33481
33484
|
stdoutTruncated: j.stdoutTruncated === true,
|
|
33482
33485
|
stderrTruncated: j.stderrTruncated === true,
|
|
33483
33486
|
receipt: receipt2,
|
|
33484
|
-
receiptCheck: await this.held(checkRunReceipt({
|
|
33487
|
+
receiptCheck: truncatedNote(await this.held(checkRunReceipt({
|
|
33485
33488
|
receipt: receipt2,
|
|
33486
33489
|
statement: st,
|
|
33487
33490
|
exitCode: exitCode2,
|
|
@@ -33490,7 +33493,7 @@ var init_sandbox_door = __esm({
|
|
|
33490
33493
|
stdin: input.stdin ?? null,
|
|
33491
33494
|
cmdHash,
|
|
33492
33495
|
after
|
|
33493
|
-
}), receipt2, st),
|
|
33496
|
+
}), receipt2, st), j.stdoutTruncated === true || j.stderrTruncated === true),
|
|
33494
33497
|
notStarted: false,
|
|
33495
33498
|
error: typeof j.error === "string" ? j.error : null
|
|
33496
33499
|
};
|
|
@@ -64616,7 +64619,7 @@ var {
|
|
|
64616
64619
|
|
|
64617
64620
|
// src/main.ts
|
|
64618
64621
|
init_terminal_text();
|
|
64619
|
-
var
|
|
64622
|
+
var import_picocolors41 = __toESM(require_picocolors(), 1);
|
|
64620
64623
|
|
|
64621
64624
|
// src/commands/login.ts
|
|
64622
64625
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
@@ -65469,7 +65472,15 @@ ${opts.ttyHeader}
|
|
|
65469
65472
|
perTxUSD: approved.perTxUSD,
|
|
65470
65473
|
perDayUSD: approved.perDayUSD,
|
|
65471
65474
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65472
|
-
mcpOrigin: origin
|
|
65475
|
+
mcpOrigin: origin,
|
|
65476
|
+
...Array.isArray(approved.wallets) ? {
|
|
65477
|
+
wallets: approved.wallets.map((w) => ({
|
|
65478
|
+
name: w.name,
|
|
65479
|
+
is_default: w.is_default,
|
|
65480
|
+
evm: w.evm,
|
|
65481
|
+
solana: w.solana ?? null
|
|
65482
|
+
}))
|
|
65483
|
+
} : {}
|
|
65473
65484
|
};
|
|
65474
65485
|
await saveProfile(profile, profileName);
|
|
65475
65486
|
if (!opts.jsonMode) {
|
|
@@ -65563,8 +65574,16 @@ Run ${import_picocolors2.default.bold(`agentgates logout --profile ${profileName
|
|
|
65563
65574
|
process.stdout.write(
|
|
65564
65575
|
` Wallet ${shortAddress(profile.walletAddress)}` + (profile.solanaAddress ? ` \xB7 ${shortAddress(profile.solanaAddress)}` : "") + "\n"
|
|
65565
65576
|
);
|
|
65566
|
-
|
|
65567
|
-
|
|
65577
|
+
const wallets2 = profile.wallets ?? [];
|
|
65578
|
+
if (wallets2.length > 1 || wallets2.length === 1 && !wallets2[0].is_default) {
|
|
65579
|
+
process.stdout.write(
|
|
65580
|
+
` Wallets ${wallets2.map((w) => w.is_default ? `${w.name} (default)` : w.name).join(", ")}
|
|
65581
|
+
`
|
|
65582
|
+
);
|
|
65583
|
+
}
|
|
65584
|
+
const scopes = profile.scopes.filter((s) => !s.startsWith("wallet:id:"));
|
|
65585
|
+
if (scopes.length > 0) {
|
|
65586
|
+
process.stdout.write(` Scopes ${scopes.join(", ")}
|
|
65568
65587
|
`);
|
|
65569
65588
|
}
|
|
65570
65589
|
const txCap = profile.perTxUSD == null ? "No limit/tx" : `$${profile.perTxUSD}/tx`;
|
|
@@ -66203,10 +66222,14 @@ var BACKOFF_MS = [2e3, 4e3, 8e3, 15e3, 3e4];
|
|
|
66203
66222
|
async function sendPaid(args) {
|
|
66204
66223
|
const attempts = Math.max(1, args.attempts ?? 6);
|
|
66205
66224
|
const sleep4 = args.sleep ?? ((ms) => new Promise((resolve5) => setTimeout(resolve5, ms)));
|
|
66225
|
+
const now = args.now ?? Date.now;
|
|
66226
|
+
const until = args.budgetMs !== void 0 ? now() + args.budgetMs : Infinity;
|
|
66206
66227
|
let last = null;
|
|
66207
66228
|
let why = "";
|
|
66229
|
+
let tried = 0;
|
|
66208
66230
|
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
66209
66231
|
let answer = null;
|
|
66232
|
+
tried = attempt;
|
|
66210
66233
|
try {
|
|
66211
66234
|
answer = await computeCall({
|
|
66212
66235
|
method: "POST",
|
|
@@ -66214,8 +66237,8 @@ async function sendPaid(args) {
|
|
|
66214
66237
|
body: args.body,
|
|
66215
66238
|
headers: { "x-payment": args.payment },
|
|
66216
66239
|
// A create waits for the chain, then the vendor: the API allows
|
|
66217
|
-
// itself 120 seconds.
|
|
66218
|
-
timeoutMs: args.timeoutMs ?? 15e4,
|
|
66240
|
+
// itself 120 seconds; within a budget, what is left of it.
|
|
66241
|
+
timeoutMs: Math.max(1e3, Math.min(args.timeoutMs ?? 15e4, until - now())),
|
|
66219
66242
|
fetchImpl: args.fetchImpl
|
|
66220
66243
|
});
|
|
66221
66244
|
} catch (err) {
|
|
@@ -66230,10 +66253,11 @@ async function sendPaid(args) {
|
|
|
66230
66253
|
}
|
|
66231
66254
|
if (attempt === attempts) break;
|
|
66232
66255
|
const waitMs = answer?.retryAfterSeconds ? Math.min(answer.retryAfterSeconds, 60) * 1e3 : BACKOFF_MS[Math.min(attempt - 1, BACKOFF_MS.length - 1)];
|
|
66256
|
+
if (now() + waitMs + 1e3 > until) break;
|
|
66233
66257
|
args.onRetry?.(why, attempt, waitMs);
|
|
66234
66258
|
await sleep4(waitMs);
|
|
66235
66259
|
}
|
|
66236
|
-
return { kind: "no_answer", error: why, attempts, last };
|
|
66260
|
+
return { kind: "no_answer", error: why, attempts: tried, last };
|
|
66237
66261
|
}
|
|
66238
66262
|
async function ownerGet(wallet, path12, opts = {}) {
|
|
66239
66263
|
const header2 = await ownerAuthHeader(wallet, "GET", path12);
|
|
@@ -66344,8 +66368,8 @@ async function computePlans(opts) {
|
|
|
66344
66368
|
const confidential = plans.filter((p) => p.proof !== "none" && !isSandbox(p));
|
|
66345
66369
|
const plain = plans.filter((p) => p.proof === "none" && !isSandbox(p));
|
|
66346
66370
|
const sections = [
|
|
66347
|
-
["CONFIDENTIAL VIRTUAL MACHINES", "memory encrypted in use", confidential],
|
|
66348
|
-
["PLAIN VIRTUAL MACHINES", "no proof
|
|
66371
|
+
["CONFIDENTIAL VIRTUAL MACHINES", "for agents that hold keys, money or private data: memory encrypted in use, a public proof", confidential],
|
|
66372
|
+
["PLAIN VIRTUAL MACHINES", "for agents with nothing secret, for much less: no proof, the host can read them", plain]
|
|
66349
66373
|
];
|
|
66350
66374
|
for (const [title, words7, list] of sections) {
|
|
66351
66375
|
if (list.length === 0) continue;
|
|
@@ -72165,10 +72189,10 @@ function html(res, status4, body) {
|
|
|
72165
72189
|
var esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
72166
72190
|
var PAGE_STYLE = "body{margin:0;background:#101216;color:#f2f3f5;font:15px/1.5 ui-sans-serif,system-ui,sans-serif;display:grid;place-items:center;min-height:100vh}main{max-width:440px;padding:28px;border:1px solid rgba(255,255,255,.09);border-radius:16px;background:#1a1c21}h1{font-size:20px;margin:0 0 8px}p{color:rgba(242,243,245,.6);margin:8px 0}code{font-family:ui-monospace,Menlo,monospace;color:#fff}button{margin-top:14px;height:40px;padding:0 16px;border:0;border-radius:11px;background:#0891b2;color:#fff;font:inherit;font-weight:650;cursor:pointer}button:disabled{opacity:.5;cursor:default}.ok{color:#4ade80}";
|
|
72167
72191
|
function openPage(args) {
|
|
72168
|
-
const
|
|
72192
|
+
const short5 = `${args.address.slice(0, 6)}\u2026${args.address.slice(-4)}`;
|
|
72169
72193
|
const site = siteOpenUrl(args.origin, args.port, args.token);
|
|
72170
|
-
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Agentgates \xB7 continue as ${esc(
|
|
72171
|
-
<h1>Continue as <code>${esc(
|
|
72194
|
+
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Agentgates \xB7 continue as ${esc(short5)}</title><style>${PAGE_STYLE}</style></head><body><main>
|
|
72195
|
+
<h1>Continue as <code>${esc(short5)}</code></h1>
|
|
72172
72196
|
<p>Your agent is handing you its session on agentgates.ai. Nothing leaves this machine: the words cross from this page to the site's window and nowhere else.</p>
|
|
72173
72197
|
<button id="go" type="button">Continue to agentgates.ai</button>
|
|
72174
72198
|
<p id="line"></p>
|
|
@@ -74639,7 +74663,7 @@ function printNext(put) {
|
|
|
74639
74663
|
`);
|
|
74640
74664
|
put(` ${import_picocolors12.default.dim("agentgates browser balance")} ${import_picocolors12.default.dim("\xB7 your balance and the address that tops it up")}
|
|
74641
74665
|
`);
|
|
74642
|
-
put(` ${import_picocolors12.default.dim("agentgates compute plans")} ${import_picocolors12.default.dim("\xB7
|
|
74666
|
+
put(` ${import_picocolors12.default.dim("agentgates compute plans")} ${import_picocolors12.default.dim("\xB7 computers for AI swarms, confidential or plain")}
|
|
74643
74667
|
`);
|
|
74644
74668
|
put(` ${import_picocolors12.default.dim("agentgates inference models")} ${import_picocolors12.default.dim("\xB7 models by the token")}
|
|
74645
74669
|
`);
|
|
@@ -74780,7 +74804,7 @@ var SandboxError = class extends Error {
|
|
|
74780
74804
|
code;
|
|
74781
74805
|
detail;
|
|
74782
74806
|
};
|
|
74783
|
-
var COLD_START_WORDS = "it waits for a seat on a host and runs once one has room: about two minutes after its payment when a host must start for it (135 s measured on production)";
|
|
74807
|
+
var COLD_START_WORDS = "it waits for a seat on a host and runs once one has room: about two minutes after its payment when a host must start for it (135 s measured on production), longer when many wait at once";
|
|
74784
74808
|
var KEY_RE = /^agc_[0-9a-f]{64}$/;
|
|
74785
74809
|
function computeKeyOf(given) {
|
|
74786
74810
|
const k = (given ?? process.env.AGENTGATES_COMPUTE_KEY ?? "").trim();
|
|
@@ -74845,15 +74869,31 @@ function microOfUsdText(raw) {
|
|
|
74845
74869
|
if (!m) throw new Error(`--max-usd takes dollars, like 1 or 0.5 (got "${raw}")`);
|
|
74846
74870
|
return BigInt(m[1]) * 1000000n + BigInt((m[2] ?? "").padEnd(6, "0"));
|
|
74847
74871
|
}
|
|
74872
|
+
function isSolLeg(leg) {
|
|
74873
|
+
return leg.extra?.token === "SOL";
|
|
74874
|
+
}
|
|
74848
74875
|
function legView2(leg) {
|
|
74849
74876
|
let amount = null;
|
|
74850
|
-
|
|
74851
|
-
|
|
74852
|
-
|
|
74853
|
-
|
|
74877
|
+
let amountSol = null;
|
|
74878
|
+
if (isSolLeg(leg)) {
|
|
74879
|
+
const said = leg.extra.usd;
|
|
74880
|
+
const dollars = typeof said === "string" || typeof said === "number" ? Number(said) : NaN;
|
|
74881
|
+
amount = Number.isFinite(dollars) ? `$${dollars.toFixed(3)}` : null;
|
|
74882
|
+
try {
|
|
74883
|
+
const v = BigInt(leg.maxAmountRequired ?? "");
|
|
74884
|
+
amountSol = `${v / 1000000000n}.${(v % 1000000000n).toString().padStart(9, "0")}`;
|
|
74885
|
+
} catch {
|
|
74886
|
+
amountSol = null;
|
|
74887
|
+
}
|
|
74888
|
+
} else {
|
|
74889
|
+
try {
|
|
74890
|
+
amount = leg.maxAmountRequired ? usd(BigInt(leg.maxAmountRequired)) : null;
|
|
74891
|
+
} catch {
|
|
74892
|
+
amount = null;
|
|
74893
|
+
}
|
|
74854
74894
|
}
|
|
74855
74895
|
const evm = evmLegs({ accepts: [leg] }).length > 0;
|
|
74856
|
-
return { network: leg.network ?? "?", amountUsd: amount, payTo: leg.payTo ?? null, asset: leg.asset ?? null, signsHere: evm };
|
|
74896
|
+
return { network: leg.network ?? "?", amountUsd: amount, ...amountSol !== null ? { amountSol } : {}, payTo: leg.payTo ?? null, asset: leg.asset ?? null, signsHere: evm };
|
|
74857
74897
|
}
|
|
74858
74898
|
async function payFor2(args) {
|
|
74859
74899
|
if (args.mode === "balance" || args.mode === "key") {
|
|
@@ -74865,7 +74905,7 @@ async function payFor2(args) {
|
|
|
74865
74905
|
}
|
|
74866
74906
|
if (ask.status !== 402) throw new SandboxError(apiWords2(ask), apiCode2(ask), { status: ask.status });
|
|
74867
74907
|
const offer2 = ask.json;
|
|
74868
|
-
const amounts = (offer2.accepts ?? []).map((l) => {
|
|
74908
|
+
const amounts = (offer2.accepts ?? []).filter((l) => !isSolLeg(l)).map((l) => {
|
|
74869
74909
|
try {
|
|
74870
74910
|
return BigInt(l.maxAmountRequired ?? "");
|
|
74871
74911
|
} catch {
|
|
@@ -74892,11 +74932,11 @@ async function payFor2(args) {
|
|
|
74892
74932
|
try {
|
|
74893
74933
|
answer = await computeCall({ method: "POST", url: args.url, body: args.body, headers, timeoutMs: 15e4 });
|
|
74894
74934
|
} catch (err) {
|
|
74895
|
-
throw new SandboxError(`the compute API did not answer: ${err.message}. A draw that went through shows in agentgates sandbox ls`, "no_answer");
|
|
74935
|
+
throw new SandboxError(`the compute API did not answer: ${err.message}. A draw that went through shows in agentgates sandbox ls${args.mode === "key" ? " --key <the same key>" : ""}`, "no_answer");
|
|
74896
74936
|
}
|
|
74897
74937
|
if (answer.status === 402) {
|
|
74898
|
-
const
|
|
74899
|
-
throw new SandboxError(`${
|
|
74938
|
+
const short5 = answer.json?.code === "insufficient_balance" || answer.json?.accepts ? "the balance does not cover it" : apiWords2(answer);
|
|
74939
|
+
throw new SandboxError(`${short5}: nothing was drawn. Pay over x402 instead (the same command without ${args.mode === "key" ? "--key" : "--from-balance"}), or top up the balance`, "insufficient_balance", { status: 402 });
|
|
74900
74940
|
}
|
|
74901
74941
|
if (answer.status < 200 || answer.status >= 300) throw new SandboxError(apiWords2(answer), apiCode2(answer), { status: answer.status });
|
|
74902
74942
|
const charged = answer.json?.charged?.amountMicro;
|
|
@@ -74957,9 +74997,10 @@ async function payFor2(args) {
|
|
|
74957
74997
|
const signed2 = await signLeg(leg, wallet.privateKey);
|
|
74958
74998
|
const paid = { network: leg.network, amountUsd: usd(leg.amountMicro), amountAtomic: leg.amountMicro.toString(), from: signed2.from, nonce: signed2.nonce };
|
|
74959
74999
|
args.onPaid?.(paid);
|
|
74960
|
-
const outcome = await sendPaid({ url: args.url, body: args.body, payment: signed2.header, onRetry: args.onRetry });
|
|
75000
|
+
const outcome = await sendPaid({ url: args.url, body: args.body, payment: signed2.header, onRetry: args.onRetry, ...args.budgetMs !== void 0 ? { budgetMs: args.budgetMs } : {} });
|
|
74961
75001
|
if (outcome.kind === "no_answer") {
|
|
74962
|
-
|
|
75002
|
+
const list = args.listWords ?? "agentgates sandbox ls";
|
|
75003
|
+
throw new SandboxError(`no clear answer after ${outcome.attempts} ${outcome.attempts === 1 ? "try" : "tries"} (${outcome.error}). The payment (nonce ${signed2.nonce}) may still settle: do not pay again; ${list} shows what it bought`, "no_answer", { paid, nonce: signed2.nonce });
|
|
74963
75004
|
}
|
|
74964
75005
|
if (outcome.kind === "refused") {
|
|
74965
75006
|
const a = outcome.answer;
|
|
@@ -74980,7 +75021,7 @@ async function createSandboxes(args) {
|
|
|
74980
75021
|
const count = typeof body.count === "number" ? body.count : 1;
|
|
74981
75022
|
const time = body.minutes !== void 0 ? `${String(body.minutes)} min` : `${String(body.hours)} h`;
|
|
74982
75023
|
const what = `${count > 1 ? `${count} x ` : ""}${String(body.plan)}, ${time}, ${typeof body.image === "string" ? body.image : "base"}`;
|
|
74983
|
-
const out = await payFor2({ url: `${computeOrigin()}${DEPLOYMENTS_PATH}`, path: DEPLOYMENTS_PATH, body, mode: args.mode, key: args.key, consent: args.consent, what, onPaid: args.onPaid, onRetry: args.onRetry });
|
|
75024
|
+
const out = await payFor2({ url: `${computeOrigin()}${DEPLOYMENTS_PATH}`, path: DEPLOYMENTS_PATH, body, mode: args.mode, key: args.key, consent: args.consent, what, onPaid: args.onPaid, onRetry: args.onRetry, budgetMs: args.budgetMs, listWords: args.listWords });
|
|
74984
75025
|
if (out.kind === "quote") return { quote: { description: out.description, legs: out.legs } };
|
|
74985
75026
|
const machines = machinesOf(out.answer.json);
|
|
74986
75027
|
const owner = args.mode === "key" ? null : out.payer;
|
|
@@ -75101,9 +75142,63 @@ async function findSandbox(id2, opts = {}) {
|
|
|
75101
75142
|
else if (wallet) doorAuth = { kind: "wallet", signer: walletSigner(wallet) };
|
|
75102
75143
|
else throw new SandboxError("no key on this machine opens that sandbox's door", "no_account");
|
|
75103
75144
|
const owner = rec?.owner ?? (machine && readAuth && "wallet" in readAuth && wallet ? wallet.address : null);
|
|
75104
|
-
const ownerUnchecked = owner !== null ? null : rec?.paidWith === "key" ? "the owner check did not run: a sandbox bought with a compute key opens with its access key, and this CLI does not know the key's wallet to hold the statement to it" : "the owner check did not run: this CLI does not know the owner's wallet";
|
|
75145
|
+
const ownerUnchecked = owner !== null ? null : rec?.paidWith === "key" ? "the owner check did not run: a sandbox bought with a compute key opens with its access key, and this CLI does not know the key's wallet to hold the statement to it" : rec?.paidWith === "attached" ? ATTACHED_OWNER_WORDS : "the owner check did not run: this CLI does not know the owner's wallet";
|
|
75105
75146
|
return { deploymentId, sandboxId, api: api2, tlsPin, owner, ownerUnchecked, auth: doorAuth, record, machine };
|
|
75106
75147
|
}
|
|
75148
|
+
var ATTACHED_OWNER_WORDS = "the owner check did not run: this sandbox was attached here from its address, pin and access key, and this CLI does not know the wallet that bought it";
|
|
75149
|
+
var ATTACHED_DELETE_WORDS = "a sandbox attached here is deleted by the wallet that bought it (agentgates.ai/sandboxes, Delete): its access key opens its door, not our API";
|
|
75150
|
+
var ACCESS_KEY_RE = /^sbxk_[0-9a-f]{64}$/;
|
|
75151
|
+
async function attachSandbox(args) {
|
|
75152
|
+
const accessKey = String(args.accessKey ?? "").trim();
|
|
75153
|
+
if (!ACCESS_KEY_RE.test(accessKey)) throw new SandboxError("the access key is sbxk_ and 64 hex characters, as agentgates.ai/sandboxes showed it once", "bad_input");
|
|
75154
|
+
const tlsPin = String(args.tlsPin ?? "").trim();
|
|
75155
|
+
const api2 = String(args.api ?? "").trim().replace(/\/+$/, "");
|
|
75156
|
+
const sandboxId = /\/v1\/sandboxes\/(sbx_[0-9a-f]{16})$/.exec(api2)?.[1] ?? null;
|
|
75157
|
+
if (!sandboxId) throw new SandboxError(`"${args.api}" is not a sandbox's address (https://<host>/v1/sandboxes/sbx_...)`, "bad_address");
|
|
75158
|
+
const deploymentId = args.deploymentId ? String(args.deploymentId).trim() : sandboxId;
|
|
75159
|
+
if (!/^[A-Za-z0-9_-]{1,64}$/.test(deploymentId)) throw new SandboxError(`"${args.deploymentId}" is not a deployment id`, "bad_input");
|
|
75160
|
+
const found = {
|
|
75161
|
+
deploymentId,
|
|
75162
|
+
sandboxId,
|
|
75163
|
+
api: api2,
|
|
75164
|
+
tlsPin,
|
|
75165
|
+
owner: null,
|
|
75166
|
+
ownerUnchecked: ATTACHED_OWNER_WORDS,
|
|
75167
|
+
auth: { kind: "key", secret: accessKey },
|
|
75168
|
+
record: null,
|
|
75169
|
+
machine: null
|
|
75170
|
+
};
|
|
75171
|
+
let door;
|
|
75172
|
+
try {
|
|
75173
|
+
door = await openCheckedDoor(found);
|
|
75174
|
+
} catch (err) {
|
|
75175
|
+
if (err instanceof DoorError) throw new SandboxError(err.message, err.code, { status: err.status });
|
|
75176
|
+
throw err;
|
|
75177
|
+
}
|
|
75178
|
+
let view;
|
|
75179
|
+
try {
|
|
75180
|
+
view = await door.door.read();
|
|
75181
|
+
} catch (err) {
|
|
75182
|
+
const e = err;
|
|
75183
|
+
if (e.status === 401 || e.status === 403) throw new SandboxError("that access key does not open this sandbox's door: nothing was kept", "wrong_key", { status: e.status });
|
|
75184
|
+
if (err instanceof DoorError) throw new SandboxError(err.message, err.code, { status: err.status });
|
|
75185
|
+
throw err;
|
|
75186
|
+
}
|
|
75187
|
+
const record = {
|
|
75188
|
+
v: 1,
|
|
75189
|
+
deploymentId,
|
|
75190
|
+
plan: null,
|
|
75191
|
+
sandboxId,
|
|
75192
|
+
api: api2,
|
|
75193
|
+
tlsPin,
|
|
75194
|
+
owner: null,
|
|
75195
|
+
accessKey,
|
|
75196
|
+
paidWith: "attached",
|
|
75197
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
75198
|
+
};
|
|
75199
|
+
await writeRecord(record);
|
|
75200
|
+
return { record, verdict: door.verdict, view };
|
|
75201
|
+
}
|
|
75107
75202
|
function receiptStateOf(found) {
|
|
75108
75203
|
const rec = found.record;
|
|
75109
75204
|
return {
|
|
@@ -75145,10 +75240,11 @@ async function renewSandbox(args) {
|
|
|
75145
75240
|
if (args.hours !== void 0) body.hours = n2;
|
|
75146
75241
|
else body.minutes = n2;
|
|
75147
75242
|
const what = `${n2} more ${args.hours !== void 0 ? "h" : "min"} on ${depId}`;
|
|
75148
|
-
return payFor2({ url: `${computeOrigin()}${path12}`, path: path12, body, mode: args.mode, key: args.key ?? null, consent: args.consent, what, onPaid: args.onPaid });
|
|
75243
|
+
return payFor2({ url: `${computeOrigin()}${path12}`, path: path12, body, mode: args.mode, key: args.key ?? null, consent: args.consent, what, onPaid: args.onPaid, budgetMs: args.budgetMs, listWords: args.listWords });
|
|
75149
75244
|
}
|
|
75150
75245
|
async function deleteSandbox(id2) {
|
|
75151
75246
|
const rec = await findRecord(id2);
|
|
75247
|
+
if (rec?.paidWith === "attached") throw new SandboxError(ATTACHED_DELETE_WORDS, "needs_owner");
|
|
75152
75248
|
let depId = rec?.deploymentId ?? id2;
|
|
75153
75249
|
const wallet = await payingWallet();
|
|
75154
75250
|
if (SANDBOX_ID_RE.test(depId)) {
|
|
@@ -75726,6 +75822,8 @@ async function sandboxExec(id2, argv, opts) {
|
|
|
75726
75822
|
process.exitCode = CLI_FAIL;
|
|
75727
75823
|
return;
|
|
75728
75824
|
}
|
|
75825
|
+
if (r.receiptCheck.note && !opts.json) sayErr2(` ${import_picocolors13.default.yellow("!")} receipt checked; ${r.receiptCheck.note}
|
|
75826
|
+
`);
|
|
75729
75827
|
if (r.timedOut) {
|
|
75730
75828
|
if (!opts.json) sayErr2(` ${import_picocolors13.default.yellow("!")} it ran out of its time${timeoutSeconds ? ` (${timeoutSeconds} s)` : " (300 s, the default)"}
|
|
75731
75829
|
`);
|
|
@@ -75973,6 +76071,44 @@ async function sandboxLs(opts) {
|
|
|
75973
76071
|
for (const e of list.errors) sayErr2(` ${import_picocolors13.default.yellow("!")} ${e}
|
|
75974
76072
|
`);
|
|
75975
76073
|
}
|
|
76074
|
+
var CHAIN_WORDS = { 8453: "Base", 137: "Polygon", 900: "Solana", 1: "Ethereum", 42161: "Arbitrum" };
|
|
76075
|
+
function paymentLine(inv) {
|
|
76076
|
+
const when3 = typeof inv.createdAt === "string" ? inv.createdAt.replace("T", " ").replace(/\.\d+Z$/, "Z") : "?";
|
|
76077
|
+
const minutes = typeof inv.minutes === "number" && inv.minutes > 0 ? inv.minutes : null;
|
|
76078
|
+
const hours = typeof inv.hours === "number" ? inv.hours : 0;
|
|
76079
|
+
const time = minutes !== null ? `${minutes} min` : hours > 0 ? `${hours} h` : "";
|
|
76080
|
+
const kind = inv.kind === "renew" ? "renewal" : inv.kind === "create" ? "purchase" : String(inv.kind ?? "payment");
|
|
76081
|
+
const how = typeof inv.chainId === "number" ? `paid on ${CHAIN_WORDS[inv.chainId] ?? `chain ${inv.chainId}`}` : "from a balance";
|
|
76082
|
+
return `${when3} ${kind}${time ? ` of ${time}` : ""} $${String(inv.amountUsd ?? "?")} ${how}`;
|
|
76083
|
+
}
|
|
76084
|
+
async function sandboxAttach(address, opts) {
|
|
76085
|
+
let accessKey = opts.accessKey ?? process.env.AGENTGATES_SANDBOX_ACCESS_KEY ?? "";
|
|
76086
|
+
if (!accessKey && !process.stdin.isTTY) {
|
|
76087
|
+
const chunks = [];
|
|
76088
|
+
for await (const c of process.stdin) chunks.push(Buffer.from(c));
|
|
76089
|
+
accessKey = Buffer.concat(chunks).toString("utf8").trim().split(/\s+/)[0] ?? "";
|
|
76090
|
+
}
|
|
76091
|
+
if (!opts.pin) return failWith(opts, new SandboxError("--pin is the sandbox's pin, sha256//..., as agentgates.ai/sandboxes shows it", "bad_input"));
|
|
76092
|
+
if (!accessKey) return failWith(opts, new SandboxError("its access key: --access-key, AGENTGATES_SANDBOX_ACCESS_KEY, or piped on stdin", "bad_input"));
|
|
76093
|
+
let out;
|
|
76094
|
+
try {
|
|
76095
|
+
out = await attachSandbox({ api: address, tlsPin: opts.pin, accessKey, deploymentId: opts.id ?? null });
|
|
76096
|
+
} catch (err) {
|
|
76097
|
+
return failWith(opts, err);
|
|
76098
|
+
}
|
|
76099
|
+
const r = out.record;
|
|
76100
|
+
if (jsonMode7(opts)) {
|
|
76101
|
+
say3(JSON.stringify({ ok: true, attached: { deploymentId: r.deploymentId, sandbox: { id: r.sandboxId, api: r.api, tlsPin: r.tlsPin } }, proof: "checked", ownerCheck: ATTACHED_OWNER_WORDS, door: out.view, delete: ATTACHED_DELETE_WORDS }, null, 2) + "\n");
|
|
76102
|
+
return;
|
|
76103
|
+
}
|
|
76104
|
+
say3(` ${import_picocolors13.default.green("ok")} ${r.sandboxId} attached: its proof checked and its door opened with the access key
|
|
76105
|
+
`);
|
|
76106
|
+
say3(` ${import_picocolors13.default.dim(`exec, cp, verify, logs and status reach it from here: agentgates sandbox exec ${r.sandboxId} -- <command>`)}
|
|
76107
|
+
`);
|
|
76108
|
+
say3(` ${import_picocolors13.default.dim(ATTACHED_DELETE_WORDS)}
|
|
76109
|
+
|
|
76110
|
+
`);
|
|
76111
|
+
}
|
|
75976
76112
|
async function sandboxStatus(id2, opts) {
|
|
75977
76113
|
let found;
|
|
75978
76114
|
try {
|
|
@@ -75996,13 +76132,21 @@ async function sandboxStatus(id2, opts) {
|
|
|
75996
76132
|
doorError = err.message;
|
|
75997
76133
|
}
|
|
75998
76134
|
if (jsonMode7(opts)) {
|
|
75999
|
-
|
|
76135
|
+
const payments = Array.isArray(found.machine?.invoices) ? found.machine.invoices : [];
|
|
76136
|
+
say3(JSON.stringify({ ok: true, deployment: found.machine, sandbox: { id: found.sandboxId, api: found.api, tlsPin: found.tlsPin }, payments, proof: door ? "checked" : "not checked", ...found.ownerUnchecked ? { ownerCheck: found.ownerUnchecked } : {}, door: doorView, ...doorError ? { doorError } : {} }, null, 2) + "\n");
|
|
76000
76137
|
return;
|
|
76001
76138
|
}
|
|
76002
76139
|
const m = found.machine;
|
|
76003
76140
|
say3(`
|
|
76004
76141
|
${sandboxLines({ deploymentId: found.deploymentId, status: m?.status ?? "running", plan: m?.plan ?? found.record?.plan, expiresAt: m?.expiresAt }, { id: found.sandboxId, api: found.api })}
|
|
76005
76142
|
`);
|
|
76143
|
+
const invoices = Array.isArray(m?.invoices) ? m.invoices : [];
|
|
76144
|
+
if (invoices.length) {
|
|
76145
|
+
say3(` payments ${invoices.length} on record
|
|
76146
|
+
`);
|
|
76147
|
+
for (const inv of invoices) say3(` ${import_picocolors13.default.dim(paymentLine(inv))}
|
|
76148
|
+
`);
|
|
76149
|
+
}
|
|
76006
76150
|
if (doorView) {
|
|
76007
76151
|
say3(` proof ${import_picocolors13.default.green("checked")} ${import_picocolors13.default.dim("(4 checks, your own nonce; agentgates sandbox verify shows each)")}
|
|
76008
76152
|
`);
|
|
@@ -78075,12 +78219,15 @@ import { pipeline as pipeline2 } from "node:stream/promises";
|
|
|
78075
78219
|
init_sandbox_door();
|
|
78076
78220
|
var TEXT_MAX = 1e5;
|
|
78077
78221
|
var SANDBOX_INSTRUCTIONS = "`sandbox_create` buys a sealed sandbox, a small Linux computer for one agent in a confidential VM, by the minute; `sandbox_exec` runs a command in it, `sandbox_file_put` and `sandbox_file_get` move files and folders in and out, `sandbox_verify` checks its proof with a nonce of this machine's own. Every call goes straight to the sandbox, its proof checked first and every body sealed; every run comes back with a receipt checked here.";
|
|
78078
|
-
|
|
78222
|
+
var MCP_PAID_BUDGET_MS = 45e3;
|
|
78223
|
+
async function sandboxListing(env = process.env, fetchImpl = fetch) {
|
|
78079
78224
|
if (env.AGENTGATES_SANDBOX_TOOLS === "1") return true;
|
|
78080
78225
|
try {
|
|
78081
|
-
|
|
78226
|
+
const plans = await listedSandboxPlans(fetchImpl);
|
|
78227
|
+
readWait = plans.length === 0 ? null : plans.some((p) => p.waitsForHost === true) ? true : plans.every((p) => p.waitsForHost === false) ? false : null;
|
|
78228
|
+
return plans.length > 0;
|
|
78082
78229
|
} catch {
|
|
78083
|
-
return
|
|
78230
|
+
return null;
|
|
78084
78231
|
}
|
|
78085
78232
|
}
|
|
78086
78233
|
function str(args, name) {
|
|
@@ -78126,11 +78273,16 @@ function payOf(args) {
|
|
|
78126
78273
|
return { mode: pay, key: null };
|
|
78127
78274
|
}
|
|
78128
78275
|
var ID_PROP = { id: { type: "string", description: "The sandbox's deployment id (or its sbx_ id), from sandbox_create or sandbox_list." } };
|
|
78129
|
-
|
|
78276
|
+
var readWait = null;
|
|
78277
|
+
function sandboxCreateWords(wait2) {
|
|
78278
|
+
const now = wait2 === true ? "When this server read the catalog no host had a free seat: one bought then waits for a host to start and runs about two minutes after its payment, its price carrying that start, and this tool answers at once with its id (sandbox_list shows it running). " : wait2 === false ? "When this server read the catalog a host had a free seat: one bought then answers running with its address; once the seats are taken, one waits about two minutes after its payment and this tool answers at once with its id. " : "It answers running with its address when a host has a seat; else it waits for a seat and runs about two minutes after its payment when a host must start for it, and this tool answers at once with its id (sandbox_list shows it running). ";
|
|
78279
|
+
return "Buy a sealed sandbox: a small Linux computer for one agent in a confidential VM (Intel TDX), by the minute. " + now + "The key that pays owns it. With access_key (always with pay key) it is made with a key kept on this machine.";
|
|
78280
|
+
}
|
|
78281
|
+
function sandboxTools(wait2 = readWait) {
|
|
78130
78282
|
return [
|
|
78131
78283
|
{
|
|
78132
78284
|
name: "sandbox_create",
|
|
78133
|
-
description:
|
|
78285
|
+
description: sandboxCreateWords(wait2),
|
|
78134
78286
|
inputSchema: {
|
|
78135
78287
|
type: "object",
|
|
78136
78288
|
properties: {
|
|
@@ -78153,7 +78305,10 @@ function sandboxTools() {
|
|
|
78153
78305
|
mode,
|
|
78154
78306
|
key,
|
|
78155
78307
|
accessKey: args.access_key === true,
|
|
78156
|
-
consent: { network: str(args, "network"), maxUsd: str(args, "max_usd"), interactive: false }
|
|
78308
|
+
consent: { network: str(args, "network"), maxUsd: str(args, "max_usd"), interactive: false },
|
|
78309
|
+
// Answered within an MCP client's 60 s (SESSION-4-GATE.md item 21).
|
|
78310
|
+
budgetMs: MCP_PAID_BUDGET_MS,
|
|
78311
|
+
listWords: "sandbox_list"
|
|
78157
78312
|
});
|
|
78158
78313
|
} catch (err) {
|
|
78159
78314
|
refused(err);
|
|
@@ -78357,7 +78512,7 @@ function sandboxTools() {
|
|
|
78357
78512
|
handler: async (args) => {
|
|
78358
78513
|
const { mode, key } = payOf(args);
|
|
78359
78514
|
try {
|
|
78360
|
-
const out = await renewSandbox({ id: need(args, "id", "the sandbox's id"), minutes: whole2(args, "minutes", 1, 720 * 60), mode, key, consent: { network: str(args, "network"), maxUsd: str(args, "max_usd"), interactive: false } });
|
|
78515
|
+
const out = await renewSandbox({ id: need(args, "id", "the sandbox's id"), minutes: whole2(args, "minutes", 1, 720 * 60), mode, key, consent: { network: str(args, "network"), maxUsd: str(args, "max_usd"), interactive: false }, budgetMs: MCP_PAID_BUDGET_MS, listWords: "sandbox_list" });
|
|
78361
78516
|
if (out.kind === "quote") throw new McpToolError("a quote was asked of a renewal");
|
|
78362
78517
|
return { ok: true, paid: out.paid, paidWith: out.mode, deployment: out.answer.json };
|
|
78363
78518
|
} catch (err) {
|
|
@@ -79052,26 +79207,40 @@ async function instructionsWithAbout() {
|
|
|
79052
79207
|
About the owner, in their own words (read when this server started; memory_about reads the current version):
|
|
79053
79208
|
${lines.map((l) => `- ${l}`).join("\n")}`;
|
|
79054
79209
|
}
|
|
79210
|
+
var LISTING_RETRY_MS = [2e3, 5e3, 15e3, 3e4];
|
|
79055
79211
|
async function mcpServeOn(io = {}, deps = {}) {
|
|
79056
79212
|
const env = deps.env ?? process.env;
|
|
79057
79213
|
const output2 = io.output ?? process.stdout;
|
|
79058
79214
|
const tools = mcpTools();
|
|
79059
79215
|
const forced = env.AGENTGATES_SANDBOX_TOOLS === "1";
|
|
79060
|
-
if (forced) tools.push(...sandboxTools());
|
|
79061
79216
|
let listedOnce = false;
|
|
79062
|
-
|
|
79063
|
-
|
|
79064
|
-
|
|
79065
|
-
|
|
79066
|
-
|
|
79217
|
+
const addSandboxTools = () => {
|
|
79218
|
+
if (tools.some((t) => t.name.startsWith("sandbox_"))) return false;
|
|
79219
|
+
tools.push(...sandboxTools());
|
|
79220
|
+
return true;
|
|
79221
|
+
};
|
|
79222
|
+
if (forced) addSandboxTools();
|
|
79223
|
+
const read = deps.listed ?? (() => sandboxListing(env));
|
|
79224
|
+
const retries = deps.retryMs ?? LISTING_RETRY_MS;
|
|
79225
|
+
const listing = forced ? Promise.resolve(true) : (async () => {
|
|
79226
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
79227
|
+
const listed = await read().catch(() => null);
|
|
79228
|
+
if (listed !== null) return listed;
|
|
79229
|
+
if (attempt >= retries.length) return false;
|
|
79230
|
+
await new Promise((r) => setTimeout(r, retries[attempt]).unref());
|
|
79231
|
+
}
|
|
79232
|
+
})();
|
|
79233
|
+
void listing.then((listed) => {
|
|
79234
|
+
if (listed && addSandboxTools() && listedOnce) output2.write(`${JSON.stringify({ jsonrpc: "2.0", method: "notifications/tools/list_changed" })}
|
|
79067
79235
|
`);
|
|
79068
|
-
|
|
79069
|
-
|
|
79070
|
-
const instructions = await instructionsWithAbout();
|
|
79236
|
+
});
|
|
79237
|
+
const inTime = Promise.race([listing, new Promise((r) => setTimeout(() => r(null), deps.waitMs ?? ABOUT_AT_START_MS).unref())]);
|
|
79238
|
+
const [instructions, listedAtStart] = await Promise.all([instructionsWithAbout(), inTime]);
|
|
79239
|
+
if (listedAtStart) addSandboxTools();
|
|
79071
79240
|
await serve(tools, {
|
|
79072
79241
|
name: MCP_SERVER_NAME,
|
|
79073
79242
|
version: CLI_VERSION,
|
|
79074
|
-
instructions:
|
|
79243
|
+
instructions: listedAtStart ? `${instructions}
|
|
79075
79244
|
|
|
79076
79245
|
${SANDBOX_INSTRUCTIONS}` : instructions,
|
|
79077
79246
|
toolsChange: true,
|
|
@@ -81001,15 +81170,29 @@ async function whoami(opts) {
|
|
|
81001
81170
|
}
|
|
81002
81171
|
process.stdout.write(`User ${me.userId}
|
|
81003
81172
|
`);
|
|
81004
|
-
|
|
81005
|
-
|
|
81173
|
+
const wallets2 = me.wallets ?? [];
|
|
81174
|
+
const onlyDefault = wallets2.length === 0 || wallets2.length === 1 && wallets2[0].is_default;
|
|
81175
|
+
if (onlyDefault) {
|
|
81176
|
+
if (me.walletAddress) {
|
|
81177
|
+
process.stdout.write(`EVM ${me.walletAddress}
|
|
81006
81178
|
`);
|
|
81007
|
-
|
|
81008
|
-
|
|
81009
|
-
|
|
81179
|
+
}
|
|
81180
|
+
if (me.solanaAddress) {
|
|
81181
|
+
process.stdout.write(`Solana ${me.solanaAddress}
|
|
81182
|
+
`);
|
|
81183
|
+
}
|
|
81184
|
+
} else {
|
|
81185
|
+
wallets2.forEach((w, i) => {
|
|
81186
|
+
process.stdout.write(`${i === 0 ? "Wallets " : " "} ${w.name}${w.is_default ? import_picocolors22.default.dim(" (default)") : ""}
|
|
81187
|
+
`);
|
|
81188
|
+
process.stdout.write(` EVM ${w.evm}
|
|
81010
81189
|
`);
|
|
81190
|
+
if (w.solana) process.stdout.write(` Solana ${w.solana}
|
|
81191
|
+
`);
|
|
81192
|
+
});
|
|
81011
81193
|
}
|
|
81012
|
-
|
|
81194
|
+
const scopes = me.scopes.filter((s) => !s.startsWith("wallet:id:"));
|
|
81195
|
+
process.stdout.write(`Scopes ${scopes.join(", ") || import_picocolors22.default.dim("(none)")}
|
|
81013
81196
|
`);
|
|
81014
81197
|
const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
|
|
81015
81198
|
const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
|
|
@@ -81301,7 +81484,8 @@ async function send(amount, asset, opts) {
|
|
|
81301
81484
|
amount,
|
|
81302
81485
|
asset: assetNormalized,
|
|
81303
81486
|
chain: opts.chain,
|
|
81304
|
-
user_stated: userStatedPayload
|
|
81487
|
+
user_stated: userStatedPayload,
|
|
81488
|
+
...opts.wallet ? { wallet: opts.wallet } : {}
|
|
81305
81489
|
};
|
|
81306
81490
|
let activeProfile = profile;
|
|
81307
81491
|
let proposed;
|
|
@@ -81405,6 +81589,12 @@ async function send(amount, asset, opts) {
|
|
|
81405
81589
|
process.stderr.write(import_picocolors23.default.red(`\u2715 ${proposed.reason}
|
|
81406
81590
|
`));
|
|
81407
81591
|
}
|
|
81592
|
+
if (proposed.code === "WALLET_NOT_GRANTED") {
|
|
81593
|
+
process.stderr.write(
|
|
81594
|
+
` To add it: ${import_picocolors23.default.bold("agentgates logout")}, then ${import_picocolors23.default.bold("agentgates login")}, and tick it on the page.
|
|
81595
|
+
`
|
|
81596
|
+
);
|
|
81597
|
+
}
|
|
81408
81598
|
if (proposed.upgrade_url) {
|
|
81409
81599
|
process.stderr.write(
|
|
81410
81600
|
` Open this to grant access, then re-run the command:
|
|
@@ -81454,15 +81644,16 @@ async function send(amount, asset, opts) {
|
|
|
81454
81644
|
preview: proposed.preview,
|
|
81455
81645
|
caps_snapshot: proposed.caps_snapshot,
|
|
81456
81646
|
price_snapshot: proposed.price_snapshot,
|
|
81457
|
-
balance_snapshot: proposed.balance_snapshot
|
|
81647
|
+
balance_snapshot: proposed.balance_snapshot,
|
|
81648
|
+
...proposed.wallet ? { wallet: proposed.wallet } : {}
|
|
81458
81649
|
});
|
|
81459
81650
|
} else {
|
|
81460
81651
|
process.stdout.write(
|
|
81461
81652
|
`
|
|
81462
81653
|
${import_picocolors23.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
81463
81654
|
${import_picocolors23.default.cyan(proposed.approval_url)}
|
|
81464
|
-
|
|
81465
|
-
`
|
|
81655
|
+
` + (proposed.wallet ? ` From ${import_picocolors23.default.bold(proposed.wallet.name)}
|
|
81656
|
+
` : "") + "\n"
|
|
81466
81657
|
);
|
|
81467
81658
|
}
|
|
81468
81659
|
if (shouldOpenBrowser) {
|
|
@@ -81835,7 +82026,10 @@ async function balance(opts) {
|
|
|
81835
82026
|
profileName,
|
|
81836
82027
|
jsonMode: jsonMode9,
|
|
81837
82028
|
ttyHeader: import_picocolors25.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
81838
|
-
fn: (bearer, origin) => apiFetch(
|
|
82029
|
+
fn: (bearer, origin) => apiFetch(
|
|
82030
|
+
opts.wallet ? `/api/balances?wallet=${encodeURIComponent(opts.wallet)}` : "/api/balances",
|
|
82031
|
+
{ bearer, origin }
|
|
82032
|
+
)
|
|
81839
82033
|
});
|
|
81840
82034
|
if (outcome.kind === "auth_failed") {
|
|
81841
82035
|
if (jsonMode9) {
|
|
@@ -81858,6 +82052,11 @@ async function balance(opts) {
|
|
|
81858
82052
|
throw err;
|
|
81859
82053
|
}
|
|
81860
82054
|
const res = outcome.result;
|
|
82055
|
+
if (res.code && res.error && !jsonMode9) {
|
|
82056
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${res.error}
|
|
82057
|
+
`));
|
|
82058
|
+
process.exit(1);
|
|
82059
|
+
}
|
|
81861
82060
|
const filtered = chainFilter !== null ? res.chains.filter((c) => c.chainId === chainFilter) : res.chains;
|
|
81862
82061
|
if (jsonMode9) {
|
|
81863
82062
|
process.stdout.write(
|
|
@@ -81867,8 +82066,10 @@ async function balance(opts) {
|
|
|
81867
82066
|
2
|
|
81868
82067
|
) + "\n"
|
|
81869
82068
|
);
|
|
82069
|
+
if (res.code && res.error) process.exit(1);
|
|
81870
82070
|
return;
|
|
81871
82071
|
}
|
|
82072
|
+
if (res.wallet) process.stdout.write(import_picocolors25.default.bold(res.wallet.name) + "\n");
|
|
81872
82073
|
if (res.snapshot && chainFilter === null) {
|
|
81873
82074
|
process.stdout.write(res.snapshot + "\n");
|
|
81874
82075
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -81994,7 +82195,7 @@ async function history(opts) {
|
|
|
81994
82195
|
jsonMode: jsonMode9,
|
|
81995
82196
|
ttyHeader: import_picocolors26.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
81996
82197
|
fn: (bearer, origin) => apiFetch(
|
|
81997
|
-
`/api/history?limit=${encodeURIComponent(String(limit))}
|
|
82198
|
+
`/api/history?limit=${encodeURIComponent(String(limit))}` + (opts.wallet ? `&wallet=${encodeURIComponent(opts.wallet)}` : ""),
|
|
81998
82199
|
{ bearer, origin }
|
|
81999
82200
|
)
|
|
82000
82201
|
});
|
|
@@ -82021,8 +82222,15 @@ async function history(opts) {
|
|
|
82021
82222
|
const res = outcome.result;
|
|
82022
82223
|
if (jsonMode9) {
|
|
82023
82224
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
82225
|
+
if (res.code && res.error) process.exit(1);
|
|
82024
82226
|
return;
|
|
82025
82227
|
}
|
|
82228
|
+
if (res.code && res.error) {
|
|
82229
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 ${res.error}
|
|
82230
|
+
`));
|
|
82231
|
+
process.exit(1);
|
|
82232
|
+
}
|
|
82233
|
+
if (res.wallet) process.stdout.write(import_picocolors26.default.bold(res.wallet.name) + "\n");
|
|
82026
82234
|
if (res.message && res.txs.length === 0) {
|
|
82027
82235
|
process.stdout.write(`${res.message}
|
|
82028
82236
|
`);
|
|
@@ -82207,6 +82415,9 @@ async function fetchTerminalDetail(intentId, profile) {
|
|
|
82207
82415
|
}
|
|
82208
82416
|
async function runIntentFlow(opts) {
|
|
82209
82417
|
let activeProfile = opts.initialProfile;
|
|
82418
|
+
if (opts.wallet && opts.body && typeof opts.body === "object") {
|
|
82419
|
+
opts = { ...opts, body: { ...opts.body, wallet: opts.wallet } };
|
|
82420
|
+
}
|
|
82210
82421
|
let proposed;
|
|
82211
82422
|
try {
|
|
82212
82423
|
proposed = await apiFetch(opts.endpoint, {
|
|
@@ -82299,6 +82510,12 @@ async function runIntentFlow(opts) {
|
|
|
82299
82510
|
}
|
|
82300
82511
|
process.stderr.write(import_picocolors27.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
|
|
82301
82512
|
`));
|
|
82513
|
+
if (proposed.code === "WALLET_NOT_GRANTED") {
|
|
82514
|
+
process.stderr.write(
|
|
82515
|
+
` To add it: ${import_picocolors27.default.bold("agentgates logout")}, then ${import_picocolors27.default.bold("agentgates login")}, and tick it on the page.
|
|
82516
|
+
`
|
|
82517
|
+
);
|
|
82518
|
+
}
|
|
82302
82519
|
if (proposed.upgrade_url) {
|
|
82303
82520
|
process.stderr.write(
|
|
82304
82521
|
` Open this to grant access, then re-run the command:
|
|
@@ -82326,15 +82543,16 @@ async function runIntentFlow(opts) {
|
|
|
82326
82543
|
preview: proposed.preview,
|
|
82327
82544
|
caps_snapshot: proposed.caps_snapshot,
|
|
82328
82545
|
price_snapshot: proposed.price_snapshot,
|
|
82329
|
-
balance_snapshot: proposed.balance_snapshot
|
|
82546
|
+
balance_snapshot: proposed.balance_snapshot,
|
|
82547
|
+
...proposed.wallet ? { wallet: proposed.wallet } : {}
|
|
82330
82548
|
});
|
|
82331
82549
|
} else {
|
|
82332
82550
|
process.stdout.write(
|
|
82333
82551
|
`
|
|
82334
82552
|
${import_picocolors27.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
82335
82553
|
${import_picocolors27.default.cyan(proposed.approval_url)}
|
|
82336
|
-
|
|
82337
|
-
`
|
|
82554
|
+
` + (proposed.wallet ? ` From ${import_picocolors27.default.bold(proposed.wallet.name)}
|
|
82555
|
+
` : "") + "\n"
|
|
82338
82556
|
);
|
|
82339
82557
|
}
|
|
82340
82558
|
if (opts.shouldOpenBrowser) {
|
|
@@ -82672,6 +82890,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
82672
82890
|
return parts.join(" ");
|
|
82673
82891
|
};
|
|
82674
82892
|
await runIntentFlow({
|
|
82893
|
+
wallet: opts.wallet,
|
|
82675
82894
|
endpoint: "/api/intents/propose-swap",
|
|
82676
82895
|
body: proposeBody,
|
|
82677
82896
|
profileName,
|
|
@@ -82733,6 +82952,7 @@ async function batch(opts) {
|
|
|
82733
82952
|
};
|
|
82734
82953
|
const shouldOpenBrowser = resolveBrowserDefault(opts.browserMode ?? "auto");
|
|
82735
82954
|
await runIntentFlow({
|
|
82955
|
+
wallet: opts.wallet,
|
|
82736
82956
|
endpoint: "/api/intents/propose-batch",
|
|
82737
82957
|
body: {
|
|
82738
82958
|
legs,
|
|
@@ -82808,6 +83028,7 @@ async function fundWallet(address, opts) {
|
|
|
82808
83028
|
const shouldOpenBrowser = resolveBrowserDefault(opts.browserMode ?? "auto");
|
|
82809
83029
|
if (gas > 0 && usdc <= 0) {
|
|
82810
83030
|
await runIntentFlow({
|
|
83031
|
+
wallet: opts.wallet,
|
|
82811
83032
|
endpoint: "/api/intents/propose",
|
|
82812
83033
|
body: {
|
|
82813
83034
|
to: address,
|
|
@@ -82823,6 +83044,7 @@ async function fundWallet(address, opts) {
|
|
|
82823
83044
|
});
|
|
82824
83045
|
}
|
|
82825
83046
|
await runIntentFlow({
|
|
83047
|
+
wallet: opts.wallet,
|
|
82826
83048
|
endpoint: "/api/intents/propose-fund",
|
|
82827
83049
|
body: {
|
|
82828
83050
|
address,
|
|
@@ -82838,12 +83060,96 @@ async function fundWallet(address, opts) {
|
|
|
82838
83060
|
});
|
|
82839
83061
|
}
|
|
82840
83062
|
|
|
82841
|
-
// src/commands/
|
|
83063
|
+
// src/commands/wallets.ts
|
|
82842
83064
|
var import_picocolors31 = __toESM(require_picocolors(), 1);
|
|
83065
|
+
function short4(address) {
|
|
83066
|
+
return address.length > 12 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
|
|
83067
|
+
}
|
|
83068
|
+
async function wallets(opts) {
|
|
83069
|
+
const resolved = await resolveProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
83070
|
+
if (!resolved) {
|
|
83071
|
+
process.stderr.write(import_picocolors31.default.red("Not logged in. Run agentgates login first.\n"));
|
|
83072
|
+
process.exit(2);
|
|
83073
|
+
}
|
|
83074
|
+
if (resolved.autoSelected) {
|
|
83075
|
+
process.stderr.write(import_picocolors31.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
83076
|
+
`));
|
|
83077
|
+
}
|
|
83078
|
+
const jsonMode9 = opts.json === true;
|
|
83079
|
+
const outcome = await callWithAutoRelogin({
|
|
83080
|
+
profile: resolved.profile,
|
|
83081
|
+
profileName: resolved.name,
|
|
83082
|
+
jsonMode: jsonMode9,
|
|
83083
|
+
ttyHeader: import_picocolors31.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
83084
|
+
fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
|
|
83085
|
+
});
|
|
83086
|
+
if (outcome.kind === "auth_failed") {
|
|
83087
|
+
if (jsonMode9) {
|
|
83088
|
+
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
83089
|
+
process.exit(1);
|
|
83090
|
+
}
|
|
83091
|
+
process.stderr.write(import_picocolors31.default.red(`\u2715 ${outcome.reason}.
|
|
83092
|
+
`));
|
|
83093
|
+
process.exit(1);
|
|
83094
|
+
}
|
|
83095
|
+
if (outcome.kind === "error") {
|
|
83096
|
+
const err = outcome.error;
|
|
83097
|
+
if (err instanceof ApiError) {
|
|
83098
|
+
process.stderr.write(import_picocolors31.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
83099
|
+
`));
|
|
83100
|
+
process.exit(1);
|
|
83101
|
+
}
|
|
83102
|
+
throw err;
|
|
83103
|
+
}
|
|
83104
|
+
const list = outcome.result.wallets;
|
|
83105
|
+
if (!Array.isArray(list)) {
|
|
83106
|
+
if (jsonMode9) {
|
|
83107
|
+
process.stdout.write(JSON.stringify({ ok: false, error: "The server did not list this terminal's wallets." }) + "\n");
|
|
83108
|
+
process.exit(1);
|
|
83109
|
+
}
|
|
83110
|
+
process.stderr.write(import_picocolors31.default.red("\u2715 The server did not list this terminal's wallets. Try again in a minute.\n"));
|
|
83111
|
+
process.exit(1);
|
|
83112
|
+
}
|
|
83113
|
+
if (jsonMode9) {
|
|
83114
|
+
process.stdout.write(JSON.stringify({ wallets: list }, null, 2) + "\n");
|
|
83115
|
+
return;
|
|
83116
|
+
}
|
|
83117
|
+
if (list.length === 0) {
|
|
83118
|
+
process.stdout.write("No wallet on this account yet. Create one at agentgates.ai.\n");
|
|
83119
|
+
return;
|
|
83120
|
+
}
|
|
83121
|
+
const width = Math.max(...list.map((w) => w.name.length + (w.is_default ? 10 : 0)));
|
|
83122
|
+
for (const w of list) {
|
|
83123
|
+
const label = w.is_default ? `${w.name} (default)` : w.name;
|
|
83124
|
+
process.stdout.write(
|
|
83125
|
+
`${label.padEnd(width)} ${short4(w.evm)}${w.solana ? ` ${short4(w.solana)}` : ""}
|
|
83126
|
+
`
|
|
83127
|
+
);
|
|
83128
|
+
}
|
|
83129
|
+
const fallback = list.find((w) => w.is_default) ?? (list.length === 1 ? list[0] : null);
|
|
83130
|
+
if (list.length > 1) {
|
|
83131
|
+
process.stdout.write(
|
|
83132
|
+
import_picocolors31.default.dim(
|
|
83133
|
+
fallback ? `
|
|
83134
|
+
Pick one with --wallet "<name>"; without it, ${fallback.name} pays.
|
|
83135
|
+
` : `
|
|
83136
|
+
Name one with --wallet "<name>" on every call.
|
|
83137
|
+
`
|
|
83138
|
+
)
|
|
83139
|
+
);
|
|
83140
|
+
} else if (!list[0].is_default) {
|
|
83141
|
+
process.stdout.write(import_picocolors31.default.dim(`
|
|
83142
|
+
This terminal pays from ${list[0].name}.
|
|
83143
|
+
`));
|
|
83144
|
+
}
|
|
83145
|
+
}
|
|
83146
|
+
|
|
83147
|
+
// src/commands/earn-supply.ts
|
|
83148
|
+
var import_picocolors32 = __toESM(require_picocolors(), 1);
|
|
82843
83149
|
var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
82844
83150
|
var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
82845
83151
|
function failArg4(msg) {
|
|
82846
|
-
process.stderr.write(
|
|
83152
|
+
process.stderr.write(import_picocolors32.default.red(`\u2715 ${msg}
|
|
82847
83153
|
`));
|
|
82848
83154
|
process.exit(2);
|
|
82849
83155
|
}
|
|
@@ -82851,11 +83157,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
82851
83157
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
82852
83158
|
const resolved = await resolveProfile(requested);
|
|
82853
83159
|
if (!resolved) {
|
|
82854
|
-
process.stderr.write(
|
|
83160
|
+
process.stderr.write(import_picocolors32.default.red("Not logged in. Run agentgates login first.\n"));
|
|
82855
83161
|
process.exit(2);
|
|
82856
83162
|
}
|
|
82857
83163
|
if (resolved.autoSelected) {
|
|
82858
|
-
process.stderr.write(
|
|
83164
|
+
process.stderr.write(import_picocolors32.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
82859
83165
|
`));
|
|
82860
83166
|
}
|
|
82861
83167
|
const { profile, name: profileName } = resolved;
|
|
@@ -82863,12 +83169,12 @@ async function earnSupply(amount, asset, opts) {
|
|
|
82863
83169
|
const jsonMode9 = opts.json === true || !stdoutIsTty;
|
|
82864
83170
|
const amountNumber = Number(amount);
|
|
82865
83171
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
82866
|
-
failArg4(`amount must be a positive number (got ${
|
|
83172
|
+
failArg4(`amount must be a positive number (got ${import_picocolors32.default.bold(amount)}).`);
|
|
82867
83173
|
}
|
|
82868
83174
|
const assetNorm = asset.toLowerCase();
|
|
82869
83175
|
if (!ASSET_VALUES2.has(assetNorm)) {
|
|
82870
83176
|
failArg4(
|
|
82871
|
-
`asset must be ${
|
|
83177
|
+
`asset must be ${import_picocolors32.default.bold("native")} or ${import_picocolors32.default.bold("usdc")} (got ${import_picocolors32.default.bold(asset)}).`
|
|
82872
83178
|
);
|
|
82873
83179
|
}
|
|
82874
83180
|
if (!opts.chain) {
|
|
@@ -82880,7 +83186,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
82880
83186
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
82881
83187
|
if (!PROTOCOLS.has(protocolNorm)) {
|
|
82882
83188
|
failArg4(
|
|
82883
|
-
`--protocol must be ${
|
|
83189
|
+
`--protocol must be ${import_picocolors32.default.bold("aave_v3")} or ${import_picocolors32.default.bold("kamino_lend")} (got ${import_picocolors32.default.bold(opts.protocol)}).`
|
|
82884
83190
|
);
|
|
82885
83191
|
}
|
|
82886
83192
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -82922,6 +83228,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
82922
83228
|
};
|
|
82923
83229
|
const shouldOpenBrowser = resolveBrowserDefault(opts.browserMode ?? "auto");
|
|
82924
83230
|
await runIntentFlow({
|
|
83231
|
+
wallet: opts.wallet,
|
|
82925
83232
|
endpoint: "/api/intents/propose-earn-supply",
|
|
82926
83233
|
body: proposeBody,
|
|
82927
83234
|
profileName,
|
|
@@ -82932,11 +83239,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
82932
83239
|
}
|
|
82933
83240
|
|
|
82934
83241
|
// src/commands/earn-withdraw.ts
|
|
82935
|
-
var
|
|
83242
|
+
var import_picocolors33 = __toESM(require_picocolors(), 1);
|
|
82936
83243
|
var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
82937
83244
|
var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
82938
83245
|
function failArg5(msg) {
|
|
82939
|
-
process.stderr.write(
|
|
83246
|
+
process.stderr.write(import_picocolors33.default.red(`\u2715 ${msg}
|
|
82940
83247
|
`));
|
|
82941
83248
|
process.exit(2);
|
|
82942
83249
|
}
|
|
@@ -82944,11 +83251,11 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
82944
83251
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
82945
83252
|
const resolved = await resolveProfile(requested);
|
|
82946
83253
|
if (!resolved) {
|
|
82947
|
-
process.stderr.write(
|
|
83254
|
+
process.stderr.write(import_picocolors33.default.red("Not logged in. Run agentgates login first.\n"));
|
|
82948
83255
|
process.exit(2);
|
|
82949
83256
|
}
|
|
82950
83257
|
if (resolved.autoSelected) {
|
|
82951
|
-
process.stderr.write(
|
|
83258
|
+
process.stderr.write(import_picocolors33.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
82952
83259
|
`));
|
|
82953
83260
|
}
|
|
82954
83261
|
const { profile, name: profileName } = resolved;
|
|
@@ -82959,14 +83266,14 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
82959
83266
|
const amountNumber = Number(amountOrMax);
|
|
82960
83267
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
82961
83268
|
failArg5(
|
|
82962
|
-
`<amount-or-max> must be a positive number or the literal string "max" (got ${
|
|
83269
|
+
`<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors33.default.bold(amountOrMax)}).`
|
|
82963
83270
|
);
|
|
82964
83271
|
}
|
|
82965
83272
|
}
|
|
82966
83273
|
const assetNorm = asset.toLowerCase();
|
|
82967
83274
|
if (!ASSET_VALUES3.has(assetNorm)) {
|
|
82968
83275
|
failArg5(
|
|
82969
|
-
`asset must be ${
|
|
83276
|
+
`asset must be ${import_picocolors33.default.bold("native")} or ${import_picocolors33.default.bold("usdc")} (got ${import_picocolors33.default.bold(asset)}).`
|
|
82970
83277
|
);
|
|
82971
83278
|
}
|
|
82972
83279
|
if (!opts.chain) {
|
|
@@ -82978,7 +83285,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
82978
83285
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
82979
83286
|
if (!PROTOCOLS2.has(protocolNorm)) {
|
|
82980
83287
|
failArg5(
|
|
82981
|
-
`--protocol must be ${
|
|
83288
|
+
`--protocol must be ${import_picocolors33.default.bold("aave_v3")} or ${import_picocolors33.default.bold("kamino_lend")} (got ${import_picocolors33.default.bold(opts.protocol)}).`
|
|
82982
83289
|
);
|
|
82983
83290
|
}
|
|
82984
83291
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -83020,6 +83327,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
83020
83327
|
};
|
|
83021
83328
|
const shouldOpenBrowser = resolveBrowserDefault(opts.browserMode ?? "auto");
|
|
83022
83329
|
await runIntentFlow({
|
|
83330
|
+
wallet: opts.wallet,
|
|
83023
83331
|
endpoint: "/api/intents/propose-earn-withdraw",
|
|
83024
83332
|
body: proposeBody,
|
|
83025
83333
|
profileName,
|
|
@@ -83030,7 +83338,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
83030
83338
|
}
|
|
83031
83339
|
|
|
83032
83340
|
// src/commands/eat.ts
|
|
83033
|
-
var
|
|
83341
|
+
var import_picocolors34 = __toESM(require_picocolors(), 1);
|
|
83034
83342
|
function parseLineJson(values) {
|
|
83035
83343
|
const lines = [];
|
|
83036
83344
|
for (const value of values) {
|
|
@@ -83057,11 +83365,11 @@ function parseLineJson(values) {
|
|
|
83057
83365
|
async function loadResolvedProfile(requested) {
|
|
83058
83366
|
const resolved = await resolveProfile(requested);
|
|
83059
83367
|
if (!resolved) {
|
|
83060
|
-
process.stderr.write(
|
|
83368
|
+
process.stderr.write(import_picocolors34.default.red("Not logged in. Run agentgates login first.\n"));
|
|
83061
83369
|
process.exit(2);
|
|
83062
83370
|
}
|
|
83063
83371
|
if (resolved.autoSelected) {
|
|
83064
|
-
process.stderr.write(
|
|
83372
|
+
process.stderr.write(import_picocolors34.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
83065
83373
|
`));
|
|
83066
83374
|
}
|
|
83067
83375
|
return resolved;
|
|
@@ -83072,12 +83380,12 @@ function printResult(res, jsonMode9) {
|
|
|
83072
83380
|
return;
|
|
83073
83381
|
}
|
|
83074
83382
|
if (res.blocked) {
|
|
83075
|
-
process.stderr.write(
|
|
83383
|
+
process.stderr.write(import_picocolors34.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
|
|
83076
83384
|
`));
|
|
83077
83385
|
if (res.upgrade_url) {
|
|
83078
83386
|
process.stderr.write(
|
|
83079
83387
|
` Open this to grant access, then re-run the command:
|
|
83080
|
-
${
|
|
83388
|
+
${import_picocolors34.default.cyan(res.upgrade_url)}
|
|
83081
83389
|
`
|
|
83082
83390
|
);
|
|
83083
83391
|
}
|
|
@@ -83108,7 +83416,7 @@ async function postRestaurant(path12, body, resolved, jsonMode9) {
|
|
|
83108
83416
|
profile: resolved.profile,
|
|
83109
83417
|
profileName: resolved.name,
|
|
83110
83418
|
jsonMode: jsonMode9,
|
|
83111
|
-
ttyHeader:
|
|
83419
|
+
ttyHeader: import_picocolors34.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
83112
83420
|
fn: (bearer, origin) => apiFetch(path12, { method: "POST", bearer, origin, body })
|
|
83113
83421
|
});
|
|
83114
83422
|
if (outcome.kind === "auth_failed") {
|
|
@@ -83118,7 +83426,7 @@ async function postRestaurant(path12, body, resolved, jsonMode9) {
|
|
|
83118
83426
|
);
|
|
83119
83427
|
process.exit(1);
|
|
83120
83428
|
}
|
|
83121
|
-
process.stderr.write(
|
|
83429
|
+
process.stderr.write(import_picocolors34.default.red(`\u2715 ${outcome.reason}.
|
|
83122
83430
|
`));
|
|
83123
83431
|
process.exit(1);
|
|
83124
83432
|
}
|
|
@@ -83131,7 +83439,7 @@ async function postRestaurant(path12, body, resolved, jsonMode9) {
|
|
|
83131
83439
|
);
|
|
83132
83440
|
process.exit(1);
|
|
83133
83441
|
}
|
|
83134
|
-
process.stderr.write(
|
|
83442
|
+
process.stderr.write(import_picocolors34.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
83135
83443
|
`));
|
|
83136
83444
|
process.exit(1);
|
|
83137
83445
|
}
|
|
@@ -83144,7 +83452,7 @@ async function searchFood(opts) {
|
|
|
83144
83452
|
const jsonMode9 = opts.json === true || process.stdout.isTTY !== true;
|
|
83145
83453
|
if (!opts.location && !opts.name) {
|
|
83146
83454
|
process.stderr.write(
|
|
83147
|
-
|
|
83455
|
+
import_picocolors34.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
|
|
83148
83456
|
);
|
|
83149
83457
|
process.exit(2);
|
|
83150
83458
|
}
|
|
@@ -83165,7 +83473,7 @@ async function menuFood(items, opts) {
|
|
|
83165
83473
|
const jsonMode9 = opts.json === true || process.stdout.isTTY !== true;
|
|
83166
83474
|
if (!opts.brand || !opts.address) {
|
|
83167
83475
|
process.stderr.write(
|
|
83168
|
-
|
|
83476
|
+
import_picocolors34.default.red(
|
|
83169
83477
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
83170
83478
|
)
|
|
83171
83479
|
);
|
|
@@ -83185,7 +83493,7 @@ async function orderFood(items, opts) {
|
|
|
83185
83493
|
const jsonMode9 = opts.json === true || process.stdout.isTTY !== true;
|
|
83186
83494
|
if (!opts.brand || !opts.address) {
|
|
83187
83495
|
process.stderr.write(
|
|
83188
|
-
|
|
83496
|
+
import_picocolors34.default.red(
|
|
83189
83497
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
83190
83498
|
)
|
|
83191
83499
|
);
|
|
@@ -83195,14 +83503,14 @@ async function orderFood(items, opts) {
|
|
|
83195
83503
|
try {
|
|
83196
83504
|
structuredLines = parseLineJson(opts.lineJson ?? []);
|
|
83197
83505
|
} catch (e) {
|
|
83198
|
-
process.stderr.write(
|
|
83506
|
+
process.stderr.write(import_picocolors34.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
|
|
83199
83507
|
`));
|
|
83200
83508
|
process.exit(2);
|
|
83201
83509
|
}
|
|
83202
83510
|
const lines = [...items ?? [], ...structuredLines];
|
|
83203
83511
|
if (lines.length === 0) {
|
|
83204
83512
|
process.stderr.write(
|
|
83205
|
-
|
|
83513
|
+
import_picocolors34.default.red("\u2715 Pass at least one dish \u2014 plain words as arguments, or --line-json for a line with a size/option/note.\n")
|
|
83206
83514
|
);
|
|
83207
83515
|
process.exit(2);
|
|
83208
83516
|
}
|
|
@@ -83236,7 +83544,7 @@ async function orderFood(items, opts) {
|
|
|
83236
83544
|
if (!agentCard.will_attempt) {
|
|
83237
83545
|
if (!jsonMode9) {
|
|
83238
83546
|
process.stderr.write(
|
|
83239
|
-
|
|
83547
|
+
import_picocolors34.default.yellow(
|
|
83240
83548
|
agentCard.allowed ? `This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
83241
83549
|
` : `You have not allowed this login to pay for food with your saved card, so it needs you. Allow "Pay for food" on this agent's page in your Agentgates wallet to let it pay the next ones.
|
|
83242
83550
|
`
|
|
@@ -83254,7 +83562,7 @@ async function orderFood(items, opts) {
|
|
|
83254
83562
|
}
|
|
83255
83563
|
if (verdict.status === "paid") {
|
|
83256
83564
|
process.stdout.write(
|
|
83257
|
-
|
|
83565
|
+
import_picocolors34.default.green(
|
|
83258
83566
|
`Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
|
|
83259
83567
|
)
|
|
83260
83568
|
);
|
|
@@ -83262,7 +83570,7 @@ async function orderFood(items, opts) {
|
|
|
83262
83570
|
}
|
|
83263
83571
|
if (verdict.status === "failed") {
|
|
83264
83572
|
process.stderr.write(
|
|
83265
|
-
|
|
83573
|
+
import_picocolors34.default.yellow(
|
|
83266
83574
|
`Your saved card did not pay this (${verdict.failure_reason ?? "refused"}${verdict.failure_detail ? `: ${verdict.failure_detail}` : ""}). Nothing was charged. The link still works for you to pay yourself.
|
|
83267
83575
|
`
|
|
83268
83576
|
)
|
|
@@ -83272,7 +83580,7 @@ async function orderFood(items, opts) {
|
|
|
83272
83580
|
}
|
|
83273
83581
|
if (verdict.status === "unconfirmed") {
|
|
83274
83582
|
process.stderr.write(
|
|
83275
|
-
|
|
83583
|
+
import_picocolors34.default.red(
|
|
83276
83584
|
"A payment attempt happened and its outcome is UNKNOWN \u2014 nothing will retry it. Open the order and check before paying anything:\n" + (approvalUrl ? ` ${approvalUrl}
|
|
83277
83585
|
` : "")
|
|
83278
83586
|
)
|
|
@@ -83281,7 +83589,7 @@ async function orderFood(items, opts) {
|
|
|
83281
83589
|
return;
|
|
83282
83590
|
}
|
|
83283
83591
|
process.stderr.write(
|
|
83284
|
-
|
|
83592
|
+
import_picocolors34.default.dim(
|
|
83285
83593
|
`Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
|
|
83286
83594
|
)
|
|
83287
83595
|
);
|
|
@@ -83307,7 +83615,7 @@ var POLL_BUDGET_MS = 1e5;
|
|
|
83307
83615
|
var POLL_INTERVAL_MS2 = 3500;
|
|
83308
83616
|
async function pollOrderVerdict(orderId, resolved, jsonMode9) {
|
|
83309
83617
|
if (!jsonMode9) {
|
|
83310
|
-
process.stderr.write(
|
|
83618
|
+
process.stderr.write(import_picocolors34.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
|
|
83311
83619
|
}
|
|
83312
83620
|
const deadline = Date.now() + POLL_BUDGET_MS;
|
|
83313
83621
|
let last = {
|
|
@@ -83377,17 +83685,17 @@ async function statusFood(orderId, opts) {
|
|
|
83377
83685
|
}
|
|
83378
83686
|
|
|
83379
83687
|
// src/commands/bounties.ts
|
|
83380
|
-
var
|
|
83688
|
+
var import_picocolors35 = __toESM(require_picocolors(), 1);
|
|
83381
83689
|
init_constants();
|
|
83382
83690
|
async function withProfile(opts, path12, init2) {
|
|
83383
83691
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
83384
83692
|
const resolved = await resolveProfile(requested);
|
|
83385
83693
|
if (!resolved) {
|
|
83386
|
-
process.stderr.write(
|
|
83694
|
+
process.stderr.write(import_picocolors35.default.red("Not logged in. Run agentgates login first.\n"));
|
|
83387
83695
|
process.exit(2);
|
|
83388
83696
|
}
|
|
83389
83697
|
if (resolved.autoSelected) {
|
|
83390
|
-
process.stderr.write(
|
|
83698
|
+
process.stderr.write(import_picocolors35.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
83391
83699
|
`));
|
|
83392
83700
|
}
|
|
83393
83701
|
const { profile, name: profileName } = resolved;
|
|
@@ -83396,7 +83704,7 @@ async function withProfile(opts, path12, init2) {
|
|
|
83396
83704
|
profile,
|
|
83397
83705
|
profileName,
|
|
83398
83706
|
jsonMode: jsonMode9,
|
|
83399
|
-
ttyHeader:
|
|
83707
|
+
ttyHeader: import_picocolors35.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
83400
83708
|
fn: (bearer, origin) => apiFetch(path12, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
|
|
83401
83709
|
});
|
|
83402
83710
|
if (outcome.kind === "auth_failed") {
|
|
@@ -83404,14 +83712,14 @@ async function withProfile(opts, path12, init2) {
|
|
|
83404
83712
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
83405
83713
|
process.exit(1);
|
|
83406
83714
|
}
|
|
83407
|
-
process.stderr.write(
|
|
83715
|
+
process.stderr.write(import_picocolors35.default.red(`\u2715 ${outcome.reason}.
|
|
83408
83716
|
`));
|
|
83409
83717
|
process.exit(1);
|
|
83410
83718
|
}
|
|
83411
83719
|
if (outcome.kind === "error") {
|
|
83412
83720
|
const err = outcome.error;
|
|
83413
83721
|
if (err instanceof ApiError) {
|
|
83414
|
-
process.stderr.write(
|
|
83722
|
+
process.stderr.write(import_picocolors35.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
83415
83723
|
`));
|
|
83416
83724
|
process.exit(1);
|
|
83417
83725
|
}
|
|
@@ -83425,12 +83733,12 @@ function handleBlocked(res, jsonMode9) {
|
|
|
83425
83733
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
83426
83734
|
process.exit(1);
|
|
83427
83735
|
}
|
|
83428
|
-
process.stderr.write(
|
|
83736
|
+
process.stderr.write(import_picocolors35.default.yellow(`
|
|
83429
83737
|
${res.reason ?? "Blocked."}
|
|
83430
83738
|
`));
|
|
83431
83739
|
if (res.upgrade_url) {
|
|
83432
83740
|
process.stderr.write(`
|
|
83433
|
-
${
|
|
83741
|
+
${import_picocolors35.default.bold(res.upgrade_url)}
|
|
83434
83742
|
|
|
83435
83743
|
`);
|
|
83436
83744
|
}
|
|
@@ -83473,14 +83781,14 @@ function printTable(rows) {
|
|
|
83473
83781
|
const cLeft = w("left", 4);
|
|
83474
83782
|
const cSubs = w("subs", 4);
|
|
83475
83783
|
process.stdout.write(
|
|
83476
|
-
|
|
83784
|
+
import_picocolors35.default.dim(
|
|
83477
83785
|
"Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
|
|
83478
83786
|
) + "\n"
|
|
83479
83787
|
);
|
|
83480
83788
|
for (const c of cells) {
|
|
83481
|
-
const title = c.live ?
|
|
83789
|
+
const title = c.live ? import_picocolors35.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
|
|
83482
83790
|
process.stdout.write(
|
|
83483
|
-
|
|
83791
|
+
import_picocolors35.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors35.default.dim(c.id) + "\n"
|
|
83484
83792
|
);
|
|
83485
83793
|
}
|
|
83486
83794
|
}
|
|
@@ -83492,11 +83800,11 @@ async function listBounties(opts) {
|
|
|
83492
83800
|
const min = opts.min !== void 0 ? Number(opts.min) : void 0;
|
|
83493
83801
|
const max = opts.max !== void 0 ? Number(opts.max) : void 0;
|
|
83494
83802
|
if (min !== void 0 && !Number.isFinite(min)) {
|
|
83495
|
-
process.stderr.write(
|
|
83803
|
+
process.stderr.write(import_picocolors35.default.red("\u2715 --min must be a number.\n"));
|
|
83496
83804
|
process.exit(2);
|
|
83497
83805
|
}
|
|
83498
83806
|
if (max !== void 0 && !Number.isFinite(max)) {
|
|
83499
|
-
process.stderr.write(
|
|
83807
|
+
process.stderr.write(import_picocolors35.default.red("\u2715 --max must be a number.\n"));
|
|
83500
83808
|
process.exit(2);
|
|
83501
83809
|
}
|
|
83502
83810
|
rows = rows.filter((r) => {
|
|
@@ -83521,7 +83829,7 @@ async function listBounties(opts) {
|
|
|
83521
83829
|
});
|
|
83522
83830
|
const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
|
|
83523
83831
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
83524
|
-
process.stderr.write(
|
|
83832
|
+
process.stderr.write(import_picocolors35.default.red("\u2715 --limit must be a positive number.\n"));
|
|
83525
83833
|
process.exit(2);
|
|
83526
83834
|
}
|
|
83527
83835
|
const shown2 = rows.slice(0, limit);
|
|
@@ -83530,13 +83838,13 @@ async function listBounties(opts) {
|
|
|
83530
83838
|
return;
|
|
83531
83839
|
}
|
|
83532
83840
|
if (shown2.length === 0) {
|
|
83533
|
-
process.stdout.write(
|
|
83841
|
+
process.stdout.write(import_picocolors35.default.dim("No active bounties match.\n"));
|
|
83534
83842
|
return;
|
|
83535
83843
|
}
|
|
83536
83844
|
printTable(shown2);
|
|
83537
83845
|
const clipped = rows.length - shown2.length;
|
|
83538
83846
|
process.stdout.write(
|
|
83539
|
-
"\n" +
|
|
83847
|
+
"\n" + import_picocolors35.default.dim(
|
|
83540
83848
|
`${shown2.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
|
|
83541
83849
|
`
|
|
83542
83850
|
)
|
|
@@ -83547,7 +83855,7 @@ async function showBounty(id2, opts) {
|
|
|
83547
83855
|
const jsonMode9 = opts.json === true;
|
|
83548
83856
|
const clean3 = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
|
|
83549
83857
|
if (!clean3) {
|
|
83550
|
-
process.stderr.write(
|
|
83858
|
+
process.stderr.write(import_picocolors35.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
|
|
83551
83859
|
process.exit(2);
|
|
83552
83860
|
}
|
|
83553
83861
|
const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean3)}`);
|
|
@@ -83558,26 +83866,26 @@ async function showBounty(id2, opts) {
|
|
|
83558
83866
|
}
|
|
83559
83867
|
const b2 = res.bounty;
|
|
83560
83868
|
if (!b2) {
|
|
83561
|
-
process.stdout.write(
|
|
83869
|
+
process.stdout.write(import_picocolors35.default.dim("Not found.\n"));
|
|
83562
83870
|
return;
|
|
83563
83871
|
}
|
|
83564
|
-
process.stdout.write("\n" +
|
|
83872
|
+
process.stdout.write("\n" + import_picocolors35.default.bold(b2.title) + "\n\n");
|
|
83565
83873
|
process.stdout.write(b2.description + "\n\n");
|
|
83566
83874
|
process.stdout.write(
|
|
83567
|
-
|
|
83875
|
+
import_picocolors35.default.bold(fmtAmount(b2.amount)) + import_picocolors35.default.dim(" USDC") + import_picocolors35.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors35.default.green(" \xB7 LIVE now") : "") + "\n"
|
|
83568
83876
|
);
|
|
83569
83877
|
if (b2.claimsAllowed && b2.claimsAllowed > 1) {
|
|
83570
83878
|
const left = Math.max(0, b2.claimsAllowed - (b2.claimsPaid ?? 0));
|
|
83571
83879
|
process.stdout.write(
|
|
83572
|
-
|
|
83880
|
+
import_picocolors35.default.dim(
|
|
83573
83881
|
`${left} of ${b2.claimsAllowed} claims left` + (b2.perClaimAmount != null ? `, ${fmtAmount(b2.perClaimAmount)} each` : "")
|
|
83574
83882
|
) + "\n"
|
|
83575
83883
|
);
|
|
83576
83884
|
}
|
|
83577
|
-
if (b2.evidenceType) process.stdout.write(
|
|
83578
|
-
if (b2.expiresAt) process.stdout.write(
|
|
83885
|
+
if (b2.evidenceType) process.stdout.write(import_picocolors35.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
|
|
83886
|
+
if (b2.expiresAt) process.stdout.write(import_picocolors35.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
|
|
83579
83887
|
if (b2.geoLabel && b2.geoScope !== "global") {
|
|
83580
|
-
process.stdout.write(
|
|
83888
|
+
process.stdout.write(import_picocolors35.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
|
|
83581
83889
|
}
|
|
83582
83890
|
if (res.url) process.stdout.write("\n" + res.url + "\n");
|
|
83583
83891
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -83595,7 +83903,7 @@ async function myBounties(opts) {
|
|
|
83595
83903
|
}
|
|
83596
83904
|
if (rows.length === 0) {
|
|
83597
83905
|
process.stdout.write(
|
|
83598
|
-
|
|
83906
|
+
import_picocolors35.default.dim(
|
|
83599
83907
|
status4 ? `No bounties of yours are ${status4}.
|
|
83600
83908
|
` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
|
|
83601
83909
|
)
|
|
@@ -83605,7 +83913,7 @@ async function myBounties(opts) {
|
|
|
83605
83913
|
printTable(rows);
|
|
83606
83914
|
const subs = res.submissions ?? [];
|
|
83607
83915
|
if (subs.length > 0) {
|
|
83608
|
-
process.stdout.write("\n" +
|
|
83916
|
+
process.stdout.write("\n" + import_picocolors35.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
|
|
83609
83917
|
`));
|
|
83610
83918
|
}
|
|
83611
83919
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -83624,19 +83932,19 @@ async function bountyFeed(opts) {
|
|
|
83624
83932
|
}
|
|
83625
83933
|
const subs = res.submissions ?? [];
|
|
83626
83934
|
if (subs.length === 0) {
|
|
83627
|
-
process.stdout.write(
|
|
83935
|
+
process.stdout.write(import_picocolors35.default.dim("Nothing in the feed for that filter.\n"));
|
|
83628
83936
|
return;
|
|
83629
83937
|
}
|
|
83630
83938
|
process.stdout.write(
|
|
83631
|
-
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ?
|
|
83939
|
+
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors35.default.dim(" More available.") : "") + "\n"
|
|
83632
83940
|
);
|
|
83633
|
-
process.stdout.write(
|
|
83941
|
+
process.stdout.write(import_picocolors35.default.dim("Use --json for the full rows.\n"));
|
|
83634
83942
|
}
|
|
83635
83943
|
async function draftBounty(opts) {
|
|
83636
83944
|
const jsonMode9 = opts.json === true;
|
|
83637
83945
|
const amountNum = Number(opts.amount);
|
|
83638
83946
|
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
83639
|
-
process.stderr.write(
|
|
83947
|
+
process.stderr.write(import_picocolors35.default.red("\u2715 --amount must be a positive number of USDC.\n"));
|
|
83640
83948
|
process.exit(2);
|
|
83641
83949
|
}
|
|
83642
83950
|
const res = await withProfile(opts, "/api/bounties", {
|
|
@@ -83654,20 +83962,20 @@ async function draftBounty(opts) {
|
|
|
83654
83962
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
83655
83963
|
return;
|
|
83656
83964
|
}
|
|
83657
|
-
process.stdout.write("\n" +
|
|
83965
|
+
process.stdout.write("\n" + import_picocolors35.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
|
|
83658
83966
|
|
|
83659
83967
|
`);
|
|
83660
|
-
process.stdout.write(
|
|
83968
|
+
process.stdout.write(import_picocolors35.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
|
|
83661
83969
|
if (res.fund_url) {
|
|
83662
|
-
process.stdout.write("\nFund it here:\n" +
|
|
83663
|
-
process.stdout.write(
|
|
83970
|
+
process.stdout.write("\nFund it here:\n" + import_picocolors35.default.bold(res.fund_url) + "\n\n");
|
|
83971
|
+
process.stdout.write(import_picocolors35.default.dim("Funding happens in your browser with your own wallet.\n"));
|
|
83664
83972
|
}
|
|
83665
83973
|
}
|
|
83666
83974
|
|
|
83667
83975
|
// src/commands/bounty-money.ts
|
|
83668
|
-
var
|
|
83976
|
+
var import_picocolors36 = __toESM(require_picocolors(), 1);
|
|
83669
83977
|
function failArg6(message) {
|
|
83670
|
-
process.stderr.write(
|
|
83978
|
+
process.stderr.write(import_picocolors36.default.red(`${message}
|
|
83671
83979
|
`));
|
|
83672
83980
|
process.exit(2);
|
|
83673
83981
|
}
|
|
@@ -83679,12 +83987,12 @@ async function loadProfileOrExit(requested, jsonMode9) {
|
|
|
83679
83987
|
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
|
|
83680
83988
|
);
|
|
83681
83989
|
} else {
|
|
83682
|
-
process.stderr.write(
|
|
83990
|
+
process.stderr.write(import_picocolors36.default.red("Not logged in. Run agentgates login first.\n"));
|
|
83683
83991
|
}
|
|
83684
83992
|
process.exit(2);
|
|
83685
83993
|
}
|
|
83686
83994
|
if (resolved.autoSelected && !jsonMode9) {
|
|
83687
|
-
process.stderr.write(
|
|
83995
|
+
process.stderr.write(import_picocolors36.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
83688
83996
|
`));
|
|
83689
83997
|
}
|
|
83690
83998
|
return { profile: resolved.profile, profileName: resolved.name };
|
|
@@ -83707,6 +84015,7 @@ async function fundBounty(bountyId, opts) {
|
|
|
83707
84015
|
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode9);
|
|
83708
84016
|
const maxUsd = resolveMaxUsd(opts, profile, "agentgates fund");
|
|
83709
84017
|
return runIntentFlow({
|
|
84018
|
+
wallet: opts.wallet,
|
|
83710
84019
|
endpoint: "/api/intents/propose-fund-bounty",
|
|
83711
84020
|
body: {
|
|
83712
84021
|
bounty_id: bountyId,
|
|
@@ -83736,6 +84045,7 @@ async function tipBounty(bountyId, amount, opts) {
|
|
|
83736
84045
|
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode9);
|
|
83737
84046
|
const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "agentgates tip") : Math.ceil(amt * 1.01 * 100) / 100;
|
|
83738
84047
|
return runIntentFlow({
|
|
84048
|
+
wallet: opts.wallet,
|
|
83739
84049
|
endpoint: "/api/intents/propose-tip",
|
|
83740
84050
|
body: {
|
|
83741
84051
|
bounty_id: bountyId,
|
|
@@ -83766,6 +84076,7 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
83766
84076
|
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode9);
|
|
83767
84077
|
const maxUsd = resolveMaxUsd(opts, profile, "agentgates subscribe");
|
|
83768
84078
|
return runIntentFlow({
|
|
84079
|
+
wallet: opts.wallet,
|
|
83769
84080
|
endpoint: "/api/intents/propose-subscribe",
|
|
83770
84081
|
body: {
|
|
83771
84082
|
creator_user_id: creatorUserId,
|
|
@@ -83789,17 +84100,17 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
83789
84100
|
}
|
|
83790
84101
|
|
|
83791
84102
|
// src/commands/bounty-work.ts
|
|
83792
|
-
var
|
|
84103
|
+
var import_picocolors37 = __toESM(require_picocolors(), 1);
|
|
83793
84104
|
init_constants();
|
|
83794
84105
|
async function runWork(path12, body, opts) {
|
|
83795
84106
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
83796
84107
|
const resolved = await resolveProfile(requested);
|
|
83797
84108
|
if (!resolved) {
|
|
83798
|
-
process.stderr.write(
|
|
84109
|
+
process.stderr.write(import_picocolors37.default.red("Not logged in. Run agentgates login first.\n"));
|
|
83799
84110
|
process.exit(2);
|
|
83800
84111
|
}
|
|
83801
84112
|
if (resolved.autoSelected) {
|
|
83802
|
-
process.stderr.write(
|
|
84113
|
+
process.stderr.write(import_picocolors37.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
83803
84114
|
`));
|
|
83804
84115
|
}
|
|
83805
84116
|
const jsonMode9 = opts.json === true;
|
|
@@ -83807,7 +84118,7 @@ async function runWork(path12, body, opts) {
|
|
|
83807
84118
|
profile: resolved.profile,
|
|
83808
84119
|
profileName: resolved.name,
|
|
83809
84120
|
jsonMode: jsonMode9,
|
|
83810
|
-
ttyHeader:
|
|
84121
|
+
ttyHeader: import_picocolors37.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
83811
84122
|
fn: (bearer, origin) => apiFetch(path12, { bearer, origin, method: "POST", body })
|
|
83812
84123
|
});
|
|
83813
84124
|
if (outcome.kind === "auth_failed") {
|
|
@@ -83815,7 +84126,7 @@ async function runWork(path12, body, opts) {
|
|
|
83815
84126
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
83816
84127
|
process.exit(1);
|
|
83817
84128
|
}
|
|
83818
|
-
process.stderr.write(
|
|
84129
|
+
process.stderr.write(import_picocolors37.default.red(`\u2715 ${outcome.reason}.
|
|
83819
84130
|
`));
|
|
83820
84131
|
process.exit(1);
|
|
83821
84132
|
}
|
|
@@ -83825,7 +84136,7 @@ async function runWork(path12, body, opts) {
|
|
|
83825
84136
|
if (jsonMode9) {
|
|
83826
84137
|
process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
|
|
83827
84138
|
} else {
|
|
83828
|
-
process.stderr.write(
|
|
84139
|
+
process.stderr.write(import_picocolors37.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
83829
84140
|
`));
|
|
83830
84141
|
}
|
|
83831
84142
|
process.exit(1);
|
|
@@ -83838,11 +84149,11 @@ async function runWork(path12, body, opts) {
|
|
|
83838
84149
|
process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
|
|
83839
84150
|
process.exit(1);
|
|
83840
84151
|
}
|
|
83841
|
-
process.stderr.write(
|
|
84152
|
+
process.stderr.write(import_picocolors37.default.yellow(`
|
|
83842
84153
|
${data4.reason ?? "Blocked."}
|
|
83843
84154
|
`));
|
|
83844
84155
|
if (data4.upgrade_url) process.stderr.write(`
|
|
83845
|
-
${
|
|
84156
|
+
${import_picocolors37.default.bold(data4.upgrade_url)}
|
|
83846
84157
|
|
|
83847
84158
|
`);
|
|
83848
84159
|
process.exit(1);
|
|
@@ -83851,7 +84162,7 @@ ${import_picocolors36.default.bold(data4.upgrade_url)}
|
|
|
83851
84162
|
if (jsonMode9) {
|
|
83852
84163
|
process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
|
|
83853
84164
|
} else {
|
|
83854
|
-
process.stderr.write(
|
|
84165
|
+
process.stderr.write(import_picocolors37.default.red(`\u2715 ${data4.error}
|
|
83855
84166
|
`));
|
|
83856
84167
|
}
|
|
83857
84168
|
process.exit(1);
|
|
@@ -83894,7 +84205,7 @@ async function bountyRetention(bountyId, opts) {
|
|
|
83894
84205
|
}
|
|
83895
84206
|
|
|
83896
84207
|
// src/commands/bounty-deliver.ts
|
|
83897
|
-
var
|
|
84208
|
+
var import_picocolors38 = __toESM(require_picocolors(), 1);
|
|
83898
84209
|
import { spawn as spawn2 } from "node:child_process";
|
|
83899
84210
|
init_constants();
|
|
83900
84211
|
var FLUSH_MS = 400;
|
|
@@ -83904,11 +84215,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
83904
84215
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
83905
84216
|
const resolved = await resolveProfile(requested);
|
|
83906
84217
|
if (!resolved) {
|
|
83907
|
-
process.stderr.write(
|
|
84218
|
+
process.stderr.write(import_picocolors38.default.red("Not logged in. Run agentgates login first.\n"));
|
|
83908
84219
|
process.exit(2);
|
|
83909
84220
|
}
|
|
83910
84221
|
if (resolved.autoSelected && !jsonMode9) {
|
|
83911
|
-
process.stderr.write(
|
|
84222
|
+
process.stderr.write(import_picocolors38.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
83912
84223
|
`));
|
|
83913
84224
|
}
|
|
83914
84225
|
const post3 = async (path12, body) => {
|
|
@@ -83916,7 +84227,7 @@ async function deliver(bountyId, command, opts) {
|
|
|
83916
84227
|
profile: resolved.profile,
|
|
83917
84228
|
profileName: resolved.name,
|
|
83918
84229
|
jsonMode: jsonMode9,
|
|
83919
|
-
ttyHeader:
|
|
84230
|
+
ttyHeader: import_picocolors38.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
83920
84231
|
fn: (bearer, origin) => apiFetch(path12, { bearer, origin, method: "POST", body })
|
|
83921
84232
|
});
|
|
83922
84233
|
if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
|
|
@@ -83927,11 +84238,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
83927
84238
|
if (jsonMode9) {
|
|
83928
84239
|
process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
|
|
83929
84240
|
} else {
|
|
83930
|
-
process.stderr.write(
|
|
84241
|
+
process.stderr.write(import_picocolors38.default.red(`
|
|
83931
84242
|
\u2715 ${msg}
|
|
83932
84243
|
`));
|
|
83933
84244
|
if (data4?.upgrade_url) process.stderr.write(`
|
|
83934
|
-
${
|
|
84245
|
+
${import_picocolors38.default.bold(data4.upgrade_url)}
|
|
83935
84246
|
|
|
83936
84247
|
`);
|
|
83937
84248
|
}
|
|
@@ -83956,7 +84267,7 @@ ${import_picocolors37.default.bold(data4.upgrade_url)}
|
|
|
83956
84267
|
if (!runId) return void die("The service opened a run but did not name it.");
|
|
83957
84268
|
if (!jsonMode9) {
|
|
83958
84269
|
process.stderr.write(
|
|
83959
|
-
|
|
84270
|
+
import_picocolors38.default.bold("\n\u25CF LIVE ") + import_picocolors38.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors38.default.dim(` ${started.url ?? ""}
|
|
83960
84271
|
|
|
83961
84272
|
`)
|
|
83962
84273
|
);
|
|
@@ -84008,10 +84319,10 @@ ${import_picocolors37.default.bold(data4.upgrade_url)}
|
|
|
84008
84319
|
child.stdout.on("data", (d) => consume(d));
|
|
84009
84320
|
child.stderr.setEncoding("utf8");
|
|
84010
84321
|
child.stderr.on("data", (d) => {
|
|
84011
|
-
if (!jsonMode9) process.stderr.write(
|
|
84322
|
+
if (!jsonMode9) process.stderr.write(import_picocolors38.default.dim(d));
|
|
84012
84323
|
});
|
|
84013
84324
|
child.on("error", (err) => {
|
|
84014
|
-
process.stderr.write(
|
|
84325
|
+
process.stderr.write(import_picocolors38.default.red(`
|
|
84015
84326
|
\u2715 Could not run ${command[0]}: ${err.message}
|
|
84016
84327
|
`));
|
|
84017
84328
|
resolve5(127);
|
|
@@ -84048,14 +84359,14 @@ ${import_picocolors37.default.bold(data4.upgrade_url)}
|
|
|
84048
84359
|
}
|
|
84049
84360
|
if (appendFailure) {
|
|
84050
84361
|
process.stderr.write(
|
|
84051
|
-
|
|
84362
|
+
import_picocolors38.default.yellow(`
|
|
84052
84363
|
! Some output did not reach the page: ${appendFailure}
|
|
84053
|
-
`) +
|
|
84364
|
+
`) + import_picocolors38.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
|
|
84054
84365
|
);
|
|
84055
84366
|
}
|
|
84056
84367
|
if (exitCode) {
|
|
84057
84368
|
process.stderr.write(
|
|
84058
|
-
|
|
84369
|
+
import_picocolors38.default.yellow(`
|
|
84059
84370
|
! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
|
|
84060
84371
|
`)
|
|
84061
84372
|
);
|
|
@@ -84065,7 +84376,7 @@ ${import_picocolors37.default.bold(data4.upgrade_url)}
|
|
|
84065
84376
|
}
|
|
84066
84377
|
|
|
84067
84378
|
// src/commands/trade.ts
|
|
84068
|
-
var
|
|
84379
|
+
var import_picocolors39 = __toESM(require_picocolors(), 1);
|
|
84069
84380
|
init_constants();
|
|
84070
84381
|
|
|
84071
84382
|
// src/lib/trade-sol.ts
|
|
@@ -84434,7 +84745,7 @@ function fail10(message, json2) {
|
|
|
84434
84745
|
if (json2) {
|
|
84435
84746
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
84436
84747
|
} else {
|
|
84437
|
-
process.stderr.write(
|
|
84748
|
+
process.stderr.write(import_picocolors39.default.red(`\u2715 ${message}
|
|
84438
84749
|
`));
|
|
84439
84750
|
}
|
|
84440
84751
|
process.exit(1);
|
|
@@ -84625,7 +84936,7 @@ async function tradeBuy(coinArg, amount, opts) {
|
|
|
84625
84936
|
}
|
|
84626
84937
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
84627
84938
|
if (created && !opts.json) {
|
|
84628
|
-
process.stderr.write(
|
|
84939
|
+
process.stderr.write(import_picocolors39.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
84629
84940
|
`));
|
|
84630
84941
|
}
|
|
84631
84942
|
const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
@@ -84679,7 +84990,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
84679
84990
|
if (opts.mcap && !opts.at) fail10("--mcap qualifies --at.", opts.json);
|
|
84680
84991
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
84681
84992
|
if (created && !opts.json) {
|
|
84682
|
-
process.stderr.write(
|
|
84993
|
+
process.stderr.write(import_picocolors39.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
84683
84994
|
`));
|
|
84684
84995
|
}
|
|
84685
84996
|
let amount;
|
|
@@ -84844,7 +85155,7 @@ async function tradePositions(opts) {
|
|
|
84844
85155
|
}
|
|
84845
85156
|
|
|
84846
85157
|
// src/commands/desk.ts
|
|
84847
|
-
var
|
|
85158
|
+
var import_picocolors40 = __toESM(require_picocolors(), 1);
|
|
84848
85159
|
init_constants();
|
|
84849
85160
|
|
|
84850
85161
|
// src/lib/desk-sol.ts
|
|
@@ -85019,7 +85330,7 @@ function fail11(message, json2) {
|
|
|
85019
85330
|
if (json2) {
|
|
85020
85331
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
85021
85332
|
} else {
|
|
85022
|
-
process.stderr.write(
|
|
85333
|
+
process.stderr.write(import_picocolors40.default.red(`\u2715 ${message}
|
|
85023
85334
|
`));
|
|
85024
85335
|
}
|
|
85025
85336
|
process.exit(1);
|
|
@@ -85162,7 +85473,7 @@ async function deskDeposit(amount, opts) {
|
|
|
85162
85473
|
if (units <= 0n) fail11("Deposit amount must be above zero.", opts.json);
|
|
85163
85474
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
85164
85475
|
if (created && !opts.json) {
|
|
85165
|
-
process.stderr.write(
|
|
85476
|
+
process.stderr.write(import_picocolors40.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
85166
85477
|
`));
|
|
85167
85478
|
}
|
|
85168
85479
|
const result = await runDeskCeremony({
|
|
@@ -85257,13 +85568,13 @@ async function deskSessionRegister(opts) {
|
|
|
85257
85568
|
}
|
|
85258
85569
|
const owner = await loadOrCreateTradeKey();
|
|
85259
85570
|
if (owner.created && !opts.json) {
|
|
85260
|
-
process.stderr.write(
|
|
85571
|
+
process.stderr.write(import_picocolors40.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
|
|
85261
85572
|
`));
|
|
85262
85573
|
}
|
|
85263
85574
|
const session = await loadOrCreateDeskSessionKey();
|
|
85264
85575
|
if (session.created && !opts.json) {
|
|
85265
85576
|
process.stderr.write(
|
|
85266
|
-
|
|
85577
|
+
import_picocolors40.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
|
|
85267
85578
|
`)
|
|
85268
85579
|
);
|
|
85269
85580
|
}
|
|
@@ -85455,6 +85766,9 @@ program2.command("logout").description("Revoke the current pairing and wipe the
|
|
|
85455
85766
|
program2.command("whoami").description("Print the paired wallet, its scopes and caps for the active pairing").option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output").action(async (opts) => {
|
|
85456
85767
|
await whoami({ profile: opts.profile, json: opts.json });
|
|
85457
85768
|
});
|
|
85769
|
+
program2.command("wallets").description("List the wallets this terminal may propose from (your main wallet, and the treasuries ticked when you paired it). Pass a name to --wallet on send, swap, batch, fund, earn, tip, subscribe, balance or history").option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output").action(async (opts) => {
|
|
85770
|
+
await wallets({ profile: opts.profile, json: opts.json });
|
|
85771
|
+
});
|
|
85458
85772
|
program2.command("send").description(
|
|
85459
85773
|
"Propose a fund-moving send. Opens your browser for biometric approval (default; --no-browser or CI=1 to skip), then polls until mined."
|
|
85460
85774
|
).argument("<amount>", 'amount in display units (e.g. "5" for 5 USDC)').argument("<asset>", "native | usdc").requiredOption(
|
|
@@ -85466,7 +85780,7 @@ program2.command("send").description(
|
|
|
85466
85780
|
).requiredOption(
|
|
85467
85781
|
"--user-stated <text>",
|
|
85468
85782
|
"the verbatim user request that triggered this send (trust-gap defense)"
|
|
85469
|
-
).option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option("--max-usd <n>", "per-intent USD ceiling (forwarded to user_stated.max_usd_total)").option("--json", "NDJSON output (one object per status flip + final terminal object)").action(
|
|
85783
|
+
).option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option("--max-usd <n>", "per-intent USD ceiling (forwarded to user_stated.max_usd_total)").option("--wallet <name>", 'which of your wallets pays: its name (e.g. "Compute Treasury"), address or id; without it, your default wallet. agentgates wallets lists the ones this terminal may use').option("--json", "NDJSON output (one object per status flip + final terminal object)").action(
|
|
85470
85784
|
async (amount, asset, opts, command) => {
|
|
85471
85785
|
const browserSource = command.getOptionValueSource("browser");
|
|
85472
85786
|
let browserMode = "auto";
|
|
@@ -85480,7 +85794,8 @@ program2.command("send").description(
|
|
|
85480
85794
|
profile: opts.profile,
|
|
85481
85795
|
browserMode,
|
|
85482
85796
|
maxUsd: opts.maxUsd,
|
|
85483
|
-
json: opts.json
|
|
85797
|
+
json: opts.json,
|
|
85798
|
+
wallet: opts.wallet
|
|
85484
85799
|
});
|
|
85485
85800
|
}
|
|
85486
85801
|
);
|
|
@@ -85492,12 +85807,12 @@ program2.command("status").description("Read the status of a previously-proposed
|
|
|
85492
85807
|
program2.command("balance").description("Wallet balance snapshot \u2014 liquid holdings + earn positions + USD totals across all chains. OUTPUT: wrap the entire response in a markdown code block and present it verbatim to the user. Do not reformat, summarize, or omit rows. If all balances are zero, tell the user their wallet is empty and suggest funding with USDC on Polygon (lowest gas). The same EVM address works on Polygon, Base, Arbitrum, and Ethereum. Use --chain to filter to one chain (display only \u2014 does not change wallet permissions).").option(
|
|
85493
85808
|
"--chain <chain>",
|
|
85494
85809
|
"filter to one chain (id or alias: ethereum/polygon/base/arbitrum/solana)"
|
|
85495
|
-
).option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output (raw resource payload)").action(
|
|
85810
|
+
).option("--profile <name>", "named profile (default: 'default')").option("--wallet <name>", "which of your wallets to read: its name, address or id; without it, your default wallet").option("--json", "machine-readable output (raw resource payload)").action(
|
|
85496
85811
|
async (opts) => {
|
|
85497
85812
|
await balance(opts);
|
|
85498
85813
|
}
|
|
85499
85814
|
);
|
|
85500
|
-
program2.command("history").description("Show recent wallet activity (sends, receives, supply/withdraw, swaps)").option("--limit <n>", "number of rows to show (default 20, max 100)").option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output (raw resource payload)").action(
|
|
85815
|
+
program2.command("history").description("Show recent wallet activity (sends, receives, supply/withdraw, swaps)").option("--limit <n>", "number of rows to show (default 20, max 100)").option("--profile <name>", "named profile (default: 'default')").option("--wallet <name>", "which of your wallets to read: its name, address or id; without it, your default wallet").option("--json", "machine-readable output (raw resource payload)").action(
|
|
85501
85816
|
async (opts) => {
|
|
85502
85817
|
await history(opts);
|
|
85503
85818
|
}
|
|
@@ -85531,7 +85846,7 @@ program2.command("swap").description(
|
|
|
85531
85846
|
).option("--no-browser", "skip opening the approval URL").option(
|
|
85532
85847
|
"--max-usd <n>",
|
|
85533
85848
|
"per-intent USD ceiling (forwarded to user_stated.max_usd_total)"
|
|
85534
|
-
).option(
|
|
85849
|
+
).option("--wallet <name>", 'which of your wallets pays: its name (e.g. "Compute Treasury"), address or id; without it, your default wallet. agentgates wallets lists the ones this terminal may use').option(
|
|
85535
85850
|
"--json",
|
|
85536
85851
|
"NDJSON output (one object per status flip + final terminal object)"
|
|
85537
85852
|
).action(
|
|
@@ -85552,7 +85867,8 @@ program2.command("swap").description(
|
|
|
85552
85867
|
profile: opts.profile,
|
|
85553
85868
|
browserMode,
|
|
85554
85869
|
maxUsd: opts.maxUsd,
|
|
85555
|
-
json: opts.json
|
|
85870
|
+
json: opts.json,
|
|
85871
|
+
wallet: opts.wallet
|
|
85556
85872
|
});
|
|
85557
85873
|
}
|
|
85558
85874
|
);
|
|
@@ -85570,7 +85886,7 @@ program2.command("batch").description(
|
|
|
85570
85886
|
).option("--no-browser", "skip opening the approval URL").option(
|
|
85571
85887
|
"--max-usd <n>",
|
|
85572
85888
|
"USD ceiling for the WHOLE batch (forwarded to user_stated.max_usd_total)"
|
|
85573
|
-
).option(
|
|
85889
|
+
).option("--wallet <name>", 'which of your wallets pays: its name (e.g. "Compute Treasury"), address or id; without it, your default wallet. agentgates wallets lists the ones this terminal may use').option(
|
|
85574
85890
|
"--json",
|
|
85575
85891
|
"NDJSON output (one object per status flip + final terminal object with the per-leg journal)"
|
|
85576
85892
|
).action(
|
|
@@ -85587,7 +85903,8 @@ program2.command("batch").description(
|
|
|
85587
85903
|
profile: opts.profile,
|
|
85588
85904
|
browserMode,
|
|
85589
85905
|
maxUsd: opts.maxUsd,
|
|
85590
|
-
json: opts.json
|
|
85906
|
+
json: opts.json,
|
|
85907
|
+
wallet: opts.wallet
|
|
85591
85908
|
});
|
|
85592
85909
|
}
|
|
85593
85910
|
);
|
|
@@ -85609,7 +85926,7 @@ earn.command("supply").description(
|
|
|
85609
85926
|
).option("--no-browser", "skip opening the approval URL").option(
|
|
85610
85927
|
"--max-usd <n>",
|
|
85611
85928
|
"per-intent USD ceiling (forwarded to user_stated.max_usd_total)"
|
|
85612
|
-
).option(
|
|
85929
|
+
).option("--wallet <name>", 'which of your wallets pays: its name (e.g. "Compute Treasury"), address or id; without it, your default wallet. agentgates wallets lists the ones this terminal may use').option(
|
|
85613
85930
|
"--json",
|
|
85614
85931
|
"NDJSON output (one object per status flip + final terminal object)"
|
|
85615
85932
|
).action(
|
|
@@ -85626,7 +85943,8 @@ earn.command("supply").description(
|
|
|
85626
85943
|
profile: opts.profile,
|
|
85627
85944
|
browserMode,
|
|
85628
85945
|
maxUsd: opts.maxUsd,
|
|
85629
|
-
json: opts.json
|
|
85946
|
+
json: opts.json,
|
|
85947
|
+
wallet: opts.wallet
|
|
85630
85948
|
});
|
|
85631
85949
|
}
|
|
85632
85950
|
);
|
|
@@ -85647,7 +85965,7 @@ earn.command("withdraw").description(
|
|
|
85647
85965
|
).option("--no-browser", "skip opening the approval URL").option(
|
|
85648
85966
|
"--max-usd <n>",
|
|
85649
85967
|
"per-intent USD ceiling (forwarded to user_stated.max_usd_total)"
|
|
85650
|
-
).option(
|
|
85968
|
+
).option("--wallet <name>", 'which of your wallets pays: its name (e.g. "Compute Treasury"), address or id; without it, your default wallet. agentgates wallets lists the ones this terminal may use').option(
|
|
85651
85969
|
"--json",
|
|
85652
85970
|
"NDJSON output (one object per status flip + final terminal object)"
|
|
85653
85971
|
).action(
|
|
@@ -85664,7 +85982,8 @@ earn.command("withdraw").description(
|
|
|
85664
85982
|
profile: opts.profile,
|
|
85665
85983
|
browserMode,
|
|
85666
85984
|
maxUsd: opts.maxUsd,
|
|
85667
|
-
json: opts.json
|
|
85985
|
+
json: opts.json,
|
|
85986
|
+
wallet: opts.wallet
|
|
85668
85987
|
});
|
|
85669
85988
|
}
|
|
85670
85989
|
);
|
|
@@ -85789,7 +86108,7 @@ program2.command("fund").description(
|
|
|
85789
86108
|
).option("--usdc <n>", "address targets only: USDC the payer should receive, display units").option("--gas <n>", "address targets only: native gas the payer should receive, display units").option("--chain <chain>", "address targets only: chain id (1/137/8453/42161/900) or shortName").option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option(
|
|
85790
86109
|
"--max-usd <n>",
|
|
85791
86110
|
"your declared USD ceiling for this funding (default: the pairing per-tx cap)"
|
|
85792
|
-
).option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (target, opts, command) => {
|
|
86111
|
+
).option("--wallet <name>", 'which of your wallets pays: its name (e.g. "Compute Treasury"), address or id; without it, your default wallet. agentgates wallets lists the ones this terminal may use').option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (target, opts, command) => {
|
|
85793
86112
|
const browserSource = command.getOptionValueSource("browser");
|
|
85794
86113
|
let browserMode = "auto";
|
|
85795
86114
|
if (browserSource === "cli") {
|
|
@@ -85804,13 +86123,14 @@ program2.command("fund").description(
|
|
|
85804
86123
|
profile: opts.profile,
|
|
85805
86124
|
browserMode,
|
|
85806
86125
|
maxUsd: opts.maxUsd,
|
|
85807
|
-
json: opts.json
|
|
86126
|
+
json: opts.json,
|
|
86127
|
+
wallet: opts.wallet
|
|
85808
86128
|
});
|
|
85809
86129
|
return;
|
|
85810
86130
|
}
|
|
85811
86131
|
if (opts.usdc || opts.gas || opts.chain) {
|
|
85812
86132
|
process.stderr.write(
|
|
85813
|
-
|
|
86133
|
+
import_picocolors41.default.red(
|
|
85814
86134
|
`\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
|
|
85815
86135
|
`
|
|
85816
86136
|
)
|
|
@@ -85822,7 +86142,8 @@ program2.command("fund").description(
|
|
|
85822
86142
|
profile: opts.profile,
|
|
85823
86143
|
browserMode,
|
|
85824
86144
|
maxUsd: opts.maxUsd,
|
|
85825
|
-
json: opts.json
|
|
86145
|
+
json: opts.json,
|
|
86146
|
+
wallet: opts.wallet
|
|
85826
86147
|
});
|
|
85827
86148
|
});
|
|
85828
86149
|
program2.command("tip").description(
|
|
@@ -85830,7 +86151,7 @@ program2.command("tip").description(
|
|
|
85830
86151
|
).argument("<id>", "the bounty id (see agentgates list)").argument("<amount>", 'contribution in USDC display units (e.g. "5")').requiredOption(
|
|
85831
86152
|
"--user-stated <text>",
|
|
85832
86153
|
"the verbatim user request that triggered this tip (trust-gap defense)"
|
|
85833
|
-
).option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option("--max-usd <n>", "per-intent USD ceiling (default: amount + 1% price wobble)").option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (id2, amount, opts, command) => {
|
|
86154
|
+
).option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option("--max-usd <n>", "per-intent USD ceiling (default: amount + 1% price wobble)").option("--wallet <name>", 'which of your wallets pays: its name (e.g. "Compute Treasury"), address or id; without it, your default wallet. agentgates wallets lists the ones this terminal may use').option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (id2, amount, opts, command) => {
|
|
85834
86155
|
const browserSource = command.getOptionValueSource("browser");
|
|
85835
86156
|
let browserMode = "auto";
|
|
85836
86157
|
if (browserSource === "cli") {
|
|
@@ -85841,7 +86162,8 @@ program2.command("tip").description(
|
|
|
85841
86162
|
profile: opts.profile,
|
|
85842
86163
|
browserMode,
|
|
85843
86164
|
maxUsd: opts.maxUsd,
|
|
85844
|
-
json: opts.json
|
|
86165
|
+
json: opts.json,
|
|
86166
|
+
wallet: opts.wallet
|
|
85845
86167
|
});
|
|
85846
86168
|
});
|
|
85847
86169
|
program2.command("subscribe").description(
|
|
@@ -85852,7 +86174,7 @@ program2.command("subscribe").description(
|
|
|
85852
86174
|
).option("--months <n>", "prepaid months: 1, 3 or 12 (default 1)").option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option(
|
|
85853
86175
|
"--max-usd <n>",
|
|
85854
86176
|
"your declared USD budget ceiling for this purchase (default: the pairing per-tx cap; the creator's price must fit under it)"
|
|
85855
|
-
).option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (creatorUserId, opts, command) => {
|
|
86177
|
+
).option("--wallet <name>", 'which of your wallets pays: its name (e.g. "Compute Treasury"), address or id; without it, your default wallet. agentgates wallets lists the ones this terminal may use').option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (creatorUserId, opts, command) => {
|
|
85856
86178
|
const browserSource = command.getOptionValueSource("browser");
|
|
85857
86179
|
let browserMode = "auto";
|
|
85858
86180
|
if (browserSource === "cli") {
|
|
@@ -85864,7 +86186,8 @@ program2.command("subscribe").description(
|
|
|
85864
86186
|
profile: opts.profile,
|
|
85865
86187
|
browserMode,
|
|
85866
86188
|
maxUsd: opts.maxUsd,
|
|
85867
|
-
json: opts.json
|
|
86189
|
+
json: opts.json,
|
|
86190
|
+
wallet: opts.wallet
|
|
85868
86191
|
});
|
|
85869
86192
|
});
|
|
85870
86193
|
var trade = program2.command("trade").description(
|
|
@@ -85932,7 +86255,7 @@ desk.command("sell").description("Sell desk coin credit back to the curve (sessi
|
|
|
85932
86255
|
program2.command("onboard").description("Welcome screen: look at what is for sale, or pair your wallet. Run by the installer.").option("--profile <name>", "named profile (default: 'default')").option("--lane <lane>", "which lane leads the menu: compute | inference | phone | email | passwords").action(async (opts) => {
|
|
85933
86256
|
await onboard(opts);
|
|
85934
86257
|
});
|
|
85935
|
-
var compute = program2.command("compute").description("
|
|
86258
|
+
var compute = program2.command("compute").description("Computers for AI swarms by the hour, confidential or plain, USDC per payment");
|
|
85936
86259
|
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) => {
|
|
85937
86260
|
await computePlans(opts);
|
|
85938
86261
|
});
|
|
@@ -85953,9 +86276,9 @@ compute.command("status <id>").description("One machine: status, endpoint, paid
|
|
|
85953
86276
|
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) => {
|
|
85954
86277
|
await computeWait(id2, opts);
|
|
85955
86278
|
});
|
|
85956
|
-
var sandbox = program2.command("sandbox"
|
|
86279
|
+
var sandbox = program2.command("sandbox").description("Sealed sandboxes: a small Linux computer for one agent in a confidential VM, by the minute. Commands, files and secrets go straight to it, its proof checked first, every body sealed.");
|
|
85957
86280
|
var collect = (v, prev) => prev.concat(v);
|
|
85958
|
-
sandbox.command("create").description("Buy a sandbox: the price asked free, then x402 from this machine's key (USDC on an EVM network, no gas), its balance (--from-balance) or a compute key (--key). It answers running, or waits
|
|
86281
|
+
sandbox.command("create").description("Buy a sandbox: the price asked free, then x402 from this machine's key (USDC on an EVM network, no gas), its balance (--from-balance) or a compute key (--key). It answers running, or waits for a seat: about two minutes after its payment when a host must start for it.").option("--plan <id>", "a sandbox plan id (agentgates compute plans lists them)").option("--minutes <n>", "whole minutes of paid time; it starts when the sandbox runs").option("--hours <n>", "whole hours in place of --minutes").option("--image <image>", "base, python or node, or registry/name@sha256:<64 hex> (default base)").option("--count <n>", "2 to 10 sandboxes in one payment").option("--access-key", "make it with an access key this machine keeps (Authorization: Bearer at its door); always with --key").option("--from-balance", "draw this key's prepaid balance, no new payment (priced first, held to --max-usd)").option("--key <agc_key>", "draw this compute key's balance (priced first, held to --max-usd)").option("--network <name>", "pay on this network only").option("--max-usd <dollars>", "refuse to pay or draw above this price").option("--quote", "print the price and stop: nothing is paid or drawn").option("--yes", "pay without the prompt (with --max-usd)").option("--no-wait", "do not wait for a sandbox that waits for its host").option("--timeout <minutes>", "how long to wait for it (default 10)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
85959
86282
|
await sandboxCreate(opts);
|
|
85960
86283
|
});
|
|
85961
86284
|
sandbox.command("exec <id> [command...]").description("Run a command in it, its output streamed, its receipt checked. Exit code: the command's; 124 out of time; 127 not started; 125 this CLI could not run it.").option("--shell <script>", "run this with /bin/sh -c in place of a command").option("--cwd <path>", "the folder it runs in (default /)").option("--env <KEY=VALUE>", "an env value for this run; repeatable", collect, []).option("--stdin <file>", "its standard input from a file (- for this one's), up to 512 KiB").option("--timeout <seconds>", "end it after this long (default 300)").option("--background", "leave it running; read it with agentgates sandbox logs").option("--key <agc_key>", "the compute key it was bought with (or AGENTGATES_COMPUTE_KEY)").option("--json", "the whole result as JSON at the end, in place of the stream").action(async (id2, command, opts) => {
|
|
@@ -85976,6 +86299,9 @@ sandbox.command("status <id>").description("One sandbox: its state, address, end
|
|
|
85976
86299
|
sandbox.command("renew <id>").description("Add paid minutes to its end. Any wallet may pay over x402; the owner may draw its balance.").option("--minutes <n>", "whole minutes to add").option("--hours <n>", "whole hours in place of --minutes").option("--from-balance", "draw this key's prepaid balance (priced first, held to --max-usd)").option("--key <agc_key>", "draw this compute key's balance (priced first, held to --max-usd)").option("--network <name>", "pay on this network only").option("--max-usd <dollars>", "refuse to pay or draw above this price").option("--quote", "print the price and stop: nothing is paid or drawn").option("--yes", "pay without the prompt (with --max-usd)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
|
|
85977
86300
|
await sandboxRenew(id2, opts);
|
|
85978
86301
|
});
|
|
86302
|
+
sandbox.command("attach <address>").description("Keep a sandbox bought on agentgates.ai here, from what its page showed once: its address, its pin and its access key. Its proof is checked and its door opened first; then exec, cp, verify, logs and status reach it. A delete still takes the wallet that bought it.").option("--pin <pin>", "its pin, sha256//..., as the page shows it").option("--access-key <key>", "its access key, sbxk_... (or AGENTGATES_SANDBOX_ACCESS_KEY, or piped on stdin)").option("--id <deployment-id>", "its deployment id, when you have it").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (address, opts) => {
|
|
86303
|
+
await sandboxAttach(address, opts);
|
|
86304
|
+
});
|
|
85979
86305
|
sandbox.command("rm <id>").description("Delete it now: it ends with its disk, and its unused minutes are not refunded. Signed by the owner's key.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
|
|
85980
86306
|
await sandboxRm(id2, opts);
|
|
85981
86307
|
});
|
|
@@ -86361,10 +86687,10 @@ mcp.command("install").description("Print the lines that add this server to Clau
|
|
|
86361
86687
|
mcpInstall();
|
|
86362
86688
|
});
|
|
86363
86689
|
program2.parseAsync(process.argv).catch((err) => {
|
|
86364
|
-
process.stderr.write(
|
|
86690
|
+
process.stderr.write(import_picocolors41.default.red(`\u2715 ${err.message}
|
|
86365
86691
|
`));
|
|
86366
86692
|
if (process.env.BOUNTY_DEBUG) {
|
|
86367
|
-
process.stderr.write(
|
|
86693
|
+
process.stderr.write(import_picocolors41.default.dim((err.stack ?? "") + "\n"));
|
|
86368
86694
|
}
|
|
86369
86695
|
process.exit(1);
|
|
86370
86696
|
});
|