@agentgates/cli 0.89.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/dist/cli.mjs +117 -6
- 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
|
}
|
|
@@ -75142,9 +75142,63 @@ async function findSandbox(id2, opts = {}) {
|
|
|
75142
75142
|
else if (wallet) doorAuth = { kind: "wallet", signer: walletSigner(wallet) };
|
|
75143
75143
|
else throw new SandboxError("no key on this machine opens that sandbox's door", "no_account");
|
|
75144
75144
|
const owner = rec?.owner ?? (machine && readAuth && "wallet" in readAuth && wallet ? wallet.address : null);
|
|
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" : "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";
|
|
75146
75146
|
return { deploymentId, sandboxId, api: api2, tlsPin, owner, ownerUnchecked, auth: doorAuth, record, machine };
|
|
75147
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
|
+
}
|
|
75148
75202
|
function receiptStateOf(found) {
|
|
75149
75203
|
const rec = found.record;
|
|
75150
75204
|
return {
|
|
@@ -75190,6 +75244,7 @@ async function renewSandbox(args) {
|
|
|
75190
75244
|
}
|
|
75191
75245
|
async function deleteSandbox(id2) {
|
|
75192
75246
|
const rec = await findRecord(id2);
|
|
75247
|
+
if (rec?.paidWith === "attached") throw new SandboxError(ATTACHED_DELETE_WORDS, "needs_owner");
|
|
75193
75248
|
let depId = rec?.deploymentId ?? id2;
|
|
75194
75249
|
const wallet = await payingWallet();
|
|
75195
75250
|
if (SANDBOX_ID_RE.test(depId)) {
|
|
@@ -76016,6 +76071,44 @@ async function sandboxLs(opts) {
|
|
|
76016
76071
|
for (const e of list.errors) sayErr2(` ${import_picocolors13.default.yellow("!")} ${e}
|
|
76017
76072
|
`);
|
|
76018
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
|
+
}
|
|
76019
76112
|
async function sandboxStatus(id2, opts) {
|
|
76020
76113
|
let found;
|
|
76021
76114
|
try {
|
|
@@ -76039,13 +76132,21 @@ async function sandboxStatus(id2, opts) {
|
|
|
76039
76132
|
doorError = err.message;
|
|
76040
76133
|
}
|
|
76041
76134
|
if (jsonMode7(opts)) {
|
|
76042
|
-
|
|
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");
|
|
76043
76137
|
return;
|
|
76044
76138
|
}
|
|
76045
76139
|
const m = found.machine;
|
|
76046
76140
|
say3(`
|
|
76047
76141
|
${sandboxLines({ deploymentId: found.deploymentId, status: m?.status ?? "running", plan: m?.plan ?? found.record?.plan, expiresAt: m?.expiresAt }, { id: found.sandboxId, api: found.api })}
|
|
76048
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
|
+
}
|
|
76049
76150
|
if (doorView) {
|
|
76050
76151
|
say3(` proof ${import_picocolors13.default.green("checked")} ${import_picocolors13.default.dim("(4 checks, your own nonce; agentgates sandbox verify shows each)")}
|
|
76051
76152
|
`);
|
|
@@ -78122,7 +78223,9 @@ var MCP_PAID_BUDGET_MS = 45e3;
|
|
|
78122
78223
|
async function sandboxListing(env = process.env, fetchImpl = fetch) {
|
|
78123
78224
|
if (env.AGENTGATES_SANDBOX_TOOLS === "1") return true;
|
|
78124
78225
|
try {
|
|
78125
|
-
|
|
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;
|
|
78126
78229
|
} catch {
|
|
78127
78230
|
return null;
|
|
78128
78231
|
}
|
|
@@ -78170,11 +78273,16 @@ function payOf(args) {
|
|
|
78170
78273
|
return { mode: pay, key: null };
|
|
78171
78274
|
}
|
|
78172
78275
|
var ID_PROP = { id: { type: "string", description: "The sandbox's deployment id (or its sbx_ id), from sandbox_create or sandbox_list." } };
|
|
78173
|
-
|
|
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) {
|
|
78174
78282
|
return [
|
|
78175
78283
|
{
|
|
78176
78284
|
name: "sandbox_create",
|
|
78177
|
-
description:
|
|
78285
|
+
description: sandboxCreateWords(wait2),
|
|
78178
78286
|
inputSchema: {
|
|
78179
78287
|
type: "object",
|
|
78180
78288
|
properties: {
|
|
@@ -86191,6 +86299,9 @@ sandbox.command("status <id>").description("One sandbox: its state, address, end
|
|
|
86191
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) => {
|
|
86192
86300
|
await sandboxRenew(id2, opts);
|
|
86193
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
|
+
});
|
|
86194
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) => {
|
|
86195
86306
|
await sandboxRm(id2, opts);
|
|
86196
86307
|
});
|