@agentgates/cli 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -37
- package/dist/cli.mjs +596 -398
- package/package.json +1 -1
- package/scripts/postinstall.mjs +18 -15
package/dist/cli.mjs
CHANGED
|
@@ -5528,9 +5528,9 @@ var require_edwards = __commonJS({
|
|
|
5528
5528
|
const { BASE, Fp, Fn } = Point;
|
|
5529
5529
|
const randomBytes = eddsaOpts.randomBytes || utils_ts_1.randomBytes;
|
|
5530
5530
|
const adjustScalarBytes = eddsaOpts.adjustScalarBytes || ((bytes) => bytes);
|
|
5531
|
-
const domain = eddsaOpts.domain || ((data,
|
|
5531
|
+
const domain = eddsaOpts.domain || ((data, ctx2, phflag) => {
|
|
5532
5532
|
(0, utils_ts_1._abool2)(phflag, "phflag");
|
|
5533
|
-
if (
|
|
5533
|
+
if (ctx2.length || phflag)
|
|
5534
5534
|
throw new Error("Contexts/pre-hash are not supported");
|
|
5535
5535
|
return data;
|
|
5536
5536
|
});
|
|
@@ -6105,10 +6105,10 @@ var require_ed25519 = __commonJS({
|
|
|
6105
6105
|
uvRatio
|
|
6106
6106
|
}))();
|
|
6107
6107
|
exports.ed25519 = (() => (0, edwards_ts_1.twistedEdwards)(ed25519Defaults))();
|
|
6108
|
-
function ed25519_domain(data,
|
|
6109
|
-
if (
|
|
6108
|
+
function ed25519_domain(data, ctx2, phflag) {
|
|
6109
|
+
if (ctx2.length > 255)
|
|
6110
6110
|
throw new Error("Context is too big");
|
|
6111
|
-
return (0, utils_js_1.concatBytes)((0, utils_js_1.utf8ToBytes)("SigEd25519 no Ed25519 collisions"), new Uint8Array([phflag ? 1 : 0,
|
|
6111
|
+
return (0, utils_js_1.concatBytes)((0, utils_js_1.utf8ToBytes)("SigEd25519 no Ed25519 collisions"), new Uint8Array([phflag ? 1 : 0, ctx2.length]), ctx2, data);
|
|
6112
6112
|
}
|
|
6113
6113
|
exports.ed25519ctx = (() => (0, edwards_ts_1.twistedEdwards)({
|
|
6114
6114
|
...ed25519Defaults,
|
|
@@ -8808,22 +8808,22 @@ var require_bn = __commonJS({
|
|
|
8808
8808
|
BN.red = function red(num) {
|
|
8809
8809
|
return new Red(num);
|
|
8810
8810
|
};
|
|
8811
|
-
BN.prototype.toRed = function toRed(
|
|
8811
|
+
BN.prototype.toRed = function toRed(ctx2) {
|
|
8812
8812
|
assert(!this.red, "Already a number in reduction context");
|
|
8813
8813
|
assert(this.negative === 0, "red works only with positives");
|
|
8814
|
-
return
|
|
8814
|
+
return ctx2.convertTo(this)._forceRed(ctx2);
|
|
8815
8815
|
};
|
|
8816
8816
|
BN.prototype.fromRed = function fromRed() {
|
|
8817
8817
|
assert(this.red, "fromRed works only with numbers in reduction context");
|
|
8818
8818
|
return this.red.convertFrom(this);
|
|
8819
8819
|
};
|
|
8820
|
-
BN.prototype._forceRed = function _forceRed(
|
|
8821
|
-
this.red =
|
|
8820
|
+
BN.prototype._forceRed = function _forceRed(ctx2) {
|
|
8821
|
+
this.red = ctx2;
|
|
8822
8822
|
return this;
|
|
8823
8823
|
};
|
|
8824
|
-
BN.prototype.forceRed = function forceRed(
|
|
8824
|
+
BN.prototype.forceRed = function forceRed(ctx2) {
|
|
8825
8825
|
assert(!this.red, "Already a number in reduction context");
|
|
8826
|
-
return this._forceRed(
|
|
8826
|
+
return this._forceRed(ctx2);
|
|
8827
8827
|
};
|
|
8828
8828
|
BN.prototype.redAdd = function redAdd(num) {
|
|
8829
8829
|
assert(this.red, "redAdd works only with red numbers");
|
|
@@ -13650,17 +13650,17 @@ var require_dist = __commonJS({
|
|
|
13650
13650
|
}
|
|
13651
13651
|
function* run(value, struct2, options = {}) {
|
|
13652
13652
|
const { path: path5 = [], branch = [value], coerce: coerce2 = false, mask: mask2 = false } = options;
|
|
13653
|
-
const
|
|
13653
|
+
const ctx2 = { path: path5, branch, mask: mask2 };
|
|
13654
13654
|
if (coerce2) {
|
|
13655
|
-
value = struct2.coercer(value,
|
|
13655
|
+
value = struct2.coercer(value, ctx2);
|
|
13656
13656
|
}
|
|
13657
13657
|
let status2 = "valid";
|
|
13658
|
-
for (const failure of struct2.validator(value,
|
|
13658
|
+
for (const failure of struct2.validator(value, ctx2)) {
|
|
13659
13659
|
failure.explanation = options.message;
|
|
13660
13660
|
status2 = "not_valid";
|
|
13661
13661
|
yield [failure, void 0];
|
|
13662
13662
|
}
|
|
13663
|
-
for (let [k, v, s] of struct2.entries(value,
|
|
13663
|
+
for (let [k, v, s] of struct2.entries(value, ctx2)) {
|
|
13664
13664
|
const ts = run(v, s, {
|
|
13665
13665
|
path: k === void 0 ? path5 : [...path5, k],
|
|
13666
13666
|
branch: k === void 0 ? branch : [...branch, v],
|
|
@@ -13688,7 +13688,7 @@ var require_dist = __commonJS({
|
|
|
13688
13688
|
}
|
|
13689
13689
|
}
|
|
13690
13690
|
if (status2 !== "not_valid") {
|
|
13691
|
-
for (const failure of struct2.refiner(value,
|
|
13691
|
+
for (const failure of struct2.refiner(value, ctx2)) {
|
|
13692
13692
|
failure.explanation = options.message;
|
|
13693
13693
|
status2 = "not_refined";
|
|
13694
13694
|
yield [failure, void 0];
|
|
@@ -13817,13 +13817,13 @@ var require_dist = __commonJS({
|
|
|
13817
13817
|
function deprecated(struct2, log) {
|
|
13818
13818
|
return new Struct({
|
|
13819
13819
|
...struct2,
|
|
13820
|
-
refiner: (value,
|
|
13821
|
-
validator(value,
|
|
13820
|
+
refiner: (value, ctx2) => value === void 0 || struct2.refiner(value, ctx2),
|
|
13821
|
+
validator(value, ctx2) {
|
|
13822
13822
|
if (value === void 0) {
|
|
13823
13823
|
return true;
|
|
13824
13824
|
} else {
|
|
13825
|
-
log(value,
|
|
13826
|
-
return struct2.validator(value,
|
|
13825
|
+
log(value, ctx2);
|
|
13826
|
+
return struct2.validator(value, ctx2);
|
|
13827
13827
|
}
|
|
13828
13828
|
}
|
|
13829
13829
|
});
|
|
@@ -13832,21 +13832,21 @@ var require_dist = __commonJS({
|
|
|
13832
13832
|
return new Struct({
|
|
13833
13833
|
type: "dynamic",
|
|
13834
13834
|
schema: null,
|
|
13835
|
-
*entries(value,
|
|
13836
|
-
const struct2 = fn(value,
|
|
13837
|
-
yield* struct2.entries(value,
|
|
13835
|
+
*entries(value, ctx2) {
|
|
13836
|
+
const struct2 = fn(value, ctx2);
|
|
13837
|
+
yield* struct2.entries(value, ctx2);
|
|
13838
13838
|
},
|
|
13839
|
-
validator(value,
|
|
13840
|
-
const struct2 = fn(value,
|
|
13841
|
-
return struct2.validator(value,
|
|
13839
|
+
validator(value, ctx2) {
|
|
13840
|
+
const struct2 = fn(value, ctx2);
|
|
13841
|
+
return struct2.validator(value, ctx2);
|
|
13842
13842
|
},
|
|
13843
|
-
coercer(value,
|
|
13844
|
-
const struct2 = fn(value,
|
|
13845
|
-
return struct2.coercer(value,
|
|
13843
|
+
coercer(value, ctx2) {
|
|
13844
|
+
const struct2 = fn(value, ctx2);
|
|
13845
|
+
return struct2.coercer(value, ctx2);
|
|
13846
13846
|
},
|
|
13847
|
-
refiner(value,
|
|
13848
|
-
const struct2 = fn(value,
|
|
13849
|
-
return struct2.refiner(value,
|
|
13847
|
+
refiner(value, ctx2) {
|
|
13848
|
+
const struct2 = fn(value, ctx2);
|
|
13849
|
+
return struct2.refiner(value, ctx2);
|
|
13850
13850
|
}
|
|
13851
13851
|
});
|
|
13852
13852
|
}
|
|
@@ -13855,21 +13855,21 @@ var require_dist = __commonJS({
|
|
|
13855
13855
|
return new Struct({
|
|
13856
13856
|
type: "lazy",
|
|
13857
13857
|
schema: null,
|
|
13858
|
-
*entries(value,
|
|
13858
|
+
*entries(value, ctx2) {
|
|
13859
13859
|
struct2 ?? (struct2 = fn());
|
|
13860
|
-
yield* struct2.entries(value,
|
|
13860
|
+
yield* struct2.entries(value, ctx2);
|
|
13861
13861
|
},
|
|
13862
|
-
validator(value,
|
|
13862
|
+
validator(value, ctx2) {
|
|
13863
13863
|
struct2 ?? (struct2 = fn());
|
|
13864
|
-
return struct2.validator(value,
|
|
13864
|
+
return struct2.validator(value, ctx2);
|
|
13865
13865
|
},
|
|
13866
|
-
coercer(value,
|
|
13866
|
+
coercer(value, ctx2) {
|
|
13867
13867
|
struct2 ?? (struct2 = fn());
|
|
13868
|
-
return struct2.coercer(value,
|
|
13868
|
+
return struct2.coercer(value, ctx2);
|
|
13869
13869
|
},
|
|
13870
|
-
refiner(value,
|
|
13870
|
+
refiner(value, ctx2) {
|
|
13871
13871
|
struct2 ?? (struct2 = fn());
|
|
13872
|
-
return struct2.refiner(value,
|
|
13872
|
+
return struct2.refiner(value, ctx2);
|
|
13873
13873
|
}
|
|
13874
13874
|
});
|
|
13875
13875
|
}
|
|
@@ -13984,19 +13984,19 @@ var require_dist = __commonJS({
|
|
|
13984
13984
|
return new Struct({
|
|
13985
13985
|
type: "intersection",
|
|
13986
13986
|
schema: null,
|
|
13987
|
-
*entries(value,
|
|
13987
|
+
*entries(value, ctx2) {
|
|
13988
13988
|
for (const S of Structs) {
|
|
13989
|
-
yield* S.entries(value,
|
|
13989
|
+
yield* S.entries(value, ctx2);
|
|
13990
13990
|
}
|
|
13991
13991
|
},
|
|
13992
|
-
*validator(value,
|
|
13992
|
+
*validator(value, ctx2) {
|
|
13993
13993
|
for (const S of Structs) {
|
|
13994
|
-
yield* S.validator(value,
|
|
13994
|
+
yield* S.validator(value, ctx2);
|
|
13995
13995
|
}
|
|
13996
13996
|
},
|
|
13997
|
-
*refiner(value,
|
|
13997
|
+
*refiner(value, ctx2) {
|
|
13998
13998
|
for (const S of Structs) {
|
|
13999
|
-
yield* S.refiner(value,
|
|
13999
|
+
yield* S.refiner(value, ctx2);
|
|
14000
14000
|
}
|
|
14001
14001
|
}
|
|
14002
14002
|
});
|
|
@@ -14038,8 +14038,8 @@ var require_dist = __commonJS({
|
|
|
14038
14038
|
function nullable(struct2) {
|
|
14039
14039
|
return new Struct({
|
|
14040
14040
|
...struct2,
|
|
14041
|
-
validator: (value,
|
|
14042
|
-
refiner: (value,
|
|
14041
|
+
validator: (value, ctx2) => value === null || struct2.validator(value, ctx2),
|
|
14042
|
+
refiner: (value, ctx2) => value === null || struct2.refiner(value, ctx2)
|
|
14043
14043
|
});
|
|
14044
14044
|
}
|
|
14045
14045
|
function number() {
|
|
@@ -14068,12 +14068,12 @@ var require_dist = __commonJS({
|
|
|
14068
14068
|
validator(value) {
|
|
14069
14069
|
return isNonArrayObject(value) || `Expected an object, but received: ${print(value)}`;
|
|
14070
14070
|
},
|
|
14071
|
-
coercer(value,
|
|
14071
|
+
coercer(value, ctx2) {
|
|
14072
14072
|
if (!isNonArrayObject(value)) {
|
|
14073
14073
|
return value;
|
|
14074
14074
|
}
|
|
14075
14075
|
const coerced = { ...value };
|
|
14076
|
-
if (
|
|
14076
|
+
if (ctx2.mask && schema) {
|
|
14077
14077
|
for (const key in coerced) {
|
|
14078
14078
|
if (schema[key] === void 0) {
|
|
14079
14079
|
delete coerced[key];
|
|
@@ -14087,8 +14087,8 @@ var require_dist = __commonJS({
|
|
|
14087
14087
|
function optional(struct2) {
|
|
14088
14088
|
return new Struct({
|
|
14089
14089
|
...struct2,
|
|
14090
|
-
validator: (value,
|
|
14091
|
-
refiner: (value,
|
|
14090
|
+
validator: (value, ctx2) => value === void 0 || struct2.validator(value, ctx2),
|
|
14091
|
+
refiner: (value, ctx2) => value === void 0 || struct2.refiner(value, ctx2)
|
|
14092
14092
|
});
|
|
14093
14093
|
}
|
|
14094
14094
|
function record(Key, Value) {
|
|
@@ -14187,11 +14187,11 @@ var require_dist = __commonJS({
|
|
|
14187
14187
|
return new Struct({
|
|
14188
14188
|
type: "union",
|
|
14189
14189
|
schema: null,
|
|
14190
|
-
coercer(value,
|
|
14190
|
+
coercer(value, ctx2) {
|
|
14191
14191
|
for (const S of Structs) {
|
|
14192
14192
|
const [error, coerced] = S.validate(value, {
|
|
14193
14193
|
coerce: true,
|
|
14194
|
-
mask:
|
|
14194
|
+
mask: ctx2.mask
|
|
14195
14195
|
});
|
|
14196
14196
|
if (!error) {
|
|
14197
14197
|
return coerced;
|
|
@@ -14199,10 +14199,10 @@ var require_dist = __commonJS({
|
|
|
14199
14199
|
}
|
|
14200
14200
|
return value;
|
|
14201
14201
|
},
|
|
14202
|
-
validator(value,
|
|
14202
|
+
validator(value, ctx2) {
|
|
14203
14203
|
const failures = [];
|
|
14204
14204
|
for (const S of Structs) {
|
|
14205
|
-
const [...tuples] = run(value, S,
|
|
14205
|
+
const [...tuples] = run(value, S, ctx2);
|
|
14206
14206
|
const [first] = tuples;
|
|
14207
14207
|
if (!first[0]) {
|
|
14208
14208
|
return [];
|
|
@@ -14227,8 +14227,8 @@ var require_dist = __commonJS({
|
|
|
14227
14227
|
function coerce(struct2, condition, coercer) {
|
|
14228
14228
|
return new Struct({
|
|
14229
14229
|
...struct2,
|
|
14230
|
-
coercer: (value,
|
|
14231
|
-
return is(value, condition) ? struct2.coercer(coercer(value,
|
|
14230
|
+
coercer: (value, ctx2) => {
|
|
14231
|
+
return is(value, condition) ? struct2.coercer(coercer(value, ctx2), ctx2) : struct2.coercer(value, ctx2);
|
|
14232
14232
|
}
|
|
14233
14233
|
});
|
|
14234
14234
|
}
|
|
@@ -14311,10 +14311,10 @@ var require_dist = __commonJS({
|
|
|
14311
14311
|
function refine(struct2, name, refiner) {
|
|
14312
14312
|
return new Struct({
|
|
14313
14313
|
...struct2,
|
|
14314
|
-
*refiner(value,
|
|
14315
|
-
yield* struct2.refiner(value,
|
|
14316
|
-
const result = refiner(value,
|
|
14317
|
-
const failures = toFailures(result,
|
|
14314
|
+
*refiner(value, ctx2) {
|
|
14315
|
+
yield* struct2.refiner(value, ctx2);
|
|
14316
|
+
const result = refiner(value, ctx2);
|
|
14317
|
+
const failures = toFailures(result, ctx2, struct2, value);
|
|
14318
14318
|
for (const failure of failures) {
|
|
14319
14319
|
yield { ...failure, refinement: name };
|
|
14320
14320
|
}
|
|
@@ -34297,7 +34297,7 @@ var require_package = __commonJS({
|
|
|
34297
34297
|
"package.json"(exports, module) {
|
|
34298
34298
|
module.exports = {
|
|
34299
34299
|
name: "@agentgates/cli",
|
|
34300
|
-
version: "0.
|
|
34300
|
+
version: "0.11.0",
|
|
34301
34301
|
description: "Wallet operations for AI agents and humans",
|
|
34302
34302
|
keywords: [
|
|
34303
34303
|
"crypto",
|
|
@@ -34373,7 +34373,7 @@ var {
|
|
|
34373
34373
|
} = import_index.default;
|
|
34374
34374
|
|
|
34375
34375
|
// src/main.ts
|
|
34376
|
-
var
|
|
34376
|
+
var import_picocolors25 = __toESM(require_picocolors(), 1);
|
|
34377
34377
|
|
|
34378
34378
|
// src/commands/login.ts
|
|
34379
34379
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
@@ -35283,7 +35283,7 @@ async function login(opts) {
|
|
|
35283
35283
|
process.stdout.write(
|
|
35284
35284
|
import_picocolors2.default.yellow(
|
|
35285
35285
|
`Profile ${import_picocolors2.default.bold(profileName)} is already paired (wallet ${shortAddress(existing.walletAddress)}).
|
|
35286
|
-
Run ${import_picocolors2.default.bold(`
|
|
35286
|
+
Run ${import_picocolors2.default.bold(`agentgates logout --profile ${profileName}`)} first to re-pair, or pass ${import_picocolors2.default.bold("--profile <name>")} to add another.
|
|
35287
35287
|
`
|
|
35288
35288
|
)
|
|
35289
35289
|
);
|
|
@@ -35306,7 +35306,7 @@ Run ${import_picocolors2.default.bold(`bounty logout --profile ${profileName}`)}
|
|
|
35306
35306
|
process.exit(1);
|
|
35307
35307
|
}
|
|
35308
35308
|
process.stderr.write(
|
|
35309
|
-
import_picocolors2.default.red(`\u2715 ${err.message}. Run ${import_picocolors2.default.bold("
|
|
35309
|
+
import_picocolors2.default.red(`\u2715 ${err.message}. Run ${import_picocolors2.default.bold("agentgates login")} again to retry.
|
|
35310
35310
|
`)
|
|
35311
35311
|
);
|
|
35312
35312
|
process.exit(1);
|
|
@@ -35334,7 +35334,7 @@ Run ${import_picocolors2.default.bold(`bounty logout --profile ${profileName}`)}
|
|
|
35334
35334
|
);
|
|
35335
35335
|
process.stdout.write(
|
|
35336
35336
|
import_picocolors2.default.dim(
|
|
35337
|
-
`Try ${import_picocolors2.default.bold("
|
|
35337
|
+
`Try ${import_picocolors2.default.bold("agentgates whoami")} to confirm, or visit ${CREATORS_ORIGIN}/settings/pairings to revoke.
|
|
35338
35338
|
`
|
|
35339
35339
|
)
|
|
35340
35340
|
);
|
|
@@ -35345,17 +35345,198 @@ function shortAddress(addr) {
|
|
|
35345
35345
|
return `${addr.slice(0, 6)}\u2026${addr.slice(-4)}`;
|
|
35346
35346
|
}
|
|
35347
35347
|
|
|
35348
|
-
// src/commands/
|
|
35348
|
+
// src/commands/onboard.ts
|
|
35349
|
+
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
35350
|
+
import { createInterface } from "node:readline/promises";
|
|
35351
|
+
|
|
35352
|
+
// src/commands/compute.ts
|
|
35349
35353
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
35354
|
+
var SITE = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
35355
|
+
var usd = (v) => `$${String(v).replace(/(\.\d\d\d?)0+$/, "$1")}`;
|
|
35356
|
+
async function computePlans(opts) {
|
|
35357
|
+
const res = await fetch(`${SITE}/api/compute/catalog`, { headers: { accept: "application/json" } });
|
|
35358
|
+
if (!res.ok) throw new Error(`compute catalog: HTTP ${res.status}`);
|
|
35359
|
+
const body = await res.json();
|
|
35360
|
+
if (opts.json) {
|
|
35361
|
+
process.stdout.write(JSON.stringify(body, null, 2) + "\n");
|
|
35362
|
+
return;
|
|
35363
|
+
}
|
|
35364
|
+
const plans = body.plans ?? [];
|
|
35365
|
+
if (plans.length === 0) {
|
|
35366
|
+
process.stdout.write(` ${import_picocolors3.default.dim("No plans are on sale right now.")}
|
|
35367
|
+
`);
|
|
35368
|
+
return;
|
|
35369
|
+
}
|
|
35370
|
+
process.stdout.write(`
|
|
35371
|
+
${import_picocolors3.default.bold("MACHINES")} ${import_picocolors3.default.dim("confidential VMs, memory encrypted in use")}
|
|
35372
|
+
|
|
35373
|
+
`);
|
|
35374
|
+
for (const p of plans) {
|
|
35375
|
+
const spec = `${p.vcpu} vCPU \xB7 ${Math.round(p.memoryMb / 1024)} GB \xB7 ${p.diskGb}GB disk`;
|
|
35376
|
+
process.stdout.write(` ${import_picocolors3.default.bold(p.name.padEnd(10))} ${import_picocolors3.default.cyan(usd(p.priceUsdPerHour))}${import_picocolors3.default.dim("/hour")} ${import_picocolors3.default.dim(spec)}
|
|
35377
|
+
`);
|
|
35378
|
+
process.stdout.write(` ${import_picocolors3.default.dim(p.id.padEnd(10))} ${import_picocolors3.default.dim(`${p.egressQuotaGb} GB traffic`)}
|
|
35379
|
+
`);
|
|
35380
|
+
const ladder = p.pricing.map((r) => `${r.hoursPerPayment}h ${usd(r.totalUsd)}`).join(" ");
|
|
35381
|
+
if (ladder) process.stdout.write(` ${import_picocolors3.default.dim(ladder)}
|
|
35382
|
+
`);
|
|
35383
|
+
process.stdout.write("\n");
|
|
35384
|
+
}
|
|
35385
|
+
const nets = body.payment?.networks ?? [];
|
|
35386
|
+
if (nets.length) process.stdout.write(` ${import_picocolors3.default.dim(`USDC on ${nets.join(", ")}`)}
|
|
35387
|
+
|
|
35388
|
+
`);
|
|
35389
|
+
}
|
|
35390
|
+
async function computeBuy() {
|
|
35391
|
+
process.stdout.write(
|
|
35392
|
+
`
|
|
35393
|
+
Renting signs an x402 payment, and this CLI has no signer yet.
|
|
35394
|
+
Buy from the wallet, one biometric: ${import_picocolors3.default.cyan(`${SITE}/compute`)}
|
|
35395
|
+
Prices from here: ${import_picocolors3.default.dim("agentgates compute plans")}
|
|
35396
|
+
|
|
35397
|
+
`
|
|
35398
|
+
);
|
|
35399
|
+
}
|
|
35400
|
+
|
|
35401
|
+
// src/commands/inference.ts
|
|
35402
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
35403
|
+
var SITE2 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
35404
|
+
var ctx = (n) => n >= 1e6 ? `${Math.round(n / 1e6)}M` : `${Math.round(n / 1e3)}k`;
|
|
35405
|
+
async function inferenceModels(opts) {
|
|
35406
|
+
const res = await fetch(`${SITE2}/api/inference/catalog`, { headers: { accept: "application/json" } });
|
|
35407
|
+
if (!res.ok) throw new Error(`inference catalog: HTTP ${res.status}`);
|
|
35408
|
+
const body = await res.json();
|
|
35409
|
+
if (opts.json) {
|
|
35410
|
+
process.stdout.write(JSON.stringify(body, null, 2) + "\n");
|
|
35411
|
+
return;
|
|
35412
|
+
}
|
|
35413
|
+
const models = body.models ?? [];
|
|
35414
|
+
const shown = opts.all ? models : models.filter((m) => m.confidential).slice(0, 12);
|
|
35415
|
+
process.stdout.write(
|
|
35416
|
+
`
|
|
35417
|
+
${import_picocolors4.default.bold("MODELS")} ${import_picocolors4.default.dim(opts.all ? `all ${models.length}` : `${shown.length} confidential of ${models.length}`)}
|
|
35418
|
+
|
|
35419
|
+
`
|
|
35420
|
+
);
|
|
35421
|
+
for (const m of shown) {
|
|
35422
|
+
const tier = m.confidential ? import_picocolors4.default.cyan("attested") : import_picocolors4.default.dim("open");
|
|
35423
|
+
const ask = m.typicalAskUsd ? `~$${Number(m.typicalAskUsd).toFixed(3)}/ask` : "";
|
|
35424
|
+
process.stdout.write(` ${import_picocolors4.default.bold(m.name.padEnd(22))} ${import_picocolors4.default.dim(`${ctx(m.contextLength)} ctx`.padEnd(9))} ${tier.padEnd(18)} ${import_picocolors4.default.cyan(ask)}
|
|
35425
|
+
`);
|
|
35426
|
+
process.stdout.write(` ${import_picocolors4.default.dim(m.id.padEnd(22))} ${import_picocolors4.default.dim(`$${m.priceInUsdPerMTokens} in \xB7 $${m.priceOutUsdPerMTokens} out /M`)}
|
|
35427
|
+
|
|
35428
|
+
`);
|
|
35429
|
+
}
|
|
35430
|
+
if (!opts.all) process.stdout.write(` ${import_picocolors4.default.dim("agentgates inference models --all \xB7 the whole board")}
|
|
35431
|
+
|
|
35432
|
+
`);
|
|
35433
|
+
}
|
|
35434
|
+
async function inferenceAsk() {
|
|
35435
|
+
process.stdout.write(
|
|
35436
|
+
`
|
|
35437
|
+
A paid ask signs an x402 leg, and this CLI has no signer yet.
|
|
35438
|
+
Ask from the wallet, one biometric: ${import_picocolors4.default.cyan(`${SITE2}/inference`)}
|
|
35439
|
+
Models and prices from here: ${import_picocolors4.default.dim("agentgates inference models")}
|
|
35440
|
+
|
|
35441
|
+
`
|
|
35442
|
+
);
|
|
35443
|
+
}
|
|
35444
|
+
|
|
35445
|
+
// src/commands/onboard.ts
|
|
35446
|
+
var WORDMARK = [
|
|
35447
|
+
" _ _",
|
|
35448
|
+
" __ _ __ _ ___ _ _| |_ __ _ __ _| |_ ___ ___",
|
|
35449
|
+
" / _` / _` / -_) ' \\ _/ _` / _` | _/ -_|_-<",
|
|
35450
|
+
" \\__,_\\__, \\___|_||_\\__\\__, \\__,_|\\__\\___/__/",
|
|
35451
|
+
" |___/ |___/"
|
|
35452
|
+
].join("\n");
|
|
35453
|
+
var TAGLINE = "Confidential compute and inference, paid per use in USDC.";
|
|
35454
|
+
function banner() {
|
|
35455
|
+
process.stdout.write("\n" + import_picocolors5.default.cyan(WORDMARK) + "\n\n");
|
|
35456
|
+
process.stdout.write(` ${import_picocolors5.default.dim(TAGLINE)}
|
|
35457
|
+
|
|
35458
|
+
`);
|
|
35459
|
+
}
|
|
35460
|
+
async function onboard(opts = {}) {
|
|
35461
|
+
const profileName = opts.profile ?? DEFAULT_PROFILE;
|
|
35462
|
+
banner();
|
|
35463
|
+
const existing = await loadProfile(profileName).catch(() => null);
|
|
35464
|
+
if (existing) {
|
|
35465
|
+
process.stdout.write(` ${import_picocolors5.default.green("\u2713")} already paired as ${import_picocolors5.default.bold(existing.walletAddress ?? existing.userId)}
|
|
35466
|
+
|
|
35467
|
+
`);
|
|
35468
|
+
printNext();
|
|
35469
|
+
return;
|
|
35470
|
+
}
|
|
35471
|
+
if (!process.stdin.isTTY) {
|
|
35472
|
+
process.stdout.write(` Run ${import_picocolors5.default.bold("agentgates onboard")} to pair your wallet.
|
|
35473
|
+
|
|
35474
|
+
`);
|
|
35475
|
+
printNext();
|
|
35476
|
+
return;
|
|
35477
|
+
}
|
|
35478
|
+
process.stdout.write(` ${import_picocolors5.default.bold("choose how to start:")}
|
|
35479
|
+
`);
|
|
35480
|
+
process.stdout.write(` ${import_picocolors5.default.cyan("1.")} pair my wallet ${import_picocolors5.default.dim("(opens your browser, one biometric)")}
|
|
35481
|
+
`);
|
|
35482
|
+
process.stdout.write(` ${import_picocolors5.default.cyan("2.")} see what compute costs
|
|
35483
|
+
`);
|
|
35484
|
+
process.stdout.write(` ${import_picocolors5.default.cyan("3.")} see the models
|
|
35485
|
+
`);
|
|
35486
|
+
process.stdout.write(` ${import_picocolors5.default.cyan("4.")} nothing, I'll poke around
|
|
35487
|
+
`);
|
|
35488
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
35489
|
+
let choice = "4";
|
|
35490
|
+
try {
|
|
35491
|
+
choice = (await rl.question(` ${import_picocolors5.default.dim("choice [1]:")} `)).trim() || "1";
|
|
35492
|
+
} catch {
|
|
35493
|
+
process.stdout.write("\n");
|
|
35494
|
+
printNext();
|
|
35495
|
+
return;
|
|
35496
|
+
} finally {
|
|
35497
|
+
rl.close();
|
|
35498
|
+
}
|
|
35499
|
+
process.stdout.write("\n");
|
|
35500
|
+
switch (choice) {
|
|
35501
|
+
case "1":
|
|
35502
|
+
await runLoginFlow({ profile: profileName, jsonMode: false, ttyHeader: "Pairing this terminal with your wallet\u2026" });
|
|
35503
|
+
process.stdout.write("\n");
|
|
35504
|
+
printNext();
|
|
35505
|
+
return;
|
|
35506
|
+
case "2":
|
|
35507
|
+
await computePlans({});
|
|
35508
|
+
printNext();
|
|
35509
|
+
return;
|
|
35510
|
+
case "3":
|
|
35511
|
+
await inferenceModels({});
|
|
35512
|
+
printNext();
|
|
35513
|
+
return;
|
|
35514
|
+
default:
|
|
35515
|
+
printNext();
|
|
35516
|
+
return;
|
|
35517
|
+
}
|
|
35518
|
+
}
|
|
35519
|
+
function printNext() {
|
|
35520
|
+
process.stdout.write(` ${import_picocolors5.default.dim("agentgates compute plans")} ${import_picocolors5.default.dim("\xB7 machines by the hour")}
|
|
35521
|
+
`);
|
|
35522
|
+
process.stdout.write(` ${import_picocolors5.default.dim("agentgates inference models")} ${import_picocolors5.default.dim("\xB7 models by the token")}
|
|
35523
|
+
`);
|
|
35524
|
+
process.stdout.write(` ${import_picocolors5.default.dim("agentgates --help")} ${import_picocolors5.default.dim("\xB7 everything else")}
|
|
35525
|
+
|
|
35526
|
+
`);
|
|
35527
|
+
}
|
|
35528
|
+
|
|
35529
|
+
// src/commands/logout.ts
|
|
35530
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
35350
35531
|
async function logout(opts) {
|
|
35351
35532
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
35352
35533
|
const resolved = await resolveProfile(requested);
|
|
35353
35534
|
if (!resolved) {
|
|
35354
|
-
process.stdout.write(
|
|
35535
|
+
process.stdout.write(import_picocolors6.default.dim("Not logged in \u2014 nothing to log out.\n"));
|
|
35355
35536
|
return;
|
|
35356
35537
|
}
|
|
35357
35538
|
if (resolved.autoSelected) {
|
|
35358
|
-
process.stderr.write(
|
|
35539
|
+
process.stderr.write(import_picocolors6.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
35359
35540
|
`));
|
|
35360
35541
|
}
|
|
35361
35542
|
const { profile, name: profileName } = resolved;
|
|
@@ -35380,15 +35561,15 @@ async function logout(opts) {
|
|
|
35380
35561
|
const removed = await deleteProfile(profileName);
|
|
35381
35562
|
if (removed) {
|
|
35382
35563
|
process.stdout.write(
|
|
35383
|
-
|
|
35564
|
+
import_picocolors6.default.green(`\u2713 Logged out of profile ${import_picocolors6.default.bold(profileName)}.
|
|
35384
35565
|
`)
|
|
35385
35566
|
);
|
|
35386
35567
|
}
|
|
35387
35568
|
if (serverError) {
|
|
35388
35569
|
process.stderr.write(
|
|
35389
|
-
|
|
35570
|
+
import_picocolors6.default.yellow(
|
|
35390
35571
|
`\u26A0 Couldn't revoke server-side: ${serverError}
|
|
35391
|
-
The local bearer is wiped. If the server still has it, revoke from ${
|
|
35572
|
+
The local bearer is wiped. If the server still has it, revoke from ${import_picocolors6.default.bold("agentgates.ai/settings/pairings")}.
|
|
35392
35573
|
`
|
|
35393
35574
|
)
|
|
35394
35575
|
);
|
|
@@ -35396,16 +35577,16 @@ async function logout(opts) {
|
|
|
35396
35577
|
}
|
|
35397
35578
|
|
|
35398
35579
|
// src/commands/whoami.ts
|
|
35399
|
-
var
|
|
35580
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
35400
35581
|
async function whoami(opts) {
|
|
35401
35582
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
35402
35583
|
const resolved = await resolveProfile(requested);
|
|
35403
35584
|
if (!resolved) {
|
|
35404
|
-
process.stderr.write(
|
|
35585
|
+
process.stderr.write(import_picocolors7.default.red("Not logged in. Run agentgates login first.\n"));
|
|
35405
35586
|
process.exit(2);
|
|
35406
35587
|
}
|
|
35407
35588
|
if (resolved.autoSelected) {
|
|
35408
|
-
process.stderr.write(
|
|
35589
|
+
process.stderr.write(import_picocolors7.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
35409
35590
|
`));
|
|
35410
35591
|
}
|
|
35411
35592
|
const { profile, name: profileName } = resolved;
|
|
@@ -35414,7 +35595,7 @@ async function whoami(opts) {
|
|
|
35414
35595
|
profile,
|
|
35415
35596
|
profileName,
|
|
35416
35597
|
jsonMode,
|
|
35417
|
-
ttyHeader:
|
|
35598
|
+
ttyHeader: import_picocolors7.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
35418
35599
|
fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
|
|
35419
35600
|
});
|
|
35420
35601
|
if (outcome.kind === "auth_failed") {
|
|
@@ -35424,14 +35605,14 @@ async function whoami(opts) {
|
|
|
35424
35605
|
);
|
|
35425
35606
|
process.exit(1);
|
|
35426
35607
|
}
|
|
35427
|
-
process.stderr.write(
|
|
35608
|
+
process.stderr.write(import_picocolors7.default.red(`\u2715 ${outcome.reason}.
|
|
35428
35609
|
`));
|
|
35429
35610
|
process.exit(1);
|
|
35430
35611
|
}
|
|
35431
35612
|
if (outcome.kind === "error") {
|
|
35432
35613
|
const err = outcome.error;
|
|
35433
35614
|
if (err instanceof ApiError) {
|
|
35434
|
-
process.stderr.write(
|
|
35615
|
+
process.stderr.write(import_picocolors7.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
35435
35616
|
`));
|
|
35436
35617
|
process.exit(1);
|
|
35437
35618
|
}
|
|
@@ -35452,7 +35633,7 @@ async function whoami(opts) {
|
|
|
35452
35633
|
process.stdout.write(`Solana ${me.solanaAddress}
|
|
35453
35634
|
`);
|
|
35454
35635
|
}
|
|
35455
|
-
process.stdout.write(`Scopes ${me.scopes.join(", ") ||
|
|
35636
|
+
process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors7.default.dim("(none)")}
|
|
35456
35637
|
`);
|
|
35457
35638
|
const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
|
|
35458
35639
|
const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
|
|
@@ -35469,7 +35650,7 @@ async function whoami(opts) {
|
|
|
35469
35650
|
`
|
|
35470
35651
|
);
|
|
35471
35652
|
process.stdout.write(
|
|
35472
|
-
`Profile ${profileName === DEFAULT_PROFILE ?
|
|
35653
|
+
`Profile ${profileName === DEFAULT_PROFILE ? import_picocolors7.default.dim("(default)") : profileName}
|
|
35473
35654
|
`
|
|
35474
35655
|
);
|
|
35475
35656
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -35483,7 +35664,7 @@ function formatDate(iso) {
|
|
|
35483
35664
|
}
|
|
35484
35665
|
|
|
35485
35666
|
// src/commands/send.ts
|
|
35486
|
-
var
|
|
35667
|
+
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
35487
35668
|
|
|
35488
35669
|
// src/lib/status.ts
|
|
35489
35670
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -35633,11 +35814,11 @@ async function send(amount, asset, opts) {
|
|
|
35633
35814
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
35634
35815
|
const resolved = await resolveProfile(requested);
|
|
35635
35816
|
if (!resolved) {
|
|
35636
|
-
process.stderr.write(
|
|
35817
|
+
process.stderr.write(import_picocolors8.default.red("Not logged in. Run agentgates login first.\n"));
|
|
35637
35818
|
process.exit(2);
|
|
35638
35819
|
}
|
|
35639
35820
|
if (resolved.autoSelected) {
|
|
35640
|
-
process.stderr.write(
|
|
35821
|
+
process.stderr.write(import_picocolors8.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
35641
35822
|
`));
|
|
35642
35823
|
}
|
|
35643
35824
|
const { profile, name: profileName } = resolved;
|
|
@@ -35646,7 +35827,7 @@ async function send(amount, asset, opts) {
|
|
|
35646
35827
|
const amountNumber = Number(amount);
|
|
35647
35828
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
35648
35829
|
process.stderr.write(
|
|
35649
|
-
|
|
35830
|
+
import_picocolors8.default.red(`\u2715 amount must be a positive number (got ${import_picocolors8.default.bold(amount)}).
|
|
35650
35831
|
`)
|
|
35651
35832
|
);
|
|
35652
35833
|
process.exit(2);
|
|
@@ -35654,23 +35835,23 @@ async function send(amount, asset, opts) {
|
|
|
35654
35835
|
const assetNormalized = asset.toLowerCase();
|
|
35655
35836
|
if (assetNormalized !== "native" && assetNormalized !== "usdc") {
|
|
35656
35837
|
process.stderr.write(
|
|
35657
|
-
|
|
35658
|
-
`\u2715 asset must be ${
|
|
35838
|
+
import_picocolors8.default.red(
|
|
35839
|
+
`\u2715 asset must be ${import_picocolors8.default.bold("native")} or ${import_picocolors8.default.bold("usdc")} (got ${import_picocolors8.default.bold(asset)}).
|
|
35659
35840
|
`
|
|
35660
35841
|
)
|
|
35661
35842
|
);
|
|
35662
35843
|
process.exit(2);
|
|
35663
35844
|
}
|
|
35664
35845
|
if (!opts.to || opts.to.trim() === "") {
|
|
35665
|
-
process.stderr.write(
|
|
35846
|
+
process.stderr.write(import_picocolors8.default.red(`\u2715 --to <address> is required.
|
|
35666
35847
|
`));
|
|
35667
35848
|
process.exit(2);
|
|
35668
35849
|
}
|
|
35669
35850
|
if (isSolanaChainAlias(opts.chain)) {
|
|
35670
35851
|
if (EVM_ADDRESS_RE.test(opts.to)) {
|
|
35671
35852
|
process.stderr.write(
|
|
35672
|
-
|
|
35673
|
-
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${
|
|
35853
|
+
import_picocolors8.default.red(
|
|
35854
|
+
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors8.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
|
|
35674
35855
|
`
|
|
35675
35856
|
)
|
|
35676
35857
|
);
|
|
@@ -35678,10 +35859,10 @@ async function send(amount, asset, opts) {
|
|
|
35678
35859
|
}
|
|
35679
35860
|
if (!SOLANA_ADDRESS_RE.test(opts.to)) {
|
|
35680
35861
|
process.stderr.write(
|
|
35681
|
-
|
|
35682
|
-
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${
|
|
35862
|
+
import_picocolors8.default.red(
|
|
35863
|
+
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors8.default.bold(opts.to)}).
|
|
35683
35864
|
`
|
|
35684
|
-
) +
|
|
35865
|
+
) + import_picocolors8.default.dim(
|
|
35685
35866
|
` SNS resolution is deferred to a future server-side change;
|
|
35686
35867
|
for now Solana sends require the literal pubkey.
|
|
35687
35868
|
`
|
|
@@ -35692,8 +35873,8 @@ async function send(amount, asset, opts) {
|
|
|
35692
35873
|
}
|
|
35693
35874
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
35694
35875
|
process.stderr.write(
|
|
35695
|
-
|
|
35696
|
-
`) +
|
|
35876
|
+
import_picocolors8.default.red(`\u2715 --user-stated <text> is required.
|
|
35877
|
+
`) + import_picocolors8.default.dim(
|
|
35697
35878
|
` This is the trust-gap defense: pass the verbatim user request so
|
|
35698
35879
|
the approval modal can cross-check what the agent thinks the user
|
|
35699
35880
|
asked for vs. the actual decoded transaction.
|
|
@@ -35711,7 +35892,7 @@ async function send(amount, asset, opts) {
|
|
|
35711
35892
|
const n = Number(opts.maxUsd);
|
|
35712
35893
|
if (!Number.isFinite(n) || n <= 0) {
|
|
35713
35894
|
process.stderr.write(
|
|
35714
|
-
|
|
35895
|
+
import_picocolors8.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
|
|
35715
35896
|
`)
|
|
35716
35897
|
);
|
|
35717
35898
|
process.exit(2);
|
|
@@ -35753,7 +35934,7 @@ async function send(amount, asset, opts) {
|
|
|
35753
35934
|
profile: profileName,
|
|
35754
35935
|
jsonMode,
|
|
35755
35936
|
origin: activeProfile.mcpOrigin,
|
|
35756
|
-
ttyHeader:
|
|
35937
|
+
ttyHeader: import_picocolors8.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
35757
35938
|
});
|
|
35758
35939
|
} catch (reloginErr) {
|
|
35759
35940
|
if (jsonMode) {
|
|
@@ -35765,7 +35946,7 @@ async function send(amount, asset, opts) {
|
|
|
35765
35946
|
process.exit(1);
|
|
35766
35947
|
}
|
|
35767
35948
|
process.stderr.write(
|
|
35768
|
-
|
|
35949
|
+
import_picocolors8.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
35769
35950
|
`)
|
|
35770
35951
|
);
|
|
35771
35952
|
process.exit(1);
|
|
@@ -35789,7 +35970,7 @@ async function send(amount, asset, opts) {
|
|
|
35789
35970
|
process.exit(1);
|
|
35790
35971
|
}
|
|
35791
35972
|
process.stderr.write(
|
|
35792
|
-
|
|
35973
|
+
import_picocolors8.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
35793
35974
|
`)
|
|
35794
35975
|
);
|
|
35795
35976
|
process.exit(1);
|
|
@@ -35806,7 +35987,7 @@ async function send(amount, asset, opts) {
|
|
|
35806
35987
|
});
|
|
35807
35988
|
process.exit(1);
|
|
35808
35989
|
}
|
|
35809
|
-
process.stderr.write(
|
|
35990
|
+
process.stderr.write(import_picocolors8.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
35810
35991
|
`));
|
|
35811
35992
|
process.exit(1);
|
|
35812
35993
|
} else {
|
|
@@ -35832,17 +36013,17 @@ async function send(amount, asset, opts) {
|
|
|
35832
36013
|
if (proposed.detail) {
|
|
35833
36014
|
const d = proposed.detail;
|
|
35834
36015
|
process.stderr.write(
|
|
35835
|
-
|
|
36016
|
+
import_picocolors8.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
|
|
35836
36017
|
`
|
|
35837
36018
|
);
|
|
35838
36019
|
} else {
|
|
35839
|
-
process.stderr.write(
|
|
36020
|
+
process.stderr.write(import_picocolors8.default.red(`\u2715 ${proposed.reason}
|
|
35840
36021
|
`));
|
|
35841
36022
|
}
|
|
35842
36023
|
if (proposed.upgrade_url) {
|
|
35843
36024
|
process.stderr.write(
|
|
35844
36025
|
` Open this to grant access, then re-run the command:
|
|
35845
|
-
${
|
|
36026
|
+
${import_picocolors8.default.cyan(proposed.upgrade_url)}
|
|
35846
36027
|
`
|
|
35847
36028
|
);
|
|
35848
36029
|
}
|
|
@@ -35852,21 +36033,21 @@ async function send(amount, asset, opts) {
|
|
|
35852
36033
|
const a = proposed.recommended_actions[i];
|
|
35853
36034
|
process.stderr.write(` ${i + 1}. ${a.label}
|
|
35854
36035
|
`);
|
|
35855
|
-
if (a.reasoning) process.stderr.write(
|
|
36036
|
+
if (a.reasoning) process.stderr.write(import_picocolors8.default.dim(` ${a.reasoning}
|
|
35856
36037
|
`));
|
|
35857
36038
|
if (a.action_intent && a.action_intent.external_url) {
|
|
35858
36039
|
process.stderr.write(
|
|
35859
|
-
` ${
|
|
36040
|
+
` ${import_picocolors8.default.cyan(a.action_intent.external_url)}
|
|
35860
36041
|
`
|
|
35861
36042
|
);
|
|
35862
36043
|
}
|
|
35863
36044
|
}
|
|
35864
36045
|
}
|
|
35865
36046
|
if (proposed.suggestions && proposed.suggestions.length > 0) {
|
|
35866
|
-
process.stderr.write(
|
|
36047
|
+
process.stderr.write(import_picocolors8.default.dim("\n Other ways to fund:\n"));
|
|
35867
36048
|
for (const s of proposed.suggestions) {
|
|
35868
36049
|
if (s.kind === "ask_user") continue;
|
|
35869
|
-
process.stderr.write(
|
|
36050
|
+
process.stderr.write(import_picocolors8.default.dim(` \u2022 ${s.label}
|
|
35870
36051
|
`));
|
|
35871
36052
|
}
|
|
35872
36053
|
}
|
|
@@ -35893,8 +36074,8 @@ async function send(amount, asset, opts) {
|
|
|
35893
36074
|
} else {
|
|
35894
36075
|
process.stdout.write(
|
|
35895
36076
|
`
|
|
35896
|
-
${
|
|
35897
|
-
${
|
|
36077
|
+
${import_picocolors8.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
36078
|
+
${import_picocolors8.default.cyan(proposed.approval_url)}
|
|
35898
36079
|
|
|
35899
36080
|
`
|
|
35900
36081
|
);
|
|
@@ -35913,7 +36094,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35913
36094
|
if (jsonMode) {
|
|
35914
36095
|
emitNdjson({ status: s.status, intent_id: s.approval_id });
|
|
35915
36096
|
} else {
|
|
35916
|
-
process.stdout.write(` ${describeStatus(s.status)}${
|
|
36097
|
+
process.stdout.write(` ${describeStatus(s.status)}${import_picocolors8.default.dim("\u2026")}\r`);
|
|
35917
36098
|
}
|
|
35918
36099
|
}
|
|
35919
36100
|
});
|
|
@@ -35927,7 +36108,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35927
36108
|
profile: profileName,
|
|
35928
36109
|
jsonMode,
|
|
35929
36110
|
origin: activeProfile.mcpOrigin,
|
|
35930
|
-
ttyHeader:
|
|
36111
|
+
ttyHeader: import_picocolors8.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
|
|
35931
36112
|
});
|
|
35932
36113
|
} catch (reloginErr) {
|
|
35933
36114
|
if (jsonMode) {
|
|
@@ -35940,7 +36121,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35940
36121
|
process.exit(1);
|
|
35941
36122
|
}
|
|
35942
36123
|
process.stderr.write(
|
|
35943
|
-
"\n" +
|
|
36124
|
+
"\n" + import_picocolors8.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
35944
36125
|
`)
|
|
35945
36126
|
);
|
|
35946
36127
|
process.exit(1);
|
|
@@ -35958,7 +36139,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35958
36139
|
process.exit(1);
|
|
35959
36140
|
}
|
|
35960
36141
|
process.stderr.write(
|
|
35961
|
-
"\n" +
|
|
36142
|
+
"\n" + import_picocolors8.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
35962
36143
|
`)
|
|
35963
36144
|
);
|
|
35964
36145
|
process.exit(1);
|
|
@@ -35974,7 +36155,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35974
36155
|
process.exit(1);
|
|
35975
36156
|
}
|
|
35976
36157
|
process.stderr.write(
|
|
35977
|
-
"\n" +
|
|
36158
|
+
"\n" + import_picocolors8.default.red(`\u2715 Status poll failed: ${err.message}
|
|
35978
36159
|
`)
|
|
35979
36160
|
);
|
|
35980
36161
|
process.exit(1);
|
|
@@ -35994,19 +36175,19 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35994
36175
|
}
|
|
35995
36176
|
process.stdout.write("\n");
|
|
35996
36177
|
if (final.status === "mined") {
|
|
35997
|
-
process.stdout.write(
|
|
36178
|
+
process.stdout.write(import_picocolors8.default.green("\u2713 Mined.") + "\n");
|
|
35998
36179
|
if (final.tx_hash) {
|
|
35999
36180
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
36000
36181
|
`);
|
|
36001
36182
|
}
|
|
36002
36183
|
if (explorer) {
|
|
36003
|
-
process.stdout.write(` Explorer ${
|
|
36184
|
+
process.stdout.write(` Explorer ${import_picocolors8.default.cyan(explorer)}
|
|
36004
36185
|
`);
|
|
36005
36186
|
}
|
|
36006
36187
|
process.exit(0);
|
|
36007
36188
|
}
|
|
36008
36189
|
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}`;
|
|
36009
|
-
process.stderr.write(
|
|
36190
|
+
process.stderr.write(import_picocolors8.default.red(`\u2715 ${label}.
|
|
36010
36191
|
`));
|
|
36011
36192
|
process.exit(1);
|
|
36012
36193
|
}
|
|
@@ -36034,7 +36215,7 @@ function describeStatus(s) {
|
|
|
36034
36215
|
}
|
|
36035
36216
|
|
|
36036
36217
|
// src/commands/status.ts
|
|
36037
|
-
var
|
|
36218
|
+
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
36038
36219
|
var WATCH_GIVEUP_MS = 10 * 6e4;
|
|
36039
36220
|
function explorerUrl2(chainId, hash) {
|
|
36040
36221
|
switch (chainId) {
|
|
@@ -36052,17 +36233,17 @@ function explorerUrl2(chainId, hash) {
|
|
|
36052
36233
|
}
|
|
36053
36234
|
async function status(intentId, opts) {
|
|
36054
36235
|
if (!intentId || intentId.trim() === "") {
|
|
36055
|
-
process.stderr.write(
|
|
36236
|
+
process.stderr.write(import_picocolors9.default.red("\u2715 Missing intent id.\n"));
|
|
36056
36237
|
process.exit(2);
|
|
36057
36238
|
}
|
|
36058
36239
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
36059
36240
|
const resolved = await resolveProfile(requested);
|
|
36060
36241
|
if (!resolved) {
|
|
36061
|
-
process.stderr.write(
|
|
36242
|
+
process.stderr.write(import_picocolors9.default.red("Not logged in. Run agentgates login first.\n"));
|
|
36062
36243
|
process.exit(2);
|
|
36063
36244
|
}
|
|
36064
36245
|
if (resolved.autoSelected) {
|
|
36065
|
-
process.stderr.write(
|
|
36246
|
+
process.stderr.write(import_picocolors9.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
36066
36247
|
`));
|
|
36067
36248
|
}
|
|
36068
36249
|
const { profile, name: profileName } = resolved;
|
|
@@ -36071,7 +36252,7 @@ async function status(intentId, opts) {
|
|
|
36071
36252
|
profile,
|
|
36072
36253
|
profileName,
|
|
36073
36254
|
jsonMode,
|
|
36074
|
-
ttyHeader:
|
|
36255
|
+
ttyHeader: import_picocolors9.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
36075
36256
|
fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
|
|
36076
36257
|
});
|
|
36077
36258
|
if (outcome.kind === "auth_failed") {
|
|
@@ -36081,7 +36262,7 @@ async function status(intentId, opts) {
|
|
|
36081
36262
|
);
|
|
36082
36263
|
process.exit(1);
|
|
36083
36264
|
}
|
|
36084
|
-
process.stderr.write(
|
|
36265
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 ${outcome.reason}.
|
|
36085
36266
|
`));
|
|
36086
36267
|
process.exit(1);
|
|
36087
36268
|
}
|
|
@@ -36089,11 +36270,11 @@ async function status(intentId, opts) {
|
|
|
36089
36270
|
const err = outcome.error;
|
|
36090
36271
|
if (err instanceof ApiError) {
|
|
36091
36272
|
if (err.status === 404) {
|
|
36092
|
-
process.stderr.write(
|
|
36273
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 No intent with id ${intentId}.
|
|
36093
36274
|
`));
|
|
36094
36275
|
process.exit(1);
|
|
36095
36276
|
}
|
|
36096
|
-
process.stderr.write(
|
|
36277
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
36097
36278
|
`));
|
|
36098
36279
|
process.exit(1);
|
|
36099
36280
|
}
|
|
@@ -36104,7 +36285,7 @@ async function status(intentId, opts) {
|
|
|
36104
36285
|
if (opts.watch && !isTerminalStatus(snap.status)) {
|
|
36105
36286
|
if (!jsonMode) {
|
|
36106
36287
|
printSnap(snap);
|
|
36107
|
-
process.stdout.write(
|
|
36288
|
+
process.stdout.write(import_picocolors9.default.dim("Watching\u2026\n"));
|
|
36108
36289
|
}
|
|
36109
36290
|
const runWatchPoll = (p) => streamStatusUntilTerminal({
|
|
36110
36291
|
intentId,
|
|
@@ -36115,7 +36296,7 @@ async function status(intentId, opts) {
|
|
|
36115
36296
|
giveUpMs: WATCH_GIVEUP_MS,
|
|
36116
36297
|
onTick: (s) => {
|
|
36117
36298
|
if (!jsonMode) {
|
|
36118
|
-
process.stdout.write(` ${
|
|
36299
|
+
process.stdout.write(` ${import_picocolors9.default.dim("\u2192")} ${s.status}
|
|
36119
36300
|
`);
|
|
36120
36301
|
}
|
|
36121
36302
|
}
|
|
@@ -36130,7 +36311,7 @@ async function status(intentId, opts) {
|
|
|
36130
36311
|
profile: profileName,
|
|
36131
36312
|
jsonMode,
|
|
36132
36313
|
origin: activeProfile.mcpOrigin,
|
|
36133
|
-
ttyHeader:
|
|
36314
|
+
ttyHeader: import_picocolors9.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
|
|
36134
36315
|
});
|
|
36135
36316
|
} catch (reloginErr) {
|
|
36136
36317
|
if (jsonMode) {
|
|
@@ -36144,7 +36325,7 @@ async function status(intentId, opts) {
|
|
|
36144
36325
|
process.exit(1);
|
|
36145
36326
|
}
|
|
36146
36327
|
process.stderr.write(
|
|
36147
|
-
|
|
36328
|
+
import_picocolors9.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
36148
36329
|
`)
|
|
36149
36330
|
);
|
|
36150
36331
|
process.exit(1);
|
|
@@ -36152,12 +36333,12 @@ async function status(intentId, opts) {
|
|
|
36152
36333
|
try {
|
|
36153
36334
|
final = await runWatchPoll(activeProfile);
|
|
36154
36335
|
} catch (retryErr) {
|
|
36155
|
-
process.stderr.write(
|
|
36336
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 ${retryErr.message}
|
|
36156
36337
|
`));
|
|
36157
36338
|
process.exit(1);
|
|
36158
36339
|
}
|
|
36159
36340
|
} else {
|
|
36160
|
-
process.stderr.write(
|
|
36341
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 ${err.message}
|
|
36161
36342
|
`));
|
|
36162
36343
|
process.exit(1);
|
|
36163
36344
|
}
|
|
@@ -36178,7 +36359,7 @@ async function status(intentId, opts) {
|
|
|
36178
36359
|
}
|
|
36179
36360
|
function printSnap(s) {
|
|
36180
36361
|
const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
|
|
36181
|
-
const colorFn = s.status === "mined" ?
|
|
36362
|
+
const colorFn = s.status === "mined" ? import_picocolors9.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors9.default.red : import_picocolors9.default.cyan;
|
|
36182
36363
|
process.stdout.write(`Intent ${s.approval_id}
|
|
36183
36364
|
`);
|
|
36184
36365
|
process.stdout.write(`Status ${colorFn(s.status)}
|
|
@@ -36193,12 +36374,12 @@ function printSnap(s) {
|
|
|
36193
36374
|
process.stdout.write(`Tx ${s.tx_hash}
|
|
36194
36375
|
`);
|
|
36195
36376
|
if (explorer) {
|
|
36196
|
-
process.stdout.write(`Explorer ${
|
|
36377
|
+
process.stdout.write(`Explorer ${import_picocolors9.default.cyan(explorer)}
|
|
36197
36378
|
`);
|
|
36198
36379
|
}
|
|
36199
36380
|
}
|
|
36200
36381
|
if (!isTerminalStatus(s.status)) {
|
|
36201
|
-
process.stdout.write(`Approve ${
|
|
36382
|
+
process.stdout.write(`Approve ${import_picocolors9.default.cyan(s.approval_url)}
|
|
36202
36383
|
`);
|
|
36203
36384
|
}
|
|
36204
36385
|
process.stdout.write(`Created ${formatDate2(s.created_at)}
|
|
@@ -36215,7 +36396,7 @@ function formatDate2(iso) {
|
|
|
36215
36396
|
}
|
|
36216
36397
|
|
|
36217
36398
|
// src/commands/balance.ts
|
|
36218
|
-
var
|
|
36399
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
36219
36400
|
var CHAIN_ALIASES = {
|
|
36220
36401
|
"1": 1,
|
|
36221
36402
|
ethereum: 1,
|
|
@@ -36238,11 +36419,11 @@ async function balance(opts) {
|
|
|
36238
36419
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
36239
36420
|
const resolved = await resolveProfile(requested);
|
|
36240
36421
|
if (!resolved) {
|
|
36241
|
-
process.stderr.write(
|
|
36422
|
+
process.stderr.write(import_picocolors10.default.red("Not logged in. Run agentgates login first.\n"));
|
|
36242
36423
|
process.exit(2);
|
|
36243
36424
|
}
|
|
36244
36425
|
if (resolved.autoSelected) {
|
|
36245
|
-
process.stderr.write(
|
|
36426
|
+
process.stderr.write(import_picocolors10.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
36246
36427
|
`));
|
|
36247
36428
|
}
|
|
36248
36429
|
const { profile, name: profileName } = resolved;
|
|
@@ -36252,8 +36433,8 @@ async function balance(opts) {
|
|
|
36252
36433
|
const id = CHAIN_ALIASES[key];
|
|
36253
36434
|
if (id === void 0) {
|
|
36254
36435
|
process.stderr.write(
|
|
36255
|
-
|
|
36256
|
-
`\u2715 Unknown chain ${
|
|
36436
|
+
import_picocolors10.default.red(
|
|
36437
|
+
`\u2715 Unknown chain ${import_picocolors10.default.bold(opts.chain)}. Supported: ${import_picocolors10.default.bold("1/ethereum")}, ${import_picocolors10.default.bold("137/polygon")}, ${import_picocolors10.default.bold("8453/base")}, ${import_picocolors10.default.bold("42161/arbitrum")}, ${import_picocolors10.default.bold("900/solana")}.
|
|
36257
36438
|
`
|
|
36258
36439
|
)
|
|
36259
36440
|
);
|
|
@@ -36266,7 +36447,7 @@ async function balance(opts) {
|
|
|
36266
36447
|
profile,
|
|
36267
36448
|
profileName,
|
|
36268
36449
|
jsonMode,
|
|
36269
|
-
ttyHeader:
|
|
36450
|
+
ttyHeader: import_picocolors10.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
36270
36451
|
fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
|
|
36271
36452
|
});
|
|
36272
36453
|
if (outcome.kind === "auth_failed") {
|
|
@@ -36276,14 +36457,14 @@ async function balance(opts) {
|
|
|
36276
36457
|
);
|
|
36277
36458
|
process.exit(1);
|
|
36278
36459
|
}
|
|
36279
|
-
process.stderr.write(
|
|
36460
|
+
process.stderr.write(import_picocolors10.default.red(`\u2715 ${outcome.reason}.
|
|
36280
36461
|
`));
|
|
36281
36462
|
process.exit(1);
|
|
36282
36463
|
}
|
|
36283
36464
|
if (outcome.kind === "error") {
|
|
36284
36465
|
const err = outcome.error;
|
|
36285
36466
|
if (err instanceof ApiError) {
|
|
36286
|
-
process.stderr.write(
|
|
36467
|
+
process.stderr.write(import_picocolors10.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
36287
36468
|
`));
|
|
36288
36469
|
process.exit(1);
|
|
36289
36470
|
}
|
|
@@ -36313,7 +36494,7 @@ async function balance(opts) {
|
|
|
36313
36494
|
}
|
|
36314
36495
|
if (filtered.length === 0) {
|
|
36315
36496
|
process.stdout.write(
|
|
36316
|
-
|
|
36497
|
+
import_picocolors10.default.dim(
|
|
36317
36498
|
chainFilter !== null ? `No balances on chain ${chainFilter}.
|
|
36318
36499
|
` : `No chain balances returned.
|
|
36319
36500
|
`
|
|
@@ -36325,7 +36506,7 @@ async function balance(opts) {
|
|
|
36325
36506
|
const errorLines = [];
|
|
36326
36507
|
for (const c of filtered) {
|
|
36327
36508
|
if (c.error) {
|
|
36328
|
-
errorLines.push(`${c.chainName} ${
|
|
36509
|
+
errorLines.push(`${c.chainName} ${import_picocolors10.default.red(`(read failed: ${c.error})`)}`);
|
|
36329
36510
|
continue;
|
|
36330
36511
|
}
|
|
36331
36512
|
if (c.native.balance > 0) {
|
|
@@ -36346,7 +36527,7 @@ async function balance(opts) {
|
|
|
36346
36527
|
}
|
|
36347
36528
|
}
|
|
36348
36529
|
if (rows.length === 0 && errorLines.length === 0) {
|
|
36349
|
-
process.stdout.write(
|
|
36530
|
+
process.stdout.write(import_picocolors10.default.dim(`All balances are zero.
|
|
36350
36531
|
`));
|
|
36351
36532
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
36352
36533
|
return;
|
|
@@ -36356,7 +36537,7 @@ async function balance(opts) {
|
|
|
36356
36537
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
36357
36538
|
const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
|
|
36358
36539
|
const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
|
|
36359
|
-
process.stdout.write(
|
|
36540
|
+
process.stdout.write(import_picocolors10.default.dim(header) + "\n");
|
|
36360
36541
|
for (const r of rows) {
|
|
36361
36542
|
process.stdout.write(
|
|
36362
36543
|
r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
|
|
@@ -36369,7 +36550,7 @@ async function balance(opts) {
|
|
|
36369
36550
|
`);
|
|
36370
36551
|
}
|
|
36371
36552
|
if (res.fetched_at) {
|
|
36372
|
-
process.stdout.write("\n" +
|
|
36553
|
+
process.stdout.write("\n" + import_picocolors10.default.dim(`Fetched ${res.fetched_at}
|
|
36373
36554
|
`));
|
|
36374
36555
|
}
|
|
36375
36556
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -36382,18 +36563,18 @@ function formatBalance(value, decimals) {
|
|
|
36382
36563
|
}
|
|
36383
36564
|
|
|
36384
36565
|
// src/commands/history.ts
|
|
36385
|
-
var
|
|
36566
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
36386
36567
|
var DEFAULT_LIMIT = 20;
|
|
36387
36568
|
var SERVER_MAX_LIMIT = 100;
|
|
36388
36569
|
async function history(opts) {
|
|
36389
36570
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
36390
36571
|
const resolved = await resolveProfile(requested);
|
|
36391
36572
|
if (!resolved) {
|
|
36392
|
-
process.stderr.write(
|
|
36573
|
+
process.stderr.write(import_picocolors11.default.red("Not logged in. Run agentgates login first.\n"));
|
|
36393
36574
|
process.exit(2);
|
|
36394
36575
|
}
|
|
36395
36576
|
if (resolved.autoSelected) {
|
|
36396
|
-
process.stderr.write(
|
|
36577
|
+
process.stderr.write(import_picocolors11.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
36397
36578
|
`));
|
|
36398
36579
|
}
|
|
36399
36580
|
const { profile, name: profileName } = resolved;
|
|
@@ -36402,14 +36583,14 @@ async function history(opts) {
|
|
|
36402
36583
|
const n = Number(opts.limit);
|
|
36403
36584
|
if (!Number.isFinite(n) || n <= 0 || !Number.isInteger(n)) {
|
|
36404
36585
|
process.stderr.write(
|
|
36405
|
-
|
|
36586
|
+
import_picocolors11.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors11.default.bold(opts.limit)}).
|
|
36406
36587
|
`)
|
|
36407
36588
|
);
|
|
36408
36589
|
process.exit(2);
|
|
36409
36590
|
}
|
|
36410
36591
|
if (n > SERVER_MAX_LIMIT) {
|
|
36411
36592
|
process.stderr.write(
|
|
36412
|
-
|
|
36593
|
+
import_picocolors11.default.red(
|
|
36413
36594
|
`\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n}.
|
|
36414
36595
|
`
|
|
36415
36596
|
)
|
|
@@ -36423,7 +36604,7 @@ async function history(opts) {
|
|
|
36423
36604
|
profile,
|
|
36424
36605
|
profileName,
|
|
36425
36606
|
jsonMode,
|
|
36426
|
-
ttyHeader:
|
|
36607
|
+
ttyHeader: import_picocolors11.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
36427
36608
|
fn: (bearer, origin) => apiFetch(
|
|
36428
36609
|
`/api/history?limit=${encodeURIComponent(String(limit))}`,
|
|
36429
36610
|
{ bearer, origin }
|
|
@@ -36436,14 +36617,14 @@ async function history(opts) {
|
|
|
36436
36617
|
);
|
|
36437
36618
|
process.exit(1);
|
|
36438
36619
|
}
|
|
36439
|
-
process.stderr.write(
|
|
36620
|
+
process.stderr.write(import_picocolors11.default.red(`\u2715 ${outcome.reason}.
|
|
36440
36621
|
`));
|
|
36441
36622
|
process.exit(1);
|
|
36442
36623
|
}
|
|
36443
36624
|
if (outcome.kind === "error") {
|
|
36444
36625
|
const err = outcome.error;
|
|
36445
36626
|
if (err instanceof ApiError) {
|
|
36446
|
-
process.stderr.write(
|
|
36627
|
+
process.stderr.write(import_picocolors11.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
36447
36628
|
`));
|
|
36448
36629
|
process.exit(1);
|
|
36449
36630
|
}
|
|
@@ -36460,7 +36641,7 @@ async function history(opts) {
|
|
|
36460
36641
|
return;
|
|
36461
36642
|
}
|
|
36462
36643
|
if (res.txs.length === 0) {
|
|
36463
|
-
process.stdout.write(
|
|
36644
|
+
process.stdout.write(import_picocolors11.default.dim(`No activity yet.
|
|
36464
36645
|
`));
|
|
36465
36646
|
return;
|
|
36466
36647
|
}
|
|
@@ -36480,7 +36661,7 @@ async function history(opts) {
|
|
|
36480
36661
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
36481
36662
|
const colTo = Math.max(2, ...rows.map((r) => r.to.length));
|
|
36482
36663
|
const header = "When".padEnd(colWhen) + " " + "Chain".padEnd(colChain) + " " + "Type".padEnd(colType) + " " + "Amount".padStart(colAmount) + " " + "Asset".padEnd(colAsset) + " " + "To".padEnd(colTo) + " Hash";
|
|
36483
|
-
process.stdout.write(
|
|
36664
|
+
process.stdout.write(import_picocolors11.default.dim(header) + "\n");
|
|
36484
36665
|
for (const r of rows) {
|
|
36485
36666
|
process.stdout.write(
|
|
36486
36667
|
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"
|
|
@@ -36488,7 +36669,7 @@ async function history(opts) {
|
|
|
36488
36669
|
}
|
|
36489
36670
|
if (res.fetched_at) {
|
|
36490
36671
|
process.stdout.write(
|
|
36491
|
-
"\n" +
|
|
36672
|
+
"\n" + import_picocolors11.default.dim(
|
|
36492
36673
|
`Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
|
|
36493
36674
|
`
|
|
36494
36675
|
)
|
|
@@ -36575,10 +36756,10 @@ function prettyType(activityType, status2) {
|
|
|
36575
36756
|
}
|
|
36576
36757
|
|
|
36577
36758
|
// src/commands/swap.ts
|
|
36578
|
-
var
|
|
36759
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
36579
36760
|
|
|
36580
36761
|
// src/lib/intent-flow.ts
|
|
36581
|
-
var
|
|
36762
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
36582
36763
|
var STREAM_GIVEUP_MS = 10 * 6e4;
|
|
36583
36764
|
var SOLANA_CHAIN_ID2 = 900;
|
|
36584
36765
|
function isBlocked2(r) {
|
|
@@ -36653,7 +36834,7 @@ async function runIntentFlow(opts) {
|
|
|
36653
36834
|
profile: opts.profileName,
|
|
36654
36835
|
jsonMode: opts.jsonMode,
|
|
36655
36836
|
origin: activeProfile.mcpOrigin,
|
|
36656
|
-
ttyHeader:
|
|
36837
|
+
ttyHeader: import_picocolors12.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
36657
36838
|
});
|
|
36658
36839
|
} catch (reloginErr) {
|
|
36659
36840
|
if (opts.jsonMode) {
|
|
@@ -36665,7 +36846,7 @@ async function runIntentFlow(opts) {
|
|
|
36665
36846
|
process.exit(1);
|
|
36666
36847
|
}
|
|
36667
36848
|
process.stderr.write(
|
|
36668
|
-
|
|
36849
|
+
import_picocolors12.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
36669
36850
|
`)
|
|
36670
36851
|
);
|
|
36671
36852
|
process.exit(1);
|
|
@@ -36689,7 +36870,7 @@ async function runIntentFlow(opts) {
|
|
|
36689
36870
|
process.exit(1);
|
|
36690
36871
|
}
|
|
36691
36872
|
process.stderr.write(
|
|
36692
|
-
|
|
36873
|
+
import_picocolors12.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
36693
36874
|
`)
|
|
36694
36875
|
);
|
|
36695
36876
|
process.exit(1);
|
|
@@ -36706,7 +36887,7 @@ async function runIntentFlow(opts) {
|
|
|
36706
36887
|
});
|
|
36707
36888
|
process.exit(1);
|
|
36708
36889
|
}
|
|
36709
|
-
process.stderr.write(
|
|
36890
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
36710
36891
|
`));
|
|
36711
36892
|
process.exit(1);
|
|
36712
36893
|
} else {
|
|
@@ -36728,18 +36909,18 @@ async function runIntentFlow(opts) {
|
|
|
36728
36909
|
});
|
|
36729
36910
|
process.exit(1);
|
|
36730
36911
|
}
|
|
36731
|
-
process.stderr.write(
|
|
36912
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
|
|
36732
36913
|
`));
|
|
36733
36914
|
if (proposed.upgrade_url) {
|
|
36734
36915
|
process.stderr.write(
|
|
36735
36916
|
` Open this to grant access, then re-run the command:
|
|
36736
|
-
${
|
|
36917
|
+
${import_picocolors12.default.cyan(proposed.upgrade_url)}
|
|
36737
36918
|
`
|
|
36738
36919
|
);
|
|
36739
36920
|
}
|
|
36740
36921
|
if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
|
|
36741
36922
|
process.stderr.write(
|
|
36742
|
-
|
|
36923
|
+
import_picocolors12.default.dim(
|
|
36743
36924
|
` Suggested actions:
|
|
36744
36925
|
` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
|
|
36745
36926
|
)
|
|
@@ -36762,8 +36943,8 @@ async function runIntentFlow(opts) {
|
|
|
36762
36943
|
} else {
|
|
36763
36944
|
process.stdout.write(
|
|
36764
36945
|
`
|
|
36765
|
-
${
|
|
36766
|
-
${
|
|
36946
|
+
${import_picocolors12.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
36947
|
+
${import_picocolors12.default.cyan(proposed.approval_url)}
|
|
36767
36948
|
|
|
36768
36949
|
`
|
|
36769
36950
|
);
|
|
@@ -36785,7 +36966,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36785
36966
|
if (opts.jsonMode) {
|
|
36786
36967
|
emitNdjson2({ status: s.status, intent_id: s.approval_id });
|
|
36787
36968
|
} else {
|
|
36788
|
-
process.stdout.write(` ${describeStatus2(s.status)}${
|
|
36969
|
+
process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors12.default.dim("\u2026")}\r`);
|
|
36789
36970
|
}
|
|
36790
36971
|
}
|
|
36791
36972
|
});
|
|
@@ -36799,7 +36980,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36799
36980
|
profile: opts.profileName,
|
|
36800
36981
|
jsonMode: opts.jsonMode,
|
|
36801
36982
|
origin: activeProfile.mcpOrigin,
|
|
36802
|
-
ttyHeader:
|
|
36983
|
+
ttyHeader: import_picocolors12.default.dim(
|
|
36803
36984
|
"Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
|
|
36804
36985
|
)
|
|
36805
36986
|
});
|
|
@@ -36814,7 +36995,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36814
36995
|
process.exit(1);
|
|
36815
36996
|
}
|
|
36816
36997
|
process.stderr.write(
|
|
36817
|
-
"\n" +
|
|
36998
|
+
"\n" + import_picocolors12.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
36818
36999
|
`)
|
|
36819
37000
|
);
|
|
36820
37001
|
process.exit(1);
|
|
@@ -36832,7 +37013,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36832
37013
|
process.exit(1);
|
|
36833
37014
|
}
|
|
36834
37015
|
process.stderr.write(
|
|
36835
|
-
"\n" +
|
|
37016
|
+
"\n" + import_picocolors12.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
36836
37017
|
`)
|
|
36837
37018
|
);
|
|
36838
37019
|
process.exit(1);
|
|
@@ -36848,7 +37029,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36848
37029
|
process.exit(1);
|
|
36849
37030
|
}
|
|
36850
37031
|
process.stderr.write(
|
|
36851
|
-
"\n" +
|
|
37032
|
+
"\n" + import_picocolors12.default.red(`\u2715 Status poll failed: ${err.message}
|
|
36852
37033
|
`)
|
|
36853
37034
|
);
|
|
36854
37035
|
process.exit(1);
|
|
@@ -36889,39 +37070,39 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36889
37070
|
process.stdout.write("\n");
|
|
36890
37071
|
const printLegJournal = () => {
|
|
36891
37072
|
if (legs.length === 0) return;
|
|
36892
|
-
process.stdout.write(
|
|
37073
|
+
process.stdout.write(import_picocolors12.default.bold(" Legs:\n"));
|
|
36893
37074
|
for (const l of legs) {
|
|
36894
|
-
const line = l.status === "mined" ?
|
|
37075
|
+
const line = l.status === "mined" ? import_picocolors12.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors12.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors12.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors12.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors12.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
|
|
36895
37076
|
process.stdout.write(` ${line}
|
|
36896
37077
|
`);
|
|
36897
37078
|
}
|
|
36898
37079
|
};
|
|
36899
37080
|
if (final.status === "mined") {
|
|
36900
|
-
process.stdout.write(
|
|
37081
|
+
process.stdout.write(import_picocolors12.default.green("\u2713 Mined.") + "\n");
|
|
36901
37082
|
if (final.tx_hash) {
|
|
36902
37083
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
36903
37084
|
`);
|
|
36904
37085
|
}
|
|
36905
37086
|
if (explorer) {
|
|
36906
|
-
process.stdout.write(` Explorer ${
|
|
37087
|
+
process.stdout.write(` Explorer ${import_picocolors12.default.cyan(explorer)}
|
|
36907
37088
|
`);
|
|
36908
37089
|
}
|
|
36909
37090
|
printLegJournal();
|
|
36910
37091
|
process.exit(0);
|
|
36911
37092
|
}
|
|
36912
37093
|
if (final.status === "failed" && failure?.message) {
|
|
36913
|
-
process.stderr.write(
|
|
37094
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${failure.message}
|
|
36914
37095
|
`));
|
|
36915
37096
|
if (retryCommand) {
|
|
36916
37097
|
process.stderr.write(` Retry:
|
|
36917
|
-
${
|
|
37098
|
+
${import_picocolors12.default.cyan(retryCommand)}
|
|
36918
37099
|
`);
|
|
36919
37100
|
}
|
|
36920
37101
|
printLegJournal();
|
|
36921
37102
|
process.exit(1);
|
|
36922
37103
|
}
|
|
36923
37104
|
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}`;
|
|
36924
|
-
process.stderr.write(
|
|
37105
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${label}.
|
|
36925
37106
|
`));
|
|
36926
37107
|
printLegJournal();
|
|
36927
37108
|
process.exit(1);
|
|
@@ -36941,7 +37122,7 @@ function isAsset(v) {
|
|
|
36941
37122
|
return ASSET_VALUES.has(v.toLowerCase());
|
|
36942
37123
|
}
|
|
36943
37124
|
function failArg(msg) {
|
|
36944
|
-
process.stderr.write(
|
|
37125
|
+
process.stderr.write(import_picocolors13.default.red(`\u2715 ${msg}
|
|
36945
37126
|
`));
|
|
36946
37127
|
process.exit(2);
|
|
36947
37128
|
}
|
|
@@ -36949,11 +37130,11 @@ async function swap(amount, fromAsset, opts) {
|
|
|
36949
37130
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
36950
37131
|
const resolved = await resolveProfile(requested);
|
|
36951
37132
|
if (!resolved) {
|
|
36952
|
-
process.stderr.write(
|
|
37133
|
+
process.stderr.write(import_picocolors13.default.red("Not logged in. Run agentgates login first.\n"));
|
|
36953
37134
|
process.exit(2);
|
|
36954
37135
|
}
|
|
36955
37136
|
if (resolved.autoSelected) {
|
|
36956
|
-
process.stderr.write(
|
|
37137
|
+
process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
36957
37138
|
`));
|
|
36958
37139
|
}
|
|
36959
37140
|
const { profile, name: profileName } = resolved;
|
|
@@ -36961,12 +37142,12 @@ async function swap(amount, fromAsset, opts) {
|
|
|
36961
37142
|
const jsonMode = opts.json === true || !stdoutIsTty;
|
|
36962
37143
|
const amountNumber = Number(amount);
|
|
36963
37144
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
36964
|
-
failArg(`amount must be a positive number (got ${
|
|
37145
|
+
failArg(`amount must be a positive number (got ${import_picocolors13.default.bold(amount)}).`);
|
|
36965
37146
|
}
|
|
36966
37147
|
const fromAssetNorm = fromAsset.toLowerCase();
|
|
36967
37148
|
if (!isAsset(fromAssetNorm)) {
|
|
36968
37149
|
failArg(
|
|
36969
|
-
`from-asset must be ${
|
|
37150
|
+
`from-asset must be ${import_picocolors13.default.bold("native")} or ${import_picocolors13.default.bold("usdc")} (got ${import_picocolors13.default.bold(fromAsset)}).`
|
|
36970
37151
|
);
|
|
36971
37152
|
}
|
|
36972
37153
|
if (!opts.toAsset) {
|
|
@@ -36975,7 +37156,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
36975
37156
|
const toAssetNorm = opts.toAsset.toLowerCase();
|
|
36976
37157
|
if (!isAsset(toAssetNorm)) {
|
|
36977
37158
|
failArg(
|
|
36978
|
-
`--to-asset must be ${
|
|
37159
|
+
`--to-asset must be ${import_picocolors13.default.bold("native")} or ${import_picocolors13.default.bold("usdc")} (got ${import_picocolors13.default.bold(opts.toAsset)}).`
|
|
36979
37160
|
);
|
|
36980
37161
|
}
|
|
36981
37162
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -37104,9 +37285,9 @@ async function swap(amount, fromAsset, opts) {
|
|
|
37104
37285
|
}
|
|
37105
37286
|
|
|
37106
37287
|
// src/commands/batch.ts
|
|
37107
|
-
var
|
|
37288
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
37108
37289
|
function failArg2(msg) {
|
|
37109
|
-
process.stderr.write(
|
|
37290
|
+
process.stderr.write(import_picocolors14.default.red(`\u2715 ${msg}
|
|
37110
37291
|
`));
|
|
37111
37292
|
process.exit(2);
|
|
37112
37293
|
}
|
|
@@ -37114,7 +37295,7 @@ async function batch(opts) {
|
|
|
37114
37295
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37115
37296
|
const resolved = await resolveProfile(requested);
|
|
37116
37297
|
if (!resolved) {
|
|
37117
|
-
process.stderr.write(
|
|
37298
|
+
process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37118
37299
|
process.exit(2);
|
|
37119
37300
|
}
|
|
37120
37301
|
const { name: profileName, profile } = resolved;
|
|
@@ -37168,14 +37349,14 @@ async function batch(opts) {
|
|
|
37168
37349
|
}
|
|
37169
37350
|
|
|
37170
37351
|
// src/commands/fund-wallet.ts
|
|
37171
|
-
var
|
|
37352
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
37172
37353
|
var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
|
|
37173
37354
|
var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
37174
37355
|
function isAddressTarget(target) {
|
|
37175
37356
|
return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
|
|
37176
37357
|
}
|
|
37177
37358
|
function failArg3(msg) {
|
|
37178
|
-
process.stderr.write(
|
|
37359
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${msg}
|
|
37179
37360
|
`));
|
|
37180
37361
|
process.exit(2);
|
|
37181
37362
|
}
|
|
@@ -37183,7 +37364,7 @@ async function fundWallet(address, opts) {
|
|
|
37183
37364
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37184
37365
|
const resolved = await resolveProfile(requested);
|
|
37185
37366
|
if (!resolved) {
|
|
37186
|
-
process.stderr.write(
|
|
37367
|
+
process.stderr.write(import_picocolors15.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37187
37368
|
process.exit(2);
|
|
37188
37369
|
}
|
|
37189
37370
|
const { name: profileName, profile } = resolved;
|
|
@@ -37260,11 +37441,11 @@ async function fundWallet(address, opts) {
|
|
|
37260
37441
|
}
|
|
37261
37442
|
|
|
37262
37443
|
// src/commands/earn-supply.ts
|
|
37263
|
-
var
|
|
37444
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
37264
37445
|
var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
37265
37446
|
var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
37266
37447
|
function failArg4(msg) {
|
|
37267
|
-
process.stderr.write(
|
|
37448
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${msg}
|
|
37268
37449
|
`));
|
|
37269
37450
|
process.exit(2);
|
|
37270
37451
|
}
|
|
@@ -37272,11 +37453,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
37272
37453
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37273
37454
|
const resolved = await resolveProfile(requested);
|
|
37274
37455
|
if (!resolved) {
|
|
37275
|
-
process.stderr.write(
|
|
37456
|
+
process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37276
37457
|
process.exit(2);
|
|
37277
37458
|
}
|
|
37278
37459
|
if (resolved.autoSelected) {
|
|
37279
|
-
process.stderr.write(
|
|
37460
|
+
process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
37280
37461
|
`));
|
|
37281
37462
|
}
|
|
37282
37463
|
const { profile, name: profileName } = resolved;
|
|
@@ -37284,12 +37465,12 @@ async function earnSupply(amount, asset, opts) {
|
|
|
37284
37465
|
const jsonMode = opts.json === true || !stdoutIsTty;
|
|
37285
37466
|
const amountNumber = Number(amount);
|
|
37286
37467
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
37287
|
-
failArg4(`amount must be a positive number (got ${
|
|
37468
|
+
failArg4(`amount must be a positive number (got ${import_picocolors16.default.bold(amount)}).`);
|
|
37288
37469
|
}
|
|
37289
37470
|
const assetNorm = asset.toLowerCase();
|
|
37290
37471
|
if (!ASSET_VALUES2.has(assetNorm)) {
|
|
37291
37472
|
failArg4(
|
|
37292
|
-
`asset must be ${
|
|
37473
|
+
`asset must be ${import_picocolors16.default.bold("native")} or ${import_picocolors16.default.bold("usdc")} (got ${import_picocolors16.default.bold(asset)}).`
|
|
37293
37474
|
);
|
|
37294
37475
|
}
|
|
37295
37476
|
if (!opts.chain) {
|
|
@@ -37301,7 +37482,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
37301
37482
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
37302
37483
|
if (!PROTOCOLS.has(protocolNorm)) {
|
|
37303
37484
|
failArg4(
|
|
37304
|
-
`--protocol must be ${
|
|
37485
|
+
`--protocol must be ${import_picocolors16.default.bold("aave_v3")} or ${import_picocolors16.default.bold("kamino_lend")} (got ${import_picocolors16.default.bold(opts.protocol)}).`
|
|
37305
37486
|
);
|
|
37306
37487
|
}
|
|
37307
37488
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -37353,11 +37534,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
37353
37534
|
}
|
|
37354
37535
|
|
|
37355
37536
|
// src/commands/earn-withdraw.ts
|
|
37356
|
-
var
|
|
37537
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
37357
37538
|
var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
37358
37539
|
var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
37359
37540
|
function failArg5(msg) {
|
|
37360
|
-
process.stderr.write(
|
|
37541
|
+
process.stderr.write(import_picocolors17.default.red(`\u2715 ${msg}
|
|
37361
37542
|
`));
|
|
37362
37543
|
process.exit(2);
|
|
37363
37544
|
}
|
|
@@ -37365,11 +37546,11 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
37365
37546
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37366
37547
|
const resolved = await resolveProfile(requested);
|
|
37367
37548
|
if (!resolved) {
|
|
37368
|
-
process.stderr.write(
|
|
37549
|
+
process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37369
37550
|
process.exit(2);
|
|
37370
37551
|
}
|
|
37371
37552
|
if (resolved.autoSelected) {
|
|
37372
|
-
process.stderr.write(
|
|
37553
|
+
process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
37373
37554
|
`));
|
|
37374
37555
|
}
|
|
37375
37556
|
const { profile, name: profileName } = resolved;
|
|
@@ -37380,14 +37561,14 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
37380
37561
|
const amountNumber = Number(amountOrMax);
|
|
37381
37562
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
37382
37563
|
failArg5(
|
|
37383
|
-
`<amount-or-max> must be a positive number or the literal string "max" (got ${
|
|
37564
|
+
`<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors17.default.bold(amountOrMax)}).`
|
|
37384
37565
|
);
|
|
37385
37566
|
}
|
|
37386
37567
|
}
|
|
37387
37568
|
const assetNorm = asset.toLowerCase();
|
|
37388
37569
|
if (!ASSET_VALUES3.has(assetNorm)) {
|
|
37389
37570
|
failArg5(
|
|
37390
|
-
`asset must be ${
|
|
37571
|
+
`asset must be ${import_picocolors17.default.bold("native")} or ${import_picocolors17.default.bold("usdc")} (got ${import_picocolors17.default.bold(asset)}).`
|
|
37391
37572
|
);
|
|
37392
37573
|
}
|
|
37393
37574
|
if (!opts.chain) {
|
|
@@ -37399,7 +37580,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
37399
37580
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
37400
37581
|
if (!PROTOCOLS2.has(protocolNorm)) {
|
|
37401
37582
|
failArg5(
|
|
37402
|
-
`--protocol must be ${
|
|
37583
|
+
`--protocol must be ${import_picocolors17.default.bold("aave_v3")} or ${import_picocolors17.default.bold("kamino_lend")} (got ${import_picocolors17.default.bold(opts.protocol)}).`
|
|
37403
37584
|
);
|
|
37404
37585
|
}
|
|
37405
37586
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -37451,7 +37632,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
37451
37632
|
}
|
|
37452
37633
|
|
|
37453
37634
|
// src/commands/eat.ts
|
|
37454
|
-
var
|
|
37635
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
37455
37636
|
function parseLineJson(values) {
|
|
37456
37637
|
const lines = [];
|
|
37457
37638
|
for (const value of values) {
|
|
@@ -37478,11 +37659,11 @@ function parseLineJson(values) {
|
|
|
37478
37659
|
async function loadResolvedProfile(requested) {
|
|
37479
37660
|
const resolved = await resolveProfile(requested);
|
|
37480
37661
|
if (!resolved) {
|
|
37481
|
-
process.stderr.write(
|
|
37662
|
+
process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37482
37663
|
process.exit(2);
|
|
37483
37664
|
}
|
|
37484
37665
|
if (resolved.autoSelected) {
|
|
37485
|
-
process.stderr.write(
|
|
37666
|
+
process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
37486
37667
|
`));
|
|
37487
37668
|
}
|
|
37488
37669
|
return resolved;
|
|
@@ -37493,12 +37674,12 @@ function printResult(res, jsonMode) {
|
|
|
37493
37674
|
return;
|
|
37494
37675
|
}
|
|
37495
37676
|
if (res.blocked) {
|
|
37496
|
-
process.stderr.write(
|
|
37677
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
|
|
37497
37678
|
`));
|
|
37498
37679
|
if (res.upgrade_url) {
|
|
37499
37680
|
process.stderr.write(
|
|
37500
37681
|
` Open this to grant access, then re-run the command:
|
|
37501
|
-
${
|
|
37682
|
+
${import_picocolors18.default.cyan(res.upgrade_url)}
|
|
37502
37683
|
`
|
|
37503
37684
|
);
|
|
37504
37685
|
}
|
|
@@ -37529,7 +37710,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
|
|
|
37529
37710
|
profile: resolved.profile,
|
|
37530
37711
|
profileName: resolved.name,
|
|
37531
37712
|
jsonMode,
|
|
37532
|
-
ttyHeader:
|
|
37713
|
+
ttyHeader: import_picocolors18.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
37533
37714
|
fn: (bearer, origin) => apiFetch(path5, { method: "POST", bearer, origin, body })
|
|
37534
37715
|
});
|
|
37535
37716
|
if (outcome.kind === "auth_failed") {
|
|
@@ -37539,7 +37720,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
|
|
|
37539
37720
|
);
|
|
37540
37721
|
process.exit(1);
|
|
37541
37722
|
}
|
|
37542
|
-
process.stderr.write(
|
|
37723
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${outcome.reason}.
|
|
37543
37724
|
`));
|
|
37544
37725
|
process.exit(1);
|
|
37545
37726
|
}
|
|
@@ -37552,7 +37733,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
|
|
|
37552
37733
|
);
|
|
37553
37734
|
process.exit(1);
|
|
37554
37735
|
}
|
|
37555
|
-
process.stderr.write(
|
|
37736
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
37556
37737
|
`));
|
|
37557
37738
|
process.exit(1);
|
|
37558
37739
|
}
|
|
@@ -37565,7 +37746,7 @@ async function searchFood(opts) {
|
|
|
37565
37746
|
const jsonMode = opts.json === true || process.stdout.isTTY !== true;
|
|
37566
37747
|
if (!opts.location && !opts.name) {
|
|
37567
37748
|
process.stderr.write(
|
|
37568
|
-
|
|
37749
|
+
import_picocolors18.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
|
|
37569
37750
|
);
|
|
37570
37751
|
process.exit(2);
|
|
37571
37752
|
}
|
|
@@ -37586,8 +37767,8 @@ async function menuFood(items, opts) {
|
|
|
37586
37767
|
const jsonMode = opts.json === true || process.stdout.isTTY !== true;
|
|
37587
37768
|
if (!opts.brand || !opts.address) {
|
|
37588
37769
|
process.stderr.write(
|
|
37589
|
-
|
|
37590
|
-
"\u2715 --brand and --address are required \u2014 use the pair a `
|
|
37770
|
+
import_picocolors18.default.red(
|
|
37771
|
+
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
37591
37772
|
)
|
|
37592
37773
|
);
|
|
37593
37774
|
process.exit(2);
|
|
@@ -37606,8 +37787,8 @@ async function orderFood(items, opts) {
|
|
|
37606
37787
|
const jsonMode = opts.json === true || process.stdout.isTTY !== true;
|
|
37607
37788
|
if (!opts.brand || !opts.address) {
|
|
37608
37789
|
process.stderr.write(
|
|
37609
|
-
|
|
37610
|
-
"\u2715 --brand and --address are required \u2014 use the pair a `
|
|
37790
|
+
import_picocolors18.default.red(
|
|
37791
|
+
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
37611
37792
|
)
|
|
37612
37793
|
);
|
|
37613
37794
|
process.exit(2);
|
|
@@ -37616,14 +37797,14 @@ async function orderFood(items, opts) {
|
|
|
37616
37797
|
try {
|
|
37617
37798
|
structuredLines = parseLineJson(opts.lineJson ?? []);
|
|
37618
37799
|
} catch (e) {
|
|
37619
|
-
process.stderr.write(
|
|
37800
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
|
|
37620
37801
|
`));
|
|
37621
37802
|
process.exit(2);
|
|
37622
37803
|
}
|
|
37623
37804
|
const lines = [...items ?? [], ...structuredLines];
|
|
37624
37805
|
if (lines.length === 0) {
|
|
37625
37806
|
process.stderr.write(
|
|
37626
|
-
|
|
37807
|
+
import_picocolors18.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")
|
|
37627
37808
|
);
|
|
37628
37809
|
process.exit(2);
|
|
37629
37810
|
}
|
|
@@ -37657,7 +37838,7 @@ async function orderFood(items, opts) {
|
|
|
37657
37838
|
if (!agentCard.will_attempt) {
|
|
37658
37839
|
if (!jsonMode) {
|
|
37659
37840
|
process.stderr.write(
|
|
37660
|
-
|
|
37841
|
+
import_picocolors18.default.yellow(
|
|
37661
37842
|
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
37662
37843
|
`
|
|
37663
37844
|
)
|
|
@@ -37674,7 +37855,7 @@ async function orderFood(items, opts) {
|
|
|
37674
37855
|
}
|
|
37675
37856
|
if (verdict.status === "paid") {
|
|
37676
37857
|
process.stdout.write(
|
|
37677
|
-
|
|
37858
|
+
import_picocolors18.default.green(
|
|
37678
37859
|
`Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
|
|
37679
37860
|
)
|
|
37680
37861
|
);
|
|
@@ -37682,7 +37863,7 @@ async function orderFood(items, opts) {
|
|
|
37682
37863
|
}
|
|
37683
37864
|
if (verdict.status === "failed") {
|
|
37684
37865
|
process.stderr.write(
|
|
37685
|
-
|
|
37866
|
+
import_picocolors18.default.yellow(
|
|
37686
37867
|
`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.
|
|
37687
37868
|
`
|
|
37688
37869
|
)
|
|
@@ -37692,7 +37873,7 @@ async function orderFood(items, opts) {
|
|
|
37692
37873
|
}
|
|
37693
37874
|
if (verdict.status === "unconfirmed") {
|
|
37694
37875
|
process.stderr.write(
|
|
37695
|
-
|
|
37876
|
+
import_picocolors18.default.red(
|
|
37696
37877
|
"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}
|
|
37697
37878
|
` : "")
|
|
37698
37879
|
)
|
|
@@ -37701,8 +37882,8 @@ async function orderFood(items, opts) {
|
|
|
37701
37882
|
return;
|
|
37702
37883
|
}
|
|
37703
37884
|
process.stderr.write(
|
|
37704
|
-
|
|
37705
|
-
`Still being attempted. Check with:
|
|
37885
|
+
import_picocolors18.default.dim(
|
|
37886
|
+
`Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
|
|
37706
37887
|
)
|
|
37707
37888
|
);
|
|
37708
37889
|
}
|
|
@@ -37726,7 +37907,7 @@ var POLL_BUDGET_MS = 1e5;
|
|
|
37726
37907
|
var POLL_INTERVAL_MS2 = 3500;
|
|
37727
37908
|
async function pollOrderVerdict(orderId, resolved, jsonMode) {
|
|
37728
37909
|
if (!jsonMode) {
|
|
37729
|
-
process.stderr.write(
|
|
37910
|
+
process.stderr.write(import_picocolors18.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
|
|
37730
37911
|
}
|
|
37731
37912
|
const deadline = Date.now() + POLL_BUDGET_MS;
|
|
37732
37913
|
let last = {
|
|
@@ -37796,16 +37977,16 @@ async function statusFood(orderId, opts) {
|
|
|
37796
37977
|
}
|
|
37797
37978
|
|
|
37798
37979
|
// src/commands/bounties.ts
|
|
37799
|
-
var
|
|
37980
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
37800
37981
|
async function withProfile(opts, path5, init) {
|
|
37801
37982
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37802
37983
|
const resolved = await resolveProfile(requested);
|
|
37803
37984
|
if (!resolved) {
|
|
37804
|
-
process.stderr.write(
|
|
37985
|
+
process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37805
37986
|
process.exit(2);
|
|
37806
37987
|
}
|
|
37807
37988
|
if (resolved.autoSelected) {
|
|
37808
|
-
process.stderr.write(
|
|
37989
|
+
process.stderr.write(import_picocolors19.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
37809
37990
|
`));
|
|
37810
37991
|
}
|
|
37811
37992
|
const { profile, name: profileName } = resolved;
|
|
@@ -37814,7 +37995,7 @@ async function withProfile(opts, path5, init) {
|
|
|
37814
37995
|
profile,
|
|
37815
37996
|
profileName,
|
|
37816
37997
|
jsonMode,
|
|
37817
|
-
ttyHeader:
|
|
37998
|
+
ttyHeader: import_picocolors19.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
37818
37999
|
fn: (bearer, origin) => apiFetch(path5, init ? { bearer, origin, method: init.method, body: init.body } : { bearer, origin })
|
|
37819
38000
|
});
|
|
37820
38001
|
if (outcome.kind === "auth_failed") {
|
|
@@ -37822,14 +38003,14 @@ async function withProfile(opts, path5, init) {
|
|
|
37822
38003
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
37823
38004
|
process.exit(1);
|
|
37824
38005
|
}
|
|
37825
|
-
process.stderr.write(
|
|
38006
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${outcome.reason}.
|
|
37826
38007
|
`));
|
|
37827
38008
|
process.exit(1);
|
|
37828
38009
|
}
|
|
37829
38010
|
if (outcome.kind === "error") {
|
|
37830
38011
|
const err = outcome.error;
|
|
37831
38012
|
if (err instanceof ApiError) {
|
|
37832
|
-
process.stderr.write(
|
|
38013
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
37833
38014
|
`));
|
|
37834
38015
|
process.exit(1);
|
|
37835
38016
|
}
|
|
@@ -37843,12 +38024,12 @@ function handleBlocked(res, jsonMode) {
|
|
|
37843
38024
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
37844
38025
|
process.exit(1);
|
|
37845
38026
|
}
|
|
37846
|
-
process.stderr.write(
|
|
38027
|
+
process.stderr.write(import_picocolors19.default.yellow(`
|
|
37847
38028
|
${res.reason ?? "Blocked."}
|
|
37848
38029
|
`));
|
|
37849
38030
|
if (res.upgrade_url) {
|
|
37850
38031
|
process.stderr.write(`
|
|
37851
|
-
${
|
|
38032
|
+
${import_picocolors19.default.bold(res.upgrade_url)}
|
|
37852
38033
|
|
|
37853
38034
|
`);
|
|
37854
38035
|
}
|
|
@@ -37891,14 +38072,14 @@ function printTable(rows) {
|
|
|
37891
38072
|
const cLeft = w("left", 4);
|
|
37892
38073
|
const cSubs = w("subs", 4);
|
|
37893
38074
|
process.stdout.write(
|
|
37894
|
-
|
|
38075
|
+
import_picocolors19.default.dim(
|
|
37895
38076
|
"Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
|
|
37896
38077
|
) + "\n"
|
|
37897
38078
|
);
|
|
37898
38079
|
for (const c of cells) {
|
|
37899
|
-
const title = c.live ?
|
|
38080
|
+
const title = c.live ? import_picocolors19.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
|
|
37900
38081
|
process.stdout.write(
|
|
37901
|
-
|
|
38082
|
+
import_picocolors19.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors19.default.dim(c.id) + "\n"
|
|
37902
38083
|
);
|
|
37903
38084
|
}
|
|
37904
38085
|
}
|
|
@@ -37910,11 +38091,11 @@ async function listBounties(opts) {
|
|
|
37910
38091
|
const min = opts.min !== void 0 ? Number(opts.min) : void 0;
|
|
37911
38092
|
const max = opts.max !== void 0 ? Number(opts.max) : void 0;
|
|
37912
38093
|
if (min !== void 0 && !Number.isFinite(min)) {
|
|
37913
|
-
process.stderr.write(
|
|
38094
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 --min must be a number.\n"));
|
|
37914
38095
|
process.exit(2);
|
|
37915
38096
|
}
|
|
37916
38097
|
if (max !== void 0 && !Number.isFinite(max)) {
|
|
37917
|
-
process.stderr.write(
|
|
38098
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 --max must be a number.\n"));
|
|
37918
38099
|
process.exit(2);
|
|
37919
38100
|
}
|
|
37920
38101
|
rows = rows.filter((r) => {
|
|
@@ -37939,7 +38120,7 @@ async function listBounties(opts) {
|
|
|
37939
38120
|
});
|
|
37940
38121
|
const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
|
|
37941
38122
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
37942
|
-
process.stderr.write(
|
|
38123
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 --limit must be a positive number.\n"));
|
|
37943
38124
|
process.exit(2);
|
|
37944
38125
|
}
|
|
37945
38126
|
const shown = rows.slice(0, limit);
|
|
@@ -37948,14 +38129,14 @@ async function listBounties(opts) {
|
|
|
37948
38129
|
return;
|
|
37949
38130
|
}
|
|
37950
38131
|
if (shown.length === 0) {
|
|
37951
|
-
process.stdout.write(
|
|
38132
|
+
process.stdout.write(import_picocolors19.default.dim("No active bounties match.\n"));
|
|
37952
38133
|
return;
|
|
37953
38134
|
}
|
|
37954
38135
|
printTable(shown);
|
|
37955
38136
|
const clipped = rows.length - shown.length;
|
|
37956
38137
|
process.stdout.write(
|
|
37957
|
-
"\n" +
|
|
37958
|
-
`${shown.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}.
|
|
38138
|
+
"\n" + import_picocolors19.default.dim(
|
|
38139
|
+
`${shown.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
|
|
37959
38140
|
`
|
|
37960
38141
|
)
|
|
37961
38142
|
);
|
|
@@ -37965,7 +38146,7 @@ async function showBounty(id, opts) {
|
|
|
37965
38146
|
const jsonMode = opts.json === true;
|
|
37966
38147
|
const clean = id.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
|
|
37967
38148
|
if (!clean) {
|
|
37968
|
-
process.stderr.write(
|
|
38149
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
|
|
37969
38150
|
process.exit(2);
|
|
37970
38151
|
}
|
|
37971
38152
|
const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean)}`);
|
|
@@ -37976,26 +38157,26 @@ async function showBounty(id, opts) {
|
|
|
37976
38157
|
}
|
|
37977
38158
|
const b = res.bounty;
|
|
37978
38159
|
if (!b) {
|
|
37979
|
-
process.stdout.write(
|
|
38160
|
+
process.stdout.write(import_picocolors19.default.dim("Not found.\n"));
|
|
37980
38161
|
return;
|
|
37981
38162
|
}
|
|
37982
|
-
process.stdout.write("\n" +
|
|
38163
|
+
process.stdout.write("\n" + import_picocolors19.default.bold(b.title) + "\n\n");
|
|
37983
38164
|
process.stdout.write(b.description + "\n\n");
|
|
37984
38165
|
process.stdout.write(
|
|
37985
|
-
|
|
38166
|
+
import_picocolors19.default.bold(fmtAmount(b.amount)) + import_picocolors19.default.dim(" USDC") + import_picocolors19.default.dim(` \xB7 ${chainOf2(b)} \xB7 ${b.status.toLowerCase()}`) + (b.liveNow ? import_picocolors19.default.green(" \xB7 LIVE now") : "") + "\n"
|
|
37986
38167
|
);
|
|
37987
38168
|
if (b.claimsAllowed && b.claimsAllowed > 1) {
|
|
37988
38169
|
const left = Math.max(0, b.claimsAllowed - (b.claimsPaid ?? 0));
|
|
37989
38170
|
process.stdout.write(
|
|
37990
|
-
|
|
38171
|
+
import_picocolors19.default.dim(
|
|
37991
38172
|
`${left} of ${b.claimsAllowed} claims left` + (b.perClaimAmount != null ? `, ${fmtAmount(b.perClaimAmount)} each` : "")
|
|
37992
38173
|
) + "\n"
|
|
37993
38174
|
);
|
|
37994
38175
|
}
|
|
37995
|
-
if (b.evidenceType) process.stdout.write(
|
|
37996
|
-
if (b.expiresAt) process.stdout.write(
|
|
38176
|
+
if (b.evidenceType) process.stdout.write(import_picocolors19.default.dim(`Evidence required: ${b.evidenceType}`) + "\n");
|
|
38177
|
+
if (b.expiresAt) process.stdout.write(import_picocolors19.default.dim(`Expires in ${fmtExpiry(b.expiresAt)}`) + "\n");
|
|
37997
38178
|
if (b.geoLabel && b.geoScope !== "global") {
|
|
37998
|
-
process.stdout.write(
|
|
38179
|
+
process.stdout.write(import_picocolors19.default.dim(`Creator says: ${b.geoLabel}`) + "\n");
|
|
37999
38180
|
}
|
|
38000
38181
|
if (res.url) process.stdout.write("\n" + res.url + "\n");
|
|
38001
38182
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -38013,9 +38194,9 @@ async function myBounties(opts) {
|
|
|
38013
38194
|
}
|
|
38014
38195
|
if (rows.length === 0) {
|
|
38015
38196
|
process.stdout.write(
|
|
38016
|
-
|
|
38197
|
+
import_picocolors19.default.dim(
|
|
38017
38198
|
status2 ? `No bounties of yours are ${status2}.
|
|
38018
|
-
` : "You have not created any bounties yet. `
|
|
38199
|
+
` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
|
|
38019
38200
|
)
|
|
38020
38201
|
);
|
|
38021
38202
|
return;
|
|
@@ -38023,7 +38204,7 @@ async function myBounties(opts) {
|
|
|
38023
38204
|
printTable(rows);
|
|
38024
38205
|
const subs = res.submissions ?? [];
|
|
38025
38206
|
if (subs.length > 0) {
|
|
38026
|
-
process.stdout.write("\n" +
|
|
38207
|
+
process.stdout.write("\n" + import_picocolors19.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
|
|
38027
38208
|
`));
|
|
38028
38209
|
}
|
|
38029
38210
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -38042,19 +38223,19 @@ async function bountyFeed(opts) {
|
|
|
38042
38223
|
}
|
|
38043
38224
|
const subs = res.submissions ?? [];
|
|
38044
38225
|
if (subs.length === 0) {
|
|
38045
|
-
process.stdout.write(
|
|
38226
|
+
process.stdout.write(import_picocolors19.default.dim("Nothing in the feed for that filter.\n"));
|
|
38046
38227
|
return;
|
|
38047
38228
|
}
|
|
38048
38229
|
process.stdout.write(
|
|
38049
|
-
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ?
|
|
38230
|
+
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors19.default.dim(" More available.") : "") + "\n"
|
|
38050
38231
|
);
|
|
38051
|
-
process.stdout.write(
|
|
38232
|
+
process.stdout.write(import_picocolors19.default.dim("Use --json for the full rows.\n"));
|
|
38052
38233
|
}
|
|
38053
38234
|
async function draftBounty(opts) {
|
|
38054
38235
|
const jsonMode = opts.json === true;
|
|
38055
38236
|
const amountNum = Number(opts.amount);
|
|
38056
38237
|
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
38057
|
-
process.stderr.write(
|
|
38238
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 --amount must be a positive number of USDC.\n"));
|
|
38058
38239
|
process.exit(2);
|
|
38059
38240
|
}
|
|
38060
38241
|
const res = await withProfile(opts, "/api/bounties", {
|
|
@@ -38072,20 +38253,20 @@ async function draftBounty(opts) {
|
|
|
38072
38253
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
38073
38254
|
return;
|
|
38074
38255
|
}
|
|
38075
|
-
process.stdout.write("\n" +
|
|
38256
|
+
process.stdout.write("\n" + import_picocolors19.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
|
|
38076
38257
|
|
|
38077
38258
|
`);
|
|
38078
|
-
process.stdout.write(
|
|
38259
|
+
process.stdout.write(import_picocolors19.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
|
|
38079
38260
|
if (res.fund_url) {
|
|
38080
|
-
process.stdout.write("\nFund it here:\n" +
|
|
38081
|
-
process.stdout.write(
|
|
38261
|
+
process.stdout.write("\nFund it here:\n" + import_picocolors19.default.bold(res.fund_url) + "\n\n");
|
|
38262
|
+
process.stdout.write(import_picocolors19.default.dim("Funding happens in your browser with your own wallet.\n"));
|
|
38082
38263
|
}
|
|
38083
38264
|
}
|
|
38084
38265
|
|
|
38085
38266
|
// src/commands/bounty-money.ts
|
|
38086
|
-
var
|
|
38267
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
38087
38268
|
function failArg6(message) {
|
|
38088
|
-
process.stderr.write(
|
|
38269
|
+
process.stderr.write(import_picocolors20.default.red(`${message}
|
|
38089
38270
|
`));
|
|
38090
38271
|
process.exit(2);
|
|
38091
38272
|
}
|
|
@@ -38094,15 +38275,15 @@ async function loadProfileOrExit(requested, jsonMode) {
|
|
|
38094
38275
|
if (!resolved) {
|
|
38095
38276
|
if (jsonMode) {
|
|
38096
38277
|
process.stdout.write(
|
|
38097
|
-
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run
|
|
38278
|
+
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
|
|
38098
38279
|
);
|
|
38099
38280
|
} else {
|
|
38100
|
-
process.stderr.write(
|
|
38281
|
+
process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
|
|
38101
38282
|
}
|
|
38102
38283
|
process.exit(2);
|
|
38103
38284
|
}
|
|
38104
38285
|
if (resolved.autoSelected && !jsonMode) {
|
|
38105
|
-
process.stderr.write(
|
|
38286
|
+
process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
38106
38287
|
`));
|
|
38107
38288
|
}
|
|
38108
38289
|
return { profile: resolved.profile, profileName: resolved.name };
|
|
@@ -38123,7 +38304,7 @@ function resolveMaxUsd(opts, profile, fallbackHint) {
|
|
|
38123
38304
|
async function fundBounty(bountyId, opts) {
|
|
38124
38305
|
const jsonMode = Boolean(opts.json) || !process.stdout.isTTY;
|
|
38125
38306
|
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode);
|
|
38126
|
-
const maxUsd = resolveMaxUsd(opts, profile, "
|
|
38307
|
+
const maxUsd = resolveMaxUsd(opts, profile, "agentgates fund");
|
|
38127
38308
|
return runIntentFlow({
|
|
38128
38309
|
endpoint: "/api/intents/propose-fund-bounty",
|
|
38129
38310
|
body: {
|
|
@@ -38152,7 +38333,7 @@ async function tipBounty(bountyId, amount, opts) {
|
|
|
38152
38333
|
failArg6(`amount must be a positive USDC number (got ${amount}).`);
|
|
38153
38334
|
}
|
|
38154
38335
|
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode);
|
|
38155
|
-
const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "
|
|
38336
|
+
const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "agentgates tip") : Math.ceil(amt * 1.01 * 100) / 100;
|
|
38156
38337
|
return runIntentFlow({
|
|
38157
38338
|
endpoint: "/api/intents/propose-tip",
|
|
38158
38339
|
body: {
|
|
@@ -38182,7 +38363,7 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
38182
38363
|
failArg6(`--months must be 1, 3 or 12 (got ${opts.months}). Prepaid periods only \u2014 no auto-renew exists.`);
|
|
38183
38364
|
}
|
|
38184
38365
|
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode);
|
|
38185
|
-
const maxUsd = resolveMaxUsd(opts, profile, "
|
|
38366
|
+
const maxUsd = resolveMaxUsd(opts, profile, "agentgates subscribe");
|
|
38186
38367
|
return runIntentFlow({
|
|
38187
38368
|
endpoint: "/api/intents/propose-subscribe",
|
|
38188
38369
|
body: {
|
|
@@ -38207,16 +38388,16 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
38207
38388
|
}
|
|
38208
38389
|
|
|
38209
38390
|
// src/commands/bounty-work.ts
|
|
38210
|
-
var
|
|
38391
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
38211
38392
|
async function runWork(path5, body, opts) {
|
|
38212
38393
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
38213
38394
|
const resolved = await resolveProfile(requested);
|
|
38214
38395
|
if (!resolved) {
|
|
38215
|
-
process.stderr.write(
|
|
38396
|
+
process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
|
|
38216
38397
|
process.exit(2);
|
|
38217
38398
|
}
|
|
38218
38399
|
if (resolved.autoSelected) {
|
|
38219
|
-
process.stderr.write(
|
|
38400
|
+
process.stderr.write(import_picocolors21.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
38220
38401
|
`));
|
|
38221
38402
|
}
|
|
38222
38403
|
const jsonMode = opts.json === true;
|
|
@@ -38224,7 +38405,7 @@ async function runWork(path5, body, opts) {
|
|
|
38224
38405
|
profile: resolved.profile,
|
|
38225
38406
|
profileName: resolved.name,
|
|
38226
38407
|
jsonMode,
|
|
38227
|
-
ttyHeader:
|
|
38408
|
+
ttyHeader: import_picocolors21.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
38228
38409
|
fn: (bearer, origin) => apiFetch(path5, { bearer, origin, method: "POST", body })
|
|
38229
38410
|
});
|
|
38230
38411
|
if (outcome.kind === "auth_failed") {
|
|
@@ -38232,7 +38413,7 @@ async function runWork(path5, body, opts) {
|
|
|
38232
38413
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
38233
38414
|
process.exit(1);
|
|
38234
38415
|
}
|
|
38235
|
-
process.stderr.write(
|
|
38416
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${outcome.reason}.
|
|
38236
38417
|
`));
|
|
38237
38418
|
process.exit(1);
|
|
38238
38419
|
}
|
|
@@ -38242,7 +38423,7 @@ async function runWork(path5, body, opts) {
|
|
|
38242
38423
|
if (jsonMode) {
|
|
38243
38424
|
process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
|
|
38244
38425
|
} else {
|
|
38245
|
-
process.stderr.write(
|
|
38426
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
38246
38427
|
`));
|
|
38247
38428
|
}
|
|
38248
38429
|
process.exit(1);
|
|
@@ -38255,11 +38436,11 @@ async function runWork(path5, body, opts) {
|
|
|
38255
38436
|
process.stdout.write(JSON.stringify({ ok: false, ...data }) + "\n");
|
|
38256
38437
|
process.exit(1);
|
|
38257
38438
|
}
|
|
38258
|
-
process.stderr.write(
|
|
38439
|
+
process.stderr.write(import_picocolors21.default.yellow(`
|
|
38259
38440
|
${data.reason ?? "Blocked."}
|
|
38260
38441
|
`));
|
|
38261
38442
|
if (data.upgrade_url) process.stderr.write(`
|
|
38262
|
-
${
|
|
38443
|
+
${import_picocolors21.default.bold(data.upgrade_url)}
|
|
38263
38444
|
|
|
38264
38445
|
`);
|
|
38265
38446
|
process.exit(1);
|
|
@@ -38268,7 +38449,7 @@ ${import_picocolors18.default.bold(data.upgrade_url)}
|
|
|
38268
38449
|
if (jsonMode) {
|
|
38269
38450
|
process.stdout.write(JSON.stringify({ ok: false, error: data.error }) + "\n");
|
|
38270
38451
|
} else {
|
|
38271
|
-
process.stderr.write(
|
|
38452
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${data.error}
|
|
38272
38453
|
`));
|
|
38273
38454
|
}
|
|
38274
38455
|
process.exit(1);
|
|
@@ -38311,7 +38492,7 @@ async function bountyRetention(bountyId, opts) {
|
|
|
38311
38492
|
}
|
|
38312
38493
|
|
|
38313
38494
|
// src/commands/bounty-deliver.ts
|
|
38314
|
-
var
|
|
38495
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
38315
38496
|
import { spawn } from "node:child_process";
|
|
38316
38497
|
var FLUSH_MS = 400;
|
|
38317
38498
|
var FLUSH_BYTES = 2048;
|
|
@@ -38320,11 +38501,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
38320
38501
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
38321
38502
|
const resolved = await resolveProfile(requested);
|
|
38322
38503
|
if (!resolved) {
|
|
38323
|
-
process.stderr.write(
|
|
38504
|
+
process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
|
|
38324
38505
|
process.exit(2);
|
|
38325
38506
|
}
|
|
38326
38507
|
if (resolved.autoSelected && !jsonMode) {
|
|
38327
|
-
process.stderr.write(
|
|
38508
|
+
process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
38328
38509
|
`));
|
|
38329
38510
|
}
|
|
38330
38511
|
const post = async (path5, body) => {
|
|
@@ -38332,7 +38513,7 @@ async function deliver(bountyId, command, opts) {
|
|
|
38332
38513
|
profile: resolved.profile,
|
|
38333
38514
|
profileName: resolved.name,
|
|
38334
38515
|
jsonMode,
|
|
38335
|
-
ttyHeader:
|
|
38516
|
+
ttyHeader: import_picocolors22.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
38336
38517
|
fn: (bearer, origin) => apiFetch(path5, { bearer, origin, method: "POST", body })
|
|
38337
38518
|
});
|
|
38338
38519
|
if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
|
|
@@ -38343,11 +38524,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
38343
38524
|
if (jsonMode) {
|
|
38344
38525
|
process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data ?? {} }) + "\n");
|
|
38345
38526
|
} else {
|
|
38346
|
-
process.stderr.write(
|
|
38527
|
+
process.stderr.write(import_picocolors22.default.red(`
|
|
38347
38528
|
\u2715 ${msg}
|
|
38348
38529
|
`));
|
|
38349
38530
|
if (data?.upgrade_url) process.stderr.write(`
|
|
38350
|
-
${
|
|
38531
|
+
${import_picocolors22.default.bold(data.upgrade_url)}
|
|
38351
38532
|
|
|
38352
38533
|
`);
|
|
38353
38534
|
}
|
|
@@ -38372,7 +38553,7 @@ ${import_picocolors19.default.bold(data.upgrade_url)}
|
|
|
38372
38553
|
if (!runId) return void die("The service opened a run but did not name it.");
|
|
38373
38554
|
if (!jsonMode) {
|
|
38374
38555
|
process.stderr.write(
|
|
38375
|
-
|
|
38556
|
+
import_picocolors22.default.bold("\n\u25CF LIVE ") + import_picocolors22.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors22.default.dim(` ${started.url ?? ""}
|
|
38376
38557
|
|
|
38377
38558
|
`)
|
|
38378
38559
|
);
|
|
@@ -38424,10 +38605,10 @@ ${import_picocolors19.default.bold(data.upgrade_url)}
|
|
|
38424
38605
|
child.stdout.on("data", (d) => consume(d));
|
|
38425
38606
|
child.stderr.setEncoding("utf8");
|
|
38426
38607
|
child.stderr.on("data", (d) => {
|
|
38427
|
-
if (!jsonMode) process.stderr.write(
|
|
38608
|
+
if (!jsonMode) process.stderr.write(import_picocolors22.default.dim(d));
|
|
38428
38609
|
});
|
|
38429
38610
|
child.on("error", (err) => {
|
|
38430
|
-
process.stderr.write(
|
|
38611
|
+
process.stderr.write(import_picocolors22.default.red(`
|
|
38431
38612
|
\u2715 Could not run ${command[0]}: ${err.message}
|
|
38432
38613
|
`));
|
|
38433
38614
|
resolve(127);
|
|
@@ -38464,14 +38645,14 @@ ${import_picocolors19.default.bold(data.upgrade_url)}
|
|
|
38464
38645
|
}
|
|
38465
38646
|
if (appendFailure) {
|
|
38466
38647
|
process.stderr.write(
|
|
38467
|
-
|
|
38648
|
+
import_picocolors22.default.yellow(`
|
|
38468
38649
|
! Some output did not reach the page: ${appendFailure}
|
|
38469
|
-
`) +
|
|
38650
|
+
`) + import_picocolors22.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
|
|
38470
38651
|
);
|
|
38471
38652
|
}
|
|
38472
38653
|
if (exitCode) {
|
|
38473
38654
|
process.stderr.write(
|
|
38474
|
-
|
|
38655
|
+
import_picocolors22.default.yellow(`
|
|
38475
38656
|
! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
|
|
38476
38657
|
`)
|
|
38477
38658
|
);
|
|
@@ -38481,7 +38662,7 @@ ${import_picocolors19.default.bold(data.upgrade_url)}
|
|
|
38481
38662
|
}
|
|
38482
38663
|
|
|
38483
38664
|
// src/commands/trade.ts
|
|
38484
|
-
var
|
|
38665
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
38485
38666
|
|
|
38486
38667
|
// src/lib/trade-sol.ts
|
|
38487
38668
|
var import_web3 = __toESM(require_index_cjs(), 1);
|
|
@@ -38847,21 +39028,21 @@ function fail(message, json) {
|
|
|
38847
39028
|
if (json) {
|
|
38848
39029
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
38849
39030
|
} else {
|
|
38850
|
-
process.stderr.write(
|
|
39031
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${message}
|
|
38851
39032
|
`));
|
|
38852
39033
|
}
|
|
38853
39034
|
process.exit(1);
|
|
38854
39035
|
}
|
|
38855
39036
|
async function withContext(opts, fn) {
|
|
38856
39037
|
try {
|
|
38857
|
-
const
|
|
38858
|
-
return await fn(
|
|
39038
|
+
const ctx2 = await resolveTradeContext();
|
|
39039
|
+
return await fn(ctx2);
|
|
38859
39040
|
} catch (err) {
|
|
38860
39041
|
fail(err.message, opts.json);
|
|
38861
39042
|
}
|
|
38862
39043
|
}
|
|
38863
|
-
function servedFloorUnits(
|
|
38864
|
-
const served =
|
|
39044
|
+
function servedFloorUnits(ctx2) {
|
|
39045
|
+
const served = ctx2.config.trading?.minTradeUsdc;
|
|
38865
39046
|
if (typeof served !== "number" || !Number.isFinite(served) || served <= 0) return null;
|
|
38866
39047
|
return { units: BigInt(Math.round(served * 1e6)), usdc: served };
|
|
38867
39048
|
}
|
|
@@ -38887,30 +39068,30 @@ async function tradeKey(opts) {
|
|
|
38887
39068
|
}
|
|
38888
39069
|
}
|
|
38889
39070
|
async function tradeStatus(opts) {
|
|
38890
|
-
await withContext(opts, async (
|
|
39071
|
+
await withContext(opts, async (ctx2) => {
|
|
38891
39072
|
const key = await loadTradeKey();
|
|
38892
39073
|
let usdc = null;
|
|
38893
39074
|
let coin = null;
|
|
38894
39075
|
if (key) {
|
|
38895
39076
|
const connection = rpcConnection();
|
|
38896
|
-
usdc = await readTokenBalance(connection, key.state.address,
|
|
39077
|
+
usdc = await readTokenBalance(connection, key.state.address, ctx2.chain.usdcMint);
|
|
38897
39078
|
if (opts.coin) {
|
|
38898
39079
|
const resolved = await resolveCoin(opts.coin);
|
|
38899
39080
|
const bal = await readTokenBalance(connection, key.state.address, resolved.mint);
|
|
38900
39081
|
if (bal) coin = { ...resolved, ...bal };
|
|
38901
39082
|
}
|
|
38902
39083
|
}
|
|
38903
|
-
const floor = servedFloorUnits(
|
|
39084
|
+
const floor = servedFloorUnits(ctx2);
|
|
38904
39085
|
if (opts.json) {
|
|
38905
39086
|
process.stdout.write(
|
|
38906
39087
|
JSON.stringify({
|
|
38907
39088
|
ok: true,
|
|
38908
|
-
chainId:
|
|
38909
|
-
program:
|
|
38910
|
-
usdcMint:
|
|
38911
|
-
feePayer:
|
|
39089
|
+
chainId: ctx2.chainId,
|
|
39090
|
+
program: ctx2.chain.program,
|
|
39091
|
+
usdcMint: ctx2.chain.usdcMint,
|
|
39092
|
+
feePayer: ctx2.chain.feePayer ?? null,
|
|
38912
39093
|
minTradeUsdc: floor?.usdc ?? null,
|
|
38913
|
-
defaultSlippageBps:
|
|
39094
|
+
defaultSlippageBps: ctx2.config.defaultSlippageBps ?? null,
|
|
38914
39095
|
rpc: rpcUrl(),
|
|
38915
39096
|
address: key?.state.address ?? null,
|
|
38916
39097
|
usdc: usdc ? formatUnits(usdc.units, usdc.decimals) : null,
|
|
@@ -38920,12 +39101,12 @@ async function tradeStatus(opts) {
|
|
|
38920
39101
|
return;
|
|
38921
39102
|
}
|
|
38922
39103
|
const lines = [];
|
|
38923
|
-
lines.push(`Launch trading (Solana devnet, chain ${
|
|
38924
|
-
lines.push(`Curve program: ${
|
|
39104
|
+
lines.push(`Launch trading (Solana devnet, chain ${ctx2.chainId})`);
|
|
39105
|
+
lines.push(`Curve program: ${ctx2.chain.program}`);
|
|
38925
39106
|
if (floor) lines.push(`Buy floor: $${floor.usdc} (served by launch-config)`);
|
|
38926
39107
|
if (!key) {
|
|
38927
39108
|
lines.push("No agent trading key yet. Create one:");
|
|
38928
|
-
lines.push("
|
|
39109
|
+
lines.push(" agentgates trade key");
|
|
38929
39110
|
} else {
|
|
38930
39111
|
lines.push(`Trade key: ${key.state.address}`);
|
|
38931
39112
|
lines.push(`USDC: ${usdc ? formatUnits(usdc.units, usdc.decimals) : "(unreadable right now \u2014 RPC did not answer; not zero)"}`);
|
|
@@ -38935,7 +39116,7 @@ async function tradeStatus(opts) {
|
|
|
38935
39116
|
});
|
|
38936
39117
|
}
|
|
38937
39118
|
async function tradeQuote(coinArg, amount, opts) {
|
|
38938
|
-
await withContext(opts, async (
|
|
39119
|
+
await withContext(opts, async (ctx2) => {
|
|
38939
39120
|
const side = opts.side === "sell" ? "sell" : "buy";
|
|
38940
39121
|
const coin = await resolveCoin(coinArg);
|
|
38941
39122
|
const amountNumber = Number(amount);
|
|
@@ -38956,13 +39137,13 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
38956
39137
|
if (!res.ok || !body) {
|
|
38957
39138
|
fail(`Quote failed: ${body?.error ?? `HTTP ${res.status}`}`, opts.json);
|
|
38958
39139
|
}
|
|
38959
|
-
const floor = servedFloorUnits(
|
|
39140
|
+
const floor = servedFloorUnits(ctx2);
|
|
38960
39141
|
const belowFloor = side === "buy" && floor !== null && parseDecimalToUnits(amount, USDC_DECIMALS, "Amount") < floor.units;
|
|
38961
39142
|
if (opts.json) {
|
|
38962
39143
|
process.stdout.write(
|
|
38963
39144
|
JSON.stringify({
|
|
38964
39145
|
ok: true,
|
|
38965
|
-
chainId:
|
|
39146
|
+
chainId: ctx2.chainId,
|
|
38966
39147
|
coin: coin.mint,
|
|
38967
39148
|
symbol: coin.symbol,
|
|
38968
39149
|
side,
|
|
@@ -38979,7 +39160,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
38979
39160
|
return;
|
|
38980
39161
|
}
|
|
38981
39162
|
const lines = [
|
|
38982
|
-
`${side === "buy" ? "Buy" : "Sell"} quote on ${coin.symbol ?? coin.mint} (chain ${
|
|
39163
|
+
`${side === "buy" ? "Buy" : "Sell"} quote on ${coin.symbol ?? coin.mint} (chain ${ctx2.chainId})`,
|
|
38983
39164
|
side === "buy" ? `In: ${amount} USDC` : `In: ${amount} coins`,
|
|
38984
39165
|
`Out: ${body.out ?? "(unavailable)"} ${side === "buy" ? "coins" : "USDC"}`,
|
|
38985
39166
|
`Fee: ${body.feeUsdc ?? "?"} USDC impact ${body.priceImpactBps ?? "?"} bps`
|
|
@@ -38990,15 +39171,15 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
38990
39171
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
38991
39172
|
});
|
|
38992
39173
|
}
|
|
38993
|
-
async function reportTrade(
|
|
39174
|
+
async function reportTrade(ctx2, opts, args) {
|
|
38994
39175
|
const connection = rpcConnection();
|
|
38995
|
-
const usdc = await readTokenBalance(connection, args.address,
|
|
39176
|
+
const usdc = await readTokenBalance(connection, args.address, ctx2.chain.usdcMint);
|
|
38996
39177
|
const coinBal = await readTokenBalance(connection, args.address, args.coin.mint);
|
|
38997
39178
|
if (opts.json) {
|
|
38998
39179
|
process.stdout.write(
|
|
38999
39180
|
JSON.stringify({
|
|
39000
39181
|
ok: true,
|
|
39001
|
-
chainId:
|
|
39182
|
+
chainId: ctx2.chainId,
|
|
39002
39183
|
side: args.side,
|
|
39003
39184
|
coin: args.coin.mint,
|
|
39004
39185
|
symbol: args.coin.symbol,
|
|
@@ -39023,7 +39204,7 @@ async function reportTrade(ctx, opts, args) {
|
|
|
39023
39204
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
39024
39205
|
}
|
|
39025
39206
|
async function tradeBuy(coinArg, amount, opts) {
|
|
39026
|
-
await withContext(opts, async (
|
|
39207
|
+
await withContext(opts, async (ctx2) => {
|
|
39027
39208
|
const coin = await resolveCoin(coinArg);
|
|
39028
39209
|
let units;
|
|
39029
39210
|
try {
|
|
@@ -39032,24 +39213,24 @@ async function tradeBuy(coinArg, amount, opts) {
|
|
|
39032
39213
|
fail(err.message, opts.json);
|
|
39033
39214
|
}
|
|
39034
39215
|
if (units <= 0n) fail("Buy amount must be above zero.", opts.json);
|
|
39035
|
-
const floor = servedFloorUnits(
|
|
39216
|
+
const floor = servedFloorUnits(ctx2);
|
|
39036
39217
|
if (floor && units < floor.units) {
|
|
39037
39218
|
fail(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
39038
39219
|
}
|
|
39039
39220
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
39040
39221
|
if (created && !opts.json) {
|
|
39041
|
-
process.stderr.write(
|
|
39222
|
+
process.stderr.write(import_picocolors23.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
39042
39223
|
`));
|
|
39043
39224
|
}
|
|
39044
|
-
const result = await runTrade({ ctx, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
39045
|
-
await reportTrade(
|
|
39225
|
+
const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
39226
|
+
await reportTrade(ctx2, opts, { side: "buy", coin, address: state.address, amount, result });
|
|
39046
39227
|
});
|
|
39047
39228
|
}
|
|
39048
39229
|
async function tradeSell(coinArg, amount, opts) {
|
|
39049
|
-
await withContext(opts, async (
|
|
39230
|
+
await withContext(opts, async (ctx2) => {
|
|
39050
39231
|
const coin = await resolveCoin(coinArg);
|
|
39051
39232
|
const key = await loadTradeKey();
|
|
39052
|
-
if (!key) fail("No agent trading key yet (nothing to sell with). Run:
|
|
39233
|
+
if (!key) fail("No agent trading key yet (nothing to sell with). Run: agentgates trade key", opts.json);
|
|
39053
39234
|
let sellAmount = amount.trim();
|
|
39054
39235
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
39055
39236
|
if (sellAmount === "all" || pct) {
|
|
@@ -39067,8 +39248,8 @@ async function tradeSell(coinArg, amount, opts) {
|
|
|
39067
39248
|
} else if (!/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
39068
39249
|
fail(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
39069
39250
|
}
|
|
39070
|
-
const result = await runTrade({ ctx, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
|
|
39071
|
-
await reportTrade(
|
|
39251
|
+
const result = await runTrade({ ctx: ctx2, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
|
|
39252
|
+
await reportTrade(ctx2, opts, { side: "sell", coin, address: key.state.address, amount: sellAmount, result });
|
|
39072
39253
|
});
|
|
39073
39254
|
}
|
|
39074
39255
|
function describeOrder(o) {
|
|
@@ -39078,7 +39259,7 @@ function describeOrder(o) {
|
|
|
39078
39259
|
return `${o.id} ${o.kind} ${amount} ${trigger} ${o.status}${tail} expires ${o.expiresAt}`;
|
|
39079
39260
|
}
|
|
39080
39261
|
async function tradeOrderPlace(coinArg, opts) {
|
|
39081
|
-
await withContext(opts, async (
|
|
39262
|
+
await withContext(opts, async (ctx2) => {
|
|
39082
39263
|
if (opts.buy === void 0 === (opts.sell === void 0)) {
|
|
39083
39264
|
fail("Pass exactly one of --buy <usdc> or --sell <amount|N%|all>.", opts.json);
|
|
39084
39265
|
}
|
|
@@ -39092,7 +39273,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
39092
39273
|
if (opts.mcap && !opts.at) fail("--mcap qualifies --at.", opts.json);
|
|
39093
39274
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
39094
39275
|
if (created && !opts.json) {
|
|
39095
|
-
process.stderr.write(
|
|
39276
|
+
process.stderr.write(import_picocolors23.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
39096
39277
|
`));
|
|
39097
39278
|
}
|
|
39098
39279
|
let amount;
|
|
@@ -39103,7 +39284,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
39103
39284
|
} catch (err) {
|
|
39104
39285
|
fail(err.message, opts.json);
|
|
39105
39286
|
}
|
|
39106
|
-
const floor = servedFloorUnits(
|
|
39287
|
+
const floor = servedFloorUnits(ctx2);
|
|
39107
39288
|
if (floor && units < floor.units) {
|
|
39108
39289
|
fail(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
39109
39290
|
}
|
|
@@ -39145,14 +39326,14 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
39145
39326
|
} : {},
|
|
39146
39327
|
...expiresInDays !== void 0 ? { expiresInDays } : {}
|
|
39147
39328
|
});
|
|
39148
|
-
const signed = signPreparedOrder(prepared, keypair,
|
|
39329
|
+
const signed = signPreparedOrder(prepared, keypair, ctx2.chain);
|
|
39149
39330
|
const order = await placeOrder({
|
|
39150
39331
|
nonceAccount: prepared.nonceAccount,
|
|
39151
39332
|
signer: state.address,
|
|
39152
39333
|
signedTransaction: signed.serialize({ requireAllSignatures: false }).toString("base64")
|
|
39153
39334
|
});
|
|
39154
39335
|
if (opts.json) {
|
|
39155
|
-
process.stdout.write(JSON.stringify({ ok: true, chainId:
|
|
39336
|
+
process.stdout.write(JSON.stringify({ ok: true, chainId: ctx2.chainId, coin: coin.mint, symbol: coin.symbol, order, nonceAccount: prepared.nonceAccount }) + "\n");
|
|
39156
39337
|
return;
|
|
39157
39338
|
}
|
|
39158
39339
|
process.stdout.write(
|
|
@@ -39164,13 +39345,13 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
39164
39345
|
});
|
|
39165
39346
|
}
|
|
39166
39347
|
async function tradeOrdersList(opts) {
|
|
39167
|
-
await withContext(opts, async (
|
|
39348
|
+
await withContext(opts, async (ctx2) => {
|
|
39168
39349
|
const key = await loadTradeKey();
|
|
39169
|
-
if (!key) fail("No agent trading key yet. Run:
|
|
39350
|
+
if (!key) fail("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
39170
39351
|
const token = opts.coin ? (await resolveCoin(opts.coin)).mint : void 0;
|
|
39171
39352
|
const res = await listOrders(key.state.address, token);
|
|
39172
39353
|
if (opts.json) {
|
|
39173
|
-
process.stdout.write(JSON.stringify({ ok: true, chainId:
|
|
39354
|
+
process.stdout.write(JSON.stringify({ ok: true, chainId: ctx2.chainId, address: key.state.address, openCount: res.openCount, orders: res.orders }) + "\n");
|
|
39174
39355
|
return;
|
|
39175
39356
|
}
|
|
39176
39357
|
if (!res.orders?.length) {
|
|
@@ -39186,7 +39367,7 @@ async function tradeOrdersList(opts) {
|
|
|
39186
39367
|
async function tradeOrderCancel(id, opts) {
|
|
39187
39368
|
await withContext(opts, async (_ctx) => {
|
|
39188
39369
|
const key = await loadTradeKey();
|
|
39189
|
-
if (!key) fail("No agent trading key yet. Run:
|
|
39370
|
+
if (!key) fail("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
39190
39371
|
try {
|
|
39191
39372
|
await cancelOrder(id, key.state.address);
|
|
39192
39373
|
} catch (err) {
|
|
@@ -39207,9 +39388,9 @@ async function tradeOrderCancel(id, opts) {
|
|
|
39207
39388
|
});
|
|
39208
39389
|
}
|
|
39209
39390
|
async function tradePositions(opts) {
|
|
39210
|
-
await withContext(opts, async (
|
|
39391
|
+
await withContext(opts, async (ctx2) => {
|
|
39211
39392
|
const key = await loadTradeKey();
|
|
39212
|
-
if (!key) fail("No agent trading key yet. Run:
|
|
39393
|
+
if (!key) fail("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
39213
39394
|
let body;
|
|
39214
39395
|
try {
|
|
39215
39396
|
body = await relayGet(`/launch-portfolio?address=${encodeURIComponent(key.state.address)}`);
|
|
@@ -39222,7 +39403,7 @@ async function tradePositions(opts) {
|
|
|
39222
39403
|
process.stdout.write(
|
|
39223
39404
|
JSON.stringify({
|
|
39224
39405
|
ok: true,
|
|
39225
|
-
chainId:
|
|
39406
|
+
chainId: ctx2.chainId,
|
|
39226
39407
|
address: key.state.address,
|
|
39227
39408
|
positions: rows.map((t) => ({
|
|
39228
39409
|
coin: t.address,
|
|
@@ -39245,7 +39426,7 @@ async function tradePositions(opts) {
|
|
|
39245
39426
|
` + AI_DIRECTIVE + "\n");
|
|
39246
39427
|
return;
|
|
39247
39428
|
}
|
|
39248
|
-
const lines = [`Positions for ${key.state.address} (chain ${
|
|
39429
|
+
const lines = [`Positions for ${key.state.address} (chain ${ctx2.chainId}):`];
|
|
39249
39430
|
for (const t of rows) {
|
|
39250
39431
|
const p = t.position ?? {};
|
|
39251
39432
|
lines.push(
|
|
@@ -39257,7 +39438,7 @@ async function tradePositions(opts) {
|
|
|
39257
39438
|
}
|
|
39258
39439
|
|
|
39259
39440
|
// src/commands/desk.ts
|
|
39260
|
-
var
|
|
39441
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
39261
39442
|
|
|
39262
39443
|
// src/lib/desk-sol.ts
|
|
39263
39444
|
var import_web32 = __toESM(require_index_cjs(), 1);
|
|
@@ -39265,14 +39446,14 @@ import { promises as fs8 } from "node:fs";
|
|
|
39265
39446
|
import * as path4 from "node:path";
|
|
39266
39447
|
import * as os4 from "node:os";
|
|
39267
39448
|
async function resolveDeskContext() {
|
|
39268
|
-
const
|
|
39269
|
-
const desk2 =
|
|
39449
|
+
const ctx2 = await resolveTradeContext();
|
|
39450
|
+
const desk2 = ctx2.chain.desk;
|
|
39270
39451
|
if (!desk2) {
|
|
39271
39452
|
throw new Error(
|
|
39272
39453
|
`launch-config serves no desk program for chain ${TRADE_CHAIN_ID}; the desk lane is not armed.`
|
|
39273
39454
|
);
|
|
39274
39455
|
}
|
|
39275
|
-
return { ...
|
|
39456
|
+
return { ...ctx2, desk: desk2 };
|
|
39276
39457
|
}
|
|
39277
39458
|
function deskSessionPath() {
|
|
39278
39459
|
return path4.join(os4.homedir(), ".agentgates", "desk-session-sol.json");
|
|
@@ -39336,7 +39517,7 @@ async function prepareDeskOp(body) {
|
|
|
39336
39517
|
function signDeskTemplate(prepared, keypair, chain, role) {
|
|
39337
39518
|
if (prepared.signWith !== keypair.publicKey.toBase58()) {
|
|
39338
39519
|
throw new Error(
|
|
39339
|
-
role === "session" ? `The desk's registered session key is ${prepared.signWith}; this terminal holds ${keypair.publicKey.toBase58()}. Re-register:
|
|
39520
|
+
role === "session" ? `The desk's registered session key is ${prepared.signWith}; this terminal holds ${keypair.publicKey.toBase58()}. Re-register: agentgates desk session register --cap <usdc> --minutes <n>` : `The prepared template names signer ${prepared.signWith}, not this terminal's ${role} key.`
|
|
39340
39521
|
);
|
|
39341
39522
|
}
|
|
39342
39523
|
if (chain.feePayer && prepared.feePayer !== chain.feePayer) {
|
|
@@ -39431,28 +39612,28 @@ function fail2(message, json) {
|
|
|
39431
39612
|
if (json) {
|
|
39432
39613
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
39433
39614
|
} else {
|
|
39434
|
-
process.stderr.write(
|
|
39615
|
+
process.stderr.write(import_picocolors24.default.red(`\u2715 ${message}
|
|
39435
39616
|
`));
|
|
39436
39617
|
}
|
|
39437
39618
|
process.exit(1);
|
|
39438
39619
|
}
|
|
39439
39620
|
async function withDesk(opts, fn) {
|
|
39440
39621
|
try {
|
|
39441
|
-
const
|
|
39442
|
-
return await fn(
|
|
39622
|
+
const ctx2 = await resolveDeskContext();
|
|
39623
|
+
return await fn(ctx2);
|
|
39443
39624
|
} catch (err) {
|
|
39444
39625
|
fail2(err.message, opts.json);
|
|
39445
39626
|
}
|
|
39446
39627
|
}
|
|
39447
|
-
function servedFloorUnits2(
|
|
39448
|
-
const served =
|
|
39628
|
+
function servedFloorUnits2(ctx2) {
|
|
39629
|
+
const served = ctx2.config.trading?.minTradeUsdc;
|
|
39449
39630
|
if (typeof served !== "number" || !Number.isFinite(served) || served <= 0) return null;
|
|
39450
39631
|
return { units: BigInt(Math.round(served * 1e6)), usdc: served };
|
|
39451
39632
|
}
|
|
39452
39633
|
async function requireOwner(opts) {
|
|
39453
39634
|
const key = await loadTradeKey();
|
|
39454
39635
|
if (!key) {
|
|
39455
|
-
fail2("No agent trading key yet (the desk's owner). Run:
|
|
39636
|
+
fail2("No agent trading key yet (the desk's owner). Run: agentgates trade key", opts.json);
|
|
39456
39637
|
}
|
|
39457
39638
|
return key;
|
|
39458
39639
|
}
|
|
@@ -39468,7 +39649,7 @@ function stateJson(state) {
|
|
|
39468
39649
|
function describeSession(state, localSessionAddress) {
|
|
39469
39650
|
if (!state.session) {
|
|
39470
39651
|
return [
|
|
39471
|
-
"Session: none (register one:
|
|
39652
|
+
"Session: none (register one: agentgates desk session register --cap <usdc> --minutes <n>)"
|
|
39472
39653
|
];
|
|
39473
39654
|
}
|
|
39474
39655
|
const s = state.session;
|
|
@@ -39516,7 +39697,7 @@ function describeFills(fills, symbols) {
|
|
|
39516
39697
|
return lines;
|
|
39517
39698
|
}
|
|
39518
39699
|
async function deskStatus(opts) {
|
|
39519
|
-
await withDesk(opts, async (
|
|
39700
|
+
await withDesk(opts, async (ctx2) => {
|
|
39520
39701
|
let fillsLimit;
|
|
39521
39702
|
if (opts.fills !== void 0) {
|
|
39522
39703
|
const n = Number(opts.fills);
|
|
@@ -39529,13 +39710,13 @@ async function deskStatus(opts) {
|
|
|
39529
39710
|
const coin = opts.coin ? await resolveCoin(opts.coin) : null;
|
|
39530
39711
|
const state = await deskState(owner.state.address, coin?.mint, fillsLimit);
|
|
39531
39712
|
const session = await loadDeskSessionKey();
|
|
39532
|
-
const floor = servedFloorUnits2(
|
|
39713
|
+
const floor = servedFloorUnits2(ctx2);
|
|
39533
39714
|
if (opts.json) {
|
|
39534
39715
|
process.stdout.write(
|
|
39535
39716
|
JSON.stringify({
|
|
39536
39717
|
ok: true,
|
|
39537
|
-
chainId:
|
|
39538
|
-
desk:
|
|
39718
|
+
chainId: ctx2.chainId,
|
|
39719
|
+
desk: ctx2.desk,
|
|
39539
39720
|
minTradeUsdc: floor?.usdc ?? null,
|
|
39540
39721
|
sessionKeyFile: session?.state.address ?? null,
|
|
39541
39722
|
...stateJson(state),
|
|
@@ -39547,8 +39728,8 @@ async function deskStatus(opts) {
|
|
|
39547
39728
|
return;
|
|
39548
39729
|
}
|
|
39549
39730
|
const lines = [
|
|
39550
|
-
`Launch trading desk (Solana devnet, chain ${
|
|
39551
|
-
`Desk program: ${
|
|
39731
|
+
`Launch trading desk (Solana devnet, chain ${ctx2.chainId})`,
|
|
39732
|
+
`Desk program: ${ctx2.desk}`,
|
|
39552
39733
|
`Owner: ${state.owner}`,
|
|
39553
39734
|
`USDC credit: ${state.usdc.credit}`
|
|
39554
39735
|
];
|
|
@@ -39564,7 +39745,7 @@ async function deskStatus(opts) {
|
|
|
39564
39745
|
});
|
|
39565
39746
|
}
|
|
39566
39747
|
async function deskDeposit(amount, opts) {
|
|
39567
|
-
await withDesk(opts, async (
|
|
39748
|
+
await withDesk(opts, async (ctx2) => {
|
|
39568
39749
|
let units;
|
|
39569
39750
|
try {
|
|
39570
39751
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Deposit amount");
|
|
@@ -39574,11 +39755,11 @@ async function deskDeposit(amount, opts) {
|
|
|
39574
39755
|
if (units <= 0n) fail2("Deposit amount must be above zero.", opts.json);
|
|
39575
39756
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
39576
39757
|
if (created && !opts.json) {
|
|
39577
|
-
process.stderr.write(
|
|
39758
|
+
process.stderr.write(import_picocolors24.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
39578
39759
|
`));
|
|
39579
39760
|
}
|
|
39580
39761
|
const result = await runDeskCeremony({
|
|
39581
|
-
ctx,
|
|
39762
|
+
ctx: ctx2,
|
|
39582
39763
|
ownerKeypair: keypair,
|
|
39583
39764
|
op: "deposit",
|
|
39584
39765
|
prepareBody: { token: "usdc", amount }
|
|
@@ -39588,7 +39769,7 @@ async function deskDeposit(amount, opts) {
|
|
|
39588
39769
|
process.stdout.write(
|
|
39589
39770
|
JSON.stringify({
|
|
39590
39771
|
ok: true,
|
|
39591
|
-
chainId:
|
|
39772
|
+
chainId: ctx2.chainId,
|
|
39592
39773
|
op: "deposit",
|
|
39593
39774
|
amount,
|
|
39594
39775
|
amountUnits: result.prepared.amountUnits ?? null,
|
|
@@ -39608,7 +39789,7 @@ async function deskDeposit(amount, opts) {
|
|
|
39608
39789
|
});
|
|
39609
39790
|
}
|
|
39610
39791
|
async function deskWithdraw(amount, opts) {
|
|
39611
|
-
await withDesk(opts, async (
|
|
39792
|
+
await withDesk(opts, async (ctx2) => {
|
|
39612
39793
|
const owner = await requireOwner(opts);
|
|
39613
39794
|
const coin = opts.coin ? await resolveCoin(opts.coin) : null;
|
|
39614
39795
|
const token = coin?.mint ?? "usdc";
|
|
@@ -39619,7 +39800,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
39619
39800
|
}
|
|
39620
39801
|
}
|
|
39621
39802
|
const result = await runDeskCeremony({
|
|
39622
|
-
ctx,
|
|
39803
|
+
ctx: ctx2,
|
|
39623
39804
|
ownerKeypair: owner.keypair,
|
|
39624
39805
|
op: "withdraw",
|
|
39625
39806
|
prepareBody: { token, amount: trimmed }
|
|
@@ -39629,7 +39810,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
39629
39810
|
process.stdout.write(
|
|
39630
39811
|
JSON.stringify({
|
|
39631
39812
|
ok: true,
|
|
39632
|
-
chainId:
|
|
39813
|
+
chainId: ctx2.chainId,
|
|
39633
39814
|
op: "withdraw",
|
|
39634
39815
|
token: result.prepared.mint ?? token,
|
|
39635
39816
|
amount: trimmed,
|
|
@@ -39653,7 +39834,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
39653
39834
|
});
|
|
39654
39835
|
}
|
|
39655
39836
|
async function deskSessionRegister(opts) {
|
|
39656
|
-
await withDesk(opts, async (
|
|
39837
|
+
await withDesk(opts, async (ctx2) => {
|
|
39657
39838
|
if (!opts.cap) fail2("--cap <usdc> is required: the per-trade cap is your risk statement, never defaulted.", opts.json);
|
|
39658
39839
|
if (!opts.minutes) fail2("--minutes <n> is required: the session expiry is your risk statement, never defaulted.", opts.json);
|
|
39659
39840
|
let capUnits;
|
|
@@ -39669,18 +39850,18 @@ async function deskSessionRegister(opts) {
|
|
|
39669
39850
|
}
|
|
39670
39851
|
const owner = await loadOrCreateTradeKey();
|
|
39671
39852
|
if (owner.created && !opts.json) {
|
|
39672
|
-
process.stderr.write(
|
|
39853
|
+
process.stderr.write(import_picocolors24.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
|
|
39673
39854
|
`));
|
|
39674
39855
|
}
|
|
39675
39856
|
const session = await loadOrCreateDeskSessionKey();
|
|
39676
39857
|
if (session.created && !opts.json) {
|
|
39677
39858
|
process.stderr.write(
|
|
39678
|
-
|
|
39859
|
+
import_picocolors24.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
|
|
39679
39860
|
`)
|
|
39680
39861
|
);
|
|
39681
39862
|
}
|
|
39682
39863
|
const result = await runDeskCeremony({
|
|
39683
|
-
ctx,
|
|
39864
|
+
ctx: ctx2,
|
|
39684
39865
|
ownerKeypair: owner.keypair,
|
|
39685
39866
|
op: "register",
|
|
39686
39867
|
prepareBody: {
|
|
@@ -39694,7 +39875,7 @@ async function deskSessionRegister(opts) {
|
|
|
39694
39875
|
process.stdout.write(
|
|
39695
39876
|
JSON.stringify({
|
|
39696
39877
|
ok: true,
|
|
39697
|
-
chainId:
|
|
39878
|
+
chainId: ctx2.chainId,
|
|
39698
39879
|
op: "register",
|
|
39699
39880
|
sessionKey: session.state.address,
|
|
39700
39881
|
perTradeCapUsdc: opts.cap,
|
|
@@ -39718,10 +39899,10 @@ async function deskSessionRegister(opts) {
|
|
|
39718
39899
|
});
|
|
39719
39900
|
}
|
|
39720
39901
|
async function deskSessionRevoke(opts) {
|
|
39721
|
-
await withDesk(opts, async (
|
|
39902
|
+
await withDesk(opts, async (ctx2) => {
|
|
39722
39903
|
const owner = await requireOwner(opts);
|
|
39723
39904
|
const result = await runDeskCeremony({
|
|
39724
|
-
ctx,
|
|
39905
|
+
ctx: ctx2,
|
|
39725
39906
|
ownerKeypair: owner.keypair,
|
|
39726
39907
|
op: "revoke",
|
|
39727
39908
|
prepareBody: {}
|
|
@@ -39730,7 +39911,7 @@ async function deskSessionRevoke(opts) {
|
|
|
39730
39911
|
process.stdout.write(
|
|
39731
39912
|
JSON.stringify({
|
|
39732
39913
|
ok: true,
|
|
39733
|
-
chainId:
|
|
39914
|
+
chainId: ctx2.chainId,
|
|
39734
39915
|
op: "revoke",
|
|
39735
39916
|
txHash: result.txHash,
|
|
39736
39917
|
reprepared: result.reprepared
|
|
@@ -39750,19 +39931,19 @@ async function requireSessionKeypair(opts) {
|
|
|
39750
39931
|
const session = await loadDeskSessionKey();
|
|
39751
39932
|
if (!session) {
|
|
39752
39933
|
fail2(
|
|
39753
|
-
"No desk session key on this terminal. Register one:
|
|
39934
|
+
"No desk session key on this terminal. Register one: agentgates desk session register --cap <usdc> --minutes <n>",
|
|
39754
39935
|
opts.json
|
|
39755
39936
|
);
|
|
39756
39937
|
}
|
|
39757
39938
|
return session;
|
|
39758
39939
|
}
|
|
39759
|
-
async function reportDeskTrade(
|
|
39940
|
+
async function reportDeskTrade(ctx2, opts, args) {
|
|
39760
39941
|
const after = await deskState(args.owner, args.coin.mint);
|
|
39761
39942
|
if (opts.json) {
|
|
39762
39943
|
process.stdout.write(
|
|
39763
39944
|
JSON.stringify({
|
|
39764
39945
|
ok: true,
|
|
39765
|
-
chainId:
|
|
39946
|
+
chainId: ctx2.chainId,
|
|
39766
39947
|
op: args.side,
|
|
39767
39948
|
coin: args.coin.mint,
|
|
39768
39949
|
symbol: args.coin.symbol,
|
|
@@ -39787,7 +39968,7 @@ async function reportDeskTrade(ctx, opts, args) {
|
|
|
39787
39968
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
39788
39969
|
}
|
|
39789
39970
|
async function deskBuy(coinArg, amount, opts) {
|
|
39790
|
-
await withDesk(opts, async (
|
|
39971
|
+
await withDesk(opts, async (ctx2) => {
|
|
39791
39972
|
const coin = await resolveCoin(coinArg);
|
|
39792
39973
|
let units;
|
|
39793
39974
|
try {
|
|
@@ -39796,14 +39977,14 @@ async function deskBuy(coinArg, amount, opts) {
|
|
|
39796
39977
|
fail2(err.message, opts.json);
|
|
39797
39978
|
}
|
|
39798
39979
|
if (units <= 0n) fail2("Buy amount must be above zero.", opts.json);
|
|
39799
|
-
const floor = servedFloorUnits2(
|
|
39980
|
+
const floor = servedFloorUnits2(ctx2);
|
|
39800
39981
|
if (floor && units < floor.units) {
|
|
39801
39982
|
fail2(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
39802
39983
|
}
|
|
39803
39984
|
const owner = await requireOwner(opts);
|
|
39804
39985
|
const session = await requireSessionKeypair(opts);
|
|
39805
39986
|
const result = await runDeskTrade({
|
|
39806
|
-
ctx,
|
|
39987
|
+
ctx: ctx2,
|
|
39807
39988
|
sessionKeypair: session.keypair,
|
|
39808
39989
|
owner: owner.state.address,
|
|
39809
39990
|
op: "buy",
|
|
@@ -39811,11 +39992,11 @@ async function deskBuy(coinArg, amount, opts) {
|
|
|
39811
39992
|
amount,
|
|
39812
39993
|
minOut: opts.minOut
|
|
39813
39994
|
});
|
|
39814
|
-
await reportDeskTrade(
|
|
39995
|
+
await reportDeskTrade(ctx2, opts, { side: "buy", coin, owner: owner.state.address, amount, result });
|
|
39815
39996
|
});
|
|
39816
39997
|
}
|
|
39817
39998
|
async function deskSell(coinArg, amount, opts) {
|
|
39818
|
-
await withDesk(opts, async (
|
|
39999
|
+
await withDesk(opts, async (ctx2) => {
|
|
39819
40000
|
const coin = await resolveCoin(coinArg);
|
|
39820
40001
|
const owner = await requireOwner(opts);
|
|
39821
40002
|
const session = await requireSessionKeypair(opts);
|
|
@@ -39835,7 +40016,7 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
39835
40016
|
fail2(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
39836
40017
|
}
|
|
39837
40018
|
const result = await runDeskTrade({
|
|
39838
|
-
ctx,
|
|
40019
|
+
ctx: ctx2,
|
|
39839
40020
|
sessionKeypair: session.keypair,
|
|
39840
40021
|
owner: owner.state.address,
|
|
39841
40022
|
op: "sell",
|
|
@@ -39843,14 +40024,14 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
39843
40024
|
amount: sellAmount,
|
|
39844
40025
|
minOut: opts.minOut
|
|
39845
40026
|
});
|
|
39846
|
-
await reportDeskTrade(
|
|
40027
|
+
await reportDeskTrade(ctx2, opts, { side: "sell", coin, owner: owner.state.address, amount: sellAmount, result });
|
|
39847
40028
|
});
|
|
39848
40029
|
}
|
|
39849
40030
|
|
|
39850
40031
|
// src/main.ts
|
|
39851
40032
|
var { version: VERSION } = require_package();
|
|
39852
40033
|
var program2 = new Command();
|
|
39853
|
-
program2.name("
|
|
40034
|
+
program2.name("agentgates").description(
|
|
39854
40035
|
"Drive your non-custodial Agentgates wallet from the terminal.\nPair once with biometric; every send still requires biometric in your browser."
|
|
39855
40036
|
).version(VERSION);
|
|
39856
40037
|
program2.command("login").description("Pair this terminal with your Agentgates wallet (one-time)").option("--profile <name>", "named profile (default: 'default')").option("--no-browser", "don't auto-open the approval URL \u2014 print it only").action(async (opts) => {
|
|
@@ -39891,7 +40072,7 @@ program2.command("send").description(
|
|
|
39891
40072
|
});
|
|
39892
40073
|
}
|
|
39893
40074
|
);
|
|
39894
|
-
program2.command("status").description("Read the status of a previously-proposed intent").argument("<intent-id>", "the approval_id returned by `
|
|
40075
|
+
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(
|
|
39895
40076
|
async (intentId, opts) => {
|
|
39896
40077
|
await status(intentId, opts);
|
|
39897
40078
|
}
|
|
@@ -40094,8 +40275,8 @@ eat.command("search").description(
|
|
|
40094
40275
|
});
|
|
40095
40276
|
});
|
|
40096
40277
|
eat.command("menu").description(
|
|
40097
|
-
"Read what one store has \u2014 items, sizes, prices, option sets. A relevance SAMPLE, never the full catalogue; for actually ordering, skip straight to `
|
|
40098
|
-
).argument("[items...]", "dishes to check for, in the person's own words \u2014 this is the lever over what comes back").requiredOption("--brand <name>", "the store, from a `
|
|
40278
|
+
"Read what one store has \u2014 items, sizes, prices, option sets. A relevance SAMPLE, never the full catalogue; for actually ordering, skip straight to `agentgates eat order`."
|
|
40279
|
+
).argument("[items...]", "dishes to check for, in the person's own words \u2014 this is the lever over what comes back").requiredOption("--brand <name>", "the store, from a `agentgates eat search` result").requiredOption(
|
|
40099
40280
|
"--address <address>",
|
|
40100
40281
|
"that location's address, from the same result \u2014 use the row's lookupAddress when it has one (street + area resolves; the bare street alone can answer 404)"
|
|
40101
40282
|
).option("--intent <text>", 'a theme, biases the sample \u2014 "lunch", "something vegan"').option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (items, opts) => {
|
|
@@ -40108,8 +40289,8 @@ eat.command("menu").description(
|
|
|
40108
40289
|
});
|
|
40109
40290
|
});
|
|
40110
40291
|
eat.command("order").description(
|
|
40111
|
-
"Build a priced, itemised order at one store and get back a link only the person can pay. Never charges anything \u2014 find the store with `
|
|
40112
|
-
).argument("[items...]", `one dish per argument, in the person's own words \u2014 e.g. "al pastor taco" "horchata"`).requiredOption("--brand <name>", "the store, from a `
|
|
40292
|
+
"Build a priced, itemised order at one store and get back a link only the person can pay. Never charges anything \u2014 find the store with `agentgates eat search` first and pass its brand + address through verbatim."
|
|
40293
|
+
).argument("[items...]", `one dish per argument, in the person's own words \u2014 e.g. "al pastor taco" "horchata"`).requiredOption("--brand <name>", "the store, from a `agentgates eat search` result").requiredOption(
|
|
40113
40294
|
"--address <address>",
|
|
40114
40295
|
"that location's address, from the same result \u2014 use the row's lookupAddress when it has one (street + area resolves; the bare street alone can answer 404)"
|
|
40115
40296
|
).option(
|
|
@@ -40136,7 +40317,7 @@ eat.command("order").description(
|
|
|
40136
40317
|
});
|
|
40137
40318
|
eat.command("status").description(
|
|
40138
40319
|
"One order's current state \u2014 pending, paid (your saved card covered it), failed (provably not charged), or unconfirmed (a human must look before anything retries)."
|
|
40139
|
-
).argument("<orderId>", "the order_id a `
|
|
40320
|
+
).argument("<orderId>", "the order_id a `agentgates eat order` response carried").option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (orderId, opts) => {
|
|
40140
40321
|
await statusFood(orderId, { profile: opts.profile, json: opts.json });
|
|
40141
40322
|
});
|
|
40142
40323
|
program2.command("list").description(
|
|
@@ -40177,7 +40358,7 @@ program2.command("live").description("Who is streaming on bounties right now \u2
|
|
|
40177
40358
|
program2.command("pot").description("A bounty's REAL current pot, read from its escrow contract: base pool, sweetener, funded state, claims left. Stream tips (the streamer's, never the pot) ride along when live.").argument("<id>", "the bounty id").option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output").action(async (id, opts) => {
|
|
40178
40359
|
await bountyPot(id, opts);
|
|
40179
40360
|
});
|
|
40180
|
-
program2.command("who").description("A creator's public track record: shipped bounties, library, subscription price, and whether you hold access.").argument("<creator-user-id>", "the creator's user id (a bounty's userId from
|
|
40361
|
+
program2.command("who").description("A creator's public track record: shipped bounties, library, subscription price, and whether you hold access.").argument("<creator-user-id>", "the creator's user id (a bounty's userId from agentgates show --json)").option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output").action(async (creatorUserId, opts) => {
|
|
40181
40362
|
await creatorWho(creatorUserId, opts);
|
|
40182
40363
|
});
|
|
40183
40364
|
program2.command("retention").description("Your OWN bounty's retention readout: what is kept, under what policy, what keeping it costs. Creator-only; read-only.").argument("<id>", "your bounty id").option("--profile <name>", "named profile (default: 'default')").option("--json", "machine-readable output").action(async (id, opts) => {
|
|
@@ -40190,7 +40371,7 @@ program2.command("deliver").description(
|
|
|
40190
40371
|
});
|
|
40191
40372
|
program2.command("fund").description(
|
|
40192
40373
|
"Two shapes, picked by the target. `fund <bounty-id>`: fund YOUR OWN bounty's escrow so it goes live (amount/chain/escrow read from the bounty). `fund <address> --usdc N --gas M --chain C`: top up a payer wallet in ONE approval ceremony \u2014 the server plans the legs (a shortfall swap sized with headroom when your USDC can't cover) and the ceremony shows the whole plan."
|
|
40193
|
-
).argument("<target>", "a bounty id (see
|
|
40374
|
+
).argument("<target>", "a bounty id (see agentgates mine) OR a payer address (0x\u2026 / Solana base58)").requiredOption(
|
|
40194
40375
|
"--user-stated <text>",
|
|
40195
40376
|
"the verbatim user request that triggered this funding (trust-gap defense)"
|
|
40196
40377
|
).option("--usdc <n>", "address targets only: USDC the payer should receive, display units").option("--gas <n>", "address targets only: native gas the payer should receive, display units").option("--chain <chain>", "address targets only: chain id (1/137/8453/42161/900) or shortName").option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option(
|
|
@@ -40217,7 +40398,7 @@ program2.command("fund").description(
|
|
|
40217
40398
|
}
|
|
40218
40399
|
if (opts.usdc || opts.gas || opts.chain) {
|
|
40219
40400
|
process.stderr.write(
|
|
40220
|
-
|
|
40401
|
+
import_picocolors25.default.red(
|
|
40221
40402
|
`\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
|
|
40222
40403
|
`
|
|
40223
40404
|
)
|
|
@@ -40234,7 +40415,7 @@ program2.command("fund").description(
|
|
|
40234
40415
|
});
|
|
40235
40416
|
program2.command("tip").description(
|
|
40236
40417
|
"Add your own USDC to a live bounty's prize pot (sweeten). The pot pays out with the bounty. Opens your browser for biometric approval, then polls until mined."
|
|
40237
|
-
).argument("<id>", "the bounty id (see
|
|
40418
|
+
).argument("<id>", "the bounty id (see agentgates list)").argument("<amount>", 'contribution in USDC display units (e.g. "5")').requiredOption(
|
|
40238
40419
|
"--user-stated <text>",
|
|
40239
40420
|
"the verbatim user request that triggered this tip (trust-gap defense)"
|
|
40240
40421
|
).option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option("--max-usd <n>", "per-intent USD ceiling (default: amount + 1% price wobble)").option("--json", "NDJSON output (one object per status flip + final terminal object)").action(async (id, amount, opts, command) => {
|
|
@@ -40253,7 +40434,7 @@ program2.command("tip").description(
|
|
|
40253
40434
|
});
|
|
40254
40435
|
program2.command("subscribe").description(
|
|
40255
40436
|
"Buy prepaid months of a creator's subscription at THEIR stored price (read server-side, never guessed). Prepaid only \u2014 no auto-renew exists. Opens your browser for biometric approval."
|
|
40256
|
-
).argument("<creator-user-id>", "the creator's user id (a bounty's userId from
|
|
40437
|
+
).argument("<creator-user-id>", "the creator's user id (a bounty's userId from agentgates show --json)").requiredOption(
|
|
40257
40438
|
"--user-stated <text>",
|
|
40258
40439
|
"the verbatim user request that triggered this purchase (trust-gap defense)"
|
|
40259
40440
|
).option("--months <n>", "prepaid months: 1, 3 or 12 (default 1)").option("--profile <name>", "named profile (default: 'default')").option("--browser", "force open the approval URL (default unless --no-browser or CI=1)").option("--no-browser", "skip opening the approval URL").option(
|
|
@@ -40301,7 +40482,7 @@ var tradeOrder = trade.command("order").description(
|
|
|
40301
40482
|
tradeOrder.command("place").description("Place a standing order (buy_at / sell_at / buy_on_graduation / sell_on_graduation)").argument("<coin>", "coin ticker or base58 mint address").option("--buy <usdc>", "buy this much USDC when the trigger crosses (floor served by launch-config)").option("--sell <amount>", 'sell this amount, a percentage like "50%", or "all" (resolved at placement)').option("--at <value>", "trigger value in USDC: price per coin, or market cap with --mcap").option("--mcap", "the --at value is a market cap, not a price").option("--stop", "sell when the value drops TO OR BELOW --at (default: take-profit at-or-above)").option("--on-graduation", "fire near graduation instead of a price/mcap trigger").option("--expires-days <n>", "order lifetime in days (default: the served orders config)").option("--json", "machine-readable output").action(async (coin, opts) => {
|
|
40302
40483
|
await tradeOrderPlace(coin, opts);
|
|
40303
40484
|
});
|
|
40304
|
-
tradeOrder.command("cancel").description("Cancel a standing order: withdraws its nonce on chain, the signed bytes can never land").argument("<id>", "the order id (see:
|
|
40485
|
+
tradeOrder.command("cancel").description("Cancel a standing order: withdraws its nonce on chain, the signed bytes can never land").argument("<id>", "the order id (see: agentgates trade orders)").option("--json", "machine-readable output").action(async (id, opts) => {
|
|
40305
40486
|
await tradeOrderCancel(id, opts);
|
|
40306
40487
|
});
|
|
40307
40488
|
trade.command("orders").description("List the agent key's standing orders (open, fired, missed, expired, canceled)").option("--coin <ticker-or-mint>", "only this coin's orders").option("--json", "machine-readable output").action(async (opts) => {
|
|
@@ -40336,11 +40517,28 @@ desk.command("buy").description("Buy a launch coin with desk USDC credit (sessio
|
|
|
40336
40517
|
desk.command("sell").description("Sell desk coin credit back to the curve (session signs; sells uncapped by design \u2014 proceeds only ever land in the owner's vault)").argument("<coin>", "coin ticker or base58 mint address").argument("<amount>", 'coin amount, a percentage like "50%" (resolved from the state read), or "all"').option("--min-out <usdc>", "explicit min-out in USDC (overrides the server-owned guard)").option("--json", "machine-readable output").action(async (coin, amount, opts) => {
|
|
40337
40518
|
await deskSell(coin, amount, opts);
|
|
40338
40519
|
});
|
|
40520
|
+
program2.command("onboard").description("Welcome screen: pair your wallet, or look at what is for sale. Run by the installer.").option("--profile <name>", "named profile (default: 'default')").action(async (opts) => {
|
|
40521
|
+
await onboard(opts);
|
|
40522
|
+
});
|
|
40523
|
+
var compute = program2.command("compute").description("Confidential VMs by the hour, USDC per payment");
|
|
40524
|
+
compute.command("plans").description("Live plans and the price ladder. Public read: no key, no account, no payment.").option("--json", "machine-readable output (the raw catalog)").action(async (opts) => {
|
|
40525
|
+
await computePlans(opts);
|
|
40526
|
+
});
|
|
40527
|
+
compute.command("buy").description("Rent a machine (needs an x402 signature this CLI does not have yet)").action(async () => {
|
|
40528
|
+
await computeBuy();
|
|
40529
|
+
});
|
|
40530
|
+
var inference = program2.command("inference").description("Attested confidential models, plus an open tier, USDC per request");
|
|
40531
|
+
inference.command("models").description("Live models and per-token prices. Public read: no key, no account, no payment.").option("--all", "every model, not just the attested tier").option("--json", "machine-readable output (the raw catalog)").action(async (opts) => {
|
|
40532
|
+
await inferenceModels(opts);
|
|
40533
|
+
});
|
|
40534
|
+
inference.command("ask").description("One paid ask (needs an x402 signature this CLI does not have yet)").action(async () => {
|
|
40535
|
+
await inferenceAsk();
|
|
40536
|
+
});
|
|
40339
40537
|
program2.parseAsync(process.argv).catch((err) => {
|
|
40340
|
-
process.stderr.write(
|
|
40538
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${err.message}
|
|
40341
40539
|
`));
|
|
40342
40540
|
if (process.env.BOUNTY_DEBUG) {
|
|
40343
|
-
process.stderr.write(
|
|
40541
|
+
process.stderr.write(import_picocolors25.default.dim((err.stack ?? "") + "\n"));
|
|
40344
40542
|
}
|
|
40345
40543
|
process.exit(1);
|
|
40346
40544
|
});
|