@agentgates/cli 0.10.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +869 -416
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -5037,15 +5037,15 @@ var require_curve = __commonJS({
|
|
|
5037
5037
|
windowSize = wbits - 2;
|
|
5038
5038
|
else if (wbits > 0)
|
|
5039
5039
|
windowSize = 2;
|
|
5040
|
-
const
|
|
5041
|
-
const buckets = new Array(Number(
|
|
5040
|
+
const MASK2 = (0, utils_ts_1.bitMask)(windowSize);
|
|
5041
|
+
const buckets = new Array(Number(MASK2) + 1).fill(zero);
|
|
5042
5042
|
const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
|
|
5043
5043
|
let sum = zero;
|
|
5044
5044
|
for (let i = lastBits; i >= 0; i -= windowSize) {
|
|
5045
5045
|
buckets.fill(zero);
|
|
5046
5046
|
for (let j = 0; j < slength; j++) {
|
|
5047
5047
|
const scalar = scalars[j];
|
|
5048
|
-
const wbits2 = Number(scalar >> BigInt(i) &
|
|
5048
|
+
const wbits2 = Number(scalar >> BigInt(i) & MASK2);
|
|
5049
5049
|
buckets[wbits2] = buckets[wbits2].add(points[j]);
|
|
5050
5050
|
}
|
|
5051
5051
|
let resI = zero;
|
|
@@ -5066,7 +5066,7 @@ var require_curve = __commonJS({
|
|
|
5066
5066
|
const zero = c.ZERO;
|
|
5067
5067
|
const tableSize = 2 ** windowSize - 1;
|
|
5068
5068
|
const chunks = Math.ceil(fieldN.BITS / windowSize);
|
|
5069
|
-
const
|
|
5069
|
+
const MASK2 = (0, utils_ts_1.bitMask)(windowSize);
|
|
5070
5070
|
const tables = points.map((p) => {
|
|
5071
5071
|
const res = [];
|
|
5072
5072
|
for (let i = 0, acc = p; i < tableSize; i++) {
|
|
@@ -5087,7 +5087,7 @@ var require_curve = __commonJS({
|
|
|
5087
5087
|
const shiftBy = BigInt(chunks * windowSize - (i + 1) * windowSize);
|
|
5088
5088
|
for (let j = 0; j < scalars.length; j++) {
|
|
5089
5089
|
const n = scalars[j];
|
|
5090
|
-
const curr = Number(n >> shiftBy &
|
|
5090
|
+
const curr = Number(n >> shiftBy & MASK2);
|
|
5091
5091
|
if (!curr)
|
|
5092
5092
|
continue;
|
|
5093
5093
|
res = res.add(tables[j][curr - 1]);
|
|
@@ -5176,7 +5176,7 @@ var require_edwards = __commonJS({
|
|
|
5176
5176
|
let CURVE = validated.CURVE;
|
|
5177
5177
|
const { h: cofactor } = CURVE;
|
|
5178
5178
|
(0, utils_ts_1._validateObject)(extraOpts, {}, { uvRatio: "function" });
|
|
5179
|
-
const
|
|
5179
|
+
const MASK2 = _2n << BigInt(Fn.BYTES * 8) - _1n;
|
|
5180
5180
|
const modP = (n) => Fp.create(n);
|
|
5181
5181
|
const uvRatio = extraOpts.uvRatio || ((u, v) => {
|
|
5182
5182
|
try {
|
|
@@ -5189,7 +5189,7 @@ var require_edwards = __commonJS({
|
|
|
5189
5189
|
throw new Error("bad curve params: generator point");
|
|
5190
5190
|
function acoord(title, n, banZero = false) {
|
|
5191
5191
|
const min = banZero ? _1n : _0n;
|
|
5192
|
-
(0, utils_ts_1.aInRange)("coordinate " + title, n, min,
|
|
5192
|
+
(0, utils_ts_1.aInRange)("coordinate " + title, n, min, MASK2);
|
|
5193
5193
|
return n;
|
|
5194
5194
|
}
|
|
5195
5195
|
function aextpoint(other) {
|
|
@@ -5259,7 +5259,7 @@ var require_edwards = __commonJS({
|
|
|
5259
5259
|
const lastByte = bytes[len - 1];
|
|
5260
5260
|
normed[len - 1] = lastByte & ~128;
|
|
5261
5261
|
const y = (0, utils_ts_1.bytesToNumberLE)(normed);
|
|
5262
|
-
const max = zip215 ?
|
|
5262
|
+
const max = zip215 ? MASK2 : Fp.ORDER;
|
|
5263
5263
|
(0, utils_ts_1.aInRange)("point.y", y, _0n, max);
|
|
5264
5264
|
const y2 = modP(y * y);
|
|
5265
5265
|
const u = modP(y2 - _1n);
|
|
@@ -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");
|
|
@@ -10417,31 +10417,31 @@ var require_Layout = __commonJS({
|
|
|
10417
10417
|
return name;
|
|
10418
10418
|
}
|
|
10419
10419
|
exports.nameWithProperty = nameWithProperty;
|
|
10420
|
-
function bindConstructorLayout(Class,
|
|
10420
|
+
function bindConstructorLayout(Class, layout2) {
|
|
10421
10421
|
if ("function" !== typeof Class) {
|
|
10422
10422
|
throw new TypeError("Class must be constructor");
|
|
10423
10423
|
}
|
|
10424
10424
|
if (Object.prototype.hasOwnProperty.call(Class, "layout_")) {
|
|
10425
10425
|
throw new Error("Class is already bound to a layout");
|
|
10426
10426
|
}
|
|
10427
|
-
if (!(
|
|
10427
|
+
if (!(layout2 && layout2 instanceof Layout)) {
|
|
10428
10428
|
throw new TypeError("layout must be a Layout");
|
|
10429
10429
|
}
|
|
10430
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
10430
|
+
if (Object.prototype.hasOwnProperty.call(layout2, "boundConstructor_")) {
|
|
10431
10431
|
throw new Error("layout is already bound to a constructor");
|
|
10432
10432
|
}
|
|
10433
|
-
Class.layout_ =
|
|
10434
|
-
|
|
10435
|
-
|
|
10433
|
+
Class.layout_ = layout2;
|
|
10434
|
+
layout2.boundConstructor_ = Class;
|
|
10435
|
+
layout2.makeDestinationObject = (() => new Class());
|
|
10436
10436
|
Object.defineProperty(Class.prototype, "encode", {
|
|
10437
10437
|
value(b, offset) {
|
|
10438
|
-
return
|
|
10438
|
+
return layout2.encode(this, b, offset);
|
|
10439
10439
|
},
|
|
10440
10440
|
writable: true
|
|
10441
10441
|
});
|
|
10442
10442
|
Object.defineProperty(Class, "decode", {
|
|
10443
10443
|
value(b, offset) {
|
|
10444
|
-
return
|
|
10444
|
+
return layout2.decode(b, offset);
|
|
10445
10445
|
},
|
|
10446
10446
|
writable: true
|
|
10447
10447
|
});
|
|
@@ -10489,15 +10489,15 @@ var require_Layout = __commonJS({
|
|
|
10489
10489
|
};
|
|
10490
10490
|
exports.GreedyCount = GreedyCount;
|
|
10491
10491
|
var OffsetLayout = class extends ExternalLayout {
|
|
10492
|
-
constructor(
|
|
10493
|
-
if (!(
|
|
10492
|
+
constructor(layout2, offset = 0, property) {
|
|
10493
|
+
if (!(layout2 instanceof Layout)) {
|
|
10494
10494
|
throw new TypeError("layout must be a Layout");
|
|
10495
10495
|
}
|
|
10496
10496
|
if (!Number.isInteger(offset)) {
|
|
10497
10497
|
throw new TypeError("offset must be integer or undefined");
|
|
10498
10498
|
}
|
|
10499
|
-
super(
|
|
10500
|
-
this.layout =
|
|
10499
|
+
super(layout2.span, property || layout2.property);
|
|
10500
|
+
this.layout = layout2;
|
|
10501
10501
|
this.offset = offset;
|
|
10502
10502
|
}
|
|
10503
10503
|
/** @override */
|
|
@@ -10974,12 +10974,12 @@ var require_Layout = __commonJS({
|
|
|
10974
10974
|
};
|
|
10975
10975
|
exports.UnionDiscriminator = UnionDiscriminator;
|
|
10976
10976
|
var UnionLayoutDiscriminator = class extends UnionDiscriminator {
|
|
10977
|
-
constructor(
|
|
10978
|
-
if (!(
|
|
10977
|
+
constructor(layout2, property) {
|
|
10978
|
+
if (!(layout2 instanceof ExternalLayout && layout2.isCount())) {
|
|
10979
10979
|
throw new TypeError("layout must be an unsigned integer ExternalLayout");
|
|
10980
10980
|
}
|
|
10981
|
-
super(property ||
|
|
10982
|
-
this.layout =
|
|
10981
|
+
super(property || layout2.property || "variant");
|
|
10982
|
+
this.layout = layout2;
|
|
10983
10983
|
}
|
|
10984
10984
|
/** Delegate decoding to {@link UnionLayoutDiscriminator#layout|layout}. */
|
|
10985
10985
|
decode(b, offset) {
|
|
@@ -11154,8 +11154,8 @@ var require_Layout = __commonJS({
|
|
|
11154
11154
|
* Layout#property|property}.
|
|
11155
11155
|
*
|
|
11156
11156
|
* @return {VariantLayout} */
|
|
11157
|
-
addVariant(variant,
|
|
11158
|
-
const rv = new VariantLayout(this, variant,
|
|
11157
|
+
addVariant(variant, layout2, property) {
|
|
11158
|
+
const rv = new VariantLayout(this, variant, layout2, property);
|
|
11159
11159
|
this.registry[variant] = rv;
|
|
11160
11160
|
return rv;
|
|
11161
11161
|
}
|
|
@@ -11185,22 +11185,22 @@ var require_Layout = __commonJS({
|
|
|
11185
11185
|
};
|
|
11186
11186
|
exports.Union = Union;
|
|
11187
11187
|
var VariantLayout = class extends Layout {
|
|
11188
|
-
constructor(union, variant,
|
|
11188
|
+
constructor(union, variant, layout2, property) {
|
|
11189
11189
|
if (!(union instanceof Union)) {
|
|
11190
11190
|
throw new TypeError("union must be a Union");
|
|
11191
11191
|
}
|
|
11192
11192
|
if (!Number.isInteger(variant) || 0 > variant) {
|
|
11193
11193
|
throw new TypeError("variant must be a (non-negative) integer");
|
|
11194
11194
|
}
|
|
11195
|
-
if ("string" === typeof
|
|
11196
|
-
property =
|
|
11197
|
-
|
|
11195
|
+
if ("string" === typeof layout2 && void 0 === property) {
|
|
11196
|
+
property = layout2;
|
|
11197
|
+
layout2 = null;
|
|
11198
11198
|
}
|
|
11199
|
-
if (
|
|
11200
|
-
if (!(
|
|
11199
|
+
if (layout2) {
|
|
11200
|
+
if (!(layout2 instanceof Layout)) {
|
|
11201
11201
|
throw new TypeError("layout must be a Layout");
|
|
11202
11202
|
}
|
|
11203
|
-
if (null !== union.defaultLayout && 0 <=
|
|
11203
|
+
if (null !== union.defaultLayout && 0 <= layout2.span && layout2.span > union.defaultLayout.span) {
|
|
11204
11204
|
throw new Error("variant span exceeds span of containing union");
|
|
11205
11205
|
}
|
|
11206
11206
|
if ("string" !== typeof property) {
|
|
@@ -11209,7 +11209,7 @@ var require_Layout = __commonJS({
|
|
|
11209
11209
|
}
|
|
11210
11210
|
let span = union.span;
|
|
11211
11211
|
if (0 > union.span) {
|
|
11212
|
-
span =
|
|
11212
|
+
span = layout2 ? layout2.span : 0;
|
|
11213
11213
|
if (0 <= span && union.usesPrefixDiscriminator) {
|
|
11214
11214
|
span += union.discriminator.layout.span;
|
|
11215
11215
|
}
|
|
@@ -11217,7 +11217,7 @@ var require_Layout = __commonJS({
|
|
|
11217
11217
|
super(span, property);
|
|
11218
11218
|
this.union = union;
|
|
11219
11219
|
this.variant = variant;
|
|
11220
|
-
this.layout =
|
|
11220
|
+
this.layout = layout2 || null;
|
|
11221
11221
|
}
|
|
11222
11222
|
/** @override */
|
|
11223
11223
|
getSpan(b, offset = 0) {
|
|
@@ -11610,7 +11610,7 @@ var require_Layout = __commonJS({
|
|
|
11610
11610
|
};
|
|
11611
11611
|
exports.Constant = Constant;
|
|
11612
11612
|
exports.greedy = ((elementSpan, property) => new GreedyCount(elementSpan, property));
|
|
11613
|
-
exports.offset = ((
|
|
11613
|
+
exports.offset = ((layout2, offset, property) => new OffsetLayout(layout2, offset, property));
|
|
11614
11614
|
exports.u8 = ((property) => new UInt(1, property));
|
|
11615
11615
|
exports.u16 = ((property) => new UInt(2, property));
|
|
11616
11616
|
exports.u24 = ((property) => new UInt(3, property));
|
|
@@ -11645,7 +11645,7 @@ var require_Layout = __commonJS({
|
|
|
11645
11645
|
exports.bits = ((word, msb, property) => new BitStructure(word, msb, property));
|
|
11646
11646
|
exports.seq = ((elementLayout, count, property) => new Sequence(elementLayout, count, property));
|
|
11647
11647
|
exports.union = ((discr, defaultLayout, property) => new Union(discr, defaultLayout, property));
|
|
11648
|
-
exports.unionLayoutDiscriminator = ((
|
|
11648
|
+
exports.unionLayoutDiscriminator = ((layout2, property) => new UnionLayoutDiscriminator(layout2, property));
|
|
11649
11649
|
exports.blob = ((length, property) => new Blob2(length, property));
|
|
11650
11650
|
exports.cstr = ((property) => new CString(property));
|
|
11651
11651
|
exports.utf8 = ((maxSpan, property) => new UTF8(maxSpan, property));
|
|
@@ -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
|
}
|
|
@@ -27144,10 +27144,10 @@ Message: ${transactionMessage}.
|
|
|
27144
27144
|
}
|
|
27145
27145
|
};
|
|
27146
27146
|
function u64(property) {
|
|
27147
|
-
const
|
|
27148
|
-
const decode =
|
|
27149
|
-
const encode =
|
|
27150
|
-
const bigIntLayout =
|
|
27147
|
+
const layout2 = BufferLayout.blob(8, property);
|
|
27148
|
+
const decode = layout2.decode.bind(layout2);
|
|
27149
|
+
const encode = layout2.encode.bind(layout2);
|
|
27150
|
+
const bigIntLayout = layout2;
|
|
27151
27151
|
const codec = codecsNumbers.getU64Codec();
|
|
27152
27152
|
bigIntLayout.decode = (buffer2, offset) => {
|
|
27153
27153
|
const src = decode(buffer2, offset);
|
|
@@ -27173,8 +27173,8 @@ Message: ${transactionMessage}.
|
|
|
27173
27173
|
const instructionTypeLayout = BufferLayout__namespace.u32("instruction");
|
|
27174
27174
|
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
27175
27175
|
let type;
|
|
27176
|
-
for (const [ixType,
|
|
27177
|
-
if (
|
|
27176
|
+
for (const [ixType, layout2] of Object.entries(SYSTEM_INSTRUCTION_LAYOUTS)) {
|
|
27177
|
+
if (layout2.index == typeIndex) {
|
|
27178
27178
|
type = ixType;
|
|
27179
27179
|
break;
|
|
27180
27180
|
}
|
|
@@ -32364,8 +32364,8 @@ Message: ${transactionMessage}.
|
|
|
32364
32364
|
const instructionTypeLayout = BufferLayout__namespace.u32("instruction");
|
|
32365
32365
|
const index = instructionTypeLayout.decode(instruction.data);
|
|
32366
32366
|
let type;
|
|
32367
|
-
for (const [layoutType,
|
|
32368
|
-
if (
|
|
32367
|
+
for (const [layoutType, layout2] of Object.entries(LOOKUP_TABLE_INSTRUCTION_LAYOUTS)) {
|
|
32368
|
+
if (layout2.index == index) {
|
|
32369
32369
|
type = layoutType;
|
|
32370
32370
|
break;
|
|
32371
32371
|
}
|
|
@@ -32585,8 +32585,8 @@ Message: ${transactionMessage}.
|
|
|
32585
32585
|
const instructionTypeLayout = BufferLayout__namespace.u8("instruction");
|
|
32586
32586
|
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
32587
32587
|
let type;
|
|
32588
|
-
for (const [ixType,
|
|
32589
|
-
if (
|
|
32588
|
+
for (const [ixType, layout2] of Object.entries(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS)) {
|
|
32589
|
+
if (layout2.index == typeIndex) {
|
|
32590
32590
|
type = ixType;
|
|
32591
32591
|
break;
|
|
32592
32592
|
}
|
|
@@ -32986,8 +32986,8 @@ Message: ${transactionMessage}.
|
|
|
32986
32986
|
const instructionTypeLayout = BufferLayout__namespace.u32("instruction");
|
|
32987
32987
|
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
32988
32988
|
let type;
|
|
32989
|
-
for (const [ixType,
|
|
32990
|
-
if (
|
|
32989
|
+
for (const [ixType, layout2] of Object.entries(STAKE_INSTRUCTION_LAYOUTS)) {
|
|
32990
|
+
if (layout2.index == typeIndex) {
|
|
32991
32991
|
type = ixType;
|
|
32992
32992
|
break;
|
|
32993
32993
|
}
|
|
@@ -33649,8 +33649,8 @@ Message: ${transactionMessage}.
|
|
|
33649
33649
|
const instructionTypeLayout = BufferLayout__namespace.u32("instruction");
|
|
33650
33650
|
const typeIndex = instructionTypeLayout.decode(instruction.data);
|
|
33651
33651
|
let type;
|
|
33652
|
-
for (const [ixType,
|
|
33653
|
-
if (
|
|
33652
|
+
for (const [ixType, layout2] of Object.entries(VOTE_INSTRUCTION_LAYOUTS)) {
|
|
33653
|
+
if (layout2.index == typeIndex) {
|
|
33654
33654
|
type = ixType;
|
|
33655
33655
|
break;
|
|
33656
33656
|
}
|
|
@@ -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.1",
|
|
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);
|
|
@@ -35345,17 +35345,453 @@ 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/lib/water.ts
|
|
35353
|
+
var RAMP = ".:-=+*#%@";
|
|
35354
|
+
var FONT = {
|
|
35355
|
+
a: [" ", " ", " ### ", " #", " ####", "# #", " ####", " "],
|
|
35356
|
+
g: [" ", " ", " ####", "# #", "# #", " ####", " #", " ### "],
|
|
35357
|
+
e: [" ", " ", " ### ", "# #", "#####", "# ", " ####", " "],
|
|
35358
|
+
n: [" ", " ", "# ## ", "## #", "# #", "# #", "# #", " "],
|
|
35359
|
+
t: [" # ", " # ", "#####", " # ", " # ", " # ", " ## ", " "],
|
|
35360
|
+
s: [" ", " ", " ####", "# ", " ### ", " #", "#### ", " "]
|
|
35361
|
+
};
|
|
35362
|
+
var WORD = "agentgates";
|
|
35363
|
+
var MARGIN = 2;
|
|
35364
|
+
var MASK_ROWS = 8;
|
|
35365
|
+
function buildMask() {
|
|
35366
|
+
const rows = Array.from({ length: MASK_ROWS }, () => []);
|
|
35367
|
+
for (let r = 0; r < MASK_ROWS; r++) {
|
|
35368
|
+
rows[r].push(...Array(MARGIN).fill(false));
|
|
35369
|
+
for (const ch of WORD) {
|
|
35370
|
+
const glyph = FONT[ch];
|
|
35371
|
+
for (const cell of glyph[r]) rows[r].push(cell === "#");
|
|
35372
|
+
rows[r].push(false);
|
|
35373
|
+
}
|
|
35374
|
+
}
|
|
35375
|
+
return rows;
|
|
35376
|
+
}
|
|
35377
|
+
var MASK = buildMask();
|
|
35378
|
+
var COLS = MASK[0].length;
|
|
35379
|
+
var STOPS = [
|
|
35380
|
+
[0, [16, 62, 138]],
|
|
35381
|
+
[0.45, [36, 120, 200]],
|
|
35382
|
+
[0.75, [66, 186, 232]],
|
|
35383
|
+
[1, [168, 240, 248]]
|
|
35384
|
+
];
|
|
35385
|
+
function rgb(b) {
|
|
35386
|
+
for (let i = 1; i < STOPS.length; i++) {
|
|
35387
|
+
if (b <= STOPS[i][0]) {
|
|
35388
|
+
const [b0, c0] = STOPS[i - 1];
|
|
35389
|
+
const [b1, c1] = STOPS[i];
|
|
35390
|
+
const f = (b - b0) / (b1 - b0);
|
|
35391
|
+
return [0, 1, 2].map((k) => Math.round(c0[k] + f * (c1[k] - c0[k])));
|
|
35392
|
+
}
|
|
35393
|
+
}
|
|
35394
|
+
return STOPS[STOPS.length - 1][1];
|
|
35395
|
+
}
|
|
35396
|
+
var RAMP256 = [17, 18, 24, 25, 31, 38, 44, 51, 87, 123, 159];
|
|
35397
|
+
function brightness(x, y, t, scale) {
|
|
35398
|
+
const w1 = Math.sin((x * 0.28 + y * 0.55) / scale + t * 2);
|
|
35399
|
+
const w2 = Math.sin(x * 0.11 / scale - t * 1.35 + Math.sin(y * 0.9 / scale + t * 0.6));
|
|
35400
|
+
const b = 0.5 + 0.27 * w1 + 0.23 * w2;
|
|
35401
|
+
return b < 0 ? 0 : b > 1 ? 1 : b;
|
|
35402
|
+
}
|
|
35403
|
+
function waterMode() {
|
|
35404
|
+
if (!process.stdout.isTTY) return null;
|
|
35405
|
+
if (process.env.NO_COLOR) return null;
|
|
35406
|
+
const term = process.env.TERM ?? "";
|
|
35407
|
+
if (term === "dumb") return null;
|
|
35408
|
+
const cols = process.stdout.columns || 80;
|
|
35409
|
+
if (cols < COLS + 1) return null;
|
|
35410
|
+
if (/truecolor|24bit/i.test(process.env.COLORTERM ?? "")) return "truecolor";
|
|
35411
|
+
if (/256color/.test(term)) return "256";
|
|
35412
|
+
return null;
|
|
35413
|
+
}
|
|
35414
|
+
function layout() {
|
|
35415
|
+
const cols = process.stdout.columns || 80;
|
|
35416
|
+
const lines = process.stdout.rows || 24;
|
|
35417
|
+
const scale = cols >= COLS * 2 + 1 && lines >= 30 ? 2 : 1;
|
|
35418
|
+
return { scale, width: COLS * scale, rows: MASK_ROWS * scale };
|
|
35419
|
+
}
|
|
35420
|
+
function frame(t, mode, L) {
|
|
35421
|
+
const out = [];
|
|
35422
|
+
for (let y = 0; y < L.rows; y++) {
|
|
35423
|
+
let line = "";
|
|
35424
|
+
let last = "";
|
|
35425
|
+
const my = Math.floor(y / L.scale);
|
|
35426
|
+
for (let x = 0; x < L.width; x++) {
|
|
35427
|
+
if (!MASK[my][Math.floor(x / L.scale)]) {
|
|
35428
|
+
line += " ";
|
|
35429
|
+
continue;
|
|
35430
|
+
}
|
|
35431
|
+
const b = brightness(x, y, t, L.scale);
|
|
35432
|
+
const g = RAMP[Math.max(1, Math.round(b * (RAMP.length - 1)))];
|
|
35433
|
+
const color = mode === "truecolor" ? `\x1B[38;2;${rgb(b).join(";")}m` : `\x1B[38;5;${RAMP256[Math.round(b * (RAMP256.length - 1))]}m`;
|
|
35434
|
+
line += (color === last ? "" : color) + g;
|
|
35435
|
+
last = color;
|
|
35436
|
+
}
|
|
35437
|
+
out.push(line + "\x1B[0m");
|
|
35438
|
+
}
|
|
35439
|
+
return out;
|
|
35440
|
+
}
|
|
35441
|
+
var cursorHookArmed = false;
|
|
35442
|
+
function armCursorHook() {
|
|
35443
|
+
if (cursorHookArmed) return;
|
|
35444
|
+
cursorHookArmed = true;
|
|
35445
|
+
process.on("exit", () => process.stdout.write("\x1B[?25h"));
|
|
35446
|
+
}
|
|
35447
|
+
function water() {
|
|
35448
|
+
const mode = waterMode();
|
|
35449
|
+
if (!mode) return null;
|
|
35450
|
+
armCursorHook();
|
|
35451
|
+
const L = layout();
|
|
35452
|
+
let below = 0;
|
|
35453
|
+
let t = 0;
|
|
35454
|
+
process.stdout.write("\x1B[?25l" + frame(t, mode, L).join("\n") + "\n");
|
|
35455
|
+
const rawStderrWrite = process.stderr.write.bind(process.stderr);
|
|
35456
|
+
process.stderr.write = ((chunk, ...rest) => {
|
|
35457
|
+
const s = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
35458
|
+
for (const ch of s) if (ch === "\n") below++;
|
|
35459
|
+
return rawStderrWrite(chunk, ...rest);
|
|
35460
|
+
});
|
|
35461
|
+
const timer = setInterval(() => {
|
|
35462
|
+
if ((process.stdout.columns || 80) < L.width + 1) {
|
|
35463
|
+
stop();
|
|
35464
|
+
return;
|
|
35465
|
+
}
|
|
35466
|
+
t += 0.09;
|
|
35467
|
+
const up = below + L.rows;
|
|
35468
|
+
const body = frame(t, mode, L).join("\x1B[1B\r");
|
|
35469
|
+
process.stdout.write(`\x1B7\x1B[${up}A\r` + body + "\x1B8");
|
|
35470
|
+
}, 90);
|
|
35471
|
+
function stop() {
|
|
35472
|
+
clearInterval(timer);
|
|
35473
|
+
process.stderr.write = rawStderrWrite;
|
|
35474
|
+
process.stdout.write("\x1B[?25h");
|
|
35475
|
+
}
|
|
35476
|
+
return {
|
|
35477
|
+
wrote(s) {
|
|
35478
|
+
for (const ch of s) if (ch === "\n") below++;
|
|
35479
|
+
},
|
|
35480
|
+
stop
|
|
35481
|
+
};
|
|
35482
|
+
}
|
|
35483
|
+
|
|
35484
|
+
// src/commands/compute.ts
|
|
35349
35485
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
35486
|
+
var SITE = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
35487
|
+
var usd = (v) => `$${String(v).replace(/(\.\d\d\d?)0+$/, "$1")}`;
|
|
35488
|
+
async function computePlans(opts) {
|
|
35489
|
+
const res = await fetch(`${SITE}/api/compute/catalog`, { headers: { accept: "application/json" } });
|
|
35490
|
+
if (!res.ok) throw new Error(`compute catalog: HTTP ${res.status}`);
|
|
35491
|
+
const body = await res.json();
|
|
35492
|
+
if (opts.json) {
|
|
35493
|
+
process.stdout.write(JSON.stringify(body, null, 2) + "\n");
|
|
35494
|
+
return;
|
|
35495
|
+
}
|
|
35496
|
+
const plans = body.plans ?? [];
|
|
35497
|
+
if (plans.length === 0) {
|
|
35498
|
+
process.stdout.write(` ${import_picocolors3.default.dim("No plans are on sale right now.")}
|
|
35499
|
+
`);
|
|
35500
|
+
return;
|
|
35501
|
+
}
|
|
35502
|
+
process.stdout.write(`
|
|
35503
|
+
${import_picocolors3.default.bold("CONFIDENTIAL VIRTUAL MACHINES")} ${import_picocolors3.default.dim("memory encrypted in use")}
|
|
35504
|
+
|
|
35505
|
+
`);
|
|
35506
|
+
for (const p of plans) {
|
|
35507
|
+
const spec = `${p.vcpu} vCPU \xB7 ${Math.round(p.memoryMb / 1024)} GB \xB7 ${p.diskGb}GB disk`;
|
|
35508
|
+
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)}
|
|
35509
|
+
`);
|
|
35510
|
+
process.stdout.write(` ${import_picocolors3.default.dim(p.id.padEnd(10))} ${import_picocolors3.default.dim(`${p.egressQuotaGb} GB traffic`)}
|
|
35511
|
+
`);
|
|
35512
|
+
const ladder = p.pricing.map((r) => `${r.hoursPerPayment}h ${usd(r.totalUsd)}`).join(" ");
|
|
35513
|
+
if (ladder) process.stdout.write(` ${import_picocolors3.default.dim(ladder)}
|
|
35514
|
+
`);
|
|
35515
|
+
process.stdout.write("\n");
|
|
35516
|
+
}
|
|
35517
|
+
const nets = body.payment?.networks ?? [];
|
|
35518
|
+
if (nets.length) process.stdout.write(` ${import_picocolors3.default.dim(`USDC on ${nets.join(", ")}`)}
|
|
35519
|
+
|
|
35520
|
+
`);
|
|
35521
|
+
}
|
|
35522
|
+
async function computeBuy() {
|
|
35523
|
+
process.stdout.write(
|
|
35524
|
+
`
|
|
35525
|
+
Renting signs an x402 payment, and this CLI has no signer yet.
|
|
35526
|
+
Buy from the wallet, one biometric: ${import_picocolors3.default.cyan(`${SITE}/compute`)}
|
|
35527
|
+
Prices from here: ${import_picocolors3.default.dim("agentgates compute plans")}
|
|
35528
|
+
|
|
35529
|
+
`
|
|
35530
|
+
);
|
|
35531
|
+
}
|
|
35532
|
+
|
|
35533
|
+
// src/commands/inference.ts
|
|
35534
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
35535
|
+
var SITE2 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
35536
|
+
function applyFilters(models, f) {
|
|
35537
|
+
let out = models;
|
|
35538
|
+
if (f.tier === "confidential") out = out.filter((m) => m.confidential);
|
|
35539
|
+
else if (f.tier === "open") out = out.filter((m) => !m.confidential);
|
|
35540
|
+
for (const t of f.tag ?? []) out = out.filter((m) => (m.tags ?? []).includes(t.toLowerCase()));
|
|
35541
|
+
if (f.org) out = out.filter((m) => (m.org ?? "").toLowerCase() === f.org.toLowerCase());
|
|
35542
|
+
if (f.search) {
|
|
35543
|
+
const q = f.search.toLowerCase();
|
|
35544
|
+
out = out.filter((m) => m.id.toLowerCase().includes(q) || m.name.toLowerCase().includes(q));
|
|
35545
|
+
}
|
|
35546
|
+
return out;
|
|
35547
|
+
}
|
|
35548
|
+
var hasFilters = (f) => Boolean(f.tier || (f.tag ?? []).length || f.org || f.search);
|
|
35549
|
+
var ctx = (n) => n >= 1e6 ? `${Math.round(n / 1e6)}M` : `${Math.round(n / 1e3)}k`;
|
|
35550
|
+
async function inferenceModels(opts) {
|
|
35551
|
+
const res = await fetch(`${SITE2}/api/inference/catalog`, { headers: { accept: "application/json" } });
|
|
35552
|
+
if (!res.ok) throw new Error(`inference catalog: HTTP ${res.status}`);
|
|
35553
|
+
const body = await res.json();
|
|
35554
|
+
const all = body.models ?? [];
|
|
35555
|
+
const filtered = hasFilters(opts);
|
|
35556
|
+
const matched = applyFilters(all, opts);
|
|
35557
|
+
if (opts.json) {
|
|
35558
|
+
process.stdout.write(JSON.stringify({ ...body, models: matched }, null, 2) + "\n");
|
|
35559
|
+
return;
|
|
35560
|
+
}
|
|
35561
|
+
const shown = opts.all || filtered ? matched : matched.filter((m) => m.confidential).slice(0, 12);
|
|
35562
|
+
const headline = filtered ? `${matched.length} of ${all.length} match` : opts.all ? `all ${all.length}` : `${shown.length} confidential of ${all.length}`;
|
|
35563
|
+
process.stdout.write(`
|
|
35564
|
+
${import_picocolors4.default.bold("MODELS")} ${import_picocolors4.default.dim(headline)}
|
|
35565
|
+
|
|
35566
|
+
`);
|
|
35567
|
+
if (filtered && matched.length === 0) {
|
|
35568
|
+
const vocab = [...new Set(all.flatMap((m) => m.tags ?? []))].sort().join(", ");
|
|
35569
|
+
process.stdout.write(` ${import_picocolors4.default.dim(`nothing matches. tags on this board: ${vocab || "none"}; tiers: confidential, open`)}
|
|
35570
|
+
|
|
35571
|
+
`);
|
|
35572
|
+
return;
|
|
35573
|
+
}
|
|
35574
|
+
for (const m of shown) {
|
|
35575
|
+
const tier = m.confidential ? import_picocolors4.default.cyan("attested") : import_picocolors4.default.dim("open");
|
|
35576
|
+
const ask = m.typicalAskUsd ? `~$${Number(m.typicalAskUsd).toFixed(3)}/ask` : "";
|
|
35577
|
+
const tags = (m.tags ?? []).join(" ");
|
|
35578
|
+
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)}${tags ? ` ${import_picocolors4.default.dim(tags)}` : ""}
|
|
35579
|
+
`);
|
|
35580
|
+
process.stdout.write(` ${import_picocolors4.default.dim(m.id.padEnd(22))} ${import_picocolors4.default.dim(`$${m.priceInUsdPerMTokens} in \xB7 $${m.priceOutUsdPerMTokens} out /M`)}
|
|
35581
|
+
|
|
35582
|
+
`);
|
|
35583
|
+
}
|
|
35584
|
+
if (!opts.all && !filtered) {
|
|
35585
|
+
process.stdout.write(` ${import_picocolors4.default.dim("agentgates inference models --all \xB7 the whole board")}
|
|
35586
|
+
`);
|
|
35587
|
+
process.stdout.write(` ${import_picocolors4.default.dim("filters: --tier confidential|open \xB7 --tag frontier \xB7 --org anthropic \xB7 --search gpt")}
|
|
35588
|
+
|
|
35589
|
+
`);
|
|
35590
|
+
}
|
|
35591
|
+
}
|
|
35592
|
+
async function inferenceAsk() {
|
|
35593
|
+
process.stdout.write(
|
|
35594
|
+
`
|
|
35595
|
+
A paid ask signs an x402 leg, and this CLI has no signer yet.
|
|
35596
|
+
Ask from the wallet, one biometric: ${import_picocolors4.default.cyan(`${SITE2}/inference`)}
|
|
35597
|
+
Models and prices from here: ${import_picocolors4.default.dim("agentgates inference models")}
|
|
35598
|
+
|
|
35599
|
+
`
|
|
35600
|
+
);
|
|
35601
|
+
}
|
|
35602
|
+
|
|
35603
|
+
// src/commands/onboard.ts
|
|
35604
|
+
var WORDMARK = [
|
|
35605
|
+
" _ _",
|
|
35606
|
+
" __ _ __ _ ___ _ _| |_ __ _ __ _| |_ ___ ___",
|
|
35607
|
+
" / _` / _` / -_) ' \\ _/ _` / _` | _/ -_|_-<",
|
|
35608
|
+
" \\__,_\\__, \\___|_||_\\__\\__, \\__,_|\\__\\___/__/",
|
|
35609
|
+
" |___/ |___/"
|
|
35610
|
+
].join("\n");
|
|
35611
|
+
var TAGLINE = "Confidential virtual machines and inference, paid per use in USDC.";
|
|
35612
|
+
function makePut(w) {
|
|
35613
|
+
return (s) => {
|
|
35614
|
+
process.stdout.write(s);
|
|
35615
|
+
w?.wrote(s);
|
|
35616
|
+
};
|
|
35617
|
+
}
|
|
35618
|
+
function banner() {
|
|
35619
|
+
const w = water();
|
|
35620
|
+
if (!w) process.stdout.write("\n" + import_picocolors5.default.cyan(WORDMARK) + "\n\n");
|
|
35621
|
+
const put = makePut(w);
|
|
35622
|
+
put(` ${import_picocolors5.default.dim(TAGLINE)}
|
|
35623
|
+
|
|
35624
|
+
`);
|
|
35625
|
+
return { w, put };
|
|
35626
|
+
}
|
|
35627
|
+
var MENU = {
|
|
35628
|
+
compute: { label: "see virtual machine pricing" },
|
|
35629
|
+
models: { label: "see inference pricing" },
|
|
35630
|
+
docs: { label: "read the docs" },
|
|
35631
|
+
poke: { label: "nothing, I'll poke around" },
|
|
35632
|
+
wallet: { label: "pair my wallet", hint: "(members only)" }
|
|
35633
|
+
};
|
|
35634
|
+
function menuOrder(lane) {
|
|
35635
|
+
const browse = lane === "inference" ? ["models", "compute"] : ["compute", "models"];
|
|
35636
|
+
return [...browse, "docs", "poke", "wallet"];
|
|
35637
|
+
}
|
|
35638
|
+
function printMenu(put, order, first) {
|
|
35639
|
+
put(` ${import_picocolors5.default.bold(first ? "choose how to start:" : "what next:")}
|
|
35640
|
+
`);
|
|
35641
|
+
order.forEach((k, i) => {
|
|
35642
|
+
const item = MENU[k];
|
|
35643
|
+
put(` ${import_picocolors5.default.cyan(`${i + 1}.`)} ${item.label}${item.hint ? ` ${import_picocolors5.default.dim(item.hint)}` : ""}
|
|
35644
|
+
`);
|
|
35645
|
+
});
|
|
35646
|
+
}
|
|
35647
|
+
async function printDocs(put, lane) {
|
|
35648
|
+
const lead = lane === "inference" ? "inference" : "compute";
|
|
35649
|
+
const other = lead === "inference" ? "compute" : "inference";
|
|
35650
|
+
const name = (l) => l === "compute" ? "virtual machines" : "inference";
|
|
35651
|
+
try {
|
|
35652
|
+
const res = await fetch(`${CREATORS_ORIGIN}/api/${lead}/docs`, {
|
|
35653
|
+
headers: { accept: "text/markdown, text/plain" }
|
|
35654
|
+
});
|
|
35655
|
+
if (!res.ok) throw new Error(String(res.status));
|
|
35656
|
+
const md = (await res.text()).replace(/\s+$/, "");
|
|
35657
|
+
put(`
|
|
35658
|
+
${import_picocolors5.default.bold(`THE ${name(lead).toUpperCase()} CONTRACT`)} ${import_picocolors5.default.dim(`${CREATORS_ORIGIN}/api/${lead}/docs`)}
|
|
35659
|
+
|
|
35660
|
+
`);
|
|
35661
|
+
put(md + "\n\n");
|
|
35662
|
+
put(` ${import_picocolors5.default.dim(`the ${name(other)} contract:`)} ${CREATORS_ORIGIN}/api/${other}/docs
|
|
35663
|
+
|
|
35664
|
+
`);
|
|
35665
|
+
} catch {
|
|
35666
|
+
put(` ${import_picocolors5.default.red("\u2715")} could not fetch the contract; the URLs:
|
|
35667
|
+
`);
|
|
35668
|
+
put(` ${import_picocolors5.default.cyan("virtual machines")} ${CREATORS_ORIGIN}/api/compute/docs
|
|
35669
|
+
`);
|
|
35670
|
+
put(` ${import_picocolors5.default.cyan("inference")} ${CREATORS_ORIGIN}/api/inference/docs
|
|
35671
|
+
|
|
35672
|
+
`);
|
|
35673
|
+
}
|
|
35674
|
+
}
|
|
35675
|
+
async function onboard(opts = {}) {
|
|
35676
|
+
const profileName = opts.profile ?? DEFAULT_PROFILE;
|
|
35677
|
+
const { w, put } = banner();
|
|
35678
|
+
const existing = await loadProfile(profileName).catch(() => null);
|
|
35679
|
+
if (existing) {
|
|
35680
|
+
put(` ${import_picocolors5.default.green("\u2713")} already paired as ${import_picocolors5.default.bold(existing.walletAddress ?? existing.userId)}
|
|
35681
|
+
|
|
35682
|
+
`);
|
|
35683
|
+
}
|
|
35684
|
+
if (!process.stdin.isTTY) {
|
|
35685
|
+
put(` No terminal attached, so no menu. The machine door:
|
|
35686
|
+
|
|
35687
|
+
`);
|
|
35688
|
+
put(` agentgates compute plans --json ${import_picocolors5.default.dim("\xB7 virtual machine pricing, JSON")}
|
|
35689
|
+
`);
|
|
35690
|
+
put(` agentgates inference models --json ${import_picocolors5.default.dim("\xB7 model pricing, JSON; --tier --tag --org --search filter it")}
|
|
35691
|
+
`);
|
|
35692
|
+
put(` ${CREATORS_ORIGIN}/api/compute/docs ${import_picocolors5.default.dim("\xB7 the buy/read/renew/destroy contract")}
|
|
35693
|
+
`);
|
|
35694
|
+
put(` ${CREATORS_ORIGIN}/api/inference/docs ${import_picocolors5.default.dim("\xB7 the chat contract, x402 or Bearer")}
|
|
35695
|
+
`);
|
|
35696
|
+
put(` ${CREATORS_ORIGIN}/llms.txt ${import_picocolors5.default.dim("\xB7 the whole surface")}
|
|
35697
|
+
|
|
35698
|
+
`);
|
|
35699
|
+
if (!existing) {
|
|
35700
|
+
put(` Pairing a wallet needs a human at a browser: ${import_picocolors5.default.bold("agentgates onboard")} in a real terminal.
|
|
35701
|
+
|
|
35702
|
+
`);
|
|
35703
|
+
}
|
|
35704
|
+
return;
|
|
35705
|
+
}
|
|
35706
|
+
const order = menuOrder(opts.lane).filter((k) => existing ? k !== "wallet" : true);
|
|
35707
|
+
printMenu(put, order, true);
|
|
35708
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
35709
|
+
const exitDefault = String(order.indexOf("poke") + 1);
|
|
35710
|
+
let first = true;
|
|
35711
|
+
let plain = put;
|
|
35712
|
+
try {
|
|
35713
|
+
for (; ; ) {
|
|
35714
|
+
const fallback = first ? "1" : exitDefault;
|
|
35715
|
+
let choice;
|
|
35716
|
+
try {
|
|
35717
|
+
choice = (await rl.question(` ${import_picocolors5.default.dim(`choice [${fallback}]:`)} `)).trim() || fallback;
|
|
35718
|
+
} catch {
|
|
35719
|
+
if (first) w?.stop();
|
|
35720
|
+
process.stdout.write("\n");
|
|
35721
|
+
printNext(makePut(null));
|
|
35722
|
+
return;
|
|
35723
|
+
}
|
|
35724
|
+
if (first) {
|
|
35725
|
+
w?.stop();
|
|
35726
|
+
plain = makePut(null);
|
|
35727
|
+
first = false;
|
|
35728
|
+
}
|
|
35729
|
+
process.stdout.write("\n");
|
|
35730
|
+
const key = order[parseInt(choice, 10) - 1] ?? "poke";
|
|
35731
|
+
if (key === "poke") {
|
|
35732
|
+
printNext(plain);
|
|
35733
|
+
return;
|
|
35734
|
+
}
|
|
35735
|
+
switch (key) {
|
|
35736
|
+
case "wallet":
|
|
35737
|
+
try {
|
|
35738
|
+
await runLoginFlow({ profile: profileName, jsonMode: false, ttyHeader: "Pairing this terminal with your wallet\u2026" });
|
|
35739
|
+
process.stdout.write("\n");
|
|
35740
|
+
} catch {
|
|
35741
|
+
plain(` ${import_picocolors5.default.red("\u2715")} pairing didn't complete
|
|
35742
|
+
|
|
35743
|
+
`);
|
|
35744
|
+
}
|
|
35745
|
+
break;
|
|
35746
|
+
case "compute":
|
|
35747
|
+
try {
|
|
35748
|
+
await computePlans({});
|
|
35749
|
+
} catch {
|
|
35750
|
+
plain(` ${import_picocolors5.default.red("\u2715")} could not read the compute catalog
|
|
35751
|
+
|
|
35752
|
+
`);
|
|
35753
|
+
}
|
|
35754
|
+
break;
|
|
35755
|
+
case "models":
|
|
35756
|
+
try {
|
|
35757
|
+
await inferenceModels({});
|
|
35758
|
+
} catch {
|
|
35759
|
+
plain(` ${import_picocolors5.default.red("\u2715")} could not read the model catalog
|
|
35760
|
+
|
|
35761
|
+
`);
|
|
35762
|
+
}
|
|
35763
|
+
break;
|
|
35764
|
+
case "docs":
|
|
35765
|
+
await printDocs(plain, opts.lane);
|
|
35766
|
+
break;
|
|
35767
|
+
}
|
|
35768
|
+
printMenu(plain, order, false);
|
|
35769
|
+
}
|
|
35770
|
+
} finally {
|
|
35771
|
+
rl.close();
|
|
35772
|
+
}
|
|
35773
|
+
}
|
|
35774
|
+
function printNext(put) {
|
|
35775
|
+
put(` ${import_picocolors5.default.dim("agentgates compute plans")} ${import_picocolors5.default.dim("\xB7 virtual machines by the hour")}
|
|
35776
|
+
`);
|
|
35777
|
+
put(` ${import_picocolors5.default.dim("agentgates inference models")} ${import_picocolors5.default.dim("\xB7 models by the token")}
|
|
35778
|
+
`);
|
|
35779
|
+
put(` ${import_picocolors5.default.dim("agentgates --help")} ${import_picocolors5.default.dim("\xB7 everything else")}
|
|
35780
|
+
|
|
35781
|
+
`);
|
|
35782
|
+
}
|
|
35783
|
+
|
|
35784
|
+
// src/commands/logout.ts
|
|
35785
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
35350
35786
|
async function logout(opts) {
|
|
35351
35787
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
35352
35788
|
const resolved = await resolveProfile(requested);
|
|
35353
35789
|
if (!resolved) {
|
|
35354
|
-
process.stdout.write(
|
|
35790
|
+
process.stdout.write(import_picocolors6.default.dim("Not logged in \u2014 nothing to log out.\n"));
|
|
35355
35791
|
return;
|
|
35356
35792
|
}
|
|
35357
35793
|
if (resolved.autoSelected) {
|
|
35358
|
-
process.stderr.write(
|
|
35794
|
+
process.stderr.write(import_picocolors6.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
35359
35795
|
`));
|
|
35360
35796
|
}
|
|
35361
35797
|
const { profile, name: profileName } = resolved;
|
|
@@ -35380,15 +35816,15 @@ async function logout(opts) {
|
|
|
35380
35816
|
const removed = await deleteProfile(profileName);
|
|
35381
35817
|
if (removed) {
|
|
35382
35818
|
process.stdout.write(
|
|
35383
|
-
|
|
35819
|
+
import_picocolors6.default.green(`\u2713 Logged out of profile ${import_picocolors6.default.bold(profileName)}.
|
|
35384
35820
|
`)
|
|
35385
35821
|
);
|
|
35386
35822
|
}
|
|
35387
35823
|
if (serverError) {
|
|
35388
35824
|
process.stderr.write(
|
|
35389
|
-
|
|
35825
|
+
import_picocolors6.default.yellow(
|
|
35390
35826
|
`\u26A0 Couldn't revoke server-side: ${serverError}
|
|
35391
|
-
The local bearer is wiped. If the server still has it, revoke from ${
|
|
35827
|
+
The local bearer is wiped. If the server still has it, revoke from ${import_picocolors6.default.bold("agentgates.ai/settings/pairings")}.
|
|
35392
35828
|
`
|
|
35393
35829
|
)
|
|
35394
35830
|
);
|
|
@@ -35396,16 +35832,16 @@ async function logout(opts) {
|
|
|
35396
35832
|
}
|
|
35397
35833
|
|
|
35398
35834
|
// src/commands/whoami.ts
|
|
35399
|
-
var
|
|
35835
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
35400
35836
|
async function whoami(opts) {
|
|
35401
35837
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
35402
35838
|
const resolved = await resolveProfile(requested);
|
|
35403
35839
|
if (!resolved) {
|
|
35404
|
-
process.stderr.write(
|
|
35840
|
+
process.stderr.write(import_picocolors7.default.red("Not logged in. Run agentgates login first.\n"));
|
|
35405
35841
|
process.exit(2);
|
|
35406
35842
|
}
|
|
35407
35843
|
if (resolved.autoSelected) {
|
|
35408
|
-
process.stderr.write(
|
|
35844
|
+
process.stderr.write(import_picocolors7.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
35409
35845
|
`));
|
|
35410
35846
|
}
|
|
35411
35847
|
const { profile, name: profileName } = resolved;
|
|
@@ -35414,7 +35850,7 @@ async function whoami(opts) {
|
|
|
35414
35850
|
profile,
|
|
35415
35851
|
profileName,
|
|
35416
35852
|
jsonMode,
|
|
35417
|
-
ttyHeader:
|
|
35853
|
+
ttyHeader: import_picocolors7.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
35418
35854
|
fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
|
|
35419
35855
|
});
|
|
35420
35856
|
if (outcome.kind === "auth_failed") {
|
|
@@ -35424,14 +35860,14 @@ async function whoami(opts) {
|
|
|
35424
35860
|
);
|
|
35425
35861
|
process.exit(1);
|
|
35426
35862
|
}
|
|
35427
|
-
process.stderr.write(
|
|
35863
|
+
process.stderr.write(import_picocolors7.default.red(`\u2715 ${outcome.reason}.
|
|
35428
35864
|
`));
|
|
35429
35865
|
process.exit(1);
|
|
35430
35866
|
}
|
|
35431
35867
|
if (outcome.kind === "error") {
|
|
35432
35868
|
const err = outcome.error;
|
|
35433
35869
|
if (err instanceof ApiError) {
|
|
35434
|
-
process.stderr.write(
|
|
35870
|
+
process.stderr.write(import_picocolors7.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
35435
35871
|
`));
|
|
35436
35872
|
process.exit(1);
|
|
35437
35873
|
}
|
|
@@ -35452,7 +35888,7 @@ async function whoami(opts) {
|
|
|
35452
35888
|
process.stdout.write(`Solana ${me.solanaAddress}
|
|
35453
35889
|
`);
|
|
35454
35890
|
}
|
|
35455
|
-
process.stdout.write(`Scopes ${me.scopes.join(", ") ||
|
|
35891
|
+
process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors7.default.dim("(none)")}
|
|
35456
35892
|
`);
|
|
35457
35893
|
const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
|
|
35458
35894
|
const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
|
|
@@ -35469,7 +35905,7 @@ async function whoami(opts) {
|
|
|
35469
35905
|
`
|
|
35470
35906
|
);
|
|
35471
35907
|
process.stdout.write(
|
|
35472
|
-
`Profile ${profileName === DEFAULT_PROFILE ?
|
|
35908
|
+
`Profile ${profileName === DEFAULT_PROFILE ? import_picocolors7.default.dim("(default)") : profileName}
|
|
35473
35909
|
`
|
|
35474
35910
|
);
|
|
35475
35911
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -35483,7 +35919,7 @@ function formatDate(iso) {
|
|
|
35483
35919
|
}
|
|
35484
35920
|
|
|
35485
35921
|
// src/commands/send.ts
|
|
35486
|
-
var
|
|
35922
|
+
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
35487
35923
|
|
|
35488
35924
|
// src/lib/status.ts
|
|
35489
35925
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -35633,11 +36069,11 @@ async function send(amount, asset, opts) {
|
|
|
35633
36069
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
35634
36070
|
const resolved = await resolveProfile(requested);
|
|
35635
36071
|
if (!resolved) {
|
|
35636
|
-
process.stderr.write(
|
|
36072
|
+
process.stderr.write(import_picocolors8.default.red("Not logged in. Run agentgates login first.\n"));
|
|
35637
36073
|
process.exit(2);
|
|
35638
36074
|
}
|
|
35639
36075
|
if (resolved.autoSelected) {
|
|
35640
|
-
process.stderr.write(
|
|
36076
|
+
process.stderr.write(import_picocolors8.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
35641
36077
|
`));
|
|
35642
36078
|
}
|
|
35643
36079
|
const { profile, name: profileName } = resolved;
|
|
@@ -35646,7 +36082,7 @@ async function send(amount, asset, opts) {
|
|
|
35646
36082
|
const amountNumber = Number(amount);
|
|
35647
36083
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
35648
36084
|
process.stderr.write(
|
|
35649
|
-
|
|
36085
|
+
import_picocolors8.default.red(`\u2715 amount must be a positive number (got ${import_picocolors8.default.bold(amount)}).
|
|
35650
36086
|
`)
|
|
35651
36087
|
);
|
|
35652
36088
|
process.exit(2);
|
|
@@ -35654,23 +36090,23 @@ async function send(amount, asset, opts) {
|
|
|
35654
36090
|
const assetNormalized = asset.toLowerCase();
|
|
35655
36091
|
if (assetNormalized !== "native" && assetNormalized !== "usdc") {
|
|
35656
36092
|
process.stderr.write(
|
|
35657
|
-
|
|
35658
|
-
`\u2715 asset must be ${
|
|
36093
|
+
import_picocolors8.default.red(
|
|
36094
|
+
`\u2715 asset must be ${import_picocolors8.default.bold("native")} or ${import_picocolors8.default.bold("usdc")} (got ${import_picocolors8.default.bold(asset)}).
|
|
35659
36095
|
`
|
|
35660
36096
|
)
|
|
35661
36097
|
);
|
|
35662
36098
|
process.exit(2);
|
|
35663
36099
|
}
|
|
35664
36100
|
if (!opts.to || opts.to.trim() === "") {
|
|
35665
|
-
process.stderr.write(
|
|
36101
|
+
process.stderr.write(import_picocolors8.default.red(`\u2715 --to <address> is required.
|
|
35666
36102
|
`));
|
|
35667
36103
|
process.exit(2);
|
|
35668
36104
|
}
|
|
35669
36105
|
if (isSolanaChainAlias(opts.chain)) {
|
|
35670
36106
|
if (EVM_ADDRESS_RE.test(opts.to)) {
|
|
35671
36107
|
process.stderr.write(
|
|
35672
|
-
|
|
35673
|
-
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${
|
|
36108
|
+
import_picocolors8.default.red(
|
|
36109
|
+
`\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
36110
|
`
|
|
35675
36111
|
)
|
|
35676
36112
|
);
|
|
@@ -35678,10 +36114,10 @@ async function send(amount, asset, opts) {
|
|
|
35678
36114
|
}
|
|
35679
36115
|
if (!SOLANA_ADDRESS_RE.test(opts.to)) {
|
|
35680
36116
|
process.stderr.write(
|
|
35681
|
-
|
|
35682
|
-
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${
|
|
36117
|
+
import_picocolors8.default.red(
|
|
36118
|
+
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors8.default.bold(opts.to)}).
|
|
35683
36119
|
`
|
|
35684
|
-
) +
|
|
36120
|
+
) + import_picocolors8.default.dim(
|
|
35685
36121
|
` SNS resolution is deferred to a future server-side change;
|
|
35686
36122
|
for now Solana sends require the literal pubkey.
|
|
35687
36123
|
`
|
|
@@ -35692,8 +36128,8 @@ async function send(amount, asset, opts) {
|
|
|
35692
36128
|
}
|
|
35693
36129
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
35694
36130
|
process.stderr.write(
|
|
35695
|
-
|
|
35696
|
-
`) +
|
|
36131
|
+
import_picocolors8.default.red(`\u2715 --user-stated <text> is required.
|
|
36132
|
+
`) + import_picocolors8.default.dim(
|
|
35697
36133
|
` This is the trust-gap defense: pass the verbatim user request so
|
|
35698
36134
|
the approval modal can cross-check what the agent thinks the user
|
|
35699
36135
|
asked for vs. the actual decoded transaction.
|
|
@@ -35711,7 +36147,7 @@ async function send(amount, asset, opts) {
|
|
|
35711
36147
|
const n = Number(opts.maxUsd);
|
|
35712
36148
|
if (!Number.isFinite(n) || n <= 0) {
|
|
35713
36149
|
process.stderr.write(
|
|
35714
|
-
|
|
36150
|
+
import_picocolors8.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
|
|
35715
36151
|
`)
|
|
35716
36152
|
);
|
|
35717
36153
|
process.exit(2);
|
|
@@ -35753,7 +36189,7 @@ async function send(amount, asset, opts) {
|
|
|
35753
36189
|
profile: profileName,
|
|
35754
36190
|
jsonMode,
|
|
35755
36191
|
origin: activeProfile.mcpOrigin,
|
|
35756
|
-
ttyHeader:
|
|
36192
|
+
ttyHeader: import_picocolors8.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
35757
36193
|
});
|
|
35758
36194
|
} catch (reloginErr) {
|
|
35759
36195
|
if (jsonMode) {
|
|
@@ -35765,7 +36201,7 @@ async function send(amount, asset, opts) {
|
|
|
35765
36201
|
process.exit(1);
|
|
35766
36202
|
}
|
|
35767
36203
|
process.stderr.write(
|
|
35768
|
-
|
|
36204
|
+
import_picocolors8.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
35769
36205
|
`)
|
|
35770
36206
|
);
|
|
35771
36207
|
process.exit(1);
|
|
@@ -35789,7 +36225,7 @@ async function send(amount, asset, opts) {
|
|
|
35789
36225
|
process.exit(1);
|
|
35790
36226
|
}
|
|
35791
36227
|
process.stderr.write(
|
|
35792
|
-
|
|
36228
|
+
import_picocolors8.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
35793
36229
|
`)
|
|
35794
36230
|
);
|
|
35795
36231
|
process.exit(1);
|
|
@@ -35806,7 +36242,7 @@ async function send(amount, asset, opts) {
|
|
|
35806
36242
|
});
|
|
35807
36243
|
process.exit(1);
|
|
35808
36244
|
}
|
|
35809
|
-
process.stderr.write(
|
|
36245
|
+
process.stderr.write(import_picocolors8.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
35810
36246
|
`));
|
|
35811
36247
|
process.exit(1);
|
|
35812
36248
|
} else {
|
|
@@ -35832,17 +36268,17 @@ async function send(amount, asset, opts) {
|
|
|
35832
36268
|
if (proposed.detail) {
|
|
35833
36269
|
const d = proposed.detail;
|
|
35834
36270
|
process.stderr.write(
|
|
35835
|
-
|
|
36271
|
+
import_picocolors8.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
|
|
35836
36272
|
`
|
|
35837
36273
|
);
|
|
35838
36274
|
} else {
|
|
35839
|
-
process.stderr.write(
|
|
36275
|
+
process.stderr.write(import_picocolors8.default.red(`\u2715 ${proposed.reason}
|
|
35840
36276
|
`));
|
|
35841
36277
|
}
|
|
35842
36278
|
if (proposed.upgrade_url) {
|
|
35843
36279
|
process.stderr.write(
|
|
35844
36280
|
` Open this to grant access, then re-run the command:
|
|
35845
|
-
${
|
|
36281
|
+
${import_picocolors8.default.cyan(proposed.upgrade_url)}
|
|
35846
36282
|
`
|
|
35847
36283
|
);
|
|
35848
36284
|
}
|
|
@@ -35852,21 +36288,21 @@ async function send(amount, asset, opts) {
|
|
|
35852
36288
|
const a = proposed.recommended_actions[i];
|
|
35853
36289
|
process.stderr.write(` ${i + 1}. ${a.label}
|
|
35854
36290
|
`);
|
|
35855
|
-
if (a.reasoning) process.stderr.write(
|
|
36291
|
+
if (a.reasoning) process.stderr.write(import_picocolors8.default.dim(` ${a.reasoning}
|
|
35856
36292
|
`));
|
|
35857
36293
|
if (a.action_intent && a.action_intent.external_url) {
|
|
35858
36294
|
process.stderr.write(
|
|
35859
|
-
` ${
|
|
36295
|
+
` ${import_picocolors8.default.cyan(a.action_intent.external_url)}
|
|
35860
36296
|
`
|
|
35861
36297
|
);
|
|
35862
36298
|
}
|
|
35863
36299
|
}
|
|
35864
36300
|
}
|
|
35865
36301
|
if (proposed.suggestions && proposed.suggestions.length > 0) {
|
|
35866
|
-
process.stderr.write(
|
|
36302
|
+
process.stderr.write(import_picocolors8.default.dim("\n Other ways to fund:\n"));
|
|
35867
36303
|
for (const s of proposed.suggestions) {
|
|
35868
36304
|
if (s.kind === "ask_user") continue;
|
|
35869
|
-
process.stderr.write(
|
|
36305
|
+
process.stderr.write(import_picocolors8.default.dim(` \u2022 ${s.label}
|
|
35870
36306
|
`));
|
|
35871
36307
|
}
|
|
35872
36308
|
}
|
|
@@ -35893,8 +36329,8 @@ async function send(amount, asset, opts) {
|
|
|
35893
36329
|
} else {
|
|
35894
36330
|
process.stdout.write(
|
|
35895
36331
|
`
|
|
35896
|
-
${
|
|
35897
|
-
${
|
|
36332
|
+
${import_picocolors8.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
36333
|
+
${import_picocolors8.default.cyan(proposed.approval_url)}
|
|
35898
36334
|
|
|
35899
36335
|
`
|
|
35900
36336
|
);
|
|
@@ -35913,7 +36349,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35913
36349
|
if (jsonMode) {
|
|
35914
36350
|
emitNdjson({ status: s.status, intent_id: s.approval_id });
|
|
35915
36351
|
} else {
|
|
35916
|
-
process.stdout.write(` ${describeStatus(s.status)}${
|
|
36352
|
+
process.stdout.write(` ${describeStatus(s.status)}${import_picocolors8.default.dim("\u2026")}\r`);
|
|
35917
36353
|
}
|
|
35918
36354
|
}
|
|
35919
36355
|
});
|
|
@@ -35927,7 +36363,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35927
36363
|
profile: profileName,
|
|
35928
36364
|
jsonMode,
|
|
35929
36365
|
origin: activeProfile.mcpOrigin,
|
|
35930
|
-
ttyHeader:
|
|
36366
|
+
ttyHeader: import_picocolors8.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
|
|
35931
36367
|
});
|
|
35932
36368
|
} catch (reloginErr) {
|
|
35933
36369
|
if (jsonMode) {
|
|
@@ -35940,7 +36376,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35940
36376
|
process.exit(1);
|
|
35941
36377
|
}
|
|
35942
36378
|
process.stderr.write(
|
|
35943
|
-
"\n" +
|
|
36379
|
+
"\n" + import_picocolors8.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
35944
36380
|
`)
|
|
35945
36381
|
);
|
|
35946
36382
|
process.exit(1);
|
|
@@ -35958,7 +36394,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35958
36394
|
process.exit(1);
|
|
35959
36395
|
}
|
|
35960
36396
|
process.stderr.write(
|
|
35961
|
-
"\n" +
|
|
36397
|
+
"\n" + import_picocolors8.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
35962
36398
|
`)
|
|
35963
36399
|
);
|
|
35964
36400
|
process.exit(1);
|
|
@@ -35974,7 +36410,7 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35974
36410
|
process.exit(1);
|
|
35975
36411
|
}
|
|
35976
36412
|
process.stderr.write(
|
|
35977
|
-
"\n" +
|
|
36413
|
+
"\n" + import_picocolors8.default.red(`\u2715 Status poll failed: ${err.message}
|
|
35978
36414
|
`)
|
|
35979
36415
|
);
|
|
35980
36416
|
process.exit(1);
|
|
@@ -35994,19 +36430,19 @@ ${import_picocolors5.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
35994
36430
|
}
|
|
35995
36431
|
process.stdout.write("\n");
|
|
35996
36432
|
if (final.status === "mined") {
|
|
35997
|
-
process.stdout.write(
|
|
36433
|
+
process.stdout.write(import_picocolors8.default.green("\u2713 Mined.") + "\n");
|
|
35998
36434
|
if (final.tx_hash) {
|
|
35999
36435
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
36000
36436
|
`);
|
|
36001
36437
|
}
|
|
36002
36438
|
if (explorer) {
|
|
36003
|
-
process.stdout.write(` Explorer ${
|
|
36439
|
+
process.stdout.write(` Explorer ${import_picocolors8.default.cyan(explorer)}
|
|
36004
36440
|
`);
|
|
36005
36441
|
}
|
|
36006
36442
|
process.exit(0);
|
|
36007
36443
|
}
|
|
36008
36444
|
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(
|
|
36445
|
+
process.stderr.write(import_picocolors8.default.red(`\u2715 ${label}.
|
|
36010
36446
|
`));
|
|
36011
36447
|
process.exit(1);
|
|
36012
36448
|
}
|
|
@@ -36034,7 +36470,7 @@ function describeStatus(s) {
|
|
|
36034
36470
|
}
|
|
36035
36471
|
|
|
36036
36472
|
// src/commands/status.ts
|
|
36037
|
-
var
|
|
36473
|
+
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
36038
36474
|
var WATCH_GIVEUP_MS = 10 * 6e4;
|
|
36039
36475
|
function explorerUrl2(chainId, hash) {
|
|
36040
36476
|
switch (chainId) {
|
|
@@ -36052,17 +36488,17 @@ function explorerUrl2(chainId, hash) {
|
|
|
36052
36488
|
}
|
|
36053
36489
|
async function status(intentId, opts) {
|
|
36054
36490
|
if (!intentId || intentId.trim() === "") {
|
|
36055
|
-
process.stderr.write(
|
|
36491
|
+
process.stderr.write(import_picocolors9.default.red("\u2715 Missing intent id.\n"));
|
|
36056
36492
|
process.exit(2);
|
|
36057
36493
|
}
|
|
36058
36494
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
36059
36495
|
const resolved = await resolveProfile(requested);
|
|
36060
36496
|
if (!resolved) {
|
|
36061
|
-
process.stderr.write(
|
|
36497
|
+
process.stderr.write(import_picocolors9.default.red("Not logged in. Run agentgates login first.\n"));
|
|
36062
36498
|
process.exit(2);
|
|
36063
36499
|
}
|
|
36064
36500
|
if (resolved.autoSelected) {
|
|
36065
|
-
process.stderr.write(
|
|
36501
|
+
process.stderr.write(import_picocolors9.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
36066
36502
|
`));
|
|
36067
36503
|
}
|
|
36068
36504
|
const { profile, name: profileName } = resolved;
|
|
@@ -36071,7 +36507,7 @@ async function status(intentId, opts) {
|
|
|
36071
36507
|
profile,
|
|
36072
36508
|
profileName,
|
|
36073
36509
|
jsonMode,
|
|
36074
|
-
ttyHeader:
|
|
36510
|
+
ttyHeader: import_picocolors9.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
36075
36511
|
fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
|
|
36076
36512
|
});
|
|
36077
36513
|
if (outcome.kind === "auth_failed") {
|
|
@@ -36081,7 +36517,7 @@ async function status(intentId, opts) {
|
|
|
36081
36517
|
);
|
|
36082
36518
|
process.exit(1);
|
|
36083
36519
|
}
|
|
36084
|
-
process.stderr.write(
|
|
36520
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 ${outcome.reason}.
|
|
36085
36521
|
`));
|
|
36086
36522
|
process.exit(1);
|
|
36087
36523
|
}
|
|
@@ -36089,11 +36525,11 @@ async function status(intentId, opts) {
|
|
|
36089
36525
|
const err = outcome.error;
|
|
36090
36526
|
if (err instanceof ApiError) {
|
|
36091
36527
|
if (err.status === 404) {
|
|
36092
|
-
process.stderr.write(
|
|
36528
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 No intent with id ${intentId}.
|
|
36093
36529
|
`));
|
|
36094
36530
|
process.exit(1);
|
|
36095
36531
|
}
|
|
36096
|
-
process.stderr.write(
|
|
36532
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
36097
36533
|
`));
|
|
36098
36534
|
process.exit(1);
|
|
36099
36535
|
}
|
|
@@ -36104,7 +36540,7 @@ async function status(intentId, opts) {
|
|
|
36104
36540
|
if (opts.watch && !isTerminalStatus(snap.status)) {
|
|
36105
36541
|
if (!jsonMode) {
|
|
36106
36542
|
printSnap(snap);
|
|
36107
|
-
process.stdout.write(
|
|
36543
|
+
process.stdout.write(import_picocolors9.default.dim("Watching\u2026\n"));
|
|
36108
36544
|
}
|
|
36109
36545
|
const runWatchPoll = (p) => streamStatusUntilTerminal({
|
|
36110
36546
|
intentId,
|
|
@@ -36115,7 +36551,7 @@ async function status(intentId, opts) {
|
|
|
36115
36551
|
giveUpMs: WATCH_GIVEUP_MS,
|
|
36116
36552
|
onTick: (s) => {
|
|
36117
36553
|
if (!jsonMode) {
|
|
36118
|
-
process.stdout.write(` ${
|
|
36554
|
+
process.stdout.write(` ${import_picocolors9.default.dim("\u2192")} ${s.status}
|
|
36119
36555
|
`);
|
|
36120
36556
|
}
|
|
36121
36557
|
}
|
|
@@ -36130,7 +36566,7 @@ async function status(intentId, opts) {
|
|
|
36130
36566
|
profile: profileName,
|
|
36131
36567
|
jsonMode,
|
|
36132
36568
|
origin: activeProfile.mcpOrigin,
|
|
36133
|
-
ttyHeader:
|
|
36569
|
+
ttyHeader: import_picocolors9.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
|
|
36134
36570
|
});
|
|
36135
36571
|
} catch (reloginErr) {
|
|
36136
36572
|
if (jsonMode) {
|
|
@@ -36144,7 +36580,7 @@ async function status(intentId, opts) {
|
|
|
36144
36580
|
process.exit(1);
|
|
36145
36581
|
}
|
|
36146
36582
|
process.stderr.write(
|
|
36147
|
-
|
|
36583
|
+
import_picocolors9.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
36148
36584
|
`)
|
|
36149
36585
|
);
|
|
36150
36586
|
process.exit(1);
|
|
@@ -36152,12 +36588,12 @@ async function status(intentId, opts) {
|
|
|
36152
36588
|
try {
|
|
36153
36589
|
final = await runWatchPoll(activeProfile);
|
|
36154
36590
|
} catch (retryErr) {
|
|
36155
|
-
process.stderr.write(
|
|
36591
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 ${retryErr.message}
|
|
36156
36592
|
`));
|
|
36157
36593
|
process.exit(1);
|
|
36158
36594
|
}
|
|
36159
36595
|
} else {
|
|
36160
|
-
process.stderr.write(
|
|
36596
|
+
process.stderr.write(import_picocolors9.default.red(`\u2715 ${err.message}
|
|
36161
36597
|
`));
|
|
36162
36598
|
process.exit(1);
|
|
36163
36599
|
}
|
|
@@ -36178,7 +36614,7 @@ async function status(intentId, opts) {
|
|
|
36178
36614
|
}
|
|
36179
36615
|
function printSnap(s) {
|
|
36180
36616
|
const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
|
|
36181
|
-
const colorFn = s.status === "mined" ?
|
|
36617
|
+
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
36618
|
process.stdout.write(`Intent ${s.approval_id}
|
|
36183
36619
|
`);
|
|
36184
36620
|
process.stdout.write(`Status ${colorFn(s.status)}
|
|
@@ -36193,12 +36629,12 @@ function printSnap(s) {
|
|
|
36193
36629
|
process.stdout.write(`Tx ${s.tx_hash}
|
|
36194
36630
|
`);
|
|
36195
36631
|
if (explorer) {
|
|
36196
|
-
process.stdout.write(`Explorer ${
|
|
36632
|
+
process.stdout.write(`Explorer ${import_picocolors9.default.cyan(explorer)}
|
|
36197
36633
|
`);
|
|
36198
36634
|
}
|
|
36199
36635
|
}
|
|
36200
36636
|
if (!isTerminalStatus(s.status)) {
|
|
36201
|
-
process.stdout.write(`Approve ${
|
|
36637
|
+
process.stdout.write(`Approve ${import_picocolors9.default.cyan(s.approval_url)}
|
|
36202
36638
|
`);
|
|
36203
36639
|
}
|
|
36204
36640
|
process.stdout.write(`Created ${formatDate2(s.created_at)}
|
|
@@ -36215,7 +36651,7 @@ function formatDate2(iso) {
|
|
|
36215
36651
|
}
|
|
36216
36652
|
|
|
36217
36653
|
// src/commands/balance.ts
|
|
36218
|
-
var
|
|
36654
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
36219
36655
|
var CHAIN_ALIASES = {
|
|
36220
36656
|
"1": 1,
|
|
36221
36657
|
ethereum: 1,
|
|
@@ -36238,11 +36674,11 @@ async function balance(opts) {
|
|
|
36238
36674
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
36239
36675
|
const resolved = await resolveProfile(requested);
|
|
36240
36676
|
if (!resolved) {
|
|
36241
|
-
process.stderr.write(
|
|
36677
|
+
process.stderr.write(import_picocolors10.default.red("Not logged in. Run agentgates login first.\n"));
|
|
36242
36678
|
process.exit(2);
|
|
36243
36679
|
}
|
|
36244
36680
|
if (resolved.autoSelected) {
|
|
36245
|
-
process.stderr.write(
|
|
36681
|
+
process.stderr.write(import_picocolors10.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
36246
36682
|
`));
|
|
36247
36683
|
}
|
|
36248
36684
|
const { profile, name: profileName } = resolved;
|
|
@@ -36252,8 +36688,8 @@ async function balance(opts) {
|
|
|
36252
36688
|
const id = CHAIN_ALIASES[key];
|
|
36253
36689
|
if (id === void 0) {
|
|
36254
36690
|
process.stderr.write(
|
|
36255
|
-
|
|
36256
|
-
`\u2715 Unknown chain ${
|
|
36691
|
+
import_picocolors10.default.red(
|
|
36692
|
+
`\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
36693
|
`
|
|
36258
36694
|
)
|
|
36259
36695
|
);
|
|
@@ -36266,7 +36702,7 @@ async function balance(opts) {
|
|
|
36266
36702
|
profile,
|
|
36267
36703
|
profileName,
|
|
36268
36704
|
jsonMode,
|
|
36269
|
-
ttyHeader:
|
|
36705
|
+
ttyHeader: import_picocolors10.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
36270
36706
|
fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
|
|
36271
36707
|
});
|
|
36272
36708
|
if (outcome.kind === "auth_failed") {
|
|
@@ -36276,14 +36712,14 @@ async function balance(opts) {
|
|
|
36276
36712
|
);
|
|
36277
36713
|
process.exit(1);
|
|
36278
36714
|
}
|
|
36279
|
-
process.stderr.write(
|
|
36715
|
+
process.stderr.write(import_picocolors10.default.red(`\u2715 ${outcome.reason}.
|
|
36280
36716
|
`));
|
|
36281
36717
|
process.exit(1);
|
|
36282
36718
|
}
|
|
36283
36719
|
if (outcome.kind === "error") {
|
|
36284
36720
|
const err = outcome.error;
|
|
36285
36721
|
if (err instanceof ApiError) {
|
|
36286
|
-
process.stderr.write(
|
|
36722
|
+
process.stderr.write(import_picocolors10.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
36287
36723
|
`));
|
|
36288
36724
|
process.exit(1);
|
|
36289
36725
|
}
|
|
@@ -36313,7 +36749,7 @@ async function balance(opts) {
|
|
|
36313
36749
|
}
|
|
36314
36750
|
if (filtered.length === 0) {
|
|
36315
36751
|
process.stdout.write(
|
|
36316
|
-
|
|
36752
|
+
import_picocolors10.default.dim(
|
|
36317
36753
|
chainFilter !== null ? `No balances on chain ${chainFilter}.
|
|
36318
36754
|
` : `No chain balances returned.
|
|
36319
36755
|
`
|
|
@@ -36325,7 +36761,7 @@ async function balance(opts) {
|
|
|
36325
36761
|
const errorLines = [];
|
|
36326
36762
|
for (const c of filtered) {
|
|
36327
36763
|
if (c.error) {
|
|
36328
|
-
errorLines.push(`${c.chainName} ${
|
|
36764
|
+
errorLines.push(`${c.chainName} ${import_picocolors10.default.red(`(read failed: ${c.error})`)}`);
|
|
36329
36765
|
continue;
|
|
36330
36766
|
}
|
|
36331
36767
|
if (c.native.balance > 0) {
|
|
@@ -36346,7 +36782,7 @@ async function balance(opts) {
|
|
|
36346
36782
|
}
|
|
36347
36783
|
}
|
|
36348
36784
|
if (rows.length === 0 && errorLines.length === 0) {
|
|
36349
|
-
process.stdout.write(
|
|
36785
|
+
process.stdout.write(import_picocolors10.default.dim(`All balances are zero.
|
|
36350
36786
|
`));
|
|
36351
36787
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
36352
36788
|
return;
|
|
@@ -36356,7 +36792,7 @@ async function balance(opts) {
|
|
|
36356
36792
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
36357
36793
|
const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
|
|
36358
36794
|
const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
|
|
36359
|
-
process.stdout.write(
|
|
36795
|
+
process.stdout.write(import_picocolors10.default.dim(header) + "\n");
|
|
36360
36796
|
for (const r of rows) {
|
|
36361
36797
|
process.stdout.write(
|
|
36362
36798
|
r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
|
|
@@ -36369,7 +36805,7 @@ async function balance(opts) {
|
|
|
36369
36805
|
`);
|
|
36370
36806
|
}
|
|
36371
36807
|
if (res.fetched_at) {
|
|
36372
|
-
process.stdout.write("\n" +
|
|
36808
|
+
process.stdout.write("\n" + import_picocolors10.default.dim(`Fetched ${res.fetched_at}
|
|
36373
36809
|
`));
|
|
36374
36810
|
}
|
|
36375
36811
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -36382,18 +36818,18 @@ function formatBalance(value, decimals) {
|
|
|
36382
36818
|
}
|
|
36383
36819
|
|
|
36384
36820
|
// src/commands/history.ts
|
|
36385
|
-
var
|
|
36821
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
36386
36822
|
var DEFAULT_LIMIT = 20;
|
|
36387
36823
|
var SERVER_MAX_LIMIT = 100;
|
|
36388
36824
|
async function history(opts) {
|
|
36389
36825
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
36390
36826
|
const resolved = await resolveProfile(requested);
|
|
36391
36827
|
if (!resolved) {
|
|
36392
|
-
process.stderr.write(
|
|
36828
|
+
process.stderr.write(import_picocolors11.default.red("Not logged in. Run agentgates login first.\n"));
|
|
36393
36829
|
process.exit(2);
|
|
36394
36830
|
}
|
|
36395
36831
|
if (resolved.autoSelected) {
|
|
36396
|
-
process.stderr.write(
|
|
36832
|
+
process.stderr.write(import_picocolors11.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
36397
36833
|
`));
|
|
36398
36834
|
}
|
|
36399
36835
|
const { profile, name: profileName } = resolved;
|
|
@@ -36402,14 +36838,14 @@ async function history(opts) {
|
|
|
36402
36838
|
const n = Number(opts.limit);
|
|
36403
36839
|
if (!Number.isFinite(n) || n <= 0 || !Number.isInteger(n)) {
|
|
36404
36840
|
process.stderr.write(
|
|
36405
|
-
|
|
36841
|
+
import_picocolors11.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors11.default.bold(opts.limit)}).
|
|
36406
36842
|
`)
|
|
36407
36843
|
);
|
|
36408
36844
|
process.exit(2);
|
|
36409
36845
|
}
|
|
36410
36846
|
if (n > SERVER_MAX_LIMIT) {
|
|
36411
36847
|
process.stderr.write(
|
|
36412
|
-
|
|
36848
|
+
import_picocolors11.default.red(
|
|
36413
36849
|
`\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n}.
|
|
36414
36850
|
`
|
|
36415
36851
|
)
|
|
@@ -36423,7 +36859,7 @@ async function history(opts) {
|
|
|
36423
36859
|
profile,
|
|
36424
36860
|
profileName,
|
|
36425
36861
|
jsonMode,
|
|
36426
|
-
ttyHeader:
|
|
36862
|
+
ttyHeader: import_picocolors11.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
36427
36863
|
fn: (bearer, origin) => apiFetch(
|
|
36428
36864
|
`/api/history?limit=${encodeURIComponent(String(limit))}`,
|
|
36429
36865
|
{ bearer, origin }
|
|
@@ -36436,14 +36872,14 @@ async function history(opts) {
|
|
|
36436
36872
|
);
|
|
36437
36873
|
process.exit(1);
|
|
36438
36874
|
}
|
|
36439
|
-
process.stderr.write(
|
|
36875
|
+
process.stderr.write(import_picocolors11.default.red(`\u2715 ${outcome.reason}.
|
|
36440
36876
|
`));
|
|
36441
36877
|
process.exit(1);
|
|
36442
36878
|
}
|
|
36443
36879
|
if (outcome.kind === "error") {
|
|
36444
36880
|
const err = outcome.error;
|
|
36445
36881
|
if (err instanceof ApiError) {
|
|
36446
|
-
process.stderr.write(
|
|
36882
|
+
process.stderr.write(import_picocolors11.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
36447
36883
|
`));
|
|
36448
36884
|
process.exit(1);
|
|
36449
36885
|
}
|
|
@@ -36460,7 +36896,7 @@ async function history(opts) {
|
|
|
36460
36896
|
return;
|
|
36461
36897
|
}
|
|
36462
36898
|
if (res.txs.length === 0) {
|
|
36463
|
-
process.stdout.write(
|
|
36899
|
+
process.stdout.write(import_picocolors11.default.dim(`No activity yet.
|
|
36464
36900
|
`));
|
|
36465
36901
|
return;
|
|
36466
36902
|
}
|
|
@@ -36480,7 +36916,7 @@ async function history(opts) {
|
|
|
36480
36916
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
36481
36917
|
const colTo = Math.max(2, ...rows.map((r) => r.to.length));
|
|
36482
36918
|
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(
|
|
36919
|
+
process.stdout.write(import_picocolors11.default.dim(header) + "\n");
|
|
36484
36920
|
for (const r of rows) {
|
|
36485
36921
|
process.stdout.write(
|
|
36486
36922
|
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 +36924,7 @@ async function history(opts) {
|
|
|
36488
36924
|
}
|
|
36489
36925
|
if (res.fetched_at) {
|
|
36490
36926
|
process.stdout.write(
|
|
36491
|
-
"\n" +
|
|
36927
|
+
"\n" + import_picocolors11.default.dim(
|
|
36492
36928
|
`Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
|
|
36493
36929
|
`
|
|
36494
36930
|
)
|
|
@@ -36575,10 +37011,10 @@ function prettyType(activityType, status2) {
|
|
|
36575
37011
|
}
|
|
36576
37012
|
|
|
36577
37013
|
// src/commands/swap.ts
|
|
36578
|
-
var
|
|
37014
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
36579
37015
|
|
|
36580
37016
|
// src/lib/intent-flow.ts
|
|
36581
|
-
var
|
|
37017
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
36582
37018
|
var STREAM_GIVEUP_MS = 10 * 6e4;
|
|
36583
37019
|
var SOLANA_CHAIN_ID2 = 900;
|
|
36584
37020
|
function isBlocked2(r) {
|
|
@@ -36653,7 +37089,7 @@ async function runIntentFlow(opts) {
|
|
|
36653
37089
|
profile: opts.profileName,
|
|
36654
37090
|
jsonMode: opts.jsonMode,
|
|
36655
37091
|
origin: activeProfile.mcpOrigin,
|
|
36656
|
-
ttyHeader:
|
|
37092
|
+
ttyHeader: import_picocolors12.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
36657
37093
|
});
|
|
36658
37094
|
} catch (reloginErr) {
|
|
36659
37095
|
if (opts.jsonMode) {
|
|
@@ -36665,7 +37101,7 @@ async function runIntentFlow(opts) {
|
|
|
36665
37101
|
process.exit(1);
|
|
36666
37102
|
}
|
|
36667
37103
|
process.stderr.write(
|
|
36668
|
-
|
|
37104
|
+
import_picocolors12.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
36669
37105
|
`)
|
|
36670
37106
|
);
|
|
36671
37107
|
process.exit(1);
|
|
@@ -36689,7 +37125,7 @@ async function runIntentFlow(opts) {
|
|
|
36689
37125
|
process.exit(1);
|
|
36690
37126
|
}
|
|
36691
37127
|
process.stderr.write(
|
|
36692
|
-
|
|
37128
|
+
import_picocolors12.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
36693
37129
|
`)
|
|
36694
37130
|
);
|
|
36695
37131
|
process.exit(1);
|
|
@@ -36706,7 +37142,7 @@ async function runIntentFlow(opts) {
|
|
|
36706
37142
|
});
|
|
36707
37143
|
process.exit(1);
|
|
36708
37144
|
}
|
|
36709
|
-
process.stderr.write(
|
|
37145
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
36710
37146
|
`));
|
|
36711
37147
|
process.exit(1);
|
|
36712
37148
|
} else {
|
|
@@ -36728,18 +37164,18 @@ async function runIntentFlow(opts) {
|
|
|
36728
37164
|
});
|
|
36729
37165
|
process.exit(1);
|
|
36730
37166
|
}
|
|
36731
|
-
process.stderr.write(
|
|
37167
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
|
|
36732
37168
|
`));
|
|
36733
37169
|
if (proposed.upgrade_url) {
|
|
36734
37170
|
process.stderr.write(
|
|
36735
37171
|
` Open this to grant access, then re-run the command:
|
|
36736
|
-
${
|
|
37172
|
+
${import_picocolors12.default.cyan(proposed.upgrade_url)}
|
|
36737
37173
|
`
|
|
36738
37174
|
);
|
|
36739
37175
|
}
|
|
36740
37176
|
if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
|
|
36741
37177
|
process.stderr.write(
|
|
36742
|
-
|
|
37178
|
+
import_picocolors12.default.dim(
|
|
36743
37179
|
` Suggested actions:
|
|
36744
37180
|
` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
|
|
36745
37181
|
)
|
|
@@ -36762,8 +37198,8 @@ async function runIntentFlow(opts) {
|
|
|
36762
37198
|
} else {
|
|
36763
37199
|
process.stdout.write(
|
|
36764
37200
|
`
|
|
36765
|
-
${
|
|
36766
|
-
${
|
|
37201
|
+
${import_picocolors12.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
37202
|
+
${import_picocolors12.default.cyan(proposed.approval_url)}
|
|
36767
37203
|
|
|
36768
37204
|
`
|
|
36769
37205
|
);
|
|
@@ -36785,7 +37221,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36785
37221
|
if (opts.jsonMode) {
|
|
36786
37222
|
emitNdjson2({ status: s.status, intent_id: s.approval_id });
|
|
36787
37223
|
} else {
|
|
36788
|
-
process.stdout.write(` ${describeStatus2(s.status)}${
|
|
37224
|
+
process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors12.default.dim("\u2026")}\r`);
|
|
36789
37225
|
}
|
|
36790
37226
|
}
|
|
36791
37227
|
});
|
|
@@ -36799,7 +37235,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36799
37235
|
profile: opts.profileName,
|
|
36800
37236
|
jsonMode: opts.jsonMode,
|
|
36801
37237
|
origin: activeProfile.mcpOrigin,
|
|
36802
|
-
ttyHeader:
|
|
37238
|
+
ttyHeader: import_picocolors12.default.dim(
|
|
36803
37239
|
"Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
|
|
36804
37240
|
)
|
|
36805
37241
|
});
|
|
@@ -36814,7 +37250,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36814
37250
|
process.exit(1);
|
|
36815
37251
|
}
|
|
36816
37252
|
process.stderr.write(
|
|
36817
|
-
"\n" +
|
|
37253
|
+
"\n" + import_picocolors12.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
36818
37254
|
`)
|
|
36819
37255
|
);
|
|
36820
37256
|
process.exit(1);
|
|
@@ -36832,7 +37268,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36832
37268
|
process.exit(1);
|
|
36833
37269
|
}
|
|
36834
37270
|
process.stderr.write(
|
|
36835
|
-
"\n" +
|
|
37271
|
+
"\n" + import_picocolors12.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
36836
37272
|
`)
|
|
36837
37273
|
);
|
|
36838
37274
|
process.exit(1);
|
|
@@ -36848,7 +37284,7 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36848
37284
|
process.exit(1);
|
|
36849
37285
|
}
|
|
36850
37286
|
process.stderr.write(
|
|
36851
|
-
"\n" +
|
|
37287
|
+
"\n" + import_picocolors12.default.red(`\u2715 Status poll failed: ${err.message}
|
|
36852
37288
|
`)
|
|
36853
37289
|
);
|
|
36854
37290
|
process.exit(1);
|
|
@@ -36889,39 +37325,39 @@ ${import_picocolors9.default.bold("Proposed.")} Open this URL to approve with bi
|
|
|
36889
37325
|
process.stdout.write("\n");
|
|
36890
37326
|
const printLegJournal = () => {
|
|
36891
37327
|
if (legs.length === 0) return;
|
|
36892
|
-
process.stdout.write(
|
|
37328
|
+
process.stdout.write(import_picocolors12.default.bold(" Legs:\n"));
|
|
36893
37329
|
for (const l of legs) {
|
|
36894
|
-
const line = l.status === "mined" ?
|
|
37330
|
+
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
37331
|
process.stdout.write(` ${line}
|
|
36896
37332
|
`);
|
|
36897
37333
|
}
|
|
36898
37334
|
};
|
|
36899
37335
|
if (final.status === "mined") {
|
|
36900
|
-
process.stdout.write(
|
|
37336
|
+
process.stdout.write(import_picocolors12.default.green("\u2713 Mined.") + "\n");
|
|
36901
37337
|
if (final.tx_hash) {
|
|
36902
37338
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
36903
37339
|
`);
|
|
36904
37340
|
}
|
|
36905
37341
|
if (explorer) {
|
|
36906
|
-
process.stdout.write(` Explorer ${
|
|
37342
|
+
process.stdout.write(` Explorer ${import_picocolors12.default.cyan(explorer)}
|
|
36907
37343
|
`);
|
|
36908
37344
|
}
|
|
36909
37345
|
printLegJournal();
|
|
36910
37346
|
process.exit(0);
|
|
36911
37347
|
}
|
|
36912
37348
|
if (final.status === "failed" && failure?.message) {
|
|
36913
|
-
process.stderr.write(
|
|
37349
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${failure.message}
|
|
36914
37350
|
`));
|
|
36915
37351
|
if (retryCommand) {
|
|
36916
37352
|
process.stderr.write(` Retry:
|
|
36917
|
-
${
|
|
37353
|
+
${import_picocolors12.default.cyan(retryCommand)}
|
|
36918
37354
|
`);
|
|
36919
37355
|
}
|
|
36920
37356
|
printLegJournal();
|
|
36921
37357
|
process.exit(1);
|
|
36922
37358
|
}
|
|
36923
37359
|
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(
|
|
37360
|
+
process.stderr.write(import_picocolors12.default.red(`\u2715 ${label}.
|
|
36925
37361
|
`));
|
|
36926
37362
|
printLegJournal();
|
|
36927
37363
|
process.exit(1);
|
|
@@ -36941,7 +37377,7 @@ function isAsset(v) {
|
|
|
36941
37377
|
return ASSET_VALUES.has(v.toLowerCase());
|
|
36942
37378
|
}
|
|
36943
37379
|
function failArg(msg) {
|
|
36944
|
-
process.stderr.write(
|
|
37380
|
+
process.stderr.write(import_picocolors13.default.red(`\u2715 ${msg}
|
|
36945
37381
|
`));
|
|
36946
37382
|
process.exit(2);
|
|
36947
37383
|
}
|
|
@@ -36949,11 +37385,11 @@ async function swap(amount, fromAsset, opts) {
|
|
|
36949
37385
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
36950
37386
|
const resolved = await resolveProfile(requested);
|
|
36951
37387
|
if (!resolved) {
|
|
36952
|
-
process.stderr.write(
|
|
37388
|
+
process.stderr.write(import_picocolors13.default.red("Not logged in. Run agentgates login first.\n"));
|
|
36953
37389
|
process.exit(2);
|
|
36954
37390
|
}
|
|
36955
37391
|
if (resolved.autoSelected) {
|
|
36956
|
-
process.stderr.write(
|
|
37392
|
+
process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
36957
37393
|
`));
|
|
36958
37394
|
}
|
|
36959
37395
|
const { profile, name: profileName } = resolved;
|
|
@@ -36961,12 +37397,12 @@ async function swap(amount, fromAsset, opts) {
|
|
|
36961
37397
|
const jsonMode = opts.json === true || !stdoutIsTty;
|
|
36962
37398
|
const amountNumber = Number(amount);
|
|
36963
37399
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
36964
|
-
failArg(`amount must be a positive number (got ${
|
|
37400
|
+
failArg(`amount must be a positive number (got ${import_picocolors13.default.bold(amount)}).`);
|
|
36965
37401
|
}
|
|
36966
37402
|
const fromAssetNorm = fromAsset.toLowerCase();
|
|
36967
37403
|
if (!isAsset(fromAssetNorm)) {
|
|
36968
37404
|
failArg(
|
|
36969
|
-
`from-asset must be ${
|
|
37405
|
+
`from-asset must be ${import_picocolors13.default.bold("native")} or ${import_picocolors13.default.bold("usdc")} (got ${import_picocolors13.default.bold(fromAsset)}).`
|
|
36970
37406
|
);
|
|
36971
37407
|
}
|
|
36972
37408
|
if (!opts.toAsset) {
|
|
@@ -36975,7 +37411,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
36975
37411
|
const toAssetNorm = opts.toAsset.toLowerCase();
|
|
36976
37412
|
if (!isAsset(toAssetNorm)) {
|
|
36977
37413
|
failArg(
|
|
36978
|
-
`--to-asset must be ${
|
|
37414
|
+
`--to-asset must be ${import_picocolors13.default.bold("native")} or ${import_picocolors13.default.bold("usdc")} (got ${import_picocolors13.default.bold(opts.toAsset)}).`
|
|
36979
37415
|
);
|
|
36980
37416
|
}
|
|
36981
37417
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -37104,9 +37540,9 @@ async function swap(amount, fromAsset, opts) {
|
|
|
37104
37540
|
}
|
|
37105
37541
|
|
|
37106
37542
|
// src/commands/batch.ts
|
|
37107
|
-
var
|
|
37543
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
37108
37544
|
function failArg2(msg) {
|
|
37109
|
-
process.stderr.write(
|
|
37545
|
+
process.stderr.write(import_picocolors14.default.red(`\u2715 ${msg}
|
|
37110
37546
|
`));
|
|
37111
37547
|
process.exit(2);
|
|
37112
37548
|
}
|
|
@@ -37114,7 +37550,7 @@ async function batch(opts) {
|
|
|
37114
37550
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37115
37551
|
const resolved = await resolveProfile(requested);
|
|
37116
37552
|
if (!resolved) {
|
|
37117
|
-
process.stderr.write(
|
|
37553
|
+
process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37118
37554
|
process.exit(2);
|
|
37119
37555
|
}
|
|
37120
37556
|
const { name: profileName, profile } = resolved;
|
|
@@ -37168,14 +37604,14 @@ async function batch(opts) {
|
|
|
37168
37604
|
}
|
|
37169
37605
|
|
|
37170
37606
|
// src/commands/fund-wallet.ts
|
|
37171
|
-
var
|
|
37607
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
37172
37608
|
var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
|
|
37173
37609
|
var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
37174
37610
|
function isAddressTarget(target) {
|
|
37175
37611
|
return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
|
|
37176
37612
|
}
|
|
37177
37613
|
function failArg3(msg) {
|
|
37178
|
-
process.stderr.write(
|
|
37614
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${msg}
|
|
37179
37615
|
`));
|
|
37180
37616
|
process.exit(2);
|
|
37181
37617
|
}
|
|
@@ -37183,7 +37619,7 @@ async function fundWallet(address, opts) {
|
|
|
37183
37619
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37184
37620
|
const resolved = await resolveProfile(requested);
|
|
37185
37621
|
if (!resolved) {
|
|
37186
|
-
process.stderr.write(
|
|
37622
|
+
process.stderr.write(import_picocolors15.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37187
37623
|
process.exit(2);
|
|
37188
37624
|
}
|
|
37189
37625
|
const { name: profileName, profile } = resolved;
|
|
@@ -37260,11 +37696,11 @@ async function fundWallet(address, opts) {
|
|
|
37260
37696
|
}
|
|
37261
37697
|
|
|
37262
37698
|
// src/commands/earn-supply.ts
|
|
37263
|
-
var
|
|
37699
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
37264
37700
|
var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
37265
37701
|
var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
37266
37702
|
function failArg4(msg) {
|
|
37267
|
-
process.stderr.write(
|
|
37703
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${msg}
|
|
37268
37704
|
`));
|
|
37269
37705
|
process.exit(2);
|
|
37270
37706
|
}
|
|
@@ -37272,11 +37708,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
37272
37708
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37273
37709
|
const resolved = await resolveProfile(requested);
|
|
37274
37710
|
if (!resolved) {
|
|
37275
|
-
process.stderr.write(
|
|
37711
|
+
process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37276
37712
|
process.exit(2);
|
|
37277
37713
|
}
|
|
37278
37714
|
if (resolved.autoSelected) {
|
|
37279
|
-
process.stderr.write(
|
|
37715
|
+
process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
37280
37716
|
`));
|
|
37281
37717
|
}
|
|
37282
37718
|
const { profile, name: profileName } = resolved;
|
|
@@ -37284,12 +37720,12 @@ async function earnSupply(amount, asset, opts) {
|
|
|
37284
37720
|
const jsonMode = opts.json === true || !stdoutIsTty;
|
|
37285
37721
|
const amountNumber = Number(amount);
|
|
37286
37722
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
37287
|
-
failArg4(`amount must be a positive number (got ${
|
|
37723
|
+
failArg4(`amount must be a positive number (got ${import_picocolors16.default.bold(amount)}).`);
|
|
37288
37724
|
}
|
|
37289
37725
|
const assetNorm = asset.toLowerCase();
|
|
37290
37726
|
if (!ASSET_VALUES2.has(assetNorm)) {
|
|
37291
37727
|
failArg4(
|
|
37292
|
-
`asset must be ${
|
|
37728
|
+
`asset must be ${import_picocolors16.default.bold("native")} or ${import_picocolors16.default.bold("usdc")} (got ${import_picocolors16.default.bold(asset)}).`
|
|
37293
37729
|
);
|
|
37294
37730
|
}
|
|
37295
37731
|
if (!opts.chain) {
|
|
@@ -37301,7 +37737,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
37301
37737
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
37302
37738
|
if (!PROTOCOLS.has(protocolNorm)) {
|
|
37303
37739
|
failArg4(
|
|
37304
|
-
`--protocol must be ${
|
|
37740
|
+
`--protocol must be ${import_picocolors16.default.bold("aave_v3")} or ${import_picocolors16.default.bold("kamino_lend")} (got ${import_picocolors16.default.bold(opts.protocol)}).`
|
|
37305
37741
|
);
|
|
37306
37742
|
}
|
|
37307
37743
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -37353,11 +37789,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
37353
37789
|
}
|
|
37354
37790
|
|
|
37355
37791
|
// src/commands/earn-withdraw.ts
|
|
37356
|
-
var
|
|
37792
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
37357
37793
|
var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
37358
37794
|
var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
37359
37795
|
function failArg5(msg) {
|
|
37360
|
-
process.stderr.write(
|
|
37796
|
+
process.stderr.write(import_picocolors17.default.red(`\u2715 ${msg}
|
|
37361
37797
|
`));
|
|
37362
37798
|
process.exit(2);
|
|
37363
37799
|
}
|
|
@@ -37365,11 +37801,11 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
37365
37801
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37366
37802
|
const resolved = await resolveProfile(requested);
|
|
37367
37803
|
if (!resolved) {
|
|
37368
|
-
process.stderr.write(
|
|
37804
|
+
process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37369
37805
|
process.exit(2);
|
|
37370
37806
|
}
|
|
37371
37807
|
if (resolved.autoSelected) {
|
|
37372
|
-
process.stderr.write(
|
|
37808
|
+
process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
37373
37809
|
`));
|
|
37374
37810
|
}
|
|
37375
37811
|
const { profile, name: profileName } = resolved;
|
|
@@ -37380,14 +37816,14 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
37380
37816
|
const amountNumber = Number(amountOrMax);
|
|
37381
37817
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
37382
37818
|
failArg5(
|
|
37383
|
-
`<amount-or-max> must be a positive number or the literal string "max" (got ${
|
|
37819
|
+
`<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors17.default.bold(amountOrMax)}).`
|
|
37384
37820
|
);
|
|
37385
37821
|
}
|
|
37386
37822
|
}
|
|
37387
37823
|
const assetNorm = asset.toLowerCase();
|
|
37388
37824
|
if (!ASSET_VALUES3.has(assetNorm)) {
|
|
37389
37825
|
failArg5(
|
|
37390
|
-
`asset must be ${
|
|
37826
|
+
`asset must be ${import_picocolors17.default.bold("native")} or ${import_picocolors17.default.bold("usdc")} (got ${import_picocolors17.default.bold(asset)}).`
|
|
37391
37827
|
);
|
|
37392
37828
|
}
|
|
37393
37829
|
if (!opts.chain) {
|
|
@@ -37399,7 +37835,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
37399
37835
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
37400
37836
|
if (!PROTOCOLS2.has(protocolNorm)) {
|
|
37401
37837
|
failArg5(
|
|
37402
|
-
`--protocol must be ${
|
|
37838
|
+
`--protocol must be ${import_picocolors17.default.bold("aave_v3")} or ${import_picocolors17.default.bold("kamino_lend")} (got ${import_picocolors17.default.bold(opts.protocol)}).`
|
|
37403
37839
|
);
|
|
37404
37840
|
}
|
|
37405
37841
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -37451,7 +37887,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
37451
37887
|
}
|
|
37452
37888
|
|
|
37453
37889
|
// src/commands/eat.ts
|
|
37454
|
-
var
|
|
37890
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
37455
37891
|
function parseLineJson(values) {
|
|
37456
37892
|
const lines = [];
|
|
37457
37893
|
for (const value of values) {
|
|
@@ -37478,11 +37914,11 @@ function parseLineJson(values) {
|
|
|
37478
37914
|
async function loadResolvedProfile(requested) {
|
|
37479
37915
|
const resolved = await resolveProfile(requested);
|
|
37480
37916
|
if (!resolved) {
|
|
37481
|
-
process.stderr.write(
|
|
37917
|
+
process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37482
37918
|
process.exit(2);
|
|
37483
37919
|
}
|
|
37484
37920
|
if (resolved.autoSelected) {
|
|
37485
|
-
process.stderr.write(
|
|
37921
|
+
process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
37486
37922
|
`));
|
|
37487
37923
|
}
|
|
37488
37924
|
return resolved;
|
|
@@ -37493,12 +37929,12 @@ function printResult(res, jsonMode) {
|
|
|
37493
37929
|
return;
|
|
37494
37930
|
}
|
|
37495
37931
|
if (res.blocked) {
|
|
37496
|
-
process.stderr.write(
|
|
37932
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
|
|
37497
37933
|
`));
|
|
37498
37934
|
if (res.upgrade_url) {
|
|
37499
37935
|
process.stderr.write(
|
|
37500
37936
|
` Open this to grant access, then re-run the command:
|
|
37501
|
-
${
|
|
37937
|
+
${import_picocolors18.default.cyan(res.upgrade_url)}
|
|
37502
37938
|
`
|
|
37503
37939
|
);
|
|
37504
37940
|
}
|
|
@@ -37529,7 +37965,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
|
|
|
37529
37965
|
profile: resolved.profile,
|
|
37530
37966
|
profileName: resolved.name,
|
|
37531
37967
|
jsonMode,
|
|
37532
|
-
ttyHeader:
|
|
37968
|
+
ttyHeader: import_picocolors18.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
37533
37969
|
fn: (bearer, origin) => apiFetch(path5, { method: "POST", bearer, origin, body })
|
|
37534
37970
|
});
|
|
37535
37971
|
if (outcome.kind === "auth_failed") {
|
|
@@ -37539,7 +37975,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
|
|
|
37539
37975
|
);
|
|
37540
37976
|
process.exit(1);
|
|
37541
37977
|
}
|
|
37542
|
-
process.stderr.write(
|
|
37978
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${outcome.reason}.
|
|
37543
37979
|
`));
|
|
37544
37980
|
process.exit(1);
|
|
37545
37981
|
}
|
|
@@ -37552,7 +37988,7 @@ async function postRestaurant(path5, body, resolved, jsonMode) {
|
|
|
37552
37988
|
);
|
|
37553
37989
|
process.exit(1);
|
|
37554
37990
|
}
|
|
37555
|
-
process.stderr.write(
|
|
37991
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
37556
37992
|
`));
|
|
37557
37993
|
process.exit(1);
|
|
37558
37994
|
}
|
|
@@ -37565,7 +38001,7 @@ async function searchFood(opts) {
|
|
|
37565
38001
|
const jsonMode = opts.json === true || process.stdout.isTTY !== true;
|
|
37566
38002
|
if (!opts.location && !opts.name) {
|
|
37567
38003
|
process.stderr.write(
|
|
37568
|
-
|
|
38004
|
+
import_picocolors18.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
|
|
37569
38005
|
);
|
|
37570
38006
|
process.exit(2);
|
|
37571
38007
|
}
|
|
@@ -37586,7 +38022,7 @@ async function menuFood(items, opts) {
|
|
|
37586
38022
|
const jsonMode = opts.json === true || process.stdout.isTTY !== true;
|
|
37587
38023
|
if (!opts.brand || !opts.address) {
|
|
37588
38024
|
process.stderr.write(
|
|
37589
|
-
|
|
38025
|
+
import_picocolors18.default.red(
|
|
37590
38026
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
37591
38027
|
)
|
|
37592
38028
|
);
|
|
@@ -37606,7 +38042,7 @@ async function orderFood(items, opts) {
|
|
|
37606
38042
|
const jsonMode = opts.json === true || process.stdout.isTTY !== true;
|
|
37607
38043
|
if (!opts.brand || !opts.address) {
|
|
37608
38044
|
process.stderr.write(
|
|
37609
|
-
|
|
38045
|
+
import_picocolors18.default.red(
|
|
37610
38046
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
37611
38047
|
)
|
|
37612
38048
|
);
|
|
@@ -37616,14 +38052,14 @@ async function orderFood(items, opts) {
|
|
|
37616
38052
|
try {
|
|
37617
38053
|
structuredLines = parseLineJson(opts.lineJson ?? []);
|
|
37618
38054
|
} catch (e) {
|
|
37619
|
-
process.stderr.write(
|
|
38055
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
|
|
37620
38056
|
`));
|
|
37621
38057
|
process.exit(2);
|
|
37622
38058
|
}
|
|
37623
38059
|
const lines = [...items ?? [], ...structuredLines];
|
|
37624
38060
|
if (lines.length === 0) {
|
|
37625
38061
|
process.stderr.write(
|
|
37626
|
-
|
|
38062
|
+
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
38063
|
);
|
|
37628
38064
|
process.exit(2);
|
|
37629
38065
|
}
|
|
@@ -37657,7 +38093,7 @@ async function orderFood(items, opts) {
|
|
|
37657
38093
|
if (!agentCard.will_attempt) {
|
|
37658
38094
|
if (!jsonMode) {
|
|
37659
38095
|
process.stderr.write(
|
|
37660
|
-
|
|
38096
|
+
import_picocolors18.default.yellow(
|
|
37661
38097
|
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
37662
38098
|
`
|
|
37663
38099
|
)
|
|
@@ -37674,7 +38110,7 @@ async function orderFood(items, opts) {
|
|
|
37674
38110
|
}
|
|
37675
38111
|
if (verdict.status === "paid") {
|
|
37676
38112
|
process.stdout.write(
|
|
37677
|
-
|
|
38113
|
+
import_picocolors18.default.green(
|
|
37678
38114
|
`Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
|
|
37679
38115
|
)
|
|
37680
38116
|
);
|
|
@@ -37682,7 +38118,7 @@ async function orderFood(items, opts) {
|
|
|
37682
38118
|
}
|
|
37683
38119
|
if (verdict.status === "failed") {
|
|
37684
38120
|
process.stderr.write(
|
|
37685
|
-
|
|
38121
|
+
import_picocolors18.default.yellow(
|
|
37686
38122
|
`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
38123
|
`
|
|
37688
38124
|
)
|
|
@@ -37692,7 +38128,7 @@ async function orderFood(items, opts) {
|
|
|
37692
38128
|
}
|
|
37693
38129
|
if (verdict.status === "unconfirmed") {
|
|
37694
38130
|
process.stderr.write(
|
|
37695
|
-
|
|
38131
|
+
import_picocolors18.default.red(
|
|
37696
38132
|
"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
38133
|
` : "")
|
|
37698
38134
|
)
|
|
@@ -37701,7 +38137,7 @@ async function orderFood(items, opts) {
|
|
|
37701
38137
|
return;
|
|
37702
38138
|
}
|
|
37703
38139
|
process.stderr.write(
|
|
37704
|
-
|
|
38140
|
+
import_picocolors18.default.dim(
|
|
37705
38141
|
`Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
|
|
37706
38142
|
)
|
|
37707
38143
|
);
|
|
@@ -37726,7 +38162,7 @@ var POLL_BUDGET_MS = 1e5;
|
|
|
37726
38162
|
var POLL_INTERVAL_MS2 = 3500;
|
|
37727
38163
|
async function pollOrderVerdict(orderId, resolved, jsonMode) {
|
|
37728
38164
|
if (!jsonMode) {
|
|
37729
|
-
process.stderr.write(
|
|
38165
|
+
process.stderr.write(import_picocolors18.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
|
|
37730
38166
|
}
|
|
37731
38167
|
const deadline = Date.now() + POLL_BUDGET_MS;
|
|
37732
38168
|
let last = {
|
|
@@ -37796,16 +38232,16 @@ async function statusFood(orderId, opts) {
|
|
|
37796
38232
|
}
|
|
37797
38233
|
|
|
37798
38234
|
// src/commands/bounties.ts
|
|
37799
|
-
var
|
|
38235
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
37800
38236
|
async function withProfile(opts, path5, init) {
|
|
37801
38237
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
37802
38238
|
const resolved = await resolveProfile(requested);
|
|
37803
38239
|
if (!resolved) {
|
|
37804
|
-
process.stderr.write(
|
|
38240
|
+
process.stderr.write(import_picocolors19.default.red("Not logged in. Run agentgates login first.\n"));
|
|
37805
38241
|
process.exit(2);
|
|
37806
38242
|
}
|
|
37807
38243
|
if (resolved.autoSelected) {
|
|
37808
|
-
process.stderr.write(
|
|
38244
|
+
process.stderr.write(import_picocolors19.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
37809
38245
|
`));
|
|
37810
38246
|
}
|
|
37811
38247
|
const { profile, name: profileName } = resolved;
|
|
@@ -37814,7 +38250,7 @@ async function withProfile(opts, path5, init) {
|
|
|
37814
38250
|
profile,
|
|
37815
38251
|
profileName,
|
|
37816
38252
|
jsonMode,
|
|
37817
|
-
ttyHeader:
|
|
38253
|
+
ttyHeader: import_picocolors19.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
37818
38254
|
fn: (bearer, origin) => apiFetch(path5, init ? { bearer, origin, method: init.method, body: init.body } : { bearer, origin })
|
|
37819
38255
|
});
|
|
37820
38256
|
if (outcome.kind === "auth_failed") {
|
|
@@ -37822,14 +38258,14 @@ async function withProfile(opts, path5, init) {
|
|
|
37822
38258
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
37823
38259
|
process.exit(1);
|
|
37824
38260
|
}
|
|
37825
|
-
process.stderr.write(
|
|
38261
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${outcome.reason}.
|
|
37826
38262
|
`));
|
|
37827
38263
|
process.exit(1);
|
|
37828
38264
|
}
|
|
37829
38265
|
if (outcome.kind === "error") {
|
|
37830
38266
|
const err = outcome.error;
|
|
37831
38267
|
if (err instanceof ApiError) {
|
|
37832
|
-
process.stderr.write(
|
|
38268
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
37833
38269
|
`));
|
|
37834
38270
|
process.exit(1);
|
|
37835
38271
|
}
|
|
@@ -37843,12 +38279,12 @@ function handleBlocked(res, jsonMode) {
|
|
|
37843
38279
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
37844
38280
|
process.exit(1);
|
|
37845
38281
|
}
|
|
37846
|
-
process.stderr.write(
|
|
38282
|
+
process.stderr.write(import_picocolors19.default.yellow(`
|
|
37847
38283
|
${res.reason ?? "Blocked."}
|
|
37848
38284
|
`));
|
|
37849
38285
|
if (res.upgrade_url) {
|
|
37850
38286
|
process.stderr.write(`
|
|
37851
|
-
${
|
|
38287
|
+
${import_picocolors19.default.bold(res.upgrade_url)}
|
|
37852
38288
|
|
|
37853
38289
|
`);
|
|
37854
38290
|
}
|
|
@@ -37891,14 +38327,14 @@ function printTable(rows) {
|
|
|
37891
38327
|
const cLeft = w("left", 4);
|
|
37892
38328
|
const cSubs = w("subs", 4);
|
|
37893
38329
|
process.stdout.write(
|
|
37894
|
-
|
|
38330
|
+
import_picocolors19.default.dim(
|
|
37895
38331
|
"Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
|
|
37896
38332
|
) + "\n"
|
|
37897
38333
|
);
|
|
37898
38334
|
for (const c of cells) {
|
|
37899
|
-
const title = c.live ?
|
|
38335
|
+
const title = c.live ? import_picocolors19.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
|
|
37900
38336
|
process.stdout.write(
|
|
37901
|
-
|
|
38337
|
+
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
38338
|
);
|
|
37903
38339
|
}
|
|
37904
38340
|
}
|
|
@@ -37910,11 +38346,11 @@ async function listBounties(opts) {
|
|
|
37910
38346
|
const min = opts.min !== void 0 ? Number(opts.min) : void 0;
|
|
37911
38347
|
const max = opts.max !== void 0 ? Number(opts.max) : void 0;
|
|
37912
38348
|
if (min !== void 0 && !Number.isFinite(min)) {
|
|
37913
|
-
process.stderr.write(
|
|
38349
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 --min must be a number.\n"));
|
|
37914
38350
|
process.exit(2);
|
|
37915
38351
|
}
|
|
37916
38352
|
if (max !== void 0 && !Number.isFinite(max)) {
|
|
37917
|
-
process.stderr.write(
|
|
38353
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 --max must be a number.\n"));
|
|
37918
38354
|
process.exit(2);
|
|
37919
38355
|
}
|
|
37920
38356
|
rows = rows.filter((r) => {
|
|
@@ -37939,7 +38375,7 @@ async function listBounties(opts) {
|
|
|
37939
38375
|
});
|
|
37940
38376
|
const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
|
|
37941
38377
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
37942
|
-
process.stderr.write(
|
|
38378
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 --limit must be a positive number.\n"));
|
|
37943
38379
|
process.exit(2);
|
|
37944
38380
|
}
|
|
37945
38381
|
const shown = rows.slice(0, limit);
|
|
@@ -37948,13 +38384,13 @@ async function listBounties(opts) {
|
|
|
37948
38384
|
return;
|
|
37949
38385
|
}
|
|
37950
38386
|
if (shown.length === 0) {
|
|
37951
|
-
process.stdout.write(
|
|
38387
|
+
process.stdout.write(import_picocolors19.default.dim("No active bounties match.\n"));
|
|
37952
38388
|
return;
|
|
37953
38389
|
}
|
|
37954
38390
|
printTable(shown);
|
|
37955
38391
|
const clipped = rows.length - shown.length;
|
|
37956
38392
|
process.stdout.write(
|
|
37957
|
-
"\n" +
|
|
38393
|
+
"\n" + import_picocolors19.default.dim(
|
|
37958
38394
|
`${shown.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
|
|
37959
38395
|
`
|
|
37960
38396
|
)
|
|
@@ -37965,7 +38401,7 @@ async function showBounty(id, opts) {
|
|
|
37965
38401
|
const jsonMode = opts.json === true;
|
|
37966
38402
|
const clean = id.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
|
|
37967
38403
|
if (!clean) {
|
|
37968
|
-
process.stderr.write(
|
|
38404
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
|
|
37969
38405
|
process.exit(2);
|
|
37970
38406
|
}
|
|
37971
38407
|
const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean)}`);
|
|
@@ -37976,26 +38412,26 @@ async function showBounty(id, opts) {
|
|
|
37976
38412
|
}
|
|
37977
38413
|
const b = res.bounty;
|
|
37978
38414
|
if (!b) {
|
|
37979
|
-
process.stdout.write(
|
|
38415
|
+
process.stdout.write(import_picocolors19.default.dim("Not found.\n"));
|
|
37980
38416
|
return;
|
|
37981
38417
|
}
|
|
37982
|
-
process.stdout.write("\n" +
|
|
38418
|
+
process.stdout.write("\n" + import_picocolors19.default.bold(b.title) + "\n\n");
|
|
37983
38419
|
process.stdout.write(b.description + "\n\n");
|
|
37984
38420
|
process.stdout.write(
|
|
37985
|
-
|
|
38421
|
+
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
38422
|
);
|
|
37987
38423
|
if (b.claimsAllowed && b.claimsAllowed > 1) {
|
|
37988
38424
|
const left = Math.max(0, b.claimsAllowed - (b.claimsPaid ?? 0));
|
|
37989
38425
|
process.stdout.write(
|
|
37990
|
-
|
|
38426
|
+
import_picocolors19.default.dim(
|
|
37991
38427
|
`${left} of ${b.claimsAllowed} claims left` + (b.perClaimAmount != null ? `, ${fmtAmount(b.perClaimAmount)} each` : "")
|
|
37992
38428
|
) + "\n"
|
|
37993
38429
|
);
|
|
37994
38430
|
}
|
|
37995
|
-
if (b.evidenceType) process.stdout.write(
|
|
37996
|
-
if (b.expiresAt) process.stdout.write(
|
|
38431
|
+
if (b.evidenceType) process.stdout.write(import_picocolors19.default.dim(`Evidence required: ${b.evidenceType}`) + "\n");
|
|
38432
|
+
if (b.expiresAt) process.stdout.write(import_picocolors19.default.dim(`Expires in ${fmtExpiry(b.expiresAt)}`) + "\n");
|
|
37997
38433
|
if (b.geoLabel && b.geoScope !== "global") {
|
|
37998
|
-
process.stdout.write(
|
|
38434
|
+
process.stdout.write(import_picocolors19.default.dim(`Creator says: ${b.geoLabel}`) + "\n");
|
|
37999
38435
|
}
|
|
38000
38436
|
if (res.url) process.stdout.write("\n" + res.url + "\n");
|
|
38001
38437
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -38013,7 +38449,7 @@ async function myBounties(opts) {
|
|
|
38013
38449
|
}
|
|
38014
38450
|
if (rows.length === 0) {
|
|
38015
38451
|
process.stdout.write(
|
|
38016
|
-
|
|
38452
|
+
import_picocolors19.default.dim(
|
|
38017
38453
|
status2 ? `No bounties of yours are ${status2}.
|
|
38018
38454
|
` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
|
|
38019
38455
|
)
|
|
@@ -38023,7 +38459,7 @@ async function myBounties(opts) {
|
|
|
38023
38459
|
printTable(rows);
|
|
38024
38460
|
const subs = res.submissions ?? [];
|
|
38025
38461
|
if (subs.length > 0) {
|
|
38026
|
-
process.stdout.write("\n" +
|
|
38462
|
+
process.stdout.write("\n" + import_picocolors19.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
|
|
38027
38463
|
`));
|
|
38028
38464
|
}
|
|
38029
38465
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -38042,19 +38478,19 @@ async function bountyFeed(opts) {
|
|
|
38042
38478
|
}
|
|
38043
38479
|
const subs = res.submissions ?? [];
|
|
38044
38480
|
if (subs.length === 0) {
|
|
38045
|
-
process.stdout.write(
|
|
38481
|
+
process.stdout.write(import_picocolors19.default.dim("Nothing in the feed for that filter.\n"));
|
|
38046
38482
|
return;
|
|
38047
38483
|
}
|
|
38048
38484
|
process.stdout.write(
|
|
38049
|
-
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ?
|
|
38485
|
+
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors19.default.dim(" More available.") : "") + "\n"
|
|
38050
38486
|
);
|
|
38051
|
-
process.stdout.write(
|
|
38487
|
+
process.stdout.write(import_picocolors19.default.dim("Use --json for the full rows.\n"));
|
|
38052
38488
|
}
|
|
38053
38489
|
async function draftBounty(opts) {
|
|
38054
38490
|
const jsonMode = opts.json === true;
|
|
38055
38491
|
const amountNum = Number(opts.amount);
|
|
38056
38492
|
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
38057
|
-
process.stderr.write(
|
|
38493
|
+
process.stderr.write(import_picocolors19.default.red("\u2715 --amount must be a positive number of USDC.\n"));
|
|
38058
38494
|
process.exit(2);
|
|
38059
38495
|
}
|
|
38060
38496
|
const res = await withProfile(opts, "/api/bounties", {
|
|
@@ -38072,20 +38508,20 @@ async function draftBounty(opts) {
|
|
|
38072
38508
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
38073
38509
|
return;
|
|
38074
38510
|
}
|
|
38075
|
-
process.stdout.write("\n" +
|
|
38511
|
+
process.stdout.write("\n" + import_picocolors19.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
|
|
38076
38512
|
|
|
38077
38513
|
`);
|
|
38078
|
-
process.stdout.write(
|
|
38514
|
+
process.stdout.write(import_picocolors19.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
|
|
38079
38515
|
if (res.fund_url) {
|
|
38080
|
-
process.stdout.write("\nFund it here:\n" +
|
|
38081
|
-
process.stdout.write(
|
|
38516
|
+
process.stdout.write("\nFund it here:\n" + import_picocolors19.default.bold(res.fund_url) + "\n\n");
|
|
38517
|
+
process.stdout.write(import_picocolors19.default.dim("Funding happens in your browser with your own wallet.\n"));
|
|
38082
38518
|
}
|
|
38083
38519
|
}
|
|
38084
38520
|
|
|
38085
38521
|
// src/commands/bounty-money.ts
|
|
38086
|
-
var
|
|
38522
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
38087
38523
|
function failArg6(message) {
|
|
38088
|
-
process.stderr.write(
|
|
38524
|
+
process.stderr.write(import_picocolors20.default.red(`${message}
|
|
38089
38525
|
`));
|
|
38090
38526
|
process.exit(2);
|
|
38091
38527
|
}
|
|
@@ -38097,12 +38533,12 @@ async function loadProfileOrExit(requested, jsonMode) {
|
|
|
38097
38533
|
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
|
|
38098
38534
|
);
|
|
38099
38535
|
} else {
|
|
38100
|
-
process.stderr.write(
|
|
38536
|
+
process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
|
|
38101
38537
|
}
|
|
38102
38538
|
process.exit(2);
|
|
38103
38539
|
}
|
|
38104
38540
|
if (resolved.autoSelected && !jsonMode) {
|
|
38105
|
-
process.stderr.write(
|
|
38541
|
+
process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
38106
38542
|
`));
|
|
38107
38543
|
}
|
|
38108
38544
|
return { profile: resolved.profile, profileName: resolved.name };
|
|
@@ -38207,16 +38643,16 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
38207
38643
|
}
|
|
38208
38644
|
|
|
38209
38645
|
// src/commands/bounty-work.ts
|
|
38210
|
-
var
|
|
38646
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
38211
38647
|
async function runWork(path5, body, opts) {
|
|
38212
38648
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
38213
38649
|
const resolved = await resolveProfile(requested);
|
|
38214
38650
|
if (!resolved) {
|
|
38215
|
-
process.stderr.write(
|
|
38651
|
+
process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
|
|
38216
38652
|
process.exit(2);
|
|
38217
38653
|
}
|
|
38218
38654
|
if (resolved.autoSelected) {
|
|
38219
|
-
process.stderr.write(
|
|
38655
|
+
process.stderr.write(import_picocolors21.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
38220
38656
|
`));
|
|
38221
38657
|
}
|
|
38222
38658
|
const jsonMode = opts.json === true;
|
|
@@ -38224,7 +38660,7 @@ async function runWork(path5, body, opts) {
|
|
|
38224
38660
|
profile: resolved.profile,
|
|
38225
38661
|
profileName: resolved.name,
|
|
38226
38662
|
jsonMode,
|
|
38227
|
-
ttyHeader:
|
|
38663
|
+
ttyHeader: import_picocolors21.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
38228
38664
|
fn: (bearer, origin) => apiFetch(path5, { bearer, origin, method: "POST", body })
|
|
38229
38665
|
});
|
|
38230
38666
|
if (outcome.kind === "auth_failed") {
|
|
@@ -38232,7 +38668,7 @@ async function runWork(path5, body, opts) {
|
|
|
38232
38668
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
38233
38669
|
process.exit(1);
|
|
38234
38670
|
}
|
|
38235
|
-
process.stderr.write(
|
|
38671
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${outcome.reason}.
|
|
38236
38672
|
`));
|
|
38237
38673
|
process.exit(1);
|
|
38238
38674
|
}
|
|
@@ -38242,7 +38678,7 @@ async function runWork(path5, body, opts) {
|
|
|
38242
38678
|
if (jsonMode) {
|
|
38243
38679
|
process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
|
|
38244
38680
|
} else {
|
|
38245
|
-
process.stderr.write(
|
|
38681
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
38246
38682
|
`));
|
|
38247
38683
|
}
|
|
38248
38684
|
process.exit(1);
|
|
@@ -38255,11 +38691,11 @@ async function runWork(path5, body, opts) {
|
|
|
38255
38691
|
process.stdout.write(JSON.stringify({ ok: false, ...data }) + "\n");
|
|
38256
38692
|
process.exit(1);
|
|
38257
38693
|
}
|
|
38258
|
-
process.stderr.write(
|
|
38694
|
+
process.stderr.write(import_picocolors21.default.yellow(`
|
|
38259
38695
|
${data.reason ?? "Blocked."}
|
|
38260
38696
|
`));
|
|
38261
38697
|
if (data.upgrade_url) process.stderr.write(`
|
|
38262
|
-
${
|
|
38698
|
+
${import_picocolors21.default.bold(data.upgrade_url)}
|
|
38263
38699
|
|
|
38264
38700
|
`);
|
|
38265
38701
|
process.exit(1);
|
|
@@ -38268,7 +38704,7 @@ ${import_picocolors18.default.bold(data.upgrade_url)}
|
|
|
38268
38704
|
if (jsonMode) {
|
|
38269
38705
|
process.stdout.write(JSON.stringify({ ok: false, error: data.error }) + "\n");
|
|
38270
38706
|
} else {
|
|
38271
|
-
process.stderr.write(
|
|
38707
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${data.error}
|
|
38272
38708
|
`));
|
|
38273
38709
|
}
|
|
38274
38710
|
process.exit(1);
|
|
@@ -38311,7 +38747,7 @@ async function bountyRetention(bountyId, opts) {
|
|
|
38311
38747
|
}
|
|
38312
38748
|
|
|
38313
38749
|
// src/commands/bounty-deliver.ts
|
|
38314
|
-
var
|
|
38750
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
38315
38751
|
import { spawn } from "node:child_process";
|
|
38316
38752
|
var FLUSH_MS = 400;
|
|
38317
38753
|
var FLUSH_BYTES = 2048;
|
|
@@ -38320,11 +38756,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
38320
38756
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
38321
38757
|
const resolved = await resolveProfile(requested);
|
|
38322
38758
|
if (!resolved) {
|
|
38323
|
-
process.stderr.write(
|
|
38759
|
+
process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
|
|
38324
38760
|
process.exit(2);
|
|
38325
38761
|
}
|
|
38326
38762
|
if (resolved.autoSelected && !jsonMode) {
|
|
38327
|
-
process.stderr.write(
|
|
38763
|
+
process.stderr.write(import_picocolors22.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
38328
38764
|
`));
|
|
38329
38765
|
}
|
|
38330
38766
|
const post = async (path5, body) => {
|
|
@@ -38332,7 +38768,7 @@ async function deliver(bountyId, command, opts) {
|
|
|
38332
38768
|
profile: resolved.profile,
|
|
38333
38769
|
profileName: resolved.name,
|
|
38334
38770
|
jsonMode,
|
|
38335
|
-
ttyHeader:
|
|
38771
|
+
ttyHeader: import_picocolors22.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
38336
38772
|
fn: (bearer, origin) => apiFetch(path5, { bearer, origin, method: "POST", body })
|
|
38337
38773
|
});
|
|
38338
38774
|
if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
|
|
@@ -38343,11 +38779,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
38343
38779
|
if (jsonMode) {
|
|
38344
38780
|
process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data ?? {} }) + "\n");
|
|
38345
38781
|
} else {
|
|
38346
|
-
process.stderr.write(
|
|
38782
|
+
process.stderr.write(import_picocolors22.default.red(`
|
|
38347
38783
|
\u2715 ${msg}
|
|
38348
38784
|
`));
|
|
38349
38785
|
if (data?.upgrade_url) process.stderr.write(`
|
|
38350
|
-
${
|
|
38786
|
+
${import_picocolors22.default.bold(data.upgrade_url)}
|
|
38351
38787
|
|
|
38352
38788
|
`);
|
|
38353
38789
|
}
|
|
@@ -38372,7 +38808,7 @@ ${import_picocolors19.default.bold(data.upgrade_url)}
|
|
|
38372
38808
|
if (!runId) return void die("The service opened a run but did not name it.");
|
|
38373
38809
|
if (!jsonMode) {
|
|
38374
38810
|
process.stderr.write(
|
|
38375
|
-
|
|
38811
|
+
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
38812
|
|
|
38377
38813
|
`)
|
|
38378
38814
|
);
|
|
@@ -38424,10 +38860,10 @@ ${import_picocolors19.default.bold(data.upgrade_url)}
|
|
|
38424
38860
|
child.stdout.on("data", (d) => consume(d));
|
|
38425
38861
|
child.stderr.setEncoding("utf8");
|
|
38426
38862
|
child.stderr.on("data", (d) => {
|
|
38427
|
-
if (!jsonMode) process.stderr.write(
|
|
38863
|
+
if (!jsonMode) process.stderr.write(import_picocolors22.default.dim(d));
|
|
38428
38864
|
});
|
|
38429
38865
|
child.on("error", (err) => {
|
|
38430
|
-
process.stderr.write(
|
|
38866
|
+
process.stderr.write(import_picocolors22.default.red(`
|
|
38431
38867
|
\u2715 Could not run ${command[0]}: ${err.message}
|
|
38432
38868
|
`));
|
|
38433
38869
|
resolve(127);
|
|
@@ -38464,14 +38900,14 @@ ${import_picocolors19.default.bold(data.upgrade_url)}
|
|
|
38464
38900
|
}
|
|
38465
38901
|
if (appendFailure) {
|
|
38466
38902
|
process.stderr.write(
|
|
38467
|
-
|
|
38903
|
+
import_picocolors22.default.yellow(`
|
|
38468
38904
|
! Some output did not reach the page: ${appendFailure}
|
|
38469
|
-
`) +
|
|
38905
|
+
`) + import_picocolors22.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
|
|
38470
38906
|
);
|
|
38471
38907
|
}
|
|
38472
38908
|
if (exitCode) {
|
|
38473
38909
|
process.stderr.write(
|
|
38474
|
-
|
|
38910
|
+
import_picocolors22.default.yellow(`
|
|
38475
38911
|
! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
|
|
38476
38912
|
`)
|
|
38477
38913
|
);
|
|
@@ -38481,7 +38917,7 @@ ${import_picocolors19.default.bold(data.upgrade_url)}
|
|
|
38481
38917
|
}
|
|
38482
38918
|
|
|
38483
38919
|
// src/commands/trade.ts
|
|
38484
|
-
var
|
|
38920
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
38485
38921
|
|
|
38486
38922
|
// src/lib/trade-sol.ts
|
|
38487
38923
|
var import_web3 = __toESM(require_index_cjs(), 1);
|
|
@@ -38847,21 +39283,21 @@ function fail(message, json) {
|
|
|
38847
39283
|
if (json) {
|
|
38848
39284
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
38849
39285
|
} else {
|
|
38850
|
-
process.stderr.write(
|
|
39286
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${message}
|
|
38851
39287
|
`));
|
|
38852
39288
|
}
|
|
38853
39289
|
process.exit(1);
|
|
38854
39290
|
}
|
|
38855
39291
|
async function withContext(opts, fn) {
|
|
38856
39292
|
try {
|
|
38857
|
-
const
|
|
38858
|
-
return await fn(
|
|
39293
|
+
const ctx2 = await resolveTradeContext();
|
|
39294
|
+
return await fn(ctx2);
|
|
38859
39295
|
} catch (err) {
|
|
38860
39296
|
fail(err.message, opts.json);
|
|
38861
39297
|
}
|
|
38862
39298
|
}
|
|
38863
|
-
function servedFloorUnits(
|
|
38864
|
-
const served =
|
|
39299
|
+
function servedFloorUnits(ctx2) {
|
|
39300
|
+
const served = ctx2.config.trading?.minTradeUsdc;
|
|
38865
39301
|
if (typeof served !== "number" || !Number.isFinite(served) || served <= 0) return null;
|
|
38866
39302
|
return { units: BigInt(Math.round(served * 1e6)), usdc: served };
|
|
38867
39303
|
}
|
|
@@ -38887,30 +39323,30 @@ async function tradeKey(opts) {
|
|
|
38887
39323
|
}
|
|
38888
39324
|
}
|
|
38889
39325
|
async function tradeStatus(opts) {
|
|
38890
|
-
await withContext(opts, async (
|
|
39326
|
+
await withContext(opts, async (ctx2) => {
|
|
38891
39327
|
const key = await loadTradeKey();
|
|
38892
39328
|
let usdc = null;
|
|
38893
39329
|
let coin = null;
|
|
38894
39330
|
if (key) {
|
|
38895
39331
|
const connection = rpcConnection();
|
|
38896
|
-
usdc = await readTokenBalance(connection, key.state.address,
|
|
39332
|
+
usdc = await readTokenBalance(connection, key.state.address, ctx2.chain.usdcMint);
|
|
38897
39333
|
if (opts.coin) {
|
|
38898
39334
|
const resolved = await resolveCoin(opts.coin);
|
|
38899
39335
|
const bal = await readTokenBalance(connection, key.state.address, resolved.mint);
|
|
38900
39336
|
if (bal) coin = { ...resolved, ...bal };
|
|
38901
39337
|
}
|
|
38902
39338
|
}
|
|
38903
|
-
const floor = servedFloorUnits(
|
|
39339
|
+
const floor = servedFloorUnits(ctx2);
|
|
38904
39340
|
if (opts.json) {
|
|
38905
39341
|
process.stdout.write(
|
|
38906
39342
|
JSON.stringify({
|
|
38907
39343
|
ok: true,
|
|
38908
|
-
chainId:
|
|
38909
|
-
program:
|
|
38910
|
-
usdcMint:
|
|
38911
|
-
feePayer:
|
|
39344
|
+
chainId: ctx2.chainId,
|
|
39345
|
+
program: ctx2.chain.program,
|
|
39346
|
+
usdcMint: ctx2.chain.usdcMint,
|
|
39347
|
+
feePayer: ctx2.chain.feePayer ?? null,
|
|
38912
39348
|
minTradeUsdc: floor?.usdc ?? null,
|
|
38913
|
-
defaultSlippageBps:
|
|
39349
|
+
defaultSlippageBps: ctx2.config.defaultSlippageBps ?? null,
|
|
38914
39350
|
rpc: rpcUrl(),
|
|
38915
39351
|
address: key?.state.address ?? null,
|
|
38916
39352
|
usdc: usdc ? formatUnits(usdc.units, usdc.decimals) : null,
|
|
@@ -38920,8 +39356,8 @@ async function tradeStatus(opts) {
|
|
|
38920
39356
|
return;
|
|
38921
39357
|
}
|
|
38922
39358
|
const lines = [];
|
|
38923
|
-
lines.push(`Launch trading (Solana devnet, chain ${
|
|
38924
|
-
lines.push(`Curve program: ${
|
|
39359
|
+
lines.push(`Launch trading (Solana devnet, chain ${ctx2.chainId})`);
|
|
39360
|
+
lines.push(`Curve program: ${ctx2.chain.program}`);
|
|
38925
39361
|
if (floor) lines.push(`Buy floor: $${floor.usdc} (served by launch-config)`);
|
|
38926
39362
|
if (!key) {
|
|
38927
39363
|
lines.push("No agent trading key yet. Create one:");
|
|
@@ -38935,7 +39371,7 @@ async function tradeStatus(opts) {
|
|
|
38935
39371
|
});
|
|
38936
39372
|
}
|
|
38937
39373
|
async function tradeQuote(coinArg, amount, opts) {
|
|
38938
|
-
await withContext(opts, async (
|
|
39374
|
+
await withContext(opts, async (ctx2) => {
|
|
38939
39375
|
const side = opts.side === "sell" ? "sell" : "buy";
|
|
38940
39376
|
const coin = await resolveCoin(coinArg);
|
|
38941
39377
|
const amountNumber = Number(amount);
|
|
@@ -38956,13 +39392,13 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
38956
39392
|
if (!res.ok || !body) {
|
|
38957
39393
|
fail(`Quote failed: ${body?.error ?? `HTTP ${res.status}`}`, opts.json);
|
|
38958
39394
|
}
|
|
38959
|
-
const floor = servedFloorUnits(
|
|
39395
|
+
const floor = servedFloorUnits(ctx2);
|
|
38960
39396
|
const belowFloor = side === "buy" && floor !== null && parseDecimalToUnits(amount, USDC_DECIMALS, "Amount") < floor.units;
|
|
38961
39397
|
if (opts.json) {
|
|
38962
39398
|
process.stdout.write(
|
|
38963
39399
|
JSON.stringify({
|
|
38964
39400
|
ok: true,
|
|
38965
|
-
chainId:
|
|
39401
|
+
chainId: ctx2.chainId,
|
|
38966
39402
|
coin: coin.mint,
|
|
38967
39403
|
symbol: coin.symbol,
|
|
38968
39404
|
side,
|
|
@@ -38979,7 +39415,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
38979
39415
|
return;
|
|
38980
39416
|
}
|
|
38981
39417
|
const lines = [
|
|
38982
|
-
`${side === "buy" ? "Buy" : "Sell"} quote on ${coin.symbol ?? coin.mint} (chain ${
|
|
39418
|
+
`${side === "buy" ? "Buy" : "Sell"} quote on ${coin.symbol ?? coin.mint} (chain ${ctx2.chainId})`,
|
|
38983
39419
|
side === "buy" ? `In: ${amount} USDC` : `In: ${amount} coins`,
|
|
38984
39420
|
`Out: ${body.out ?? "(unavailable)"} ${side === "buy" ? "coins" : "USDC"}`,
|
|
38985
39421
|
`Fee: ${body.feeUsdc ?? "?"} USDC impact ${body.priceImpactBps ?? "?"} bps`
|
|
@@ -38990,15 +39426,15 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
38990
39426
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
38991
39427
|
});
|
|
38992
39428
|
}
|
|
38993
|
-
async function reportTrade(
|
|
39429
|
+
async function reportTrade(ctx2, opts, args) {
|
|
38994
39430
|
const connection = rpcConnection();
|
|
38995
|
-
const usdc = await readTokenBalance(connection, args.address,
|
|
39431
|
+
const usdc = await readTokenBalance(connection, args.address, ctx2.chain.usdcMint);
|
|
38996
39432
|
const coinBal = await readTokenBalance(connection, args.address, args.coin.mint);
|
|
38997
39433
|
if (opts.json) {
|
|
38998
39434
|
process.stdout.write(
|
|
38999
39435
|
JSON.stringify({
|
|
39000
39436
|
ok: true,
|
|
39001
|
-
chainId:
|
|
39437
|
+
chainId: ctx2.chainId,
|
|
39002
39438
|
side: args.side,
|
|
39003
39439
|
coin: args.coin.mint,
|
|
39004
39440
|
symbol: args.coin.symbol,
|
|
@@ -39023,7 +39459,7 @@ async function reportTrade(ctx, opts, args) {
|
|
|
39023
39459
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
39024
39460
|
}
|
|
39025
39461
|
async function tradeBuy(coinArg, amount, opts) {
|
|
39026
|
-
await withContext(opts, async (
|
|
39462
|
+
await withContext(opts, async (ctx2) => {
|
|
39027
39463
|
const coin = await resolveCoin(coinArg);
|
|
39028
39464
|
let units;
|
|
39029
39465
|
try {
|
|
@@ -39032,21 +39468,21 @@ async function tradeBuy(coinArg, amount, opts) {
|
|
|
39032
39468
|
fail(err.message, opts.json);
|
|
39033
39469
|
}
|
|
39034
39470
|
if (units <= 0n) fail("Buy amount must be above zero.", opts.json);
|
|
39035
|
-
const floor = servedFloorUnits(
|
|
39471
|
+
const floor = servedFloorUnits(ctx2);
|
|
39036
39472
|
if (floor && units < floor.units) {
|
|
39037
39473
|
fail(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
39038
39474
|
}
|
|
39039
39475
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
39040
39476
|
if (created && !opts.json) {
|
|
39041
|
-
process.stderr.write(
|
|
39477
|
+
process.stderr.write(import_picocolors23.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
39042
39478
|
`));
|
|
39043
39479
|
}
|
|
39044
|
-
const result = await runTrade({ ctx, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
39045
|
-
await reportTrade(
|
|
39480
|
+
const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
39481
|
+
await reportTrade(ctx2, opts, { side: "buy", coin, address: state.address, amount, result });
|
|
39046
39482
|
});
|
|
39047
39483
|
}
|
|
39048
39484
|
async function tradeSell(coinArg, amount, opts) {
|
|
39049
|
-
await withContext(opts, async (
|
|
39485
|
+
await withContext(opts, async (ctx2) => {
|
|
39050
39486
|
const coin = await resolveCoin(coinArg);
|
|
39051
39487
|
const key = await loadTradeKey();
|
|
39052
39488
|
if (!key) fail("No agent trading key yet (nothing to sell with). Run: agentgates trade key", opts.json);
|
|
@@ -39067,8 +39503,8 @@ async function tradeSell(coinArg, amount, opts) {
|
|
|
39067
39503
|
} else if (!/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
39068
39504
|
fail(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
39069
39505
|
}
|
|
39070
|
-
const result = await runTrade({ ctx, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
|
|
39071
|
-
await reportTrade(
|
|
39506
|
+
const result = await runTrade({ ctx: ctx2, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
|
|
39507
|
+
await reportTrade(ctx2, opts, { side: "sell", coin, address: key.state.address, amount: sellAmount, result });
|
|
39072
39508
|
});
|
|
39073
39509
|
}
|
|
39074
39510
|
function describeOrder(o) {
|
|
@@ -39078,7 +39514,7 @@ function describeOrder(o) {
|
|
|
39078
39514
|
return `${o.id} ${o.kind} ${amount} ${trigger} ${o.status}${tail} expires ${o.expiresAt}`;
|
|
39079
39515
|
}
|
|
39080
39516
|
async function tradeOrderPlace(coinArg, opts) {
|
|
39081
|
-
await withContext(opts, async (
|
|
39517
|
+
await withContext(opts, async (ctx2) => {
|
|
39082
39518
|
if (opts.buy === void 0 === (opts.sell === void 0)) {
|
|
39083
39519
|
fail("Pass exactly one of --buy <usdc> or --sell <amount|N%|all>.", opts.json);
|
|
39084
39520
|
}
|
|
@@ -39092,7 +39528,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
39092
39528
|
if (opts.mcap && !opts.at) fail("--mcap qualifies --at.", opts.json);
|
|
39093
39529
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
39094
39530
|
if (created && !opts.json) {
|
|
39095
|
-
process.stderr.write(
|
|
39531
|
+
process.stderr.write(import_picocolors23.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
39096
39532
|
`));
|
|
39097
39533
|
}
|
|
39098
39534
|
let amount;
|
|
@@ -39103,7 +39539,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
39103
39539
|
} catch (err) {
|
|
39104
39540
|
fail(err.message, opts.json);
|
|
39105
39541
|
}
|
|
39106
|
-
const floor = servedFloorUnits(
|
|
39542
|
+
const floor = servedFloorUnits(ctx2);
|
|
39107
39543
|
if (floor && units < floor.units) {
|
|
39108
39544
|
fail(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
39109
39545
|
}
|
|
@@ -39145,14 +39581,14 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
39145
39581
|
} : {},
|
|
39146
39582
|
...expiresInDays !== void 0 ? { expiresInDays } : {}
|
|
39147
39583
|
});
|
|
39148
|
-
const signed = signPreparedOrder(prepared, keypair,
|
|
39584
|
+
const signed = signPreparedOrder(prepared, keypair, ctx2.chain);
|
|
39149
39585
|
const order = await placeOrder({
|
|
39150
39586
|
nonceAccount: prepared.nonceAccount,
|
|
39151
39587
|
signer: state.address,
|
|
39152
39588
|
signedTransaction: signed.serialize({ requireAllSignatures: false }).toString("base64")
|
|
39153
39589
|
});
|
|
39154
39590
|
if (opts.json) {
|
|
39155
|
-
process.stdout.write(JSON.stringify({ ok: true, chainId:
|
|
39591
|
+
process.stdout.write(JSON.stringify({ ok: true, chainId: ctx2.chainId, coin: coin.mint, symbol: coin.symbol, order, nonceAccount: prepared.nonceAccount }) + "\n");
|
|
39156
39592
|
return;
|
|
39157
39593
|
}
|
|
39158
39594
|
process.stdout.write(
|
|
@@ -39164,13 +39600,13 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
39164
39600
|
});
|
|
39165
39601
|
}
|
|
39166
39602
|
async function tradeOrdersList(opts) {
|
|
39167
|
-
await withContext(opts, async (
|
|
39603
|
+
await withContext(opts, async (ctx2) => {
|
|
39168
39604
|
const key = await loadTradeKey();
|
|
39169
39605
|
if (!key) fail("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
39170
39606
|
const token = opts.coin ? (await resolveCoin(opts.coin)).mint : void 0;
|
|
39171
39607
|
const res = await listOrders(key.state.address, token);
|
|
39172
39608
|
if (opts.json) {
|
|
39173
|
-
process.stdout.write(JSON.stringify({ ok: true, chainId:
|
|
39609
|
+
process.stdout.write(JSON.stringify({ ok: true, chainId: ctx2.chainId, address: key.state.address, openCount: res.openCount, orders: res.orders }) + "\n");
|
|
39174
39610
|
return;
|
|
39175
39611
|
}
|
|
39176
39612
|
if (!res.orders?.length) {
|
|
@@ -39207,7 +39643,7 @@ async function tradeOrderCancel(id, opts) {
|
|
|
39207
39643
|
});
|
|
39208
39644
|
}
|
|
39209
39645
|
async function tradePositions(opts) {
|
|
39210
|
-
await withContext(opts, async (
|
|
39646
|
+
await withContext(opts, async (ctx2) => {
|
|
39211
39647
|
const key = await loadTradeKey();
|
|
39212
39648
|
if (!key) fail("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
39213
39649
|
let body;
|
|
@@ -39222,7 +39658,7 @@ async function tradePositions(opts) {
|
|
|
39222
39658
|
process.stdout.write(
|
|
39223
39659
|
JSON.stringify({
|
|
39224
39660
|
ok: true,
|
|
39225
|
-
chainId:
|
|
39661
|
+
chainId: ctx2.chainId,
|
|
39226
39662
|
address: key.state.address,
|
|
39227
39663
|
positions: rows.map((t) => ({
|
|
39228
39664
|
coin: t.address,
|
|
@@ -39245,7 +39681,7 @@ async function tradePositions(opts) {
|
|
|
39245
39681
|
` + AI_DIRECTIVE + "\n");
|
|
39246
39682
|
return;
|
|
39247
39683
|
}
|
|
39248
|
-
const lines = [`Positions for ${key.state.address} (chain ${
|
|
39684
|
+
const lines = [`Positions for ${key.state.address} (chain ${ctx2.chainId}):`];
|
|
39249
39685
|
for (const t of rows) {
|
|
39250
39686
|
const p = t.position ?? {};
|
|
39251
39687
|
lines.push(
|
|
@@ -39257,7 +39693,7 @@ async function tradePositions(opts) {
|
|
|
39257
39693
|
}
|
|
39258
39694
|
|
|
39259
39695
|
// src/commands/desk.ts
|
|
39260
|
-
var
|
|
39696
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
39261
39697
|
|
|
39262
39698
|
// src/lib/desk-sol.ts
|
|
39263
39699
|
var import_web32 = __toESM(require_index_cjs(), 1);
|
|
@@ -39265,14 +39701,14 @@ import { promises as fs8 } from "node:fs";
|
|
|
39265
39701
|
import * as path4 from "node:path";
|
|
39266
39702
|
import * as os4 from "node:os";
|
|
39267
39703
|
async function resolveDeskContext() {
|
|
39268
|
-
const
|
|
39269
|
-
const desk2 =
|
|
39704
|
+
const ctx2 = await resolveTradeContext();
|
|
39705
|
+
const desk2 = ctx2.chain.desk;
|
|
39270
39706
|
if (!desk2) {
|
|
39271
39707
|
throw new Error(
|
|
39272
39708
|
`launch-config serves no desk program for chain ${TRADE_CHAIN_ID}; the desk lane is not armed.`
|
|
39273
39709
|
);
|
|
39274
39710
|
}
|
|
39275
|
-
return { ...
|
|
39711
|
+
return { ...ctx2, desk: desk2 };
|
|
39276
39712
|
}
|
|
39277
39713
|
function deskSessionPath() {
|
|
39278
39714
|
return path4.join(os4.homedir(), ".agentgates", "desk-session-sol.json");
|
|
@@ -39431,21 +39867,21 @@ function fail2(message, json) {
|
|
|
39431
39867
|
if (json) {
|
|
39432
39868
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
39433
39869
|
} else {
|
|
39434
|
-
process.stderr.write(
|
|
39870
|
+
process.stderr.write(import_picocolors24.default.red(`\u2715 ${message}
|
|
39435
39871
|
`));
|
|
39436
39872
|
}
|
|
39437
39873
|
process.exit(1);
|
|
39438
39874
|
}
|
|
39439
39875
|
async function withDesk(opts, fn) {
|
|
39440
39876
|
try {
|
|
39441
|
-
const
|
|
39442
|
-
return await fn(
|
|
39877
|
+
const ctx2 = await resolveDeskContext();
|
|
39878
|
+
return await fn(ctx2);
|
|
39443
39879
|
} catch (err) {
|
|
39444
39880
|
fail2(err.message, opts.json);
|
|
39445
39881
|
}
|
|
39446
39882
|
}
|
|
39447
|
-
function servedFloorUnits2(
|
|
39448
|
-
const served =
|
|
39883
|
+
function servedFloorUnits2(ctx2) {
|
|
39884
|
+
const served = ctx2.config.trading?.minTradeUsdc;
|
|
39449
39885
|
if (typeof served !== "number" || !Number.isFinite(served) || served <= 0) return null;
|
|
39450
39886
|
return { units: BigInt(Math.round(served * 1e6)), usdc: served };
|
|
39451
39887
|
}
|
|
@@ -39516,7 +39952,7 @@ function describeFills(fills, symbols) {
|
|
|
39516
39952
|
return lines;
|
|
39517
39953
|
}
|
|
39518
39954
|
async function deskStatus(opts) {
|
|
39519
|
-
await withDesk(opts, async (
|
|
39955
|
+
await withDesk(opts, async (ctx2) => {
|
|
39520
39956
|
let fillsLimit;
|
|
39521
39957
|
if (opts.fills !== void 0) {
|
|
39522
39958
|
const n = Number(opts.fills);
|
|
@@ -39529,13 +39965,13 @@ async function deskStatus(opts) {
|
|
|
39529
39965
|
const coin = opts.coin ? await resolveCoin(opts.coin) : null;
|
|
39530
39966
|
const state = await deskState(owner.state.address, coin?.mint, fillsLimit);
|
|
39531
39967
|
const session = await loadDeskSessionKey();
|
|
39532
|
-
const floor = servedFloorUnits2(
|
|
39968
|
+
const floor = servedFloorUnits2(ctx2);
|
|
39533
39969
|
if (opts.json) {
|
|
39534
39970
|
process.stdout.write(
|
|
39535
39971
|
JSON.stringify({
|
|
39536
39972
|
ok: true,
|
|
39537
|
-
chainId:
|
|
39538
|
-
desk:
|
|
39973
|
+
chainId: ctx2.chainId,
|
|
39974
|
+
desk: ctx2.desk,
|
|
39539
39975
|
minTradeUsdc: floor?.usdc ?? null,
|
|
39540
39976
|
sessionKeyFile: session?.state.address ?? null,
|
|
39541
39977
|
...stateJson(state),
|
|
@@ -39547,8 +39983,8 @@ async function deskStatus(opts) {
|
|
|
39547
39983
|
return;
|
|
39548
39984
|
}
|
|
39549
39985
|
const lines = [
|
|
39550
|
-
`Launch trading desk (Solana devnet, chain ${
|
|
39551
|
-
`Desk program: ${
|
|
39986
|
+
`Launch trading desk (Solana devnet, chain ${ctx2.chainId})`,
|
|
39987
|
+
`Desk program: ${ctx2.desk}`,
|
|
39552
39988
|
`Owner: ${state.owner}`,
|
|
39553
39989
|
`USDC credit: ${state.usdc.credit}`
|
|
39554
39990
|
];
|
|
@@ -39564,7 +40000,7 @@ async function deskStatus(opts) {
|
|
|
39564
40000
|
});
|
|
39565
40001
|
}
|
|
39566
40002
|
async function deskDeposit(amount, opts) {
|
|
39567
|
-
await withDesk(opts, async (
|
|
40003
|
+
await withDesk(opts, async (ctx2) => {
|
|
39568
40004
|
let units;
|
|
39569
40005
|
try {
|
|
39570
40006
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Deposit amount");
|
|
@@ -39574,11 +40010,11 @@ async function deskDeposit(amount, opts) {
|
|
|
39574
40010
|
if (units <= 0n) fail2("Deposit amount must be above zero.", opts.json);
|
|
39575
40011
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
39576
40012
|
if (created && !opts.json) {
|
|
39577
|
-
process.stderr.write(
|
|
40013
|
+
process.stderr.write(import_picocolors24.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
39578
40014
|
`));
|
|
39579
40015
|
}
|
|
39580
40016
|
const result = await runDeskCeremony({
|
|
39581
|
-
ctx,
|
|
40017
|
+
ctx: ctx2,
|
|
39582
40018
|
ownerKeypair: keypair,
|
|
39583
40019
|
op: "deposit",
|
|
39584
40020
|
prepareBody: { token: "usdc", amount }
|
|
@@ -39588,7 +40024,7 @@ async function deskDeposit(amount, opts) {
|
|
|
39588
40024
|
process.stdout.write(
|
|
39589
40025
|
JSON.stringify({
|
|
39590
40026
|
ok: true,
|
|
39591
|
-
chainId:
|
|
40027
|
+
chainId: ctx2.chainId,
|
|
39592
40028
|
op: "deposit",
|
|
39593
40029
|
amount,
|
|
39594
40030
|
amountUnits: result.prepared.amountUnits ?? null,
|
|
@@ -39608,7 +40044,7 @@ async function deskDeposit(amount, opts) {
|
|
|
39608
40044
|
});
|
|
39609
40045
|
}
|
|
39610
40046
|
async function deskWithdraw(amount, opts) {
|
|
39611
|
-
await withDesk(opts, async (
|
|
40047
|
+
await withDesk(opts, async (ctx2) => {
|
|
39612
40048
|
const owner = await requireOwner(opts);
|
|
39613
40049
|
const coin = opts.coin ? await resolveCoin(opts.coin) : null;
|
|
39614
40050
|
const token = coin?.mint ?? "usdc";
|
|
@@ -39619,7 +40055,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
39619
40055
|
}
|
|
39620
40056
|
}
|
|
39621
40057
|
const result = await runDeskCeremony({
|
|
39622
|
-
ctx,
|
|
40058
|
+
ctx: ctx2,
|
|
39623
40059
|
ownerKeypair: owner.keypair,
|
|
39624
40060
|
op: "withdraw",
|
|
39625
40061
|
prepareBody: { token, amount: trimmed }
|
|
@@ -39629,7 +40065,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
39629
40065
|
process.stdout.write(
|
|
39630
40066
|
JSON.stringify({
|
|
39631
40067
|
ok: true,
|
|
39632
|
-
chainId:
|
|
40068
|
+
chainId: ctx2.chainId,
|
|
39633
40069
|
op: "withdraw",
|
|
39634
40070
|
token: result.prepared.mint ?? token,
|
|
39635
40071
|
amount: trimmed,
|
|
@@ -39653,7 +40089,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
39653
40089
|
});
|
|
39654
40090
|
}
|
|
39655
40091
|
async function deskSessionRegister(opts) {
|
|
39656
|
-
await withDesk(opts, async (
|
|
40092
|
+
await withDesk(opts, async (ctx2) => {
|
|
39657
40093
|
if (!opts.cap) fail2("--cap <usdc> is required: the per-trade cap is your risk statement, never defaulted.", opts.json);
|
|
39658
40094
|
if (!opts.minutes) fail2("--minutes <n> is required: the session expiry is your risk statement, never defaulted.", opts.json);
|
|
39659
40095
|
let capUnits;
|
|
@@ -39669,18 +40105,18 @@ async function deskSessionRegister(opts) {
|
|
|
39669
40105
|
}
|
|
39670
40106
|
const owner = await loadOrCreateTradeKey();
|
|
39671
40107
|
if (owner.created && !opts.json) {
|
|
39672
|
-
process.stderr.write(
|
|
40108
|
+
process.stderr.write(import_picocolors24.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
|
|
39673
40109
|
`));
|
|
39674
40110
|
}
|
|
39675
40111
|
const session = await loadOrCreateDeskSessionKey();
|
|
39676
40112
|
if (session.created && !opts.json) {
|
|
39677
40113
|
process.stderr.write(
|
|
39678
|
-
|
|
40114
|
+
import_picocolors24.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
|
|
39679
40115
|
`)
|
|
39680
40116
|
);
|
|
39681
40117
|
}
|
|
39682
40118
|
const result = await runDeskCeremony({
|
|
39683
|
-
ctx,
|
|
40119
|
+
ctx: ctx2,
|
|
39684
40120
|
ownerKeypair: owner.keypair,
|
|
39685
40121
|
op: "register",
|
|
39686
40122
|
prepareBody: {
|
|
@@ -39694,7 +40130,7 @@ async function deskSessionRegister(opts) {
|
|
|
39694
40130
|
process.stdout.write(
|
|
39695
40131
|
JSON.stringify({
|
|
39696
40132
|
ok: true,
|
|
39697
|
-
chainId:
|
|
40133
|
+
chainId: ctx2.chainId,
|
|
39698
40134
|
op: "register",
|
|
39699
40135
|
sessionKey: session.state.address,
|
|
39700
40136
|
perTradeCapUsdc: opts.cap,
|
|
@@ -39718,10 +40154,10 @@ async function deskSessionRegister(opts) {
|
|
|
39718
40154
|
});
|
|
39719
40155
|
}
|
|
39720
40156
|
async function deskSessionRevoke(opts) {
|
|
39721
|
-
await withDesk(opts, async (
|
|
40157
|
+
await withDesk(opts, async (ctx2) => {
|
|
39722
40158
|
const owner = await requireOwner(opts);
|
|
39723
40159
|
const result = await runDeskCeremony({
|
|
39724
|
-
ctx,
|
|
40160
|
+
ctx: ctx2,
|
|
39725
40161
|
ownerKeypair: owner.keypair,
|
|
39726
40162
|
op: "revoke",
|
|
39727
40163
|
prepareBody: {}
|
|
@@ -39730,7 +40166,7 @@ async function deskSessionRevoke(opts) {
|
|
|
39730
40166
|
process.stdout.write(
|
|
39731
40167
|
JSON.stringify({
|
|
39732
40168
|
ok: true,
|
|
39733
|
-
chainId:
|
|
40169
|
+
chainId: ctx2.chainId,
|
|
39734
40170
|
op: "revoke",
|
|
39735
40171
|
txHash: result.txHash,
|
|
39736
40172
|
reprepared: result.reprepared
|
|
@@ -39756,13 +40192,13 @@ async function requireSessionKeypair(opts) {
|
|
|
39756
40192
|
}
|
|
39757
40193
|
return session;
|
|
39758
40194
|
}
|
|
39759
|
-
async function reportDeskTrade(
|
|
40195
|
+
async function reportDeskTrade(ctx2, opts, args) {
|
|
39760
40196
|
const after = await deskState(args.owner, args.coin.mint);
|
|
39761
40197
|
if (opts.json) {
|
|
39762
40198
|
process.stdout.write(
|
|
39763
40199
|
JSON.stringify({
|
|
39764
40200
|
ok: true,
|
|
39765
|
-
chainId:
|
|
40201
|
+
chainId: ctx2.chainId,
|
|
39766
40202
|
op: args.side,
|
|
39767
40203
|
coin: args.coin.mint,
|
|
39768
40204
|
symbol: args.coin.symbol,
|
|
@@ -39787,7 +40223,7 @@ async function reportDeskTrade(ctx, opts, args) {
|
|
|
39787
40223
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
39788
40224
|
}
|
|
39789
40225
|
async function deskBuy(coinArg, amount, opts) {
|
|
39790
|
-
await withDesk(opts, async (
|
|
40226
|
+
await withDesk(opts, async (ctx2) => {
|
|
39791
40227
|
const coin = await resolveCoin(coinArg);
|
|
39792
40228
|
let units;
|
|
39793
40229
|
try {
|
|
@@ -39796,14 +40232,14 @@ async function deskBuy(coinArg, amount, opts) {
|
|
|
39796
40232
|
fail2(err.message, opts.json);
|
|
39797
40233
|
}
|
|
39798
40234
|
if (units <= 0n) fail2("Buy amount must be above zero.", opts.json);
|
|
39799
|
-
const floor = servedFloorUnits2(
|
|
40235
|
+
const floor = servedFloorUnits2(ctx2);
|
|
39800
40236
|
if (floor && units < floor.units) {
|
|
39801
40237
|
fail2(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
39802
40238
|
}
|
|
39803
40239
|
const owner = await requireOwner(opts);
|
|
39804
40240
|
const session = await requireSessionKeypair(opts);
|
|
39805
40241
|
const result = await runDeskTrade({
|
|
39806
|
-
ctx,
|
|
40242
|
+
ctx: ctx2,
|
|
39807
40243
|
sessionKeypair: session.keypair,
|
|
39808
40244
|
owner: owner.state.address,
|
|
39809
40245
|
op: "buy",
|
|
@@ -39811,11 +40247,11 @@ async function deskBuy(coinArg, amount, opts) {
|
|
|
39811
40247
|
amount,
|
|
39812
40248
|
minOut: opts.minOut
|
|
39813
40249
|
});
|
|
39814
|
-
await reportDeskTrade(
|
|
40250
|
+
await reportDeskTrade(ctx2, opts, { side: "buy", coin, owner: owner.state.address, amount, result });
|
|
39815
40251
|
});
|
|
39816
40252
|
}
|
|
39817
40253
|
async function deskSell(coinArg, amount, opts) {
|
|
39818
|
-
await withDesk(opts, async (
|
|
40254
|
+
await withDesk(opts, async (ctx2) => {
|
|
39819
40255
|
const coin = await resolveCoin(coinArg);
|
|
39820
40256
|
const owner = await requireOwner(opts);
|
|
39821
40257
|
const session = await requireSessionKeypair(opts);
|
|
@@ -39835,7 +40271,7 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
39835
40271
|
fail2(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
39836
40272
|
}
|
|
39837
40273
|
const result = await runDeskTrade({
|
|
39838
|
-
ctx,
|
|
40274
|
+
ctx: ctx2,
|
|
39839
40275
|
sessionKeypair: session.keypair,
|
|
39840
40276
|
owner: owner.state.address,
|
|
39841
40277
|
op: "sell",
|
|
@@ -39843,7 +40279,7 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
39843
40279
|
amount: sellAmount,
|
|
39844
40280
|
minOut: opts.minOut
|
|
39845
40281
|
});
|
|
39846
|
-
await reportDeskTrade(
|
|
40282
|
+
await reportDeskTrade(ctx2, opts, { side: "sell", coin, owner: owner.state.address, amount: sellAmount, result });
|
|
39847
40283
|
});
|
|
39848
40284
|
}
|
|
39849
40285
|
|
|
@@ -40217,7 +40653,7 @@ program2.command("fund").description(
|
|
|
40217
40653
|
}
|
|
40218
40654
|
if (opts.usdc || opts.gas || opts.chain) {
|
|
40219
40655
|
process.stderr.write(
|
|
40220
|
-
|
|
40656
|
+
import_picocolors25.default.red(
|
|
40221
40657
|
`\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
|
|
40222
40658
|
`
|
|
40223
40659
|
)
|
|
@@ -40336,11 +40772,28 @@ desk.command("buy").description("Buy a launch coin with desk USDC credit (sessio
|
|
|
40336
40772
|
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
40773
|
await deskSell(coin, amount, opts);
|
|
40338
40774
|
});
|
|
40775
|
+
program2.command("onboard").description("Welcome screen: look at what is for sale, or pair your wallet. Run by the installer.").option("--profile <name>", "named profile (default: 'default')").option("--lane <lane>", "which lane leads the menu: compute | inference").action(async (opts) => {
|
|
40776
|
+
await onboard(opts);
|
|
40777
|
+
});
|
|
40778
|
+
var compute = program2.command("compute").description("Confidential virtual machines by the hour, USDC per payment");
|
|
40779
|
+
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) => {
|
|
40780
|
+
await computePlans(opts);
|
|
40781
|
+
});
|
|
40782
|
+
compute.command("buy").description("Rent a machine (needs an x402 signature this CLI does not have yet)").action(async () => {
|
|
40783
|
+
await computeBuy();
|
|
40784
|
+
});
|
|
40785
|
+
var inference = program2.command("inference").description("Attested confidential models, plus an open tier, USDC per request");
|
|
40786
|
+
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("--tier <tier>", "confidential | open").option("--tag <tag>", "filter by tag, repeatable (the board carries: reasoning, multimodal, frontier)", (v, prev) => prev.concat(v), []).option("--org <org>", "filter by maker org (openai, anthropic, qwen, ...)").option("--search <text>", "match against model id and name").option("--json", "machine-readable output (the catalog, filters applied)").action(async (opts) => {
|
|
40787
|
+
await inferenceModels(opts);
|
|
40788
|
+
});
|
|
40789
|
+
inference.command("ask").description("One paid ask (needs an x402 signature this CLI does not have yet)").action(async () => {
|
|
40790
|
+
await inferenceAsk();
|
|
40791
|
+
});
|
|
40339
40792
|
program2.parseAsync(process.argv).catch((err) => {
|
|
40340
|
-
process.stderr.write(
|
|
40793
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${err.message}
|
|
40341
40794
|
`));
|
|
40342
40795
|
if (process.env.BOUNTY_DEBUG) {
|
|
40343
|
-
process.stderr.write(
|
|
40796
|
+
process.stderr.write(import_picocolors25.default.dim((err.stack ?? "") + "\n"));
|
|
40344
40797
|
}
|
|
40345
40798
|
process.exit(1);
|
|
40346
40799
|
});
|