@agentgates/cli 0.65.1 → 0.72.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 +8 -0
- package/dist/cli.mjs +1070 -425
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -3128,7 +3128,7 @@ var init_constants = __esm({
|
|
|
3128
3128
|
trim = (v) => v ? v.replace(/\/$/, "") : "";
|
|
3129
3129
|
CLI_API_ORIGIN = trim(process.env.BOUNTY_API_ORIGIN) || "https://cli.agentgates.ai";
|
|
3130
3130
|
CREATORS_ORIGIN = trim(process.env.BOUNTY_CREATORS_ORIGIN) || "https://agentgates.ai";
|
|
3131
|
-
CLI_VERSION = "0.
|
|
3131
|
+
CLI_VERSION = "0.72.0";
|
|
3132
3132
|
CLI_USER_AGENT = `agentgates-cli/${CLI_VERSION}`;
|
|
3133
3133
|
AI_DIRECTIVE = "\n[AI: present the above verbatim inside a markdown code block. Do not reformat, summarize, or omit rows.]";
|
|
3134
3134
|
}
|
|
@@ -32211,7 +32211,7 @@ function eventDigestV2(entry, payload) {
|
|
|
32211
32211
|
const json2 = `{"name":${JSON.stringify(entry.event)},"payload":"${payload.toString("hex")}","type":${entry.event_type >>> 0}}`;
|
|
32212
32212
|
return createHash3("sha384").update(json2, "utf8").digest("hex");
|
|
32213
32213
|
}
|
|
32214
|
-
function
|
|
32214
|
+
function replayLog(eventLogRaw, quoteRtmr3) {
|
|
32215
32215
|
if (typeof eventLogRaw !== "string" || !eventLogRaw) return { ok: false, reason: "the attestation carried no event log, so the box identity cannot be read" };
|
|
32216
32216
|
let entries;
|
|
32217
32217
|
try {
|
|
@@ -32245,28 +32245,47 @@ function quotedAppId(eventLogRaw, quoteRtmr3) {
|
|
|
32245
32245
|
if (provedByRecompute) replayed = target;
|
|
32246
32246
|
}
|
|
32247
32247
|
if (!replayed || replayed !== target) return { ok: false, reason: "the attestation event log does not replay to the quoted RTMR3" };
|
|
32248
|
-
|
|
32249
|
-
|
|
32250
|
-
|
|
32251
|
-
|
|
32252
|
-
if (!
|
|
32253
|
-
|
|
32254
|
-
|
|
32255
|
-
|
|
32248
|
+
return { ok: true, value: { imr3, provedByRecompute } };
|
|
32249
|
+
}
|
|
32250
|
+
function eventPayload(log, name) {
|
|
32251
|
+
const entry = log.imr3.find((e) => e.event === name);
|
|
32252
|
+
if (!entry) return { ok: true, value: null };
|
|
32253
|
+
const payload = hexToBuffer(entry.event_payload);
|
|
32254
|
+
if (!payload || payload.length === 0) return { ok: false, reason: `the attestation ${name} event has no payload` };
|
|
32255
|
+
if (!log.provedByRecompute) {
|
|
32256
|
+
const served = entry.digest.toLowerCase().replace(/^0x/, "");
|
|
32257
|
+
if (eventDigestV1(entry, payload) !== served && eventDigestV2(entry, payload) !== served) {
|
|
32258
|
+
return { ok: false, reason: `the attestation ${name} event does not match its own digest` };
|
|
32256
32259
|
}
|
|
32257
32260
|
}
|
|
32258
32261
|
return { ok: true, value: payload.toString("hex") };
|
|
32259
32262
|
}
|
|
32263
|
+
function quotedEvents(eventLogRaw, quoteRtmr3) {
|
|
32264
|
+
const log = replayLog(eventLogRaw, quoteRtmr3);
|
|
32265
|
+
if (!log.ok) return log;
|
|
32266
|
+
const appId = eventPayload(log.value, "app-id");
|
|
32267
|
+
if (!appId.ok) return appId;
|
|
32268
|
+
if (appId.value === null) return { ok: false, reason: "the attestation event log names no app id" };
|
|
32269
|
+
const composeHash = eventPayload(log.value, "compose-hash");
|
|
32270
|
+
if (!composeHash.ok) return composeHash;
|
|
32271
|
+
return { ok: true, value: { appId: appId.value, composeHash: composeHash.value } };
|
|
32272
|
+
}
|
|
32260
32273
|
function verifyBoxQuote(input) {
|
|
32261
32274
|
if (typeof input.quote !== "string" || !input.quote) return { ok: false, reason: "the box published no attestation quote" };
|
|
32262
32275
|
const pin = input.pinnedAppId.toLowerCase().replace(/^0x/, "");
|
|
32263
32276
|
if (!/^[0-9a-f]{2,128}$/.test(pin)) return { ok: false, reason: "the pinned box app id is not hex" };
|
|
32264
32277
|
const quote = verifyTdxQuote(input.quote, input.expectedReportData, input.now);
|
|
32265
32278
|
if (!quote.ok) return quote;
|
|
32266
|
-
const
|
|
32267
|
-
if (!
|
|
32268
|
-
if (
|
|
32269
|
-
|
|
32279
|
+
const events = quotedEvents(input.eventLog, quote.value.rtmr3);
|
|
32280
|
+
if (!events.ok) return events;
|
|
32281
|
+
if (events.value.appId !== pin) return { ok: false, reason: "that attestation is another box's: its app id is not the one this CLI pins" };
|
|
32282
|
+
const composeHash = events.value.composeHash;
|
|
32283
|
+
if (input.approvedComposeHashes) {
|
|
32284
|
+
if (!composeHash) return { ok: false, reason: "the attestation names no compose hash, so the code the box runs is unknown" };
|
|
32285
|
+
const approved = input.approvedComposeHashes.map((h) => h.toLowerCase().replace(/^0x/, ""));
|
|
32286
|
+
if (!approved.includes(composeHash)) return { ok: false, reason: `the box runs code that is not approved (compose ${composeHash.slice(0, 12)}), so nothing is sealed to it` };
|
|
32287
|
+
}
|
|
32288
|
+
return { ok: true, value: { appId: events.value.appId, mrtd: quote.value.mrtd, composeHash } };
|
|
32270
32289
|
}
|
|
32271
32290
|
var INTEL_SGX_ROOT_CA_KEY, NO_CHAIN_REASON, TEE_TYPE_TDX, HEADER_BYTES, TD_REPORT_V10_BYTES, TD_REPORT_V15_BYTES, REPORT_DATA_OFFSET_IN_BODY, REPORT_DATA_BYTES, SGX_REPORT_BYTES, QE_REPORT_DATA_OFFSET, ECDSA_SIG_BYTES, ECDSA_PUBKEY_BYTES, CERT_TYPE_PCK_CHAIN, CERT_TYPE_QE_REPORT, DSTACK_RUNTIME_EVENT_TYPE, RTMR_BYTES;
|
|
32272
32291
|
var init_tdx_attestation = __esm({
|
|
@@ -32291,6 +32310,55 @@ var init_tdx_attestation = __esm({
|
|
|
32291
32310
|
}
|
|
32292
32311
|
});
|
|
32293
32312
|
|
|
32313
|
+
// src/lib/cvm-approved.ts
|
|
32314
|
+
function parseCvmApproved(raw) {
|
|
32315
|
+
if (!raw || typeof raw !== "object") return null;
|
|
32316
|
+
const doc = raw;
|
|
32317
|
+
if (doc.v !== CVM_APPROVED_VERSION || !Array.isArray(doc.cvms)) return null;
|
|
32318
|
+
const out = [];
|
|
32319
|
+
for (const item of doc.cvms) {
|
|
32320
|
+
const c = item && typeof item === "object" ? item : null;
|
|
32321
|
+
if (!c || typeof c.name !== "string" || typeof c.appId !== "string" || !APP_ID.test(c.appId)) return null;
|
|
32322
|
+
if (!Array.isArray(c.composeHashes) || !c.composeHashes.every((h) => typeof h === "string" && HEX64.test(h))) return null;
|
|
32323
|
+
out.push({ name: c.name, appId: c.appId, composeHashes: c.composeHashes });
|
|
32324
|
+
}
|
|
32325
|
+
return out;
|
|
32326
|
+
}
|
|
32327
|
+
function approvedFor(cvms, appId) {
|
|
32328
|
+
const app = appId.toLowerCase().replace(/^0x/, "");
|
|
32329
|
+
return cvms.find((c) => c.appId === app)?.composeHashes ?? [];
|
|
32330
|
+
}
|
|
32331
|
+
async function approvedComposeHashes(appId, origin, fetchImpl = fetch) {
|
|
32332
|
+
if (cached && cached.origin === origin && Date.now() - cached.at < CACHE_MS) return approvedFor(cached.cvms, appId);
|
|
32333
|
+
let body;
|
|
32334
|
+
try {
|
|
32335
|
+
const init2 = { headers: { accept: "application/json" }, cache: "no-store", signal: AbortSignal.timeout(2e4) };
|
|
32336
|
+
const res = await fetchImpl(`${origin}/api/public/cvm-approved`, init2);
|
|
32337
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
32338
|
+
body = await res.json();
|
|
32339
|
+
} catch (err) {
|
|
32340
|
+
throw new ApprovedListError(`the approved CVM list at ${origin} did not answer (${err.message}), so nothing was sealed`);
|
|
32341
|
+
}
|
|
32342
|
+
const cvms = parseCvmApproved(body);
|
|
32343
|
+
if (!cvms) throw new ApprovedListError(`the approved CVM list at ${origin} is not the shape this CLI reads, so nothing was sealed`);
|
|
32344
|
+
cached = { origin, at: Date.now(), cvms };
|
|
32345
|
+
return approvedFor(cvms, appId);
|
|
32346
|
+
}
|
|
32347
|
+
var CVM_APPROVED_VERSION, HEX64, APP_ID, cached, CACHE_MS, ApprovedListError;
|
|
32348
|
+
var init_cvm_approved = __esm({
|
|
32349
|
+
"src/lib/cvm-approved.ts"() {
|
|
32350
|
+
"use strict";
|
|
32351
|
+
CVM_APPROVED_VERSION = 1;
|
|
32352
|
+
HEX64 = /^[0-9a-f]{64}$/;
|
|
32353
|
+
APP_ID = /^[0-9a-f]{40}$/;
|
|
32354
|
+
cached = null;
|
|
32355
|
+
CACHE_MS = 6e4;
|
|
32356
|
+
ApprovedListError = class extends Error {
|
|
32357
|
+
code = "approved_list_unreachable";
|
|
32358
|
+
};
|
|
32359
|
+
}
|
|
32360
|
+
});
|
|
32361
|
+
|
|
32294
32362
|
// src/lib/passwords-wire.ts
|
|
32295
32363
|
var passwords_wire_exports = {};
|
|
32296
32364
|
__export(passwords_wire_exports, {
|
|
@@ -32317,8 +32385,10 @@ __export(passwords_wire_exports, {
|
|
|
32317
32385
|
postUse: () => postUse,
|
|
32318
32386
|
putKeyWrap: () => putKeyWrap,
|
|
32319
32387
|
readAttestation: () => readAttestation,
|
|
32388
|
+
readSolveChecks: () => readSolveChecks,
|
|
32320
32389
|
revealRow: () => revealRow,
|
|
32321
32390
|
revokeLoginKey: () => revokeLoginKey,
|
|
32391
|
+
rowForWorkflow: () => rowForWorkflow,
|
|
32322
32392
|
runsOnKeyOnly: () => runsOnKeyOnly,
|
|
32323
32393
|
setKeyMemoryFolders: () => setKeyMemoryFolders,
|
|
32324
32394
|
setLoginKey: () => setLoginKey,
|
|
@@ -32327,7 +32397,9 @@ __export(passwords_wire_exports, {
|
|
|
32327
32397
|
storeRow: () => storeRow,
|
|
32328
32398
|
updateRow: () => updateRow,
|
|
32329
32399
|
verifyPasswordsAttestation: () => verifyPasswordsAttestation,
|
|
32330
|
-
withdrawInvite: () => withdrawInvite
|
|
32400
|
+
withdrawInvite: () => withdrawInvite,
|
|
32401
|
+
workflowInputsOf: () => workflowInputsOf,
|
|
32402
|
+
writeSolveChecks: () => writeSolveChecks
|
|
32331
32403
|
});
|
|
32332
32404
|
import { createHash as createHash4, randomBytes as randomBytes5 } from "node:crypto";
|
|
32333
32405
|
function identityOrigin() {
|
|
@@ -32462,7 +32534,7 @@ function expectOk(answer, what) {
|
|
|
32462
32534
|
const error = typeof b2.error === "string" ? b2.error : `${what}: HTTP ${answer.status}`;
|
|
32463
32535
|
throw new WireError(answer.status, code, error, answer.body);
|
|
32464
32536
|
}
|
|
32465
|
-
function verifyPasswordsAttestation(body, opts
|
|
32537
|
+
function verifyPasswordsAttestation(body, opts) {
|
|
32466
32538
|
const p = body && typeof body === "object" ? body : null;
|
|
32467
32539
|
if (!p) return { ok: false, reason: "the box did not answer with an attestation" };
|
|
32468
32540
|
if (p.v !== PASSWORDS_WIRE_VERSION || p.suite !== PASSWORDS_SUITE) return { ok: false, reason: "this box speaks a different passwords wire" };
|
|
@@ -32475,6 +32547,7 @@ function verifyPasswordsAttestation(body, opts = {}) {
|
|
|
32475
32547
|
eventLog: p.eventLog,
|
|
32476
32548
|
expectedReportData,
|
|
32477
32549
|
pinnedAppId: opts.pinnedAppId ?? PASSWORDS_BOX_APP_ID,
|
|
32550
|
+
approvedComposeHashes: opts.approved,
|
|
32478
32551
|
now: opts.now
|
|
32479
32552
|
});
|
|
32480
32553
|
if (!proof.ok) return proof;
|
|
@@ -32497,12 +32570,36 @@ async function readAttestation() {
|
|
|
32497
32570
|
const error = body?.error ?? `the CVM's key could not be read: HTTP ${res.status}`;
|
|
32498
32571
|
throw new WireError(res.status, body?.code ?? null, error, body);
|
|
32499
32572
|
}
|
|
32500
|
-
|
|
32573
|
+
let approved;
|
|
32574
|
+
try {
|
|
32575
|
+
approved = await approvedComposeHashes(PASSWORDS_BOX_APP_ID, siteOrigin());
|
|
32576
|
+
} catch (err) {
|
|
32577
|
+
if (err instanceof ApprovedListError) throw new WireError(0, err.code, err.message, null);
|
|
32578
|
+
throw err;
|
|
32579
|
+
}
|
|
32580
|
+
const proven = verifyPasswordsAttestation(body, { approved });
|
|
32501
32581
|
if (!proven.ok) {
|
|
32502
32582
|
throw new WireError(0, "box_unproven", `the passwords box did not prove itself (${proven.reason}), so nothing was sealed`, null);
|
|
32503
32583
|
}
|
|
32504
32584
|
return proven.value;
|
|
32505
32585
|
}
|
|
32586
|
+
async function rowForWorkflow(wallet, name) {
|
|
32587
|
+
const { passwords: passwords2, permitted } = await listRows(wallet);
|
|
32588
|
+
const wanted = name.replace(/\s+/g, " ").trim();
|
|
32589
|
+
const hits = [...passwords2, ...permitted].flatMap((r) => (r.workflows ?? []).filter((w) => w.name === wanted).map((workflow) => ({ id: r.id, workflow })));
|
|
32590
|
+
if (hits.length === 0) throw new WireError(404, "workflow_not_found", `no login this key holds or may use has a workflow named "${wanted}"; agentgates passwords list shows them`, null);
|
|
32591
|
+
if (hits.length > 1) throw new WireError(400, "bad_request", `${hits.length} logins have a workflow named "${wanted}"; pass --row <id>`, null);
|
|
32592
|
+
return hits[0];
|
|
32593
|
+
}
|
|
32594
|
+
function workflowInputsOf(pairs) {
|
|
32595
|
+
const out = {};
|
|
32596
|
+
for (const pair of pairs ?? []) {
|
|
32597
|
+
const at = pair.indexOf("=");
|
|
32598
|
+
if (at <= 0) throw new WireError(400, "bad_request", `--input takes name=value (got "${pair.slice(0, 40)}")`, null);
|
|
32599
|
+
out[pair.slice(0, at).trim()] = pair.slice(at + 1);
|
|
32600
|
+
}
|
|
32601
|
+
return out;
|
|
32602
|
+
}
|
|
32506
32603
|
async function listRows(wallet) {
|
|
32507
32604
|
const out = expectOk(await signedFetch(wallet, "GET", lanePath(`/passwords`)), "list");
|
|
32508
32605
|
return { passwords: out.passwords ?? [], permitted: out.permitted ?? [] };
|
|
@@ -32534,6 +32631,14 @@ async function postPermit(wallet, signed2) {
|
|
|
32534
32631
|
);
|
|
32535
32632
|
return out.permit;
|
|
32536
32633
|
}
|
|
32634
|
+
async function readSolveChecks(wallet) {
|
|
32635
|
+
const out = expectOk(await signedFetch(wallet, "GET", lanePath(`/passwords/settings`)), "settings");
|
|
32636
|
+
return out.settings?.solveChecks === "solve" ? "solve" : "ask";
|
|
32637
|
+
}
|
|
32638
|
+
async function writeSolveChecks(wallet, word) {
|
|
32639
|
+
const out = expectOk(await signedFetch(wallet, "POST", lanePath(`/passwords/settings`), { solveChecks: word }), "settings");
|
|
32640
|
+
return out.settings?.solveChecks === "solve" ? "solve" : "ask";
|
|
32641
|
+
}
|
|
32537
32642
|
async function postUse(wallet, id2, body, timeoutMs = 2e5) {
|
|
32538
32643
|
return signedFetch(wallet, "POST", lanePath(`/passwords/${encodeURIComponent(id2)}/use`), body, timeoutMs);
|
|
32539
32644
|
}
|
|
@@ -32550,9 +32655,10 @@ var init_passwords_wire = __esm({
|
|
|
32550
32655
|
init_constants();
|
|
32551
32656
|
init_passwords_seal();
|
|
32552
32657
|
init_tdx_attestation();
|
|
32658
|
+
init_cvm_approved();
|
|
32553
32659
|
trim2 = (v) => v ? v.replace(/\/$/, "") : "";
|
|
32554
32660
|
ACCOUNT_HEADS = { credits: "account/balance", deposit: "account/deposit", plans: "account/plans", keys: "account/keys", docs: "account/docs", catalog: "account/catalog", notify: "account/notify", founder: "account/founder", renew: "account/renew", "seal-key": "account/seal-key", "seal-grants": "account/seal-grants" };
|
|
32555
|
-
SERVICE_HEADS = /* @__PURE__ */ new Set(["booth", "booths", "browser", "passwords", "phones", "inboxes", "calls", "personas", "playbooks", "intents", "memory", "ag"]);
|
|
32661
|
+
SERVICE_HEADS = /* @__PURE__ */ new Set(["booth", "booths", "browser", "passwords", "phones", "inboxes", "calls", "personas", "playbooks", "intents", "memory", "ag", "integrations", "sites"]);
|
|
32556
32662
|
PASSWORDS_USE_PINNED_BY_BOX = false;
|
|
32557
32663
|
WireError = class extends Error {
|
|
32558
32664
|
constructor(status4, code, message, body) {
|
|
@@ -32572,7 +32678,7 @@ var init_passwords_wire = __esm({
|
|
|
32572
32678
|
revokedNoticed = false;
|
|
32573
32679
|
keyOnly = false;
|
|
32574
32680
|
loginReading = null;
|
|
32575
|
-
SIGNED_DOORS = /\/keys(\/(?!me\/)|$)|\/passwords\/[A-Za-z0-9_-]{1,64}\/use$|\/seal-key$|\/ag\/(?:agent|bindings)
|
|
32681
|
+
SIGNED_DOORS = /\/keys(\/(?!me\/)|$)|\/passwords\/[A-Za-z0-9_-]{1,64}\/use$|\/seal-key$|\/ag\/(?:agent|bindings)$|\/integrations(\/|$)/;
|
|
32576
32682
|
PASSWORDS_BOX_APP_ID = "c8746c93771d337af3588872dcad76ddb1fccdb6";
|
|
32577
32683
|
PASSWORDS_REPORT_DATA_LABEL = "agentgates/passwords/seal-key/v1";
|
|
32578
32684
|
}
|
|
@@ -32583,7 +32689,7 @@ var require_package = __commonJS({
|
|
|
32583
32689
|
"package.json"(exports, module) {
|
|
32584
32690
|
module.exports = {
|
|
32585
32691
|
name: "@agentgates/cli",
|
|
32586
|
-
version: "0.
|
|
32692
|
+
version: "0.72.0",
|
|
32587
32693
|
description: "Wallet operations for AI agents and humans",
|
|
32588
32694
|
keywords: [
|
|
32589
32695
|
"crypto",
|
|
@@ -43110,7 +43216,7 @@ var require_dist = __commonJS({
|
|
|
43110
43216
|
"use strict";
|
|
43111
43217
|
class StructError extends TypeError {
|
|
43112
43218
|
constructor(failure, failures) {
|
|
43113
|
-
let
|
|
43219
|
+
let cached2;
|
|
43114
43220
|
const { message, explanation, ...rest } = failure;
|
|
43115
43221
|
const { path: path8 } = failure;
|
|
43116
43222
|
const msg = path8.length === 0 ? message : `At path: ${path8.join(".")} -- ${message}`;
|
|
@@ -43120,7 +43226,7 @@ var require_dist = __commonJS({
|
|
|
43120
43226
|
Object.assign(this, rest);
|
|
43121
43227
|
this.name = this.constructor.name;
|
|
43122
43228
|
this.failures = () => {
|
|
43123
|
-
return
|
|
43229
|
+
return cached2 ?? (cached2 = [failure, ...failures()]);
|
|
43124
43230
|
};
|
|
43125
43231
|
}
|
|
43126
43232
|
}
|
|
@@ -51168,7 +51274,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
51168
51274
|
if (listeners.fn) return 1;
|
|
51169
51275
|
return listeners.length;
|
|
51170
51276
|
};
|
|
51171
|
-
EventEmitter.prototype.emit = function
|
|
51277
|
+
EventEmitter.prototype.emit = function emit12(event, a1, a2, a3, a4, a5) {
|
|
51172
51278
|
var evt = prefix ? prefix + event : event;
|
|
51173
51279
|
if (!this._events[evt]) return false;
|
|
51174
51280
|
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
@@ -56363,7 +56469,7 @@ Message: ${transactionMessage}.
|
|
|
56363
56469
|
}
|
|
56364
56470
|
return signature2;
|
|
56365
56471
|
}
|
|
56366
|
-
function
|
|
56472
|
+
function sleep4(ms2) {
|
|
56367
56473
|
return new Promise((resolve3) => setTimeout(resolve3, ms2));
|
|
56368
56474
|
}
|
|
56369
56475
|
function encodeData(type, fields) {
|
|
@@ -57173,7 +57279,7 @@ Message: ${transactionMessage}.
|
|
|
57173
57279
|
}));
|
|
57174
57280
|
if (connection._rpcEndpoint.includes("solana.com")) {
|
|
57175
57281
|
const REQUESTS_PER_SECOND = 4;
|
|
57176
|
-
await
|
|
57282
|
+
await sleep4(1e3 / REQUESTS_PER_SECOND);
|
|
57177
57283
|
}
|
|
57178
57284
|
offset += chunkSize;
|
|
57179
57285
|
array = array.slice(chunkSize);
|
|
@@ -58328,7 +58434,7 @@ Message: ${transactionMessage}.
|
|
|
58328
58434
|
break;
|
|
58329
58435
|
}
|
|
58330
58436
|
console.error(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
|
|
58331
|
-
await
|
|
58437
|
+
await sleep4(waitTime);
|
|
58332
58438
|
waitTime *= 2;
|
|
58333
58439
|
}
|
|
58334
58440
|
const text = await res.text();
|
|
@@ -59443,7 +59549,7 @@ Message: ${transactionMessage}.
|
|
|
59443
59549
|
let currentBlockHeight = await checkBlockHeight();
|
|
59444
59550
|
if (done) return;
|
|
59445
59551
|
while (currentBlockHeight <= lastValidBlockHeight) {
|
|
59446
|
-
await
|
|
59552
|
+
await sleep4(1e3);
|
|
59447
59553
|
if (done) return;
|
|
59448
59554
|
currentBlockHeight = await checkBlockHeight();
|
|
59449
59555
|
if (done) return;
|
|
@@ -59515,7 +59621,7 @@ Message: ${transactionMessage}.
|
|
|
59515
59621
|
});
|
|
59516
59622
|
return;
|
|
59517
59623
|
}
|
|
59518
|
-
await
|
|
59624
|
+
await sleep4(2e3);
|
|
59519
59625
|
if (done) return;
|
|
59520
59626
|
currentNonceValue = await getCurrentNonceValue();
|
|
59521
59627
|
if (done) return;
|
|
@@ -59543,7 +59649,7 @@ Message: ${transactionMessage}.
|
|
|
59543
59649
|
break;
|
|
59544
59650
|
}
|
|
59545
59651
|
if (status4.context.slot < (outcome.slotInWhichNonceDidAdvance ?? minContextSlot)) {
|
|
59546
|
-
await
|
|
59652
|
+
await sleep4(400);
|
|
59547
59653
|
continue;
|
|
59548
59654
|
}
|
|
59549
59655
|
signatureStatus = status4;
|
|
@@ -60615,7 +60721,7 @@ Message: ${transactionMessage}.
|
|
|
60615
60721
|
async _blockhashWithExpiryBlockHeight(disableCache) {
|
|
60616
60722
|
if (!disableCache) {
|
|
60617
60723
|
while (this._pollingBlockhash) {
|
|
60618
|
-
await
|
|
60724
|
+
await sleep4(100);
|
|
60619
60725
|
}
|
|
60620
60726
|
const timeSinceFetch = Date.now() - this._blockhashInfo.lastFetch;
|
|
60621
60727
|
const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
@@ -60645,7 +60751,7 @@ Message: ${transactionMessage}.
|
|
|
60645
60751
|
};
|
|
60646
60752
|
return latestBlockhash;
|
|
60647
60753
|
}
|
|
60648
|
-
await
|
|
60754
|
+
await sleep4(MS_PER_SLOT / 2);
|
|
60649
60755
|
}
|
|
60650
60756
|
throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
|
|
60651
60757
|
} finally {
|
|
@@ -63584,7 +63690,7 @@ var {
|
|
|
63584
63690
|
} = import_index.default;
|
|
63585
63691
|
|
|
63586
63692
|
// src/main.ts
|
|
63587
|
-
var
|
|
63693
|
+
var import_picocolors39 = __toESM(require_picocolors(), 1);
|
|
63588
63694
|
|
|
63589
63695
|
// src/commands/login.ts
|
|
63590
63696
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
@@ -70299,11 +70405,11 @@ async function serveWordsOnce(args) {
|
|
|
70299
70405
|
let port = 0;
|
|
70300
70406
|
let done = () => {
|
|
70301
70407
|
};
|
|
70302
|
-
let
|
|
70408
|
+
let fail10 = () => {
|
|
70303
70409
|
};
|
|
70304
70410
|
const settled = new Promise((resolve3, reject) => {
|
|
70305
70411
|
done = resolve3;
|
|
70306
|
-
|
|
70412
|
+
fail10 = reject;
|
|
70307
70413
|
});
|
|
70308
70414
|
const server = createServer((req, res) => {
|
|
70309
70415
|
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
@@ -70329,7 +70435,7 @@ async function serveWordsOnce(args) {
|
|
|
70329
70435
|
const timer = setTimeout(() => {
|
|
70330
70436
|
if (!taken) {
|
|
70331
70437
|
server.close();
|
|
70332
|
-
|
|
70438
|
+
fail10(new Error(`nobody took the session in ${Math.round(args.waitMs / 1e3)}s`));
|
|
70333
70439
|
}
|
|
70334
70440
|
}, args.waitMs);
|
|
70335
70441
|
try {
|
|
@@ -70343,11 +70449,11 @@ async function receiveKeyOnce(args) {
|
|
|
70343
70449
|
let taken = false;
|
|
70344
70450
|
let done = () => {
|
|
70345
70451
|
};
|
|
70346
|
-
let
|
|
70452
|
+
let fail10 = () => {
|
|
70347
70453
|
};
|
|
70348
70454
|
const settled = new Promise((resolve3, reject) => {
|
|
70349
70455
|
done = resolve3;
|
|
70350
|
-
|
|
70456
|
+
fail10 = reject;
|
|
70351
70457
|
});
|
|
70352
70458
|
const server = createServer(async (req, res) => {
|
|
70353
70459
|
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
@@ -70377,7 +70483,7 @@ async function receiveKeyOnce(args) {
|
|
|
70377
70483
|
const timer = setTimeout(() => {
|
|
70378
70484
|
if (!taken) {
|
|
70379
70485
|
server.close();
|
|
70380
|
-
|
|
70486
|
+
fail10(new Error(`nobody handed a session over in ${Math.round(args.waitMs / 1e3)}s`));
|
|
70381
70487
|
}
|
|
70382
70488
|
}, args.waitMs);
|
|
70383
70489
|
try {
|
|
@@ -70899,17 +71005,30 @@ async function passwordsList(opts) {
|
|
|
70899
71005
|
`);
|
|
70900
71006
|
return;
|
|
70901
71007
|
}
|
|
71008
|
+
const flows = (list) => {
|
|
71009
|
+
for (const w of list ?? []) {
|
|
71010
|
+
const takes = w.inputs.length ? ` --input ${w.inputs.map((i) => `${i.name}=\u2026`).join(" --input ")}` : "";
|
|
71011
|
+
process.stdout.write(` ${"".padEnd(40)} ${import_picocolors9.default.dim("workflow")} ${w.name}${import_picocolors9.default.dim(` ${w.steps} steps${takes}`)}
|
|
71012
|
+
`);
|
|
71013
|
+
}
|
|
71014
|
+
};
|
|
70902
71015
|
if (passwords2.length) {
|
|
70903
71016
|
process.stdout.write(` ${import_picocolors9.default.dim("yours")}
|
|
70904
71017
|
`);
|
|
70905
|
-
for (const r of passwords2)
|
|
71018
|
+
for (const r of passwords2) {
|
|
71019
|
+
process.stdout.write(` ${import_picocolors9.default.cyan(r.id.padEnd(40))} ${r.label.padEnd(24)} ${import_picocolors9.default.dim(r.hosts.join(", "))}${r.stale ? import_picocolors9.default.dim(" (stale: re-seal on the board)") : ""}
|
|
70906
71020
|
`);
|
|
71021
|
+
flows(r.workflows);
|
|
71022
|
+
}
|
|
70907
71023
|
}
|
|
70908
71024
|
if (permitted.length) {
|
|
70909
71025
|
process.stdout.write(` ${import_picocolors9.default.dim("permitted to you")}
|
|
70910
71026
|
`);
|
|
70911
|
-
for (const r of permitted)
|
|
71027
|
+
for (const r of permitted) {
|
|
71028
|
+
process.stdout.write(` ${import_picocolors9.default.cyan(r.id.padEnd(40))} ${r.label.padEnd(24)} ${import_picocolors9.default.dim(`${r.hosts.join(", ")} \xB7 ${r.uses.join(", ")}`)}
|
|
70912
71029
|
`);
|
|
71030
|
+
flows(r.workflows);
|
|
71031
|
+
}
|
|
70913
71032
|
}
|
|
70914
71033
|
process.stdout.write("\n");
|
|
70915
71034
|
});
|
|
@@ -70917,6 +71036,21 @@ async function passwordsList(opts) {
|
|
|
70917
71036
|
failFrom2(opts, err);
|
|
70918
71037
|
}
|
|
70919
71038
|
}
|
|
71039
|
+
async function passwordsChecks(word, opts) {
|
|
71040
|
+
try {
|
|
71041
|
+
const { wallet } = await requirePasswordsKey();
|
|
71042
|
+
if (word !== void 0 && word !== "ask" && word !== "solve") throw new PasswordsSealError("the word is ask or solve");
|
|
71043
|
+
const now = word === void 0 ? await readSolveChecks(wallet) : await writeSolveChecks(wallet, word);
|
|
71044
|
+
emit4(opts, { ok: true, solveChecks: now }, () => {
|
|
71045
|
+
process.stdout.write(`
|
|
71046
|
+
bot checks: ${import_picocolors9.default.bold(now)} ${import_picocolors9.default.dim(now === "solve" ? "the CVM passes every check it can, without asking" : "an agent's use that meets a check waits for your answer on the board")}
|
|
71047
|
+
|
|
71048
|
+
`);
|
|
71049
|
+
});
|
|
71050
|
+
} catch (err) {
|
|
71051
|
+
failFrom2(opts, err);
|
|
71052
|
+
}
|
|
71053
|
+
}
|
|
70920
71054
|
async function rowForUrl(wallet, url) {
|
|
70921
71055
|
let host2;
|
|
70922
71056
|
try {
|
|
@@ -70971,6 +71105,21 @@ function printUseAnswer(opts, status4, body) {
|
|
|
70971
71105
|
`);
|
|
70972
71106
|
if (result.device && typeof result.device === "object") process.stdout.write(` ${import_picocolors9.default.dim(`the site created a device credential for ${String(result.device.rpId ?? "")}; agentgates passwords device seals it into the row`)}
|
|
70973
71107
|
`);
|
|
71108
|
+
for (const s of Array.isArray(result.solved) ? result.solved : []) {
|
|
71109
|
+
process.stdout.write(` ${import_picocolors9.default.dim(`passed a ${String(s.kind)} check ${s.how === "service" ? "through the solver service" : "by hand"} in ${Math.max(1, Math.round(Number(s.ms ?? 0) / 1e3))}s`)}
|
|
71110
|
+
`);
|
|
71111
|
+
}
|
|
71112
|
+
const check = result.check && typeof result.check === "object" ? result.check : null;
|
|
71113
|
+
if (check && check.passable === true && check.tried !== true) {
|
|
71114
|
+
process.stdout.write(` ${import_picocolors9.default.dim(`a ${String(check.kind)} check stood in front of the site; with your own key, --solve lets the CVM pass it (agentgates passwords checks solve: every time)`)}
|
|
71115
|
+
`);
|
|
71116
|
+
}
|
|
71117
|
+
const wf = result.workflow && typeof result.workflow === "object" ? result.workflow : null;
|
|
71118
|
+
if (wf) {
|
|
71119
|
+
const mended = Array.isArray(wf.mended) ? wf.mended.length : 0;
|
|
71120
|
+
process.stdout.write(` ${import_picocolors9.default.dim(`workflow "${String(wf.name)}": ${String(wf.ran)} of ${String(wf.of)} steps${mended ? `, ${mended} found another way and kept` : ""}`)}
|
|
71121
|
+
`);
|
|
71122
|
+
}
|
|
70974
71123
|
if (typeof result.error === "string" && result.error) process.stdout.write(` ${result.error}
|
|
70975
71124
|
`);
|
|
70976
71125
|
if (digest) process.stdout.write(`
|
|
@@ -71035,9 +71184,21 @@ async function passwordsUse(opts) {
|
|
|
71035
71184
|
if (use !== "login" && use !== "session") throw new PasswordsSealError("--mailbox goes with the login or session use");
|
|
71036
71185
|
request.mailbox = opts.mailbox;
|
|
71037
71186
|
}
|
|
71038
|
-
|
|
71039
|
-
|
|
71040
|
-
|
|
71187
|
+
let workflowRow = null;
|
|
71188
|
+
if (opts.workflow) {
|
|
71189
|
+
if (use !== "login") throw new PasswordsSealError("--workflow goes with the login use");
|
|
71190
|
+
if (opts.stepsJson) throw new PasswordsSealError("--workflow runs the owner's steps; --steps-json is for your own");
|
|
71191
|
+
request.workflow = opts.workflow;
|
|
71192
|
+
const inputs = workflowInputsOf(opts.input);
|
|
71193
|
+
if (Object.keys(inputs).length) request.inputs = inputs;
|
|
71194
|
+
if (!opts.row) workflowRow = (await rowForWorkflow(wallet, opts.workflow)).id;
|
|
71195
|
+
} else if (opts.input?.length) {
|
|
71196
|
+
throw new PasswordsSealError("--input goes with --workflow");
|
|
71197
|
+
}
|
|
71198
|
+
if (use !== "totp" && use !== "reveal" && !opts.workflow && typeof request.url !== "string") throw new PasswordsSealError("--url is the https URL the use targets");
|
|
71199
|
+
const rowId = opts.row ?? workflowRow ?? await rowForUrl(wallet, request.url);
|
|
71200
|
+
if (opts.solve && use !== "login" && use !== "session") throw new PasswordsSealError("--solve goes with the login or session use");
|
|
71201
|
+
const firstBody = { use, request: use === "totp" && Object.keys(request).length === 0 ? void 0 : request, ...opts.useId ? { useId: opts.useId } : {}, ...opts.solve ? { solve: true } : {} };
|
|
71041
71202
|
const answer = await postUseAndWait(wallet, rowId, firstBody, waitOptionsOf(opts));
|
|
71042
71203
|
const body = answer.body ?? {};
|
|
71043
71204
|
printUseAnswer(opts, answer.status, body);
|
|
@@ -73854,6 +74015,148 @@ var US_STATES = [
|
|
|
73854
74015
|
["WI", "Wisconsin"],
|
|
73855
74016
|
["WY", "Wyoming"]
|
|
73856
74017
|
];
|
|
74018
|
+
var ETHERFI_COUNTRIES = [
|
|
74019
|
+
["AD", "Andorra"],
|
|
74020
|
+
["AO", "Angola"],
|
|
74021
|
+
["AG", "Antigua & Barbuda"],
|
|
74022
|
+
["AR", "Argentina"],
|
|
74023
|
+
["AU", "Australia"],
|
|
74024
|
+
["AT", "Austria"],
|
|
74025
|
+
["BS", "Bahamas"],
|
|
74026
|
+
["BH", "Bahrain"],
|
|
74027
|
+
["BD", "Bangladesh"],
|
|
74028
|
+
["BB", "Barbados"],
|
|
74029
|
+
["BE", "Belgium"],
|
|
74030
|
+
["BZ", "Belize"],
|
|
74031
|
+
["BO", "Bolivia"],
|
|
74032
|
+
["BR", "Brazil"],
|
|
74033
|
+
["VG", "British Virgin Islands"],
|
|
74034
|
+
["BG", "Bulgaria"],
|
|
74035
|
+
["CA", "Canada"],
|
|
74036
|
+
["KY", "Cayman Islands"],
|
|
74037
|
+
["CL", "Chile"],
|
|
74038
|
+
["CO", "Colombia"],
|
|
74039
|
+
["CR", "Costa Rica"],
|
|
74040
|
+
["HR", "Croatia"],
|
|
74041
|
+
["CY", "Cyprus"],
|
|
74042
|
+
["CZ", "Czech Republic"],
|
|
74043
|
+
["DK", "Denmark"],
|
|
74044
|
+
["DM", "Dominica"],
|
|
74045
|
+
["DO", "Dominican Republic"],
|
|
74046
|
+
["EC", "Ecuador"],
|
|
74047
|
+
["SV", "El Salvador"],
|
|
74048
|
+
["FR", "France"],
|
|
74049
|
+
["DE", "Germany"],
|
|
74050
|
+
["GI", "Gibraltar"],
|
|
74051
|
+
["GR", "Greece"],
|
|
74052
|
+
["GT", "Guatemala"],
|
|
74053
|
+
["GG", "Guernsey"],
|
|
74054
|
+
["GY", "Guyana"],
|
|
74055
|
+
["HN", "Honduras"],
|
|
74056
|
+
["HK", "Hong Kong"],
|
|
74057
|
+
["HU", "Hungary"],
|
|
74058
|
+
["IS", "Iceland"],
|
|
74059
|
+
["ID", "Indonesia"],
|
|
74060
|
+
["IE", "Ireland"],
|
|
74061
|
+
["IM", "Isle of Man"],
|
|
74062
|
+
["IT", "Italy"],
|
|
74063
|
+
["JP", "Japan"],
|
|
74064
|
+
["JE", "Jersey"],
|
|
74065
|
+
["LV", "Latvia"],
|
|
74066
|
+
["LI", "Liechtenstein"],
|
|
74067
|
+
["LT", "Lithuania"],
|
|
74068
|
+
["LU", "Luxembourg"],
|
|
74069
|
+
["MY", "Malaysia"],
|
|
74070
|
+
["MV", "Maldives"],
|
|
74071
|
+
["MT", "Malta"],
|
|
74072
|
+
["MX", "Mexico"],
|
|
74073
|
+
["MC", "Monaco"],
|
|
74074
|
+
["NZ", "New Zealand"],
|
|
74075
|
+
["NG", "Nigeria"],
|
|
74076
|
+
["NO", "Norway"],
|
|
74077
|
+
["OM", "Oman"],
|
|
74078
|
+
["PW", "Palau"],
|
|
74079
|
+
["PA", "Panama"],
|
|
74080
|
+
["PY", "Paraguay"],
|
|
74081
|
+
["PE", "Peru"],
|
|
74082
|
+
["PH", "Philippines"],
|
|
74083
|
+
["PL", "Poland"],
|
|
74084
|
+
["PT", "Portugal"],
|
|
74085
|
+
["PR", "Puerto Rico"],
|
|
74086
|
+
["RO", "Romania"],
|
|
74087
|
+
["SA", "Saudi Arabia"],
|
|
74088
|
+
["SC", "Seychelles"],
|
|
74089
|
+
["SG", "Singapore"],
|
|
74090
|
+
["SK", "Slovakia"],
|
|
74091
|
+
["SI", "Slovenia"],
|
|
74092
|
+
["ZA", "South Africa"],
|
|
74093
|
+
["KR", "South Korea"],
|
|
74094
|
+
["ES", "Spain"],
|
|
74095
|
+
["KN", "St. Kitts and Nevis"],
|
|
74096
|
+
["LC", "St. Lucia"],
|
|
74097
|
+
["VC", "St. Vincent and the Grenadines"],
|
|
74098
|
+
["SR", "Suriname"],
|
|
74099
|
+
["SE", "Sweden"],
|
|
74100
|
+
["CH", "Switzerland"],
|
|
74101
|
+
["TW", "Taiwan"],
|
|
74102
|
+
["TH", "Thailand"],
|
|
74103
|
+
["TT", "Trinidad & Tobago"],
|
|
74104
|
+
["TC", "Turks & Caicos Islands"],
|
|
74105
|
+
["AE", "United Arab Emirates"],
|
|
74106
|
+
["GB", "United Kingdom"],
|
|
74107
|
+
["US", "United States"],
|
|
74108
|
+
["UY", "Uruguay"],
|
|
74109
|
+
["VU", "Vanuatu"]
|
|
74110
|
+
];
|
|
74111
|
+
var COUNTRY_ALIASES = {
|
|
74112
|
+
"usa": "US",
|
|
74113
|
+
"u s a": "US",
|
|
74114
|
+
"united states of america": "US",
|
|
74115
|
+
"america": "US",
|
|
74116
|
+
"uk": "GB",
|
|
74117
|
+
"great britain": "GB",
|
|
74118
|
+
"britain": "GB",
|
|
74119
|
+
"england": "GB",
|
|
74120
|
+
"scotland": "GB",
|
|
74121
|
+
"wales": "GB",
|
|
74122
|
+
"northern ireland": "GB",
|
|
74123
|
+
"uae": "AE",
|
|
74124
|
+
"emirates": "AE",
|
|
74125
|
+
"korea": "KR",
|
|
74126
|
+
"republic of korea": "KR",
|
|
74127
|
+
"czechia": "CZ",
|
|
74128
|
+
"bvi": "VG",
|
|
74129
|
+
"antigua and barbuda": "AG",
|
|
74130
|
+
"trinidad and tobago": "TT",
|
|
74131
|
+
"turks and caicos islands": "TC",
|
|
74132
|
+
"turks and caicos": "TC",
|
|
74133
|
+
"saint kitts and nevis": "KN",
|
|
74134
|
+
"saint lucia": "LC",
|
|
74135
|
+
"saint vincent and the grenadines": "VC",
|
|
74136
|
+
"brasil": "BR",
|
|
74137
|
+
"espana": "ES",
|
|
74138
|
+
"deutschland": "DE",
|
|
74139
|
+
"italia": "IT",
|
|
74140
|
+
"schweiz": "CH",
|
|
74141
|
+
"suisse": "CH",
|
|
74142
|
+
"osterreich": "AT",
|
|
74143
|
+
"sverige": "SE",
|
|
74144
|
+
"norge": "NO",
|
|
74145
|
+
"danmark": "DK",
|
|
74146
|
+
"polska": "PL",
|
|
74147
|
+
"republica dominicana": "DO",
|
|
74148
|
+
"the bahamas": "BS"
|
|
74149
|
+
};
|
|
74150
|
+
function fold(s) {
|
|
74151
|
+
return s.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[.,]/g, " ").replace(/\s+/g, " ").trim();
|
|
74152
|
+
}
|
|
74153
|
+
function countryOf(text) {
|
|
74154
|
+
const t = fold(text);
|
|
74155
|
+
if (!t) return null;
|
|
74156
|
+
const code = t.length === 2 ? t.toUpperCase() : null;
|
|
74157
|
+
const alias = COUNTRY_ALIASES[t] ?? null;
|
|
74158
|
+
return ETHERFI_COUNTRIES.find(([c, n2]) => c === code || c === alias || fold(n2) === t) ?? null;
|
|
74159
|
+
}
|
|
73857
74160
|
var ETHERFI_UNAVAILABLE_STATES = [
|
|
73858
74161
|
"AZ",
|
|
73859
74162
|
"DE",
|
|
@@ -73861,6 +74164,8 @@ var ETHERFI_UNAVAILABLE_STATES = [
|
|
|
73861
74164
|
"ID",
|
|
73862
74165
|
"LA",
|
|
73863
74166
|
"MD",
|
|
74167
|
+
"MS",
|
|
74168
|
+
"MO",
|
|
73864
74169
|
"MT",
|
|
73865
74170
|
"NV",
|
|
73866
74171
|
"NM",
|
|
@@ -73869,6 +74174,7 @@ var ETHERFI_UNAVAILABLE_STATES = [
|
|
|
73869
74174
|
"OR",
|
|
73870
74175
|
"RI",
|
|
73871
74176
|
"SD",
|
|
74177
|
+
"TN",
|
|
73872
74178
|
"VT",
|
|
73873
74179
|
"WA",
|
|
73874
74180
|
"WI"
|
|
@@ -73885,27 +74191,37 @@ function stateName(code) {
|
|
|
73885
74191
|
function addressLine(raw) {
|
|
73886
74192
|
return raw.replace(/\s+/g, " ").trim();
|
|
73887
74193
|
}
|
|
73888
|
-
function checkAddressField(field, raw) {
|
|
74194
|
+
function checkAddressField(field, raw, country = "US") {
|
|
73889
74195
|
const v = addressLine(raw);
|
|
73890
74196
|
if (v.length > ADDRESS_LINE_MAX) return `Keep it under ${ADDRESS_LINE_MAX} characters.`;
|
|
74197
|
+
if (field === "country") return countryOf(v) ? null : v ? "ether.fi does not offer its card in that country yet." : "Pick the country.";
|
|
73891
74198
|
if (field === "line1" && !v) return "Add the street address.";
|
|
73892
74199
|
if (field === "city" && !v) return "Add the city.";
|
|
74200
|
+
const us = country.toUpperCase() === "US";
|
|
73893
74201
|
if (field === "region") {
|
|
74202
|
+
if (!us) return v ? null : "Add the region.";
|
|
73894
74203
|
const name = stateName(v);
|
|
73895
74204
|
if (!name) return "Pick the state.";
|
|
73896
74205
|
const unavailable = unavailableStateName(v.toUpperCase());
|
|
73897
74206
|
if (unavailable) return `ether.fi does not offer its card in ${unavailable} yet.`;
|
|
73898
74207
|
}
|
|
73899
|
-
if (field === "zip"
|
|
74208
|
+
if (field === "zip") {
|
|
74209
|
+
if (us) return /^\d{5}(?:-\d{4})?$/.test(v) ? null : "The ZIP code is five digits.";
|
|
74210
|
+
if (!v) return "Add the postal code.";
|
|
74211
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9 -]{1,11}$/.test(v)) return "Check the postal code.";
|
|
74212
|
+
}
|
|
73900
74213
|
return null;
|
|
73901
74214
|
}
|
|
73902
|
-
var FIELDS = ["line1", "line2", "city", "region", "zip"];
|
|
74215
|
+
var FIELDS = ["country", "line1", "line2", "city", "region", "zip"];
|
|
73903
74216
|
function homeAddressFrom(input) {
|
|
74217
|
+
const place = countryOf(input.country ?? "US");
|
|
74218
|
+
const code = place ? place[0] : "US";
|
|
73904
74219
|
for (const field of FIELDS) {
|
|
73905
|
-
const why = checkAddressField(field, input[field] ?? "");
|
|
74220
|
+
const why = checkAddressField(field, field === "country" ? input.country ?? "US" : input[field] ?? "", code);
|
|
73906
74221
|
if (why) return { ok: false, field, why };
|
|
73907
74222
|
}
|
|
73908
|
-
const
|
|
74223
|
+
const us = code === "US";
|
|
74224
|
+
const region = us ? addressLine(input.region).toUpperCase() : addressLine(input.region);
|
|
73909
74225
|
return {
|
|
73910
74226
|
ok: true,
|
|
73911
74227
|
address: {
|
|
@@ -73915,10 +74231,10 @@ function homeAddressFrom(input) {
|
|
|
73915
74231
|
line2: addressLine(input.line2 ?? ""),
|
|
73916
74232
|
city: addressLine(input.city),
|
|
73917
74233
|
region,
|
|
73918
|
-
regionName: stateName(region) ?? region,
|
|
73919
|
-
zip: addressLine(input.zip),
|
|
73920
|
-
country:
|
|
73921
|
-
countryName: "United States"
|
|
74234
|
+
regionName: us ? stateName(region) ?? region : region,
|
|
74235
|
+
zip: us ? addressLine(input.zip) : addressLine(input.zip).toUpperCase(),
|
|
74236
|
+
country: code,
|
|
74237
|
+
countryName: place ? place[1] : "United States"
|
|
73922
74238
|
}
|
|
73923
74239
|
};
|
|
73924
74240
|
}
|
|
@@ -73974,7 +74290,8 @@ function readHomeAddress(body) {
|
|
|
73974
74290
|
};
|
|
73975
74291
|
}
|
|
73976
74292
|
function addressLines(a) {
|
|
73977
|
-
|
|
74293
|
+
const place = a.country === "US" ? `${a.city}, ${a.region} ${a.zip}` : `${a.city}, ${a.regionName} ${a.zip}`;
|
|
74294
|
+
return [a.line1, a.line2, place.trim(), a.countryName].filter((l) => l.length > 0);
|
|
73978
74295
|
}
|
|
73979
74296
|
var STATES_LONGEST_FIRST = [...US_STATES].sort((a, b2) => b2[1].length - a[1].length);
|
|
73980
74297
|
var STREET_WORDS = [
|
|
@@ -74038,9 +74355,45 @@ function takeState(rest) {
|
|
|
74038
74355
|
if (m && US_STATES.some(([c]) => c === m[2].toUpperCase())) return { code: m[2].toUpperCase(), before: m[1] };
|
|
74039
74356
|
return null;
|
|
74040
74357
|
}
|
|
74041
|
-
|
|
74358
|
+
var UNIT_ABROAD = /^(?:d[a-z]{0,2}p[a-z]{0,10}|ap[a-z]{0,10}|unit|suite|ste|flat|fl|floor|piso|of[a-z]{0,6}|casa|torre|block|bloque|bl|edif[a-z]{0,6}|#|n[o°º])\.?\s*#?\s*[\w-]+/i;
|
|
74359
|
+
function parseAbroad(parts, country) {
|
|
74360
|
+
const shape = "Write it as street, city, region, postal code.";
|
|
74361
|
+
if (parts.length < 2) return { ok: false, why: shape };
|
|
74362
|
+
const line1 = parts[0];
|
|
74363
|
+
let line2 = "";
|
|
74364
|
+
let at = 1;
|
|
74365
|
+
if (parts.length >= 3 && UNIT_ABROAD.test(parts[1])) {
|
|
74366
|
+
line2 = parts[1];
|
|
74367
|
+
at = 2;
|
|
74368
|
+
}
|
|
74369
|
+
let zip = "";
|
|
74370
|
+
const tail = parts.slice(at).map((part) => {
|
|
74371
|
+
if (zip) return part;
|
|
74372
|
+
const m = /^(\d{4,8})\s+(.+)$/.exec(part) ?? /^(.+?)\s+(\d{4,8})$/.exec(part);
|
|
74373
|
+
if (m) {
|
|
74374
|
+
const digitsFirst = /^\d/.test(m[1]);
|
|
74375
|
+
zip = digitsFirst ? m[1] : m[2];
|
|
74376
|
+
return digitsFirst ? m[2] : m[1];
|
|
74377
|
+
}
|
|
74378
|
+
if (/^\d{4,8}$/.test(part)) {
|
|
74379
|
+
zip = part;
|
|
74380
|
+
return "";
|
|
74381
|
+
}
|
|
74382
|
+
return part;
|
|
74383
|
+
}).filter(Boolean);
|
|
74384
|
+
const city = tail[0] ?? "";
|
|
74385
|
+
if (!city) return { ok: false, why: shape };
|
|
74386
|
+
return { ok: true, input: { country, line1, line2, city, region: tail.length > 1 ? tail[tail.length - 1] : "", zip } };
|
|
74387
|
+
}
|
|
74388
|
+
function parseHomeAddress(line2, country) {
|
|
74042
74389
|
const shape = "Write it as street, city, state ZIP.";
|
|
74043
74390
|
let rest = line2.replace(/\s*\n+\s*/g, ", ").replace(/\s+/g, " ").trim();
|
|
74391
|
+
const pieces = rest.split(",").map((p) => p.trim()).filter(Boolean);
|
|
74392
|
+
const last = pieces[pieces.length - 1] ?? "";
|
|
74393
|
+
const named = pieces.length > 1 && fold(last).length > 2 ? countryOf(last) : null;
|
|
74394
|
+
const given = country ? countryOf(country) : null;
|
|
74395
|
+
const abroad = named ? named[0] !== "US" ? named[0] : null : given && given[0] !== "US" ? given[0] : null;
|
|
74396
|
+
if (abroad) return parseAbroad(named ? pieces.slice(0, -1) : pieces, abroad);
|
|
74044
74397
|
rest = rest.replace(/[,\s]+(?:U\.?S\.?A?\.?|United States(?: of America)?)$/i, "").trim();
|
|
74045
74398
|
const zip = /[,\s]*(\d{5}(?:-\d{4})?)$/.exec(rest);
|
|
74046
74399
|
if (!zip) return { ok: false, why: `Add the ZIP code. ${shape}` };
|
|
@@ -74070,7 +74423,7 @@ function parseHomeAddress(line2) {
|
|
|
74070
74423
|
line22 = unit[2];
|
|
74071
74424
|
}
|
|
74072
74425
|
}
|
|
74073
|
-
return { ok: true, input: { line1, line2: line22, city, region: state.code, zip: zip[1] } };
|
|
74426
|
+
return { ok: true, input: { country: "US", line1, line2: line22, city, region: state.code, zip: zip[1] } };
|
|
74074
74427
|
}
|
|
74075
74428
|
|
|
74076
74429
|
// src/commands/card.ts
|
|
@@ -74099,15 +74452,16 @@ function fail5(opts, err) {
|
|
|
74099
74452
|
var NOT_SEALED = "this account is not sealed yet: `agentgates email seal` first, then save the address";
|
|
74100
74453
|
function addressInputOf(flags) {
|
|
74101
74454
|
const line2 = (flags.line ?? "").trim();
|
|
74455
|
+
const country = (flags.country ?? "").trim() || void 0;
|
|
74102
74456
|
if (line2) {
|
|
74103
|
-
const read = parseHomeAddress(line2);
|
|
74457
|
+
const read = parseHomeAddress(line2, country);
|
|
74104
74458
|
if (!read.ok) throw new MemoryError(read.why, "bad_address");
|
|
74105
74459
|
return read.input;
|
|
74106
74460
|
}
|
|
74107
|
-
return { line1: flags.line1 ?? "", line2: flags.line2 ?? "", city: flags.city ?? "", region: flags.state ?? "", zip: flags.zip ?? "" };
|
|
74461
|
+
return { country: country ?? "US", line1: flags.line1 ?? "", line2: flags.line2 ?? "", city: flags.city ?? "", region: flags.state ?? "", zip: flags.zip ?? "" };
|
|
74108
74462
|
}
|
|
74109
74463
|
function givesAddress(flags) {
|
|
74110
|
-
return [flags.line, flags.line1, flags.line2, flags.city, flags.state, flags.zip].some((v) => typeof v === "string" && v.trim() !== "");
|
|
74464
|
+
return [flags.line, flags.line1, flags.line2, flags.city, flags.state, flags.zip, flags.country].some((v) => typeof v === "string" && v.trim() !== "");
|
|
74111
74465
|
}
|
|
74112
74466
|
function checkedAddress(input) {
|
|
74113
74467
|
const built = homeAddressFrom(input);
|
|
@@ -74137,30 +74491,42 @@ async function readHomeAddressHere(wallet) {
|
|
|
74137
74491
|
return read.ok ? { ...base, address: read.address, note: null } : { ...base, address: null, note: `the saved address does not read: ${read.why}` };
|
|
74138
74492
|
}
|
|
74139
74493
|
var QUESTIONS = [
|
|
74494
|
+
{ field: "country", ask: "Country (enter for the United States)" },
|
|
74140
74495
|
{ field: "line1", ask: "Street address" },
|
|
74141
74496
|
{ field: "line2", ask: "Apartment, suite or unit", optional: true },
|
|
74142
74497
|
{ field: "city", ask: "City" },
|
|
74143
|
-
{ field: "region", ask: "State (two letters)" },
|
|
74144
|
-
{ field: "zip", ask: "ZIP code" }
|
|
74498
|
+
{ field: "region", ask: "State (two letters)", abroad: "Region" },
|
|
74499
|
+
{ field: "zip", ask: "ZIP code", abroad: "Postal code" }
|
|
74145
74500
|
];
|
|
74146
74501
|
async function askAddress() {
|
|
74147
74502
|
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
74148
|
-
const answers = { line1: "", line2: "", city: "", region: "", zip: "" };
|
|
74503
|
+
const answers = { country: "US", line1: "", line2: "", city: "", region: "", zip: "" };
|
|
74149
74504
|
try {
|
|
74150
74505
|
process.stdout.write(`
|
|
74151
74506
|
${import_picocolors15.default.bold("Your home address")} ${import_picocolors15.default.dim("\xB7 ether.fi asks it before the card; sealed on this machine")}
|
|
74152
74507
|
|
|
74153
74508
|
`);
|
|
74154
74509
|
for (const q of QUESTIONS) {
|
|
74510
|
+
const us = (countryOf(answers.country ?? "US")?.[0] ?? "US") === "US";
|
|
74155
74511
|
for (; ; ) {
|
|
74156
74512
|
let raw;
|
|
74157
74513
|
try {
|
|
74158
|
-
raw = await rl.question(` ${q.ask}${q.optional ? import_picocolors15.default.dim(" (enter to skip)") : ""}: `);
|
|
74514
|
+
raw = await rl.question(` ${!us && q.abroad ? q.abroad : q.ask}${q.optional ? import_picocolors15.default.dim(" (enter to skip)") : ""}: `);
|
|
74159
74515
|
} catch {
|
|
74160
74516
|
return null;
|
|
74161
74517
|
}
|
|
74162
|
-
|
|
74163
|
-
|
|
74518
|
+
if (q.field === "country") {
|
|
74519
|
+
const hit = countryOf(raw.trim() || "US");
|
|
74520
|
+
if (!hit) {
|
|
74521
|
+
process.stdout.write(` ${import_picocolors15.default.yellow(checkAddressField("country", raw))}
|
|
74522
|
+
`);
|
|
74523
|
+
continue;
|
|
74524
|
+
}
|
|
74525
|
+
answers.country = hit[0];
|
|
74526
|
+
break;
|
|
74527
|
+
}
|
|
74528
|
+
const value = q.field === "region" && us ? raw.trim().toUpperCase() : raw;
|
|
74529
|
+
const why = checkAddressField(q.field, value, answers.country ?? "US");
|
|
74164
74530
|
if (why) {
|
|
74165
74531
|
process.stdout.write(` ${import_picocolors15.default.yellow(why)}
|
|
74166
74532
|
`);
|
|
@@ -74201,7 +74567,7 @@ async function cardAddressSet(opts) {
|
|
|
74201
74567
|
return;
|
|
74202
74568
|
}
|
|
74203
74569
|
} else {
|
|
74204
|
-
throw new MemoryError('give the address: --line "1 Main St Apt 4, San Francisco, CA 94110", or --line1 --city --state --zip (--line2 optional)', "no_address");
|
|
74570
|
+
throw new MemoryError('give the address: --line "1 Main St Apt 4, San Francisco, CA 94110", or --line1 --city --state --zip (--line2 optional); outside the United States add --country (Chile, CL) with --state for the region and --zip for the postal code', "no_address");
|
|
74205
74571
|
}
|
|
74206
74572
|
const address = checkedAddress(input);
|
|
74207
74573
|
const { wallet } = await requirePasswordsKey();
|
|
@@ -74561,8 +74927,11 @@ function mcpTools() {
|
|
|
74561
74927
|
row: { type: "string", description: "the row id (passwords_list); default: the row whose hosts cover the url" },
|
|
74562
74928
|
use: { type: "string", enum: [...USE_KINDS], description: "default login" },
|
|
74563
74929
|
steps: { type: "array", description: "steps at the site after the sign-in (the lane's steps shape), for the login use" },
|
|
74930
|
+
workflow: { type: "string", description: "login only: a workflow the owner taught the VM on the row, by its name (passwords_list shows each row's workflows and the values they take); url may be left out" },
|
|
74931
|
+
inputs: { type: "object", additionalProperties: { type: "string" }, description: "the workflow's values by its own names; a value left out types what the owner typed" },
|
|
74564
74932
|
codeSteps: { type: "array", description: "steps to the page where the site's code is typed, for the login use" },
|
|
74565
74933
|
mailbox: { type: "string", description: "the mailbox row the sign-in code is read from, when the account has several" },
|
|
74934
|
+
solve: { type: "boolean", description: "login and session, the owner's own key: the VM passes a bot check it meets (Cloudflare, Turnstile, reCAPTCHA, hCaptcha). Under another owner's permit the use parks as check_pending and the owner answers on their board" },
|
|
74566
74935
|
useId: { type: "string", description: "continue a parked use" },
|
|
74567
74936
|
waitSeconds: { type: "integer", minimum: 0, maximum: WAIT_MAX_S, description: `how long to wait on a parked use or a starting VM (default ${WAIT_DEFAULT_S}; 0 returns the first answer)` }
|
|
74568
74937
|
},
|
|
@@ -74585,10 +74954,20 @@ function mcpTools() {
|
|
|
74585
74954
|
if (use !== "login" && use !== "session") throw new McpToolError("mailbox goes with the login or session use");
|
|
74586
74955
|
request.mailbox = mailbox;
|
|
74587
74956
|
}
|
|
74588
|
-
|
|
74589
|
-
|
|
74957
|
+
const workflow = str(args, "workflow");
|
|
74958
|
+
let workflowRow = null;
|
|
74959
|
+
if (workflow) {
|
|
74960
|
+
if (use !== "login") throw new McpToolError("workflow goes with the login use");
|
|
74961
|
+
if (Array.isArray(args.steps)) throw new McpToolError("workflow runs the owner's steps; steps are for your own");
|
|
74962
|
+
request.workflow = workflow;
|
|
74963
|
+
if (args.inputs && typeof args.inputs === "object" && !Array.isArray(args.inputs)) request.inputs = args.inputs;
|
|
74964
|
+
if (!str(args, "row")) workflowRow = (await rowForWorkflow(wallet, workflow)).id;
|
|
74965
|
+
}
|
|
74966
|
+
if (use !== "totp" && use !== "reveal" && !url && !workflow) throw new McpToolError("url is the https URL the use targets");
|
|
74967
|
+
const rowId = str(args, "row") ?? workflowRow ?? await rowForUrl(wallet, url);
|
|
74590
74968
|
const useId = str(args, "useId");
|
|
74591
|
-
|
|
74969
|
+
if (args.solve === true && use !== "login" && use !== "session") throw new McpToolError("solve goes with the login or session use");
|
|
74970
|
+
const firstBody = { use, request: use === "totp" && Object.keys(request).length === 0 ? void 0 : request, ...useId ? { useId } : {}, ...args.solve === true ? { solve: true } : {} };
|
|
74592
74971
|
const waitSeconds = int(args, "waitSeconds", WAIT_DEFAULT_S, 0, WAIT_MAX_S);
|
|
74593
74972
|
const answer = await postUseAndWait(wallet, rowId, firstBody, { waitSeconds, noWait: waitSeconds === 0, note });
|
|
74594
74973
|
const body = answer.body ?? {};
|
|
@@ -74835,23 +75214,24 @@ function mcpTools() {
|
|
|
74835
75214
|
// instead of inside the CVM. The street never comes back through here.
|
|
74836
75215
|
{
|
|
74837
75216
|
name: "card_address_set",
|
|
74838
|
-
description: "Save the person's home address for their Agentgates card (ether.fi asks it before the card). Only the address the person gave you, never one you guessed: it is checked against their ID. Pass it as one `line` (\"1 Main St Apt 4, San Francisco, CA 94110\") or as `line1`, `line2`, `city`, `state` (two letters) and `zip`.
|
|
75217
|
+
description: "Save the person's home address for their Agentgates card (ether.fi asks it before the card). Only the address the person gave you, never one you guessed: it is checked against their ID. Pass it as one `line` (\"1 Main St Apt 4, San Francisco, CA 94110\") or as `line1`, `line2`, `city`, `state` (two letters) and `zip`. Any country ether.fi issues the card in: give `country` (Chile, CL; the United States when left out), and abroad `state` is the region as written and `zip` the postal code. It is sealed on this machine to the account's own data key and stored as ciphertext; a second save replaces the first. Free.",
|
|
74839
75218
|
inputSchema: {
|
|
74840
75219
|
type: "object",
|
|
74841
75220
|
properties: {
|
|
74842
|
-
|
|
75221
|
+
country: { type: "string", description: "The country, by name or two letters (the United States when left out)." },
|
|
75222
|
+
line: { type: "string", description: "The whole address on one line: street, city, state ZIP (abroad: street, city, region, postal code)." },
|
|
74843
75223
|
line1: { type: "string", description: "Street address." },
|
|
74844
75224
|
line2: { type: "string", description: "Apartment, suite or unit (optional)." },
|
|
74845
75225
|
city: { type: "string", description: "City." },
|
|
74846
|
-
state: { type: "string", description: "The state's two letters (CA)." },
|
|
74847
|
-
zip: { type: "string", description: "ZIP code, five digits." }
|
|
75226
|
+
state: { type: "string", description: "The state's two letters (CA); abroad, the region as written." },
|
|
75227
|
+
zip: { type: "string", description: "ZIP code, five digits; abroad, the postal code." }
|
|
74848
75228
|
},
|
|
74849
75229
|
additionalProperties: false
|
|
74850
75230
|
},
|
|
74851
75231
|
handler: async (args) => {
|
|
74852
75232
|
let address;
|
|
74853
75233
|
try {
|
|
74854
|
-
address = checkedAddress(addressInputOf({ line: str(args, "line"), line1: str(args, "line1"), line2: str(args, "line2"), city: str(args, "city"), state: str(args, "state"), zip: str(args, "zip") }));
|
|
75234
|
+
address = checkedAddress(addressInputOf({ country: str(args, "country"), line: str(args, "line"), line1: str(args, "line1"), line2: str(args, "line2"), city: str(args, "city"), state: str(args, "state"), zip: str(args, "zip") }));
|
|
74855
75235
|
} catch (err) {
|
|
74856
75236
|
throw new McpToolError(err instanceof Error ? err.message : String(err));
|
|
74857
75237
|
}
|
|
@@ -75792,9 +76172,243 @@ async function intentsNoShow(askId, opts) {
|
|
|
75792
76172
|
}
|
|
75793
76173
|
}
|
|
75794
76174
|
|
|
76175
|
+
// src/commands/integrations.ts
|
|
76176
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
76177
|
+
init_passwords_wire();
|
|
76178
|
+
function emit10(opts, data4, human) {
|
|
76179
|
+
if (opts.json || !process.stdout.isTTY) {
|
|
76180
|
+
process.stdout.write(`${JSON.stringify(data4)}
|
|
76181
|
+
`);
|
|
76182
|
+
return;
|
|
76183
|
+
}
|
|
76184
|
+
human();
|
|
76185
|
+
}
|
|
76186
|
+
function fail6(opts, err) {
|
|
76187
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
76188
|
+
const code = err instanceof WireError ? err.code : err?.code;
|
|
76189
|
+
if (opts.json || !process.stdout.isTTY) {
|
|
76190
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: message, ...typeof code === "string" ? { code } : {} })}
|
|
76191
|
+
`);
|
|
76192
|
+
} else {
|
|
76193
|
+
process.stderr.write(`
|
|
76194
|
+
${import_picocolors18.default.red("\u2717")} ${message}
|
|
76195
|
+
|
|
76196
|
+
`);
|
|
76197
|
+
}
|
|
76198
|
+
process.exit(1);
|
|
76199
|
+
}
|
|
76200
|
+
var normalizeOwner2 = (owner) => /^0x[0-9a-fA-F]{40}$/.test(owner.trim()) ? owner.trim().toLowerCase() : owner.trim();
|
|
76201
|
+
function answerAad(owner, integrationId, kind) {
|
|
76202
|
+
return `AGENTGATES-INTEGRATION-v1|${kind}|${normalizeOwner2(owner)}|${integrationId}`;
|
|
76203
|
+
}
|
|
76204
|
+
var REGISTRATIONS = { github: "agentgates", vercel: "agentgates", neon: "api-key" };
|
|
76205
|
+
var isRegistration = (r) => REGISTRATIONS[r.provider] === r.app;
|
|
76206
|
+
function labelAad(owner, r) {
|
|
76207
|
+
return isRegistration(r) ? `AGENTGATES-INTEGRATION-v1|label|${normalizeOwner2(owner)}|${r.id}` : memoryLabelAad(owner, r.id);
|
|
76208
|
+
}
|
|
76209
|
+
var PROVIDER_NAMES = { github: "GitHub", vercel: "Vercel", neon: "Neon", "google-drive": "Google Drive", dropbox: "Dropbox", passwords: "Passwords" };
|
|
76210
|
+
function usedFor(r) {
|
|
76211
|
+
if (r.provider === "passwords") return r.hosts?.[0] ?? "";
|
|
76212
|
+
if (isRegistration(r)) return r.provider === "github" ? "edit access" : r.provider === "vercel" ? "your projects" : "your databases";
|
|
76213
|
+
return `${r.folders ?? 0} ${r.provider === "github" ? "repos" : "folders"} in Memory`;
|
|
76214
|
+
}
|
|
76215
|
+
async function integrationsList(opts) {
|
|
76216
|
+
try {
|
|
76217
|
+
const { wallet } = await requirePasswordsKey();
|
|
76218
|
+
const out = expectOk(await signedFetch(wallet, "GET", lanePath("/integrations")), "integrations");
|
|
76219
|
+
const key = await mailKeyFor(wallet).catch(() => null);
|
|
76220
|
+
const rows = (out.integrations ?? []).map((r) => {
|
|
76221
|
+
let label = r.name;
|
|
76222
|
+
if (!label && key && r.labelBlob) {
|
|
76223
|
+
try {
|
|
76224
|
+
label = openText(key.dataKey, r.labelBlob, labelAad(wallet.address, r));
|
|
76225
|
+
} catch {
|
|
76226
|
+
label = null;
|
|
76227
|
+
}
|
|
76228
|
+
}
|
|
76229
|
+
return { id: r.id, provider: r.provider, app: r.app, state: r.state, label, hosts: r.hosts, folders: r.folders };
|
|
76230
|
+
});
|
|
76231
|
+
emit10(opts, { ok: true, integrations: rows }, () => {
|
|
76232
|
+
if (rows.length === 0) {
|
|
76233
|
+
process.stdout.write(`
|
|
76234
|
+
Nothing connected. Connect on ${import_picocolors18.default.cyan("agentgates.ai/dashboard/user/integrations")}.
|
|
76235
|
+
|
|
76236
|
+
`);
|
|
76237
|
+
return;
|
|
76238
|
+
}
|
|
76239
|
+
process.stdout.write("\n");
|
|
76240
|
+
for (const r of rows) {
|
|
76241
|
+
const what = usedFor(r);
|
|
76242
|
+
process.stdout.write(` ${import_picocolors18.default.bold(PROVIDER_NAMES[r.provider] ?? r.provider)} ${r.label ?? ""} ${import_picocolors18.default.dim(r.state)} ${import_picocolors18.default.dim(what)}
|
|
76243
|
+
${import_picocolors18.default.dim(r.id)}
|
|
76244
|
+
|
|
76245
|
+
`);
|
|
76246
|
+
}
|
|
76247
|
+
});
|
|
76248
|
+
} catch (err) {
|
|
76249
|
+
fail6(opts, err);
|
|
76250
|
+
}
|
|
76251
|
+
}
|
|
76252
|
+
var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
76253
|
+
async function integrationsUse(integrationId, opts) {
|
|
76254
|
+
try {
|
|
76255
|
+
if (!/^[A-Za-z0-9_-]{1,64}$/.test(integrationId)) throw new Error("an integration id is 1 to 64 of A-Z a-z 0-9 _ -");
|
|
76256
|
+
const { wallet } = await requirePasswordsKey();
|
|
76257
|
+
const sealing = sealingKeyFromSignature(await wallet.signMessage(MAIL_SEAL_MESSAGE_V1));
|
|
76258
|
+
const door = opts.file ? "file" : "list";
|
|
76259
|
+
const waitMs = Math.max(0, Math.min(900, Number(opts.wait ?? "300"))) * 1e3;
|
|
76260
|
+
const deadline = Date.now() + waitMs;
|
|
76261
|
+
let useId = null;
|
|
76262
|
+
let told = false;
|
|
76263
|
+
for (; ; ) {
|
|
76264
|
+
const q = new URLSearchParams(door === "file" ? { fileId: opts.file } : { what: "folder", ...opts.folder ? { folderId: opts.folder } : {} });
|
|
76265
|
+
q.set("recipient", sealing.publicKey);
|
|
76266
|
+
if (useId) q.set("use", useId);
|
|
76267
|
+
const answer = await signedFetch(wallet, "GET", lanePath(`/integrations/${integrationId}/${door}?${q.toString()}`));
|
|
76268
|
+
if (answer.status === 202) {
|
|
76269
|
+
const use = answer.body?.use ?? {};
|
|
76270
|
+
useId = typeof use.id === "string" ? use.id : useId;
|
|
76271
|
+
if (!told && !(opts.json || !process.stdout.isTTY)) {
|
|
76272
|
+
process.stdout.write(`
|
|
76273
|
+
${import_picocolors18.default.yellow("\u2026")} waiting for the owner to allow this read on their board
|
|
76274
|
+
`);
|
|
76275
|
+
told = true;
|
|
76276
|
+
}
|
|
76277
|
+
if (Date.now() >= deadline) {
|
|
76278
|
+
emit10(opts, { ok: false, code: "approval_pending", use: answer.body?.use ?? null }, () => process.stdout.write(` still waiting; run it again with the same arguments to keep waiting
|
|
76279
|
+
|
|
76280
|
+
`));
|
|
76281
|
+
process.exit(2);
|
|
76282
|
+
}
|
|
76283
|
+
await sleep2(3e3);
|
|
76284
|
+
continue;
|
|
76285
|
+
}
|
|
76286
|
+
const body = expectOk(answer, `integration ${door}`);
|
|
76287
|
+
const owner = typeof body.owner === "string" ? body.owner : "";
|
|
76288
|
+
if (door === "file") {
|
|
76289
|
+
const file = JSON.parse(openText(sealing.secret, String(body.fileBlob), answerAad(owner, integrationId, "file-answer")));
|
|
76290
|
+
emit10(opts, { ok: true, name: file.name, text: file.text }, () => process.stdout.write(`${file.text}${file.text.endsWith("\n") ? "" : "\n"}`));
|
|
76291
|
+
return;
|
|
76292
|
+
}
|
|
76293
|
+
const listing = JSON.parse(openText(sealing.secret, String(body.listBlob), answerAad(owner, integrationId, "list-answer")));
|
|
76294
|
+
emit10(opts, { ok: true, ...listing.what ? { what: listing.what } : {}, entries: listing.entries }, () => {
|
|
76295
|
+
process.stdout.write("\n");
|
|
76296
|
+
if (listing.entries.length === 0) process.stdout.write(` ${import_picocolors18.default.dim(listing.what === "projects" ? "no projects this connection reaches" : "nothing here that the owner picked")}
|
|
76297
|
+
`);
|
|
76298
|
+
for (const e of listing.entries) {
|
|
76299
|
+
if (listing.what === "projects") process.stdout.write(` ${import_picocolors18.default.bold(e.name)} ${import_picocolors18.default.dim(e.repo?.fullName ?? e.url ?? "")} ${import_picocolors18.default.dim(e.id)}
|
|
76300
|
+
`);
|
|
76301
|
+
else process.stdout.write(` ${e.kind === "folder" ? import_picocolors18.default.cyan(`${e.name}/`) : e.name} ${import_picocolors18.default.dim(e.id)}
|
|
76302
|
+
`);
|
|
76303
|
+
}
|
|
76304
|
+
process.stdout.write("\n");
|
|
76305
|
+
});
|
|
76306
|
+
return;
|
|
76307
|
+
}
|
|
76308
|
+
} catch (err) {
|
|
76309
|
+
fail6(opts, err);
|
|
76310
|
+
}
|
|
76311
|
+
}
|
|
76312
|
+
async function integrationsSignup(provider, opts) {
|
|
76313
|
+
try {
|
|
76314
|
+
const { wallet } = await requirePasswordsKey();
|
|
76315
|
+
const id2 = Buffer.from(crypto.getRandomValues(new Uint8Array(16))).toString("base64url");
|
|
76316
|
+
const answer = await signedFetch(wallet, "POST", lanePath("/integrations/signup"), { id: id2, provider, ...opts.inbox ? { inboxId: opts.inbox } : {} });
|
|
76317
|
+
if (answer.status !== 202) expectOk(answer, "integrations signup");
|
|
76318
|
+
const r = answer.body?.integration;
|
|
76319
|
+
const facts = answer.body?.signup;
|
|
76320
|
+
emit10(opts, { ok: true, id: r?.id, signupId: facts?.source?.id ?? null, inbox: facts?.source?.address ?? null, provider, state: r?.state }, () => {
|
|
76321
|
+
process.stdout.write(`
|
|
76322
|
+
${import_picocolors18.default.bold(PROVIDER_NAMES[provider] ?? provider)} account signup opened: ${import_picocolors18.default.dim(r?.id ?? "")}
|
|
76323
|
+
Inbox: ${import_picocolors18.default.cyan(facts?.source?.address ?? "?")}
|
|
76324
|
+
|
|
76325
|
+
`);
|
|
76326
|
+
});
|
|
76327
|
+
} catch (err) {
|
|
76328
|
+
fail6(opts, err);
|
|
76329
|
+
}
|
|
76330
|
+
}
|
|
76331
|
+
async function integrationsSignupReport(signupId, opts) {
|
|
76332
|
+
try {
|
|
76333
|
+
const { wallet } = await requirePasswordsKey();
|
|
76334
|
+
const answer = await signedFetch(wallet, "POST", lanePath(`/integrations/signup/${encodeURIComponent(signupId)}/report`), { loginId: opts.loginId });
|
|
76335
|
+
expectOk(answer, "integrations signup report");
|
|
76336
|
+
emit10(opts, { ok: true, id: answer.body?.integration?.id, loginId: opts.loginId ?? null }, () => {
|
|
76337
|
+
process.stdout.write(`
|
|
76338
|
+
Reported.${opts.loginId ? ` Login row: ${import_picocolors18.default.dim(opts.loginId)}.` : ""}
|
|
76339
|
+
|
|
76340
|
+
`);
|
|
76341
|
+
});
|
|
76342
|
+
} catch (err) {
|
|
76343
|
+
fail6(opts, err);
|
|
76344
|
+
}
|
|
76345
|
+
}
|
|
76346
|
+
async function integrationsSignupHandoff(signupId, provider, opts) {
|
|
76347
|
+
try {
|
|
76348
|
+
const { wallet } = await requirePasswordsKey();
|
|
76349
|
+
const body = { provider };
|
|
76350
|
+
if (opts.code) body.code = opts.code;
|
|
76351
|
+
if (opts.installationId) body.installationId = opts.installationId;
|
|
76352
|
+
if (opts.setupAction) body.setupAction = opts.setupAction;
|
|
76353
|
+
if (opts.configurationId) body.configurationId = opts.configurationId;
|
|
76354
|
+
if (opts.teamId) body.teamId = opts.teamId;
|
|
76355
|
+
if (opts.redirectUri) body.redirectUri = opts.redirectUri;
|
|
76356
|
+
if (opts.sealed) body.sealed = JSON.parse(await (await import("node:fs/promises")).readFile(opts.sealed, "utf8"));
|
|
76357
|
+
else if (opts.grantCvm && opts.cvmKeyId) body.sealed = { grantCvm: opts.grantCvm, cvmKeyId: opts.cvmKeyId };
|
|
76358
|
+
const answer = await signedFetch(wallet, "POST", lanePath(`/integrations/signup/${encodeURIComponent(signupId)}/handoff`), body);
|
|
76359
|
+
expectOk(answer, "integrations signup handoff");
|
|
76360
|
+
const r = answer.body?.integration;
|
|
76361
|
+
emit10(opts, { ok: true, id: r?.id, state: r?.state, accountId: r ? r.accountId ?? null : null }, () => {
|
|
76362
|
+
process.stdout.write(`
|
|
76363
|
+
Connected: ${import_picocolors18.default.green(r?.state ?? "?")} ${import_picocolors18.default.dim(r?.id ?? "")}
|
|
76364
|
+
|
|
76365
|
+
`);
|
|
76366
|
+
});
|
|
76367
|
+
} catch (err) {
|
|
76368
|
+
fail6(opts, err);
|
|
76369
|
+
}
|
|
76370
|
+
}
|
|
76371
|
+
async function sitesList(opts) {
|
|
76372
|
+
try {
|
|
76373
|
+
const { wallet } = await requirePasswordsKey();
|
|
76374
|
+
const out = expectOk(await signedFetch(wallet, "GET", lanePath("/sites")), "sites");
|
|
76375
|
+
const key = await mailKeyFor(wallet).catch(() => null);
|
|
76376
|
+
const rows = (out.apps ?? []).map((a) => {
|
|
76377
|
+
let label = null;
|
|
76378
|
+
if (key && a.labelBlob) {
|
|
76379
|
+
try {
|
|
76380
|
+
label = JSON.parse(openText(key.dataKey, a.labelBlob, `AGENTGATES-APPS-v1|app-label|${normalizeOwner2(wallet.address)}|${a.id}`));
|
|
76381
|
+
} catch {
|
|
76382
|
+
label = null;
|
|
76383
|
+
}
|
|
76384
|
+
}
|
|
76385
|
+
return { id: a.id, state: a.state, code: a.code, name: label?.name ?? null, repo: label?.repo ?? null, url: label?.url ?? null, vercelProjectId: a.vercelProjectId };
|
|
76386
|
+
});
|
|
76387
|
+
emit10(opts, { ok: true, sites: rows }, () => {
|
|
76388
|
+
if (rows.length === 0) {
|
|
76389
|
+
process.stdout.write(`
|
|
76390
|
+
No site connected. Connect one from Vercel on ${import_picocolors18.default.cyan("agentgates.ai/dashboard/user/integrations")}.
|
|
76391
|
+
|
|
76392
|
+
`);
|
|
76393
|
+
return;
|
|
76394
|
+
}
|
|
76395
|
+
process.stdout.write("\n");
|
|
76396
|
+
for (const r of rows) {
|
|
76397
|
+
const state = r.state === "ready" ? import_picocolors18.default.green("ready") : import_picocolors18.default.yellow(r.code ?? r.state);
|
|
76398
|
+
process.stdout.write(` ${import_picocolors18.default.bold(r.name ?? r.vercelProjectId ?? r.id)} ${state} ${import_picocolors18.default.dim(r.repo ?? "")} ${import_picocolors18.default.dim(r.url ?? "")}
|
|
76399
|
+
${import_picocolors18.default.dim(r.id)}
|
|
76400
|
+
|
|
76401
|
+
`);
|
|
76402
|
+
}
|
|
76403
|
+
});
|
|
76404
|
+
} catch (err) {
|
|
76405
|
+
fail6(opts, err);
|
|
76406
|
+
}
|
|
76407
|
+
}
|
|
76408
|
+
|
|
75795
76409
|
// src/commands/agent.ts
|
|
75796
76410
|
init_lib2();
|
|
75797
|
-
var
|
|
76411
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
75798
76412
|
init_passwords_wire();
|
|
75799
76413
|
|
|
75800
76414
|
// src/lib/ag-wire.ts
|
|
@@ -75832,6 +76446,7 @@ function conversationTurnAad(owner, conversationId, seq, role, origin) {
|
|
|
75832
76446
|
// src/lib/ag-wire.ts
|
|
75833
76447
|
init_passwords_wire();
|
|
75834
76448
|
init_tdx_attestation();
|
|
76449
|
+
init_cvm_approved();
|
|
75835
76450
|
var AG_SEAL_SUITE = "AGENTGATES-AG-v1";
|
|
75836
76451
|
var AG_REPORT_DATA_LABEL = "agentgates/ag/fleet-key/v1";
|
|
75837
76452
|
var AG_JOURNAL_LANE = "agent";
|
|
@@ -75878,7 +76493,7 @@ function isLoopbackOrigin(origin) {
|
|
|
75878
76493
|
return false;
|
|
75879
76494
|
}
|
|
75880
76495
|
}
|
|
75881
|
-
function verifyAgFleetAttestation(body, opts
|
|
76496
|
+
function verifyAgFleetAttestation(body, opts) {
|
|
75882
76497
|
const parsed = parseAgAttestation(body);
|
|
75883
76498
|
if (!parsed.ok) return { ok: false, reason: parsed.error };
|
|
75884
76499
|
const att = parsed.attestation;
|
|
@@ -75891,6 +76506,7 @@ function verifyAgFleetAttestation(body, opts = {}) {
|
|
|
75891
76506
|
eventLog: body.eventLog,
|
|
75892
76507
|
expectedReportData: Buffer.from(fleetBindingReportData(att.publicKey), "hex"),
|
|
75893
76508
|
pinnedAppId: opts.pinnedAppId ?? AG_FLEET_APP_ID,
|
|
76509
|
+
approvedComposeHashes: opts.approved,
|
|
75894
76510
|
now: opts.now
|
|
75895
76511
|
});
|
|
75896
76512
|
if (!proof.ok) return proof;
|
|
@@ -75908,7 +76524,14 @@ async function readAgAttestation() {
|
|
|
75908
76524
|
}
|
|
75909
76525
|
const body = await res.json().catch(() => null);
|
|
75910
76526
|
if (!res.ok) throw new WireError(res.status, typeof body?.code === "string" ? body.code : null, typeof body?.error === "string" ? body.error : `the attestation door answered ${res.status}`, body);
|
|
75911
|
-
|
|
76527
|
+
let approved;
|
|
76528
|
+
try {
|
|
76529
|
+
approved = await approvedComposeHashes(AG_FLEET_APP_ID, siteOrigin());
|
|
76530
|
+
} catch (err) {
|
|
76531
|
+
if (err instanceof ApprovedListError) throw new WireError(0, err.code, err.message, null);
|
|
76532
|
+
throw err;
|
|
76533
|
+
}
|
|
76534
|
+
const proven = verifyAgFleetAttestation(body, { approved });
|
|
75912
76535
|
if (!proven.ok) throw new WireError(0, "box_unproven", `the AG AI box did not prove itself (${proven.reason}), so nothing was sealed`, null);
|
|
75913
76536
|
return proven.value;
|
|
75914
76537
|
}
|
|
@@ -75978,7 +76601,7 @@ async function revokeBinding(wallet, id2) {
|
|
|
75978
76601
|
}
|
|
75979
76602
|
|
|
75980
76603
|
// src/commands/agent.ts
|
|
75981
|
-
function
|
|
76604
|
+
function emit11(opts, data4, human) {
|
|
75982
76605
|
if (opts.json || !process.stdout.isTTY) {
|
|
75983
76606
|
process.stdout.write(`${JSON.stringify(data4)}
|
|
75984
76607
|
`);
|
|
@@ -75986,7 +76609,7 @@ function emit10(opts, data4, human) {
|
|
|
75986
76609
|
}
|
|
75987
76610
|
human();
|
|
75988
76611
|
}
|
|
75989
|
-
function
|
|
76612
|
+
function fail7(opts, err) {
|
|
75990
76613
|
const message = err instanceof Error ? err.message : String(err);
|
|
75991
76614
|
const code = err?.code;
|
|
75992
76615
|
if (opts.json || !process.stdout.isTTY) {
|
|
@@ -75994,7 +76617,7 @@ function fail6(opts, err) {
|
|
|
75994
76617
|
`);
|
|
75995
76618
|
} else {
|
|
75996
76619
|
process.stderr.write(`
|
|
75997
|
-
${
|
|
76620
|
+
${import_picocolors19.default.red("\u2717")} ${message}
|
|
75998
76621
|
|
|
75999
76622
|
`);
|
|
76000
76623
|
}
|
|
@@ -76004,10 +76627,10 @@ function short2(address) {
|
|
|
76004
76627
|
return `${address.slice(0, 6)}\u2026${address.slice(-4)}`;
|
|
76005
76628
|
}
|
|
76006
76629
|
function agentLine(agent2) {
|
|
76007
|
-
if (!agent2 || agent2.state !== "on") return
|
|
76630
|
+
if (!agent2 || agent2.state !== "on") return import_picocolors19.default.dim("off");
|
|
76008
76631
|
const reach = agent2.reach;
|
|
76009
76632
|
const where = [reach?.number, reach?.address].filter(Boolean).join(" ");
|
|
76010
|
-
return `${
|
|
76633
|
+
return `${import_picocolors19.default.bold(short2(agent2.agentAddress))} ${import_picocolors19.default.dim("pays from your balance")}${where ? ` ${import_picocolors19.default.dim(where)}` : ""}`;
|
|
76011
76634
|
}
|
|
76012
76635
|
function sendTo(channel, to) {
|
|
76013
76636
|
const target = channel === "sms" ? to.house?.number ?? to.number : to.address;
|
|
@@ -76016,33 +76639,33 @@ function sendTo(channel, to) {
|
|
|
76016
76639
|
}
|
|
76017
76640
|
function bindingLine(b2, to) {
|
|
76018
76641
|
if (b2.channel === "telegram" || b2.channel === "whatsapp") {
|
|
76019
|
-
const state2 = b2.bound ?
|
|
76020
|
-
return ` ${
|
|
76642
|
+
const state2 = b2.bound ? import_picocolors19.default.green("bound") : b2.expired ? import_picocolors19.default.dim(`the link lapsed: agentgates agent bind ${b2.channel}`) : import_picocolors19.default.dim(`link open until ${(b2.expiresAt ?? "").slice(11, 16)} UTC`);
|
|
76643
|
+
return ` ${import_picocolors19.default.dim(b2.id)} ${b2.channel} ${b2.senderId ?? ""} ${state2}`;
|
|
76021
76644
|
}
|
|
76022
76645
|
if (b2.confirm && !b2.bound) {
|
|
76023
|
-
const state2 = b2.expired ?
|
|
76024
|
-
return ` ${
|
|
76646
|
+
const state2 = b2.expired ? import_picocolors19.default.dim(`the link lapsed: agentgates agent bind mail ${b2.senderId}`) : import_picocolors19.default.dim(`check its mail for the link, until ${(b2.expiresAt ?? "").slice(11, 16)} UTC`);
|
|
76647
|
+
return ` ${import_picocolors19.default.dim(b2.id)} ${b2.channel} ${b2.senderId} ${state2}`;
|
|
76025
76648
|
}
|
|
76026
|
-
if (b2.bound && b2.channel === "mail" && to.house?.mail) return ` ${
|
|
76027
|
-
const state = b2.bound ?
|
|
76028
|
-
return ` ${
|
|
76649
|
+
if (b2.bound && b2.channel === "mail" && to.house?.mail) return ` ${import_picocolors19.default.dim(b2.id)} mail ${b2.senderId} ${import_picocolors19.default.green("bound")} ${import_picocolors19.default.dim(`write to ${to.house.mail}`)}`;
|
|
76650
|
+
const state = b2.bound ? import_picocolors19.default.green("bound") : b2.code ? `${import_picocolors19.default.bold(b2.code)} ${import_picocolors19.default.dim(sendTo(b2.channel, to))}` : import_picocolors19.default.dim("open");
|
|
76651
|
+
return ` ${import_picocolors19.default.dim(b2.id)} ${b2.channel} ${b2.senderId} ${state}`;
|
|
76029
76652
|
}
|
|
76030
76653
|
async function agentStatus(opts) {
|
|
76031
76654
|
try {
|
|
76032
76655
|
const { wallet } = await requirePasswordsKey();
|
|
76033
76656
|
const read = await readAgent(wallet);
|
|
76034
|
-
|
|
76657
|
+
emit11(opts, { ok: true, ...read }, () => {
|
|
76035
76658
|
process.stdout.write(`
|
|
76036
76659
|
your agent: ${agentLine(read.agent)}
|
|
76037
76660
|
`);
|
|
76038
|
-
if (read.agent?.state === "on") process.stdout.write(` ${
|
|
76661
|
+
if (read.agent?.state === "on") process.stdout.write(` ${import_picocolors19.default.dim(`address ${read.agent.agentAddress}`)}
|
|
76039
76662
|
`);
|
|
76040
|
-
if (!read.fleet.keyPublished) process.stdout.write(` ${
|
|
76663
|
+
if (!read.fleet.keyPublished) process.stdout.write(` ${import_picocolors19.default.dim("the AG AI CVM has not published its key on this deployment yet")}
|
|
76041
76664
|
`);
|
|
76042
76665
|
process.stdout.write("\n");
|
|
76043
76666
|
});
|
|
76044
76667
|
} catch (err) {
|
|
76045
|
-
|
|
76668
|
+
fail7(opts, err);
|
|
76046
76669
|
}
|
|
76047
76670
|
}
|
|
76048
76671
|
async function agentOn(opts) {
|
|
@@ -76067,14 +76690,14 @@ async function agentOn(opts) {
|
|
|
76067
76690
|
const memoryKeyBoxBlob = sealText(fleet.publicKey, JSON.stringify({ wire: made.key, reading }), agMemoryKeyAad(wallet.address, made.created.id));
|
|
76068
76691
|
const out = await postAgentOn(wallet, { agentAddress: agent2.address, keyOwnerBlob, keyBoxBlob, memoryKeyId: made.created.id, memoryKeyBoxBlob });
|
|
76069
76692
|
const note2 = opts.fund !== void 0 ? AGENT_PAYS_SENTENCE : null;
|
|
76070
|
-
|
|
76693
|
+
emit11(opts, { ok: true, agent: out.agent, memoryKeyId: made.created.id, fleet: { mode: fleet.mode, keyId: fleet.keyId }, ...note2 ? { note: note2 } : {} }, () => {
|
|
76071
76694
|
process.stdout.write(
|
|
76072
76695
|
`
|
|
76073
|
-
${
|
|
76074
|
-
${
|
|
76075
|
-
` + (note2 ? ` ${
|
|
76076
|
-
` : "") + ` ${
|
|
76077
|
-
${
|
|
76696
|
+
${import_picocolors19.default.green("\u2713")} your agent is on: ${import_picocolors19.default.bold(agent2.address)}, paying from your balance
|
|
76697
|
+
${import_picocolors19.default.dim(`its key is sealed to you and to the CVM (${fleet.mode}, key ${fleet.keyId.slice(0, 12)}\u2026); its Memory key is ${made.created.prefix}`)}
|
|
76698
|
+
` + (note2 ? ` ${import_picocolors19.default.dim(note2)}
|
|
76699
|
+
` : "") + ` ${import_picocolors19.default.dim(`agentgates passwords allow --agent ${agent2.address} \u2026 \xB7 lets it use your saved logins`)}
|
|
76700
|
+
${import_picocolors19.default.dim('agentgates agent say "\u2026" \xB7 tells it what to do')}
|
|
76078
76701
|
|
|
76079
76702
|
`
|
|
76080
76703
|
);
|
|
@@ -76084,7 +76707,7 @@ async function agentOn(opts) {
|
|
|
76084
76707
|
throw err;
|
|
76085
76708
|
}
|
|
76086
76709
|
} catch (err) {
|
|
76087
|
-
|
|
76710
|
+
fail7(opts, err);
|
|
76088
76711
|
}
|
|
76089
76712
|
}
|
|
76090
76713
|
async function agentOff(opts) {
|
|
@@ -76099,37 +76722,37 @@ async function agentOff(opts) {
|
|
|
76099
76722
|
revokedKey = before.agent.memoryKeyId;
|
|
76100
76723
|
}).catch(() => void 0);
|
|
76101
76724
|
}
|
|
76102
|
-
|
|
76725
|
+
emit11(opts, { ok: true, agent: out.agent, sweptBackUsd: out.sweptBackUsd, revokedKey }, () => {
|
|
76103
76726
|
const swept = Number(out.sweptBackUsd) > 0 ? `$${out.sweptBackUsd} it held came back to your balance` : "";
|
|
76104
76727
|
const said = [swept, revokedKey ? "its Memory key is revoked" : ""].filter(Boolean).join("; ");
|
|
76105
76728
|
process.stdout.write(`
|
|
76106
|
-
${
|
|
76107
|
-
${
|
|
76729
|
+
${import_picocolors19.default.green("\u2713")} your agent is off.${said ? ` ${import_picocolors19.default.dim(`${said}.`)}` : ""}
|
|
76730
|
+
${import_picocolors19.default.dim("agentgates passwords permits \xB7 shows any permit still standing for it")}
|
|
76108
76731
|
|
|
76109
76732
|
`);
|
|
76110
76733
|
});
|
|
76111
76734
|
} catch (err) {
|
|
76112
|
-
|
|
76735
|
+
fail7(opts, err);
|
|
76113
76736
|
}
|
|
76114
76737
|
}
|
|
76115
76738
|
async function agentFund(_amountUsd, opts) {
|
|
76116
|
-
|
|
76739
|
+
fail7(opts, agentPaysRefusal());
|
|
76117
76740
|
}
|
|
76118
76741
|
async function agentRefill(_action, opts) {
|
|
76119
|
-
|
|
76742
|
+
fail7(opts, agentPaysRefusal());
|
|
76120
76743
|
}
|
|
76121
76744
|
async function agentSay(text, opts) {
|
|
76122
76745
|
try {
|
|
76123
76746
|
const { wallet } = await requirePasswordsKey();
|
|
76124
76747
|
const said = await sayToAgent(wallet, text);
|
|
76125
|
-
|
|
76748
|
+
emit11(opts, { ok: true, ...said }, () => {
|
|
76126
76749
|
process.stdout.write(`
|
|
76127
|
-
${
|
|
76750
|
+
${import_picocolors19.default.green("\u2713")} sent${said.woke ? "" : " (the CVM was not woken; the sweep will)"}. ${import_picocolors19.default.dim("agentgates agent journal \xB7 reads the thread")}
|
|
76128
76751
|
|
|
76129
76752
|
`);
|
|
76130
76753
|
});
|
|
76131
76754
|
} catch (err) {
|
|
76132
|
-
|
|
76755
|
+
fail7(opts, err);
|
|
76133
76756
|
}
|
|
76134
76757
|
}
|
|
76135
76758
|
async function agentJournal(opts) {
|
|
@@ -76140,25 +76763,25 @@ async function agentJournal(opts) {
|
|
|
76140
76763
|
const tail = Number.parseInt(opts.tail ?? "40", 10);
|
|
76141
76764
|
const { owner, conversationId, rows } = await readAgentThread(wallet, Number.isFinite(tail) && tail > 0 ? tail : 40);
|
|
76142
76765
|
const lines = conversationId ? rows.map((r) => openAgentThreadRow(key.dataKey, owner, conversationId, r)) : [];
|
|
76143
|
-
|
|
76766
|
+
emit11(opts, { ok: true, lane: AG_JOURNAL_LANE, conversationId, lines }, () => {
|
|
76144
76767
|
if (lines.length === 0) {
|
|
76145
76768
|
process.stdout.write(`
|
|
76146
|
-
${
|
|
76769
|
+
${import_picocolors19.default.dim("nothing in the thread yet")}
|
|
76147
76770
|
|
|
76148
76771
|
`);
|
|
76149
76772
|
return;
|
|
76150
76773
|
}
|
|
76151
76774
|
process.stdout.write("\n");
|
|
76152
76775
|
for (const l of lines) {
|
|
76153
|
-
const who = l.who === "agent" ?
|
|
76154
|
-
const via = l.channel && l.channel !== "site" && l.who !== "act" ?
|
|
76155
|
-
process.stdout.write(` ${
|
|
76776
|
+
const who = l.who === "agent" ? import_picocolors19.default.bold("agent") : l.who === "act" ? import_picocolors19.default.dim("act") : "you";
|
|
76777
|
+
const via = l.channel && l.channel !== "site" && l.who !== "act" ? import_picocolors19.default.dim(` (${l.channel})`) : "";
|
|
76778
|
+
process.stdout.write(` ${import_picocolors19.default.dim(l.at.slice(11, 16))} ${who}${via} ${l.words ?? import_picocolors19.default.dim("(does not open with this key)")}
|
|
76156
76779
|
`);
|
|
76157
76780
|
}
|
|
76158
76781
|
process.stdout.write("\n");
|
|
76159
76782
|
});
|
|
76160
76783
|
} catch (err) {
|
|
76161
|
-
|
|
76784
|
+
fail7(opts, err);
|
|
76162
76785
|
}
|
|
76163
76786
|
}
|
|
76164
76787
|
async function agentBind(channel, senderId, opts) {
|
|
@@ -76169,10 +76792,10 @@ async function agentBind(channel, senderId, opts) {
|
|
|
76169
76792
|
if (runsOnKeyOnly()) throw new WireError(401, "words_required", "binding a sender takes the account's words, and this machine runs on a key alone: run it where the words are", null);
|
|
76170
76793
|
if (channel === "telegram") {
|
|
76171
76794
|
const link = await mintTelegramLink(wallet);
|
|
76172
|
-
|
|
76795
|
+
emit11(opts, { ok: true, ...link }, () => {
|
|
76173
76796
|
process.stdout.write(`
|
|
76174
|
-
${
|
|
76175
|
-
${
|
|
76797
|
+
${import_picocolors19.default.green("\u2713")} open this in your Telegram and press Start: ${import_picocolors19.default.bold(link.link)}
|
|
76798
|
+
${import_picocolors19.default.dim(`It works once, until ${link.expiresAt.slice(11, 16)} UTC. Then write to @${link.to.telegram ?? "the bot"} to reach your agent.`)}
|
|
76176
76799
|
|
|
76177
76800
|
`);
|
|
76178
76801
|
});
|
|
@@ -76180,21 +76803,21 @@ async function agentBind(channel, senderId, opts) {
|
|
|
76180
76803
|
}
|
|
76181
76804
|
if (channel === "whatsapp") {
|
|
76182
76805
|
const link = await mintWhatsAppLink(wallet);
|
|
76183
|
-
|
|
76806
|
+
emit11(opts, { ok: true, ...link }, () => {
|
|
76184
76807
|
process.stdout.write(`
|
|
76185
|
-
${
|
|
76186
|
-
${
|
|
76808
|
+
${import_picocolors19.default.green("\u2713")} open this on your phone and press send: ${import_picocolors19.default.bold(link.link)}
|
|
76809
|
+
${import_picocolors19.default.dim(`It works once, until ${link.expiresAt.slice(11, 16)} UTC. Then write to ${link.to.whatsapp ?? "the house number"} on WhatsApp to reach your agent.`)}
|
|
76187
76810
|
|
|
76188
76811
|
`);
|
|
76189
76812
|
});
|
|
76190
76813
|
return;
|
|
76191
76814
|
}
|
|
76192
76815
|
const out = await mintBinding(wallet, channel, senderId);
|
|
76193
|
-
|
|
76816
|
+
emit11(opts, { ok: true, ...out }, () => {
|
|
76194
76817
|
const b2 = out.binding;
|
|
76195
76818
|
if (b2.bound) {
|
|
76196
76819
|
process.stdout.write(`
|
|
76197
|
-
${
|
|
76820
|
+
${import_picocolors19.default.green("\u2713")} ${b2.senderId} is already bound to this agent.
|
|
76198
76821
|
|
|
76199
76822
|
`);
|
|
76200
76823
|
return;
|
|
@@ -76202,33 +76825,33 @@ async function agentBind(channel, senderId, opts) {
|
|
|
76202
76825
|
if (b2.confirm) {
|
|
76203
76826
|
const house = out.to.house?.mail ?? "the house address";
|
|
76204
76827
|
process.stdout.write(out.sent ? `
|
|
76205
|
-
${
|
|
76206
|
-
${
|
|
76828
|
+
${import_picocolors19.default.green("\u2713")} a link went to ${b2.senderId} from ${house}: open it and press Confirm.
|
|
76829
|
+
${import_picocolors19.default.dim(`It works once, until ${(b2.expiresAt ?? "").slice(11, 16)} UTC. Then write to ${house} from that address to reach your agent.`)}
|
|
76207
76830
|
|
|
76208
76831
|
` : `
|
|
76209
|
-
${
|
|
76832
|
+
${import_picocolors19.default.green("\u2713")} a link went to ${b2.senderId} a moment ago: check its mail and press Confirm.
|
|
76210
76833
|
|
|
76211
76834
|
`);
|
|
76212
76835
|
return;
|
|
76213
76836
|
}
|
|
76214
76837
|
process.stdout.write(`
|
|
76215
|
-
${
|
|
76216
|
-
${
|
|
76838
|
+
${import_picocolors19.default.green("\u2713")} code ${import_picocolors19.default.bold(b2.code ?? "")} for ${b2.senderId}: ${sendTo(channel, out.to)}.
|
|
76839
|
+
${import_picocolors19.default.dim("Until the code arrives from that " + (channel === "sms" ? "number" : "address") + ", its messages land nothing and get one line back.")}
|
|
76217
76840
|
|
|
76218
76841
|
`);
|
|
76219
76842
|
});
|
|
76220
76843
|
} catch (err) {
|
|
76221
|
-
|
|
76844
|
+
fail7(opts, err);
|
|
76222
76845
|
}
|
|
76223
76846
|
}
|
|
76224
76847
|
async function agentBindings(opts) {
|
|
76225
76848
|
try {
|
|
76226
76849
|
const { wallet } = await requirePasswordsKey();
|
|
76227
76850
|
const read = await listBindings(wallet);
|
|
76228
|
-
|
|
76851
|
+
emit11(opts, { ok: true, ...read }, () => {
|
|
76229
76852
|
if (read.bindings.length === 0) {
|
|
76230
76853
|
process.stdout.write(`
|
|
76231
|
-
${
|
|
76854
|
+
${import_picocolors19.default.dim("nobody is bound yet")} ${import_picocolors19.default.dim("agentgates agent bind sms <number> | mail <address> | telegram | whatsapp")}
|
|
76232
76855
|
|
|
76233
76856
|
`);
|
|
76234
76857
|
return;
|
|
@@ -76239,7 +76862,7 @@ async function agentBindings(opts) {
|
|
|
76239
76862
|
process.stdout.write("\n");
|
|
76240
76863
|
});
|
|
76241
76864
|
} catch (err) {
|
|
76242
|
-
|
|
76865
|
+
fail7(opts, err);
|
|
76243
76866
|
}
|
|
76244
76867
|
}
|
|
76245
76868
|
async function agentUnbind(id2, opts) {
|
|
@@ -76247,28 +76870,28 @@ async function agentUnbind(id2, opts) {
|
|
|
76247
76870
|
const { wallet } = await requirePasswordsKey();
|
|
76248
76871
|
if (runsOnKeyOnly()) throw new WireError(401, "words_required", "unbinding a sender takes the account's words, and this machine runs on a key alone: run it where the words are", null);
|
|
76249
76872
|
await revokeBinding(wallet, id2);
|
|
76250
|
-
|
|
76873
|
+
emit11(opts, { ok: true, revoked: id2 }, () => {
|
|
76251
76874
|
process.stdout.write(`
|
|
76252
|
-
${
|
|
76875
|
+
${import_picocolors19.default.green("\u2713")} ${id2} is revoked; that sender is a stranger to the agent again.
|
|
76253
76876
|
|
|
76254
76877
|
`);
|
|
76255
76878
|
});
|
|
76256
76879
|
} catch (err) {
|
|
76257
|
-
|
|
76880
|
+
fail7(opts, err);
|
|
76258
76881
|
}
|
|
76259
76882
|
}
|
|
76260
76883
|
|
|
76261
76884
|
// src/commands/logout.ts
|
|
76262
|
-
var
|
|
76885
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
76263
76886
|
async function logout(opts) {
|
|
76264
76887
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
76265
76888
|
const resolved = await resolveProfile(requested);
|
|
76266
76889
|
if (!resolved) {
|
|
76267
|
-
process.stdout.write(
|
|
76890
|
+
process.stdout.write(import_picocolors20.default.dim("Not logged in \u2014 nothing to log out.\n"));
|
|
76268
76891
|
return;
|
|
76269
76892
|
}
|
|
76270
76893
|
if (resolved.autoSelected) {
|
|
76271
|
-
process.stderr.write(
|
|
76894
|
+
process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
76272
76895
|
`));
|
|
76273
76896
|
}
|
|
76274
76897
|
const { profile, name: profileName } = resolved;
|
|
@@ -76293,15 +76916,15 @@ async function logout(opts) {
|
|
|
76293
76916
|
const removed = await deleteProfile(profileName);
|
|
76294
76917
|
if (removed) {
|
|
76295
76918
|
process.stdout.write(
|
|
76296
|
-
|
|
76919
|
+
import_picocolors20.default.green(`\u2713 Logged out of profile ${import_picocolors20.default.bold(profileName)}.
|
|
76297
76920
|
`)
|
|
76298
76921
|
);
|
|
76299
76922
|
}
|
|
76300
76923
|
if (serverError) {
|
|
76301
76924
|
process.stderr.write(
|
|
76302
|
-
|
|
76925
|
+
import_picocolors20.default.yellow(
|
|
76303
76926
|
`\u26A0 Couldn't revoke server-side: ${serverError}
|
|
76304
|
-
The local bearer is wiped. If the server still has it, revoke from ${
|
|
76927
|
+
The local bearer is wiped. If the server still has it, revoke from ${import_picocolors20.default.bold("agentgates.ai/settings/pairings")}.
|
|
76305
76928
|
`
|
|
76306
76929
|
)
|
|
76307
76930
|
);
|
|
@@ -76309,17 +76932,17 @@ async function logout(opts) {
|
|
|
76309
76932
|
}
|
|
76310
76933
|
|
|
76311
76934
|
// src/commands/whoami.ts
|
|
76312
|
-
var
|
|
76935
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
76313
76936
|
init_constants();
|
|
76314
76937
|
async function whoami(opts) {
|
|
76315
76938
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
76316
76939
|
const resolved = await resolveProfile(requested);
|
|
76317
76940
|
if (!resolved) {
|
|
76318
|
-
process.stderr.write(
|
|
76941
|
+
process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
|
|
76319
76942
|
process.exit(2);
|
|
76320
76943
|
}
|
|
76321
76944
|
if (resolved.autoSelected) {
|
|
76322
|
-
process.stderr.write(
|
|
76945
|
+
process.stderr.write(import_picocolors21.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
76323
76946
|
`));
|
|
76324
76947
|
}
|
|
76325
76948
|
const { profile, name: profileName } = resolved;
|
|
@@ -76328,7 +76951,7 @@ async function whoami(opts) {
|
|
|
76328
76951
|
profile,
|
|
76329
76952
|
profileName,
|
|
76330
76953
|
jsonMode: jsonMode7,
|
|
76331
|
-
ttyHeader:
|
|
76954
|
+
ttyHeader: import_picocolors21.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
76332
76955
|
fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
|
|
76333
76956
|
});
|
|
76334
76957
|
if (outcome.kind === "auth_failed") {
|
|
@@ -76338,14 +76961,14 @@ async function whoami(opts) {
|
|
|
76338
76961
|
);
|
|
76339
76962
|
process.exit(1);
|
|
76340
76963
|
}
|
|
76341
|
-
process.stderr.write(
|
|
76964
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${outcome.reason}.
|
|
76342
76965
|
`));
|
|
76343
76966
|
process.exit(1);
|
|
76344
76967
|
}
|
|
76345
76968
|
if (outcome.kind === "error") {
|
|
76346
76969
|
const err = outcome.error;
|
|
76347
76970
|
if (err instanceof ApiError) {
|
|
76348
|
-
process.stderr.write(
|
|
76971
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
76349
76972
|
`));
|
|
76350
76973
|
process.exit(1);
|
|
76351
76974
|
}
|
|
@@ -76366,7 +76989,7 @@ async function whoami(opts) {
|
|
|
76366
76989
|
process.stdout.write(`Solana ${me.solanaAddress}
|
|
76367
76990
|
`);
|
|
76368
76991
|
}
|
|
76369
|
-
process.stdout.write(`Scopes ${me.scopes.join(", ") ||
|
|
76992
|
+
process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors21.default.dim("(none)")}
|
|
76370
76993
|
`);
|
|
76371
76994
|
const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
|
|
76372
76995
|
const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
|
|
@@ -76383,7 +77006,7 @@ async function whoami(opts) {
|
|
|
76383
77006
|
`
|
|
76384
77007
|
);
|
|
76385
77008
|
process.stdout.write(
|
|
76386
|
-
`Profile ${profileName === DEFAULT_PROFILE ?
|
|
77009
|
+
`Profile ${profileName === DEFAULT_PROFILE ? import_picocolors21.default.dim("(default)") : profileName}
|
|
76387
77010
|
`
|
|
76388
77011
|
);
|
|
76389
77012
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -76397,7 +77020,7 @@ function formatDate(iso) {
|
|
|
76397
77020
|
}
|
|
76398
77021
|
|
|
76399
77022
|
// src/commands/send.ts
|
|
76400
|
-
var
|
|
77023
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
76401
77024
|
|
|
76402
77025
|
// src/lib/status.ts
|
|
76403
77026
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -76438,7 +77061,7 @@ async function pollStatusUntilTerminal(opts) {
|
|
|
76438
77061
|
});
|
|
76439
77062
|
} catch (err) {
|
|
76440
77063
|
if (err instanceof ApiError && err.status >= 500) {
|
|
76441
|
-
await
|
|
77064
|
+
await sleep3(opts.intervalMs);
|
|
76442
77065
|
continue;
|
|
76443
77066
|
}
|
|
76444
77067
|
throw err;
|
|
@@ -76450,7 +77073,7 @@ async function pollStatusUntilTerminal(opts) {
|
|
|
76450
77073
|
if (isTerminalStatus(snap.status)) {
|
|
76451
77074
|
return snap;
|
|
76452
77075
|
}
|
|
76453
|
-
await
|
|
77076
|
+
await sleep3(opts.intervalMs);
|
|
76454
77077
|
}
|
|
76455
77078
|
throw new Error(
|
|
76456
77079
|
`Status poll timed out after ${Math.round(opts.giveUpMs / 6e4)} minutes (last status: ${last?.status ?? "unknown"})`
|
|
@@ -76485,20 +77108,20 @@ async function streamStatusUntilTerminal(opts) {
|
|
|
76485
77108
|
if (err.status >= 400 && err.status < 500) {
|
|
76486
77109
|
throw err;
|
|
76487
77110
|
}
|
|
76488
|
-
await
|
|
77111
|
+
await sleep3(RECONNECT_BACKOFF_MS);
|
|
76489
77112
|
reconnects += 1;
|
|
76490
77113
|
continue;
|
|
76491
77114
|
}
|
|
76492
77115
|
throw err;
|
|
76493
77116
|
}
|
|
76494
77117
|
reconnects += 1;
|
|
76495
|
-
await
|
|
77118
|
+
await sleep3(RECONNECT_BACKOFF_MS);
|
|
76496
77119
|
}
|
|
76497
77120
|
throw new Error(
|
|
76498
77121
|
`Status stream timed out after ${Math.round(opts.giveUpMs / 6e4)} minutes (last status: ${last?.status ?? "unknown"})`
|
|
76499
77122
|
);
|
|
76500
77123
|
}
|
|
76501
|
-
function
|
|
77124
|
+
function sleep3(ms) {
|
|
76502
77125
|
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
76503
77126
|
}
|
|
76504
77127
|
|
|
@@ -76556,11 +77179,11 @@ async function send(amount, asset, opts) {
|
|
|
76556
77179
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
76557
77180
|
const resolved = await resolveProfile(requested);
|
|
76558
77181
|
if (!resolved) {
|
|
76559
|
-
process.stderr.write(
|
|
77182
|
+
process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
|
|
76560
77183
|
process.exit(2);
|
|
76561
77184
|
}
|
|
76562
77185
|
if (resolved.autoSelected) {
|
|
76563
|
-
process.stderr.write(
|
|
77186
|
+
process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
76564
77187
|
`));
|
|
76565
77188
|
}
|
|
76566
77189
|
const { profile, name: profileName } = resolved;
|
|
@@ -76569,7 +77192,7 @@ async function send(amount, asset, opts) {
|
|
|
76569
77192
|
const amountNumber = Number(amount);
|
|
76570
77193
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
76571
77194
|
process.stderr.write(
|
|
76572
|
-
|
|
77195
|
+
import_picocolors22.default.red(`\u2715 amount must be a positive number (got ${import_picocolors22.default.bold(amount)}).
|
|
76573
77196
|
`)
|
|
76574
77197
|
);
|
|
76575
77198
|
process.exit(2);
|
|
@@ -76577,23 +77200,23 @@ async function send(amount, asset, opts) {
|
|
|
76577
77200
|
const assetNormalized = asset.toLowerCase();
|
|
76578
77201
|
if (assetNormalized !== "native" && assetNormalized !== "usdc") {
|
|
76579
77202
|
process.stderr.write(
|
|
76580
|
-
|
|
76581
|
-
`\u2715 asset must be ${
|
|
77203
|
+
import_picocolors22.default.red(
|
|
77204
|
+
`\u2715 asset must be ${import_picocolors22.default.bold("native")} or ${import_picocolors22.default.bold("usdc")} (got ${import_picocolors22.default.bold(asset)}).
|
|
76582
77205
|
`
|
|
76583
77206
|
)
|
|
76584
77207
|
);
|
|
76585
77208
|
process.exit(2);
|
|
76586
77209
|
}
|
|
76587
77210
|
if (!opts.to || opts.to.trim() === "") {
|
|
76588
|
-
process.stderr.write(
|
|
77211
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 --to <address> is required.
|
|
76589
77212
|
`));
|
|
76590
77213
|
process.exit(2);
|
|
76591
77214
|
}
|
|
76592
77215
|
if (isSolanaChainAlias(opts.chain)) {
|
|
76593
77216
|
if (EVM_ADDRESS_RE.test(opts.to)) {
|
|
76594
77217
|
process.stderr.write(
|
|
76595
|
-
|
|
76596
|
-
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${
|
|
77218
|
+
import_picocolors22.default.red(
|
|
77219
|
+
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors22.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
|
|
76597
77220
|
`
|
|
76598
77221
|
)
|
|
76599
77222
|
);
|
|
@@ -76601,10 +77224,10 @@ async function send(amount, asset, opts) {
|
|
|
76601
77224
|
}
|
|
76602
77225
|
if (!SOLANA_ADDRESS_RE.test(opts.to)) {
|
|
76603
77226
|
process.stderr.write(
|
|
76604
|
-
|
|
76605
|
-
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${
|
|
77227
|
+
import_picocolors22.default.red(
|
|
77228
|
+
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors22.default.bold(opts.to)}).
|
|
76606
77229
|
`
|
|
76607
|
-
) +
|
|
77230
|
+
) + import_picocolors22.default.dim(
|
|
76608
77231
|
` SNS resolution is deferred to a future server-side change;
|
|
76609
77232
|
for now Solana sends require the literal pubkey.
|
|
76610
77233
|
`
|
|
@@ -76615,8 +77238,8 @@ async function send(amount, asset, opts) {
|
|
|
76615
77238
|
}
|
|
76616
77239
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
76617
77240
|
process.stderr.write(
|
|
76618
|
-
|
|
76619
|
-
`) +
|
|
77241
|
+
import_picocolors22.default.red(`\u2715 --user-stated <text> is required.
|
|
77242
|
+
`) + import_picocolors22.default.dim(
|
|
76620
77243
|
` This is the trust-gap defense: pass the verbatim user request so
|
|
76621
77244
|
the approval modal can cross-check what the agent thinks the user
|
|
76622
77245
|
asked for vs. the actual decoded transaction.
|
|
@@ -76634,7 +77257,7 @@ async function send(amount, asset, opts) {
|
|
|
76634
77257
|
const n2 = Number(opts.maxUsd);
|
|
76635
77258
|
if (!Number.isFinite(n2) || n2 <= 0) {
|
|
76636
77259
|
process.stderr.write(
|
|
76637
|
-
|
|
77260
|
+
import_picocolors22.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
|
|
76638
77261
|
`)
|
|
76639
77262
|
);
|
|
76640
77263
|
process.exit(2);
|
|
@@ -76676,7 +77299,7 @@ async function send(amount, asset, opts) {
|
|
|
76676
77299
|
profile: profileName,
|
|
76677
77300
|
jsonMode: jsonMode7,
|
|
76678
77301
|
origin: activeProfile.mcpOrigin,
|
|
76679
|
-
ttyHeader:
|
|
77302
|
+
ttyHeader: import_picocolors22.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
76680
77303
|
});
|
|
76681
77304
|
} catch (reloginErr) {
|
|
76682
77305
|
if (jsonMode7) {
|
|
@@ -76688,7 +77311,7 @@ async function send(amount, asset, opts) {
|
|
|
76688
77311
|
process.exit(1);
|
|
76689
77312
|
}
|
|
76690
77313
|
process.stderr.write(
|
|
76691
|
-
|
|
77314
|
+
import_picocolors22.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
76692
77315
|
`)
|
|
76693
77316
|
);
|
|
76694
77317
|
process.exit(1);
|
|
@@ -76712,7 +77335,7 @@ async function send(amount, asset, opts) {
|
|
|
76712
77335
|
process.exit(1);
|
|
76713
77336
|
}
|
|
76714
77337
|
process.stderr.write(
|
|
76715
|
-
|
|
77338
|
+
import_picocolors22.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
76716
77339
|
`)
|
|
76717
77340
|
);
|
|
76718
77341
|
process.exit(1);
|
|
@@ -76729,7 +77352,7 @@ async function send(amount, asset, opts) {
|
|
|
76729
77352
|
});
|
|
76730
77353
|
process.exit(1);
|
|
76731
77354
|
}
|
|
76732
|
-
process.stderr.write(
|
|
77355
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
76733
77356
|
`));
|
|
76734
77357
|
process.exit(1);
|
|
76735
77358
|
} else {
|
|
@@ -76755,17 +77378,17 @@ async function send(amount, asset, opts) {
|
|
|
76755
77378
|
if (proposed.detail) {
|
|
76756
77379
|
const d = proposed.detail;
|
|
76757
77380
|
process.stderr.write(
|
|
76758
|
-
|
|
77381
|
+
import_picocolors22.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
|
|
76759
77382
|
`
|
|
76760
77383
|
);
|
|
76761
77384
|
} else {
|
|
76762
|
-
process.stderr.write(
|
|
77385
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${proposed.reason}
|
|
76763
77386
|
`));
|
|
76764
77387
|
}
|
|
76765
77388
|
if (proposed.upgrade_url) {
|
|
76766
77389
|
process.stderr.write(
|
|
76767
77390
|
` Open this to grant access, then re-run the command:
|
|
76768
|
-
${
|
|
77391
|
+
${import_picocolors22.default.cyan(proposed.upgrade_url)}
|
|
76769
77392
|
`
|
|
76770
77393
|
);
|
|
76771
77394
|
}
|
|
@@ -76775,21 +77398,21 @@ async function send(amount, asset, opts) {
|
|
|
76775
77398
|
const a = proposed.recommended_actions[i];
|
|
76776
77399
|
process.stderr.write(` ${i + 1}. ${a.label}
|
|
76777
77400
|
`);
|
|
76778
|
-
if (a.reasoning) process.stderr.write(
|
|
77401
|
+
if (a.reasoning) process.stderr.write(import_picocolors22.default.dim(` ${a.reasoning}
|
|
76779
77402
|
`));
|
|
76780
77403
|
if (a.action_intent && a.action_intent.external_url) {
|
|
76781
77404
|
process.stderr.write(
|
|
76782
|
-
` ${
|
|
77405
|
+
` ${import_picocolors22.default.cyan(a.action_intent.external_url)}
|
|
76783
77406
|
`
|
|
76784
77407
|
);
|
|
76785
77408
|
}
|
|
76786
77409
|
}
|
|
76787
77410
|
}
|
|
76788
77411
|
if (proposed.suggestions && proposed.suggestions.length > 0) {
|
|
76789
|
-
process.stderr.write(
|
|
77412
|
+
process.stderr.write(import_picocolors22.default.dim("\n Other ways to fund:\n"));
|
|
76790
77413
|
for (const s of proposed.suggestions) {
|
|
76791
77414
|
if (s.kind === "ask_user") continue;
|
|
76792
|
-
process.stderr.write(
|
|
77415
|
+
process.stderr.write(import_picocolors22.default.dim(` \u2022 ${s.label}
|
|
76793
77416
|
`));
|
|
76794
77417
|
}
|
|
76795
77418
|
}
|
|
@@ -76816,8 +77439,8 @@ async function send(amount, asset, opts) {
|
|
|
76816
77439
|
} else {
|
|
76817
77440
|
process.stdout.write(
|
|
76818
77441
|
`
|
|
76819
|
-
${
|
|
76820
|
-
${
|
|
77442
|
+
${import_picocolors22.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
77443
|
+
${import_picocolors22.default.cyan(proposed.approval_url)}
|
|
76821
77444
|
|
|
76822
77445
|
`
|
|
76823
77446
|
);
|
|
@@ -76836,7 +77459,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
76836
77459
|
if (jsonMode7) {
|
|
76837
77460
|
emitNdjson({ status: s.status, intent_id: s.approval_id });
|
|
76838
77461
|
} else {
|
|
76839
|
-
process.stdout.write(` ${describeStatus(s.status)}${
|
|
77462
|
+
process.stdout.write(` ${describeStatus(s.status)}${import_picocolors22.default.dim("\u2026")}\r`);
|
|
76840
77463
|
}
|
|
76841
77464
|
}
|
|
76842
77465
|
});
|
|
@@ -76850,7 +77473,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
76850
77473
|
profile: profileName,
|
|
76851
77474
|
jsonMode: jsonMode7,
|
|
76852
77475
|
origin: activeProfile.mcpOrigin,
|
|
76853
|
-
ttyHeader:
|
|
77476
|
+
ttyHeader: import_picocolors22.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
|
|
76854
77477
|
});
|
|
76855
77478
|
} catch (reloginErr) {
|
|
76856
77479
|
if (jsonMode7) {
|
|
@@ -76863,7 +77486,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
76863
77486
|
process.exit(1);
|
|
76864
77487
|
}
|
|
76865
77488
|
process.stderr.write(
|
|
76866
|
-
"\n" +
|
|
77489
|
+
"\n" + import_picocolors22.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
76867
77490
|
`)
|
|
76868
77491
|
);
|
|
76869
77492
|
process.exit(1);
|
|
@@ -76881,7 +77504,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
76881
77504
|
process.exit(1);
|
|
76882
77505
|
}
|
|
76883
77506
|
process.stderr.write(
|
|
76884
|
-
"\n" +
|
|
77507
|
+
"\n" + import_picocolors22.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
76885
77508
|
`)
|
|
76886
77509
|
);
|
|
76887
77510
|
process.exit(1);
|
|
@@ -76897,7 +77520,7 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
76897
77520
|
process.exit(1);
|
|
76898
77521
|
}
|
|
76899
77522
|
process.stderr.write(
|
|
76900
|
-
"\n" +
|
|
77523
|
+
"\n" + import_picocolors22.default.red(`\u2715 Status poll failed: ${err.message}
|
|
76901
77524
|
`)
|
|
76902
77525
|
);
|
|
76903
77526
|
process.exit(1);
|
|
@@ -76917,19 +77540,19 @@ ${import_picocolors21.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
76917
77540
|
}
|
|
76918
77541
|
process.stdout.write("\n");
|
|
76919
77542
|
if (final.status === "mined") {
|
|
76920
|
-
process.stdout.write(
|
|
77543
|
+
process.stdout.write(import_picocolors22.default.green("\u2713 Mined.") + "\n");
|
|
76921
77544
|
if (final.tx_hash) {
|
|
76922
77545
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
76923
77546
|
`);
|
|
76924
77547
|
}
|
|
76925
77548
|
if (explorer) {
|
|
76926
|
-
process.stdout.write(` Explorer ${
|
|
77549
|
+
process.stdout.write(` Explorer ${import_picocolors22.default.cyan(explorer)}
|
|
76927
77550
|
`);
|
|
76928
77551
|
}
|
|
76929
77552
|
process.exit(0);
|
|
76930
77553
|
}
|
|
76931
77554
|
const label = final.status === "rejected" ? "Rejected by user" : final.status === "expired" ? "Expired (TTL elapsed before approval)" : final.status === "failed" ? "Broadcast failed" : `Ended in unexpected status: ${final.status}`;
|
|
76932
|
-
process.stderr.write(
|
|
77555
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${label}.
|
|
76933
77556
|
`));
|
|
76934
77557
|
process.exit(1);
|
|
76935
77558
|
}
|
|
@@ -76957,7 +77580,7 @@ function describeStatus(s) {
|
|
|
76957
77580
|
}
|
|
76958
77581
|
|
|
76959
77582
|
// src/commands/status.ts
|
|
76960
|
-
var
|
|
77583
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
76961
77584
|
init_constants();
|
|
76962
77585
|
var WATCH_GIVEUP_MS = 10 * 6e4;
|
|
76963
77586
|
function explorerUrl2(chainId, hash2) {
|
|
@@ -76976,17 +77599,17 @@ function explorerUrl2(chainId, hash2) {
|
|
|
76976
77599
|
}
|
|
76977
77600
|
async function status3(intentId, opts) {
|
|
76978
77601
|
if (!intentId || intentId.trim() === "") {
|
|
76979
|
-
process.stderr.write(
|
|
77602
|
+
process.stderr.write(import_picocolors23.default.red("\u2715 Missing intent id.\n"));
|
|
76980
77603
|
process.exit(2);
|
|
76981
77604
|
}
|
|
76982
77605
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
76983
77606
|
const resolved = await resolveProfile(requested);
|
|
76984
77607
|
if (!resolved) {
|
|
76985
|
-
process.stderr.write(
|
|
77608
|
+
process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
|
|
76986
77609
|
process.exit(2);
|
|
76987
77610
|
}
|
|
76988
77611
|
if (resolved.autoSelected) {
|
|
76989
|
-
process.stderr.write(
|
|
77612
|
+
process.stderr.write(import_picocolors23.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
76990
77613
|
`));
|
|
76991
77614
|
}
|
|
76992
77615
|
const { profile, name: profileName } = resolved;
|
|
@@ -76995,7 +77618,7 @@ async function status3(intentId, opts) {
|
|
|
76995
77618
|
profile,
|
|
76996
77619
|
profileName,
|
|
76997
77620
|
jsonMode: jsonMode7,
|
|
76998
|
-
ttyHeader:
|
|
77621
|
+
ttyHeader: import_picocolors23.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
76999
77622
|
fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
|
|
77000
77623
|
});
|
|
77001
77624
|
if (outcome.kind === "auth_failed") {
|
|
@@ -77005,7 +77628,7 @@ async function status3(intentId, opts) {
|
|
|
77005
77628
|
);
|
|
77006
77629
|
process.exit(1);
|
|
77007
77630
|
}
|
|
77008
|
-
process.stderr.write(
|
|
77631
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${outcome.reason}.
|
|
77009
77632
|
`));
|
|
77010
77633
|
process.exit(1);
|
|
77011
77634
|
}
|
|
@@ -77013,11 +77636,11 @@ async function status3(intentId, opts) {
|
|
|
77013
77636
|
const err = outcome.error;
|
|
77014
77637
|
if (err instanceof ApiError) {
|
|
77015
77638
|
if (err.status === 404) {
|
|
77016
|
-
process.stderr.write(
|
|
77639
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 No intent with id ${intentId}.
|
|
77017
77640
|
`));
|
|
77018
77641
|
process.exit(1);
|
|
77019
77642
|
}
|
|
77020
|
-
process.stderr.write(
|
|
77643
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
77021
77644
|
`));
|
|
77022
77645
|
process.exit(1);
|
|
77023
77646
|
}
|
|
@@ -77028,7 +77651,7 @@ async function status3(intentId, opts) {
|
|
|
77028
77651
|
if (opts.watch && !isTerminalStatus(snap.status)) {
|
|
77029
77652
|
if (!jsonMode7) {
|
|
77030
77653
|
printSnap(snap);
|
|
77031
|
-
process.stdout.write(
|
|
77654
|
+
process.stdout.write(import_picocolors23.default.dim("Watching\u2026\n"));
|
|
77032
77655
|
}
|
|
77033
77656
|
const runWatchPoll = (p) => streamStatusUntilTerminal({
|
|
77034
77657
|
intentId,
|
|
@@ -77039,7 +77662,7 @@ async function status3(intentId, opts) {
|
|
|
77039
77662
|
giveUpMs: WATCH_GIVEUP_MS,
|
|
77040
77663
|
onTick: (s) => {
|
|
77041
77664
|
if (!jsonMode7) {
|
|
77042
|
-
process.stdout.write(` ${
|
|
77665
|
+
process.stdout.write(` ${import_picocolors23.default.dim("\u2192")} ${s.status}
|
|
77043
77666
|
`);
|
|
77044
77667
|
}
|
|
77045
77668
|
}
|
|
@@ -77054,7 +77677,7 @@ async function status3(intentId, opts) {
|
|
|
77054
77677
|
profile: profileName,
|
|
77055
77678
|
jsonMode: jsonMode7,
|
|
77056
77679
|
origin: activeProfile.mcpOrigin,
|
|
77057
|
-
ttyHeader:
|
|
77680
|
+
ttyHeader: import_picocolors23.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
|
|
77058
77681
|
});
|
|
77059
77682
|
} catch (reloginErr) {
|
|
77060
77683
|
if (jsonMode7) {
|
|
@@ -77068,7 +77691,7 @@ async function status3(intentId, opts) {
|
|
|
77068
77691
|
process.exit(1);
|
|
77069
77692
|
}
|
|
77070
77693
|
process.stderr.write(
|
|
77071
|
-
|
|
77694
|
+
import_picocolors23.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
77072
77695
|
`)
|
|
77073
77696
|
);
|
|
77074
77697
|
process.exit(1);
|
|
@@ -77076,12 +77699,12 @@ async function status3(intentId, opts) {
|
|
|
77076
77699
|
try {
|
|
77077
77700
|
final = await runWatchPoll(activeProfile);
|
|
77078
77701
|
} catch (retryErr) {
|
|
77079
|
-
process.stderr.write(
|
|
77702
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${retryErr.message}
|
|
77080
77703
|
`));
|
|
77081
77704
|
process.exit(1);
|
|
77082
77705
|
}
|
|
77083
77706
|
} else {
|
|
77084
|
-
process.stderr.write(
|
|
77707
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${err.message}
|
|
77085
77708
|
`));
|
|
77086
77709
|
process.exit(1);
|
|
77087
77710
|
}
|
|
@@ -77102,7 +77725,7 @@ async function status3(intentId, opts) {
|
|
|
77102
77725
|
}
|
|
77103
77726
|
function printSnap(s) {
|
|
77104
77727
|
const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
|
|
77105
|
-
const colorFn = s.status === "mined" ?
|
|
77728
|
+
const colorFn = s.status === "mined" ? import_picocolors23.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors23.default.red : import_picocolors23.default.cyan;
|
|
77106
77729
|
process.stdout.write(`Intent ${s.approval_id}
|
|
77107
77730
|
`);
|
|
77108
77731
|
process.stdout.write(`Status ${colorFn(s.status)}
|
|
@@ -77117,12 +77740,12 @@ function printSnap(s) {
|
|
|
77117
77740
|
process.stdout.write(`Tx ${s.tx_hash}
|
|
77118
77741
|
`);
|
|
77119
77742
|
if (explorer) {
|
|
77120
|
-
process.stdout.write(`Explorer ${
|
|
77743
|
+
process.stdout.write(`Explorer ${import_picocolors23.default.cyan(explorer)}
|
|
77121
77744
|
`);
|
|
77122
77745
|
}
|
|
77123
77746
|
}
|
|
77124
77747
|
if (!isTerminalStatus(s.status)) {
|
|
77125
|
-
process.stdout.write(`Approve ${
|
|
77748
|
+
process.stdout.write(`Approve ${import_picocolors23.default.cyan(s.approval_url)}
|
|
77126
77749
|
`);
|
|
77127
77750
|
}
|
|
77128
77751
|
process.stdout.write(`Created ${formatDate2(s.created_at)}
|
|
@@ -77139,7 +77762,7 @@ function formatDate2(iso) {
|
|
|
77139
77762
|
}
|
|
77140
77763
|
|
|
77141
77764
|
// src/commands/balance.ts
|
|
77142
|
-
var
|
|
77765
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
77143
77766
|
init_constants();
|
|
77144
77767
|
var CHAIN_ALIASES = {
|
|
77145
77768
|
"1": 1,
|
|
@@ -77163,11 +77786,11 @@ async function balance(opts) {
|
|
|
77163
77786
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
77164
77787
|
const resolved = await resolveProfile(requested);
|
|
77165
77788
|
if (!resolved) {
|
|
77166
|
-
process.stderr.write(
|
|
77789
|
+
process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
|
|
77167
77790
|
process.exit(2);
|
|
77168
77791
|
}
|
|
77169
77792
|
if (resolved.autoSelected) {
|
|
77170
|
-
process.stderr.write(
|
|
77793
|
+
process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
77171
77794
|
`));
|
|
77172
77795
|
}
|
|
77173
77796
|
const { profile, name: profileName } = resolved;
|
|
@@ -77177,8 +77800,8 @@ async function balance(opts) {
|
|
|
77177
77800
|
const id2 = CHAIN_ALIASES[key];
|
|
77178
77801
|
if (id2 === void 0) {
|
|
77179
77802
|
process.stderr.write(
|
|
77180
|
-
|
|
77181
|
-
`\u2715 Unknown chain ${
|
|
77803
|
+
import_picocolors24.default.red(
|
|
77804
|
+
`\u2715 Unknown chain ${import_picocolors24.default.bold(opts.chain)}. Supported: ${import_picocolors24.default.bold("1/ethereum")}, ${import_picocolors24.default.bold("137/polygon")}, ${import_picocolors24.default.bold("8453/base")}, ${import_picocolors24.default.bold("42161/arbitrum")}, ${import_picocolors24.default.bold("900/solana")}.
|
|
77182
77805
|
`
|
|
77183
77806
|
)
|
|
77184
77807
|
);
|
|
@@ -77191,7 +77814,7 @@ async function balance(opts) {
|
|
|
77191
77814
|
profile,
|
|
77192
77815
|
profileName,
|
|
77193
77816
|
jsonMode: jsonMode7,
|
|
77194
|
-
ttyHeader:
|
|
77817
|
+
ttyHeader: import_picocolors24.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
77195
77818
|
fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
|
|
77196
77819
|
});
|
|
77197
77820
|
if (outcome.kind === "auth_failed") {
|
|
@@ -77201,14 +77824,14 @@ async function balance(opts) {
|
|
|
77201
77824
|
);
|
|
77202
77825
|
process.exit(1);
|
|
77203
77826
|
}
|
|
77204
|
-
process.stderr.write(
|
|
77827
|
+
process.stderr.write(import_picocolors24.default.red(`\u2715 ${outcome.reason}.
|
|
77205
77828
|
`));
|
|
77206
77829
|
process.exit(1);
|
|
77207
77830
|
}
|
|
77208
77831
|
if (outcome.kind === "error") {
|
|
77209
77832
|
const err = outcome.error;
|
|
77210
77833
|
if (err instanceof ApiError) {
|
|
77211
|
-
process.stderr.write(
|
|
77834
|
+
process.stderr.write(import_picocolors24.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
77212
77835
|
`));
|
|
77213
77836
|
process.exit(1);
|
|
77214
77837
|
}
|
|
@@ -77238,7 +77861,7 @@ async function balance(opts) {
|
|
|
77238
77861
|
}
|
|
77239
77862
|
if (filtered.length === 0) {
|
|
77240
77863
|
process.stdout.write(
|
|
77241
|
-
|
|
77864
|
+
import_picocolors24.default.dim(
|
|
77242
77865
|
chainFilter !== null ? `No balances on chain ${chainFilter}.
|
|
77243
77866
|
` : `No chain balances returned.
|
|
77244
77867
|
`
|
|
@@ -77250,7 +77873,7 @@ async function balance(opts) {
|
|
|
77250
77873
|
const errorLines = [];
|
|
77251
77874
|
for (const c of filtered) {
|
|
77252
77875
|
if (c.error) {
|
|
77253
|
-
errorLines.push(`${c.chainName} ${
|
|
77876
|
+
errorLines.push(`${c.chainName} ${import_picocolors24.default.red(`(read failed: ${c.error})`)}`);
|
|
77254
77877
|
continue;
|
|
77255
77878
|
}
|
|
77256
77879
|
if (c.native.balance > 0) {
|
|
@@ -77271,7 +77894,7 @@ async function balance(opts) {
|
|
|
77271
77894
|
}
|
|
77272
77895
|
}
|
|
77273
77896
|
if (rows.length === 0 && errorLines.length === 0) {
|
|
77274
|
-
process.stdout.write(
|
|
77897
|
+
process.stdout.write(import_picocolors24.default.dim(`All balances are zero.
|
|
77275
77898
|
`));
|
|
77276
77899
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
77277
77900
|
return;
|
|
@@ -77281,7 +77904,7 @@ async function balance(opts) {
|
|
|
77281
77904
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
77282
77905
|
const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
|
|
77283
77906
|
const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
|
|
77284
|
-
process.stdout.write(
|
|
77907
|
+
process.stdout.write(import_picocolors24.default.dim(header) + "\n");
|
|
77285
77908
|
for (const r of rows) {
|
|
77286
77909
|
process.stdout.write(
|
|
77287
77910
|
r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
|
|
@@ -77294,7 +77917,7 @@ async function balance(opts) {
|
|
|
77294
77917
|
`);
|
|
77295
77918
|
}
|
|
77296
77919
|
if (res.fetched_at) {
|
|
77297
|
-
process.stdout.write("\n" +
|
|
77920
|
+
process.stdout.write("\n" + import_picocolors24.default.dim(`Fetched ${res.fetched_at}
|
|
77298
77921
|
`));
|
|
77299
77922
|
}
|
|
77300
77923
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -77307,7 +77930,7 @@ function formatBalance(value, decimals) {
|
|
|
77307
77930
|
}
|
|
77308
77931
|
|
|
77309
77932
|
// src/commands/history.ts
|
|
77310
|
-
var
|
|
77933
|
+
var import_picocolors25 = __toESM(require_picocolors(), 1);
|
|
77311
77934
|
init_constants();
|
|
77312
77935
|
var DEFAULT_LIMIT = 20;
|
|
77313
77936
|
var SERVER_MAX_LIMIT = 100;
|
|
@@ -77315,11 +77938,11 @@ async function history(opts) {
|
|
|
77315
77938
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
77316
77939
|
const resolved = await resolveProfile(requested);
|
|
77317
77940
|
if (!resolved) {
|
|
77318
|
-
process.stderr.write(
|
|
77941
|
+
process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
|
|
77319
77942
|
process.exit(2);
|
|
77320
77943
|
}
|
|
77321
77944
|
if (resolved.autoSelected) {
|
|
77322
|
-
process.stderr.write(
|
|
77945
|
+
process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
77323
77946
|
`));
|
|
77324
77947
|
}
|
|
77325
77948
|
const { profile, name: profileName } = resolved;
|
|
@@ -77328,14 +77951,14 @@ async function history(opts) {
|
|
|
77328
77951
|
const n2 = Number(opts.limit);
|
|
77329
77952
|
if (!Number.isFinite(n2) || n2 <= 0 || !Number.isInteger(n2)) {
|
|
77330
77953
|
process.stderr.write(
|
|
77331
|
-
|
|
77954
|
+
import_picocolors25.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors25.default.bold(opts.limit)}).
|
|
77332
77955
|
`)
|
|
77333
77956
|
);
|
|
77334
77957
|
process.exit(2);
|
|
77335
77958
|
}
|
|
77336
77959
|
if (n2 > SERVER_MAX_LIMIT) {
|
|
77337
77960
|
process.stderr.write(
|
|
77338
|
-
|
|
77961
|
+
import_picocolors25.default.red(
|
|
77339
77962
|
`\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n2}.
|
|
77340
77963
|
`
|
|
77341
77964
|
)
|
|
@@ -77349,7 +77972,7 @@ async function history(opts) {
|
|
|
77349
77972
|
profile,
|
|
77350
77973
|
profileName,
|
|
77351
77974
|
jsonMode: jsonMode7,
|
|
77352
|
-
ttyHeader:
|
|
77975
|
+
ttyHeader: import_picocolors25.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
77353
77976
|
fn: (bearer, origin) => apiFetch(
|
|
77354
77977
|
`/api/history?limit=${encodeURIComponent(String(limit))}`,
|
|
77355
77978
|
{ bearer, origin }
|
|
@@ -77362,14 +77985,14 @@ async function history(opts) {
|
|
|
77362
77985
|
);
|
|
77363
77986
|
process.exit(1);
|
|
77364
77987
|
}
|
|
77365
|
-
process.stderr.write(
|
|
77988
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${outcome.reason}.
|
|
77366
77989
|
`));
|
|
77367
77990
|
process.exit(1);
|
|
77368
77991
|
}
|
|
77369
77992
|
if (outcome.kind === "error") {
|
|
77370
77993
|
const err = outcome.error;
|
|
77371
77994
|
if (err instanceof ApiError) {
|
|
77372
|
-
process.stderr.write(
|
|
77995
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
77373
77996
|
`));
|
|
77374
77997
|
process.exit(1);
|
|
77375
77998
|
}
|
|
@@ -77386,7 +78009,7 @@ async function history(opts) {
|
|
|
77386
78009
|
return;
|
|
77387
78010
|
}
|
|
77388
78011
|
if (res.txs.length === 0) {
|
|
77389
|
-
process.stdout.write(
|
|
78012
|
+
process.stdout.write(import_picocolors25.default.dim(`No activity yet.
|
|
77390
78013
|
`));
|
|
77391
78014
|
return;
|
|
77392
78015
|
}
|
|
@@ -77406,7 +78029,7 @@ async function history(opts) {
|
|
|
77406
78029
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
77407
78030
|
const colTo = Math.max(2, ...rows.map((r) => r.to.length));
|
|
77408
78031
|
const header = "When".padEnd(colWhen) + " " + "Chain".padEnd(colChain) + " " + "Type".padEnd(colType) + " " + "Amount".padStart(colAmount) + " " + "Asset".padEnd(colAsset) + " " + "To".padEnd(colTo) + " Hash";
|
|
77409
|
-
process.stdout.write(
|
|
78032
|
+
process.stdout.write(import_picocolors25.default.dim(header) + "\n");
|
|
77410
78033
|
for (const r of rows) {
|
|
77411
78034
|
process.stdout.write(
|
|
77412
78035
|
r.when.padEnd(colWhen) + " " + r.chain.padEnd(colChain) + " " + r.type.padEnd(colType) + " " + r.amount.padStart(colAmount) + " " + r.asset.padEnd(colAsset) + " " + r.to.padEnd(colTo) + " " + r.hash + "\n"
|
|
@@ -77414,7 +78037,7 @@ async function history(opts) {
|
|
|
77414
78037
|
}
|
|
77415
78038
|
if (res.fetched_at) {
|
|
77416
78039
|
process.stdout.write(
|
|
77417
|
-
"\n" +
|
|
78040
|
+
"\n" + import_picocolors25.default.dim(
|
|
77418
78041
|
`Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
|
|
77419
78042
|
`
|
|
77420
78043
|
)
|
|
@@ -77501,10 +78124,10 @@ function prettyType(activityType, status4) {
|
|
|
77501
78124
|
}
|
|
77502
78125
|
|
|
77503
78126
|
// src/commands/swap.ts
|
|
77504
|
-
var
|
|
78127
|
+
var import_picocolors27 = __toESM(require_picocolors(), 1);
|
|
77505
78128
|
|
|
77506
78129
|
// src/lib/intent-flow.ts
|
|
77507
|
-
var
|
|
78130
|
+
var import_picocolors26 = __toESM(require_picocolors(), 1);
|
|
77508
78131
|
var STREAM_GIVEUP_MS = 10 * 6e4;
|
|
77509
78132
|
var SOLANA_CHAIN_ID2 = 900;
|
|
77510
78133
|
function isBlocked2(r) {
|
|
@@ -77579,7 +78202,7 @@ async function runIntentFlow(opts) {
|
|
|
77579
78202
|
profile: opts.profileName,
|
|
77580
78203
|
jsonMode: opts.jsonMode,
|
|
77581
78204
|
origin: activeProfile.mcpOrigin,
|
|
77582
|
-
ttyHeader:
|
|
78205
|
+
ttyHeader: import_picocolors26.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
77583
78206
|
});
|
|
77584
78207
|
} catch (reloginErr) {
|
|
77585
78208
|
if (opts.jsonMode) {
|
|
@@ -77591,7 +78214,7 @@ async function runIntentFlow(opts) {
|
|
|
77591
78214
|
process.exit(1);
|
|
77592
78215
|
}
|
|
77593
78216
|
process.stderr.write(
|
|
77594
|
-
|
|
78217
|
+
import_picocolors26.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
77595
78218
|
`)
|
|
77596
78219
|
);
|
|
77597
78220
|
process.exit(1);
|
|
@@ -77615,7 +78238,7 @@ async function runIntentFlow(opts) {
|
|
|
77615
78238
|
process.exit(1);
|
|
77616
78239
|
}
|
|
77617
78240
|
process.stderr.write(
|
|
77618
|
-
|
|
78241
|
+
import_picocolors26.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
77619
78242
|
`)
|
|
77620
78243
|
);
|
|
77621
78244
|
process.exit(1);
|
|
@@ -77632,7 +78255,7 @@ async function runIntentFlow(opts) {
|
|
|
77632
78255
|
});
|
|
77633
78256
|
process.exit(1);
|
|
77634
78257
|
}
|
|
77635
|
-
process.stderr.write(
|
|
78258
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
77636
78259
|
`));
|
|
77637
78260
|
process.exit(1);
|
|
77638
78261
|
} else {
|
|
@@ -77654,18 +78277,18 @@ async function runIntentFlow(opts) {
|
|
|
77654
78277
|
});
|
|
77655
78278
|
process.exit(1);
|
|
77656
78279
|
}
|
|
77657
|
-
process.stderr.write(
|
|
78280
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
|
|
77658
78281
|
`));
|
|
77659
78282
|
if (proposed.upgrade_url) {
|
|
77660
78283
|
process.stderr.write(
|
|
77661
78284
|
` Open this to grant access, then re-run the command:
|
|
77662
|
-
${
|
|
78285
|
+
${import_picocolors26.default.cyan(proposed.upgrade_url)}
|
|
77663
78286
|
`
|
|
77664
78287
|
);
|
|
77665
78288
|
}
|
|
77666
78289
|
if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
|
|
77667
78290
|
process.stderr.write(
|
|
77668
|
-
|
|
78291
|
+
import_picocolors26.default.dim(
|
|
77669
78292
|
` Suggested actions:
|
|
77670
78293
|
` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
|
|
77671
78294
|
)
|
|
@@ -77688,8 +78311,8 @@ async function runIntentFlow(opts) {
|
|
|
77688
78311
|
} else {
|
|
77689
78312
|
process.stdout.write(
|
|
77690
78313
|
`
|
|
77691
|
-
${
|
|
77692
|
-
${
|
|
78314
|
+
${import_picocolors26.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
78315
|
+
${import_picocolors26.default.cyan(proposed.approval_url)}
|
|
77693
78316
|
|
|
77694
78317
|
`
|
|
77695
78318
|
);
|
|
@@ -77718,10 +78341,10 @@ ${import_picocolors25.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77718
78341
|
});
|
|
77719
78342
|
} else if (retryable) {
|
|
77720
78343
|
process.stdout.write(
|
|
77721
|
-
` ${
|
|
78344
|
+
` ${import_picocolors26.default.red("\u2715 failed")} \u2014 retry it on the approve page: ${import_picocolors26.default.cyan(proposed.approval_url)} ` + import_picocolors26.default.dim(`(until ${new Date(proposed.expires_at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })})`) + "\n"
|
|
77722
78345
|
);
|
|
77723
78346
|
} else {
|
|
77724
|
-
process.stdout.write(` ${describeStatus2(s.status)}${
|
|
78347
|
+
process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors26.default.dim("\u2026")}\r`);
|
|
77725
78348
|
}
|
|
77726
78349
|
}
|
|
77727
78350
|
});
|
|
@@ -77735,7 +78358,7 @@ ${import_picocolors25.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77735
78358
|
profile: opts.profileName,
|
|
77736
78359
|
jsonMode: opts.jsonMode,
|
|
77737
78360
|
origin: activeProfile.mcpOrigin,
|
|
77738
|
-
ttyHeader:
|
|
78361
|
+
ttyHeader: import_picocolors26.default.dim(
|
|
77739
78362
|
"Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
|
|
77740
78363
|
)
|
|
77741
78364
|
});
|
|
@@ -77750,7 +78373,7 @@ ${import_picocolors25.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77750
78373
|
process.exit(1);
|
|
77751
78374
|
}
|
|
77752
78375
|
process.stderr.write(
|
|
77753
|
-
"\n" +
|
|
78376
|
+
"\n" + import_picocolors26.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
77754
78377
|
`)
|
|
77755
78378
|
);
|
|
77756
78379
|
process.exit(1);
|
|
@@ -77768,7 +78391,7 @@ ${import_picocolors25.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77768
78391
|
process.exit(1);
|
|
77769
78392
|
}
|
|
77770
78393
|
process.stderr.write(
|
|
77771
|
-
"\n" +
|
|
78394
|
+
"\n" + import_picocolors26.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
77772
78395
|
`)
|
|
77773
78396
|
);
|
|
77774
78397
|
process.exit(1);
|
|
@@ -77784,7 +78407,7 @@ ${import_picocolors25.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77784
78407
|
process.exit(1);
|
|
77785
78408
|
}
|
|
77786
78409
|
process.stderr.write(
|
|
77787
|
-
"\n" +
|
|
78410
|
+
"\n" + import_picocolors26.default.red(`\u2715 Status poll failed: ${err.message}
|
|
77788
78411
|
`)
|
|
77789
78412
|
);
|
|
77790
78413
|
process.exit(1);
|
|
@@ -77825,39 +78448,39 @@ ${import_picocolors25.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
77825
78448
|
process.stdout.write("\n");
|
|
77826
78449
|
const printLegJournal = () => {
|
|
77827
78450
|
if (legs.length === 0) return;
|
|
77828
|
-
process.stdout.write(
|
|
78451
|
+
process.stdout.write(import_picocolors26.default.bold(" Legs:\n"));
|
|
77829
78452
|
for (const l of legs) {
|
|
77830
|
-
const line2 = l.status === "mined" ?
|
|
78453
|
+
const line2 = l.status === "mined" ? import_picocolors26.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors26.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors26.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors26.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors26.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
|
|
77831
78454
|
process.stdout.write(` ${line2}
|
|
77832
78455
|
`);
|
|
77833
78456
|
}
|
|
77834
78457
|
};
|
|
77835
78458
|
if (final.status === "mined") {
|
|
77836
|
-
process.stdout.write(
|
|
78459
|
+
process.stdout.write(import_picocolors26.default.green("\u2713 Mined.") + "\n");
|
|
77837
78460
|
if (final.tx_hash) {
|
|
77838
78461
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
77839
78462
|
`);
|
|
77840
78463
|
}
|
|
77841
78464
|
if (explorer) {
|
|
77842
|
-
process.stdout.write(` Explorer ${
|
|
78465
|
+
process.stdout.write(` Explorer ${import_picocolors26.default.cyan(explorer)}
|
|
77843
78466
|
`);
|
|
77844
78467
|
}
|
|
77845
78468
|
printLegJournal();
|
|
77846
78469
|
process.exit(0);
|
|
77847
78470
|
}
|
|
77848
78471
|
if (final.status === "failed" && failure?.message) {
|
|
77849
|
-
process.stderr.write(
|
|
78472
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 ${failure.message}
|
|
77850
78473
|
`));
|
|
77851
78474
|
if (retryCommand) {
|
|
77852
78475
|
process.stderr.write(` Retry:
|
|
77853
|
-
${
|
|
78476
|
+
${import_picocolors26.default.cyan(retryCommand)}
|
|
77854
78477
|
`);
|
|
77855
78478
|
}
|
|
77856
78479
|
printLegJournal();
|
|
77857
78480
|
process.exit(1);
|
|
77858
78481
|
}
|
|
77859
78482
|
const label = final.status === "rejected" ? "Rejected by user" : final.status === "expired" ? "Expired (TTL elapsed before approval)" : final.status === "failed" ? "The transaction did not land; nothing moved, and the approval window has closed. Re-run the command to propose it again" : `Ended in unexpected status: ${final.status}`;
|
|
77860
|
-
process.stderr.write(
|
|
78483
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 ${label}.
|
|
77861
78484
|
`));
|
|
77862
78485
|
printLegJournal();
|
|
77863
78486
|
process.exit(1);
|
|
@@ -77877,7 +78500,7 @@ function isAsset(v) {
|
|
|
77877
78500
|
return ASSET_VALUES.has(v.toLowerCase());
|
|
77878
78501
|
}
|
|
77879
78502
|
function failArg(msg) {
|
|
77880
|
-
process.stderr.write(
|
|
78503
|
+
process.stderr.write(import_picocolors27.default.red(`\u2715 ${msg}
|
|
77881
78504
|
`));
|
|
77882
78505
|
process.exit(2);
|
|
77883
78506
|
}
|
|
@@ -77885,11 +78508,11 @@ async function swap(amount, fromAsset, opts) {
|
|
|
77885
78508
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
77886
78509
|
const resolved = await resolveProfile(requested);
|
|
77887
78510
|
if (!resolved) {
|
|
77888
|
-
process.stderr.write(
|
|
78511
|
+
process.stderr.write(import_picocolors27.default.red("Not logged in. Run agentgates login first.\n"));
|
|
77889
78512
|
process.exit(2);
|
|
77890
78513
|
}
|
|
77891
78514
|
if (resolved.autoSelected) {
|
|
77892
|
-
process.stderr.write(
|
|
78515
|
+
process.stderr.write(import_picocolors27.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
77893
78516
|
`));
|
|
77894
78517
|
}
|
|
77895
78518
|
const { profile, name: profileName } = resolved;
|
|
@@ -77897,12 +78520,12 @@ async function swap(amount, fromAsset, opts) {
|
|
|
77897
78520
|
const jsonMode7 = opts.json === true || !stdoutIsTty;
|
|
77898
78521
|
const amountNumber = Number(amount);
|
|
77899
78522
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
77900
|
-
failArg(`amount must be a positive number (got ${
|
|
78523
|
+
failArg(`amount must be a positive number (got ${import_picocolors27.default.bold(amount)}).`);
|
|
77901
78524
|
}
|
|
77902
78525
|
const fromAssetNorm = fromAsset.toLowerCase();
|
|
77903
78526
|
if (!isAsset(fromAssetNorm)) {
|
|
77904
78527
|
failArg(
|
|
77905
|
-
`from-asset must be ${
|
|
78528
|
+
`from-asset must be ${import_picocolors27.default.bold("native")} or ${import_picocolors27.default.bold("usdc")} (got ${import_picocolors27.default.bold(fromAsset)}).`
|
|
77906
78529
|
);
|
|
77907
78530
|
}
|
|
77908
78531
|
if (!opts.toAsset) {
|
|
@@ -77911,7 +78534,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
77911
78534
|
const toAssetNorm = opts.toAsset.toLowerCase();
|
|
77912
78535
|
if (!isAsset(toAssetNorm)) {
|
|
77913
78536
|
failArg(
|
|
77914
|
-
`--to-asset must be ${
|
|
78537
|
+
`--to-asset must be ${import_picocolors27.default.bold("native")} or ${import_picocolors27.default.bold("usdc")} (got ${import_picocolors27.default.bold(opts.toAsset)}).`
|
|
77915
78538
|
);
|
|
77916
78539
|
}
|
|
77917
78540
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -78040,9 +78663,9 @@ async function swap(amount, fromAsset, opts) {
|
|
|
78040
78663
|
}
|
|
78041
78664
|
|
|
78042
78665
|
// src/commands/batch.ts
|
|
78043
|
-
var
|
|
78666
|
+
var import_picocolors28 = __toESM(require_picocolors(), 1);
|
|
78044
78667
|
function failArg2(msg) {
|
|
78045
|
-
process.stderr.write(
|
|
78668
|
+
process.stderr.write(import_picocolors28.default.red(`\u2715 ${msg}
|
|
78046
78669
|
`));
|
|
78047
78670
|
process.exit(2);
|
|
78048
78671
|
}
|
|
@@ -78050,7 +78673,7 @@ async function batch(opts) {
|
|
|
78050
78673
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
78051
78674
|
const resolved = await resolveProfile(requested);
|
|
78052
78675
|
if (!resolved) {
|
|
78053
|
-
process.stderr.write(
|
|
78676
|
+
process.stderr.write(import_picocolors28.default.red("Not logged in. Run agentgates login first.\n"));
|
|
78054
78677
|
process.exit(2);
|
|
78055
78678
|
}
|
|
78056
78679
|
const { name: profileName, profile } = resolved;
|
|
@@ -78104,14 +78727,14 @@ async function batch(opts) {
|
|
|
78104
78727
|
}
|
|
78105
78728
|
|
|
78106
78729
|
// src/commands/fund-wallet.ts
|
|
78107
|
-
var
|
|
78730
|
+
var import_picocolors29 = __toESM(require_picocolors(), 1);
|
|
78108
78731
|
var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
|
|
78109
78732
|
var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
78110
78733
|
function isAddressTarget(target) {
|
|
78111
78734
|
return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
|
|
78112
78735
|
}
|
|
78113
78736
|
function failArg3(msg) {
|
|
78114
|
-
process.stderr.write(
|
|
78737
|
+
process.stderr.write(import_picocolors29.default.red(`\u2715 ${msg}
|
|
78115
78738
|
`));
|
|
78116
78739
|
process.exit(2);
|
|
78117
78740
|
}
|
|
@@ -78119,7 +78742,7 @@ async function fundWallet(address, opts) {
|
|
|
78119
78742
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
78120
78743
|
const resolved = await resolveProfile(requested);
|
|
78121
78744
|
if (!resolved) {
|
|
78122
|
-
process.stderr.write(
|
|
78745
|
+
process.stderr.write(import_picocolors29.default.red("Not logged in. Run agentgates login first.\n"));
|
|
78123
78746
|
process.exit(2);
|
|
78124
78747
|
}
|
|
78125
78748
|
const { name: profileName, profile } = resolved;
|
|
@@ -78196,11 +78819,11 @@ async function fundWallet(address, opts) {
|
|
|
78196
78819
|
}
|
|
78197
78820
|
|
|
78198
78821
|
// src/commands/earn-supply.ts
|
|
78199
|
-
var
|
|
78822
|
+
var import_picocolors30 = __toESM(require_picocolors(), 1);
|
|
78200
78823
|
var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
78201
78824
|
var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
78202
78825
|
function failArg4(msg) {
|
|
78203
|
-
process.stderr.write(
|
|
78826
|
+
process.stderr.write(import_picocolors30.default.red(`\u2715 ${msg}
|
|
78204
78827
|
`));
|
|
78205
78828
|
process.exit(2);
|
|
78206
78829
|
}
|
|
@@ -78208,11 +78831,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
78208
78831
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
78209
78832
|
const resolved = await resolveProfile(requested);
|
|
78210
78833
|
if (!resolved) {
|
|
78211
|
-
process.stderr.write(
|
|
78834
|
+
process.stderr.write(import_picocolors30.default.red("Not logged in. Run agentgates login first.\n"));
|
|
78212
78835
|
process.exit(2);
|
|
78213
78836
|
}
|
|
78214
78837
|
if (resolved.autoSelected) {
|
|
78215
|
-
process.stderr.write(
|
|
78838
|
+
process.stderr.write(import_picocolors30.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
78216
78839
|
`));
|
|
78217
78840
|
}
|
|
78218
78841
|
const { profile, name: profileName } = resolved;
|
|
@@ -78220,12 +78843,12 @@ async function earnSupply(amount, asset, opts) {
|
|
|
78220
78843
|
const jsonMode7 = opts.json === true || !stdoutIsTty;
|
|
78221
78844
|
const amountNumber = Number(amount);
|
|
78222
78845
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
78223
|
-
failArg4(`amount must be a positive number (got ${
|
|
78846
|
+
failArg4(`amount must be a positive number (got ${import_picocolors30.default.bold(amount)}).`);
|
|
78224
78847
|
}
|
|
78225
78848
|
const assetNorm = asset.toLowerCase();
|
|
78226
78849
|
if (!ASSET_VALUES2.has(assetNorm)) {
|
|
78227
78850
|
failArg4(
|
|
78228
|
-
`asset must be ${
|
|
78851
|
+
`asset must be ${import_picocolors30.default.bold("native")} or ${import_picocolors30.default.bold("usdc")} (got ${import_picocolors30.default.bold(asset)}).`
|
|
78229
78852
|
);
|
|
78230
78853
|
}
|
|
78231
78854
|
if (!opts.chain) {
|
|
@@ -78237,7 +78860,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
78237
78860
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
78238
78861
|
if (!PROTOCOLS.has(protocolNorm)) {
|
|
78239
78862
|
failArg4(
|
|
78240
|
-
`--protocol must be ${
|
|
78863
|
+
`--protocol must be ${import_picocolors30.default.bold("aave_v3")} or ${import_picocolors30.default.bold("kamino_lend")} (got ${import_picocolors30.default.bold(opts.protocol)}).`
|
|
78241
78864
|
);
|
|
78242
78865
|
}
|
|
78243
78866
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -78289,11 +78912,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
78289
78912
|
}
|
|
78290
78913
|
|
|
78291
78914
|
// src/commands/earn-withdraw.ts
|
|
78292
|
-
var
|
|
78915
|
+
var import_picocolors31 = __toESM(require_picocolors(), 1);
|
|
78293
78916
|
var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
78294
78917
|
var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
78295
78918
|
function failArg5(msg) {
|
|
78296
|
-
process.stderr.write(
|
|
78919
|
+
process.stderr.write(import_picocolors31.default.red(`\u2715 ${msg}
|
|
78297
78920
|
`));
|
|
78298
78921
|
process.exit(2);
|
|
78299
78922
|
}
|
|
@@ -78301,11 +78924,11 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
78301
78924
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
78302
78925
|
const resolved = await resolveProfile(requested);
|
|
78303
78926
|
if (!resolved) {
|
|
78304
|
-
process.stderr.write(
|
|
78927
|
+
process.stderr.write(import_picocolors31.default.red("Not logged in. Run agentgates login first.\n"));
|
|
78305
78928
|
process.exit(2);
|
|
78306
78929
|
}
|
|
78307
78930
|
if (resolved.autoSelected) {
|
|
78308
|
-
process.stderr.write(
|
|
78931
|
+
process.stderr.write(import_picocolors31.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
78309
78932
|
`));
|
|
78310
78933
|
}
|
|
78311
78934
|
const { profile, name: profileName } = resolved;
|
|
@@ -78316,14 +78939,14 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
78316
78939
|
const amountNumber = Number(amountOrMax);
|
|
78317
78940
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
78318
78941
|
failArg5(
|
|
78319
|
-
`<amount-or-max> must be a positive number or the literal string "max" (got ${
|
|
78942
|
+
`<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors31.default.bold(amountOrMax)}).`
|
|
78320
78943
|
);
|
|
78321
78944
|
}
|
|
78322
78945
|
}
|
|
78323
78946
|
const assetNorm = asset.toLowerCase();
|
|
78324
78947
|
if (!ASSET_VALUES3.has(assetNorm)) {
|
|
78325
78948
|
failArg5(
|
|
78326
|
-
`asset must be ${
|
|
78949
|
+
`asset must be ${import_picocolors31.default.bold("native")} or ${import_picocolors31.default.bold("usdc")} (got ${import_picocolors31.default.bold(asset)}).`
|
|
78327
78950
|
);
|
|
78328
78951
|
}
|
|
78329
78952
|
if (!opts.chain) {
|
|
@@ -78335,7 +78958,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
78335
78958
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
78336
78959
|
if (!PROTOCOLS2.has(protocolNorm)) {
|
|
78337
78960
|
failArg5(
|
|
78338
|
-
`--protocol must be ${
|
|
78961
|
+
`--protocol must be ${import_picocolors31.default.bold("aave_v3")} or ${import_picocolors31.default.bold("kamino_lend")} (got ${import_picocolors31.default.bold(opts.protocol)}).`
|
|
78339
78962
|
);
|
|
78340
78963
|
}
|
|
78341
78964
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -78387,7 +79010,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
78387
79010
|
}
|
|
78388
79011
|
|
|
78389
79012
|
// src/commands/eat.ts
|
|
78390
|
-
var
|
|
79013
|
+
var import_picocolors32 = __toESM(require_picocolors(), 1);
|
|
78391
79014
|
function parseLineJson(values) {
|
|
78392
79015
|
const lines = [];
|
|
78393
79016
|
for (const value of values) {
|
|
@@ -78414,11 +79037,11 @@ function parseLineJson(values) {
|
|
|
78414
79037
|
async function loadResolvedProfile(requested) {
|
|
78415
79038
|
const resolved = await resolveProfile(requested);
|
|
78416
79039
|
if (!resolved) {
|
|
78417
|
-
process.stderr.write(
|
|
79040
|
+
process.stderr.write(import_picocolors32.default.red("Not logged in. Run agentgates login first.\n"));
|
|
78418
79041
|
process.exit(2);
|
|
78419
79042
|
}
|
|
78420
79043
|
if (resolved.autoSelected) {
|
|
78421
|
-
process.stderr.write(
|
|
79044
|
+
process.stderr.write(import_picocolors32.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
78422
79045
|
`));
|
|
78423
79046
|
}
|
|
78424
79047
|
return resolved;
|
|
@@ -78429,12 +79052,12 @@ function printResult(res, jsonMode7) {
|
|
|
78429
79052
|
return;
|
|
78430
79053
|
}
|
|
78431
79054
|
if (res.blocked) {
|
|
78432
|
-
process.stderr.write(
|
|
79055
|
+
process.stderr.write(import_picocolors32.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
|
|
78433
79056
|
`));
|
|
78434
79057
|
if (res.upgrade_url) {
|
|
78435
79058
|
process.stderr.write(
|
|
78436
79059
|
` Open this to grant access, then re-run the command:
|
|
78437
|
-
${
|
|
79060
|
+
${import_picocolors32.default.cyan(res.upgrade_url)}
|
|
78438
79061
|
`
|
|
78439
79062
|
);
|
|
78440
79063
|
}
|
|
@@ -78465,7 +79088,7 @@ async function postRestaurant(path8, body, resolved, jsonMode7) {
|
|
|
78465
79088
|
profile: resolved.profile,
|
|
78466
79089
|
profileName: resolved.name,
|
|
78467
79090
|
jsonMode: jsonMode7,
|
|
78468
|
-
ttyHeader:
|
|
79091
|
+
ttyHeader: import_picocolors32.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
78469
79092
|
fn: (bearer, origin) => apiFetch(path8, { method: "POST", bearer, origin, body })
|
|
78470
79093
|
});
|
|
78471
79094
|
if (outcome.kind === "auth_failed") {
|
|
@@ -78475,7 +79098,7 @@ async function postRestaurant(path8, body, resolved, jsonMode7) {
|
|
|
78475
79098
|
);
|
|
78476
79099
|
process.exit(1);
|
|
78477
79100
|
}
|
|
78478
|
-
process.stderr.write(
|
|
79101
|
+
process.stderr.write(import_picocolors32.default.red(`\u2715 ${outcome.reason}.
|
|
78479
79102
|
`));
|
|
78480
79103
|
process.exit(1);
|
|
78481
79104
|
}
|
|
@@ -78488,7 +79111,7 @@ async function postRestaurant(path8, body, resolved, jsonMode7) {
|
|
|
78488
79111
|
);
|
|
78489
79112
|
process.exit(1);
|
|
78490
79113
|
}
|
|
78491
|
-
process.stderr.write(
|
|
79114
|
+
process.stderr.write(import_picocolors32.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
78492
79115
|
`));
|
|
78493
79116
|
process.exit(1);
|
|
78494
79117
|
}
|
|
@@ -78501,7 +79124,7 @@ async function searchFood(opts) {
|
|
|
78501
79124
|
const jsonMode7 = opts.json === true || process.stdout.isTTY !== true;
|
|
78502
79125
|
if (!opts.location && !opts.name) {
|
|
78503
79126
|
process.stderr.write(
|
|
78504
|
-
|
|
79127
|
+
import_picocolors32.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
|
|
78505
79128
|
);
|
|
78506
79129
|
process.exit(2);
|
|
78507
79130
|
}
|
|
@@ -78522,7 +79145,7 @@ async function menuFood(items, opts) {
|
|
|
78522
79145
|
const jsonMode7 = opts.json === true || process.stdout.isTTY !== true;
|
|
78523
79146
|
if (!opts.brand || !opts.address) {
|
|
78524
79147
|
process.stderr.write(
|
|
78525
|
-
|
|
79148
|
+
import_picocolors32.default.red(
|
|
78526
79149
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
78527
79150
|
)
|
|
78528
79151
|
);
|
|
@@ -78542,7 +79165,7 @@ async function orderFood(items, opts) {
|
|
|
78542
79165
|
const jsonMode7 = opts.json === true || process.stdout.isTTY !== true;
|
|
78543
79166
|
if (!opts.brand || !opts.address) {
|
|
78544
79167
|
process.stderr.write(
|
|
78545
|
-
|
|
79168
|
+
import_picocolors32.default.red(
|
|
78546
79169
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
78547
79170
|
)
|
|
78548
79171
|
);
|
|
@@ -78552,14 +79175,14 @@ async function orderFood(items, opts) {
|
|
|
78552
79175
|
try {
|
|
78553
79176
|
structuredLines = parseLineJson(opts.lineJson ?? []);
|
|
78554
79177
|
} catch (e) {
|
|
78555
|
-
process.stderr.write(
|
|
79178
|
+
process.stderr.write(import_picocolors32.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
|
|
78556
79179
|
`));
|
|
78557
79180
|
process.exit(2);
|
|
78558
79181
|
}
|
|
78559
79182
|
const lines = [...items ?? [], ...structuredLines];
|
|
78560
79183
|
if (lines.length === 0) {
|
|
78561
79184
|
process.stderr.write(
|
|
78562
|
-
|
|
79185
|
+
import_picocolors32.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")
|
|
78563
79186
|
);
|
|
78564
79187
|
process.exit(2);
|
|
78565
79188
|
}
|
|
@@ -78593,7 +79216,7 @@ async function orderFood(items, opts) {
|
|
|
78593
79216
|
if (!agentCard.will_attempt) {
|
|
78594
79217
|
if (!jsonMode7) {
|
|
78595
79218
|
process.stderr.write(
|
|
78596
|
-
|
|
79219
|
+
import_picocolors32.default.yellow(
|
|
78597
79220
|
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
78598
79221
|
`
|
|
78599
79222
|
)
|
|
@@ -78610,7 +79233,7 @@ async function orderFood(items, opts) {
|
|
|
78610
79233
|
}
|
|
78611
79234
|
if (verdict.status === "paid") {
|
|
78612
79235
|
process.stdout.write(
|
|
78613
|
-
|
|
79236
|
+
import_picocolors32.default.green(
|
|
78614
79237
|
`Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
|
|
78615
79238
|
)
|
|
78616
79239
|
);
|
|
@@ -78618,7 +79241,7 @@ async function orderFood(items, opts) {
|
|
|
78618
79241
|
}
|
|
78619
79242
|
if (verdict.status === "failed") {
|
|
78620
79243
|
process.stderr.write(
|
|
78621
|
-
|
|
79244
|
+
import_picocolors32.default.yellow(
|
|
78622
79245
|
`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.
|
|
78623
79246
|
`
|
|
78624
79247
|
)
|
|
@@ -78628,7 +79251,7 @@ async function orderFood(items, opts) {
|
|
|
78628
79251
|
}
|
|
78629
79252
|
if (verdict.status === "unconfirmed") {
|
|
78630
79253
|
process.stderr.write(
|
|
78631
|
-
|
|
79254
|
+
import_picocolors32.default.red(
|
|
78632
79255
|
"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}
|
|
78633
79256
|
` : "")
|
|
78634
79257
|
)
|
|
@@ -78637,7 +79260,7 @@ async function orderFood(items, opts) {
|
|
|
78637
79260
|
return;
|
|
78638
79261
|
}
|
|
78639
79262
|
process.stderr.write(
|
|
78640
|
-
|
|
79263
|
+
import_picocolors32.default.dim(
|
|
78641
79264
|
`Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
|
|
78642
79265
|
)
|
|
78643
79266
|
);
|
|
@@ -78662,7 +79285,7 @@ var POLL_BUDGET_MS = 1e5;
|
|
|
78662
79285
|
var POLL_INTERVAL_MS2 = 3500;
|
|
78663
79286
|
async function pollOrderVerdict(orderId, resolved, jsonMode7) {
|
|
78664
79287
|
if (!jsonMode7) {
|
|
78665
|
-
process.stderr.write(
|
|
79288
|
+
process.stderr.write(import_picocolors32.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
|
|
78666
79289
|
}
|
|
78667
79290
|
const deadline = Date.now() + POLL_BUDGET_MS;
|
|
78668
79291
|
let last = {
|
|
@@ -78732,17 +79355,17 @@ async function statusFood(orderId, opts) {
|
|
|
78732
79355
|
}
|
|
78733
79356
|
|
|
78734
79357
|
// src/commands/bounties.ts
|
|
78735
|
-
var
|
|
79358
|
+
var import_picocolors33 = __toESM(require_picocolors(), 1);
|
|
78736
79359
|
init_constants();
|
|
78737
79360
|
async function withProfile(opts, path8, init2) {
|
|
78738
79361
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
78739
79362
|
const resolved = await resolveProfile(requested);
|
|
78740
79363
|
if (!resolved) {
|
|
78741
|
-
process.stderr.write(
|
|
79364
|
+
process.stderr.write(import_picocolors33.default.red("Not logged in. Run agentgates login first.\n"));
|
|
78742
79365
|
process.exit(2);
|
|
78743
79366
|
}
|
|
78744
79367
|
if (resolved.autoSelected) {
|
|
78745
|
-
process.stderr.write(
|
|
79368
|
+
process.stderr.write(import_picocolors33.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
78746
79369
|
`));
|
|
78747
79370
|
}
|
|
78748
79371
|
const { profile, name: profileName } = resolved;
|
|
@@ -78751,7 +79374,7 @@ async function withProfile(opts, path8, init2) {
|
|
|
78751
79374
|
profile,
|
|
78752
79375
|
profileName,
|
|
78753
79376
|
jsonMode: jsonMode7,
|
|
78754
|
-
ttyHeader:
|
|
79377
|
+
ttyHeader: import_picocolors33.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
78755
79378
|
fn: (bearer, origin) => apiFetch(path8, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
|
|
78756
79379
|
});
|
|
78757
79380
|
if (outcome.kind === "auth_failed") {
|
|
@@ -78759,14 +79382,14 @@ async function withProfile(opts, path8, init2) {
|
|
|
78759
79382
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
78760
79383
|
process.exit(1);
|
|
78761
79384
|
}
|
|
78762
|
-
process.stderr.write(
|
|
79385
|
+
process.stderr.write(import_picocolors33.default.red(`\u2715 ${outcome.reason}.
|
|
78763
79386
|
`));
|
|
78764
79387
|
process.exit(1);
|
|
78765
79388
|
}
|
|
78766
79389
|
if (outcome.kind === "error") {
|
|
78767
79390
|
const err = outcome.error;
|
|
78768
79391
|
if (err instanceof ApiError) {
|
|
78769
|
-
process.stderr.write(
|
|
79392
|
+
process.stderr.write(import_picocolors33.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
78770
79393
|
`));
|
|
78771
79394
|
process.exit(1);
|
|
78772
79395
|
}
|
|
@@ -78780,12 +79403,12 @@ function handleBlocked(res, jsonMode7) {
|
|
|
78780
79403
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
78781
79404
|
process.exit(1);
|
|
78782
79405
|
}
|
|
78783
|
-
process.stderr.write(
|
|
79406
|
+
process.stderr.write(import_picocolors33.default.yellow(`
|
|
78784
79407
|
${res.reason ?? "Blocked."}
|
|
78785
79408
|
`));
|
|
78786
79409
|
if (res.upgrade_url) {
|
|
78787
79410
|
process.stderr.write(`
|
|
78788
|
-
${
|
|
79411
|
+
${import_picocolors33.default.bold(res.upgrade_url)}
|
|
78789
79412
|
|
|
78790
79413
|
`);
|
|
78791
79414
|
}
|
|
@@ -78828,14 +79451,14 @@ function printTable(rows) {
|
|
|
78828
79451
|
const cLeft = w("left", 4);
|
|
78829
79452
|
const cSubs = w("subs", 4);
|
|
78830
79453
|
process.stdout.write(
|
|
78831
|
-
|
|
79454
|
+
import_picocolors33.default.dim(
|
|
78832
79455
|
"Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
|
|
78833
79456
|
) + "\n"
|
|
78834
79457
|
);
|
|
78835
79458
|
for (const c of cells) {
|
|
78836
|
-
const title = c.live ?
|
|
79459
|
+
const title = c.live ? import_picocolors33.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
|
|
78837
79460
|
process.stdout.write(
|
|
78838
|
-
|
|
79461
|
+
import_picocolors33.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors33.default.dim(c.id) + "\n"
|
|
78839
79462
|
);
|
|
78840
79463
|
}
|
|
78841
79464
|
}
|
|
@@ -78847,11 +79470,11 @@ async function listBounties(opts) {
|
|
|
78847
79470
|
const min = opts.min !== void 0 ? Number(opts.min) : void 0;
|
|
78848
79471
|
const max = opts.max !== void 0 ? Number(opts.max) : void 0;
|
|
78849
79472
|
if (min !== void 0 && !Number.isFinite(min)) {
|
|
78850
|
-
process.stderr.write(
|
|
79473
|
+
process.stderr.write(import_picocolors33.default.red("\u2715 --min must be a number.\n"));
|
|
78851
79474
|
process.exit(2);
|
|
78852
79475
|
}
|
|
78853
79476
|
if (max !== void 0 && !Number.isFinite(max)) {
|
|
78854
|
-
process.stderr.write(
|
|
79477
|
+
process.stderr.write(import_picocolors33.default.red("\u2715 --max must be a number.\n"));
|
|
78855
79478
|
process.exit(2);
|
|
78856
79479
|
}
|
|
78857
79480
|
rows = rows.filter((r) => {
|
|
@@ -78876,7 +79499,7 @@ async function listBounties(opts) {
|
|
|
78876
79499
|
});
|
|
78877
79500
|
const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
|
|
78878
79501
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
78879
|
-
process.stderr.write(
|
|
79502
|
+
process.stderr.write(import_picocolors33.default.red("\u2715 --limit must be a positive number.\n"));
|
|
78880
79503
|
process.exit(2);
|
|
78881
79504
|
}
|
|
78882
79505
|
const shown2 = rows.slice(0, limit);
|
|
@@ -78885,13 +79508,13 @@ async function listBounties(opts) {
|
|
|
78885
79508
|
return;
|
|
78886
79509
|
}
|
|
78887
79510
|
if (shown2.length === 0) {
|
|
78888
|
-
process.stdout.write(
|
|
79511
|
+
process.stdout.write(import_picocolors33.default.dim("No active bounties match.\n"));
|
|
78889
79512
|
return;
|
|
78890
79513
|
}
|
|
78891
79514
|
printTable(shown2);
|
|
78892
79515
|
const clipped = rows.length - shown2.length;
|
|
78893
79516
|
process.stdout.write(
|
|
78894
|
-
"\n" +
|
|
79517
|
+
"\n" + import_picocolors33.default.dim(
|
|
78895
79518
|
`${shown2.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
|
|
78896
79519
|
`
|
|
78897
79520
|
)
|
|
@@ -78902,7 +79525,7 @@ async function showBounty(id2, opts) {
|
|
|
78902
79525
|
const jsonMode7 = opts.json === true;
|
|
78903
79526
|
const clean3 = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
|
|
78904
79527
|
if (!clean3) {
|
|
78905
|
-
process.stderr.write(
|
|
79528
|
+
process.stderr.write(import_picocolors33.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
|
|
78906
79529
|
process.exit(2);
|
|
78907
79530
|
}
|
|
78908
79531
|
const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean3)}`);
|
|
@@ -78913,26 +79536,26 @@ async function showBounty(id2, opts) {
|
|
|
78913
79536
|
}
|
|
78914
79537
|
const b2 = res.bounty;
|
|
78915
79538
|
if (!b2) {
|
|
78916
|
-
process.stdout.write(
|
|
79539
|
+
process.stdout.write(import_picocolors33.default.dim("Not found.\n"));
|
|
78917
79540
|
return;
|
|
78918
79541
|
}
|
|
78919
|
-
process.stdout.write("\n" +
|
|
79542
|
+
process.stdout.write("\n" + import_picocolors33.default.bold(b2.title) + "\n\n");
|
|
78920
79543
|
process.stdout.write(b2.description + "\n\n");
|
|
78921
79544
|
process.stdout.write(
|
|
78922
|
-
|
|
79545
|
+
import_picocolors33.default.bold(fmtAmount(b2.amount)) + import_picocolors33.default.dim(" USDC") + import_picocolors33.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors33.default.green(" \xB7 LIVE now") : "") + "\n"
|
|
78923
79546
|
);
|
|
78924
79547
|
if (b2.claimsAllowed && b2.claimsAllowed > 1) {
|
|
78925
79548
|
const left = Math.max(0, b2.claimsAllowed - (b2.claimsPaid ?? 0));
|
|
78926
79549
|
process.stdout.write(
|
|
78927
|
-
|
|
79550
|
+
import_picocolors33.default.dim(
|
|
78928
79551
|
`${left} of ${b2.claimsAllowed} claims left` + (b2.perClaimAmount != null ? `, ${fmtAmount(b2.perClaimAmount)} each` : "")
|
|
78929
79552
|
) + "\n"
|
|
78930
79553
|
);
|
|
78931
79554
|
}
|
|
78932
|
-
if (b2.evidenceType) process.stdout.write(
|
|
78933
|
-
if (b2.expiresAt) process.stdout.write(
|
|
79555
|
+
if (b2.evidenceType) process.stdout.write(import_picocolors33.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
|
|
79556
|
+
if (b2.expiresAt) process.stdout.write(import_picocolors33.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
|
|
78934
79557
|
if (b2.geoLabel && b2.geoScope !== "global") {
|
|
78935
|
-
process.stdout.write(
|
|
79558
|
+
process.stdout.write(import_picocolors33.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
|
|
78936
79559
|
}
|
|
78937
79560
|
if (res.url) process.stdout.write("\n" + res.url + "\n");
|
|
78938
79561
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -78950,7 +79573,7 @@ async function myBounties(opts) {
|
|
|
78950
79573
|
}
|
|
78951
79574
|
if (rows.length === 0) {
|
|
78952
79575
|
process.stdout.write(
|
|
78953
|
-
|
|
79576
|
+
import_picocolors33.default.dim(
|
|
78954
79577
|
status4 ? `No bounties of yours are ${status4}.
|
|
78955
79578
|
` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
|
|
78956
79579
|
)
|
|
@@ -78960,7 +79583,7 @@ async function myBounties(opts) {
|
|
|
78960
79583
|
printTable(rows);
|
|
78961
79584
|
const subs = res.submissions ?? [];
|
|
78962
79585
|
if (subs.length > 0) {
|
|
78963
|
-
process.stdout.write("\n" +
|
|
79586
|
+
process.stdout.write("\n" + import_picocolors33.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
|
|
78964
79587
|
`));
|
|
78965
79588
|
}
|
|
78966
79589
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -78979,19 +79602,19 @@ async function bountyFeed(opts) {
|
|
|
78979
79602
|
}
|
|
78980
79603
|
const subs = res.submissions ?? [];
|
|
78981
79604
|
if (subs.length === 0) {
|
|
78982
|
-
process.stdout.write(
|
|
79605
|
+
process.stdout.write(import_picocolors33.default.dim("Nothing in the feed for that filter.\n"));
|
|
78983
79606
|
return;
|
|
78984
79607
|
}
|
|
78985
79608
|
process.stdout.write(
|
|
78986
|
-
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ?
|
|
79609
|
+
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors33.default.dim(" More available.") : "") + "\n"
|
|
78987
79610
|
);
|
|
78988
|
-
process.stdout.write(
|
|
79611
|
+
process.stdout.write(import_picocolors33.default.dim("Use --json for the full rows.\n"));
|
|
78989
79612
|
}
|
|
78990
79613
|
async function draftBounty(opts) {
|
|
78991
79614
|
const jsonMode7 = opts.json === true;
|
|
78992
79615
|
const amountNum = Number(opts.amount);
|
|
78993
79616
|
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
78994
|
-
process.stderr.write(
|
|
79617
|
+
process.stderr.write(import_picocolors33.default.red("\u2715 --amount must be a positive number of USDC.\n"));
|
|
78995
79618
|
process.exit(2);
|
|
78996
79619
|
}
|
|
78997
79620
|
const res = await withProfile(opts, "/api/bounties", {
|
|
@@ -79009,20 +79632,20 @@ async function draftBounty(opts) {
|
|
|
79009
79632
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
79010
79633
|
return;
|
|
79011
79634
|
}
|
|
79012
|
-
process.stdout.write("\n" +
|
|
79635
|
+
process.stdout.write("\n" + import_picocolors33.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
|
|
79013
79636
|
|
|
79014
79637
|
`);
|
|
79015
|
-
process.stdout.write(
|
|
79638
|
+
process.stdout.write(import_picocolors33.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
|
|
79016
79639
|
if (res.fund_url) {
|
|
79017
|
-
process.stdout.write("\nFund it here:\n" +
|
|
79018
|
-
process.stdout.write(
|
|
79640
|
+
process.stdout.write("\nFund it here:\n" + import_picocolors33.default.bold(res.fund_url) + "\n\n");
|
|
79641
|
+
process.stdout.write(import_picocolors33.default.dim("Funding happens in your browser with your own wallet.\n"));
|
|
79019
79642
|
}
|
|
79020
79643
|
}
|
|
79021
79644
|
|
|
79022
79645
|
// src/commands/bounty-money.ts
|
|
79023
|
-
var
|
|
79646
|
+
var import_picocolors34 = __toESM(require_picocolors(), 1);
|
|
79024
79647
|
function failArg6(message) {
|
|
79025
|
-
process.stderr.write(
|
|
79648
|
+
process.stderr.write(import_picocolors34.default.red(`${message}
|
|
79026
79649
|
`));
|
|
79027
79650
|
process.exit(2);
|
|
79028
79651
|
}
|
|
@@ -79034,12 +79657,12 @@ async function loadProfileOrExit(requested, jsonMode7) {
|
|
|
79034
79657
|
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
|
|
79035
79658
|
);
|
|
79036
79659
|
} else {
|
|
79037
|
-
process.stderr.write(
|
|
79660
|
+
process.stderr.write(import_picocolors34.default.red("Not logged in. Run agentgates login first.\n"));
|
|
79038
79661
|
}
|
|
79039
79662
|
process.exit(2);
|
|
79040
79663
|
}
|
|
79041
79664
|
if (resolved.autoSelected && !jsonMode7) {
|
|
79042
|
-
process.stderr.write(
|
|
79665
|
+
process.stderr.write(import_picocolors34.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
79043
79666
|
`));
|
|
79044
79667
|
}
|
|
79045
79668
|
return { profile: resolved.profile, profileName: resolved.name };
|
|
@@ -79144,17 +79767,17 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
79144
79767
|
}
|
|
79145
79768
|
|
|
79146
79769
|
// src/commands/bounty-work.ts
|
|
79147
|
-
var
|
|
79770
|
+
var import_picocolors35 = __toESM(require_picocolors(), 1);
|
|
79148
79771
|
init_constants();
|
|
79149
79772
|
async function runWork(path8, body, opts) {
|
|
79150
79773
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
79151
79774
|
const resolved = await resolveProfile(requested);
|
|
79152
79775
|
if (!resolved) {
|
|
79153
|
-
process.stderr.write(
|
|
79776
|
+
process.stderr.write(import_picocolors35.default.red("Not logged in. Run agentgates login first.\n"));
|
|
79154
79777
|
process.exit(2);
|
|
79155
79778
|
}
|
|
79156
79779
|
if (resolved.autoSelected) {
|
|
79157
|
-
process.stderr.write(
|
|
79780
|
+
process.stderr.write(import_picocolors35.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
79158
79781
|
`));
|
|
79159
79782
|
}
|
|
79160
79783
|
const jsonMode7 = opts.json === true;
|
|
@@ -79162,7 +79785,7 @@ async function runWork(path8, body, opts) {
|
|
|
79162
79785
|
profile: resolved.profile,
|
|
79163
79786
|
profileName: resolved.name,
|
|
79164
79787
|
jsonMode: jsonMode7,
|
|
79165
|
-
ttyHeader:
|
|
79788
|
+
ttyHeader: import_picocolors35.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
79166
79789
|
fn: (bearer, origin) => apiFetch(path8, { bearer, origin, method: "POST", body })
|
|
79167
79790
|
});
|
|
79168
79791
|
if (outcome.kind === "auth_failed") {
|
|
@@ -79170,7 +79793,7 @@ async function runWork(path8, body, opts) {
|
|
|
79170
79793
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
79171
79794
|
process.exit(1);
|
|
79172
79795
|
}
|
|
79173
|
-
process.stderr.write(
|
|
79796
|
+
process.stderr.write(import_picocolors35.default.red(`\u2715 ${outcome.reason}.
|
|
79174
79797
|
`));
|
|
79175
79798
|
process.exit(1);
|
|
79176
79799
|
}
|
|
@@ -79180,7 +79803,7 @@ async function runWork(path8, body, opts) {
|
|
|
79180
79803
|
if (jsonMode7) {
|
|
79181
79804
|
process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
|
|
79182
79805
|
} else {
|
|
79183
|
-
process.stderr.write(
|
|
79806
|
+
process.stderr.write(import_picocolors35.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
79184
79807
|
`));
|
|
79185
79808
|
}
|
|
79186
79809
|
process.exit(1);
|
|
@@ -79193,11 +79816,11 @@ async function runWork(path8, body, opts) {
|
|
|
79193
79816
|
process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
|
|
79194
79817
|
process.exit(1);
|
|
79195
79818
|
}
|
|
79196
|
-
process.stderr.write(
|
|
79819
|
+
process.stderr.write(import_picocolors35.default.yellow(`
|
|
79197
79820
|
${data4.reason ?? "Blocked."}
|
|
79198
79821
|
`));
|
|
79199
79822
|
if (data4.upgrade_url) process.stderr.write(`
|
|
79200
|
-
${
|
|
79823
|
+
${import_picocolors35.default.bold(data4.upgrade_url)}
|
|
79201
79824
|
|
|
79202
79825
|
`);
|
|
79203
79826
|
process.exit(1);
|
|
@@ -79206,7 +79829,7 @@ ${import_picocolors34.default.bold(data4.upgrade_url)}
|
|
|
79206
79829
|
if (jsonMode7) {
|
|
79207
79830
|
process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
|
|
79208
79831
|
} else {
|
|
79209
|
-
process.stderr.write(
|
|
79832
|
+
process.stderr.write(import_picocolors35.default.red(`\u2715 ${data4.error}
|
|
79210
79833
|
`));
|
|
79211
79834
|
}
|
|
79212
79835
|
process.exit(1);
|
|
@@ -79249,7 +79872,7 @@ async function bountyRetention(bountyId, opts) {
|
|
|
79249
79872
|
}
|
|
79250
79873
|
|
|
79251
79874
|
// src/commands/bounty-deliver.ts
|
|
79252
|
-
var
|
|
79875
|
+
var import_picocolors36 = __toESM(require_picocolors(), 1);
|
|
79253
79876
|
import { spawn as spawn2 } from "node:child_process";
|
|
79254
79877
|
init_constants();
|
|
79255
79878
|
var FLUSH_MS = 400;
|
|
@@ -79259,11 +79882,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
79259
79882
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
79260
79883
|
const resolved = await resolveProfile(requested);
|
|
79261
79884
|
if (!resolved) {
|
|
79262
|
-
process.stderr.write(
|
|
79885
|
+
process.stderr.write(import_picocolors36.default.red("Not logged in. Run agentgates login first.\n"));
|
|
79263
79886
|
process.exit(2);
|
|
79264
79887
|
}
|
|
79265
79888
|
if (resolved.autoSelected && !jsonMode7) {
|
|
79266
|
-
process.stderr.write(
|
|
79889
|
+
process.stderr.write(import_picocolors36.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
79267
79890
|
`));
|
|
79268
79891
|
}
|
|
79269
79892
|
const post3 = async (path8, body) => {
|
|
@@ -79271,7 +79894,7 @@ async function deliver(bountyId, command, opts) {
|
|
|
79271
79894
|
profile: resolved.profile,
|
|
79272
79895
|
profileName: resolved.name,
|
|
79273
79896
|
jsonMode: jsonMode7,
|
|
79274
|
-
ttyHeader:
|
|
79897
|
+
ttyHeader: import_picocolors36.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
79275
79898
|
fn: (bearer, origin) => apiFetch(path8, { bearer, origin, method: "POST", body })
|
|
79276
79899
|
});
|
|
79277
79900
|
if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
|
|
@@ -79282,11 +79905,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
79282
79905
|
if (jsonMode7) {
|
|
79283
79906
|
process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
|
|
79284
79907
|
} else {
|
|
79285
|
-
process.stderr.write(
|
|
79908
|
+
process.stderr.write(import_picocolors36.default.red(`
|
|
79286
79909
|
\u2715 ${msg}
|
|
79287
79910
|
`));
|
|
79288
79911
|
if (data4?.upgrade_url) process.stderr.write(`
|
|
79289
|
-
${
|
|
79912
|
+
${import_picocolors36.default.bold(data4.upgrade_url)}
|
|
79290
79913
|
|
|
79291
79914
|
`);
|
|
79292
79915
|
}
|
|
@@ -79311,7 +79934,7 @@ ${import_picocolors35.default.bold(data4.upgrade_url)}
|
|
|
79311
79934
|
if (!runId) return void die("The service opened a run but did not name it.");
|
|
79312
79935
|
if (!jsonMode7) {
|
|
79313
79936
|
process.stderr.write(
|
|
79314
|
-
|
|
79937
|
+
import_picocolors36.default.bold("\n\u25CF LIVE ") + import_picocolors36.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors36.default.dim(` ${started.url ?? ""}
|
|
79315
79938
|
|
|
79316
79939
|
`)
|
|
79317
79940
|
);
|
|
@@ -79363,10 +79986,10 @@ ${import_picocolors35.default.bold(data4.upgrade_url)}
|
|
|
79363
79986
|
child.stdout.on("data", (d) => consume(d));
|
|
79364
79987
|
child.stderr.setEncoding("utf8");
|
|
79365
79988
|
child.stderr.on("data", (d) => {
|
|
79366
|
-
if (!jsonMode7) process.stderr.write(
|
|
79989
|
+
if (!jsonMode7) process.stderr.write(import_picocolors36.default.dim(d));
|
|
79367
79990
|
});
|
|
79368
79991
|
child.on("error", (err) => {
|
|
79369
|
-
process.stderr.write(
|
|
79992
|
+
process.stderr.write(import_picocolors36.default.red(`
|
|
79370
79993
|
\u2715 Could not run ${command[0]}: ${err.message}
|
|
79371
79994
|
`));
|
|
79372
79995
|
resolve3(127);
|
|
@@ -79403,14 +80026,14 @@ ${import_picocolors35.default.bold(data4.upgrade_url)}
|
|
|
79403
80026
|
}
|
|
79404
80027
|
if (appendFailure) {
|
|
79405
80028
|
process.stderr.write(
|
|
79406
|
-
|
|
80029
|
+
import_picocolors36.default.yellow(`
|
|
79407
80030
|
! Some output did not reach the page: ${appendFailure}
|
|
79408
|
-
`) +
|
|
80031
|
+
`) + import_picocolors36.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
|
|
79409
80032
|
);
|
|
79410
80033
|
}
|
|
79411
80034
|
if (exitCode) {
|
|
79412
80035
|
process.stderr.write(
|
|
79413
|
-
|
|
80036
|
+
import_picocolors36.default.yellow(`
|
|
79414
80037
|
! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
|
|
79415
80038
|
`)
|
|
79416
80039
|
);
|
|
@@ -79420,7 +80043,7 @@ ${import_picocolors35.default.bold(data4.upgrade_url)}
|
|
|
79420
80043
|
}
|
|
79421
80044
|
|
|
79422
80045
|
// src/commands/trade.ts
|
|
79423
|
-
var
|
|
80046
|
+
var import_picocolors37 = __toESM(require_picocolors(), 1);
|
|
79424
80047
|
init_constants();
|
|
79425
80048
|
|
|
79426
80049
|
// src/lib/trade-sol.ts
|
|
@@ -79784,11 +80407,11 @@ async function runTrade(args) {
|
|
|
79784
80407
|
}
|
|
79785
80408
|
|
|
79786
80409
|
// src/commands/trade.ts
|
|
79787
|
-
function
|
|
80410
|
+
function fail8(message, json2) {
|
|
79788
80411
|
if (json2) {
|
|
79789
80412
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
79790
80413
|
} else {
|
|
79791
|
-
process.stderr.write(
|
|
80414
|
+
process.stderr.write(import_picocolors37.default.red(`\u2715 ${message}
|
|
79792
80415
|
`));
|
|
79793
80416
|
}
|
|
79794
80417
|
process.exit(1);
|
|
@@ -79798,7 +80421,7 @@ async function withContext(opts, fn) {
|
|
|
79798
80421
|
const ctx2 = await resolveTradeContext();
|
|
79799
80422
|
return await fn(ctx2);
|
|
79800
80423
|
} catch (err) {
|
|
79801
|
-
|
|
80424
|
+
fail8(err.message, opts.json);
|
|
79802
80425
|
}
|
|
79803
80426
|
}
|
|
79804
80427
|
function servedFloorUnits(ctx2) {
|
|
@@ -79824,7 +80447,7 @@ async function tradeKey(opts) {
|
|
|
79824
80447
|
];
|
|
79825
80448
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
79826
80449
|
} catch (err) {
|
|
79827
|
-
|
|
80450
|
+
fail8(err.message, opts.json);
|
|
79828
80451
|
}
|
|
79829
80452
|
}
|
|
79830
80453
|
async function tradeStatus(opts) {
|
|
@@ -79881,7 +80504,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
79881
80504
|
const coin = await resolveCoin(coinArg);
|
|
79882
80505
|
const amountNumber = Number(amount);
|
|
79883
80506
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
79884
|
-
|
|
80507
|
+
fail8(`Amount "${amount}" is not a positive number.`, opts.json);
|
|
79885
80508
|
}
|
|
79886
80509
|
const res = await fetch(`${CREATORS_ORIGIN}/api/launch-quote`, {
|
|
79887
80510
|
method: "POST",
|
|
@@ -79895,7 +80518,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
79895
80518
|
});
|
|
79896
80519
|
const body = await res.json().catch(() => null);
|
|
79897
80520
|
if (!res.ok || !body) {
|
|
79898
|
-
|
|
80521
|
+
fail8(`Quote failed: ${body?.error ?? `HTTP ${res.status}`}`, opts.json);
|
|
79899
80522
|
}
|
|
79900
80523
|
const floor = servedFloorUnits(ctx2);
|
|
79901
80524
|
const belowFloor = side === "buy" && floor !== null && parseDecimalToUnits(amount, USDC_DECIMALS, "Amount") < floor.units;
|
|
@@ -79970,16 +80593,16 @@ async function tradeBuy(coinArg, amount, opts) {
|
|
|
79970
80593
|
try {
|
|
79971
80594
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
|
|
79972
80595
|
} catch (err) {
|
|
79973
|
-
|
|
80596
|
+
fail8(err.message, opts.json);
|
|
79974
80597
|
}
|
|
79975
|
-
if (units <= 0n)
|
|
80598
|
+
if (units <= 0n) fail8("Buy amount must be above zero.", opts.json);
|
|
79976
80599
|
const floor = servedFloorUnits(ctx2);
|
|
79977
80600
|
if (floor && units < floor.units) {
|
|
79978
|
-
|
|
80601
|
+
fail8(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
79979
80602
|
}
|
|
79980
80603
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
79981
80604
|
if (created && !opts.json) {
|
|
79982
|
-
process.stderr.write(
|
|
80605
|
+
process.stderr.write(import_picocolors37.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
79983
80606
|
`));
|
|
79984
80607
|
}
|
|
79985
80608
|
const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
@@ -79990,23 +80613,23 @@ async function tradeSell(coinArg, amount, opts) {
|
|
|
79990
80613
|
await withContext(opts, async (ctx2) => {
|
|
79991
80614
|
const coin = await resolveCoin(coinArg);
|
|
79992
80615
|
const key = await loadTradeKey();
|
|
79993
|
-
if (!key)
|
|
80616
|
+
if (!key) fail8("No agent trading key yet (nothing to sell with). Run: agentgates trade key", opts.json);
|
|
79994
80617
|
let sellAmount = amount.trim();
|
|
79995
80618
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
79996
80619
|
if (sellAmount === "all" || pct) {
|
|
79997
80620
|
const bal = await readTokenBalance(rpcConnection(), key.state.address, coin.mint);
|
|
79998
|
-
if (!bal)
|
|
79999
|
-
if (bal.units <= 0n)
|
|
80621
|
+
if (!bal) fail8("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
|
|
80622
|
+
if (bal.units <= 0n) fail8("This key holds none of that coin.", opts.json);
|
|
80000
80623
|
let units = bal.units;
|
|
80001
80624
|
if (pct) {
|
|
80002
80625
|
const p = BigInt(pct[1]);
|
|
80003
|
-
if (p <= 0n || p > 100n)
|
|
80626
|
+
if (p <= 0n || p > 100n) fail8(`Percentage must be 1-100, got "${amount}".`, opts.json);
|
|
80004
80627
|
units = bal.units * p / 100n;
|
|
80005
80628
|
}
|
|
80006
|
-
if (units <= 0n)
|
|
80629
|
+
if (units <= 0n) fail8("Sell amount rounds to zero.", opts.json);
|
|
80007
80630
|
sellAmount = formatUnits2(units, bal.decimals);
|
|
80008
80631
|
} else if (!/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
80009
|
-
|
|
80632
|
+
fail8(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
80010
80633
|
}
|
|
80011
80634
|
const result = await runTrade({ ctx: ctx2, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
|
|
80012
80635
|
await reportTrade(ctx2, opts, { side: "sell", coin, address: key.state.address, amount: sellAmount, result });
|
|
@@ -80021,19 +80644,19 @@ function describeOrder(o) {
|
|
|
80021
80644
|
async function tradeOrderPlace(coinArg, opts) {
|
|
80022
80645
|
await withContext(opts, async (ctx2) => {
|
|
80023
80646
|
if (opts.buy === void 0 === (opts.sell === void 0)) {
|
|
80024
|
-
|
|
80647
|
+
fail8("Pass exactly one of --buy <usdc> or --sell <amount|N%|all>.", opts.json);
|
|
80025
80648
|
}
|
|
80026
80649
|
if (opts.at === void 0 === (opts.onGraduation !== true)) {
|
|
80027
|
-
|
|
80650
|
+
fail8("Pass exactly one trigger: --at <value> (price, or mcap with --mcap) or --on-graduation.", opts.json);
|
|
80028
80651
|
}
|
|
80029
80652
|
const coin = await resolveCoin(coinArg);
|
|
80030
80653
|
const side = opts.buy !== void 0 ? "buy" : "sell";
|
|
80031
80654
|
const kind = opts.onGraduation ? side === "buy" ? "buy_on_graduation" : "sell_on_graduation" : side === "buy" ? "buy_at" : "sell_at";
|
|
80032
|
-
if (opts.stop && kind !== "sell_at")
|
|
80033
|
-
if (opts.mcap && !opts.at)
|
|
80655
|
+
if (opts.stop && kind !== "sell_at") fail8("--stop only applies to a --sell order with --at.", opts.json);
|
|
80656
|
+
if (opts.mcap && !opts.at) fail8("--mcap qualifies --at.", opts.json);
|
|
80034
80657
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
80035
80658
|
if (created && !opts.json) {
|
|
80036
|
-
process.stderr.write(
|
|
80659
|
+
process.stderr.write(import_picocolors37.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
80037
80660
|
`));
|
|
80038
80661
|
}
|
|
80039
80662
|
let amount;
|
|
@@ -80042,11 +80665,11 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
80042
80665
|
try {
|
|
80043
80666
|
units = parseDecimalToUnits(opts.buy, USDC_DECIMALS, "Buy amount");
|
|
80044
80667
|
} catch (err) {
|
|
80045
|
-
|
|
80668
|
+
fail8(err.message, opts.json);
|
|
80046
80669
|
}
|
|
80047
80670
|
const floor = servedFloorUnits(ctx2);
|
|
80048
80671
|
if (floor && units < floor.units) {
|
|
80049
|
-
|
|
80672
|
+
fail8(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
80050
80673
|
}
|
|
80051
80674
|
amount = opts.buy;
|
|
80052
80675
|
} else {
|
|
@@ -80054,24 +80677,24 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
80054
80677
|
const pct = amount.match(/^(\d+)%$/);
|
|
80055
80678
|
if (amount === "all" || pct) {
|
|
80056
80679
|
const bal = await readTokenBalance(rpcConnection(), state.address, coin.mint);
|
|
80057
|
-
if (!bal)
|
|
80058
|
-
if (bal.units <= 0n)
|
|
80680
|
+
if (!bal) fail8("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
|
|
80681
|
+
if (bal.units <= 0n) fail8("This key holds none of that coin.", opts.json);
|
|
80059
80682
|
let units = bal.units;
|
|
80060
80683
|
if (pct) {
|
|
80061
80684
|
const p = BigInt(pct[1]);
|
|
80062
|
-
if (p <= 0n || p > 100n)
|
|
80685
|
+
if (p <= 0n || p > 100n) fail8(`Percentage must be 1-100, got "${opts.sell}".`, opts.json);
|
|
80063
80686
|
units = bal.units * p / 100n;
|
|
80064
80687
|
}
|
|
80065
|
-
if (units <= 0n)
|
|
80688
|
+
if (units <= 0n) fail8("Sell amount rounds to zero.", opts.json);
|
|
80066
80689
|
amount = formatUnits2(units, bal.decimals);
|
|
80067
80690
|
} else if (!/^\d+(\.\d+)?$/.test(amount)) {
|
|
80068
|
-
|
|
80691
|
+
fail8(`Sell amount "${opts.sell}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
80069
80692
|
}
|
|
80070
80693
|
}
|
|
80071
80694
|
let expiresInDays;
|
|
80072
80695
|
if (opts.expiresDays !== void 0) {
|
|
80073
80696
|
const n2 = Number(opts.expiresDays);
|
|
80074
|
-
if (!Number.isInteger(n2) || n2 < 1)
|
|
80697
|
+
if (!Number.isInteger(n2) || n2 < 1) fail8(`--expires-days must be a positive integer, got "${opts.expiresDays}".`, opts.json);
|
|
80075
80698
|
expiresInDays = n2;
|
|
80076
80699
|
}
|
|
80077
80700
|
const prepared = await prepareOrder({
|
|
@@ -80107,7 +80730,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
80107
80730
|
async function tradeOrdersList(opts) {
|
|
80108
80731
|
await withContext(opts, async (ctx2) => {
|
|
80109
80732
|
const key = await loadTradeKey();
|
|
80110
|
-
if (!key)
|
|
80733
|
+
if (!key) fail8("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
80111
80734
|
const token = opts.coin ? (await resolveCoin(opts.coin)).mint : void 0;
|
|
80112
80735
|
const res = await listOrders(key.state.address, token);
|
|
80113
80736
|
if (opts.json) {
|
|
@@ -80127,15 +80750,15 @@ async function tradeOrdersList(opts) {
|
|
|
80127
80750
|
async function tradeOrderCancel(id2, opts) {
|
|
80128
80751
|
await withContext(opts, async (_ctx) => {
|
|
80129
80752
|
const key = await loadTradeKey();
|
|
80130
|
-
if (!key)
|
|
80753
|
+
if (!key) fail8("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
80131
80754
|
try {
|
|
80132
80755
|
await cancelOrder(id2, key.state.address);
|
|
80133
80756
|
} catch (err) {
|
|
80134
80757
|
if (err instanceof RelayError && err.status === 409) {
|
|
80135
|
-
|
|
80758
|
+
fail8(`Order ${id2} already fired or ended; nothing to cancel.`, opts.json);
|
|
80136
80759
|
}
|
|
80137
80760
|
if (err instanceof RelayError && err.status === 404) {
|
|
80138
|
-
|
|
80761
|
+
fail8(`No order ${id2} for this key (already canceled, or never placed).`, opts.json);
|
|
80139
80762
|
}
|
|
80140
80763
|
throw err;
|
|
80141
80764
|
}
|
|
@@ -80150,12 +80773,12 @@ async function tradeOrderCancel(id2, opts) {
|
|
|
80150
80773
|
async function tradePositions(opts) {
|
|
80151
80774
|
await withContext(opts, async (ctx2) => {
|
|
80152
80775
|
const key = await loadTradeKey();
|
|
80153
|
-
if (!key)
|
|
80776
|
+
if (!key) fail8("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
80154
80777
|
let body;
|
|
80155
80778
|
try {
|
|
80156
80779
|
body = await relayGet(`/launch-portfolio?address=${encodeURIComponent(key.state.address)}`);
|
|
80157
80780
|
} catch (err) {
|
|
80158
|
-
if (err instanceof RelayError)
|
|
80781
|
+
if (err instanceof RelayError) fail8(`Positions read failed: ${err.message}`, opts.json);
|
|
80159
80782
|
throw err;
|
|
80160
80783
|
}
|
|
80161
80784
|
const rows = body?.tokens ?? [];
|
|
@@ -80198,7 +80821,7 @@ async function tradePositions(opts) {
|
|
|
80198
80821
|
}
|
|
80199
80822
|
|
|
80200
80823
|
// src/commands/desk.ts
|
|
80201
|
-
var
|
|
80824
|
+
var import_picocolors38 = __toESM(require_picocolors(), 1);
|
|
80202
80825
|
init_constants();
|
|
80203
80826
|
|
|
80204
80827
|
// src/lib/desk-sol.ts
|
|
@@ -80369,11 +80992,11 @@ async function runDeskTrade(args) {
|
|
|
80369
80992
|
}
|
|
80370
80993
|
|
|
80371
80994
|
// src/commands/desk.ts
|
|
80372
|
-
function
|
|
80995
|
+
function fail9(message, json2) {
|
|
80373
80996
|
if (json2) {
|
|
80374
80997
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
80375
80998
|
} else {
|
|
80376
|
-
process.stderr.write(
|
|
80999
|
+
process.stderr.write(import_picocolors38.default.red(`\u2715 ${message}
|
|
80377
81000
|
`));
|
|
80378
81001
|
}
|
|
80379
81002
|
process.exit(1);
|
|
@@ -80383,7 +81006,7 @@ async function withDesk(opts, fn) {
|
|
|
80383
81006
|
const ctx2 = await resolveDeskContext();
|
|
80384
81007
|
return await fn(ctx2);
|
|
80385
81008
|
} catch (err) {
|
|
80386
|
-
|
|
81009
|
+
fail9(err.message, opts.json);
|
|
80387
81010
|
}
|
|
80388
81011
|
}
|
|
80389
81012
|
function servedFloorUnits2(ctx2) {
|
|
@@ -80394,7 +81017,7 @@ function servedFloorUnits2(ctx2) {
|
|
|
80394
81017
|
async function requireOwner(opts) {
|
|
80395
81018
|
const key = await loadTradeKey();
|
|
80396
81019
|
if (!key) {
|
|
80397
|
-
|
|
81020
|
+
fail9("No agent trading key yet (the desk's owner). Run: agentgates trade key", opts.json);
|
|
80398
81021
|
}
|
|
80399
81022
|
return key;
|
|
80400
81023
|
}
|
|
@@ -80463,7 +81086,7 @@ async function deskStatus(opts) {
|
|
|
80463
81086
|
if (opts.fills !== void 0) {
|
|
80464
81087
|
const n2 = Number(opts.fills);
|
|
80465
81088
|
if (!Number.isInteger(n2) || n2 <= 0) {
|
|
80466
|
-
|
|
81089
|
+
fail9(`--fills must be a positive integer, got "${opts.fills}".`, opts.json);
|
|
80467
81090
|
}
|
|
80468
81091
|
fillsLimit = n2;
|
|
80469
81092
|
}
|
|
@@ -80511,12 +81134,12 @@ async function deskDeposit(amount, opts) {
|
|
|
80511
81134
|
try {
|
|
80512
81135
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Deposit amount");
|
|
80513
81136
|
} catch (err) {
|
|
80514
|
-
|
|
81137
|
+
fail9(err.message, opts.json);
|
|
80515
81138
|
}
|
|
80516
|
-
if (units <= 0n)
|
|
81139
|
+
if (units <= 0n) fail9("Deposit amount must be above zero.", opts.json);
|
|
80517
81140
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
80518
81141
|
if (created && !opts.json) {
|
|
80519
|
-
process.stderr.write(
|
|
81142
|
+
process.stderr.write(import_picocolors38.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
80520
81143
|
`));
|
|
80521
81144
|
}
|
|
80522
81145
|
const result = await runDeskCeremony({
|
|
@@ -80557,7 +81180,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
80557
81180
|
const trimmed = amount.trim();
|
|
80558
81181
|
if (trimmed !== "all") {
|
|
80559
81182
|
if (!/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
80560
|
-
|
|
81183
|
+
fail9(`Withdraw amount "${amount}" is not a decimal amount or "all".`, opts.json);
|
|
80561
81184
|
}
|
|
80562
81185
|
}
|
|
80563
81186
|
const result = await runDeskCeremony({
|
|
@@ -80596,28 +81219,28 @@ async function deskWithdraw(amount, opts) {
|
|
|
80596
81219
|
}
|
|
80597
81220
|
async function deskSessionRegister(opts) {
|
|
80598
81221
|
await withDesk(opts, async (ctx2) => {
|
|
80599
|
-
if (!opts.cap)
|
|
80600
|
-
if (!opts.minutes)
|
|
81222
|
+
if (!opts.cap) fail9("--cap <usdc> is required: the per-trade cap is your risk statement, never defaulted.", opts.json);
|
|
81223
|
+
if (!opts.minutes) fail9("--minutes <n> is required: the session expiry is your risk statement, never defaulted.", opts.json);
|
|
80601
81224
|
let capUnits;
|
|
80602
81225
|
try {
|
|
80603
81226
|
capUnits = parseDecimalToUnits(opts.cap, USDC_DECIMALS, "Per-trade cap");
|
|
80604
81227
|
} catch (err) {
|
|
80605
|
-
|
|
81228
|
+
fail9(err.message, opts.json);
|
|
80606
81229
|
}
|
|
80607
|
-
if (capUnits <= 0n)
|
|
81230
|
+
if (capUnits <= 0n) fail9("Per-trade cap must be above zero.", opts.json);
|
|
80608
81231
|
const minutes = Number(opts.minutes);
|
|
80609
81232
|
if (!Number.isInteger(minutes) || minutes <= 0) {
|
|
80610
|
-
|
|
81233
|
+
fail9(`--minutes must be a positive integer, got "${opts.minutes}".`, opts.json);
|
|
80611
81234
|
}
|
|
80612
81235
|
const owner = await loadOrCreateTradeKey();
|
|
80613
81236
|
if (owner.created && !opts.json) {
|
|
80614
|
-
process.stderr.write(
|
|
81237
|
+
process.stderr.write(import_picocolors38.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
|
|
80615
81238
|
`));
|
|
80616
81239
|
}
|
|
80617
81240
|
const session = await loadOrCreateDeskSessionKey();
|
|
80618
81241
|
if (session.created && !opts.json) {
|
|
80619
81242
|
process.stderr.write(
|
|
80620
|
-
|
|
81243
|
+
import_picocolors38.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
|
|
80621
81244
|
`)
|
|
80622
81245
|
);
|
|
80623
81246
|
}
|
|
@@ -80691,7 +81314,7 @@ async function deskSessionRevoke(opts) {
|
|
|
80691
81314
|
async function requireSessionKeypair(opts) {
|
|
80692
81315
|
const session = await loadDeskSessionKey();
|
|
80693
81316
|
if (!session) {
|
|
80694
|
-
|
|
81317
|
+
fail9(
|
|
80695
81318
|
"No desk session key on this terminal. Register one: agentgates desk session register --cap <usdc> --minutes <n>",
|
|
80696
81319
|
opts.json
|
|
80697
81320
|
);
|
|
@@ -80735,12 +81358,12 @@ async function deskBuy(coinArg, amount, opts) {
|
|
|
80735
81358
|
try {
|
|
80736
81359
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
|
|
80737
81360
|
} catch (err) {
|
|
80738
|
-
|
|
81361
|
+
fail9(err.message, opts.json);
|
|
80739
81362
|
}
|
|
80740
|
-
if (units <= 0n)
|
|
81363
|
+
if (units <= 0n) fail9("Buy amount must be above zero.", opts.json);
|
|
80741
81364
|
const floor = servedFloorUnits2(ctx2);
|
|
80742
81365
|
if (floor && units < floor.units) {
|
|
80743
|
-
|
|
81366
|
+
fail9(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
80744
81367
|
}
|
|
80745
81368
|
const owner = await requireOwner(opts);
|
|
80746
81369
|
const session = await requireSessionKeypair(opts);
|
|
@@ -80765,16 +81388,16 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
80765
81388
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
80766
81389
|
if (pct) {
|
|
80767
81390
|
const state = await deskState(owner.state.address, coin.mint);
|
|
80768
|
-
if (!state.coin)
|
|
81391
|
+
if (!state.coin) fail9("The desk holds none of that coin for this owner.", opts.json);
|
|
80769
81392
|
const credit = BigInt(state.coin.creditUnits);
|
|
80770
|
-
if (credit <= 0n)
|
|
81393
|
+
if (credit <= 0n) fail9("The desk holds none of that coin for this owner.", opts.json);
|
|
80771
81394
|
const p = BigInt(pct[1]);
|
|
80772
|
-
if (p <= 0n || p > 100n)
|
|
81395
|
+
if (p <= 0n || p > 100n) fail9(`Percentage must be 1-100, got "${amount}".`, opts.json);
|
|
80773
81396
|
const units = credit * p / 100n;
|
|
80774
|
-
if (units <= 0n)
|
|
81397
|
+
if (units <= 0n) fail9("Sell amount rounds to zero.", opts.json);
|
|
80775
81398
|
sellAmount = formatUnits2(units, state.coin.decimals);
|
|
80776
81399
|
} else if (sellAmount !== "all" && !/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
80777
|
-
|
|
81400
|
+
fail9(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
80778
81401
|
}
|
|
80779
81402
|
const result = await runDeskTrade({
|
|
80780
81403
|
ctx: ctx2,
|
|
@@ -81163,7 +81786,7 @@ program2.command("fund").description(
|
|
|
81163
81786
|
}
|
|
81164
81787
|
if (opts.usdc || opts.gas || opts.chain) {
|
|
81165
81788
|
process.stderr.write(
|
|
81166
|
-
|
|
81789
|
+
import_picocolors39.default.red(
|
|
81167
81790
|
`\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
|
|
81168
81791
|
`
|
|
81169
81792
|
)
|
|
@@ -81364,10 +81987,13 @@ passwords.command("add").alias("store").description("Store a login: sealed on th
|
|
|
81364
81987
|
passwords.command("allow").description("Sign a permit: which agent may use which rows on which sites, how many times a day, until when. Default: yourself, every row, every use, 30 days.").option("--agent <address>", "the key that will sign uses (default: this key)").option("--rows <id,id|*>", "row ids, or * for every row this key holds (default *)").option("--hosts <a,b>", "narrow to these hostnames (default: the rows' own)").option("--uses <login,totp,header>", "which uses (default all three)").option("--gets <session|password>", "what the agent gets: session = the site's cookies after the CVM logs in (default); password = the secret itself; cvm = the acting uses alone, for an agent that works inside the CVM over the API").option("--per-day <n>", "hard daily cap; 0 = the plan allowance (default 0)").option("--days <n>", "how long, 1 to 366 (default 30)").option("--ask-me", "every use waits for the owner's signature on their board (the brake)").option("--factors <device,codes,mail,sms>", "the account's sign-in verification step the agent may complete: device = the stored device credential answers the site's device step; codes = one of the stored backup codes is spent; mail = a code the site emails is read from your mailbox row or an inbox this key holds (allow the mailbox row too); sms = a code the site texts is read from a number this key holds").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
81365
81988
|
await passwordsAllow(opts);
|
|
81366
81989
|
});
|
|
81367
|
-
passwords.command("use").description("Log in through the CVM with a stored login and get the page's digest back, never the password. Pass --row, or just --url and the matching row is picked. A parked use (the owner has to approve, or type a code) is waited on until it answers.").option("--row <id>", "the row to use (default: the one whose hosts cover --url)").option("--url <https://site/login>", "the page the use targets").option("--use <login|header|totp|session|reveal>", "which use (default login); session hands this key the site's cookies, reveal the secret, when the permit says so").option("--cookies-out <file>", "session only: write the cookies to this file (Playwright addCookies / Puppeteer setCookie shape)").option("--steps-json <json>", "login only: steps the CVM runs inside the session after the login lands (goto, fill, click, wait, read; a click may name the control's text instead of a selector)").option("--code-steps-json <json>", "login only: the clicks that reach a code field the site keeps behind a 'try another way' menu (at most 4, click and wait), run before the code is typed").option("--enroll-device", "login only, your own key: provision a device credential for the account on this sign-in (the steps reach the page where the account adds a device); agentgates passwords device does this and seals it into the row").option("--attend", "login only, your own key: the CVM fills the password and holds the page for you at the controls (finish it on your board's live view); prints the use id and the view token").option("--use-id <id>", "continue a parked use by its id (Done on an attended sign-in, or a use the owner answered)").option("--mailbox <row>", "login and session: the mailbox row the box reads an emailed sign-in code from (default: your one mailbox row, when the permit covers it and lists mail)").option("--request-json <json>", "the whole request object for header and totp uses (spec \xA75.1)").option("--wait <seconds>", "cap on how long to wait for the owner's answer (default: the owner's window)").option("--no-wait", "answer the parked use's id and return at once").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts, command) => {
|
|
81990
|
+
passwords.command("use").description("Log in through the CVM with a stored login and get the page's digest back, never the password. Pass --row, or just --url and the matching row is picked, or --workflow to run a task the owner taught the CVM. A parked use (the owner has to approve, or type a code) is waited on until it answers.").option("--row <id>", "the row to use (default: the one whose hosts cover --url)").option("--url <https://site/login>", "the page the use targets").option("--use <login|header|totp|session|reveal>", "which use (default login); session hands this key the site's cookies, reveal the secret, when the permit says so").option("--cookies-out <file>", "session only: write the cookies to this file (Playwright addCookies / Puppeteer setCookie shape)").option("--steps-json <json>", "login only: steps the CVM runs inside the session after the login lands (goto, fill, click, wait, read, press; a click may name the control's text instead of a selector)").option("--workflow <name>", "login only: run a workflow the owner taught the CVM on the row, by its name (passwords list shows them); --url may be left out").option("--input <name=value>", "a value the workflow takes, by its name; repeat for each (a value you leave out types what the owner typed)", (v, prev = []) => [...prev, v]).option("--code-steps-json <json>", "login only: the clicks that reach a code field the site keeps behind a 'try another way' menu (at most 4, click and wait), run before the code is typed").option("--enroll-device", "login only, your own key: provision a device credential for the account on this sign-in (the steps reach the page where the account adds a device); agentgates passwords device does this and seals it into the row").option("--attend", "login only, your own key: the CVM fills the password and holds the page for you at the controls (finish it on your board's live view); prints the use id and the view token").option("--use-id <id>", "continue a parked use by its id (Done on an attended sign-in, or a use the owner answered)").option("--mailbox <row>", "login and session: the mailbox row the box reads an emailed sign-in code from (default: your one mailbox row, when the permit covers it and lists mail)").option("--solve", "login and session, your own key: the CVM passes a bot check it meets (Cloudflare, Turnstile, reCAPTCHA, hCaptcha) by ticking it, then through its solver service").option("--request-json <json>", "the whole request object for header and totp uses (spec \xA75.1)").option("--wait <seconds>", "cap on how long to wait for the owner's answer (default: the owner's window)").option("--no-wait", "answer the parked use's id and return at once").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts, command) => {
|
|
81368
81991
|
const waitSource = command.getOptionValueSource("wait");
|
|
81369
81992
|
await passwordsUse({ ...opts, noWait: waitSource === "cli" && opts.wait === false, wait: typeof opts.wait === "string" ? opts.wait : void 0 });
|
|
81370
81993
|
});
|
|
81994
|
+
passwords.command("checks [word]").description("Bot checks (Cloudflare, Turnstile, reCAPTCHA, hCaptcha): ask = an agent's use that meets one waits for your answer on the board (default); solve = the CVM passes every one it can without asking. No word prints the current one.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (word, opts) => {
|
|
81995
|
+
await passwordsChecks(word, opts);
|
|
81996
|
+
});
|
|
81371
81997
|
passwords.command("code").description("Fetch a verification code one of the account's own contacts received, for an account the owner is registering or signing into elsewhere: the newest message from a site in your mailbox row (an app password, or a Gmail login you connected on your board; the permit lists mail), or the newest code that reached an inbox or a number this key holds, read through its own door (a sealed inbox is opened with your own key). One source: --mailbox, --inbox or --phone.").option("--from <domain>", "the site the code comes from, e.g. etsy.com (a mailbox row reads that sender)").option("--mailbox <row>", "the mailbox row (default: your one mailbox row, or your one Gmail login)").option("--inbox <id>", "an inbox this key holds (agentgates passwords inbox list): the newest code that reached it").option("--phone <id>", "a number this key holds (agentgates phone list): the newest code texted to it").option("--timeout <seconds>", "--inbox and --phone: how long the door waits for a code (default 60)").option("--since <minutes>", "how far back to look (default 10)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
81372
81998
|
await passwordsCode(opts);
|
|
81373
81999
|
});
|
|
@@ -81517,6 +82143,25 @@ intents.command("rate <askId>").description("Rate a business's leg that settled
|
|
|
81517
82143
|
intents.command("noshow <askId>").description("Mark a no-show on a committed leg of yours: a fact on the poster's record that sellers see.").requiredOption("--offer <offerId>", "your committed leg").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (askId, opts) => {
|
|
81518
82144
|
await intentsNoShow(askId, opts);
|
|
81519
82145
|
});
|
|
82146
|
+
var integrations = program2.command("integrations").description("Outside accounts this account connected (GitHub, Vercel, Neon, Google Drive, Dropbox, and the sites and API tokens kept in Passwords), and an agent's read of one under the owner's permit.");
|
|
82147
|
+
integrations.command("list", { isDefault: true }).description("The account's integrations: provider, account name (opened here), state, what uses it.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82148
|
+
await integrationsList(opts);
|
|
82149
|
+
});
|
|
82150
|
+
integrations.command("use <integrationId>").description("As an agent the owner permitted: list the folders the owner picked (--folder <id> lists inside one), or read one file (--file <id>); on Vercel or Neon, list the projects. Sealed to this agent's own key and opened here. A permit that asks each use waits for the owner's answer.").option("--folder <id>", "a folder id from a listing").option("--file <id>", "a file id from a listing").option("--wait <seconds>", "how long to wait for the owner's answer (default 300, at most 900)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (integrationId, opts) => {
|
|
82151
|
+
await integrationsUse(integrationId, opts);
|
|
82152
|
+
});
|
|
82153
|
+
integrations.command("signup <provider>").description("Stage 4: open a signup row that makes the owner's free account on GitHub, Vercel or Neon with the owner's Agentgates email. Prints the row's id and the inbox the account is made with.").option("--inbox <id>", "an inbox the owner holds (default: the account's free inbox, minted when none)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (provider, opts) => {
|
|
82154
|
+
await integrationsSignup(provider, opts);
|
|
82155
|
+
});
|
|
82156
|
+
integrations.command("signup-report <signupId>").description("Report a signup's run: the Passwords row the login was stored in (--login-id).").option("--login-id <rowId>", "the passwords row the login landed in").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (signupId, opts) => {
|
|
82157
|
+
await integrationsSignupReport(signupId, opts);
|
|
82158
|
+
});
|
|
82159
|
+
integrations.command("signup-handoff <signupId> <provider>").description("Hand the connect material back and connect the row: GitHub's install redirect (--code --installation-id), Vercel's (--code --configuration-id), or Neon's key sealed to the box (--sealed <file> with {grantCvm, cvmKeyId}).").option("--code <code>", "the provider's install redirect code").option("--installation-id <id>", "GitHub's installation id").option("--setup-action <action>", "GitHub's setup action (install|request)").option("--configuration-id <id>", "Vercel's configuration id").option("--team-id <id>", "Vercel's team id").option("--redirect-uri <url>", "the address the provider sent the browser back to").option("--sealed <file>", "a file holding {grantCvm, cvmKeyId} (Neon)").option("--grant-cvm <blob>", "the Neon grant sealed to the connections CVM").option("--cvm-key-id <id>", "the CVM key id the grant is sealed under").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (signupId, provider, opts) => {
|
|
82160
|
+
await integrationsSignupHandoff(signupId, provider, opts);
|
|
82161
|
+
});
|
|
82162
|
+
program2.command("sites").description("The account's sites: one Vercel project each and the GitHub repo behind it; name, repo and address opened here.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
82163
|
+
await sitesList(opts);
|
|
82164
|
+
});
|
|
81520
82165
|
var memory = program2.command("memory").description("Sealed folders of markdown your agents read: names and bodies are sealed on this machine to the account's data key; the wire and the server carry ciphertext only.");
|
|
81521
82166
|
memory.command("overview", { isDefault: true }).description("The folders, their counts, and what the plan allows.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
81522
82167
|
await memoryOverview(opts);
|
|
@@ -81550,7 +82195,7 @@ memory.command("about").description("About you: what you tell every agent up fro
|
|
|
81550
82195
|
});
|
|
81551
82196
|
var card = program2.command("card").description("Your Agentgates card: the home address ether.fi asks before it, sealed on this machine.");
|
|
81552
82197
|
var cardAddress = card.command("address").description("The home address the card is made with. Sealed on this machine to the account's data key; the wire and the server carry ciphertext only.");
|
|
81553
|
-
cardAddress.command("set").description("Save it, or replace it: one --line, or --line1 --line2 --city --state --zip; with neither, a few questions.
|
|
82198
|
+
cardAddress.command("set").description("Save it, or replace it: one --line, or --line1 --line2 --city --state --zip; with neither, a few questions. Any country ether.fi issues the card in (--country, the United States when left out). Only the person's real address: ether.fi checks it against their ID.").option("--country <country>", "the country, by name or two letters (Chile, CL); the United States when left out").option("--line <address>", "the whole address on one line: street, city, state ZIP (abroad: street, city, region, postal code)").option("--line1 <street>", "street address").option("--line2 <unit>", "apartment, suite or unit (optional)").option("--city <city>", "city").option("--state <XX>", "the state's two letters (abroad: the region, as written)").option("--zip <zip>", "ZIP code (abroad: the postal code)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
81554
82199
|
await cardAddressSet(opts);
|
|
81555
82200
|
});
|
|
81556
82201
|
cardAddress.command("show").description("Print the saved address, opened on this machine with the account's data key (the words, or a key's own copy).").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
@@ -81618,10 +82263,10 @@ mcp.command("install").description("Print the lines that add this server to Clau
|
|
|
81618
82263
|
mcpInstall();
|
|
81619
82264
|
});
|
|
81620
82265
|
program2.parseAsync(process.argv).catch((err) => {
|
|
81621
|
-
process.stderr.write(
|
|
82266
|
+
process.stderr.write(import_picocolors39.default.red(`\u2715 ${err.message}
|
|
81622
82267
|
`));
|
|
81623
82268
|
if (process.env.BOUNTY_DEBUG) {
|
|
81624
|
-
process.stderr.write(
|
|
82269
|
+
process.stderr.write(import_picocolors39.default.dim((err.stack ?? "") + "\n"));
|
|
81625
82270
|
}
|
|
81626
82271
|
process.exit(1);
|
|
81627
82272
|
});
|