@agentgates/cli 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +714 -433
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -6875,7 +6875,7 @@ var require_package = __commonJS({
|
|
|
6875
6875
|
"package.json"(exports, module) {
|
|
6876
6876
|
module.exports = {
|
|
6877
6877
|
name: "@agentgates/cli",
|
|
6878
|
-
version: "0.
|
|
6878
|
+
version: "0.16.0",
|
|
6879
6879
|
description: "Wallet operations for AI agents and humans",
|
|
6880
6880
|
keywords: [
|
|
6881
6881
|
"crypto",
|
|
@@ -17475,10 +17475,10 @@ var require_dist = __commonJS({
|
|
|
17475
17475
|
if (coerce2) {
|
|
17476
17476
|
value = struct2.coercer(value, ctx2);
|
|
17477
17477
|
}
|
|
17478
|
-
let
|
|
17478
|
+
let status3 = "valid";
|
|
17479
17479
|
for (const failure of struct2.validator(value, ctx2)) {
|
|
17480
17480
|
failure.explanation = options.message;
|
|
17481
|
-
|
|
17481
|
+
status3 = "not_valid";
|
|
17482
17482
|
yield [failure, void 0];
|
|
17483
17483
|
}
|
|
17484
17484
|
for (let [k, v, s] of struct2.entries(value, ctx2)) {
|
|
@@ -17491,7 +17491,7 @@ var require_dist = __commonJS({
|
|
|
17491
17491
|
});
|
|
17492
17492
|
for (const t of ts) {
|
|
17493
17493
|
if (t[0]) {
|
|
17494
|
-
|
|
17494
|
+
status3 = t[0].refinement != null ? "not_refined" : "not_valid";
|
|
17495
17495
|
yield [t[0], void 0];
|
|
17496
17496
|
} else if (coerce2) {
|
|
17497
17497
|
v = t[1];
|
|
@@ -17508,14 +17508,14 @@ var require_dist = __commonJS({
|
|
|
17508
17508
|
}
|
|
17509
17509
|
}
|
|
17510
17510
|
}
|
|
17511
|
-
if (
|
|
17511
|
+
if (status3 !== "not_valid") {
|
|
17512
17512
|
for (const failure of struct2.refiner(value, ctx2)) {
|
|
17513
17513
|
failure.explanation = options.message;
|
|
17514
|
-
|
|
17514
|
+
status3 = "not_refined";
|
|
17515
17515
|
yield [failure, void 0];
|
|
17516
17516
|
}
|
|
17517
17517
|
}
|
|
17518
|
-
if (
|
|
17518
|
+
if (status3 === "valid") {
|
|
17519
17519
|
yield [void 0, value];
|
|
17520
17520
|
}
|
|
17521
17521
|
}
|
|
@@ -18903,8 +18903,8 @@ var require_tr46 = __commonJS({
|
|
|
18903
18903
|
var len = countSymbols(domain_name);
|
|
18904
18904
|
for (var i = 0; i < len; ++i) {
|
|
18905
18905
|
var codePoint = domain_name.codePointAt(i);
|
|
18906
|
-
var
|
|
18907
|
-
switch (
|
|
18906
|
+
var status3 = findStatus(codePoint);
|
|
18907
|
+
switch (status3[1]) {
|
|
18908
18908
|
case "disallowed":
|
|
18909
18909
|
hasError = true;
|
|
18910
18910
|
processed += String.fromCodePoint(codePoint);
|
|
@@ -18912,11 +18912,11 @@ var require_tr46 = __commonJS({
|
|
|
18912
18912
|
case "ignored":
|
|
18913
18913
|
break;
|
|
18914
18914
|
case "mapped":
|
|
18915
|
-
processed += String.fromCodePoint.apply(String,
|
|
18915
|
+
processed += String.fromCodePoint.apply(String, status3[2]);
|
|
18916
18916
|
break;
|
|
18917
18917
|
case "deviation":
|
|
18918
18918
|
if (processing_option === PROCESSING_OPTIONS.TRANSITIONAL) {
|
|
18919
|
-
processed += String.fromCodePoint.apply(String,
|
|
18919
|
+
processed += String.fromCodePoint.apply(String, status3[2]);
|
|
18920
18920
|
} else {
|
|
18921
18921
|
processed += String.fromCodePoint(codePoint);
|
|
18922
18922
|
}
|
|
@@ -18929,7 +18929,7 @@ var require_tr46 = __commonJS({
|
|
|
18929
18929
|
hasError = true;
|
|
18930
18930
|
processed += String.fromCodePoint(codePoint);
|
|
18931
18931
|
} else {
|
|
18932
|
-
processed += String.fromCodePoint.apply(String,
|
|
18932
|
+
processed += String.fromCodePoint.apply(String, status3[2]);
|
|
18933
18933
|
}
|
|
18934
18934
|
break;
|
|
18935
18935
|
case "disallowed_STD3_valid":
|
|
@@ -18957,8 +18957,8 @@ var require_tr46 = __commonJS({
|
|
|
18957
18957
|
}
|
|
18958
18958
|
var len = countSymbols(label);
|
|
18959
18959
|
for (var i = 0; i < len; ++i) {
|
|
18960
|
-
var
|
|
18961
|
-
if (processing === PROCESSING_OPTIONS.TRANSITIONAL &&
|
|
18960
|
+
var status3 = findStatus(label.codePointAt(i));
|
|
18961
|
+
if (processing === PROCESSING_OPTIONS.TRANSITIONAL && status3[1] !== "valid" || processing === PROCESSING_OPTIONS.NONTRANSITIONAL && status3[1] !== "valid" && status3[1] !== "deviation") {
|
|
18962
18962
|
error = true;
|
|
18963
18963
|
break;
|
|
18964
18964
|
}
|
|
@@ -19397,14 +19397,14 @@ var require_url_state_machine = __commonJS({
|
|
|
19397
19397
|
len: maxLen
|
|
19398
19398
|
};
|
|
19399
19399
|
}
|
|
19400
|
-
function serializeHost(
|
|
19401
|
-
if (typeof
|
|
19402
|
-
return serializeIPv4(
|
|
19400
|
+
function serializeHost(host2) {
|
|
19401
|
+
if (typeof host2 === "number") {
|
|
19402
|
+
return serializeIPv4(host2);
|
|
19403
19403
|
}
|
|
19404
|
-
if (
|
|
19405
|
-
return "[" + serializeIPv6(
|
|
19404
|
+
if (host2 instanceof Array) {
|
|
19405
|
+
return "[" + serializeIPv6(host2) + "]";
|
|
19406
19406
|
}
|
|
19407
|
-
return
|
|
19407
|
+
return host2;
|
|
19408
19408
|
}
|
|
19409
19409
|
function trimControlChars(url) {
|
|
19410
19410
|
return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, "");
|
|
@@ -19707,11 +19707,11 @@ var require_url_state_machine = __commonJS({
|
|
|
19707
19707
|
this.parseError = true;
|
|
19708
19708
|
return failure;
|
|
19709
19709
|
}
|
|
19710
|
-
const
|
|
19711
|
-
if (
|
|
19710
|
+
const host2 = parseHost(this.buffer, isSpecial(this.url));
|
|
19711
|
+
if (host2 === failure) {
|
|
19712
19712
|
return failure;
|
|
19713
19713
|
}
|
|
19714
|
-
this.url.host =
|
|
19714
|
+
this.url.host = host2;
|
|
19715
19715
|
this.buffer = "";
|
|
19716
19716
|
this.state = "port";
|
|
19717
19717
|
if (this.stateOverride === "hostname") {
|
|
@@ -19726,11 +19726,11 @@ var require_url_state_machine = __commonJS({
|
|
|
19726
19726
|
this.parseError = true;
|
|
19727
19727
|
return false;
|
|
19728
19728
|
}
|
|
19729
|
-
const
|
|
19730
|
-
if (
|
|
19729
|
+
const host2 = parseHost(this.buffer, isSpecial(this.url));
|
|
19730
|
+
if (host2 === failure) {
|
|
19731
19731
|
return failure;
|
|
19732
19732
|
}
|
|
19733
|
-
this.url.host =
|
|
19733
|
+
this.url.host = host2;
|
|
19734
19734
|
this.buffer = "";
|
|
19735
19735
|
this.state = "path start";
|
|
19736
19736
|
if (this.stateOverride) {
|
|
@@ -19845,14 +19845,14 @@ var require_url_state_machine = __commonJS({
|
|
|
19845
19845
|
}
|
|
19846
19846
|
this.state = "path start";
|
|
19847
19847
|
} else {
|
|
19848
|
-
let
|
|
19849
|
-
if (
|
|
19848
|
+
let host2 = parseHost(this.buffer, isSpecial(this.url));
|
|
19849
|
+
if (host2 === failure) {
|
|
19850
19850
|
return failure;
|
|
19851
19851
|
}
|
|
19852
|
-
if (
|
|
19853
|
-
|
|
19852
|
+
if (host2 === "localhost") {
|
|
19853
|
+
host2 = "";
|
|
19854
19854
|
}
|
|
19855
|
-
this.url.host =
|
|
19855
|
+
this.url.host = host2;
|
|
19856
19856
|
if (this.stateOverride) {
|
|
19857
19857
|
return false;
|
|
19858
19858
|
}
|
|
@@ -21205,7 +21205,7 @@ var require_lib3 = __commonJS({
|
|
|
21205
21205
|
let body = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
21206
21206
|
let opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
21207
21207
|
Body.call(this, body, opts);
|
|
21208
|
-
const
|
|
21208
|
+
const status3 = opts.status || 200;
|
|
21209
21209
|
const headers = new Headers(opts.headers);
|
|
21210
21210
|
if (body != null && !headers.has("Content-Type")) {
|
|
21211
21211
|
const contentType = extractContentType(body);
|
|
@@ -21215,8 +21215,8 @@ var require_lib3 = __commonJS({
|
|
|
21215
21215
|
}
|
|
21216
21216
|
this[INTERNALS$1] = {
|
|
21217
21217
|
url: opts.url,
|
|
21218
|
-
status:
|
|
21219
|
-
statusText: opts.statusText || STATUS_CODES[
|
|
21218
|
+
status: status3,
|
|
21219
|
+
statusText: opts.statusText || STATUS_CODES[status3],
|
|
21220
21220
|
headers,
|
|
21221
21221
|
counter: opts.counter
|
|
21222
21222
|
};
|
|
@@ -25454,7 +25454,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
25454
25454
|
if (listeners.fn) return 1;
|
|
25455
25455
|
return listeners.length;
|
|
25456
25456
|
};
|
|
25457
|
-
EventEmitter.prototype.emit = function
|
|
25457
|
+
EventEmitter.prototype.emit = function emit4(event, a1, a2, a3, a4, a5) {
|
|
25458
25458
|
var evt = prefix ? prefix + event : event;
|
|
25459
25459
|
if (!this._events[evt]) return false;
|
|
25460
25460
|
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
@@ -30611,9 +30611,9 @@ Message: ${transactionMessage}.
|
|
|
30611
30611
|
minContextSlot: options.minContextSlot
|
|
30612
30612
|
};
|
|
30613
30613
|
const signature2 = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
30614
|
-
let
|
|
30614
|
+
let status3;
|
|
30615
30615
|
if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {
|
|
30616
|
-
|
|
30616
|
+
status3 = (await connection.confirmTransaction({
|
|
30617
30617
|
abortSignal: options?.abortSignal,
|
|
30618
30618
|
signature: signature2,
|
|
30619
30619
|
blockhash: transaction.recentBlockhash,
|
|
@@ -30624,7 +30624,7 @@ Message: ${transactionMessage}.
|
|
|
30624
30624
|
nonceInstruction
|
|
30625
30625
|
} = transaction.nonceInfo;
|
|
30626
30626
|
const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
|
|
30627
|
-
|
|
30627
|
+
status3 = (await connection.confirmTransaction({
|
|
30628
30628
|
abortSignal: options?.abortSignal,
|
|
30629
30629
|
minContextSlot: transaction.minNonceContextSlot,
|
|
30630
30630
|
nonceAccountPubkey,
|
|
@@ -30635,17 +30635,17 @@ Message: ${transactionMessage}.
|
|
|
30635
30635
|
if (options?.abortSignal != null) {
|
|
30636
30636
|
console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable.");
|
|
30637
30637
|
}
|
|
30638
|
-
|
|
30638
|
+
status3 = (await connection.confirmTransaction(signature2, options && options.commitment)).value;
|
|
30639
30639
|
}
|
|
30640
|
-
if (
|
|
30640
|
+
if (status3.err) {
|
|
30641
30641
|
if (signature2 != null) {
|
|
30642
30642
|
throw new SendTransactionError({
|
|
30643
30643
|
action: "send",
|
|
30644
30644
|
signature: signature2,
|
|
30645
|
-
transactionMessage: `Status: (${JSON.stringify(
|
|
30645
|
+
transactionMessage: `Status: (${JSON.stringify(status3)})`
|
|
30646
30646
|
});
|
|
30647
30647
|
}
|
|
30648
|
-
throw new Error(`Transaction ${signature2} failed (${JSON.stringify(
|
|
30648
|
+
throw new Error(`Transaction ${signature2} failed (${JSON.stringify(status3)})`);
|
|
30649
30649
|
}
|
|
30650
30650
|
return signature2;
|
|
30651
30651
|
}
|
|
@@ -33824,15 +33824,15 @@ Message: ${transactionMessage}.
|
|
|
33824
33824
|
} else {
|
|
33825
33825
|
let signatureStatus;
|
|
33826
33826
|
while (true) {
|
|
33827
|
-
const
|
|
33828
|
-
if (
|
|
33827
|
+
const status3 = await this.getSignatureStatus(signature2);
|
|
33828
|
+
if (status3 == null) {
|
|
33829
33829
|
break;
|
|
33830
33830
|
}
|
|
33831
|
-
if (
|
|
33831
|
+
if (status3.context.slot < (outcome.slotInWhichNonceDidAdvance ?? minContextSlot)) {
|
|
33832
33832
|
await sleep3(400);
|
|
33833
33833
|
continue;
|
|
33834
33834
|
}
|
|
33835
|
-
signatureStatus =
|
|
33835
|
+
signatureStatus = status3;
|
|
33836
33836
|
break;
|
|
33837
33837
|
}
|
|
33838
33838
|
if (signatureStatus?.value) {
|
|
@@ -37759,16 +37759,16 @@ Message: ${transactionMessage}.
|
|
|
37759
37759
|
const signature2 = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
37760
37760
|
const commitment = options && options.commitment;
|
|
37761
37761
|
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature2, commitment);
|
|
37762
|
-
const
|
|
37763
|
-
if (
|
|
37762
|
+
const status3 = (await confirmationPromise).value;
|
|
37763
|
+
if (status3.err) {
|
|
37764
37764
|
if (signature2 != null) {
|
|
37765
37765
|
throw new SendTransactionError({
|
|
37766
37766
|
action: sendOptions?.skipPreflight ? "send" : "simulate",
|
|
37767
37767
|
signature: signature2,
|
|
37768
|
-
transactionMessage: `Status: (${JSON.stringify(
|
|
37768
|
+
transactionMessage: `Status: (${JSON.stringify(status3)})`
|
|
37769
37769
|
});
|
|
37770
37770
|
}
|
|
37771
|
-
throw new Error(`Raw transaction ${signature2} failed (${JSON.stringify(
|
|
37771
|
+
throw new Error(`Raw transaction ${signature2} failed (${JSON.stringify(status3)})`);
|
|
37772
37772
|
}
|
|
37773
37773
|
return signature2;
|
|
37774
37774
|
}
|
|
@@ -37870,7 +37870,7 @@ var {
|
|
|
37870
37870
|
} = import_index.default;
|
|
37871
37871
|
|
|
37872
37872
|
// src/main.ts
|
|
37873
|
-
var
|
|
37873
|
+
var import_picocolors29 = __toESM(require_picocolors(), 1);
|
|
37874
37874
|
|
|
37875
37875
|
// src/commands/login.ts
|
|
37876
37876
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
@@ -37891,9 +37891,9 @@ var AI_DIRECTIVE = "\n[AI: present the above verbatim inside a markdown code blo
|
|
|
37891
37891
|
|
|
37892
37892
|
// src/lib/api.ts
|
|
37893
37893
|
var ApiError = class extends Error {
|
|
37894
|
-
constructor(
|
|
37894
|
+
constructor(status3, code, message, body) {
|
|
37895
37895
|
super(message);
|
|
37896
|
-
this.status =
|
|
37896
|
+
this.status = status3;
|
|
37897
37897
|
this.code = code;
|
|
37898
37898
|
this.body = body;
|
|
37899
37899
|
this.name = "ApiError";
|
|
@@ -38368,9 +38368,9 @@ var baseOpen = async (options) => {
|
|
|
38368
38368
|
firefox: "--private-window",
|
|
38369
38369
|
edge: "--inPrivate"
|
|
38370
38370
|
};
|
|
38371
|
-
const
|
|
38372
|
-
if (
|
|
38373
|
-
const browserName = ids[
|
|
38371
|
+
const browser2 = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser2();
|
|
38372
|
+
if (browser2.id in ids) {
|
|
38373
|
+
const browserName = ids[browser2.id];
|
|
38374
38374
|
if (app === "browserPrivate") {
|
|
38375
38375
|
appArguments.push(flags[browserName]);
|
|
38376
38376
|
}
|
|
@@ -38382,7 +38382,7 @@ var baseOpen = async (options) => {
|
|
|
38382
38382
|
}
|
|
38383
38383
|
});
|
|
38384
38384
|
}
|
|
38385
|
-
throw new Error(`${
|
|
38385
|
+
throw new Error(`${browser2.name} is not supported as a default browser`);
|
|
38386
38386
|
}
|
|
38387
38387
|
let command;
|
|
38388
38388
|
const cliArguments = [];
|
|
@@ -52503,7 +52503,7 @@ var TransactionReceipt = class {
|
|
|
52503
52503
|
logsBloom,
|
|
52504
52504
|
logs,
|
|
52505
52505
|
//byzantium,
|
|
52506
|
-
status:
|
|
52506
|
+
status: status3,
|
|
52507
52507
|
root
|
|
52508
52508
|
} = this;
|
|
52509
52509
|
return {
|
|
@@ -52523,7 +52523,7 @@ var TransactionReceipt = class {
|
|
|
52523
52523
|
logs,
|
|
52524
52524
|
logsBloom,
|
|
52525
52525
|
root,
|
|
52526
|
-
status:
|
|
52526
|
+
status: status3,
|
|
52527
52527
|
to
|
|
52528
52528
|
};
|
|
52529
52529
|
}
|
|
@@ -63340,9 +63340,9 @@ function siteOrigin() {
|
|
|
63340
63340
|
}
|
|
63341
63341
|
var LANE = "/api/identity";
|
|
63342
63342
|
var WireError = class extends Error {
|
|
63343
|
-
constructor(
|
|
63343
|
+
constructor(status3, code, message, body) {
|
|
63344
63344
|
super(message);
|
|
63345
|
-
this.status =
|
|
63345
|
+
this.status = status3;
|
|
63346
63346
|
this.code = code;
|
|
63347
63347
|
this.body = body;
|
|
63348
63348
|
this.name = "WireError";
|
|
@@ -63765,24 +63765,24 @@ async function passwordsList(opts) {
|
|
|
63765
63765
|
}
|
|
63766
63766
|
}
|
|
63767
63767
|
async function rowForUrl(wallet, url) {
|
|
63768
|
-
let
|
|
63768
|
+
let host2;
|
|
63769
63769
|
try {
|
|
63770
|
-
|
|
63770
|
+
host2 = new URL(url).hostname.toLowerCase();
|
|
63771
63771
|
} catch {
|
|
63772
63772
|
throw new PasswordsSealError("--url must be the https URL the use targets");
|
|
63773
63773
|
}
|
|
63774
63774
|
const { passwords: passwords2, permitted } = await listRows(wallet);
|
|
63775
|
-
const covers = (hosts) => hosts.some((h) =>
|
|
63775
|
+
const covers = (hosts) => hosts.some((h) => host2 === h.toLowerCase() || host2.endsWith(`.${h.toLowerCase()}`));
|
|
63776
63776
|
const own = passwords2.find((r) => covers(r.hosts));
|
|
63777
63777
|
if (own) return own.id;
|
|
63778
63778
|
const lent = permitted.find((r) => covers(r.hosts));
|
|
63779
63779
|
if (lent) return lent.id;
|
|
63780
|
-
throw new PasswordsSealError(`no login this key holds or may use covers ${
|
|
63780
|
+
throw new PasswordsSealError(`no login this key holds or may use covers ${host2}; pass --row <id>, or add one`);
|
|
63781
63781
|
}
|
|
63782
|
-
function printUseAnswer(opts,
|
|
63783
|
-
const data4 = { ok: body.ok === true, status:
|
|
63782
|
+
function printUseAnswer(opts, status3, body) {
|
|
63783
|
+
const data4 = { ok: body.ok === true, status: status3, ...body };
|
|
63784
63784
|
emit2(opts, data4, () => {
|
|
63785
|
-
if (
|
|
63785
|
+
if (status3 === 200) {
|
|
63786
63786
|
const result = body.result ?? {};
|
|
63787
63787
|
const code = typeof result.code === "string" ? result.code : "ok";
|
|
63788
63788
|
const digest = typeof result.digest === "string" ? result.digest : "";
|
|
@@ -63799,7 +63799,7 @@ ${digest.split("\n").map((l) => ` ${l}`).join("\n")}
|
|
|
63799
63799
|
return;
|
|
63800
63800
|
}
|
|
63801
63801
|
process.stdout.write(`
|
|
63802
|
-
${body.error ?? `HTTP ${
|
|
63802
|
+
${body.error ?? `HTTP ${status3}`}${body.code ? import_picocolors7.default.dim(` (${body.code})`) : ""}
|
|
63803
63803
|
${body.useId ? ` ${import_picocolors7.default.dim("use")} ${body.useId}
|
|
63804
63804
|
` : ""}
|
|
63805
63805
|
`);
|
|
@@ -64210,17 +64210,283 @@ function printNext(put) {
|
|
|
64210
64210
|
`);
|
|
64211
64211
|
}
|
|
64212
64212
|
|
|
64213
|
-
// src/commands/
|
|
64213
|
+
// src/commands/browser.ts
|
|
64214
64214
|
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
64215
|
+
|
|
64216
|
+
// src/lib/browser-wire.ts
|
|
64217
|
+
var BROWSER_LANE = "/api/identity/browser";
|
|
64218
|
+
var SETTLED = /* @__PURE__ */ new Set(["done", "failed", "cancelled"]);
|
|
64219
|
+
async function readBrowserCatalog() {
|
|
64220
|
+
let res;
|
|
64221
|
+
try {
|
|
64222
|
+
res = await fetch(`${siteOrigin()}/api/identity/catalog`, { headers: { accept: "application/json", "user-agent": CLI_USER_AGENT } });
|
|
64223
|
+
} catch (err) {
|
|
64224
|
+
throw new WireError(0, "network_error", `could not reach ${siteOrigin()}: ${err.message}`, null);
|
|
64225
|
+
}
|
|
64226
|
+
if (!res.ok) throw new WireError(res.status, null, `browser catalog: HTTP ${res.status}`, null);
|
|
64227
|
+
const body = await res.json();
|
|
64228
|
+
return {
|
|
64229
|
+
product: (body.products ?? []).find((p) => p.id === "browser") ?? null,
|
|
64230
|
+
usage: body.browserUsage ?? null,
|
|
64231
|
+
networks: body.payment?.networks ?? []
|
|
64232
|
+
};
|
|
64233
|
+
}
|
|
64234
|
+
function expect(answer, what) {
|
|
64235
|
+
if (answer.status >= 200 && answer.status < 300 && answer.body) return answer.body;
|
|
64236
|
+
const body = answer.body ?? null;
|
|
64237
|
+
const sentence = typeof body?.error === "string" ? body.error : answer.text.slice(0, 300) || `${what}: HTTP ${answer.status}`;
|
|
64238
|
+
const code = typeof body?.code === "string" ? body.code : null;
|
|
64239
|
+
throw new WireError(answer.status, code, sentence, answer.body);
|
|
64240
|
+
}
|
|
64241
|
+
async function postTask(wallet, args) {
|
|
64242
|
+
const body = { url: args.url, goal: args.goal };
|
|
64243
|
+
if (args.hosts?.length) body.hosts = args.hosts;
|
|
64244
|
+
if (typeof args.maxSteps === "number") body.maxSteps = args.maxSteps;
|
|
64245
|
+
if (typeof args.maxSeconds === "number") body.maxSeconds = args.maxSeconds;
|
|
64246
|
+
const answer = await signedFetch(wallet, "POST", `${BROWSER_LANE}/tasks`, body);
|
|
64247
|
+
return expect(answer, "task").task;
|
|
64248
|
+
}
|
|
64249
|
+
async function listTasks(wallet) {
|
|
64250
|
+
const answer = await signedFetch(wallet, "GET", `${BROWSER_LANE}/tasks`);
|
|
64251
|
+
return expect(answer, "tasks").tasks ?? [];
|
|
64252
|
+
}
|
|
64253
|
+
async function readTask(wallet, id2) {
|
|
64254
|
+
const answer = await signedFetch(wallet, "GET", `${BROWSER_LANE}/tasks/${encodeURIComponent(id2)}`);
|
|
64255
|
+
return expect(answer, "task").task;
|
|
64256
|
+
}
|
|
64257
|
+
async function cancelTask(wallet, id2) {
|
|
64258
|
+
const answer = await signedFetch(wallet, "POST", `${BROWSER_LANE}/tasks/${encodeURIComponent(id2)}/cancel`);
|
|
64259
|
+
return expect(answer, "cancel").task;
|
|
64260
|
+
}
|
|
64261
|
+
async function waitForTask(wallet, id2, { maxSeconds = 900, everyMs = 5e3, onTick } = {}) {
|
|
64262
|
+
const until = Date.now() + maxSeconds * 1e3;
|
|
64263
|
+
for (; ; ) {
|
|
64264
|
+
const task = await readTask(wallet, id2);
|
|
64265
|
+
onTick?.(task);
|
|
64266
|
+
if (SETTLED.has(task.status) || Date.now() >= until) return task;
|
|
64267
|
+
await new Promise((r) => setTimeout(r, everyMs));
|
|
64268
|
+
}
|
|
64269
|
+
}
|
|
64270
|
+
|
|
64271
|
+
// src/commands/browser.ts
|
|
64272
|
+
var jsonMode2 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
64273
|
+
function emit3(opts, data4, human) {
|
|
64274
|
+
if (jsonMode2(opts)) {
|
|
64275
|
+
process.stdout.write(JSON.stringify(data4, null, 2) + "\n");
|
|
64276
|
+
return;
|
|
64277
|
+
}
|
|
64278
|
+
human();
|
|
64279
|
+
}
|
|
64280
|
+
function refuse2(opts, error, code, extra = {}) {
|
|
64281
|
+
if (jsonMode2(opts)) {
|
|
64282
|
+
process.stdout.write(JSON.stringify({ ok: false, code, error, ...extra }, null, 2) + "\n");
|
|
64283
|
+
} else {
|
|
64284
|
+
process.stderr.write(` ${error}${code ? import_picocolors9.default.dim(` (${code})`) : ""}
|
|
64285
|
+
`);
|
|
64286
|
+
}
|
|
64287
|
+
process.exit(1);
|
|
64288
|
+
}
|
|
64289
|
+
function failFrom2(opts, err) {
|
|
64290
|
+
if (err instanceof WireError) return refuse2(opts, err.message, err.code, { status: err.status });
|
|
64291
|
+
return refuse2(opts, err.message ?? String(err), null);
|
|
64292
|
+
}
|
|
64293
|
+
var usd5 = (v) => {
|
|
64294
|
+
const n2 = Number(v);
|
|
64295
|
+
if (Number.isInteger(n2)) return `$${n2}`;
|
|
64296
|
+
const [whole, frac = ""] = n2.toFixed(6).replace(/0+$/, "").split(".");
|
|
64297
|
+
return `$${whole}.${frac.padEnd(2, "0")}`;
|
|
64298
|
+
};
|
|
64299
|
+
var host = (url) => {
|
|
64300
|
+
try {
|
|
64301
|
+
return new URL(url).host;
|
|
64302
|
+
} catch {
|
|
64303
|
+
return url;
|
|
64304
|
+
}
|
|
64305
|
+
};
|
|
64306
|
+
var when = (iso) => iso ? iso.replace("T", " ").slice(0, 16) : "";
|
|
64307
|
+
var STATUS_COLOR = {
|
|
64308
|
+
queued: import_picocolors9.default.dim,
|
|
64309
|
+
running: import_picocolors9.default.cyan,
|
|
64310
|
+
done: import_picocolors9.default.green,
|
|
64311
|
+
failed: import_picocolors9.default.red,
|
|
64312
|
+
cancelled: import_picocolors9.default.dim
|
|
64313
|
+
};
|
|
64314
|
+
var status = (s) => (STATUS_COLOR[s] ?? import_picocolors9.default.dim)(s.padEnd(9));
|
|
64315
|
+
function siteUrl(raw) {
|
|
64316
|
+
const t = raw.trim();
|
|
64317
|
+
return /^[a-z][a-z0-9+.-]*:\/\//i.test(t) ? t : `https://${t}`;
|
|
64318
|
+
}
|
|
64319
|
+
function printTask(t, full) {
|
|
64320
|
+
process.stdout.write(`
|
|
64321
|
+
${status(t.status)} ${import_picocolors9.default.bold(t.id)} ${import_picocolors9.default.dim(host(t.url))} ${import_picocolors9.default.dim(`${t.stepsRun}/${t.maxSteps} steps`)}
|
|
64322
|
+
`);
|
|
64323
|
+
process.stdout.write(` ${t.goal}
|
|
64324
|
+
`);
|
|
64325
|
+
if (t.status === "done") process.stdout.write(` ${import_picocolors9.default.dim(`charged ${usd5(t.chargedUsd)}`)}
|
|
64326
|
+
`);
|
|
64327
|
+
else if (t.status === "queued" || t.status === "running") process.stdout.write(` ${import_picocolors9.default.dim(`reserved ${usd5(t.reservedUsd)}`)}
|
|
64328
|
+
`);
|
|
64329
|
+
if (t.answer) process.stdout.write(`
|
|
64330
|
+
${import_picocolors9.default.bold("Answer")}
|
|
64331
|
+
${t.answer.replace(/\n/g, "\n ")}
|
|
64332
|
+
`);
|
|
64333
|
+
if (t.status === "failed" && t.error) process.stdout.write(`
|
|
64334
|
+
${import_picocolors9.default.red(t.error)}${t.code ? import_picocolors9.default.dim(` (${t.code})`) : ""}
|
|
64335
|
+
`);
|
|
64336
|
+
if (t.reached) process.stdout.write(` ${import_picocolors9.default.dim("reached:")} ${t.reached}
|
|
64337
|
+
`);
|
|
64338
|
+
if (t.wall) process.stdout.write(` ${import_picocolors9.default.dim("stopped by:")} ${t.wall}
|
|
64339
|
+
`);
|
|
64340
|
+
if (t.finalUrl) process.stdout.write(` ${import_picocolors9.default.dim("ended on:")} ${t.finalUrl}
|
|
64341
|
+
`);
|
|
64342
|
+
if (full && t.findings?.length) {
|
|
64343
|
+
process.stdout.write(`
|
|
64344
|
+
${import_picocolors9.default.bold("Notes")}
|
|
64345
|
+
`);
|
|
64346
|
+
for (const f2 of t.findings) process.stdout.write(` - ${String(f2)}
|
|
64347
|
+
`);
|
|
64348
|
+
}
|
|
64349
|
+
if (full && t.transcript?.length) {
|
|
64350
|
+
process.stdout.write(`
|
|
64351
|
+
${import_picocolors9.default.bold("What it did")}
|
|
64352
|
+
`);
|
|
64353
|
+
for (const s of t.transcript) process.stdout.write(` ${import_picocolors9.default.dim(s.line)}
|
|
64354
|
+
`);
|
|
64355
|
+
}
|
|
64356
|
+
process.stdout.write("\n");
|
|
64357
|
+
}
|
|
64358
|
+
async function browserPricing(opts) {
|
|
64359
|
+
try {
|
|
64360
|
+
const { product, usage, networks } = await readBrowserCatalog();
|
|
64361
|
+
emit3(opts, { ok: true, product, usage, networks }, () => {
|
|
64362
|
+
process.stdout.write(`
|
|
64363
|
+
${import_picocolors9.default.bold("BROWSER")} ${import_picocolors9.default.dim(product?.brief ?? "a site and a task in words; it browses, then answers")}
|
|
64364
|
+
|
|
64365
|
+
`);
|
|
64366
|
+
if (!product || product.available === false) {
|
|
64367
|
+
process.stdout.write(` ${import_picocolors9.default.dim(product?.note ?? "the browser is not on sale right now")}
|
|
64368
|
+
|
|
64369
|
+
`);
|
|
64370
|
+
return;
|
|
64371
|
+
}
|
|
64372
|
+
if (usage?.stepUsd) process.stdout.write(` ${import_picocolors9.default.cyan(usd5(usage.stepUsd))} ${import_picocolors9.default.dim("a step, from the prepaid balance")}
|
|
64373
|
+
`);
|
|
64374
|
+
if (usage) {
|
|
64375
|
+
process.stdout.write(` ${import_picocolors9.default.dim(`steps 1 to ${usage.maxSteps} (default ${usage.defaultSteps}) \xB7 ${usage.minSeconds} to ${usage.maxSeconds} seconds \xB7 up to ${usage.maxHosts} extra hosts`)}
|
|
64376
|
+
`);
|
|
64377
|
+
process.stdout.write(` ${import_picocolors9.default.dim(usage.note)}
|
|
64378
|
+
`);
|
|
64379
|
+
}
|
|
64380
|
+
if (networks.length) process.stdout.write(`
|
|
64381
|
+
${import_picocolors9.default.dim(`balance top-ups in USDC on ${networks.join(", ")}`)}
|
|
64382
|
+
`);
|
|
64383
|
+
process.stdout.write("\n");
|
|
64384
|
+
});
|
|
64385
|
+
} catch (err) {
|
|
64386
|
+
failFrom2(opts, err);
|
|
64387
|
+
}
|
|
64388
|
+
}
|
|
64389
|
+
async function browserRun(url, opts) {
|
|
64390
|
+
const goal = (opts.task ?? "").trim();
|
|
64391
|
+
if (!goal) return refuse2(opts, 'say what the browser agent should do: --task "<words>"', "bad_request");
|
|
64392
|
+
const maxSteps = opts.steps !== void 0 ? Number(opts.steps) : void 0;
|
|
64393
|
+
if (maxSteps !== void 0 && !Number.isInteger(maxSteps)) return refuse2(opts, "--steps must be a whole number", "bad_request");
|
|
64394
|
+
const maxSeconds = opts.seconds !== void 0 ? Number(opts.seconds) : void 0;
|
|
64395
|
+
if (maxSeconds !== void 0 && !Number.isInteger(maxSeconds)) return refuse2(opts, "--seconds must be a whole number", "bad_request");
|
|
64396
|
+
try {
|
|
64397
|
+
const keys = await requirePasswordsKey();
|
|
64398
|
+
const task = await postTask(keys.wallet, { url: siteUrl(url), goal, hosts: opts.host, maxSteps, maxSeconds });
|
|
64399
|
+
if (!opts.wait) {
|
|
64400
|
+
emit3(opts, { ok: true, task }, () => {
|
|
64401
|
+
printTask(task, false);
|
|
64402
|
+
process.stdout.write(` ${import_picocolors9.default.dim(`read it back: agentgates browser task ${task.id} --wait`)}
|
|
64403
|
+
|
|
64404
|
+
`);
|
|
64405
|
+
});
|
|
64406
|
+
return;
|
|
64407
|
+
}
|
|
64408
|
+
const waitSeconds = typeof opts.wait === "string" ? Math.max(5, Number(opts.wait) || 0) : Math.max(60, task.maxSeconds + 120);
|
|
64409
|
+
let lastStatus = "";
|
|
64410
|
+
const settled = await waitForTask(keys.wallet, task.id, {
|
|
64411
|
+
maxSeconds: waitSeconds,
|
|
64412
|
+
onTick: (t) => {
|
|
64413
|
+
if (jsonMode2(opts) || t.status === lastStatus) return;
|
|
64414
|
+
lastStatus = t.status;
|
|
64415
|
+
process.stderr.write(` ${import_picocolors9.default.dim(`${t.status}${t.status === "running" ? ` \xB7 ${t.stepsRun} steps` : ""}`)}
|
|
64416
|
+
`);
|
|
64417
|
+
}
|
|
64418
|
+
});
|
|
64419
|
+
emit3(opts, { ok: SETTLED.has(settled.status), task: settled }, () => {
|
|
64420
|
+
printTask(settled, true);
|
|
64421
|
+
if (!SETTLED.has(settled.status)) process.stdout.write(` ${import_picocolors9.default.dim(`still ${settled.status}; read it later: agentgates browser task ${settled.id} --wait`)}
|
|
64422
|
+
|
|
64423
|
+
`);
|
|
64424
|
+
});
|
|
64425
|
+
if (settled.status === "failed") process.exitCode = 1;
|
|
64426
|
+
} catch (err) {
|
|
64427
|
+
failFrom2(opts, err);
|
|
64428
|
+
}
|
|
64429
|
+
}
|
|
64430
|
+
async function browserTasks(opts) {
|
|
64431
|
+
try {
|
|
64432
|
+
const keys = await requirePasswordsKey();
|
|
64433
|
+
const tasks = await listTasks(keys.wallet);
|
|
64434
|
+
emit3(opts, { ok: true, wallet: keys.wallet.address, tasks }, () => {
|
|
64435
|
+
process.stdout.write(`
|
|
64436
|
+
${import_picocolors9.default.bold("YOUR TASKS")} ${import_picocolors9.default.dim(keys.wallet.address)}
|
|
64437
|
+
|
|
64438
|
+
`);
|
|
64439
|
+
if (tasks.length === 0) {
|
|
64440
|
+
process.stdout.write(` ${import_picocolors9.default.dim('none yet: agentgates browser run <url> --task "\u2026"')}
|
|
64441
|
+
|
|
64442
|
+
`);
|
|
64443
|
+
return;
|
|
64444
|
+
}
|
|
64445
|
+
for (const t of tasks) {
|
|
64446
|
+
const money = t.status === "done" ? usd5(t.chargedUsd) : t.status === "queued" || t.status === "running" ? `${usd5(t.reservedUsd)} reserved` : "";
|
|
64447
|
+
process.stdout.write(` ${status(t.status)} ${t.id} ${import_picocolors9.default.dim(host(t.url).padEnd(24))} ${import_picocolors9.default.dim(`${t.stepsRun}/${t.maxSteps}`.padStart(6))} ${import_picocolors9.default.dim(money.padEnd(16))} ${import_picocolors9.default.dim(when(t.createdAt))}
|
|
64448
|
+
`);
|
|
64449
|
+
process.stdout.write(` ${t.goal.length > 90 ? `${t.goal.slice(0, 89)}\u2026` : t.goal}
|
|
64450
|
+
`);
|
|
64451
|
+
}
|
|
64452
|
+
process.stdout.write("\n");
|
|
64453
|
+
});
|
|
64454
|
+
} catch (err) {
|
|
64455
|
+
failFrom2(opts, err);
|
|
64456
|
+
}
|
|
64457
|
+
}
|
|
64458
|
+
async function browserTask(id2, opts) {
|
|
64459
|
+
try {
|
|
64460
|
+
const keys = await requirePasswordsKey();
|
|
64461
|
+
if (opts.cancel) {
|
|
64462
|
+
const task2 = await cancelTask(keys.wallet, id2);
|
|
64463
|
+
emit3(opts, { ok: true, task: task2 }, () => printTask(task2, false));
|
|
64464
|
+
return;
|
|
64465
|
+
}
|
|
64466
|
+
const task = opts.wait ? await waitForTask(keys.wallet, id2, {
|
|
64467
|
+
maxSeconds: typeof opts.wait === "string" ? Math.max(5, Number(opts.wait) || 0) : 900,
|
|
64468
|
+
onTick: (t) => {
|
|
64469
|
+
if (!jsonMode2(opts) && !SETTLED.has(t.status)) process.stderr.write(` ${import_picocolors9.default.dim(`${t.status} \xB7 ${t.stepsRun} steps`)}
|
|
64470
|
+
`);
|
|
64471
|
+
}
|
|
64472
|
+
}) : await readTask(keys.wallet, id2);
|
|
64473
|
+
emit3(opts, { ok: true, task }, () => printTask(task, true));
|
|
64474
|
+
} catch (err) {
|
|
64475
|
+
failFrom2(opts, err);
|
|
64476
|
+
}
|
|
64477
|
+
}
|
|
64478
|
+
|
|
64479
|
+
// src/commands/logout.ts
|
|
64480
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
64215
64481
|
async function logout(opts) {
|
|
64216
64482
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
64217
64483
|
const resolved = await resolveProfile(requested);
|
|
64218
64484
|
if (!resolved) {
|
|
64219
|
-
process.stdout.write(
|
|
64485
|
+
process.stdout.write(import_picocolors10.default.dim("Not logged in \u2014 nothing to log out.\n"));
|
|
64220
64486
|
return;
|
|
64221
64487
|
}
|
|
64222
64488
|
if (resolved.autoSelected) {
|
|
64223
|
-
process.stderr.write(
|
|
64489
|
+
process.stderr.write(import_picocolors10.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
64224
64490
|
`));
|
|
64225
64491
|
}
|
|
64226
64492
|
const { profile, name: profileName } = resolved;
|
|
@@ -64245,15 +64511,15 @@ async function logout(opts) {
|
|
|
64245
64511
|
const removed = await deleteProfile(profileName);
|
|
64246
64512
|
if (removed) {
|
|
64247
64513
|
process.stdout.write(
|
|
64248
|
-
|
|
64514
|
+
import_picocolors10.default.green(`\u2713 Logged out of profile ${import_picocolors10.default.bold(profileName)}.
|
|
64249
64515
|
`)
|
|
64250
64516
|
);
|
|
64251
64517
|
}
|
|
64252
64518
|
if (serverError) {
|
|
64253
64519
|
process.stderr.write(
|
|
64254
|
-
|
|
64520
|
+
import_picocolors10.default.yellow(
|
|
64255
64521
|
`\u26A0 Couldn't revoke server-side: ${serverError}
|
|
64256
|
-
The local bearer is wiped. If the server still has it, revoke from ${
|
|
64522
|
+
The local bearer is wiped. If the server still has it, revoke from ${import_picocolors10.default.bold("agentgates.ai/settings/pairings")}.
|
|
64257
64523
|
`
|
|
64258
64524
|
)
|
|
64259
64525
|
);
|
|
@@ -64261,49 +64527,49 @@ async function logout(opts) {
|
|
|
64261
64527
|
}
|
|
64262
64528
|
|
|
64263
64529
|
// src/commands/whoami.ts
|
|
64264
|
-
var
|
|
64530
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
64265
64531
|
async function whoami(opts) {
|
|
64266
64532
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
64267
64533
|
const resolved = await resolveProfile(requested);
|
|
64268
64534
|
if (!resolved) {
|
|
64269
|
-
process.stderr.write(
|
|
64535
|
+
process.stderr.write(import_picocolors11.default.red("Not logged in. Run agentgates login first.\n"));
|
|
64270
64536
|
process.exit(2);
|
|
64271
64537
|
}
|
|
64272
64538
|
if (resolved.autoSelected) {
|
|
64273
|
-
process.stderr.write(
|
|
64539
|
+
process.stderr.write(import_picocolors11.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
64274
64540
|
`));
|
|
64275
64541
|
}
|
|
64276
64542
|
const { profile, name: profileName } = resolved;
|
|
64277
|
-
const
|
|
64543
|
+
const jsonMode3 = opts.json === true;
|
|
64278
64544
|
const outcome = await callWithAutoRelogin({
|
|
64279
64545
|
profile,
|
|
64280
64546
|
profileName,
|
|
64281
|
-
jsonMode:
|
|
64282
|
-
ttyHeader:
|
|
64547
|
+
jsonMode: jsonMode3,
|
|
64548
|
+
ttyHeader: import_picocolors11.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
64283
64549
|
fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
|
|
64284
64550
|
});
|
|
64285
64551
|
if (outcome.kind === "auth_failed") {
|
|
64286
|
-
if (
|
|
64552
|
+
if (jsonMode3) {
|
|
64287
64553
|
process.stdout.write(
|
|
64288
64554
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
64289
64555
|
);
|
|
64290
64556
|
process.exit(1);
|
|
64291
64557
|
}
|
|
64292
|
-
process.stderr.write(
|
|
64558
|
+
process.stderr.write(import_picocolors11.default.red(`\u2715 ${outcome.reason}.
|
|
64293
64559
|
`));
|
|
64294
64560
|
process.exit(1);
|
|
64295
64561
|
}
|
|
64296
64562
|
if (outcome.kind === "error") {
|
|
64297
64563
|
const err = outcome.error;
|
|
64298
64564
|
if (err instanceof ApiError) {
|
|
64299
|
-
process.stderr.write(
|
|
64565
|
+
process.stderr.write(import_picocolors11.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
64300
64566
|
`));
|
|
64301
64567
|
process.exit(1);
|
|
64302
64568
|
}
|
|
64303
64569
|
throw err;
|
|
64304
64570
|
}
|
|
64305
64571
|
const me = outcome.result;
|
|
64306
|
-
if (
|
|
64572
|
+
if (jsonMode3) {
|
|
64307
64573
|
process.stdout.write(JSON.stringify(me, null, 2) + "\n");
|
|
64308
64574
|
return;
|
|
64309
64575
|
}
|
|
@@ -64317,7 +64583,7 @@ async function whoami(opts) {
|
|
|
64317
64583
|
process.stdout.write(`Solana ${me.solanaAddress}
|
|
64318
64584
|
`);
|
|
64319
64585
|
}
|
|
64320
|
-
process.stdout.write(`Scopes ${me.scopes.join(", ") ||
|
|
64586
|
+
process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors11.default.dim("(none)")}
|
|
64321
64587
|
`);
|
|
64322
64588
|
const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
|
|
64323
64589
|
const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
|
|
@@ -64334,7 +64600,7 @@ async function whoami(opts) {
|
|
|
64334
64600
|
`
|
|
64335
64601
|
);
|
|
64336
64602
|
process.stdout.write(
|
|
64337
|
-
`Profile ${profileName === DEFAULT_PROFILE ?
|
|
64603
|
+
`Profile ${profileName === DEFAULT_PROFILE ? import_picocolors11.default.dim("(default)") : profileName}
|
|
64338
64604
|
`
|
|
64339
64605
|
);
|
|
64340
64606
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -64348,7 +64614,7 @@ function formatDate(iso) {
|
|
|
64348
64614
|
}
|
|
64349
64615
|
|
|
64350
64616
|
// src/commands/send.ts
|
|
64351
|
-
var
|
|
64617
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
64352
64618
|
|
|
64353
64619
|
// src/lib/status.ts
|
|
64354
64620
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -64498,20 +64764,20 @@ async function send(amount, asset, opts) {
|
|
|
64498
64764
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
64499
64765
|
const resolved = await resolveProfile(requested);
|
|
64500
64766
|
if (!resolved) {
|
|
64501
|
-
process.stderr.write(
|
|
64767
|
+
process.stderr.write(import_picocolors12.default.red("Not logged in. Run agentgates login first.\n"));
|
|
64502
64768
|
process.exit(2);
|
|
64503
64769
|
}
|
|
64504
64770
|
if (resolved.autoSelected) {
|
|
64505
|
-
process.stderr.write(
|
|
64771
|
+
process.stderr.write(import_picocolors12.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
64506
64772
|
`));
|
|
64507
64773
|
}
|
|
64508
64774
|
const { profile, name: profileName } = resolved;
|
|
64509
64775
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
64510
|
-
const
|
|
64776
|
+
const jsonMode3 = opts.json === true || !stdoutIsTty;
|
|
64511
64777
|
const amountNumber = Number(amount);
|
|
64512
64778
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
64513
64779
|
process.stderr.write(
|
|
64514
|
-
|
|
64780
|
+
import_picocolors12.default.red(`\u2715 amount must be a positive number (got ${import_picocolors12.default.bold(amount)}).
|
|
64515
64781
|
`)
|
|
64516
64782
|
);
|
|
64517
64783
|
process.exit(2);
|
|
@@ -64519,23 +64785,23 @@ async function send(amount, asset, opts) {
|
|
|
64519
64785
|
const assetNormalized = asset.toLowerCase();
|
|
64520
64786
|
if (assetNormalized !== "native" && assetNormalized !== "usdc") {
|
|
64521
64787
|
process.stderr.write(
|
|
64522
|
-
|
|
64523
|
-
`\u2715 asset must be ${
|
|
64788
|
+
import_picocolors12.default.red(
|
|
64789
|
+
`\u2715 asset must be ${import_picocolors12.default.bold("native")} or ${import_picocolors12.default.bold("usdc")} (got ${import_picocolors12.default.bold(asset)}).
|
|
64524
64790
|
`
|
|
64525
64791
|
)
|
|
64526
64792
|
);
|
|
64527
64793
|
process.exit(2);
|
|
64528
64794
|
}
|
|
64529
64795
|
if (!opts.to || opts.to.trim() === "") {
|
|
64530
|
-
process.stderr.write(
|
|
64796
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 --to <address> is required.
|
|
64531
64797
|
`));
|
|
64532
64798
|
process.exit(2);
|
|
64533
64799
|
}
|
|
64534
64800
|
if (isSolanaChainAlias(opts.chain)) {
|
|
64535
64801
|
if (EVM_ADDRESS_RE.test(opts.to)) {
|
|
64536
64802
|
process.stderr.write(
|
|
64537
|
-
|
|
64538
|
-
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${
|
|
64803
|
+
import_picocolors12.default.red(
|
|
64804
|
+
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors12.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
|
|
64539
64805
|
`
|
|
64540
64806
|
)
|
|
64541
64807
|
);
|
|
@@ -64543,10 +64809,10 @@ async function send(amount, asset, opts) {
|
|
|
64543
64809
|
}
|
|
64544
64810
|
if (!SOLANA_ADDRESS_RE.test(opts.to)) {
|
|
64545
64811
|
process.stderr.write(
|
|
64546
|
-
|
|
64547
|
-
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${
|
|
64812
|
+
import_picocolors12.default.red(
|
|
64813
|
+
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors12.default.bold(opts.to)}).
|
|
64548
64814
|
`
|
|
64549
|
-
) +
|
|
64815
|
+
) + import_picocolors12.default.dim(
|
|
64550
64816
|
` SNS resolution is deferred to a future server-side change;
|
|
64551
64817
|
for now Solana sends require the literal pubkey.
|
|
64552
64818
|
`
|
|
@@ -64557,8 +64823,8 @@ async function send(amount, asset, opts) {
|
|
|
64557
64823
|
}
|
|
64558
64824
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
64559
64825
|
process.stderr.write(
|
|
64560
|
-
|
|
64561
|
-
`) +
|
|
64826
|
+
import_picocolors12.default.red(`\u2715 --user-stated <text> is required.
|
|
64827
|
+
`) + import_picocolors12.default.dim(
|
|
64562
64828
|
` This is the trust-gap defense: pass the verbatim user request so
|
|
64563
64829
|
the approval modal can cross-check what the agent thinks the user
|
|
64564
64830
|
asked for vs. the actual decoded transaction.
|
|
@@ -64576,7 +64842,7 @@ async function send(amount, asset, opts) {
|
|
|
64576
64842
|
const n2 = Number(opts.maxUsd);
|
|
64577
64843
|
if (!Number.isFinite(n2) || n2 <= 0) {
|
|
64578
64844
|
process.stderr.write(
|
|
64579
|
-
|
|
64845
|
+
import_picocolors12.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
|
|
64580
64846
|
`)
|
|
64581
64847
|
);
|
|
64582
64848
|
process.exit(2);
|
|
@@ -64616,12 +64882,12 @@ async function send(amount, asset, opts) {
|
|
|
64616
64882
|
try {
|
|
64617
64883
|
activeProfile = await runLoginFlow({
|
|
64618
64884
|
profile: profileName,
|
|
64619
|
-
jsonMode:
|
|
64885
|
+
jsonMode: jsonMode3,
|
|
64620
64886
|
origin: activeProfile.mcpOrigin,
|
|
64621
|
-
ttyHeader:
|
|
64887
|
+
ttyHeader: import_picocolors12.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
64622
64888
|
});
|
|
64623
64889
|
} catch (reloginErr) {
|
|
64624
|
-
if (
|
|
64890
|
+
if (jsonMode3) {
|
|
64625
64891
|
emitNdjson({
|
|
64626
64892
|
ok: false,
|
|
64627
64893
|
status: "auth_failed",
|
|
@@ -64630,7 +64896,7 @@ async function send(amount, asset, opts) {
|
|
|
64630
64896
|
process.exit(1);
|
|
64631
64897
|
}
|
|
64632
64898
|
process.stderr.write(
|
|
64633
|
-
|
|
64899
|
+
import_picocolors12.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
64634
64900
|
`)
|
|
64635
64901
|
);
|
|
64636
64902
|
process.exit(1);
|
|
@@ -64644,7 +64910,7 @@ async function send(amount, asset, opts) {
|
|
|
64644
64910
|
});
|
|
64645
64911
|
} catch (retryErr) {
|
|
64646
64912
|
if (retryErr instanceof ApiError) {
|
|
64647
|
-
if (
|
|
64913
|
+
if (jsonMode3) {
|
|
64648
64914
|
emitNdjson({
|
|
64649
64915
|
ok: false,
|
|
64650
64916
|
status: retryErr.status === 401 ? "auth_failed" : "propose_failed",
|
|
@@ -64654,7 +64920,7 @@ async function send(amount, asset, opts) {
|
|
|
64654
64920
|
process.exit(1);
|
|
64655
64921
|
}
|
|
64656
64922
|
process.stderr.write(
|
|
64657
|
-
|
|
64923
|
+
import_picocolors12.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
64658
64924
|
`)
|
|
64659
64925
|
);
|
|
64660
64926
|
process.exit(1);
|
|
@@ -64662,7 +64928,7 @@ async function send(amount, asset, opts) {
|
|
|
64662
64928
|
throw retryErr;
|
|
64663
64929
|
}
|
|
64664
64930
|
} else if (err instanceof ApiError) {
|
|
64665
|
-
if (
|
|
64931
|
+
if (jsonMode3) {
|
|
64666
64932
|
emitNdjson({
|
|
64667
64933
|
ok: false,
|
|
64668
64934
|
status: "propose_failed",
|
|
@@ -64671,7 +64937,7 @@ async function send(amount, asset, opts) {
|
|
|
64671
64937
|
});
|
|
64672
64938
|
process.exit(1);
|
|
64673
64939
|
}
|
|
64674
|
-
process.stderr.write(
|
|
64940
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
64675
64941
|
`));
|
|
64676
64942
|
process.exit(1);
|
|
64677
64943
|
} else {
|
|
@@ -64679,7 +64945,7 @@ async function send(amount, asset, opts) {
|
|
|
64679
64945
|
}
|
|
64680
64946
|
}
|
|
64681
64947
|
if (isBlocked(proposed)) {
|
|
64682
|
-
if (
|
|
64948
|
+
if (jsonMode3) {
|
|
64683
64949
|
const envelope = {
|
|
64684
64950
|
ok: false,
|
|
64685
64951
|
status: "blocked",
|
|
@@ -64697,17 +64963,17 @@ async function send(amount, asset, opts) {
|
|
|
64697
64963
|
if (proposed.detail) {
|
|
64698
64964
|
const d = proposed.detail;
|
|
64699
64965
|
process.stderr.write(
|
|
64700
|
-
|
|
64966
|
+
import_picocolors12.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
|
|
64701
64967
|
`
|
|
64702
64968
|
);
|
|
64703
64969
|
} else {
|
|
64704
|
-
process.stderr.write(
|
|
64970
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${proposed.reason}
|
|
64705
64971
|
`));
|
|
64706
64972
|
}
|
|
64707
64973
|
if (proposed.upgrade_url) {
|
|
64708
64974
|
process.stderr.write(
|
|
64709
64975
|
` Open this to grant access, then re-run the command:
|
|
64710
|
-
${
|
|
64976
|
+
${import_picocolors12.default.cyan(proposed.upgrade_url)}
|
|
64711
64977
|
`
|
|
64712
64978
|
);
|
|
64713
64979
|
}
|
|
@@ -64717,21 +64983,21 @@ async function send(amount, asset, opts) {
|
|
|
64717
64983
|
const a = proposed.recommended_actions[i];
|
|
64718
64984
|
process.stderr.write(` ${i + 1}. ${a.label}
|
|
64719
64985
|
`);
|
|
64720
|
-
if (a.reasoning) process.stderr.write(
|
|
64986
|
+
if (a.reasoning) process.stderr.write(import_picocolors12.default.dim(` ${a.reasoning}
|
|
64721
64987
|
`));
|
|
64722
64988
|
if (a.action_intent && a.action_intent.external_url) {
|
|
64723
64989
|
process.stderr.write(
|
|
64724
|
-
` ${
|
|
64990
|
+
` ${import_picocolors12.default.cyan(a.action_intent.external_url)}
|
|
64725
64991
|
`
|
|
64726
64992
|
);
|
|
64727
64993
|
}
|
|
64728
64994
|
}
|
|
64729
64995
|
}
|
|
64730
64996
|
if (proposed.suggestions && proposed.suggestions.length > 0) {
|
|
64731
|
-
process.stderr.write(
|
|
64997
|
+
process.stderr.write(import_picocolors12.default.dim("\n Other ways to fund:\n"));
|
|
64732
64998
|
for (const s of proposed.suggestions) {
|
|
64733
64999
|
if (s.kind === "ask_user") continue;
|
|
64734
|
-
process.stderr.write(
|
|
65000
|
+
process.stderr.write(import_picocolors12.default.dim(` \u2022 ${s.label}
|
|
64735
65001
|
`));
|
|
64736
65002
|
}
|
|
64737
65003
|
}
|
|
@@ -64743,7 +65009,7 @@ async function send(amount, asset, opts) {
|
|
|
64743
65009
|
if (process.env.CI === "1" || process.env.CI === "true") return false;
|
|
64744
65010
|
return true;
|
|
64745
65011
|
})();
|
|
64746
|
-
if (
|
|
65012
|
+
if (jsonMode3) {
|
|
64747
65013
|
emitNdjson({
|
|
64748
65014
|
ok: true,
|
|
64749
65015
|
status: "proposed",
|
|
@@ -64758,8 +65024,8 @@ async function send(amount, asset, opts) {
|
|
|
64758
65024
|
} else {
|
|
64759
65025
|
process.stdout.write(
|
|
64760
65026
|
`
|
|
64761
|
-
${
|
|
64762
|
-
${
|
|
65027
|
+
${import_picocolors12.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
65028
|
+
${import_picocolors12.default.cyan(proposed.approval_url)}
|
|
64763
65029
|
|
|
64764
65030
|
`
|
|
64765
65031
|
);
|
|
@@ -64775,10 +65041,10 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
64775
65041
|
intervalMs: POLL_INTERVAL_MS,
|
|
64776
65042
|
giveUpMs: POLL_GIVEUP_MS,
|
|
64777
65043
|
onTick: (s) => {
|
|
64778
|
-
if (
|
|
65044
|
+
if (jsonMode3) {
|
|
64779
65045
|
emitNdjson({ status: s.status, intent_id: s.approval_id });
|
|
64780
65046
|
} else {
|
|
64781
|
-
process.stdout.write(` ${describeStatus(s.status)}${
|
|
65047
|
+
process.stdout.write(` ${describeStatus(s.status)}${import_picocolors12.default.dim("\u2026")}\r`);
|
|
64782
65048
|
}
|
|
64783
65049
|
}
|
|
64784
65050
|
});
|
|
@@ -64790,12 +65056,12 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
64790
65056
|
try {
|
|
64791
65057
|
activeProfile = await runLoginFlow({
|
|
64792
65058
|
profile: profileName,
|
|
64793
|
-
jsonMode:
|
|
65059
|
+
jsonMode: jsonMode3,
|
|
64794
65060
|
origin: activeProfile.mcpOrigin,
|
|
64795
|
-
ttyHeader:
|
|
65061
|
+
ttyHeader: import_picocolors12.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
|
|
64796
65062
|
});
|
|
64797
65063
|
} catch (reloginErr) {
|
|
64798
|
-
if (
|
|
65064
|
+
if (jsonMode3) {
|
|
64799
65065
|
emitNdjson({
|
|
64800
65066
|
ok: false,
|
|
64801
65067
|
status: "auth_failed",
|
|
@@ -64805,7 +65071,7 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
64805
65071
|
process.exit(1);
|
|
64806
65072
|
}
|
|
64807
65073
|
process.stderr.write(
|
|
64808
|
-
"\n" +
|
|
65074
|
+
"\n" + import_picocolors12.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
64809
65075
|
`)
|
|
64810
65076
|
);
|
|
64811
65077
|
process.exit(1);
|
|
@@ -64813,7 +65079,7 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
64813
65079
|
try {
|
|
64814
65080
|
final = await runPoll(activeProfile);
|
|
64815
65081
|
} catch (retryErr) {
|
|
64816
|
-
if (
|
|
65082
|
+
if (jsonMode3) {
|
|
64817
65083
|
emitNdjson({
|
|
64818
65084
|
ok: false,
|
|
64819
65085
|
status: retryErr instanceof ApiError && retryErr.status === 401 ? "auth_failed" : "poll_failed",
|
|
@@ -64823,13 +65089,13 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
64823
65089
|
process.exit(1);
|
|
64824
65090
|
}
|
|
64825
65091
|
process.stderr.write(
|
|
64826
|
-
"\n" +
|
|
65092
|
+
"\n" + import_picocolors12.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
64827
65093
|
`)
|
|
64828
65094
|
);
|
|
64829
65095
|
process.exit(1);
|
|
64830
65096
|
}
|
|
64831
65097
|
} else {
|
|
64832
|
-
if (
|
|
65098
|
+
if (jsonMode3) {
|
|
64833
65099
|
emitNdjson({
|
|
64834
65100
|
ok: false,
|
|
64835
65101
|
status: "poll_failed",
|
|
@@ -64839,14 +65105,14 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
64839
65105
|
process.exit(1);
|
|
64840
65106
|
}
|
|
64841
65107
|
process.stderr.write(
|
|
64842
|
-
"\n" +
|
|
65108
|
+
"\n" + import_picocolors12.default.red(`\u2715 Status poll failed: ${err.message}
|
|
64843
65109
|
`)
|
|
64844
65110
|
);
|
|
64845
65111
|
process.exit(1);
|
|
64846
65112
|
}
|
|
64847
65113
|
}
|
|
64848
65114
|
const explorer = final.tx_hash != null ? explorerUrl(final.chain_id, final.tx_hash) : null;
|
|
64849
|
-
if (
|
|
65115
|
+
if (jsonMode3) {
|
|
64850
65116
|
emitNdjson({
|
|
64851
65117
|
ok: final.status === "mined",
|
|
64852
65118
|
status: final.status,
|
|
@@ -64859,19 +65125,19 @@ ${import_picocolors11.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
64859
65125
|
}
|
|
64860
65126
|
process.stdout.write("\n");
|
|
64861
65127
|
if (final.status === "mined") {
|
|
64862
|
-
process.stdout.write(
|
|
65128
|
+
process.stdout.write(import_picocolors12.default.green("\u2713 Mined.") + "\n");
|
|
64863
65129
|
if (final.tx_hash) {
|
|
64864
65130
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
64865
65131
|
`);
|
|
64866
65132
|
}
|
|
64867
65133
|
if (explorer) {
|
|
64868
|
-
process.stdout.write(` Explorer ${
|
|
65134
|
+
process.stdout.write(` Explorer ${import_picocolors12.default.cyan(explorer)}
|
|
64869
65135
|
`);
|
|
64870
65136
|
}
|
|
64871
65137
|
process.exit(0);
|
|
64872
65138
|
}
|
|
64873
65139
|
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}`;
|
|
64874
|
-
process.stderr.write(
|
|
65140
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${label}.
|
|
64875
65141
|
`));
|
|
64876
65142
|
process.exit(1);
|
|
64877
65143
|
}
|
|
@@ -64899,7 +65165,7 @@ function describeStatus(s) {
|
|
|
64899
65165
|
}
|
|
64900
65166
|
|
|
64901
65167
|
// src/commands/status.ts
|
|
64902
|
-
var
|
|
65168
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
64903
65169
|
var WATCH_GIVEUP_MS = 10 * 6e4;
|
|
64904
65170
|
function explorerUrl2(chainId, hash2) {
|
|
64905
65171
|
switch (chainId) {
|
|
@@ -64915,38 +65181,38 @@ function explorerUrl2(chainId, hash2) {
|
|
|
64915
65181
|
return null;
|
|
64916
65182
|
}
|
|
64917
65183
|
}
|
|
64918
|
-
async function
|
|
65184
|
+
async function status2(intentId, opts) {
|
|
64919
65185
|
if (!intentId || intentId.trim() === "") {
|
|
64920
|
-
process.stderr.write(
|
|
65186
|
+
process.stderr.write(import_picocolors13.default.red("\u2715 Missing intent id.\n"));
|
|
64921
65187
|
process.exit(2);
|
|
64922
65188
|
}
|
|
64923
65189
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
64924
65190
|
const resolved = await resolveProfile(requested);
|
|
64925
65191
|
if (!resolved) {
|
|
64926
|
-
process.stderr.write(
|
|
65192
|
+
process.stderr.write(import_picocolors13.default.red("Not logged in. Run agentgates login first.\n"));
|
|
64927
65193
|
process.exit(2);
|
|
64928
65194
|
}
|
|
64929
65195
|
if (resolved.autoSelected) {
|
|
64930
|
-
process.stderr.write(
|
|
65196
|
+
process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
64931
65197
|
`));
|
|
64932
65198
|
}
|
|
64933
65199
|
const { profile, name: profileName } = resolved;
|
|
64934
|
-
const
|
|
65200
|
+
const jsonMode3 = opts.json === true;
|
|
64935
65201
|
const outcome = await callWithAutoRelogin({
|
|
64936
65202
|
profile,
|
|
64937
65203
|
profileName,
|
|
64938
|
-
jsonMode:
|
|
64939
|
-
ttyHeader:
|
|
65204
|
+
jsonMode: jsonMode3,
|
|
65205
|
+
ttyHeader: import_picocolors13.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
64940
65206
|
fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
|
|
64941
65207
|
});
|
|
64942
65208
|
if (outcome.kind === "auth_failed") {
|
|
64943
|
-
if (
|
|
65209
|
+
if (jsonMode3) {
|
|
64944
65210
|
process.stdout.write(
|
|
64945
65211
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
64946
65212
|
);
|
|
64947
65213
|
process.exit(1);
|
|
64948
65214
|
}
|
|
64949
|
-
process.stderr.write(
|
|
65215
|
+
process.stderr.write(import_picocolors13.default.red(`\u2715 ${outcome.reason}.
|
|
64950
65216
|
`));
|
|
64951
65217
|
process.exit(1);
|
|
64952
65218
|
}
|
|
@@ -64954,11 +65220,11 @@ async function status(intentId, opts) {
|
|
|
64954
65220
|
const err = outcome.error;
|
|
64955
65221
|
if (err instanceof ApiError) {
|
|
64956
65222
|
if (err.status === 404) {
|
|
64957
|
-
process.stderr.write(
|
|
65223
|
+
process.stderr.write(import_picocolors13.default.red(`\u2715 No intent with id ${intentId}.
|
|
64958
65224
|
`));
|
|
64959
65225
|
process.exit(1);
|
|
64960
65226
|
}
|
|
64961
|
-
process.stderr.write(
|
|
65227
|
+
process.stderr.write(import_picocolors13.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
64962
65228
|
`));
|
|
64963
65229
|
process.exit(1);
|
|
64964
65230
|
}
|
|
@@ -64967,9 +65233,9 @@ async function status(intentId, opts) {
|
|
|
64967
65233
|
let snap = outcome.result;
|
|
64968
65234
|
let activeProfile = outcome.profile;
|
|
64969
65235
|
if (opts.watch && !isTerminalStatus(snap.status)) {
|
|
64970
|
-
if (!
|
|
65236
|
+
if (!jsonMode3) {
|
|
64971
65237
|
printSnap(snap);
|
|
64972
|
-
process.stdout.write(
|
|
65238
|
+
process.stdout.write(import_picocolors13.default.dim("Watching\u2026\n"));
|
|
64973
65239
|
}
|
|
64974
65240
|
const runWatchPoll = (p) => streamStatusUntilTerminal({
|
|
64975
65241
|
intentId,
|
|
@@ -64979,8 +65245,8 @@ async function status(intentId, opts) {
|
|
|
64979
65245
|
intervalMs: 0,
|
|
64980
65246
|
giveUpMs: WATCH_GIVEUP_MS,
|
|
64981
65247
|
onTick: (s) => {
|
|
64982
|
-
if (!
|
|
64983
|
-
process.stdout.write(` ${
|
|
65248
|
+
if (!jsonMode3) {
|
|
65249
|
+
process.stdout.write(` ${import_picocolors13.default.dim("\u2192")} ${s.status}
|
|
64984
65250
|
`);
|
|
64985
65251
|
}
|
|
64986
65252
|
}
|
|
@@ -64993,12 +65259,12 @@ async function status(intentId, opts) {
|
|
|
64993
65259
|
try {
|
|
64994
65260
|
activeProfile = await runLoginFlow({
|
|
64995
65261
|
profile: profileName,
|
|
64996
|
-
jsonMode:
|
|
65262
|
+
jsonMode: jsonMode3,
|
|
64997
65263
|
origin: activeProfile.mcpOrigin,
|
|
64998
|
-
ttyHeader:
|
|
65264
|
+
ttyHeader: import_picocolors13.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
|
|
64999
65265
|
});
|
|
65000
65266
|
} catch (reloginErr) {
|
|
65001
|
-
if (
|
|
65267
|
+
if (jsonMode3) {
|
|
65002
65268
|
process.stdout.write(
|
|
65003
65269
|
JSON.stringify({
|
|
65004
65270
|
ok: false,
|
|
@@ -65009,7 +65275,7 @@ async function status(intentId, opts) {
|
|
|
65009
65275
|
process.exit(1);
|
|
65010
65276
|
}
|
|
65011
65277
|
process.stderr.write(
|
|
65012
|
-
|
|
65278
|
+
import_picocolors13.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65013
65279
|
`)
|
|
65014
65280
|
);
|
|
65015
65281
|
process.exit(1);
|
|
@@ -65017,24 +65283,24 @@ async function status(intentId, opts) {
|
|
|
65017
65283
|
try {
|
|
65018
65284
|
final = await runWatchPoll(activeProfile);
|
|
65019
65285
|
} catch (retryErr) {
|
|
65020
|
-
process.stderr.write(
|
|
65286
|
+
process.stderr.write(import_picocolors13.default.red(`\u2715 ${retryErr.message}
|
|
65021
65287
|
`));
|
|
65022
65288
|
process.exit(1);
|
|
65023
65289
|
}
|
|
65024
65290
|
} else {
|
|
65025
|
-
process.stderr.write(
|
|
65291
|
+
process.stderr.write(import_picocolors13.default.red(`\u2715 ${err.message}
|
|
65026
65292
|
`));
|
|
65027
65293
|
process.exit(1);
|
|
65028
65294
|
}
|
|
65029
65295
|
}
|
|
65030
|
-
if (
|
|
65296
|
+
if (jsonMode3) {
|
|
65031
65297
|
process.stdout.write(JSON.stringify(final, null, 2) + "\n");
|
|
65032
65298
|
} else {
|
|
65033
65299
|
printSnap(final);
|
|
65034
65300
|
}
|
|
65035
65301
|
process.exit(final.status === "mined" ? 0 : 1);
|
|
65036
65302
|
}
|
|
65037
|
-
if (
|
|
65303
|
+
if (jsonMode3) {
|
|
65038
65304
|
process.stdout.write(JSON.stringify(snap, null, 2) + "\n");
|
|
65039
65305
|
process.exit(snap.status === "mined" ? 0 : 0);
|
|
65040
65306
|
}
|
|
@@ -65043,7 +65309,7 @@ async function status(intentId, opts) {
|
|
|
65043
65309
|
}
|
|
65044
65310
|
function printSnap(s) {
|
|
65045
65311
|
const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
|
|
65046
|
-
const colorFn = s.status === "mined" ?
|
|
65312
|
+
const colorFn = s.status === "mined" ? import_picocolors13.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors13.default.red : import_picocolors13.default.cyan;
|
|
65047
65313
|
process.stdout.write(`Intent ${s.approval_id}
|
|
65048
65314
|
`);
|
|
65049
65315
|
process.stdout.write(`Status ${colorFn(s.status)}
|
|
@@ -65058,12 +65324,12 @@ function printSnap(s) {
|
|
|
65058
65324
|
process.stdout.write(`Tx ${s.tx_hash}
|
|
65059
65325
|
`);
|
|
65060
65326
|
if (explorer) {
|
|
65061
|
-
process.stdout.write(`Explorer ${
|
|
65327
|
+
process.stdout.write(`Explorer ${import_picocolors13.default.cyan(explorer)}
|
|
65062
65328
|
`);
|
|
65063
65329
|
}
|
|
65064
65330
|
}
|
|
65065
65331
|
if (!isTerminalStatus(s.status)) {
|
|
65066
|
-
process.stdout.write(`Approve ${
|
|
65332
|
+
process.stdout.write(`Approve ${import_picocolors13.default.cyan(s.approval_url)}
|
|
65067
65333
|
`);
|
|
65068
65334
|
}
|
|
65069
65335
|
process.stdout.write(`Created ${formatDate2(s.created_at)}
|
|
@@ -65080,7 +65346,7 @@ function formatDate2(iso) {
|
|
|
65080
65346
|
}
|
|
65081
65347
|
|
|
65082
65348
|
// src/commands/balance.ts
|
|
65083
|
-
var
|
|
65349
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
65084
65350
|
var CHAIN_ALIASES = {
|
|
65085
65351
|
"1": 1,
|
|
65086
65352
|
ethereum: 1,
|
|
@@ -65103,11 +65369,11 @@ async function balance(opts) {
|
|
|
65103
65369
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65104
65370
|
const resolved = await resolveProfile(requested);
|
|
65105
65371
|
if (!resolved) {
|
|
65106
|
-
process.stderr.write(
|
|
65372
|
+
process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65107
65373
|
process.exit(2);
|
|
65108
65374
|
}
|
|
65109
65375
|
if (resolved.autoSelected) {
|
|
65110
|
-
process.stderr.write(
|
|
65376
|
+
process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65111
65377
|
`));
|
|
65112
65378
|
}
|
|
65113
65379
|
const { profile, name: profileName } = resolved;
|
|
@@ -65117,8 +65383,8 @@ async function balance(opts) {
|
|
|
65117
65383
|
const id2 = CHAIN_ALIASES[key];
|
|
65118
65384
|
if (id2 === void 0) {
|
|
65119
65385
|
process.stderr.write(
|
|
65120
|
-
|
|
65121
|
-
`\u2715 Unknown chain ${
|
|
65386
|
+
import_picocolors14.default.red(
|
|
65387
|
+
`\u2715 Unknown chain ${import_picocolors14.default.bold(opts.chain)}. Supported: ${import_picocolors14.default.bold("1/ethereum")}, ${import_picocolors14.default.bold("137/polygon")}, ${import_picocolors14.default.bold("8453/base")}, ${import_picocolors14.default.bold("42161/arbitrum")}, ${import_picocolors14.default.bold("900/solana")}.
|
|
65122
65388
|
`
|
|
65123
65389
|
)
|
|
65124
65390
|
);
|
|
@@ -65126,29 +65392,29 @@ async function balance(opts) {
|
|
|
65126
65392
|
}
|
|
65127
65393
|
chainFilter = id2;
|
|
65128
65394
|
}
|
|
65129
|
-
const
|
|
65395
|
+
const jsonMode3 = opts.json === true;
|
|
65130
65396
|
const outcome = await callWithAutoRelogin({
|
|
65131
65397
|
profile,
|
|
65132
65398
|
profileName,
|
|
65133
|
-
jsonMode:
|
|
65134
|
-
ttyHeader:
|
|
65399
|
+
jsonMode: jsonMode3,
|
|
65400
|
+
ttyHeader: import_picocolors14.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
65135
65401
|
fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
|
|
65136
65402
|
});
|
|
65137
65403
|
if (outcome.kind === "auth_failed") {
|
|
65138
|
-
if (
|
|
65404
|
+
if (jsonMode3) {
|
|
65139
65405
|
process.stdout.write(
|
|
65140
65406
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
65141
65407
|
);
|
|
65142
65408
|
process.exit(1);
|
|
65143
65409
|
}
|
|
65144
|
-
process.stderr.write(
|
|
65410
|
+
process.stderr.write(import_picocolors14.default.red(`\u2715 ${outcome.reason}.
|
|
65145
65411
|
`));
|
|
65146
65412
|
process.exit(1);
|
|
65147
65413
|
}
|
|
65148
65414
|
if (outcome.kind === "error") {
|
|
65149
65415
|
const err = outcome.error;
|
|
65150
65416
|
if (err instanceof ApiError) {
|
|
65151
|
-
process.stderr.write(
|
|
65417
|
+
process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65152
65418
|
`));
|
|
65153
65419
|
process.exit(1);
|
|
65154
65420
|
}
|
|
@@ -65156,7 +65422,7 @@ async function balance(opts) {
|
|
|
65156
65422
|
}
|
|
65157
65423
|
const res = outcome.result;
|
|
65158
65424
|
const filtered = chainFilter !== null ? res.chains.filter((c) => c.chainId === chainFilter) : res.chains;
|
|
65159
|
-
if (
|
|
65425
|
+
if (jsonMode3) {
|
|
65160
65426
|
process.stdout.write(
|
|
65161
65427
|
JSON.stringify(
|
|
65162
65428
|
chainFilter !== null ? { ...res, chains: filtered } : res,
|
|
@@ -65178,7 +65444,7 @@ async function balance(opts) {
|
|
|
65178
65444
|
}
|
|
65179
65445
|
if (filtered.length === 0) {
|
|
65180
65446
|
process.stdout.write(
|
|
65181
|
-
|
|
65447
|
+
import_picocolors14.default.dim(
|
|
65182
65448
|
chainFilter !== null ? `No balances on chain ${chainFilter}.
|
|
65183
65449
|
` : `No chain balances returned.
|
|
65184
65450
|
`
|
|
@@ -65190,7 +65456,7 @@ async function balance(opts) {
|
|
|
65190
65456
|
const errorLines = [];
|
|
65191
65457
|
for (const c of filtered) {
|
|
65192
65458
|
if (c.error) {
|
|
65193
|
-
errorLines.push(`${c.chainName} ${
|
|
65459
|
+
errorLines.push(`${c.chainName} ${import_picocolors14.default.red(`(read failed: ${c.error})`)}`);
|
|
65194
65460
|
continue;
|
|
65195
65461
|
}
|
|
65196
65462
|
if (c.native.balance > 0) {
|
|
@@ -65211,7 +65477,7 @@ async function balance(opts) {
|
|
|
65211
65477
|
}
|
|
65212
65478
|
}
|
|
65213
65479
|
if (rows.length === 0 && errorLines.length === 0) {
|
|
65214
|
-
process.stdout.write(
|
|
65480
|
+
process.stdout.write(import_picocolors14.default.dim(`All balances are zero.
|
|
65215
65481
|
`));
|
|
65216
65482
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
65217
65483
|
return;
|
|
@@ -65221,7 +65487,7 @@ async function balance(opts) {
|
|
|
65221
65487
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
65222
65488
|
const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
|
|
65223
65489
|
const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
|
|
65224
|
-
process.stdout.write(
|
|
65490
|
+
process.stdout.write(import_picocolors14.default.dim(header) + "\n");
|
|
65225
65491
|
for (const r of rows) {
|
|
65226
65492
|
process.stdout.write(
|
|
65227
65493
|
r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
|
|
@@ -65234,7 +65500,7 @@ async function balance(opts) {
|
|
|
65234
65500
|
`);
|
|
65235
65501
|
}
|
|
65236
65502
|
if (res.fetched_at) {
|
|
65237
|
-
process.stdout.write("\n" +
|
|
65503
|
+
process.stdout.write("\n" + import_picocolors14.default.dim(`Fetched ${res.fetched_at}
|
|
65238
65504
|
`));
|
|
65239
65505
|
}
|
|
65240
65506
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -65247,18 +65513,18 @@ function formatBalance(value, decimals) {
|
|
|
65247
65513
|
}
|
|
65248
65514
|
|
|
65249
65515
|
// src/commands/history.ts
|
|
65250
|
-
var
|
|
65516
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
65251
65517
|
var DEFAULT_LIMIT = 20;
|
|
65252
65518
|
var SERVER_MAX_LIMIT = 100;
|
|
65253
65519
|
async function history(opts) {
|
|
65254
65520
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65255
65521
|
const resolved = await resolveProfile(requested);
|
|
65256
65522
|
if (!resolved) {
|
|
65257
|
-
process.stderr.write(
|
|
65523
|
+
process.stderr.write(import_picocolors15.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65258
65524
|
process.exit(2);
|
|
65259
65525
|
}
|
|
65260
65526
|
if (resolved.autoSelected) {
|
|
65261
|
-
process.stderr.write(
|
|
65527
|
+
process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65262
65528
|
`));
|
|
65263
65529
|
}
|
|
65264
65530
|
const { profile, name: profileName } = resolved;
|
|
@@ -65267,14 +65533,14 @@ async function history(opts) {
|
|
|
65267
65533
|
const n2 = Number(opts.limit);
|
|
65268
65534
|
if (!Number.isFinite(n2) || n2 <= 0 || !Number.isInteger(n2)) {
|
|
65269
65535
|
process.stderr.write(
|
|
65270
|
-
|
|
65536
|
+
import_picocolors15.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors15.default.bold(opts.limit)}).
|
|
65271
65537
|
`)
|
|
65272
65538
|
);
|
|
65273
65539
|
process.exit(2);
|
|
65274
65540
|
}
|
|
65275
65541
|
if (n2 > SERVER_MAX_LIMIT) {
|
|
65276
65542
|
process.stderr.write(
|
|
65277
|
-
|
|
65543
|
+
import_picocolors15.default.red(
|
|
65278
65544
|
`\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n2}.
|
|
65279
65545
|
`
|
|
65280
65546
|
)
|
|
@@ -65283,39 +65549,39 @@ async function history(opts) {
|
|
|
65283
65549
|
}
|
|
65284
65550
|
limit = n2;
|
|
65285
65551
|
}
|
|
65286
|
-
const
|
|
65552
|
+
const jsonMode3 = opts.json === true;
|
|
65287
65553
|
const outcome = await callWithAutoRelogin({
|
|
65288
65554
|
profile,
|
|
65289
65555
|
profileName,
|
|
65290
|
-
jsonMode:
|
|
65291
|
-
ttyHeader:
|
|
65556
|
+
jsonMode: jsonMode3,
|
|
65557
|
+
ttyHeader: import_picocolors15.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
65292
65558
|
fn: (bearer, origin) => apiFetch(
|
|
65293
65559
|
`/api/history?limit=${encodeURIComponent(String(limit))}`,
|
|
65294
65560
|
{ bearer, origin }
|
|
65295
65561
|
)
|
|
65296
65562
|
});
|
|
65297
65563
|
if (outcome.kind === "auth_failed") {
|
|
65298
|
-
if (
|
|
65564
|
+
if (jsonMode3) {
|
|
65299
65565
|
process.stdout.write(
|
|
65300
65566
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
65301
65567
|
);
|
|
65302
65568
|
process.exit(1);
|
|
65303
65569
|
}
|
|
65304
|
-
process.stderr.write(
|
|
65570
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${outcome.reason}.
|
|
65305
65571
|
`));
|
|
65306
65572
|
process.exit(1);
|
|
65307
65573
|
}
|
|
65308
65574
|
if (outcome.kind === "error") {
|
|
65309
65575
|
const err = outcome.error;
|
|
65310
65576
|
if (err instanceof ApiError) {
|
|
65311
|
-
process.stderr.write(
|
|
65577
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65312
65578
|
`));
|
|
65313
65579
|
process.exit(1);
|
|
65314
65580
|
}
|
|
65315
65581
|
throw err;
|
|
65316
65582
|
}
|
|
65317
65583
|
const res = outcome.result;
|
|
65318
|
-
if (
|
|
65584
|
+
if (jsonMode3) {
|
|
65319
65585
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
65320
65586
|
return;
|
|
65321
65587
|
}
|
|
@@ -65325,7 +65591,7 @@ async function history(opts) {
|
|
|
65325
65591
|
return;
|
|
65326
65592
|
}
|
|
65327
65593
|
if (res.txs.length === 0) {
|
|
65328
|
-
process.stdout.write(
|
|
65594
|
+
process.stdout.write(import_picocolors15.default.dim(`No activity yet.
|
|
65329
65595
|
`));
|
|
65330
65596
|
return;
|
|
65331
65597
|
}
|
|
@@ -65345,7 +65611,7 @@ async function history(opts) {
|
|
|
65345
65611
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
65346
65612
|
const colTo = Math.max(2, ...rows.map((r) => r.to.length));
|
|
65347
65613
|
const header = "When".padEnd(colWhen) + " " + "Chain".padEnd(colChain) + " " + "Type".padEnd(colType) + " " + "Amount".padStart(colAmount) + " " + "Asset".padEnd(colAsset) + " " + "To".padEnd(colTo) + " Hash";
|
|
65348
|
-
process.stdout.write(
|
|
65614
|
+
process.stdout.write(import_picocolors15.default.dim(header) + "\n");
|
|
65349
65615
|
for (const r of rows) {
|
|
65350
65616
|
process.stdout.write(
|
|
65351
65617
|
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"
|
|
@@ -65353,7 +65619,7 @@ async function history(opts) {
|
|
|
65353
65619
|
}
|
|
65354
65620
|
if (res.fetched_at) {
|
|
65355
65621
|
process.stdout.write(
|
|
65356
|
-
"\n" +
|
|
65622
|
+
"\n" + import_picocolors15.default.dim(
|
|
65357
65623
|
`Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
|
|
65358
65624
|
`
|
|
65359
65625
|
)
|
|
@@ -65403,7 +65669,7 @@ function chainIdLabel(id2) {
|
|
|
65403
65669
|
return `chain ${id2}`;
|
|
65404
65670
|
}
|
|
65405
65671
|
}
|
|
65406
|
-
function prettyType(activityType,
|
|
65672
|
+
function prettyType(activityType, status3) {
|
|
65407
65673
|
const base = (() => {
|
|
65408
65674
|
switch (activityType) {
|
|
65409
65675
|
case "received":
|
|
@@ -65433,17 +65699,17 @@ function prettyType(activityType, status2) {
|
|
|
65433
65699
|
return activityType;
|
|
65434
65700
|
}
|
|
65435
65701
|
})();
|
|
65436
|
-
if (
|
|
65437
|
-
return `${base} \xB7 ${
|
|
65702
|
+
if (status3 && status3 !== "confirmed" && status3 !== "complete") {
|
|
65703
|
+
return `${base} \xB7 ${status3}`;
|
|
65438
65704
|
}
|
|
65439
65705
|
return base;
|
|
65440
65706
|
}
|
|
65441
65707
|
|
|
65442
65708
|
// src/commands/swap.ts
|
|
65443
|
-
var
|
|
65709
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
65444
65710
|
|
|
65445
65711
|
// src/lib/intent-flow.ts
|
|
65446
|
-
var
|
|
65712
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
65447
65713
|
var STREAM_GIVEUP_MS = 10 * 6e4;
|
|
65448
65714
|
var SOLANA_CHAIN_ID2 = 900;
|
|
65449
65715
|
function isBlocked2(r) {
|
|
@@ -65518,7 +65784,7 @@ async function runIntentFlow(opts) {
|
|
|
65518
65784
|
profile: opts.profileName,
|
|
65519
65785
|
jsonMode: opts.jsonMode,
|
|
65520
65786
|
origin: activeProfile.mcpOrigin,
|
|
65521
|
-
ttyHeader:
|
|
65787
|
+
ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
65522
65788
|
});
|
|
65523
65789
|
} catch (reloginErr) {
|
|
65524
65790
|
if (opts.jsonMode) {
|
|
@@ -65530,7 +65796,7 @@ async function runIntentFlow(opts) {
|
|
|
65530
65796
|
process.exit(1);
|
|
65531
65797
|
}
|
|
65532
65798
|
process.stderr.write(
|
|
65533
|
-
|
|
65799
|
+
import_picocolors16.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65534
65800
|
`)
|
|
65535
65801
|
);
|
|
65536
65802
|
process.exit(1);
|
|
@@ -65554,7 +65820,7 @@ async function runIntentFlow(opts) {
|
|
|
65554
65820
|
process.exit(1);
|
|
65555
65821
|
}
|
|
65556
65822
|
process.stderr.write(
|
|
65557
|
-
|
|
65823
|
+
import_picocolors16.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
65558
65824
|
`)
|
|
65559
65825
|
);
|
|
65560
65826
|
process.exit(1);
|
|
@@ -65571,7 +65837,7 @@ async function runIntentFlow(opts) {
|
|
|
65571
65837
|
});
|
|
65572
65838
|
process.exit(1);
|
|
65573
65839
|
}
|
|
65574
|
-
process.stderr.write(
|
|
65840
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65575
65841
|
`));
|
|
65576
65842
|
process.exit(1);
|
|
65577
65843
|
} else {
|
|
@@ -65593,18 +65859,18 @@ async function runIntentFlow(opts) {
|
|
|
65593
65859
|
});
|
|
65594
65860
|
process.exit(1);
|
|
65595
65861
|
}
|
|
65596
|
-
process.stderr.write(
|
|
65862
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
|
|
65597
65863
|
`));
|
|
65598
65864
|
if (proposed.upgrade_url) {
|
|
65599
65865
|
process.stderr.write(
|
|
65600
65866
|
` Open this to grant access, then re-run the command:
|
|
65601
|
-
${
|
|
65867
|
+
${import_picocolors16.default.cyan(proposed.upgrade_url)}
|
|
65602
65868
|
`
|
|
65603
65869
|
);
|
|
65604
65870
|
}
|
|
65605
65871
|
if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
|
|
65606
65872
|
process.stderr.write(
|
|
65607
|
-
|
|
65873
|
+
import_picocolors16.default.dim(
|
|
65608
65874
|
` Suggested actions:
|
|
65609
65875
|
` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
|
|
65610
65876
|
)
|
|
@@ -65627,8 +65893,8 @@ async function runIntentFlow(opts) {
|
|
|
65627
65893
|
} else {
|
|
65628
65894
|
process.stdout.write(
|
|
65629
65895
|
`
|
|
65630
|
-
${
|
|
65631
|
-
${
|
|
65896
|
+
${import_picocolors16.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
65897
|
+
${import_picocolors16.default.cyan(proposed.approval_url)}
|
|
65632
65898
|
|
|
65633
65899
|
`
|
|
65634
65900
|
);
|
|
@@ -65650,7 +65916,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65650
65916
|
if (opts.jsonMode) {
|
|
65651
65917
|
emitNdjson2({ status: s.status, intent_id: s.approval_id });
|
|
65652
65918
|
} else {
|
|
65653
|
-
process.stdout.write(` ${describeStatus2(s.status)}${
|
|
65919
|
+
process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors16.default.dim("\u2026")}\r`);
|
|
65654
65920
|
}
|
|
65655
65921
|
}
|
|
65656
65922
|
});
|
|
@@ -65664,7 +65930,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65664
65930
|
profile: opts.profileName,
|
|
65665
65931
|
jsonMode: opts.jsonMode,
|
|
65666
65932
|
origin: activeProfile.mcpOrigin,
|
|
65667
|
-
ttyHeader:
|
|
65933
|
+
ttyHeader: import_picocolors16.default.dim(
|
|
65668
65934
|
"Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
|
|
65669
65935
|
)
|
|
65670
65936
|
});
|
|
@@ -65679,7 +65945,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65679
65945
|
process.exit(1);
|
|
65680
65946
|
}
|
|
65681
65947
|
process.stderr.write(
|
|
65682
|
-
"\n" +
|
|
65948
|
+
"\n" + import_picocolors16.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65683
65949
|
`)
|
|
65684
65950
|
);
|
|
65685
65951
|
process.exit(1);
|
|
@@ -65697,7 +65963,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65697
65963
|
process.exit(1);
|
|
65698
65964
|
}
|
|
65699
65965
|
process.stderr.write(
|
|
65700
|
-
"\n" +
|
|
65966
|
+
"\n" + import_picocolors16.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
65701
65967
|
`)
|
|
65702
65968
|
);
|
|
65703
65969
|
process.exit(1);
|
|
@@ -65713,7 +65979,7 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65713
65979
|
process.exit(1);
|
|
65714
65980
|
}
|
|
65715
65981
|
process.stderr.write(
|
|
65716
|
-
"\n" +
|
|
65982
|
+
"\n" + import_picocolors16.default.red(`\u2715 Status poll failed: ${err.message}
|
|
65717
65983
|
`)
|
|
65718
65984
|
);
|
|
65719
65985
|
process.exit(1);
|
|
@@ -65754,39 +66020,39 @@ ${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65754
66020
|
process.stdout.write("\n");
|
|
65755
66021
|
const printLegJournal = () => {
|
|
65756
66022
|
if (legs.length === 0) return;
|
|
65757
|
-
process.stdout.write(
|
|
66023
|
+
process.stdout.write(import_picocolors16.default.bold(" Legs:\n"));
|
|
65758
66024
|
for (const l of legs) {
|
|
65759
|
-
const line = l.status === "mined" ?
|
|
66025
|
+
const line = l.status === "mined" ? import_picocolors16.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors16.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors16.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors16.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors16.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
|
|
65760
66026
|
process.stdout.write(` ${line}
|
|
65761
66027
|
`);
|
|
65762
66028
|
}
|
|
65763
66029
|
};
|
|
65764
66030
|
if (final.status === "mined") {
|
|
65765
|
-
process.stdout.write(
|
|
66031
|
+
process.stdout.write(import_picocolors16.default.green("\u2713 Mined.") + "\n");
|
|
65766
66032
|
if (final.tx_hash) {
|
|
65767
66033
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
65768
66034
|
`);
|
|
65769
66035
|
}
|
|
65770
66036
|
if (explorer) {
|
|
65771
|
-
process.stdout.write(` Explorer ${
|
|
66037
|
+
process.stdout.write(` Explorer ${import_picocolors16.default.cyan(explorer)}
|
|
65772
66038
|
`);
|
|
65773
66039
|
}
|
|
65774
66040
|
printLegJournal();
|
|
65775
66041
|
process.exit(0);
|
|
65776
66042
|
}
|
|
65777
66043
|
if (final.status === "failed" && failure?.message) {
|
|
65778
|
-
process.stderr.write(
|
|
66044
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${failure.message}
|
|
65779
66045
|
`));
|
|
65780
66046
|
if (retryCommand) {
|
|
65781
66047
|
process.stderr.write(` Retry:
|
|
65782
|
-
${
|
|
66048
|
+
${import_picocolors16.default.cyan(retryCommand)}
|
|
65783
66049
|
`);
|
|
65784
66050
|
}
|
|
65785
66051
|
printLegJournal();
|
|
65786
66052
|
process.exit(1);
|
|
65787
66053
|
}
|
|
65788
66054
|
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. Re-run the command to retry with fresh parameters" : `Ended in unexpected status: ${final.status}`;
|
|
65789
|
-
process.stderr.write(
|
|
66055
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${label}.
|
|
65790
66056
|
`));
|
|
65791
66057
|
printLegJournal();
|
|
65792
66058
|
process.exit(1);
|
|
@@ -65806,7 +66072,7 @@ function isAsset(v) {
|
|
|
65806
66072
|
return ASSET_VALUES.has(v.toLowerCase());
|
|
65807
66073
|
}
|
|
65808
66074
|
function failArg(msg) {
|
|
65809
|
-
process.stderr.write(
|
|
66075
|
+
process.stderr.write(import_picocolors17.default.red(`\u2715 ${msg}
|
|
65810
66076
|
`));
|
|
65811
66077
|
process.exit(2);
|
|
65812
66078
|
}
|
|
@@ -65814,24 +66080,24 @@ async function swap(amount, fromAsset, opts) {
|
|
|
65814
66080
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65815
66081
|
const resolved = await resolveProfile(requested);
|
|
65816
66082
|
if (!resolved) {
|
|
65817
|
-
process.stderr.write(
|
|
66083
|
+
process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65818
66084
|
process.exit(2);
|
|
65819
66085
|
}
|
|
65820
66086
|
if (resolved.autoSelected) {
|
|
65821
|
-
process.stderr.write(
|
|
66087
|
+
process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65822
66088
|
`));
|
|
65823
66089
|
}
|
|
65824
66090
|
const { profile, name: profileName } = resolved;
|
|
65825
66091
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
65826
|
-
const
|
|
66092
|
+
const jsonMode3 = opts.json === true || !stdoutIsTty;
|
|
65827
66093
|
const amountNumber = Number(amount);
|
|
65828
66094
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
65829
|
-
failArg(`amount must be a positive number (got ${
|
|
66095
|
+
failArg(`amount must be a positive number (got ${import_picocolors17.default.bold(amount)}).`);
|
|
65830
66096
|
}
|
|
65831
66097
|
const fromAssetNorm = fromAsset.toLowerCase();
|
|
65832
66098
|
if (!isAsset(fromAssetNorm)) {
|
|
65833
66099
|
failArg(
|
|
65834
|
-
`from-asset must be ${
|
|
66100
|
+
`from-asset must be ${import_picocolors17.default.bold("native")} or ${import_picocolors17.default.bold("usdc")} (got ${import_picocolors17.default.bold(fromAsset)}).`
|
|
65835
66101
|
);
|
|
65836
66102
|
}
|
|
65837
66103
|
if (!opts.toAsset) {
|
|
@@ -65840,7 +66106,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
65840
66106
|
const toAssetNorm = opts.toAsset.toLowerCase();
|
|
65841
66107
|
if (!isAsset(toAssetNorm)) {
|
|
65842
66108
|
failArg(
|
|
65843
|
-
`--to-asset must be ${
|
|
66109
|
+
`--to-asset must be ${import_picocolors17.default.bold("native")} or ${import_picocolors17.default.bold("usdc")} (got ${import_picocolors17.default.bold(opts.toAsset)}).`
|
|
65844
66110
|
);
|
|
65845
66111
|
}
|
|
65846
66112
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -65962,16 +66228,16 @@ async function swap(amount, fromAsset, opts) {
|
|
|
65962
66228
|
body: proposeBody,
|
|
65963
66229
|
profileName,
|
|
65964
66230
|
initialProfile: profile,
|
|
65965
|
-
jsonMode:
|
|
66231
|
+
jsonMode: jsonMode3,
|
|
65966
66232
|
shouldOpenBrowser,
|
|
65967
66233
|
buildRetryCommand
|
|
65968
66234
|
});
|
|
65969
66235
|
}
|
|
65970
66236
|
|
|
65971
66237
|
// src/commands/batch.ts
|
|
65972
|
-
var
|
|
66238
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
65973
66239
|
function failArg2(msg) {
|
|
65974
|
-
process.stderr.write(
|
|
66240
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${msg}
|
|
65975
66241
|
`));
|
|
65976
66242
|
process.exit(2);
|
|
65977
66243
|
}
|
|
@@ -65979,11 +66245,11 @@ async function batch(opts) {
|
|
|
65979
66245
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65980
66246
|
const resolved = await resolveProfile(requested);
|
|
65981
66247
|
if (!resolved) {
|
|
65982
|
-
process.stderr.write(
|
|
66248
|
+
process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65983
66249
|
process.exit(2);
|
|
65984
66250
|
}
|
|
65985
66251
|
const { name: profileName, profile } = resolved;
|
|
65986
|
-
const
|
|
66252
|
+
const jsonMode3 = opts.json === true || !process.stdout.isTTY;
|
|
65987
66253
|
let legs;
|
|
65988
66254
|
try {
|
|
65989
66255
|
legs = JSON.parse(opts.legsJson);
|
|
@@ -66027,20 +66293,20 @@ async function batch(opts) {
|
|
|
66027
66293
|
},
|
|
66028
66294
|
profileName,
|
|
66029
66295
|
initialProfile: profile,
|
|
66030
|
-
jsonMode:
|
|
66296
|
+
jsonMode: jsonMode3,
|
|
66031
66297
|
shouldOpenBrowser
|
|
66032
66298
|
});
|
|
66033
66299
|
}
|
|
66034
66300
|
|
|
66035
66301
|
// src/commands/fund-wallet.ts
|
|
66036
|
-
var
|
|
66302
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
66037
66303
|
var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
|
|
66038
66304
|
var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
66039
66305
|
function isAddressTarget(target) {
|
|
66040
66306
|
return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
|
|
66041
66307
|
}
|
|
66042
66308
|
function failArg3(msg) {
|
|
66043
|
-
process.stderr.write(
|
|
66309
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${msg}
|
|
66044
66310
|
`));
|
|
66045
66311
|
process.exit(2);
|
|
66046
66312
|
}
|
|
@@ -66048,11 +66314,11 @@ async function fundWallet(address, opts) {
|
|
|
66048
66314
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66049
66315
|
const resolved = await resolveProfile(requested);
|
|
66050
66316
|
if (!resolved) {
|
|
66051
|
-
process.stderr.write(
|
|
66317
|
+
process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66052
66318
|
process.exit(2);
|
|
66053
66319
|
}
|
|
66054
66320
|
const { name: profileName, profile } = resolved;
|
|
66055
|
-
const
|
|
66321
|
+
const jsonMode3 = opts.json === true || !process.stdout.isTTY;
|
|
66056
66322
|
if (!opts.chain) {
|
|
66057
66323
|
failArg3("--chain is required (1/137/8453/42161/900 or shortName).");
|
|
66058
66324
|
}
|
|
@@ -66104,7 +66370,7 @@ async function fundWallet(address, opts) {
|
|
|
66104
66370
|
},
|
|
66105
66371
|
profileName,
|
|
66106
66372
|
initialProfile: profile,
|
|
66107
|
-
jsonMode:
|
|
66373
|
+
jsonMode: jsonMode3,
|
|
66108
66374
|
shouldOpenBrowser
|
|
66109
66375
|
});
|
|
66110
66376
|
}
|
|
@@ -66119,17 +66385,17 @@ async function fundWallet(address, opts) {
|
|
|
66119
66385
|
},
|
|
66120
66386
|
profileName,
|
|
66121
66387
|
initialProfile: profile,
|
|
66122
|
-
jsonMode:
|
|
66388
|
+
jsonMode: jsonMode3,
|
|
66123
66389
|
shouldOpenBrowser
|
|
66124
66390
|
});
|
|
66125
66391
|
}
|
|
66126
66392
|
|
|
66127
66393
|
// src/commands/earn-supply.ts
|
|
66128
|
-
var
|
|
66394
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
66129
66395
|
var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
66130
66396
|
var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
66131
66397
|
function failArg4(msg) {
|
|
66132
|
-
process.stderr.write(
|
|
66398
|
+
process.stderr.write(import_picocolors20.default.red(`\u2715 ${msg}
|
|
66133
66399
|
`));
|
|
66134
66400
|
process.exit(2);
|
|
66135
66401
|
}
|
|
@@ -66137,24 +66403,24 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66137
66403
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66138
66404
|
const resolved = await resolveProfile(requested);
|
|
66139
66405
|
if (!resolved) {
|
|
66140
|
-
process.stderr.write(
|
|
66406
|
+
process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66141
66407
|
process.exit(2);
|
|
66142
66408
|
}
|
|
66143
66409
|
if (resolved.autoSelected) {
|
|
66144
|
-
process.stderr.write(
|
|
66410
|
+
process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66145
66411
|
`));
|
|
66146
66412
|
}
|
|
66147
66413
|
const { profile, name: profileName } = resolved;
|
|
66148
66414
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
66149
|
-
const
|
|
66415
|
+
const jsonMode3 = opts.json === true || !stdoutIsTty;
|
|
66150
66416
|
const amountNumber = Number(amount);
|
|
66151
66417
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
66152
|
-
failArg4(`amount must be a positive number (got ${
|
|
66418
|
+
failArg4(`amount must be a positive number (got ${import_picocolors20.default.bold(amount)}).`);
|
|
66153
66419
|
}
|
|
66154
66420
|
const assetNorm = asset.toLowerCase();
|
|
66155
66421
|
if (!ASSET_VALUES2.has(assetNorm)) {
|
|
66156
66422
|
failArg4(
|
|
66157
|
-
`asset must be ${
|
|
66423
|
+
`asset must be ${import_picocolors20.default.bold("native")} or ${import_picocolors20.default.bold("usdc")} (got ${import_picocolors20.default.bold(asset)}).`
|
|
66158
66424
|
);
|
|
66159
66425
|
}
|
|
66160
66426
|
if (!opts.chain) {
|
|
@@ -66166,7 +66432,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66166
66432
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
66167
66433
|
if (!PROTOCOLS.has(protocolNorm)) {
|
|
66168
66434
|
failArg4(
|
|
66169
|
-
`--protocol must be ${
|
|
66435
|
+
`--protocol must be ${import_picocolors20.default.bold("aave_v3")} or ${import_picocolors20.default.bold("kamino_lend")} (got ${import_picocolors20.default.bold(opts.protocol)}).`
|
|
66170
66436
|
);
|
|
66171
66437
|
}
|
|
66172
66438
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -66212,17 +66478,17 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66212
66478
|
body: proposeBody,
|
|
66213
66479
|
profileName,
|
|
66214
66480
|
initialProfile: profile,
|
|
66215
|
-
jsonMode:
|
|
66481
|
+
jsonMode: jsonMode3,
|
|
66216
66482
|
shouldOpenBrowser
|
|
66217
66483
|
});
|
|
66218
66484
|
}
|
|
66219
66485
|
|
|
66220
66486
|
// src/commands/earn-withdraw.ts
|
|
66221
|
-
var
|
|
66487
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
66222
66488
|
var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
66223
66489
|
var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
66224
66490
|
function failArg5(msg) {
|
|
66225
|
-
process.stderr.write(
|
|
66491
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${msg}
|
|
66226
66492
|
`));
|
|
66227
66493
|
process.exit(2);
|
|
66228
66494
|
}
|
|
@@ -66230,29 +66496,29 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
66230
66496
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66231
66497
|
const resolved = await resolveProfile(requested);
|
|
66232
66498
|
if (!resolved) {
|
|
66233
|
-
process.stderr.write(
|
|
66499
|
+
process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66234
66500
|
process.exit(2);
|
|
66235
66501
|
}
|
|
66236
66502
|
if (resolved.autoSelected) {
|
|
66237
|
-
process.stderr.write(
|
|
66503
|
+
process.stderr.write(import_picocolors21.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66238
66504
|
`));
|
|
66239
66505
|
}
|
|
66240
66506
|
const { profile, name: profileName } = resolved;
|
|
66241
66507
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
66242
|
-
const
|
|
66508
|
+
const jsonMode3 = opts.json === true || !stdoutIsTty;
|
|
66243
66509
|
const isMax = amountOrMax.toLowerCase() === "max";
|
|
66244
66510
|
if (!isMax) {
|
|
66245
66511
|
const amountNumber = Number(amountOrMax);
|
|
66246
66512
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
66247
66513
|
failArg5(
|
|
66248
|
-
`<amount-or-max> must be a positive number or the literal string "max" (got ${
|
|
66514
|
+
`<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors21.default.bold(amountOrMax)}).`
|
|
66249
66515
|
);
|
|
66250
66516
|
}
|
|
66251
66517
|
}
|
|
66252
66518
|
const assetNorm = asset.toLowerCase();
|
|
66253
66519
|
if (!ASSET_VALUES3.has(assetNorm)) {
|
|
66254
66520
|
failArg5(
|
|
66255
|
-
`asset must be ${
|
|
66521
|
+
`asset must be ${import_picocolors21.default.bold("native")} or ${import_picocolors21.default.bold("usdc")} (got ${import_picocolors21.default.bold(asset)}).`
|
|
66256
66522
|
);
|
|
66257
66523
|
}
|
|
66258
66524
|
if (!opts.chain) {
|
|
@@ -66264,7 +66530,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
66264
66530
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
66265
66531
|
if (!PROTOCOLS2.has(protocolNorm)) {
|
|
66266
66532
|
failArg5(
|
|
66267
|
-
`--protocol must be ${
|
|
66533
|
+
`--protocol must be ${import_picocolors21.default.bold("aave_v3")} or ${import_picocolors21.default.bold("kamino_lend")} (got ${import_picocolors21.default.bold(opts.protocol)}).`
|
|
66268
66534
|
);
|
|
66269
66535
|
}
|
|
66270
66536
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -66310,13 +66576,13 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
66310
66576
|
body: proposeBody,
|
|
66311
66577
|
profileName,
|
|
66312
66578
|
initialProfile: profile,
|
|
66313
|
-
jsonMode:
|
|
66579
|
+
jsonMode: jsonMode3,
|
|
66314
66580
|
shouldOpenBrowser
|
|
66315
66581
|
});
|
|
66316
66582
|
}
|
|
66317
66583
|
|
|
66318
66584
|
// src/commands/eat.ts
|
|
66319
|
-
var
|
|
66585
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
66320
66586
|
function parseLineJson(values) {
|
|
66321
66587
|
const lines = [];
|
|
66322
66588
|
for (const value of values) {
|
|
@@ -66343,27 +66609,27 @@ function parseLineJson(values) {
|
|
|
66343
66609
|
async function loadResolvedProfile(requested) {
|
|
66344
66610
|
const resolved = await resolveProfile(requested);
|
|
66345
66611
|
if (!resolved) {
|
|
66346
|
-
process.stderr.write(
|
|
66612
|
+
process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66347
66613
|
process.exit(2);
|
|
66348
66614
|
}
|
|
66349
66615
|
if (resolved.autoSelected) {
|
|
66350
|
-
process.stderr.write(
|
|
66616
|
+
process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66351
66617
|
`));
|
|
66352
66618
|
}
|
|
66353
66619
|
return resolved;
|
|
66354
66620
|
}
|
|
66355
|
-
function printResult(res,
|
|
66356
|
-
if (
|
|
66621
|
+
function printResult(res, jsonMode3) {
|
|
66622
|
+
if (jsonMode3) {
|
|
66357
66623
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
66358
66624
|
return;
|
|
66359
66625
|
}
|
|
66360
66626
|
if (res.blocked) {
|
|
66361
|
-
process.stderr.write(
|
|
66627
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
|
|
66362
66628
|
`));
|
|
66363
66629
|
if (res.upgrade_url) {
|
|
66364
66630
|
process.stderr.write(
|
|
66365
66631
|
` Open this to grant access, then re-run the command:
|
|
66366
|
-
${
|
|
66632
|
+
${import_picocolors22.default.cyan(res.upgrade_url)}
|
|
66367
66633
|
`
|
|
66368
66634
|
);
|
|
66369
66635
|
}
|
|
@@ -66389,35 +66655,35 @@ async function postRestaurantQuiet(path6, body, resolved) {
|
|
|
66389
66655
|
return null;
|
|
66390
66656
|
}
|
|
66391
66657
|
}
|
|
66392
|
-
async function postRestaurant(path6, body, resolved,
|
|
66658
|
+
async function postRestaurant(path6, body, resolved, jsonMode3) {
|
|
66393
66659
|
const outcome = await callWithAutoRelogin({
|
|
66394
66660
|
profile: resolved.profile,
|
|
66395
66661
|
profileName: resolved.name,
|
|
66396
|
-
jsonMode:
|
|
66397
|
-
ttyHeader:
|
|
66662
|
+
jsonMode: jsonMode3,
|
|
66663
|
+
ttyHeader: import_picocolors22.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
66398
66664
|
fn: (bearer, origin) => apiFetch(path6, { method: "POST", bearer, origin, body })
|
|
66399
66665
|
});
|
|
66400
66666
|
if (outcome.kind === "auth_failed") {
|
|
66401
|
-
if (
|
|
66667
|
+
if (jsonMode3) {
|
|
66402
66668
|
process.stdout.write(
|
|
66403
66669
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
66404
66670
|
);
|
|
66405
66671
|
process.exit(1);
|
|
66406
66672
|
}
|
|
66407
|
-
process.stderr.write(
|
|
66673
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${outcome.reason}.
|
|
66408
66674
|
`));
|
|
66409
66675
|
process.exit(1);
|
|
66410
66676
|
}
|
|
66411
66677
|
if (outcome.kind === "error") {
|
|
66412
66678
|
const err = outcome.error;
|
|
66413
66679
|
if (err instanceof ApiError) {
|
|
66414
|
-
if (
|
|
66680
|
+
if (jsonMode3) {
|
|
66415
66681
|
process.stdout.write(
|
|
66416
66682
|
JSON.stringify({ ok: false, status: "request_failed", error: err.message, http_status: err.status }) + "\n"
|
|
66417
66683
|
);
|
|
66418
66684
|
process.exit(1);
|
|
66419
66685
|
}
|
|
66420
|
-
process.stderr.write(
|
|
66686
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
66421
66687
|
`));
|
|
66422
66688
|
process.exit(1);
|
|
66423
66689
|
}
|
|
@@ -66427,10 +66693,10 @@ async function postRestaurant(path6, body, resolved, jsonMode2) {
|
|
|
66427
66693
|
}
|
|
66428
66694
|
async function searchFood(opts) {
|
|
66429
66695
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
66430
|
-
const
|
|
66696
|
+
const jsonMode3 = opts.json === true || process.stdout.isTTY !== true;
|
|
66431
66697
|
if (!opts.location && !opts.name) {
|
|
66432
66698
|
process.stderr.write(
|
|
66433
|
-
|
|
66699
|
+
import_picocolors22.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
|
|
66434
66700
|
);
|
|
66435
66701
|
process.exit(2);
|
|
66436
66702
|
}
|
|
@@ -66443,15 +66709,15 @@ async function searchFood(opts) {
|
|
|
66443
66709
|
if (opts.radiusMiles !== void 0) body.radius_miles = Number(opts.radiusMiles);
|
|
66444
66710
|
if (opts.openOnly !== void 0) body.open_only = opts.openOnly;
|
|
66445
66711
|
if (opts.limit !== void 0) body.limit = Number(opts.limit);
|
|
66446
|
-
const result = await postRestaurant("/api/restaurants/search", body, resolved,
|
|
66447
|
-
if (result) printResult(result,
|
|
66712
|
+
const result = await postRestaurant("/api/restaurants/search", body, resolved, jsonMode3);
|
|
66713
|
+
if (result) printResult(result, jsonMode3);
|
|
66448
66714
|
}
|
|
66449
66715
|
async function menuFood(items, opts) {
|
|
66450
66716
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
66451
|
-
const
|
|
66717
|
+
const jsonMode3 = opts.json === true || process.stdout.isTTY !== true;
|
|
66452
66718
|
if (!opts.brand || !opts.address) {
|
|
66453
66719
|
process.stderr.write(
|
|
66454
|
-
|
|
66720
|
+
import_picocolors22.default.red(
|
|
66455
66721
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
66456
66722
|
)
|
|
66457
66723
|
);
|
|
@@ -66463,15 +66729,15 @@ async function menuFood(items, opts) {
|
|
|
66463
66729
|
intent: opts.intent,
|
|
66464
66730
|
items: items ?? []
|
|
66465
66731
|
};
|
|
66466
|
-
const result = await postRestaurant("/api/restaurants/menu", body, resolved,
|
|
66467
|
-
if (result) printResult(result,
|
|
66732
|
+
const result = await postRestaurant("/api/restaurants/menu", body, resolved, jsonMode3);
|
|
66733
|
+
if (result) printResult(result, jsonMode3);
|
|
66468
66734
|
}
|
|
66469
66735
|
async function orderFood(items, opts) {
|
|
66470
66736
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
66471
|
-
const
|
|
66737
|
+
const jsonMode3 = opts.json === true || process.stdout.isTTY !== true;
|
|
66472
66738
|
if (!opts.brand || !opts.address) {
|
|
66473
66739
|
process.stderr.write(
|
|
66474
|
-
|
|
66740
|
+
import_picocolors22.default.red(
|
|
66475
66741
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
66476
66742
|
)
|
|
66477
66743
|
);
|
|
@@ -66481,14 +66747,14 @@ async function orderFood(items, opts) {
|
|
|
66481
66747
|
try {
|
|
66482
66748
|
structuredLines = parseLineJson(opts.lineJson ?? []);
|
|
66483
66749
|
} catch (e) {
|
|
66484
|
-
process.stderr.write(
|
|
66750
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
|
|
66485
66751
|
`));
|
|
66486
66752
|
process.exit(2);
|
|
66487
66753
|
}
|
|
66488
66754
|
const lines = [...items ?? [], ...structuredLines];
|
|
66489
66755
|
if (lines.length === 0) {
|
|
66490
66756
|
process.stderr.write(
|
|
66491
|
-
|
|
66757
|
+
import_picocolors22.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")
|
|
66492
66758
|
);
|
|
66493
66759
|
process.exit(2);
|
|
66494
66760
|
}
|
|
@@ -66499,9 +66765,9 @@ async function orderFood(items, opts) {
|
|
|
66499
66765
|
fulfillment: opts.fulfillment,
|
|
66500
66766
|
intent: opts.intent
|
|
66501
66767
|
};
|
|
66502
|
-
const result = await postRestaurant("/api/restaurants/order", body, resolved,
|
|
66768
|
+
const result = await postRestaurant("/api/restaurants/order", body, resolved, jsonMode3);
|
|
66503
66769
|
if (!result) return;
|
|
66504
|
-
printResult(result,
|
|
66770
|
+
printResult(result, jsonMode3);
|
|
66505
66771
|
const approvalUrl = typeof result.approval_url === "string" ? result.approval_url : null;
|
|
66506
66772
|
const browserAllowed = (() => {
|
|
66507
66773
|
if (opts.browserMode === "open") return true;
|
|
@@ -66520,9 +66786,9 @@ async function orderFood(items, opts) {
|
|
|
66520
66786
|
return;
|
|
66521
66787
|
}
|
|
66522
66788
|
if (!agentCard.will_attempt) {
|
|
66523
|
-
if (!
|
|
66789
|
+
if (!jsonMode3) {
|
|
66524
66790
|
process.stderr.write(
|
|
66525
|
-
|
|
66791
|
+
import_picocolors22.default.yellow(
|
|
66526
66792
|
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
66527
66793
|
`
|
|
66528
66794
|
)
|
|
@@ -66531,15 +66797,15 @@ async function orderFood(items, opts) {
|
|
|
66531
66797
|
openApproval();
|
|
66532
66798
|
return;
|
|
66533
66799
|
}
|
|
66534
|
-
const verdict = await pollOrderVerdict(orderId, resolved,
|
|
66535
|
-
if (
|
|
66800
|
+
const verdict = await pollOrderVerdict(orderId, resolved, jsonMode3);
|
|
66801
|
+
if (jsonMode3) {
|
|
66536
66802
|
process.stdout.write(JSON.stringify(verdict) + "\n");
|
|
66537
66803
|
if (verdict.status === "failed") return;
|
|
66538
66804
|
return;
|
|
66539
66805
|
}
|
|
66540
66806
|
if (verdict.status === "paid") {
|
|
66541
66807
|
process.stdout.write(
|
|
66542
|
-
|
|
66808
|
+
import_picocolors22.default.green(
|
|
66543
66809
|
`Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
|
|
66544
66810
|
)
|
|
66545
66811
|
);
|
|
@@ -66547,7 +66813,7 @@ async function orderFood(items, opts) {
|
|
|
66547
66813
|
}
|
|
66548
66814
|
if (verdict.status === "failed") {
|
|
66549
66815
|
process.stderr.write(
|
|
66550
|
-
|
|
66816
|
+
import_picocolors22.default.yellow(
|
|
66551
66817
|
`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.
|
|
66552
66818
|
`
|
|
66553
66819
|
)
|
|
@@ -66557,7 +66823,7 @@ async function orderFood(items, opts) {
|
|
|
66557
66823
|
}
|
|
66558
66824
|
if (verdict.status === "unconfirmed") {
|
|
66559
66825
|
process.stderr.write(
|
|
66560
|
-
|
|
66826
|
+
import_picocolors22.default.red(
|
|
66561
66827
|
"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}
|
|
66562
66828
|
` : "")
|
|
66563
66829
|
)
|
|
@@ -66566,7 +66832,7 @@ async function orderFood(items, opts) {
|
|
|
66566
66832
|
return;
|
|
66567
66833
|
}
|
|
66568
66834
|
process.stderr.write(
|
|
66569
|
-
|
|
66835
|
+
import_picocolors22.default.dim(
|
|
66570
66836
|
`Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
|
|
66571
66837
|
)
|
|
66572
66838
|
);
|
|
@@ -66589,9 +66855,9 @@ function fmtCents(cents) {
|
|
|
66589
66855
|
}
|
|
66590
66856
|
var POLL_BUDGET_MS = 1e5;
|
|
66591
66857
|
var POLL_INTERVAL_MS2 = 3500;
|
|
66592
|
-
async function pollOrderVerdict(orderId, resolved,
|
|
66593
|
-
if (!
|
|
66594
|
-
process.stderr.write(
|
|
66858
|
+
async function pollOrderVerdict(orderId, resolved, jsonMode3) {
|
|
66859
|
+
if (!jsonMode3) {
|
|
66860
|
+
process.stderr.write(import_picocolors22.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
|
|
66595
66861
|
}
|
|
66596
66862
|
const deadline = Date.now() + POLL_BUDGET_MS;
|
|
66597
66863
|
let last = {
|
|
@@ -66608,50 +66874,50 @@ async function pollOrderVerdict(orderId, resolved, jsonMode2) {
|
|
|
66608
66874
|
resolved
|
|
66609
66875
|
);
|
|
66610
66876
|
if (!res) break;
|
|
66611
|
-
const
|
|
66877
|
+
const status3 = typeof res.status === "string" ? res.status : "pending";
|
|
66612
66878
|
last = {
|
|
66613
66879
|
order_id: orderId,
|
|
66614
|
-
status:
|
|
66880
|
+
status: status3,
|
|
66615
66881
|
failure_reason: typeof res.failure_reason === "string" ? res.failure_reason : null,
|
|
66616
66882
|
failure_detail: typeof res.failure_detail === "string" ? res.failure_detail : null
|
|
66617
66883
|
};
|
|
66618
|
-
if (
|
|
66884
|
+
if (status3 !== "pending" && status3 !== "claimed") return last;
|
|
66619
66885
|
}
|
|
66620
66886
|
return last;
|
|
66621
66887
|
}
|
|
66622
66888
|
async function statusFood(orderId, opts) {
|
|
66623
66889
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
66624
|
-
const
|
|
66890
|
+
const jsonMode3 = opts.json === true || process.stdout.isTTY !== true;
|
|
66625
66891
|
const result = await postRestaurant(
|
|
66626
66892
|
"/api/restaurants/order-status",
|
|
66627
66893
|
{ order_id: orderId.trim() },
|
|
66628
66894
|
resolved,
|
|
66629
|
-
|
|
66895
|
+
jsonMode3
|
|
66630
66896
|
);
|
|
66631
66897
|
if (!result) return;
|
|
66632
66898
|
if (result.blocked) {
|
|
66633
|
-
printResult(result,
|
|
66899
|
+
printResult(result, jsonMode3);
|
|
66634
66900
|
return;
|
|
66635
66901
|
}
|
|
66636
|
-
if (
|
|
66902
|
+
if (jsonMode3) {
|
|
66637
66903
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
66638
66904
|
return;
|
|
66639
66905
|
}
|
|
66640
|
-
const
|
|
66641
|
-
const lines = [`${result.brand} \xB7 ${result.address} \u2014 ${
|
|
66642
|
-
if (
|
|
66906
|
+
const status3 = typeof result.status === "string" ? result.status : "unknown";
|
|
66907
|
+
const lines = [`${result.brand} \xB7 ${result.address} \u2014 ${status3}`];
|
|
66908
|
+
if (status3 === "paid") {
|
|
66643
66909
|
lines.push(`Paid.${result.failure_detail ? ` ${result.failure_detail}` : ""} Nothing to do.`);
|
|
66644
|
-
} else if (
|
|
66910
|
+
} else if (status3 === "failed") {
|
|
66645
66911
|
lines.push(
|
|
66646
66912
|
`Not charged (${result.failure_reason ?? "refused"}${result.failure_detail ? `: ${result.failure_detail}` : ""}). The checkout link still works if you want to pay yourself.`
|
|
66647
66913
|
);
|
|
66648
66914
|
if (typeof result.review_url === "string") lines.push(String(result.review_url));
|
|
66649
|
-
} else if (
|
|
66915
|
+
} else if (status3 === "unconfirmed") {
|
|
66650
66916
|
lines.push(
|
|
66651
66917
|
"A payment attempt happened and its outcome is UNKNOWN \u2014 nothing will retry it. Look at the order before paying anything:"
|
|
66652
66918
|
);
|
|
66653
66919
|
if (typeof result.review_url === "string") lines.push(String(result.review_url));
|
|
66654
|
-
} else if (
|
|
66920
|
+
} else if (status3 === "expired") {
|
|
66655
66921
|
lines.push("These prices went stale before anyone paid. Ask again for a fresh order.");
|
|
66656
66922
|
} else {
|
|
66657
66923
|
lines.push("Waiting to be paid.");
|
|
@@ -66661,40 +66927,40 @@ async function statusFood(orderId, opts) {
|
|
|
66661
66927
|
}
|
|
66662
66928
|
|
|
66663
66929
|
// src/commands/bounties.ts
|
|
66664
|
-
var
|
|
66930
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
66665
66931
|
async function withProfile(opts, path6, init2) {
|
|
66666
66932
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66667
66933
|
const resolved = await resolveProfile(requested);
|
|
66668
66934
|
if (!resolved) {
|
|
66669
|
-
process.stderr.write(
|
|
66935
|
+
process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66670
66936
|
process.exit(2);
|
|
66671
66937
|
}
|
|
66672
66938
|
if (resolved.autoSelected) {
|
|
66673
|
-
process.stderr.write(
|
|
66939
|
+
process.stderr.write(import_picocolors23.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66674
66940
|
`));
|
|
66675
66941
|
}
|
|
66676
66942
|
const { profile, name: profileName } = resolved;
|
|
66677
|
-
const
|
|
66943
|
+
const jsonMode3 = opts.json === true;
|
|
66678
66944
|
const outcome = await callWithAutoRelogin({
|
|
66679
66945
|
profile,
|
|
66680
66946
|
profileName,
|
|
66681
|
-
jsonMode:
|
|
66682
|
-
ttyHeader:
|
|
66947
|
+
jsonMode: jsonMode3,
|
|
66948
|
+
ttyHeader: import_picocolors23.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
66683
66949
|
fn: (bearer, origin) => apiFetch(path6, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
|
|
66684
66950
|
});
|
|
66685
66951
|
if (outcome.kind === "auth_failed") {
|
|
66686
|
-
if (
|
|
66952
|
+
if (jsonMode3) {
|
|
66687
66953
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
66688
66954
|
process.exit(1);
|
|
66689
66955
|
}
|
|
66690
|
-
process.stderr.write(
|
|
66956
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${outcome.reason}.
|
|
66691
66957
|
`));
|
|
66692
66958
|
process.exit(1);
|
|
66693
66959
|
}
|
|
66694
66960
|
if (outcome.kind === "error") {
|
|
66695
66961
|
const err = outcome.error;
|
|
66696
66962
|
if (err instanceof ApiError) {
|
|
66697
|
-
process.stderr.write(
|
|
66963
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
66698
66964
|
`));
|
|
66699
66965
|
process.exit(1);
|
|
66700
66966
|
}
|
|
@@ -66702,18 +66968,18 @@ async function withProfile(opts, path6, init2) {
|
|
|
66702
66968
|
}
|
|
66703
66969
|
return outcome.result;
|
|
66704
66970
|
}
|
|
66705
|
-
function handleBlocked(res,
|
|
66971
|
+
function handleBlocked(res, jsonMode3) {
|
|
66706
66972
|
if (!res.blocked) return false;
|
|
66707
|
-
if (
|
|
66973
|
+
if (jsonMode3) {
|
|
66708
66974
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
66709
66975
|
process.exit(1);
|
|
66710
66976
|
}
|
|
66711
|
-
process.stderr.write(
|
|
66977
|
+
process.stderr.write(import_picocolors23.default.yellow(`
|
|
66712
66978
|
${res.reason ?? "Blocked."}
|
|
66713
66979
|
`));
|
|
66714
66980
|
if (res.upgrade_url) {
|
|
66715
66981
|
process.stderr.write(`
|
|
66716
|
-
${
|
|
66982
|
+
${import_picocolors23.default.bold(res.upgrade_url)}
|
|
66717
66983
|
|
|
66718
66984
|
`);
|
|
66719
66985
|
}
|
|
@@ -66756,30 +67022,30 @@ function printTable(rows) {
|
|
|
66756
67022
|
const cLeft = w("left", 4);
|
|
66757
67023
|
const cSubs = w("subs", 4);
|
|
66758
67024
|
process.stdout.write(
|
|
66759
|
-
|
|
67025
|
+
import_picocolors23.default.dim(
|
|
66760
67026
|
"Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
|
|
66761
67027
|
) + "\n"
|
|
66762
67028
|
);
|
|
66763
67029
|
for (const c of cells) {
|
|
66764
|
-
const title = c.live ?
|
|
67030
|
+
const title = c.live ? import_picocolors23.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
|
|
66765
67031
|
process.stdout.write(
|
|
66766
|
-
|
|
67032
|
+
import_picocolors23.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors23.default.dim(c.id) + "\n"
|
|
66767
67033
|
);
|
|
66768
67034
|
}
|
|
66769
67035
|
}
|
|
66770
67036
|
async function listBounties(opts) {
|
|
66771
|
-
const
|
|
67037
|
+
const jsonMode3 = opts.json === true;
|
|
66772
67038
|
const res = await withProfile(opts, "/api/bounties");
|
|
66773
|
-
handleBlocked(res,
|
|
67039
|
+
handleBlocked(res, jsonMode3);
|
|
66774
67040
|
let rows = res.bounties ?? [];
|
|
66775
67041
|
const min = opts.min !== void 0 ? Number(opts.min) : void 0;
|
|
66776
67042
|
const max = opts.max !== void 0 ? Number(opts.max) : void 0;
|
|
66777
67043
|
if (min !== void 0 && !Number.isFinite(min)) {
|
|
66778
|
-
process.stderr.write(
|
|
67044
|
+
process.stderr.write(import_picocolors23.default.red("\u2715 --min must be a number.\n"));
|
|
66779
67045
|
process.exit(2);
|
|
66780
67046
|
}
|
|
66781
67047
|
if (max !== void 0 && !Number.isFinite(max)) {
|
|
66782
|
-
process.stderr.write(
|
|
67048
|
+
process.stderr.write(import_picocolors23.default.red("\u2715 --max must be a number.\n"));
|
|
66783
67049
|
process.exit(2);
|
|
66784
67050
|
}
|
|
66785
67051
|
rows = rows.filter((r) => {
|
|
@@ -66804,22 +67070,22 @@ async function listBounties(opts) {
|
|
|
66804
67070
|
});
|
|
66805
67071
|
const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
|
|
66806
67072
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
66807
|
-
process.stderr.write(
|
|
67073
|
+
process.stderr.write(import_picocolors23.default.red("\u2715 --limit must be a positive number.\n"));
|
|
66808
67074
|
process.exit(2);
|
|
66809
67075
|
}
|
|
66810
67076
|
const shown2 = rows.slice(0, limit);
|
|
66811
|
-
if (
|
|
67077
|
+
if (jsonMode3) {
|
|
66812
67078
|
process.stdout.write(JSON.stringify({ bounties: shown2, matched: rows.length }, null, 2) + "\n");
|
|
66813
67079
|
return;
|
|
66814
67080
|
}
|
|
66815
67081
|
if (shown2.length === 0) {
|
|
66816
|
-
process.stdout.write(
|
|
67082
|
+
process.stdout.write(import_picocolors23.default.dim("No active bounties match.\n"));
|
|
66817
67083
|
return;
|
|
66818
67084
|
}
|
|
66819
67085
|
printTable(shown2);
|
|
66820
67086
|
const clipped = rows.length - shown2.length;
|
|
66821
67087
|
process.stdout.write(
|
|
66822
|
-
"\n" +
|
|
67088
|
+
"\n" + import_picocolors23.default.dim(
|
|
66823
67089
|
`${shown2.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
|
|
66824
67090
|
`
|
|
66825
67091
|
)
|
|
@@ -66827,59 +67093,59 @@ async function listBounties(opts) {
|
|
|
66827
67093
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
66828
67094
|
}
|
|
66829
67095
|
async function showBounty(id2, opts) {
|
|
66830
|
-
const
|
|
67096
|
+
const jsonMode3 = opts.json === true;
|
|
66831
67097
|
const clean = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
|
|
66832
67098
|
if (!clean) {
|
|
66833
|
-
process.stderr.write(
|
|
67099
|
+
process.stderr.write(import_picocolors23.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
|
|
66834
67100
|
process.exit(2);
|
|
66835
67101
|
}
|
|
66836
67102
|
const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean)}`);
|
|
66837
|
-
handleBlocked(res,
|
|
66838
|
-
if (
|
|
67103
|
+
handleBlocked(res, jsonMode3);
|
|
67104
|
+
if (jsonMode3) {
|
|
66839
67105
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
66840
67106
|
return;
|
|
66841
67107
|
}
|
|
66842
67108
|
const b2 = res.bounty;
|
|
66843
67109
|
if (!b2) {
|
|
66844
|
-
process.stdout.write(
|
|
67110
|
+
process.stdout.write(import_picocolors23.default.dim("Not found.\n"));
|
|
66845
67111
|
return;
|
|
66846
67112
|
}
|
|
66847
|
-
process.stdout.write("\n" +
|
|
67113
|
+
process.stdout.write("\n" + import_picocolors23.default.bold(b2.title) + "\n\n");
|
|
66848
67114
|
process.stdout.write(b2.description + "\n\n");
|
|
66849
67115
|
process.stdout.write(
|
|
66850
|
-
|
|
67116
|
+
import_picocolors23.default.bold(fmtAmount(b2.amount)) + import_picocolors23.default.dim(" USDC") + import_picocolors23.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors23.default.green(" \xB7 LIVE now") : "") + "\n"
|
|
66851
67117
|
);
|
|
66852
67118
|
if (b2.claimsAllowed && b2.claimsAllowed > 1) {
|
|
66853
67119
|
const left = Math.max(0, b2.claimsAllowed - (b2.claimsPaid ?? 0));
|
|
66854
67120
|
process.stdout.write(
|
|
66855
|
-
|
|
67121
|
+
import_picocolors23.default.dim(
|
|
66856
67122
|
`${left} of ${b2.claimsAllowed} claims left` + (b2.perClaimAmount != null ? `, ${fmtAmount(b2.perClaimAmount)} each` : "")
|
|
66857
67123
|
) + "\n"
|
|
66858
67124
|
);
|
|
66859
67125
|
}
|
|
66860
|
-
if (b2.evidenceType) process.stdout.write(
|
|
66861
|
-
if (b2.expiresAt) process.stdout.write(
|
|
67126
|
+
if (b2.evidenceType) process.stdout.write(import_picocolors23.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
|
|
67127
|
+
if (b2.expiresAt) process.stdout.write(import_picocolors23.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
|
|
66862
67128
|
if (b2.geoLabel && b2.geoScope !== "global") {
|
|
66863
|
-
process.stdout.write(
|
|
67129
|
+
process.stdout.write(import_picocolors23.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
|
|
66864
67130
|
}
|
|
66865
67131
|
if (res.url) process.stdout.write("\n" + res.url + "\n");
|
|
66866
67132
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
66867
67133
|
}
|
|
66868
67134
|
async function myBounties(opts) {
|
|
66869
|
-
const
|
|
67135
|
+
const jsonMode3 = opts.json === true;
|
|
66870
67136
|
const res = await withProfile(opts, "/api/bounties?mine=1");
|
|
66871
|
-
handleBlocked(res,
|
|
67137
|
+
handleBlocked(res, jsonMode3);
|
|
66872
67138
|
const all = res.bounties ?? [];
|
|
66873
|
-
const
|
|
66874
|
-
const rows =
|
|
66875
|
-
if (
|
|
67139
|
+
const status3 = opts.status?.trim().toUpperCase();
|
|
67140
|
+
const rows = status3 ? all.filter((r) => (r.status ?? "").toUpperCase() === status3) : all;
|
|
67141
|
+
if (jsonMode3) {
|
|
66876
67142
|
process.stdout.write(JSON.stringify({ bounties: rows, submissions: res.submissions ?? [] }, null, 2) + "\n");
|
|
66877
67143
|
return;
|
|
66878
67144
|
}
|
|
66879
67145
|
if (rows.length === 0) {
|
|
66880
67146
|
process.stdout.write(
|
|
66881
|
-
|
|
66882
|
-
|
|
67147
|
+
import_picocolors23.default.dim(
|
|
67148
|
+
status3 ? `No bounties of yours are ${status3}.
|
|
66883
67149
|
` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
|
|
66884
67150
|
)
|
|
66885
67151
|
);
|
|
@@ -66888,38 +67154,38 @@ async function myBounties(opts) {
|
|
|
66888
67154
|
printTable(rows);
|
|
66889
67155
|
const subs = res.submissions ?? [];
|
|
66890
67156
|
if (subs.length > 0) {
|
|
66891
|
-
process.stdout.write("\n" +
|
|
67157
|
+
process.stdout.write("\n" + import_picocolors23.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
|
|
66892
67158
|
`));
|
|
66893
67159
|
}
|
|
66894
67160
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
66895
67161
|
}
|
|
66896
67162
|
async function bountyFeed(opts) {
|
|
66897
|
-
const
|
|
67163
|
+
const jsonMode3 = opts.json === true;
|
|
66898
67164
|
const params = new URLSearchParams();
|
|
66899
67165
|
if (opts.limit) params.set("limit", opts.limit);
|
|
66900
67166
|
if (opts.type) params.set("type", opts.type);
|
|
66901
67167
|
const qs = params.toString();
|
|
66902
67168
|
const res = await withProfile(opts, `/api/bounties/feed${qs ? `?${qs}` : ""}`);
|
|
66903
|
-
handleBlocked(res,
|
|
66904
|
-
if (
|
|
67169
|
+
handleBlocked(res, jsonMode3);
|
|
67170
|
+
if (jsonMode3) {
|
|
66905
67171
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
66906
67172
|
return;
|
|
66907
67173
|
}
|
|
66908
67174
|
const subs = res.submissions ?? [];
|
|
66909
67175
|
if (subs.length === 0) {
|
|
66910
|
-
process.stdout.write(
|
|
67176
|
+
process.stdout.write(import_picocolors23.default.dim("Nothing in the feed for that filter.\n"));
|
|
66911
67177
|
return;
|
|
66912
67178
|
}
|
|
66913
67179
|
process.stdout.write(
|
|
66914
|
-
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ?
|
|
67180
|
+
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors23.default.dim(" More available.") : "") + "\n"
|
|
66915
67181
|
);
|
|
66916
|
-
process.stdout.write(
|
|
67182
|
+
process.stdout.write(import_picocolors23.default.dim("Use --json for the full rows.\n"));
|
|
66917
67183
|
}
|
|
66918
67184
|
async function draftBounty(opts) {
|
|
66919
|
-
const
|
|
67185
|
+
const jsonMode3 = opts.json === true;
|
|
66920
67186
|
const amountNum = Number(opts.amount);
|
|
66921
67187
|
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
66922
|
-
process.stderr.write(
|
|
67188
|
+
process.stderr.write(import_picocolors23.default.red("\u2715 --amount must be a positive number of USDC.\n"));
|
|
66923
67189
|
process.exit(2);
|
|
66924
67190
|
}
|
|
66925
67191
|
const res = await withProfile(opts, "/api/bounties", {
|
|
@@ -66932,42 +67198,42 @@ async function draftBounty(opts) {
|
|
|
66932
67198
|
evidenceType: opts.evidenceType
|
|
66933
67199
|
}
|
|
66934
67200
|
});
|
|
66935
|
-
handleBlocked(res,
|
|
66936
|
-
if (
|
|
67201
|
+
handleBlocked(res, jsonMode3);
|
|
67202
|
+
if (jsonMode3) {
|
|
66937
67203
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
66938
67204
|
return;
|
|
66939
67205
|
}
|
|
66940
|
-
process.stdout.write("\n" +
|
|
67206
|
+
process.stdout.write("\n" + import_picocolors23.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
|
|
66941
67207
|
|
|
66942
67208
|
`);
|
|
66943
|
-
process.stdout.write(
|
|
67209
|
+
process.stdout.write(import_picocolors23.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
|
|
66944
67210
|
if (res.fund_url) {
|
|
66945
|
-
process.stdout.write("\nFund it here:\n" +
|
|
66946
|
-
process.stdout.write(
|
|
67211
|
+
process.stdout.write("\nFund it here:\n" + import_picocolors23.default.bold(res.fund_url) + "\n\n");
|
|
67212
|
+
process.stdout.write(import_picocolors23.default.dim("Funding happens in your browser with your own wallet.\n"));
|
|
66947
67213
|
}
|
|
66948
67214
|
}
|
|
66949
67215
|
|
|
66950
67216
|
// src/commands/bounty-money.ts
|
|
66951
|
-
var
|
|
67217
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
66952
67218
|
function failArg6(message) {
|
|
66953
|
-
process.stderr.write(
|
|
67219
|
+
process.stderr.write(import_picocolors24.default.red(`${message}
|
|
66954
67220
|
`));
|
|
66955
67221
|
process.exit(2);
|
|
66956
67222
|
}
|
|
66957
|
-
async function loadProfileOrExit(requested,
|
|
67223
|
+
async function loadProfileOrExit(requested, jsonMode3) {
|
|
66958
67224
|
const resolved = await resolveProfile(requested);
|
|
66959
67225
|
if (!resolved) {
|
|
66960
|
-
if (
|
|
67226
|
+
if (jsonMode3) {
|
|
66961
67227
|
process.stdout.write(
|
|
66962
67228
|
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
|
|
66963
67229
|
);
|
|
66964
67230
|
} else {
|
|
66965
|
-
process.stderr.write(
|
|
67231
|
+
process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66966
67232
|
}
|
|
66967
67233
|
process.exit(2);
|
|
66968
67234
|
}
|
|
66969
|
-
if (resolved.autoSelected && !
|
|
66970
|
-
process.stderr.write(
|
|
67235
|
+
if (resolved.autoSelected && !jsonMode3) {
|
|
67236
|
+
process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66971
67237
|
`));
|
|
66972
67238
|
}
|
|
66973
67239
|
return { profile: resolved.profile, profileName: resolved.name };
|
|
@@ -66986,8 +67252,8 @@ function resolveMaxUsd(opts, profile, fallbackHint) {
|
|
|
66986
67252
|
);
|
|
66987
67253
|
}
|
|
66988
67254
|
async function fundBounty(bountyId, opts) {
|
|
66989
|
-
const
|
|
66990
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
67255
|
+
const jsonMode3 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
67256
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode3);
|
|
66991
67257
|
const maxUsd = resolveMaxUsd(opts, profile, "agentgates fund");
|
|
66992
67258
|
return runIntentFlow({
|
|
66993
67259
|
endpoint: "/api/intents/propose-fund-bounty",
|
|
@@ -67006,17 +67272,17 @@ async function fundBounty(bountyId, opts) {
|
|
|
67006
67272
|
},
|
|
67007
67273
|
profileName,
|
|
67008
67274
|
initialProfile: profile,
|
|
67009
|
-
jsonMode:
|
|
67275
|
+
jsonMode: jsonMode3,
|
|
67010
67276
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
67011
67277
|
});
|
|
67012
67278
|
}
|
|
67013
67279
|
async function tipBounty(bountyId, amount, opts) {
|
|
67014
|
-
const
|
|
67280
|
+
const jsonMode3 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
67015
67281
|
const amt = Number(amount);
|
|
67016
67282
|
if (!Number.isFinite(amt) || amt <= 0) {
|
|
67017
67283
|
failArg6(`amount must be a positive USDC number (got ${amount}).`);
|
|
67018
67284
|
}
|
|
67019
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
67285
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode3);
|
|
67020
67286
|
const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "agentgates tip") : Math.ceil(amt * 1.01 * 100) / 100;
|
|
67021
67287
|
return runIntentFlow({
|
|
67022
67288
|
endpoint: "/api/intents/propose-tip",
|
|
@@ -67036,17 +67302,17 @@ async function tipBounty(bountyId, amount, opts) {
|
|
|
67036
67302
|
},
|
|
67037
67303
|
profileName,
|
|
67038
67304
|
initialProfile: profile,
|
|
67039
|
-
jsonMode:
|
|
67305
|
+
jsonMode: jsonMode3,
|
|
67040
67306
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
67041
67307
|
});
|
|
67042
67308
|
}
|
|
67043
67309
|
async function subscribeCreator(creatorUserId, opts) {
|
|
67044
|
-
const
|
|
67310
|
+
const jsonMode3 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
67045
67311
|
const months = opts.months === void 0 ? 1 : Number(opts.months);
|
|
67046
67312
|
if (![1, 3, 12].includes(months)) {
|
|
67047
67313
|
failArg6(`--months must be 1, 3 or 12 (got ${opts.months}). Prepaid periods only \u2014 no auto-renew exists.`);
|
|
67048
67314
|
}
|
|
67049
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
67315
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode3);
|
|
67050
67316
|
const maxUsd = resolveMaxUsd(opts, profile, "agentgates subscribe");
|
|
67051
67317
|
return runIntentFlow({
|
|
67052
67318
|
endpoint: "/api/intents/propose-subscribe",
|
|
@@ -67066,48 +67332,48 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
67066
67332
|
},
|
|
67067
67333
|
profileName,
|
|
67068
67334
|
initialProfile: profile,
|
|
67069
|
-
jsonMode:
|
|
67335
|
+
jsonMode: jsonMode3,
|
|
67070
67336
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
67071
67337
|
});
|
|
67072
67338
|
}
|
|
67073
67339
|
|
|
67074
67340
|
// src/commands/bounty-work.ts
|
|
67075
|
-
var
|
|
67341
|
+
var import_picocolors25 = __toESM(require_picocolors(), 1);
|
|
67076
67342
|
async function runWork(path6, body, opts) {
|
|
67077
67343
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67078
67344
|
const resolved = await resolveProfile(requested);
|
|
67079
67345
|
if (!resolved) {
|
|
67080
|
-
process.stderr.write(
|
|
67346
|
+
process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67081
67347
|
process.exit(2);
|
|
67082
67348
|
}
|
|
67083
67349
|
if (resolved.autoSelected) {
|
|
67084
|
-
process.stderr.write(
|
|
67350
|
+
process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67085
67351
|
`));
|
|
67086
67352
|
}
|
|
67087
|
-
const
|
|
67353
|
+
const jsonMode3 = opts.json === true;
|
|
67088
67354
|
const outcome = await callWithAutoRelogin({
|
|
67089
67355
|
profile: resolved.profile,
|
|
67090
67356
|
profileName: resolved.name,
|
|
67091
|
-
jsonMode:
|
|
67092
|
-
ttyHeader:
|
|
67357
|
+
jsonMode: jsonMode3,
|
|
67358
|
+
ttyHeader: import_picocolors25.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
67093
67359
|
fn: (bearer, origin) => apiFetch(path6, { bearer, origin, method: "POST", body })
|
|
67094
67360
|
});
|
|
67095
67361
|
if (outcome.kind === "auth_failed") {
|
|
67096
|
-
if (
|
|
67362
|
+
if (jsonMode3) {
|
|
67097
67363
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
67098
67364
|
process.exit(1);
|
|
67099
67365
|
}
|
|
67100
|
-
process.stderr.write(
|
|
67366
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${outcome.reason}.
|
|
67101
67367
|
`));
|
|
67102
67368
|
process.exit(1);
|
|
67103
67369
|
}
|
|
67104
67370
|
if (outcome.kind === "error") {
|
|
67105
67371
|
const err = outcome.error;
|
|
67106
67372
|
if (err instanceof ApiError) {
|
|
67107
|
-
if (
|
|
67373
|
+
if (jsonMode3) {
|
|
67108
67374
|
process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
|
|
67109
67375
|
} else {
|
|
67110
|
-
process.stderr.write(
|
|
67376
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
67111
67377
|
`));
|
|
67112
67378
|
}
|
|
67113
67379
|
process.exit(1);
|
|
@@ -67116,29 +67382,29 @@ async function runWork(path6, body, opts) {
|
|
|
67116
67382
|
}
|
|
67117
67383
|
const data4 = outcome.result;
|
|
67118
67384
|
if (data4.blocked) {
|
|
67119
|
-
if (
|
|
67385
|
+
if (jsonMode3) {
|
|
67120
67386
|
process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
|
|
67121
67387
|
process.exit(1);
|
|
67122
67388
|
}
|
|
67123
|
-
process.stderr.write(
|
|
67389
|
+
process.stderr.write(import_picocolors25.default.yellow(`
|
|
67124
67390
|
${data4.reason ?? "Blocked."}
|
|
67125
67391
|
`));
|
|
67126
67392
|
if (data4.upgrade_url) process.stderr.write(`
|
|
67127
|
-
${
|
|
67393
|
+
${import_picocolors25.default.bold(data4.upgrade_url)}
|
|
67128
67394
|
|
|
67129
67395
|
`);
|
|
67130
67396
|
process.exit(1);
|
|
67131
67397
|
}
|
|
67132
67398
|
if (typeof data4.error === "string" && data4.error) {
|
|
67133
|
-
if (
|
|
67399
|
+
if (jsonMode3) {
|
|
67134
67400
|
process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
|
|
67135
67401
|
} else {
|
|
67136
|
-
process.stderr.write(
|
|
67402
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${data4.error}
|
|
67137
67403
|
`));
|
|
67138
67404
|
}
|
|
67139
67405
|
process.exit(1);
|
|
67140
67406
|
}
|
|
67141
|
-
if (
|
|
67407
|
+
if (jsonMode3) {
|
|
67142
67408
|
process.stdout.write(JSON.stringify({ ok: true, ...data4 }) + "\n");
|
|
67143
67409
|
return;
|
|
67144
67410
|
}
|
|
@@ -67176,28 +67442,28 @@ async function bountyRetention(bountyId, opts) {
|
|
|
67176
67442
|
}
|
|
67177
67443
|
|
|
67178
67444
|
// src/commands/bounty-deliver.ts
|
|
67179
|
-
var
|
|
67445
|
+
var import_picocolors26 = __toESM(require_picocolors(), 1);
|
|
67180
67446
|
import { spawn } from "node:child_process";
|
|
67181
67447
|
var FLUSH_MS = 400;
|
|
67182
67448
|
var FLUSH_BYTES = 2048;
|
|
67183
67449
|
async function deliver(bountyId, command, opts) {
|
|
67184
|
-
const
|
|
67450
|
+
const jsonMode3 = opts.json === true;
|
|
67185
67451
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67186
67452
|
const resolved = await resolveProfile(requested);
|
|
67187
67453
|
if (!resolved) {
|
|
67188
|
-
process.stderr.write(
|
|
67454
|
+
process.stderr.write(import_picocolors26.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67189
67455
|
process.exit(2);
|
|
67190
67456
|
}
|
|
67191
|
-
if (resolved.autoSelected && !
|
|
67192
|
-
process.stderr.write(
|
|
67457
|
+
if (resolved.autoSelected && !jsonMode3) {
|
|
67458
|
+
process.stderr.write(import_picocolors26.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67193
67459
|
`));
|
|
67194
67460
|
}
|
|
67195
67461
|
const post = async (path6, body) => {
|
|
67196
67462
|
const outcome = await callWithAutoRelogin({
|
|
67197
67463
|
profile: resolved.profile,
|
|
67198
67464
|
profileName: resolved.name,
|
|
67199
|
-
jsonMode:
|
|
67200
|
-
ttyHeader:
|
|
67465
|
+
jsonMode: jsonMode3,
|
|
67466
|
+
ttyHeader: import_picocolors26.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
67201
67467
|
fn: (bearer, origin) => apiFetch(path6, { bearer, origin, method: "POST", body })
|
|
67202
67468
|
});
|
|
67203
67469
|
if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
|
|
@@ -67205,14 +67471,14 @@ async function deliver(bountyId, command, opts) {
|
|
|
67205
67471
|
return outcome.result;
|
|
67206
67472
|
};
|
|
67207
67473
|
const die = (msg, data4) => {
|
|
67208
|
-
if (
|
|
67474
|
+
if (jsonMode3) {
|
|
67209
67475
|
process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
|
|
67210
67476
|
} else {
|
|
67211
|
-
process.stderr.write(
|
|
67477
|
+
process.stderr.write(import_picocolors26.default.red(`
|
|
67212
67478
|
\u2715 ${msg}
|
|
67213
67479
|
`));
|
|
67214
67480
|
if (data4?.upgrade_url) process.stderr.write(`
|
|
67215
|
-
${
|
|
67481
|
+
${import_picocolors26.default.bold(data4.upgrade_url)}
|
|
67216
67482
|
|
|
67217
67483
|
`);
|
|
67218
67484
|
}
|
|
@@ -67235,9 +67501,9 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
|
|
|
67235
67501
|
if (started.error) return void die(started.error, started);
|
|
67236
67502
|
const runId = started.run_id;
|
|
67237
67503
|
if (!runId) return void die("The service opened a run but did not name it.");
|
|
67238
|
-
if (!
|
|
67504
|
+
if (!jsonMode3) {
|
|
67239
67505
|
process.stderr.write(
|
|
67240
|
-
|
|
67506
|
+
import_picocolors26.default.bold("\n\u25CF LIVE ") + import_picocolors26.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors26.default.dim(` ${started.url ?? ""}
|
|
67241
67507
|
|
|
67242
67508
|
`)
|
|
67243
67509
|
);
|
|
@@ -67266,7 +67532,7 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
|
|
|
67266
67532
|
const timer = setInterval(() => flush(true), FLUSH_MS);
|
|
67267
67533
|
const consume = (data4) => {
|
|
67268
67534
|
buffer += data4;
|
|
67269
|
-
if (!opts.quiet && !
|
|
67535
|
+
if (!opts.quiet && !jsonMode3) process.stderr.write(data4);
|
|
67270
67536
|
flush();
|
|
67271
67537
|
};
|
|
67272
67538
|
let exitCode = 0;
|
|
@@ -67289,10 +67555,10 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
|
|
|
67289
67555
|
child.stdout.on("data", (d) => consume(d));
|
|
67290
67556
|
child.stderr.setEncoding("utf8");
|
|
67291
67557
|
child.stderr.on("data", (d) => {
|
|
67292
|
-
if (!
|
|
67558
|
+
if (!jsonMode3) process.stderr.write(import_picocolors26.default.dim(d));
|
|
67293
67559
|
});
|
|
67294
67560
|
child.on("error", (err) => {
|
|
67295
|
-
process.stderr.write(
|
|
67561
|
+
process.stderr.write(import_picocolors26.default.red(`
|
|
67296
67562
|
\u2715 Could not run ${command[0]}: ${err.message}
|
|
67297
67563
|
`));
|
|
67298
67564
|
resolve2(127);
|
|
@@ -67314,7 +67580,7 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
|
|
|
67314
67580
|
}
|
|
67315
67581
|
if (finished.blocked) return void die(finished.reason ?? "Blocked.", finished);
|
|
67316
67582
|
if (finished.error) return void die(finished.error, finished);
|
|
67317
|
-
if (
|
|
67583
|
+
if (jsonMode3) {
|
|
67318
67584
|
process.stdout.write(
|
|
67319
67585
|
JSON.stringify({
|
|
67320
67586
|
ok: true,
|
|
@@ -67329,14 +67595,14 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
|
|
|
67329
67595
|
}
|
|
67330
67596
|
if (appendFailure) {
|
|
67331
67597
|
process.stderr.write(
|
|
67332
|
-
|
|
67598
|
+
import_picocolors26.default.yellow(`
|
|
67333
67599
|
! Some output did not reach the page: ${appendFailure}
|
|
67334
|
-
`) +
|
|
67600
|
+
`) + import_picocolors26.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
|
|
67335
67601
|
);
|
|
67336
67602
|
}
|
|
67337
67603
|
if (exitCode) {
|
|
67338
67604
|
process.stderr.write(
|
|
67339
|
-
|
|
67605
|
+
import_picocolors26.default.yellow(`
|
|
67340
67606
|
! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
|
|
67341
67607
|
`)
|
|
67342
67608
|
);
|
|
@@ -67346,7 +67612,7 @@ ${import_picocolors25.default.bold(data4.upgrade_url)}
|
|
|
67346
67612
|
}
|
|
67347
67613
|
|
|
67348
67614
|
// src/commands/trade.ts
|
|
67349
|
-
var
|
|
67615
|
+
var import_picocolors27 = __toESM(require_picocolors(), 1);
|
|
67350
67616
|
|
|
67351
67617
|
// src/lib/trade-sol.ts
|
|
67352
67618
|
var import_web3 = __toESM(require_index_cjs(), 1);
|
|
@@ -67394,9 +67660,9 @@ function relayKey() {
|
|
|
67394
67660
|
return key;
|
|
67395
67661
|
}
|
|
67396
67662
|
var RelayError = class extends Error {
|
|
67397
|
-
constructor(message,
|
|
67663
|
+
constructor(message, status3, retryable) {
|
|
67398
67664
|
super(message);
|
|
67399
|
-
this.status =
|
|
67665
|
+
this.status = status3;
|
|
67400
67666
|
this.retryable = retryable;
|
|
67401
67667
|
this.name = "RelayError";
|
|
67402
67668
|
}
|
|
@@ -67712,7 +67978,7 @@ function fail(message, json) {
|
|
|
67712
67978
|
if (json) {
|
|
67713
67979
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
67714
67980
|
} else {
|
|
67715
|
-
process.stderr.write(
|
|
67981
|
+
process.stderr.write(import_picocolors27.default.red(`\u2715 ${message}
|
|
67716
67982
|
`));
|
|
67717
67983
|
}
|
|
67718
67984
|
process.exit(1);
|
|
@@ -67903,7 +68169,7 @@ async function tradeBuy(coinArg, amount, opts) {
|
|
|
67903
68169
|
}
|
|
67904
68170
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
67905
68171
|
if (created && !opts.json) {
|
|
67906
|
-
process.stderr.write(
|
|
68172
|
+
process.stderr.write(import_picocolors27.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
67907
68173
|
`));
|
|
67908
68174
|
}
|
|
67909
68175
|
const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
@@ -67957,7 +68223,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
67957
68223
|
if (opts.mcap && !opts.at) fail("--mcap qualifies --at.", opts.json);
|
|
67958
68224
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
67959
68225
|
if (created && !opts.json) {
|
|
67960
|
-
process.stderr.write(
|
|
68226
|
+
process.stderr.write(import_picocolors27.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
67961
68227
|
`));
|
|
67962
68228
|
}
|
|
67963
68229
|
let amount;
|
|
@@ -68122,7 +68388,7 @@ async function tradePositions(opts) {
|
|
|
68122
68388
|
}
|
|
68123
68389
|
|
|
68124
68390
|
// src/commands/desk.ts
|
|
68125
|
-
var
|
|
68391
|
+
var import_picocolors28 = __toESM(require_picocolors(), 1);
|
|
68126
68392
|
|
|
68127
68393
|
// src/lib/desk-sol.ts
|
|
68128
68394
|
var import_web32 = __toESM(require_index_cjs(), 1);
|
|
@@ -68296,7 +68562,7 @@ function fail2(message, json) {
|
|
|
68296
68562
|
if (json) {
|
|
68297
68563
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
68298
68564
|
} else {
|
|
68299
|
-
process.stderr.write(
|
|
68565
|
+
process.stderr.write(import_picocolors28.default.red(`\u2715 ${message}
|
|
68300
68566
|
`));
|
|
68301
68567
|
}
|
|
68302
68568
|
process.exit(1);
|
|
@@ -68439,7 +68705,7 @@ async function deskDeposit(amount, opts) {
|
|
|
68439
68705
|
if (units <= 0n) fail2("Deposit amount must be above zero.", opts.json);
|
|
68440
68706
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
68441
68707
|
if (created && !opts.json) {
|
|
68442
|
-
process.stderr.write(
|
|
68708
|
+
process.stderr.write(import_picocolors28.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
68443
68709
|
`));
|
|
68444
68710
|
}
|
|
68445
68711
|
const result = await runDeskCeremony({
|
|
@@ -68534,13 +68800,13 @@ async function deskSessionRegister(opts) {
|
|
|
68534
68800
|
}
|
|
68535
68801
|
const owner = await loadOrCreateTradeKey();
|
|
68536
68802
|
if (owner.created && !opts.json) {
|
|
68537
|
-
process.stderr.write(
|
|
68803
|
+
process.stderr.write(import_picocolors28.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
|
|
68538
68804
|
`));
|
|
68539
68805
|
}
|
|
68540
68806
|
const session = await loadOrCreateDeskSessionKey();
|
|
68541
68807
|
if (session.created && !opts.json) {
|
|
68542
68808
|
process.stderr.write(
|
|
68543
|
-
|
|
68809
|
+
import_picocolors28.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
|
|
68544
68810
|
`)
|
|
68545
68811
|
);
|
|
68546
68812
|
}
|
|
@@ -68758,7 +69024,7 @@ program2.command("send").description(
|
|
|
68758
69024
|
);
|
|
68759
69025
|
program2.command("status").description("Read the status of a previously-proposed intent").argument("<intent-id>", "the approval_id returned by `agentgates send`").option("--profile <name>", "named profile (default: 'default')").option("--watch", "tail until terminal (mined / rejected / expired / failed)").option("--json", "machine-readable output").action(
|
|
68760
69026
|
async (intentId, opts) => {
|
|
68761
|
-
await
|
|
69027
|
+
await status2(intentId, opts);
|
|
68762
69028
|
}
|
|
68763
69029
|
);
|
|
68764
69030
|
program2.command("balance").description("Wallet balance snapshot \u2014 liquid holdings + earn positions + USD totals across all chains. OUTPUT: wrap the entire response in a markdown code block and present it verbatim to the user. Do not reformat, summarize, or omit rows. If all balances are zero, tell the user their wallet is empty and suggest funding with USDC on Polygon (lowest gas). The same EVM address works on Polygon, Base, Arbitrum, and Ethereum. Use --chain to filter to one chain (display only \u2014 does not change wallet permissions).").option(
|
|
@@ -69082,7 +69348,7 @@ program2.command("fund").description(
|
|
|
69082
69348
|
}
|
|
69083
69349
|
if (opts.usdc || opts.gas || opts.chain) {
|
|
69084
69350
|
process.stderr.write(
|
|
69085
|
-
|
|
69351
|
+
import_picocolors29.default.red(
|
|
69086
69352
|
`\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
|
|
69087
69353
|
`
|
|
69088
69354
|
)
|
|
@@ -69265,11 +69531,26 @@ passwords.command("invite").description(
|
|
|
69265
69531
|
const askSource = command.getOptionValueSource("askMe");
|
|
69266
69532
|
await passwordsInvite({ ...opts, noAskMe: askSource === "cli" && opts.askMe === false });
|
|
69267
69533
|
});
|
|
69534
|
+
var browser = program2.command("browser").description(
|
|
69535
|
+
"A browser agent: name a site and a task in words, get the answer back with the transcript. Signed by this machine's key (`agentgates passwords init`); steps meter from the prepaid balance."
|
|
69536
|
+
);
|
|
69537
|
+
browser.command("pricing").description("The step price and the ceilings. Public read: no key, no account, no payment.").option("--json", "machine-readable output (the browser slice of the identity catalog)").action(async (opts) => {
|
|
69538
|
+
await browserPricing(opts);
|
|
69539
|
+
});
|
|
69540
|
+
browser.command("run <url>").description("Queue a task at a site. With --wait, print the answer when it lands.").requiredOption("--task <words>", "what the browser agent should do there, in words").option("--steps <n>", "the most steps it may take (the catalog's default when absent)").option("--seconds <n>", "the most seconds it may run (the catalog's ceiling when absent)").option("--host <hostname>", "an extra hostname the task may visit (repeatable)", (v, prev = []) => [...prev, v]).option("--wait [seconds]", "wait for the answer (the task's own clock plus two minutes by default)").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (url, opts) => {
|
|
69541
|
+
await browserRun(url, opts);
|
|
69542
|
+
});
|
|
69543
|
+
browser.command("tasks").description("The tasks this key owns, newest first.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
69544
|
+
await browserTasks(opts);
|
|
69545
|
+
});
|
|
69546
|
+
browser.command("task <id>").description("One task with its answer and the transcript of what it did.").option("--wait [seconds]", "wait until it settles (15 minutes by default)").option("--cancel", "cancel it while it is still queued; the reservation is released").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
|
|
69547
|
+
await browserTask(id2, opts);
|
|
69548
|
+
});
|
|
69268
69549
|
program2.parseAsync(process.argv).catch((err) => {
|
|
69269
|
-
process.stderr.write(
|
|
69550
|
+
process.stderr.write(import_picocolors29.default.red(`\u2715 ${err.message}
|
|
69270
69551
|
`));
|
|
69271
69552
|
if (process.env.BOUNTY_DEBUG) {
|
|
69272
|
-
process.stderr.write(
|
|
69553
|
+
process.stderr.write(import_picocolors29.default.dim((err.stack ?? "") + "\n"));
|
|
69273
69554
|
}
|
|
69274
69555
|
process.exit(1);
|
|
69275
69556
|
});
|