@agentgates/cli 0.19.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +744 -547
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -6875,7 +6875,7 @@ var require_package = __commonJS({
|
|
|
6875
6875
|
"package.json"(exports, module) {
|
|
6876
6876
|
module.exports = {
|
|
6877
6877
|
name: "@agentgates/cli",
|
|
6878
|
-
version: "0.
|
|
6878
|
+
version: "0.20.0",
|
|
6879
6879
|
description: "Wallet operations for AI agents and humans",
|
|
6880
6880
|
keywords: [
|
|
6881
6881
|
"crypto",
|
|
@@ -17694,10 +17694,10 @@ var require_dist = __commonJS({
|
|
|
17694
17694
|
}
|
|
17695
17695
|
});
|
|
17696
17696
|
}
|
|
17697
|
-
function omit(struct2,
|
|
17697
|
+
function omit(struct2, keys2) {
|
|
17698
17698
|
const { schema } = struct2;
|
|
17699
17699
|
const subschema = { ...schema };
|
|
17700
|
-
for (const key of
|
|
17700
|
+
for (const key of keys2) {
|
|
17701
17701
|
delete subschema[key];
|
|
17702
17702
|
}
|
|
17703
17703
|
switch (struct2.type) {
|
|
@@ -17718,10 +17718,10 @@ var require_dist = __commonJS({
|
|
|
17718
17718
|
}
|
|
17719
17719
|
return object2(schema);
|
|
17720
17720
|
}
|
|
17721
|
-
function pick(struct2,
|
|
17721
|
+
function pick(struct2, keys2) {
|
|
17722
17722
|
const { schema } = struct2;
|
|
17723
17723
|
const subschema = {};
|
|
17724
|
-
for (const key of
|
|
17724
|
+
for (const key of keys2) {
|
|
17725
17725
|
subschema[key] = schema[key];
|
|
17726
17726
|
}
|
|
17727
17727
|
switch (struct2.type) {
|
|
@@ -17984,13 +17984,13 @@ var require_dist = __commonJS({
|
|
|
17984
17984
|
});
|
|
17985
17985
|
}
|
|
17986
17986
|
function type(schema) {
|
|
17987
|
-
const
|
|
17987
|
+
const keys2 = Object.keys(schema);
|
|
17988
17988
|
return new Struct({
|
|
17989
17989
|
type: "type",
|
|
17990
17990
|
schema,
|
|
17991
17991
|
*entries(value) {
|
|
17992
17992
|
if (isObject(value)) {
|
|
17993
|
-
for (const k of
|
|
17993
|
+
for (const k of keys2) {
|
|
17994
17994
|
yield [k, value[k], schema[k]];
|
|
17995
17995
|
}
|
|
17996
17996
|
}
|
|
@@ -18839,9 +18839,9 @@ var require_utils3 = __commonJS({
|
|
|
18839
18839
|
"node_modules/whatwg-url/lib/utils.js"(exports, module) {
|
|
18840
18840
|
"use strict";
|
|
18841
18841
|
module.exports.mixin = function mixin(target, source) {
|
|
18842
|
-
const
|
|
18843
|
-
for (let i = 0; i <
|
|
18844
|
-
Object.defineProperty(target,
|
|
18842
|
+
const keys2 = Object.getOwnPropertyNames(source);
|
|
18843
|
+
for (let i = 0; i < keys2.length; ++i) {
|
|
18844
|
+
Object.defineProperty(target, keys2[i], Object.getOwnPropertyDescriptor(source, keys2[i]));
|
|
18845
18845
|
}
|
|
18846
18846
|
};
|
|
18847
18847
|
module.exports.wrapperSymbol = /* @__PURE__ */ Symbol("wrapper");
|
|
@@ -21120,8 +21120,8 @@ var require_lib3 = __commonJS({
|
|
|
21120
21120
|
});
|
|
21121
21121
|
function getHeaders(headers) {
|
|
21122
21122
|
let kind = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "key+value";
|
|
21123
|
-
const
|
|
21124
|
-
return
|
|
21123
|
+
const keys2 = Object.keys(headers[MAP]).sort();
|
|
21124
|
+
return keys2.map(kind === "key" ? function(k) {
|
|
21125
21125
|
return k.toLowerCase();
|
|
21126
21126
|
} : kind === "value" ? function(k) {
|
|
21127
21127
|
return headers[MAP][k].join(", ");
|
|
@@ -25454,7 +25454,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
25454
25454
|
if (listeners.fn) return 1;
|
|
25455
25455
|
return listeners.length;
|
|
25456
25456
|
};
|
|
25457
|
-
EventEmitter.prototype.emit = function
|
|
25457
|
+
EventEmitter.prototype.emit = function emit5(event, a1, a2, a3, a4, a5) {
|
|
25458
25458
|
var evt = prefix ? prefix + event : event;
|
|
25459
25459
|
if (!this._events[evt]) return false;
|
|
25460
25460
|
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
@@ -30331,7 +30331,7 @@ Missing signature for public key${sigErrors.missing.length === 1 ? "" : "(s)"} [
|
|
|
30331
30331
|
transaction.signatures.push(sigPubkeyPair);
|
|
30332
30332
|
});
|
|
30333
30333
|
message.instructions.forEach((instruction) => {
|
|
30334
|
-
const
|
|
30334
|
+
const keys2 = instruction.accounts.map((account) => {
|
|
30335
30335
|
const pubkey = message.accountKeys[account];
|
|
30336
30336
|
return {
|
|
30337
30337
|
pubkey,
|
|
@@ -30340,7 +30340,7 @@ Missing signature for public key${sigErrors.missing.length === 1 ? "" : "(s)"} [
|
|
|
30340
30340
|
};
|
|
30341
30341
|
});
|
|
30342
30342
|
transaction.instructions.push(new TransactionInstruction({
|
|
30343
|
-
keys,
|
|
30343
|
+
keys: keys2,
|
|
30344
30344
|
programId: message.accountKeys[instruction.programIdIndex],
|
|
30345
30345
|
data: bs58__default.default.decode(instruction.data)
|
|
30346
30346
|
}));
|
|
@@ -30381,7 +30381,7 @@ Missing signature for public key${sigErrors.missing.length === 1 ? "" : "(s)"} [
|
|
|
30381
30381
|
}
|
|
30382
30382
|
const instructions = [];
|
|
30383
30383
|
for (const compiledIx of compiledInstructions) {
|
|
30384
|
-
const
|
|
30384
|
+
const keys2 = [];
|
|
30385
30385
|
for (const keyIndex of compiledIx.accountKeyIndexes) {
|
|
30386
30386
|
const pubkey = accountKeys.get(keyIndex);
|
|
30387
30387
|
if (pubkey === void 0) {
|
|
@@ -30397,7 +30397,7 @@ Missing signature for public key${sigErrors.missing.length === 1 ? "" : "(s)"} [
|
|
|
30397
30397
|
isWritable = keyIndex - accountKeys.staticAccountKeys.length < // accountKeysFromLookups cannot be undefined because we already found a pubkey for this index above
|
|
30398
30398
|
accountKeys.accountKeysFromLookups.writable.length;
|
|
30399
30399
|
}
|
|
30400
|
-
|
|
30400
|
+
keys2.push({
|
|
30401
30401
|
pubkey,
|
|
30402
30402
|
isSigner: keyIndex < header.numRequiredSignatures,
|
|
30403
30403
|
isWritable
|
|
@@ -30410,7 +30410,7 @@ Missing signature for public key${sigErrors.missing.length === 1 ? "" : "(s)"} [
|
|
|
30410
30410
|
instructions.push(new TransactionInstruction({
|
|
30411
30411
|
programId,
|
|
30412
30412
|
data: toBuffer(compiledIx.data),
|
|
30413
|
-
keys
|
|
30413
|
+
keys: keys2
|
|
30414
30414
|
}));
|
|
30415
30415
|
}
|
|
30416
30416
|
return new _TransactionMessage({
|
|
@@ -30955,9 +30955,9 @@ Message: ${transactionMessage}.
|
|
|
30955
30955
|
/**
|
|
30956
30956
|
* @internal
|
|
30957
30957
|
*/
|
|
30958
|
-
static checkKeyLength(
|
|
30959
|
-
if (
|
|
30960
|
-
throw new Error(`invalid instruction; found ${
|
|
30958
|
+
static checkKeyLength(keys2, expectedLength) {
|
|
30959
|
+
if (keys2.length < expectedLength) {
|
|
30960
|
+
throw new Error(`invalid instruction; found ${keys2.length} keys, expected at least ${expectedLength}`);
|
|
30961
30961
|
}
|
|
30962
30962
|
}
|
|
30963
30963
|
};
|
|
@@ -31053,7 +31053,7 @@ Message: ${transactionMessage}.
|
|
|
31053
31053
|
*/
|
|
31054
31054
|
static transfer(params) {
|
|
31055
31055
|
let data4;
|
|
31056
|
-
let
|
|
31056
|
+
let keys2;
|
|
31057
31057
|
if ("basePubkey" in params) {
|
|
31058
31058
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;
|
|
31059
31059
|
data4 = encodeData(type, {
|
|
@@ -31061,7 +31061,7 @@ Message: ${transactionMessage}.
|
|
|
31061
31061
|
seed: params.seed,
|
|
31062
31062
|
programId: toBuffer(params.programId.toBuffer())
|
|
31063
31063
|
});
|
|
31064
|
-
|
|
31064
|
+
keys2 = [{
|
|
31065
31065
|
pubkey: params.fromPubkey,
|
|
31066
31066
|
isSigner: false,
|
|
31067
31067
|
isWritable: true
|
|
@@ -31079,7 +31079,7 @@ Message: ${transactionMessage}.
|
|
|
31079
31079
|
data4 = encodeData(type, {
|
|
31080
31080
|
lamports: BigInt(params.lamports)
|
|
31081
31081
|
});
|
|
31082
|
-
|
|
31082
|
+
keys2 = [{
|
|
31083
31083
|
pubkey: params.fromPubkey,
|
|
31084
31084
|
isSigner: true,
|
|
31085
31085
|
isWritable: true
|
|
@@ -31090,7 +31090,7 @@ Message: ${transactionMessage}.
|
|
|
31090
31090
|
}];
|
|
31091
31091
|
}
|
|
31092
31092
|
return new TransactionInstruction({
|
|
31093
|
-
keys,
|
|
31093
|
+
keys: keys2,
|
|
31094
31094
|
programId: this.programId,
|
|
31095
31095
|
data: data4
|
|
31096
31096
|
});
|
|
@@ -31100,7 +31100,7 @@ Message: ${transactionMessage}.
|
|
|
31100
31100
|
*/
|
|
31101
31101
|
static assign(params) {
|
|
31102
31102
|
let data4;
|
|
31103
|
-
let
|
|
31103
|
+
let keys2;
|
|
31104
31104
|
if ("basePubkey" in params) {
|
|
31105
31105
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.AssignWithSeed;
|
|
31106
31106
|
data4 = encodeData(type, {
|
|
@@ -31108,7 +31108,7 @@ Message: ${transactionMessage}.
|
|
|
31108
31108
|
seed: params.seed,
|
|
31109
31109
|
programId: toBuffer(params.programId.toBuffer())
|
|
31110
31110
|
});
|
|
31111
|
-
|
|
31111
|
+
keys2 = [{
|
|
31112
31112
|
pubkey: params.accountPubkey,
|
|
31113
31113
|
isSigner: false,
|
|
31114
31114
|
isWritable: true
|
|
@@ -31122,14 +31122,14 @@ Message: ${transactionMessage}.
|
|
|
31122
31122
|
data4 = encodeData(type, {
|
|
31123
31123
|
programId: toBuffer(params.programId.toBuffer())
|
|
31124
31124
|
});
|
|
31125
|
-
|
|
31125
|
+
keys2 = [{
|
|
31126
31126
|
pubkey: params.accountPubkey,
|
|
31127
31127
|
isSigner: true,
|
|
31128
31128
|
isWritable: true
|
|
31129
31129
|
}];
|
|
31130
31130
|
}
|
|
31131
31131
|
return new TransactionInstruction({
|
|
31132
|
-
keys,
|
|
31132
|
+
keys: keys2,
|
|
31133
31133
|
programId: this.programId,
|
|
31134
31134
|
data: data4
|
|
31135
31135
|
});
|
|
@@ -31147,7 +31147,7 @@ Message: ${transactionMessage}.
|
|
|
31147
31147
|
space: params.space,
|
|
31148
31148
|
programId: toBuffer(params.programId.toBuffer())
|
|
31149
31149
|
});
|
|
31150
|
-
let
|
|
31150
|
+
let keys2 = [{
|
|
31151
31151
|
pubkey: params.fromPubkey,
|
|
31152
31152
|
isSigner: true,
|
|
31153
31153
|
isWritable: true
|
|
@@ -31157,14 +31157,14 @@ Message: ${transactionMessage}.
|
|
|
31157
31157
|
isWritable: true
|
|
31158
31158
|
}];
|
|
31159
31159
|
if (!params.basePubkey.equals(params.fromPubkey)) {
|
|
31160
|
-
|
|
31160
|
+
keys2.push({
|
|
31161
31161
|
pubkey: params.basePubkey,
|
|
31162
31162
|
isSigner: true,
|
|
31163
31163
|
isWritable: false
|
|
31164
31164
|
});
|
|
31165
31165
|
}
|
|
31166
31166
|
return new TransactionInstruction({
|
|
31167
|
-
keys,
|
|
31167
|
+
keys: keys2,
|
|
31168
31168
|
programId: this.programId,
|
|
31169
31169
|
data: data4
|
|
31170
31170
|
});
|
|
@@ -31314,7 +31314,7 @@ Message: ${transactionMessage}.
|
|
|
31314
31314
|
*/
|
|
31315
31315
|
static allocate(params) {
|
|
31316
31316
|
let data4;
|
|
31317
|
-
let
|
|
31317
|
+
let keys2;
|
|
31318
31318
|
if ("basePubkey" in params) {
|
|
31319
31319
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed;
|
|
31320
31320
|
data4 = encodeData(type, {
|
|
@@ -31323,7 +31323,7 @@ Message: ${transactionMessage}.
|
|
|
31323
31323
|
space: params.space,
|
|
31324
31324
|
programId: toBuffer(params.programId.toBuffer())
|
|
31325
31325
|
});
|
|
31326
|
-
|
|
31326
|
+
keys2 = [{
|
|
31327
31327
|
pubkey: params.accountPubkey,
|
|
31328
31328
|
isSigner: false,
|
|
31329
31329
|
isWritable: true
|
|
@@ -31337,14 +31337,14 @@ Message: ${transactionMessage}.
|
|
|
31337
31337
|
data4 = encodeData(type, {
|
|
31338
31338
|
space: params.space
|
|
31339
31339
|
});
|
|
31340
|
-
|
|
31340
|
+
keys2 = [{
|
|
31341
31341
|
pubkey: params.accountPubkey,
|
|
31342
31342
|
isSigner: true,
|
|
31343
31343
|
isWritable: true
|
|
31344
31344
|
}];
|
|
31345
31345
|
}
|
|
31346
31346
|
return new TransactionInstruction({
|
|
31347
|
-
keys,
|
|
31347
|
+
keys: keys2,
|
|
31348
31348
|
programId: this.programId,
|
|
31349
31349
|
data: data4
|
|
31350
31350
|
});
|
|
@@ -32091,14 +32091,14 @@ Message: ${transactionMessage}.
|
|
|
32091
32091
|
hasRequiredFastStableStringify = 1;
|
|
32092
32092
|
var objToString = Object.prototype.toString;
|
|
32093
32093
|
var objKeys = Object.keys || function(obj) {
|
|
32094
|
-
var
|
|
32094
|
+
var keys2 = [];
|
|
32095
32095
|
for (var name in obj) {
|
|
32096
|
-
|
|
32096
|
+
keys2.push(name);
|
|
32097
32097
|
}
|
|
32098
|
-
return
|
|
32098
|
+
return keys2;
|
|
32099
32099
|
};
|
|
32100
32100
|
function stringify5(val, isArrayProp) {
|
|
32101
|
-
var i, max, str,
|
|
32101
|
+
var i, max, str, keys2, key, propVal, toStr2;
|
|
32102
32102
|
if (val === true) {
|
|
32103
32103
|
return "true";
|
|
32104
32104
|
}
|
|
@@ -32124,12 +32124,12 @@ Message: ${transactionMessage}.
|
|
|
32124
32124
|
}
|
|
32125
32125
|
return str + "]";
|
|
32126
32126
|
} else if (toStr2 === "[object Object]") {
|
|
32127
|
-
|
|
32128
|
-
max =
|
|
32127
|
+
keys2 = objKeys(val).sort();
|
|
32128
|
+
max = keys2.length;
|
|
32129
32129
|
str = "";
|
|
32130
32130
|
i = 0;
|
|
32131
32131
|
while (i < max) {
|
|
32132
|
-
key =
|
|
32132
|
+
key = keys2[i];
|
|
32133
32133
|
propVal = stringify5(val[key], false);
|
|
32134
32134
|
if (propVal !== void 0) {
|
|
32135
32135
|
if (str) {
|
|
@@ -33454,12 +33454,12 @@ Message: ${transactionMessage}.
|
|
|
33454
33454
|
commitment,
|
|
33455
33455
|
config
|
|
33456
33456
|
} = extractCommitmentFromConfig(rawConfig);
|
|
33457
|
-
const
|
|
33458
|
-
const args = this._buildArgs([
|
|
33457
|
+
const keys2 = publicKeys.map((key) => key.toBase58());
|
|
33458
|
+
const args = this._buildArgs([keys2], commitment, "jsonParsed", config);
|
|
33459
33459
|
const unsafeRes = await this._rpcRequest("getMultipleAccounts", args);
|
|
33460
33460
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(ParsedAccountInfoResult))));
|
|
33461
33461
|
if ("error" in res) {
|
|
33462
|
-
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${
|
|
33462
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys2}`);
|
|
33463
33463
|
}
|
|
33464
33464
|
return res.result;
|
|
33465
33465
|
}
|
|
@@ -33471,12 +33471,12 @@ Message: ${transactionMessage}.
|
|
|
33471
33471
|
commitment,
|
|
33472
33472
|
config
|
|
33473
33473
|
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
33474
|
-
const
|
|
33475
|
-
const args = this._buildArgs([
|
|
33474
|
+
const keys2 = publicKeys.map((key) => key.toBase58());
|
|
33475
|
+
const args = this._buildArgs([keys2], commitment, "base64", config);
|
|
33476
33476
|
const unsafeRes = await this._rpcRequest("getMultipleAccounts", args);
|
|
33477
33477
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
33478
33478
|
if ("error" in res) {
|
|
33479
|
-
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${
|
|
33479
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys2}`);
|
|
33480
33480
|
}
|
|
33481
33481
|
return res.result;
|
|
33482
33482
|
}
|
|
@@ -35998,9 +35998,9 @@ Message: ${transactionMessage}.
|
|
|
35998
35998
|
/**
|
|
35999
35999
|
* @internal
|
|
36000
36000
|
*/
|
|
36001
|
-
static checkKeysLength(
|
|
36002
|
-
if (
|
|
36003
|
-
throw new Error(`invalid instruction; found ${
|
|
36001
|
+
static checkKeysLength(keys2, expectedLength) {
|
|
36002
|
+
if (keys2.length < expectedLength) {
|
|
36003
|
+
throw new Error(`invalid instruction; found ${keys2.length} keys, expected at least ${expectedLength}`);
|
|
36004
36004
|
}
|
|
36005
36005
|
}
|
|
36006
36006
|
};
|
|
@@ -36017,7 +36017,7 @@ Message: ${transactionMessage}.
|
|
|
36017
36017
|
recentSlot: BigInt(params.recentSlot),
|
|
36018
36018
|
bumpSeed
|
|
36019
36019
|
});
|
|
36020
|
-
const
|
|
36020
|
+
const keys2 = [{
|
|
36021
36021
|
pubkey: lookupTableAddress,
|
|
36022
36022
|
isSigner: false,
|
|
36023
36023
|
isWritable: true
|
|
@@ -36036,14 +36036,14 @@ Message: ${transactionMessage}.
|
|
|
36036
36036
|
}];
|
|
36037
36037
|
return [new TransactionInstruction({
|
|
36038
36038
|
programId: this.programId,
|
|
36039
|
-
keys,
|
|
36039
|
+
keys: keys2,
|
|
36040
36040
|
data: data4
|
|
36041
36041
|
}), lookupTableAddress];
|
|
36042
36042
|
}
|
|
36043
36043
|
static freezeLookupTable(params) {
|
|
36044
36044
|
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;
|
|
36045
36045
|
const data4 = encodeData(type);
|
|
36046
|
-
const
|
|
36046
|
+
const keys2 = [{
|
|
36047
36047
|
pubkey: params.lookupTable,
|
|
36048
36048
|
isSigner: false,
|
|
36049
36049
|
isWritable: true
|
|
@@ -36054,7 +36054,7 @@ Message: ${transactionMessage}.
|
|
|
36054
36054
|
}];
|
|
36055
36055
|
return new TransactionInstruction({
|
|
36056
36056
|
programId: this.programId,
|
|
36057
|
-
keys,
|
|
36057
|
+
keys: keys2,
|
|
36058
36058
|
data: data4
|
|
36059
36059
|
});
|
|
36060
36060
|
}
|
|
@@ -36063,7 +36063,7 @@ Message: ${transactionMessage}.
|
|
|
36063
36063
|
const data4 = encodeData(type, {
|
|
36064
36064
|
addresses: params.addresses.map((addr) => addr.toBytes())
|
|
36065
36065
|
});
|
|
36066
|
-
const
|
|
36066
|
+
const keys2 = [{
|
|
36067
36067
|
pubkey: params.lookupTable,
|
|
36068
36068
|
isSigner: false,
|
|
36069
36069
|
isWritable: true
|
|
@@ -36073,7 +36073,7 @@ Message: ${transactionMessage}.
|
|
|
36073
36073
|
isWritable: false
|
|
36074
36074
|
}];
|
|
36075
36075
|
if (params.payer) {
|
|
36076
|
-
|
|
36076
|
+
keys2.push({
|
|
36077
36077
|
pubkey: params.payer,
|
|
36078
36078
|
isSigner: true,
|
|
36079
36079
|
isWritable: true
|
|
@@ -36085,14 +36085,14 @@ Message: ${transactionMessage}.
|
|
|
36085
36085
|
}
|
|
36086
36086
|
return new TransactionInstruction({
|
|
36087
36087
|
programId: this.programId,
|
|
36088
|
-
keys,
|
|
36088
|
+
keys: keys2,
|
|
36089
36089
|
data: data4
|
|
36090
36090
|
});
|
|
36091
36091
|
}
|
|
36092
36092
|
static deactivateLookupTable(params) {
|
|
36093
36093
|
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;
|
|
36094
36094
|
const data4 = encodeData(type);
|
|
36095
|
-
const
|
|
36095
|
+
const keys2 = [{
|
|
36096
36096
|
pubkey: params.lookupTable,
|
|
36097
36097
|
isSigner: false,
|
|
36098
36098
|
isWritable: true
|
|
@@ -36103,14 +36103,14 @@ Message: ${transactionMessage}.
|
|
|
36103
36103
|
}];
|
|
36104
36104
|
return new TransactionInstruction({
|
|
36105
36105
|
programId: this.programId,
|
|
36106
|
-
keys,
|
|
36106
|
+
keys: keys2,
|
|
36107
36107
|
data: data4
|
|
36108
36108
|
});
|
|
36109
36109
|
}
|
|
36110
36110
|
static closeLookupTable(params) {
|
|
36111
36111
|
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;
|
|
36112
36112
|
const data4 = encodeData(type);
|
|
36113
|
-
const
|
|
36113
|
+
const keys2 = [{
|
|
36114
36114
|
pubkey: params.lookupTable,
|
|
36115
36115
|
isSigner: false,
|
|
36116
36116
|
isWritable: true
|
|
@@ -36125,7 +36125,7 @@ Message: ${transactionMessage}.
|
|
|
36125
36125
|
}];
|
|
36126
36126
|
return new TransactionInstruction({
|
|
36127
36127
|
programId: this.programId,
|
|
36128
|
-
keys,
|
|
36128
|
+
keys: keys2,
|
|
36129
36129
|
data: data4
|
|
36130
36130
|
});
|
|
36131
36131
|
}
|
|
@@ -36708,9 +36708,9 @@ Message: ${transactionMessage}.
|
|
|
36708
36708
|
/**
|
|
36709
36709
|
* @internal
|
|
36710
36710
|
*/
|
|
36711
|
-
static checkKeyLength(
|
|
36712
|
-
if (
|
|
36713
|
-
throw new Error(`invalid instruction; found ${
|
|
36711
|
+
static checkKeyLength(keys2, expectedLength) {
|
|
36712
|
+
if (keys2.length < expectedLength) {
|
|
36713
|
+
throw new Error(`invalid instruction; found ${keys2.length} keys, expected at least ${expectedLength}`);
|
|
36714
36714
|
}
|
|
36715
36715
|
}
|
|
36716
36716
|
};
|
|
@@ -36911,7 +36911,7 @@ Message: ${transactionMessage}.
|
|
|
36911
36911
|
newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
|
|
36912
36912
|
stakeAuthorizationType: stakeAuthorizationType.index
|
|
36913
36913
|
});
|
|
36914
|
-
const
|
|
36914
|
+
const keys2 = [{
|
|
36915
36915
|
pubkey: stakePubkey,
|
|
36916
36916
|
isSigner: false,
|
|
36917
36917
|
isWritable: true
|
|
@@ -36925,14 +36925,14 @@ Message: ${transactionMessage}.
|
|
|
36925
36925
|
isWritable: false
|
|
36926
36926
|
}];
|
|
36927
36927
|
if (custodianPubkey) {
|
|
36928
|
-
|
|
36928
|
+
keys2.push({
|
|
36929
36929
|
pubkey: custodianPubkey,
|
|
36930
36930
|
isSigner: true,
|
|
36931
36931
|
isWritable: false
|
|
36932
36932
|
});
|
|
36933
36933
|
}
|
|
36934
36934
|
return new Transaction4().add({
|
|
36935
|
-
keys,
|
|
36935
|
+
keys: keys2,
|
|
36936
36936
|
programId: this.programId,
|
|
36937
36937
|
data: data4
|
|
36938
36938
|
});
|
|
@@ -36958,7 +36958,7 @@ Message: ${transactionMessage}.
|
|
|
36958
36958
|
authoritySeed,
|
|
36959
36959
|
authorityOwner: toBuffer(authorityOwner.toBuffer())
|
|
36960
36960
|
});
|
|
36961
|
-
const
|
|
36961
|
+
const keys2 = [{
|
|
36962
36962
|
pubkey: stakePubkey,
|
|
36963
36963
|
isSigner: false,
|
|
36964
36964
|
isWritable: true
|
|
@@ -36972,14 +36972,14 @@ Message: ${transactionMessage}.
|
|
|
36972
36972
|
isWritable: false
|
|
36973
36973
|
}];
|
|
36974
36974
|
if (custodianPubkey) {
|
|
36975
|
-
|
|
36975
|
+
keys2.push({
|
|
36976
36976
|
pubkey: custodianPubkey,
|
|
36977
36977
|
isSigner: true,
|
|
36978
36978
|
isWritable: false
|
|
36979
36979
|
});
|
|
36980
36980
|
}
|
|
36981
36981
|
return new Transaction4().add({
|
|
36982
|
-
keys,
|
|
36982
|
+
keys: keys2,
|
|
36983
36983
|
programId: this.programId,
|
|
36984
36984
|
data: data4
|
|
36985
36985
|
});
|
|
@@ -37117,7 +37117,7 @@ Message: ${transactionMessage}.
|
|
|
37117
37117
|
const data4 = encodeData(type, {
|
|
37118
37118
|
lamports
|
|
37119
37119
|
});
|
|
37120
|
-
const
|
|
37120
|
+
const keys2 = [{
|
|
37121
37121
|
pubkey: stakePubkey,
|
|
37122
37122
|
isSigner: false,
|
|
37123
37123
|
isWritable: true
|
|
@@ -37139,14 +37139,14 @@ Message: ${transactionMessage}.
|
|
|
37139
37139
|
isWritable: false
|
|
37140
37140
|
}];
|
|
37141
37141
|
if (custodianPubkey) {
|
|
37142
|
-
|
|
37142
|
+
keys2.push({
|
|
37143
37143
|
pubkey: custodianPubkey,
|
|
37144
37144
|
isSigner: true,
|
|
37145
37145
|
isWritable: false
|
|
37146
37146
|
});
|
|
37147
37147
|
}
|
|
37148
37148
|
return new Transaction4().add({
|
|
37149
|
-
keys,
|
|
37149
|
+
keys: keys2,
|
|
37150
37150
|
programId: this.programId,
|
|
37151
37151
|
data: data4
|
|
37152
37152
|
});
|
|
@@ -37306,9 +37306,9 @@ Message: ${transactionMessage}.
|
|
|
37306
37306
|
/**
|
|
37307
37307
|
* @internal
|
|
37308
37308
|
*/
|
|
37309
|
-
static checkKeyLength(
|
|
37310
|
-
if (
|
|
37311
|
-
throw new Error(`invalid instruction; found ${
|
|
37309
|
+
static checkKeyLength(keys2, expectedLength) {
|
|
37310
|
+
if (keys2.length < expectedLength) {
|
|
37311
|
+
throw new Error(`invalid instruction; found ${keys2.length} keys, expected at least ${expectedLength}`);
|
|
37312
37312
|
}
|
|
37313
37313
|
}
|
|
37314
37314
|
};
|
|
@@ -37425,7 +37425,7 @@ Message: ${transactionMessage}.
|
|
|
37425
37425
|
newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
|
|
37426
37426
|
voteAuthorizationType: voteAuthorizationType.index
|
|
37427
37427
|
});
|
|
37428
|
-
const
|
|
37428
|
+
const keys2 = [{
|
|
37429
37429
|
pubkey: votePubkey,
|
|
37430
37430
|
isSigner: false,
|
|
37431
37431
|
isWritable: true
|
|
@@ -37439,7 +37439,7 @@ Message: ${transactionMessage}.
|
|
|
37439
37439
|
isWritable: false
|
|
37440
37440
|
}];
|
|
37441
37441
|
return new Transaction4().add({
|
|
37442
|
-
keys,
|
|
37442
|
+
keys: keys2,
|
|
37443
37443
|
programId: this.programId,
|
|
37444
37444
|
data: data4
|
|
37445
37445
|
});
|
|
@@ -37466,7 +37466,7 @@ Message: ${transactionMessage}.
|
|
|
37466
37466
|
voteAuthorizationType: voteAuthorizationType.index
|
|
37467
37467
|
}
|
|
37468
37468
|
});
|
|
37469
|
-
const
|
|
37469
|
+
const keys2 = [{
|
|
37470
37470
|
pubkey: votePubkey,
|
|
37471
37471
|
isSigner: false,
|
|
37472
37472
|
isWritable: true
|
|
@@ -37480,7 +37480,7 @@ Message: ${transactionMessage}.
|
|
|
37480
37480
|
isWritable: false
|
|
37481
37481
|
}];
|
|
37482
37482
|
return new Transaction4().add({
|
|
37483
|
-
keys,
|
|
37483
|
+
keys: keys2,
|
|
37484
37484
|
programId: this.programId,
|
|
37485
37485
|
data: data4
|
|
37486
37486
|
});
|
|
@@ -37499,7 +37499,7 @@ Message: ${transactionMessage}.
|
|
|
37499
37499
|
const data4 = encodeData(type, {
|
|
37500
37500
|
lamports
|
|
37501
37501
|
});
|
|
37502
|
-
const
|
|
37502
|
+
const keys2 = [{
|
|
37503
37503
|
pubkey: votePubkey,
|
|
37504
37504
|
isSigner: false,
|
|
37505
37505
|
isWritable: true
|
|
@@ -37513,7 +37513,7 @@ Message: ${transactionMessage}.
|
|
|
37513
37513
|
isWritable: false
|
|
37514
37514
|
}];
|
|
37515
37515
|
return new Transaction4().add({
|
|
37516
|
-
keys,
|
|
37516
|
+
keys: keys2,
|
|
37517
37517
|
programId: this.programId,
|
|
37518
37518
|
data: data4
|
|
37519
37519
|
});
|
|
@@ -37543,7 +37543,7 @@ Message: ${transactionMessage}.
|
|
|
37543
37543
|
} = params;
|
|
37544
37544
|
const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
|
|
37545
37545
|
const data4 = encodeData(type);
|
|
37546
|
-
const
|
|
37546
|
+
const keys2 = [{
|
|
37547
37547
|
pubkey: votePubkey,
|
|
37548
37548
|
isSigner: false,
|
|
37549
37549
|
isWritable: true
|
|
@@ -37557,7 +37557,7 @@ Message: ${transactionMessage}.
|
|
|
37557
37557
|
isWritable: false
|
|
37558
37558
|
}];
|
|
37559
37559
|
return new Transaction4().add({
|
|
37560
|
-
keys,
|
|
37560
|
+
keys: keys2,
|
|
37561
37561
|
programId: this.programId,
|
|
37562
37562
|
data: data4
|
|
37563
37563
|
});
|
|
@@ -37870,7 +37870,7 @@ var {
|
|
|
37870
37870
|
} = import_index.default;
|
|
37871
37871
|
|
|
37872
37872
|
// src/main.ts
|
|
37873
|
-
var
|
|
37873
|
+
var import_picocolors32 = __toESM(require_picocolors(), 1);
|
|
37874
37874
|
|
|
37875
37875
|
// src/commands/login.ts
|
|
37876
37876
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
@@ -39556,10 +39556,10 @@ function checkType(value, type, name) {
|
|
|
39556
39556
|
throw error;
|
|
39557
39557
|
}
|
|
39558
39558
|
async function resolveProperties(value) {
|
|
39559
|
-
const
|
|
39560
|
-
const results = await Promise.all(
|
|
39559
|
+
const keys2 = Object.keys(value);
|
|
39560
|
+
const results = await Promise.all(keys2.map((k) => Promise.resolve(value[k])));
|
|
39561
39561
|
return results.reduce((accum, v, index) => {
|
|
39562
|
-
accum[
|
|
39562
|
+
accum[keys2[index]] = v;
|
|
39563
39563
|
return accum;
|
|
39564
39564
|
}, {});
|
|
39565
39565
|
}
|
|
@@ -39613,9 +39613,9 @@ function stringify(value, seen) {
|
|
|
39613
39613
|
case "string":
|
|
39614
39614
|
return JSON.stringify(value);
|
|
39615
39615
|
case "object": {
|
|
39616
|
-
const
|
|
39617
|
-
|
|
39618
|
-
return "{ " +
|
|
39616
|
+
const keys2 = Object.keys(value);
|
|
39617
|
+
keys2.sort();
|
|
39618
|
+
return "{ " + keys2.map((k) => `${stringify(k, seen)}: ${stringify(value[k], seen)}`).join(", ") + " }";
|
|
39619
39619
|
}
|
|
39620
39620
|
}
|
|
39621
39621
|
return `[ COULD NOT SERIALIZE ]`;
|
|
@@ -40559,12 +40559,12 @@ var FetchRequest = class _FetchRequest {
|
|
|
40559
40559
|
}
|
|
40560
40560
|
[Symbol.iterator]() {
|
|
40561
40561
|
const headers = this.headers;
|
|
40562
|
-
const
|
|
40562
|
+
const keys2 = Object.keys(headers);
|
|
40563
40563
|
let index = 0;
|
|
40564
40564
|
return {
|
|
40565
40565
|
next: () => {
|
|
40566
|
-
if (index <
|
|
40567
|
-
const key =
|
|
40566
|
+
if (index < keys2.length) {
|
|
40567
|
+
const key = keys2[index++];
|
|
40568
40568
|
return {
|
|
40569
40569
|
value: [key, headers[key]],
|
|
40570
40570
|
done: false
|
|
@@ -41002,12 +41002,12 @@ var FetchResponse = class _FetchResponse {
|
|
|
41002
41002
|
}
|
|
41003
41003
|
[Symbol.iterator]() {
|
|
41004
41004
|
const headers = this.headers;
|
|
41005
|
-
const
|
|
41005
|
+
const keys2 = Object.keys(headers);
|
|
41006
41006
|
let index = 0;
|
|
41007
41007
|
return {
|
|
41008
41008
|
next: () => {
|
|
41009
|
-
if (index <
|
|
41010
|
-
const key =
|
|
41009
|
+
if (index < keys2.length) {
|
|
41010
|
+
const key = keys2[index++];
|
|
41011
41011
|
return {
|
|
41012
41012
|
value: [key, headers[key]],
|
|
41013
41013
|
done: false
|
|
@@ -42027,8 +42027,8 @@ var Result = class _Result extends Array {
|
|
|
42027
42027
|
* Creates a new [[Result]] for %%items%% with each entry
|
|
42028
42028
|
* also accessible by its corresponding name in %%keys%%.
|
|
42029
42029
|
*/
|
|
42030
|
-
static fromItems(items,
|
|
42031
|
-
return new _Result(_guard2, items,
|
|
42030
|
+
static fromItems(items, keys2) {
|
|
42031
|
+
return new _Result(_guard2, items, keys2);
|
|
42032
42032
|
}
|
|
42033
42033
|
};
|
|
42034
42034
|
function checkResultErrors(result) {
|
|
@@ -46385,7 +46385,7 @@ function pack(writer, coders, values) {
|
|
|
46385
46385
|
}
|
|
46386
46386
|
function unpack(reader, coders) {
|
|
46387
46387
|
let values = [];
|
|
46388
|
-
let
|
|
46388
|
+
let keys2 = [];
|
|
46389
46389
|
let baseReader = reader.subReader(0);
|
|
46390
46390
|
coders.forEach((coder) => {
|
|
46391
46391
|
let value = null;
|
|
@@ -46420,9 +46420,9 @@ function unpack(reader, coders) {
|
|
|
46420
46420
|
throw new Error("investigate");
|
|
46421
46421
|
}
|
|
46422
46422
|
values.push(value);
|
|
46423
|
-
|
|
46423
|
+
keys2.push(coder.localName || null);
|
|
46424
46424
|
});
|
|
46425
|
-
return Result.fromItems(values,
|
|
46425
|
+
return Result.fromItems(values, keys2);
|
|
46426
46426
|
}
|
|
46427
46427
|
var ArrayCoder = class extends Coder {
|
|
46428
46428
|
coder;
|
|
@@ -51716,7 +51716,7 @@ var Interface = class _Interface {
|
|
|
51716
51716
|
const resultIndexed = topics != null ? this.#abiCoder.decode(indexed, concat(topics)) : null;
|
|
51717
51717
|
const resultNonIndexed = this.#abiCoder.decode(nonIndexed, data4, true);
|
|
51718
51718
|
const values = [];
|
|
51719
|
-
const
|
|
51719
|
+
const keys2 = [];
|
|
51720
51720
|
let nonIndexedIndex = 0, indexedIndex = 0;
|
|
51721
51721
|
fragment.inputs.forEach((param, index) => {
|
|
51722
51722
|
let value = null;
|
|
@@ -51740,9 +51740,9 @@ var Interface = class _Interface {
|
|
|
51740
51740
|
}
|
|
51741
51741
|
}
|
|
51742
51742
|
values.push(value);
|
|
51743
|
-
|
|
51743
|
+
keys2.push(param.name || null);
|
|
51744
51744
|
});
|
|
51745
|
-
return Result.fromItems(values,
|
|
51745
|
+
return Result.fromItems(values, keys2);
|
|
51746
51746
|
}
|
|
51747
51747
|
/**
|
|
51748
51748
|
* Parses a transaction, finding the matching function and extracts
|
|
@@ -55639,9 +55639,9 @@ function getTag(prefix, value) {
|
|
|
55639
55639
|
return v.toLowerCase();
|
|
55640
55640
|
}
|
|
55641
55641
|
if (typeof v === "object" && !Array.isArray(v)) {
|
|
55642
|
-
const
|
|
55643
|
-
|
|
55644
|
-
return
|
|
55642
|
+
const keys2 = Object.keys(v);
|
|
55643
|
+
keys2.sort();
|
|
55644
|
+
return keys2.reduce((accum, key) => {
|
|
55645
55645
|
accum[key] = v[key];
|
|
55646
55646
|
return accum;
|
|
55647
55647
|
}, {});
|
|
@@ -59627,9 +59627,9 @@ function _normalize(value) {
|
|
|
59627
59627
|
case "string":
|
|
59628
59628
|
return JSON.stringify(value);
|
|
59629
59629
|
case "object": {
|
|
59630
|
-
const
|
|
59631
|
-
|
|
59632
|
-
return "{" +
|
|
59630
|
+
const keys2 = Object.keys(value);
|
|
59631
|
+
keys2.sort();
|
|
59632
|
+
return "{" + keys2.map((k) => `${JSON.stringify(k)}:${_normalize(value[k])}`).join(",") + "}";
|
|
59633
59633
|
}
|
|
59634
59634
|
}
|
|
59635
59635
|
console.log("Could not serialize", value);
|
|
@@ -62859,6 +62859,162 @@ var wordlists2 = {
|
|
|
62859
62859
|
zh_tw: LangZh.wordlist("tw")
|
|
62860
62860
|
};
|
|
62861
62861
|
|
|
62862
|
+
// src/lib/passwords-wire.ts
|
|
62863
|
+
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
62864
|
+
var trim2 = (v) => v ? v.replace(/\/$/, "") : "";
|
|
62865
|
+
function identityOrigin() {
|
|
62866
|
+
return trim2(process.env.AGENTGATES_IDENTITY_ORIGIN) || trim2(process.env.AGENTGATES_ORIGIN) || "https://agentgates.ai";
|
|
62867
|
+
}
|
|
62868
|
+
function siteOrigin() {
|
|
62869
|
+
return trim2(process.env.AGENTGATES_ORIGIN) || "https://agentgates.ai";
|
|
62870
|
+
}
|
|
62871
|
+
var LANE = "/api/identity";
|
|
62872
|
+
var WireError = class extends Error {
|
|
62873
|
+
constructor(status3, code, message, body) {
|
|
62874
|
+
super(message);
|
|
62875
|
+
this.status = status3;
|
|
62876
|
+
this.code = code;
|
|
62877
|
+
this.body = body;
|
|
62878
|
+
this.name = "WireError";
|
|
62879
|
+
}
|
|
62880
|
+
status;
|
|
62881
|
+
code;
|
|
62882
|
+
body;
|
|
62883
|
+
};
|
|
62884
|
+
async function ownerAuthHeader(wallet, method, path7) {
|
|
62885
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
62886
|
+
const nonce = randomBytes4(16).toString("hex");
|
|
62887
|
+
const signature = await wallet.signMessage(`${method.toUpperCase()}
|
|
62888
|
+
${path7}
|
|
62889
|
+
${nonce}
|
|
62890
|
+
${timestamp}`);
|
|
62891
|
+
return Buffer.from(JSON.stringify({ address: wallet.address, timestamp, nonce, signature })).toString("base64");
|
|
62892
|
+
}
|
|
62893
|
+
var loginKey = null;
|
|
62894
|
+
var revokedHook = null;
|
|
62895
|
+
var lastVia = null;
|
|
62896
|
+
var revokedNoticed = false;
|
|
62897
|
+
function setLoginKey(key) {
|
|
62898
|
+
loginKey = key;
|
|
62899
|
+
}
|
|
62900
|
+
function onLoginKeyRevoked(hook) {
|
|
62901
|
+
revokedHook = hook;
|
|
62902
|
+
}
|
|
62903
|
+
function lastAuthVia() {
|
|
62904
|
+
return lastVia;
|
|
62905
|
+
}
|
|
62906
|
+
function loginKeyWasRevoked() {
|
|
62907
|
+
return revokedNoticed;
|
|
62908
|
+
}
|
|
62909
|
+
var KEYS_DOOR = /\/keys(\/|$)/;
|
|
62910
|
+
async function signedFetch(wallet, method, path7, body, timeoutMs = 13e4) {
|
|
62911
|
+
const once = async (viaKey) => {
|
|
62912
|
+
const headers = {
|
|
62913
|
+
accept: "application/json",
|
|
62914
|
+
"user-agent": CLI_USER_AGENT,
|
|
62915
|
+
...viaKey && loginKey ? { authorization: `Bearer ${loginKey}` } : { "x-wallet-auth": await ownerAuthHeader(wallet, method, path7) }
|
|
62916
|
+
};
|
|
62917
|
+
if (body !== void 0) headers["content-type"] = "application/json";
|
|
62918
|
+
let res;
|
|
62919
|
+
try {
|
|
62920
|
+
res = await fetch(`${identityOrigin()}${path7}`, {
|
|
62921
|
+
method,
|
|
62922
|
+
headers,
|
|
62923
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
62924
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
62925
|
+
});
|
|
62926
|
+
} catch (err) {
|
|
62927
|
+
throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
|
|
62928
|
+
}
|
|
62929
|
+
const text = await res.text();
|
|
62930
|
+
let json2 = null;
|
|
62931
|
+
try {
|
|
62932
|
+
json2 = text ? JSON.parse(text) : null;
|
|
62933
|
+
} catch {
|
|
62934
|
+
json2 = null;
|
|
62935
|
+
}
|
|
62936
|
+
lastVia = viaKey && loginKey ? "key" : "signature";
|
|
62937
|
+
return { status: res.status, body: json2, text };
|
|
62938
|
+
};
|
|
62939
|
+
const useKey = !!loginKey && !KEYS_DOOR.test(path7);
|
|
62940
|
+
const answer = await once(useKey);
|
|
62941
|
+
if (useKey && answer.status === 401) {
|
|
62942
|
+
const signed2 = await once(false);
|
|
62943
|
+
if (signed2.status < 400) {
|
|
62944
|
+
loginKey = null;
|
|
62945
|
+
revokedNoticed = true;
|
|
62946
|
+
if (revokedHook) await revokedHook().catch(() => void 0);
|
|
62947
|
+
process.stderr.write("\n ! your login key was revoked: this call was signed with the words and the key was dropped. agentgates keys create --keep \xB7 mints a new one\n\n");
|
|
62948
|
+
}
|
|
62949
|
+
return signed2;
|
|
62950
|
+
}
|
|
62951
|
+
return answer;
|
|
62952
|
+
}
|
|
62953
|
+
async function listLoginKeys(wallet) {
|
|
62954
|
+
const answer = await signedFetch(wallet, "GET", `${LANE}/keys`);
|
|
62955
|
+
return expectOk(answer, "login keys").keys ?? [];
|
|
62956
|
+
}
|
|
62957
|
+
async function createLoginKey(wallet, name) {
|
|
62958
|
+
const answer = await signedFetch(wallet, "POST", `${LANE}/keys`, { name });
|
|
62959
|
+
return expectOk(answer, "login key mint");
|
|
62960
|
+
}
|
|
62961
|
+
async function revokeLoginKey(wallet, id2) {
|
|
62962
|
+
const answer = await signedFetch(wallet, "POST", `${LANE}/keys`, { revoke: id2 });
|
|
62963
|
+
return expectOk(answer, "login key revoke");
|
|
62964
|
+
}
|
|
62965
|
+
function expectOk(answer, what) {
|
|
62966
|
+
if (answer.status >= 200 && answer.status < 300 && answer.body) return answer.body;
|
|
62967
|
+
const b2 = answer.body ?? {};
|
|
62968
|
+
const code = typeof b2.code === "string" ? b2.code : null;
|
|
62969
|
+
const error = typeof b2.error === "string" ? b2.error : `${what}: HTTP ${answer.status}`;
|
|
62970
|
+
throw new WireError(answer.status, code, error, answer.body);
|
|
62971
|
+
}
|
|
62972
|
+
async function readAttestation() {
|
|
62973
|
+
let res;
|
|
62974
|
+
try {
|
|
62975
|
+
res = await fetch(`${identityOrigin()}${LANE}/passwords/attestation`, {
|
|
62976
|
+
headers: { accept: "application/json", "user-agent": CLI_USER_AGENT },
|
|
62977
|
+
signal: AbortSignal.timeout(6e4)
|
|
62978
|
+
});
|
|
62979
|
+
} catch (err) {
|
|
62980
|
+
throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
|
|
62981
|
+
}
|
|
62982
|
+
const body = await res.json().catch(() => null);
|
|
62983
|
+
if (!res.ok || !body?.publicKey || !body?.keyId) {
|
|
62984
|
+
const error = body?.error ?? `the box's key could not be read: HTTP ${res.status}`;
|
|
62985
|
+
throw new WireError(res.status, body?.code ?? null, error, body);
|
|
62986
|
+
}
|
|
62987
|
+
return body;
|
|
62988
|
+
}
|
|
62989
|
+
async function listRows(wallet) {
|
|
62990
|
+
const out = expectOk(await signedFetch(wallet, "GET", `${LANE}/passwords`), "list");
|
|
62991
|
+
return { passwords: out.passwords ?? [], permitted: out.permitted ?? [] };
|
|
62992
|
+
}
|
|
62993
|
+
async function storeRow(wallet, body) {
|
|
62994
|
+
const out = expectOk(await signedFetch(wallet, "POST", `${LANE}/passwords`, body), "store");
|
|
62995
|
+
return out.password;
|
|
62996
|
+
}
|
|
62997
|
+
async function revealRow(wallet, id2) {
|
|
62998
|
+
const out = expectOk(await signedFetch(wallet, "POST", `${LANE}/passwords/${encodeURIComponent(id2)}/reveal`), "reveal");
|
|
62999
|
+
return out.passkeyBlob;
|
|
63000
|
+
}
|
|
63001
|
+
async function postPermit(wallet, signed2) {
|
|
63002
|
+
const out = expectOk(
|
|
63003
|
+
await signedFetch(wallet, "POST", `${LANE}/passwords/permits`, { typedData: signed2.typedData, signature: signed2.signature }),
|
|
63004
|
+
"permit"
|
|
63005
|
+
);
|
|
63006
|
+
return out.permit;
|
|
63007
|
+
}
|
|
63008
|
+
async function postUse(wallet, id2, body, timeoutMs = 2e5) {
|
|
63009
|
+
return signedFetch(wallet, "POST", `${LANE}/passwords/${encodeURIComponent(id2)}/use`, body, timeoutMs);
|
|
63010
|
+
}
|
|
63011
|
+
async function withdrawInvite(wallet, envelope, signature) {
|
|
63012
|
+
return expectOk(
|
|
63013
|
+
await signedFetch(wallet, "POST", `${LANE}/passwords/invites/withdraw`, { invite: { envelope, signature } }),
|
|
63014
|
+
"withdraw"
|
|
63015
|
+
);
|
|
63016
|
+
}
|
|
63017
|
+
|
|
62862
63018
|
// src/lib/passwords-key.ts
|
|
62863
63019
|
var SEED_PATH = "m/44'/60'/0'/0/0";
|
|
62864
63020
|
var SEED_WORDS = 12;
|
|
@@ -62891,8 +63047,26 @@ async function loadPasswordsKey() {
|
|
|
62891
63047
|
if (state.family !== "evm" || typeof state.privateKey !== "string") {
|
|
62892
63048
|
throw new Error(`${passwordsKeyPath()} is not a passwords key file; move it aside and run init again.`);
|
|
62893
63049
|
}
|
|
63050
|
+
setLoginKey(typeof state.apiKey === "string" ? state.apiKey : null);
|
|
63051
|
+
onLoginKeyRevoked(async () => {
|
|
63052
|
+
await forgetLoginKey(state);
|
|
63053
|
+
});
|
|
62894
63054
|
return keysOf(state);
|
|
62895
63055
|
}
|
|
63056
|
+
async function saveLoginKey(state, key) {
|
|
63057
|
+
state.apiKey = key.secret;
|
|
63058
|
+
state.apiKeyPrefix = key.prefix;
|
|
63059
|
+
state.apiKeyName = key.name;
|
|
63060
|
+
await writeKey(state);
|
|
63061
|
+
setLoginKey(key.secret);
|
|
63062
|
+
}
|
|
63063
|
+
async function forgetLoginKey(state) {
|
|
63064
|
+
delete state.apiKey;
|
|
63065
|
+
delete state.apiKeyPrefix;
|
|
63066
|
+
delete state.apiKeyName;
|
|
63067
|
+
await writeKey(state);
|
|
63068
|
+
setLoginKey(null);
|
|
63069
|
+
}
|
|
62896
63070
|
async function writeKey(state) {
|
|
62897
63071
|
const dir = path3.dirname(passwordsKeyPath());
|
|
62898
63072
|
await fs7.mkdir(dir, { recursive: true, mode: 448 });
|
|
@@ -62980,119 +63154,6 @@ async function requirePasswordsKey() {
|
|
|
62980
63154
|
// src/lib/session-bridge.ts
|
|
62981
63155
|
import { createServer } from "node:http";
|
|
62982
63156
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
62983
|
-
|
|
62984
|
-
// src/lib/passwords-wire.ts
|
|
62985
|
-
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
62986
|
-
var trim2 = (v) => v ? v.replace(/\/$/, "") : "";
|
|
62987
|
-
function identityOrigin() {
|
|
62988
|
-
return trim2(process.env.AGENTGATES_IDENTITY_ORIGIN) || trim2(process.env.AGENTGATES_ORIGIN) || "https://agentgates.ai";
|
|
62989
|
-
}
|
|
62990
|
-
function siteOrigin() {
|
|
62991
|
-
return trim2(process.env.AGENTGATES_ORIGIN) || "https://agentgates.ai";
|
|
62992
|
-
}
|
|
62993
|
-
var LANE = "/api/identity";
|
|
62994
|
-
var WireError = class extends Error {
|
|
62995
|
-
constructor(status3, code, message, body) {
|
|
62996
|
-
super(message);
|
|
62997
|
-
this.status = status3;
|
|
62998
|
-
this.code = code;
|
|
62999
|
-
this.body = body;
|
|
63000
|
-
this.name = "WireError";
|
|
63001
|
-
}
|
|
63002
|
-
status;
|
|
63003
|
-
code;
|
|
63004
|
-
body;
|
|
63005
|
-
};
|
|
63006
|
-
async function ownerAuthHeader(wallet, method, path7) {
|
|
63007
|
-
const timestamp = Math.floor(Date.now() / 1e3);
|
|
63008
|
-
const nonce = randomBytes4(16).toString("hex");
|
|
63009
|
-
const signature = await wallet.signMessage(`${method.toUpperCase()}
|
|
63010
|
-
${path7}
|
|
63011
|
-
${nonce}
|
|
63012
|
-
${timestamp}`);
|
|
63013
|
-
return Buffer.from(JSON.stringify({ address: wallet.address, timestamp, nonce, signature })).toString("base64");
|
|
63014
|
-
}
|
|
63015
|
-
async function signedFetch(wallet, method, path7, body, timeoutMs = 13e4) {
|
|
63016
|
-
const headers = {
|
|
63017
|
-
accept: "application/json",
|
|
63018
|
-
"user-agent": CLI_USER_AGENT,
|
|
63019
|
-
"x-wallet-auth": await ownerAuthHeader(wallet, method, path7)
|
|
63020
|
-
};
|
|
63021
|
-
if (body !== void 0) headers["content-type"] = "application/json";
|
|
63022
|
-
let res;
|
|
63023
|
-
try {
|
|
63024
|
-
res = await fetch(`${identityOrigin()}${path7}`, {
|
|
63025
|
-
method,
|
|
63026
|
-
headers,
|
|
63027
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
63028
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
63029
|
-
});
|
|
63030
|
-
} catch (err) {
|
|
63031
|
-
throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
|
|
63032
|
-
}
|
|
63033
|
-
const text = await res.text();
|
|
63034
|
-
let json2 = null;
|
|
63035
|
-
try {
|
|
63036
|
-
json2 = text ? JSON.parse(text) : null;
|
|
63037
|
-
} catch {
|
|
63038
|
-
json2 = null;
|
|
63039
|
-
}
|
|
63040
|
-
return { status: res.status, body: json2, text };
|
|
63041
|
-
}
|
|
63042
|
-
function expectOk(answer, what) {
|
|
63043
|
-
if (answer.status >= 200 && answer.status < 300 && answer.body) return answer.body;
|
|
63044
|
-
const b2 = answer.body ?? {};
|
|
63045
|
-
const code = typeof b2.code === "string" ? b2.code : null;
|
|
63046
|
-
const error = typeof b2.error === "string" ? b2.error : `${what}: HTTP ${answer.status}`;
|
|
63047
|
-
throw new WireError(answer.status, code, error, answer.body);
|
|
63048
|
-
}
|
|
63049
|
-
async function readAttestation() {
|
|
63050
|
-
let res;
|
|
63051
|
-
try {
|
|
63052
|
-
res = await fetch(`${identityOrigin()}${LANE}/passwords/attestation`, {
|
|
63053
|
-
headers: { accept: "application/json", "user-agent": CLI_USER_AGENT },
|
|
63054
|
-
signal: AbortSignal.timeout(6e4)
|
|
63055
|
-
});
|
|
63056
|
-
} catch (err) {
|
|
63057
|
-
throw new WireError(0, "network_error", `could not reach ${identityOrigin()}: ${err.message}`, null);
|
|
63058
|
-
}
|
|
63059
|
-
const body = await res.json().catch(() => null);
|
|
63060
|
-
if (!res.ok || !body?.publicKey || !body?.keyId) {
|
|
63061
|
-
const error = body?.error ?? `the box's key could not be read: HTTP ${res.status}`;
|
|
63062
|
-
throw new WireError(res.status, body?.code ?? null, error, body);
|
|
63063
|
-
}
|
|
63064
|
-
return body;
|
|
63065
|
-
}
|
|
63066
|
-
async function listRows(wallet) {
|
|
63067
|
-
const out = expectOk(await signedFetch(wallet, "GET", `${LANE}/passwords`), "list");
|
|
63068
|
-
return { passwords: out.passwords ?? [], permitted: out.permitted ?? [] };
|
|
63069
|
-
}
|
|
63070
|
-
async function storeRow(wallet, body) {
|
|
63071
|
-
const out = expectOk(await signedFetch(wallet, "POST", `${LANE}/passwords`, body), "store");
|
|
63072
|
-
return out.password;
|
|
63073
|
-
}
|
|
63074
|
-
async function revealRow(wallet, id2) {
|
|
63075
|
-
const out = expectOk(await signedFetch(wallet, "POST", `${LANE}/passwords/${encodeURIComponent(id2)}/reveal`), "reveal");
|
|
63076
|
-
return out.passkeyBlob;
|
|
63077
|
-
}
|
|
63078
|
-
async function postPermit(wallet, signed2) {
|
|
63079
|
-
const out = expectOk(
|
|
63080
|
-
await signedFetch(wallet, "POST", `${LANE}/passwords/permits`, { typedData: signed2.typedData, signature: signed2.signature }),
|
|
63081
|
-
"permit"
|
|
63082
|
-
);
|
|
63083
|
-
return out.permit;
|
|
63084
|
-
}
|
|
63085
|
-
async function postUse(wallet, id2, body, timeoutMs = 2e5) {
|
|
63086
|
-
return signedFetch(wallet, "POST", `${LANE}/passwords/${encodeURIComponent(id2)}/use`, body, timeoutMs);
|
|
63087
|
-
}
|
|
63088
|
-
async function withdrawInvite(wallet, envelope, signature) {
|
|
63089
|
-
return expectOk(
|
|
63090
|
-
await signedFetch(wallet, "POST", `${LANE}/passwords/invites/withdraw`, { invite: { envelope, signature } }),
|
|
63091
|
-
"withdraw"
|
|
63092
|
-
);
|
|
63093
|
-
}
|
|
63094
|
-
|
|
63095
|
-
// src/lib/session-bridge.ts
|
|
63096
63157
|
var BRIDGE_FRAGMENT_KEY = "agentgates-open";
|
|
63097
63158
|
var CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
63098
63159
|
function mintToken() {
|
|
@@ -63209,11 +63270,11 @@ async function serveWordsOnce(args) {
|
|
|
63209
63270
|
let port = 0;
|
|
63210
63271
|
let done = () => {
|
|
63211
63272
|
};
|
|
63212
|
-
let
|
|
63273
|
+
let fail4 = () => {
|
|
63213
63274
|
};
|
|
63214
63275
|
const settled = new Promise((resolve2, reject) => {
|
|
63215
63276
|
done = resolve2;
|
|
63216
|
-
|
|
63277
|
+
fail4 = reject;
|
|
63217
63278
|
});
|
|
63218
63279
|
const server = createServer((req, res) => {
|
|
63219
63280
|
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
@@ -63239,7 +63300,7 @@ async function serveWordsOnce(args) {
|
|
|
63239
63300
|
const timer = setTimeout(() => {
|
|
63240
63301
|
if (!taken) {
|
|
63241
63302
|
server.close();
|
|
63242
|
-
|
|
63303
|
+
fail4(new Error(`nobody took the session in ${Math.round(args.waitMs / 1e3)}s`));
|
|
63243
63304
|
}
|
|
63244
63305
|
}, args.waitMs);
|
|
63245
63306
|
try {
|
|
@@ -63253,11 +63314,11 @@ async function receiveWordsOnce(args) {
|
|
|
63253
63314
|
let taken = false;
|
|
63254
63315
|
let done = () => {
|
|
63255
63316
|
};
|
|
63256
|
-
let
|
|
63317
|
+
let fail4 = () => {
|
|
63257
63318
|
};
|
|
63258
63319
|
const settled = new Promise((resolve2, reject) => {
|
|
63259
63320
|
done = resolve2;
|
|
63260
|
-
|
|
63321
|
+
fail4 = reject;
|
|
63261
63322
|
});
|
|
63262
63323
|
const server = createServer(async (req, res) => {
|
|
63263
63324
|
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
@@ -63287,7 +63348,7 @@ async function receiveWordsOnce(args) {
|
|
|
63287
63348
|
const timer = setTimeout(() => {
|
|
63288
63349
|
if (!taken) {
|
|
63289
63350
|
server.close();
|
|
63290
|
-
|
|
63351
|
+
fail4(new Error(`nobody handed a session over in ${Math.round(args.waitMs / 1e3)}s`));
|
|
63291
63352
|
}
|
|
63292
63353
|
}, args.waitMs);
|
|
63293
63354
|
try {
|
|
@@ -63317,15 +63378,15 @@ function humanHandoffLines(address) {
|
|
|
63317
63378
|
}
|
|
63318
63379
|
async function sessionOpen(opts) {
|
|
63319
63380
|
const waitMs = Math.max(10, Number(opts.wait) || 300) * 1e3;
|
|
63320
|
-
let
|
|
63381
|
+
let keys2;
|
|
63321
63382
|
try {
|
|
63322
|
-
|
|
63383
|
+
keys2 = await requirePasswordsKey();
|
|
63323
63384
|
} catch (err) {
|
|
63324
63385
|
return refuse(opts, err.message, "no_key");
|
|
63325
63386
|
}
|
|
63326
|
-
const words7 =
|
|
63387
|
+
const words7 = keys2.state.mnemonic;
|
|
63327
63388
|
if (!words7) return refuse(opts, "this key was made without words (a bare key); only a twelve-word account can be handed to a browser. Mint one with init --replace.", "bare_key");
|
|
63328
|
-
const address =
|
|
63389
|
+
const address = keys2.wallet.address;
|
|
63329
63390
|
try {
|
|
63330
63391
|
await serveWordsOnce({
|
|
63331
63392
|
words: words7,
|
|
@@ -63387,6 +63448,9 @@ async function sessionReceive(opts) {
|
|
|
63387
63448
|
}
|
|
63388
63449
|
}
|
|
63389
63450
|
|
|
63451
|
+
// src/commands/passwords.ts
|
|
63452
|
+
import { hostname } from "node:os";
|
|
63453
|
+
|
|
63390
63454
|
// src/lib/passwords-seal.ts
|
|
63391
63455
|
import { createCipheriv, createDecipheriv, createECDH, createHash as createHash2, hkdfSync, randomBytes as randomBytes6, randomUUID } from "node:crypto";
|
|
63392
63456
|
var PASSWORDS_SUITE = "AGENTGATES-PASSWORDS-ECDH-P256-HKDF-SHA256-AESGCM-v1";
|
|
@@ -63671,8 +63735,8 @@ function canonicalJson(value) {
|
|
|
63671
63735
|
}
|
|
63672
63736
|
if (Array.isArray(value)) return `[${value.map((v) => canonicalJson(v)).join(",")}]`;
|
|
63673
63737
|
const obj = value;
|
|
63674
|
-
const
|
|
63675
|
-
return `{${
|
|
63738
|
+
const keys2 = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
|
|
63739
|
+
return `{${keys2.map((k) => `${JSON.stringify(k)}:${canonicalJson(obj[k])}`).join(",")}}`;
|
|
63676
63740
|
}
|
|
63677
63741
|
var INVITE_KIND = "agentgates.passwords-invite";
|
|
63678
63742
|
var INVITE_VERSION = 1;
|
|
@@ -63725,6 +63789,27 @@ function decodeInviteFragment(fragment) {
|
|
|
63725
63789
|
}
|
|
63726
63790
|
|
|
63727
63791
|
// src/commands/passwords.ts
|
|
63792
|
+
async function mintLoginKeyIfMissing(keys2) {
|
|
63793
|
+
if (keys2.state.apiKey) return { prefix: keys2.state.apiKeyPrefix ?? "", name: keys2.state.apiKeyName ?? "", minted: false };
|
|
63794
|
+
try {
|
|
63795
|
+
const name = `cli ${hostname()}`.slice(0, 64);
|
|
63796
|
+
const out = await createLoginKey(keys2.wallet, name);
|
|
63797
|
+
await saveLoginKey(keys2.state, { secret: out.key, prefix: out.created.prefix, name: out.created.name });
|
|
63798
|
+
return { prefix: out.created.prefix, name: out.created.name, minted: true };
|
|
63799
|
+
} catch (err) {
|
|
63800
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
63801
|
+
}
|
|
63802
|
+
}
|
|
63803
|
+
function loginKeyFields(login2) {
|
|
63804
|
+
return "error" in login2 ? { loginKeyError: login2.error } : { loginKey: { prefix: login2.prefix, name: login2.name, minted: login2.minted } };
|
|
63805
|
+
}
|
|
63806
|
+
function loginKeyLines(login2) {
|
|
63807
|
+
if ("error" in login2) return ` ${import_picocolors8.default.dim(`no login key yet (${login2.error}); the words sign every call until agentgates keys create --keep`)}
|
|
63808
|
+
`;
|
|
63809
|
+
return login2.minted ? ` ${import_picocolors8.default.green("\u2713")} login key minted: ${import_picocolors8.default.bold(login2.prefix)} ${import_picocolors8.default.dim("kept in the key file; every call sends it and the words stay home. agentgates keys \xB7 lists, mints, revokes")}
|
|
63810
|
+
` : ` ${import_picocolors8.default.dim(`login key here: ${login2.prefix}; every call sends it`)}
|
|
63811
|
+
`;
|
|
63812
|
+
}
|
|
63728
63813
|
var SITE5 = (process.env.AGENTGATES_ORIGIN || "https://agentgates.ai").replace(/\/$/, "");
|
|
63729
63814
|
var jsonMode2 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
63730
63815
|
function emit2(opts, data4, human) {
|
|
@@ -63874,13 +63959,13 @@ async function passwordsInit(opts) {
|
|
|
63874
63959
|
return;
|
|
63875
63960
|
}
|
|
63876
63961
|
if (opts.seed) {
|
|
63877
|
-
const
|
|
63878
|
-
|
|
63962
|
+
const brought = await importPasswordsSeed({ seed: opts.seed, replace: opts.replace === true });
|
|
63963
|
+
const login3 = await mintLoginKeyIfMissing(brought);
|
|
63964
|
+
emit2(opts, { ok: true, address: brought.state.address, created: false, imported: true, words: SEED_WORDS, path: passwordsKeyPath(), ...loginKeyFields(login3) }, () => {
|
|
63879
63965
|
process.stdout.write(`
|
|
63880
|
-
${import_picocolors8.default.green("\u2713")} twelve words taken: ${import_picocolors8.default.bold(
|
|
63966
|
+
${import_picocolors8.default.green("\u2713")} twelve words taken: ${import_picocolors8.default.bold(brought.state.address)}
|
|
63881
63967
|
${import_picocolors8.default.dim(passwordsKeyPath())}
|
|
63882
|
-
|
|
63883
|
-
`);
|
|
63968
|
+
` + loginKeyLines(login3) + "\n");
|
|
63884
63969
|
});
|
|
63885
63970
|
return;
|
|
63886
63971
|
}
|
|
@@ -63897,13 +63982,15 @@ async function passwordsInit(opts) {
|
|
|
63897
63982
|
});
|
|
63898
63983
|
return;
|
|
63899
63984
|
}
|
|
63900
|
-
const
|
|
63901
|
-
|
|
63985
|
+
const made = await loadOrCreatePasswordsKey();
|
|
63986
|
+
const { state, created, minted } = made;
|
|
63987
|
+
const login2 = await mintLoginKeyIfMissing(made);
|
|
63988
|
+
emit2(opts, { ok: true, address: state.address, created, path: passwordsKeyPath(), ...minted ? { seed: minted.seed } : {}, ...loginKeyFields(login2) }, () => {
|
|
63902
63989
|
process.stdout.write(
|
|
63903
63990
|
`
|
|
63904
63991
|
${import_picocolors8.default.green("\u2713")} ${created ? "key minted" : "key already here"}: ${import_picocolors8.default.bold(state.address)}
|
|
63905
63992
|
${import_picocolors8.default.dim(passwordsKeyPath())}
|
|
63906
|
-
` + (minted ? `
|
|
63993
|
+
` + loginKeyLines(login2) + (minted ? `
|
|
63907
63994
|
${import_picocolors8.default.bold(minted.seed)}
|
|
63908
63995
|
|
|
63909
63996
|
${import_picocolors8.default.dim("Shown once. These twelve words are this account on agentgates.ai: they sign every call, hold its balance and open what it stores. Write them down, or hand them to the person you work for.")}
|
|
@@ -64427,18 +64514,18 @@ async function browserPricing(opts) {
|
|
|
64427
64514
|
}
|
|
64428
64515
|
async function browserBalance(opts) {
|
|
64429
64516
|
try {
|
|
64430
|
-
const
|
|
64431
|
-
let balance2 = await readIdentityBalance(
|
|
64432
|
-
const { deposit, dark } = await readDepositAddress(
|
|
64517
|
+
const keys2 = await requirePasswordsKey();
|
|
64518
|
+
let balance2 = await readIdentityBalance(keys2.wallet);
|
|
64519
|
+
const { deposit, dark } = await readDepositAddress(keys2.wallet);
|
|
64433
64520
|
let scan = null;
|
|
64434
64521
|
if (opts.scan && deposit) {
|
|
64435
|
-
const out = await scanDeposit(
|
|
64522
|
+
const out = await scanDeposit(keys2.wallet);
|
|
64436
64523
|
scan = { scanned: out.scanned, credited: out.credited };
|
|
64437
|
-
if (out.credited > 0) balance2 = await readIdentityBalance(
|
|
64524
|
+
if (out.credited > 0) balance2 = await readIdentityBalance(keys2.wallet);
|
|
64438
64525
|
}
|
|
64439
|
-
emit3(opts, { ok: true, wallet:
|
|
64526
|
+
emit3(opts, { ok: true, wallet: keys2.wallet.address, via: lastAuthVia(), loginKeyRevoked: loginKeyWasRevoked(), balance: balance2.balance, rungsUsd: balance2.rungsUsd, deposit, ...dark ? { depositDark: dark } : {}, ...scan ? { scan } : {} }, () => {
|
|
64440
64527
|
process.stdout.write(`
|
|
64441
|
-
${import_picocolors9.default.bold("BALANCE")} ${import_picocolors9.default.dim(
|
|
64528
|
+
${import_picocolors9.default.bold("BALANCE")} ${import_picocolors9.default.dim(keys2.wallet.address)}
|
|
64442
64529
|
|
|
64443
64530
|
`);
|
|
64444
64531
|
if (balance2.balance) {
|
|
@@ -64480,8 +64567,8 @@ async function browserRun(url, opts) {
|
|
|
64480
64567
|
const maxSeconds = opts.seconds !== void 0 ? Number(opts.seconds) : void 0;
|
|
64481
64568
|
if (maxSeconds !== void 0 && !Number.isInteger(maxSeconds)) return refuse3(opts, "--seconds must be a whole number", "bad_request");
|
|
64482
64569
|
try {
|
|
64483
|
-
const
|
|
64484
|
-
const task = await postTask(
|
|
64570
|
+
const keys2 = await requirePasswordsKey();
|
|
64571
|
+
const task = await postTask(keys2.wallet, { url: siteUrl(url), goal, hosts: opts.host, maxSteps, maxSeconds });
|
|
64485
64572
|
if (!opts.wait) {
|
|
64486
64573
|
emit3(opts, { ok: true, task }, () => {
|
|
64487
64574
|
printTask(task, false);
|
|
@@ -64493,7 +64580,7 @@ async function browserRun(url, opts) {
|
|
|
64493
64580
|
}
|
|
64494
64581
|
const waitSeconds = typeof opts.wait === "string" ? Math.max(5, Number(opts.wait) || 0) : Math.max(60, task.maxSeconds + 120);
|
|
64495
64582
|
let lastStatus = "";
|
|
64496
|
-
const settled = await waitForTask(
|
|
64583
|
+
const settled = await waitForTask(keys2.wallet, task.id, {
|
|
64497
64584
|
maxSeconds: waitSeconds,
|
|
64498
64585
|
onTick: (t) => {
|
|
64499
64586
|
if (jsonMode3(opts) || t.status === lastStatus) return;
|
|
@@ -64515,11 +64602,11 @@ async function browserRun(url, opts) {
|
|
|
64515
64602
|
}
|
|
64516
64603
|
async function browserTasks(opts) {
|
|
64517
64604
|
try {
|
|
64518
|
-
const
|
|
64519
|
-
const tasks = await listTasks(
|
|
64520
|
-
emit3(opts, { ok: true, wallet:
|
|
64605
|
+
const keys2 = await requirePasswordsKey();
|
|
64606
|
+
const tasks = await listTasks(keys2.wallet);
|
|
64607
|
+
emit3(opts, { ok: true, wallet: keys2.wallet.address, tasks }, () => {
|
|
64521
64608
|
process.stdout.write(`
|
|
64522
|
-
${import_picocolors9.default.bold("YOUR TASKS")} ${import_picocolors9.default.dim(
|
|
64609
|
+
${import_picocolors9.default.bold("YOUR TASKS")} ${import_picocolors9.default.dim(keys2.wallet.address)}
|
|
64523
64610
|
|
|
64524
64611
|
`);
|
|
64525
64612
|
if (tasks.length === 0) {
|
|
@@ -64543,19 +64630,19 @@ async function browserTasks(opts) {
|
|
|
64543
64630
|
}
|
|
64544
64631
|
async function browserTask(id2, opts) {
|
|
64545
64632
|
try {
|
|
64546
|
-
const
|
|
64633
|
+
const keys2 = await requirePasswordsKey();
|
|
64547
64634
|
if (opts.cancel) {
|
|
64548
|
-
const task2 = await cancelTask(
|
|
64635
|
+
const task2 = await cancelTask(keys2.wallet, id2);
|
|
64549
64636
|
emit3(opts, { ok: true, task: task2 }, () => printTask(task2, false));
|
|
64550
64637
|
return;
|
|
64551
64638
|
}
|
|
64552
|
-
const task = opts.wait ? await waitForTask(
|
|
64639
|
+
const task = opts.wait ? await waitForTask(keys2.wallet, id2, {
|
|
64553
64640
|
maxSeconds: typeof opts.wait === "string" ? Math.max(5, Number(opts.wait) || 0) : 900,
|
|
64554
64641
|
onTick: (t) => {
|
|
64555
64642
|
if (!jsonMode3(opts) && !SETTLED.has(t.status)) process.stderr.write(` ${import_picocolors9.default.dim(`${t.status} \xB7 ${t.stepsRun} steps`)}
|
|
64556
64643
|
`);
|
|
64557
64644
|
}
|
|
64558
|
-
}) : await readTask(
|
|
64645
|
+
}) : await readTask(keys2.wallet, id2);
|
|
64559
64646
|
emit3(opts, { ok: true, task }, () => printTask(task, true));
|
|
64560
64647
|
} catch (err) {
|
|
64561
64648
|
failFrom2(opts, err);
|
|
@@ -64996,17 +65083,117 @@ function printNext(put) {
|
|
|
64996
65083
|
`);
|
|
64997
65084
|
}
|
|
64998
65085
|
|
|
64999
|
-
// src/commands/
|
|
65086
|
+
// src/commands/keys.ts
|
|
65000
65087
|
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
65088
|
+
import { hostname as hostname2 } from "node:os";
|
|
65089
|
+
function emit4(opts, data4, human) {
|
|
65090
|
+
if (opts.json || !process.stdout.isTTY) {
|
|
65091
|
+
process.stdout.write(`${JSON.stringify(data4)}
|
|
65092
|
+
`);
|
|
65093
|
+
return;
|
|
65094
|
+
}
|
|
65095
|
+
human();
|
|
65096
|
+
}
|
|
65097
|
+
function fail(opts, err) {
|
|
65098
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
65099
|
+
const code = err?.code;
|
|
65100
|
+
if (opts.json || !process.stdout.isTTY) {
|
|
65101
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: message, ...typeof code === "string" ? { code } : {} })}
|
|
65102
|
+
`);
|
|
65103
|
+
} else {
|
|
65104
|
+
process.stderr.write(`
|
|
65105
|
+
${import_picocolors12.default.red("\u2717")} ${message}
|
|
65106
|
+
|
|
65107
|
+
`);
|
|
65108
|
+
}
|
|
65109
|
+
process.exit(1);
|
|
65110
|
+
}
|
|
65111
|
+
function whenLabel(iso) {
|
|
65112
|
+
if (!iso) return "never";
|
|
65113
|
+
const d = new Date(iso);
|
|
65114
|
+
return Number.isNaN(d.getTime()) ? "" : d.toISOString().slice(0, 16).replace("T", " ");
|
|
65115
|
+
}
|
|
65116
|
+
function printRows(rows, mine) {
|
|
65117
|
+
if (rows.length === 0) {
|
|
65118
|
+
process.stdout.write(`
|
|
65119
|
+
${import_picocolors12.default.dim("no login keys on this account yet")}
|
|
65120
|
+
${import_picocolors12.default.dim("agentgates keys create --keep \xB7 mints one for this machine")}
|
|
65121
|
+
|
|
65122
|
+
`);
|
|
65123
|
+
return;
|
|
65124
|
+
}
|
|
65125
|
+
process.stdout.write("\n");
|
|
65126
|
+
for (const r of rows) {
|
|
65127
|
+
const here = mine && r.prefix === mine ? import_picocolors12.default.green(" this machine") : "";
|
|
65128
|
+
process.stdout.write(` ${import_picocolors12.default.bold(r.prefix)} ${r.name} ${import_picocolors12.default.dim(`used ${whenLabel(r.lastUsedAt)}`)} ${import_picocolors12.default.dim(r.id)}${here}
|
|
65129
|
+
`);
|
|
65130
|
+
}
|
|
65131
|
+
process.stdout.write("\n");
|
|
65132
|
+
}
|
|
65133
|
+
async function keysList(opts) {
|
|
65134
|
+
try {
|
|
65135
|
+
const keys2 = await requirePasswordsKey();
|
|
65136
|
+
const rows = await listLoginKeys(keys2.wallet);
|
|
65137
|
+
emit4(opts, { ok: true, address: keys2.state.address, keys: rows, thisMachine: keys2.state.apiKeyPrefix ?? null }, () => printRows(rows, keys2.state.apiKeyPrefix ?? null));
|
|
65138
|
+
} catch (err) {
|
|
65139
|
+
fail(opts, err);
|
|
65140
|
+
}
|
|
65141
|
+
}
|
|
65142
|
+
async function keysCreate(opts) {
|
|
65143
|
+
try {
|
|
65144
|
+
const keys2 = await requirePasswordsKey();
|
|
65145
|
+
const name = (opts.name?.trim() || `cli ${hostname2()}`).slice(0, 64);
|
|
65146
|
+
const made = await createLoginKey(keys2.wallet, name);
|
|
65147
|
+
if (opts.keep) await saveLoginKey(keys2.state, { secret: made.key, prefix: made.created.prefix, name: made.created.name });
|
|
65148
|
+
emit4(opts, { ok: true, key: made.key, created: made.created, kept: opts.keep === true }, () => {
|
|
65149
|
+
process.stdout.write(
|
|
65150
|
+
`
|
|
65151
|
+
${import_picocolors12.default.green("\u2713")} login key minted: ${import_picocolors12.default.bold(made.created.name)}
|
|
65152
|
+
|
|
65153
|
+
${made.key}
|
|
65154
|
+
|
|
65155
|
+
${import_picocolors12.default.dim("Shown once. Send it as Authorization: Bearer <key> on every /api/identity door; the words stay home.")}
|
|
65156
|
+
` + (opts.keep ? ` ${import_picocolors12.default.dim("Kept in the key file: this machine sends it from now on.")}
|
|
65157
|
+
|
|
65158
|
+
` : ` ${import_picocolors12.default.dim("agentgates keys create --keep \xB7 would have made it this machine's")}
|
|
65159
|
+
|
|
65160
|
+
`)
|
|
65161
|
+
);
|
|
65162
|
+
});
|
|
65163
|
+
} catch (err) {
|
|
65164
|
+
fail(opts, err);
|
|
65165
|
+
}
|
|
65166
|
+
}
|
|
65167
|
+
async function keysRevoke(id2, opts) {
|
|
65168
|
+
try {
|
|
65169
|
+
const keys2 = await requirePasswordsKey();
|
|
65170
|
+
const before = await listLoginKeys(keys2.wallet);
|
|
65171
|
+
const target = before.find((r) => r.id === id2);
|
|
65172
|
+
const out = await revokeLoginKey(keys2.wallet, id2);
|
|
65173
|
+
const wasMine = !!target && !!keys2.state.apiKeyPrefix && target.prefix === keys2.state.apiKeyPrefix;
|
|
65174
|
+
if (wasMine) await forgetLoginKey(keys2.state);
|
|
65175
|
+
emit4(opts, { ok: true, revoked: id2, keys: out.keys, thisMachineDropped: wasMine }, () => {
|
|
65176
|
+
process.stdout.write(`
|
|
65177
|
+
${import_picocolors12.default.green("\u2713")} revoked ${target ? import_picocolors12.default.bold(target.prefix) : id2}${wasMine ? import_picocolors12.default.dim(" (this machine signs with the words until keys create --keep)") : ""}
|
|
65178
|
+
`);
|
|
65179
|
+
printRows(out.keys, wasMine ? null : keys2.state.apiKeyPrefix ?? null);
|
|
65180
|
+
});
|
|
65181
|
+
} catch (err) {
|
|
65182
|
+
fail(opts, err);
|
|
65183
|
+
}
|
|
65184
|
+
}
|
|
65185
|
+
|
|
65186
|
+
// src/commands/logout.ts
|
|
65187
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
65001
65188
|
async function logout(opts) {
|
|
65002
65189
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65003
65190
|
const resolved = await resolveProfile(requested);
|
|
65004
65191
|
if (!resolved) {
|
|
65005
|
-
process.stdout.write(
|
|
65192
|
+
process.stdout.write(import_picocolors13.default.dim("Not logged in \u2014 nothing to log out.\n"));
|
|
65006
65193
|
return;
|
|
65007
65194
|
}
|
|
65008
65195
|
if (resolved.autoSelected) {
|
|
65009
|
-
process.stderr.write(
|
|
65196
|
+
process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65010
65197
|
`));
|
|
65011
65198
|
}
|
|
65012
65199
|
const { profile, name: profileName } = resolved;
|
|
@@ -65031,15 +65218,15 @@ async function logout(opts) {
|
|
|
65031
65218
|
const removed = await deleteProfile(profileName);
|
|
65032
65219
|
if (removed) {
|
|
65033
65220
|
process.stdout.write(
|
|
65034
|
-
|
|
65221
|
+
import_picocolors13.default.green(`\u2713 Logged out of profile ${import_picocolors13.default.bold(profileName)}.
|
|
65035
65222
|
`)
|
|
65036
65223
|
);
|
|
65037
65224
|
}
|
|
65038
65225
|
if (serverError) {
|
|
65039
65226
|
process.stderr.write(
|
|
65040
|
-
|
|
65227
|
+
import_picocolors13.default.yellow(
|
|
65041
65228
|
`\u26A0 Couldn't revoke server-side: ${serverError}
|
|
65042
|
-
The local bearer is wiped. If the server still has it, revoke from ${
|
|
65229
|
+
The local bearer is wiped. If the server still has it, revoke from ${import_picocolors13.default.bold("agentgates.ai/settings/pairings")}.
|
|
65043
65230
|
`
|
|
65044
65231
|
)
|
|
65045
65232
|
);
|
|
@@ -65047,16 +65234,16 @@ async function logout(opts) {
|
|
|
65047
65234
|
}
|
|
65048
65235
|
|
|
65049
65236
|
// src/commands/whoami.ts
|
|
65050
|
-
var
|
|
65237
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
65051
65238
|
async function whoami(opts) {
|
|
65052
65239
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65053
65240
|
const resolved = await resolveProfile(requested);
|
|
65054
65241
|
if (!resolved) {
|
|
65055
|
-
process.stderr.write(
|
|
65242
|
+
process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65056
65243
|
process.exit(2);
|
|
65057
65244
|
}
|
|
65058
65245
|
if (resolved.autoSelected) {
|
|
65059
|
-
process.stderr.write(
|
|
65246
|
+
process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65060
65247
|
`));
|
|
65061
65248
|
}
|
|
65062
65249
|
const { profile, name: profileName } = resolved;
|
|
@@ -65065,7 +65252,7 @@ async function whoami(opts) {
|
|
|
65065
65252
|
profile,
|
|
65066
65253
|
profileName,
|
|
65067
65254
|
jsonMode: jsonMode5,
|
|
65068
|
-
ttyHeader:
|
|
65255
|
+
ttyHeader: import_picocolors14.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
65069
65256
|
fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
|
|
65070
65257
|
});
|
|
65071
65258
|
if (outcome.kind === "auth_failed") {
|
|
@@ -65075,14 +65262,14 @@ async function whoami(opts) {
|
|
|
65075
65262
|
);
|
|
65076
65263
|
process.exit(1);
|
|
65077
65264
|
}
|
|
65078
|
-
process.stderr.write(
|
|
65265
|
+
process.stderr.write(import_picocolors14.default.red(`\u2715 ${outcome.reason}.
|
|
65079
65266
|
`));
|
|
65080
65267
|
process.exit(1);
|
|
65081
65268
|
}
|
|
65082
65269
|
if (outcome.kind === "error") {
|
|
65083
65270
|
const err = outcome.error;
|
|
65084
65271
|
if (err instanceof ApiError) {
|
|
65085
|
-
process.stderr.write(
|
|
65272
|
+
process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65086
65273
|
`));
|
|
65087
65274
|
process.exit(1);
|
|
65088
65275
|
}
|
|
@@ -65103,7 +65290,7 @@ async function whoami(opts) {
|
|
|
65103
65290
|
process.stdout.write(`Solana ${me.solanaAddress}
|
|
65104
65291
|
`);
|
|
65105
65292
|
}
|
|
65106
|
-
process.stdout.write(`Scopes ${me.scopes.join(", ") ||
|
|
65293
|
+
process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors14.default.dim("(none)")}
|
|
65107
65294
|
`);
|
|
65108
65295
|
const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
|
|
65109
65296
|
const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
|
|
@@ -65120,7 +65307,7 @@ async function whoami(opts) {
|
|
|
65120
65307
|
`
|
|
65121
65308
|
);
|
|
65122
65309
|
process.stdout.write(
|
|
65123
|
-
`Profile ${profileName === DEFAULT_PROFILE ?
|
|
65310
|
+
`Profile ${profileName === DEFAULT_PROFILE ? import_picocolors14.default.dim("(default)") : profileName}
|
|
65124
65311
|
`
|
|
65125
65312
|
);
|
|
65126
65313
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -65134,7 +65321,7 @@ function formatDate(iso) {
|
|
|
65134
65321
|
}
|
|
65135
65322
|
|
|
65136
65323
|
// src/commands/send.ts
|
|
65137
|
-
var
|
|
65324
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
65138
65325
|
|
|
65139
65326
|
// src/lib/status.ts
|
|
65140
65327
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -65284,11 +65471,11 @@ async function send(amount, asset, opts) {
|
|
|
65284
65471
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65285
65472
|
const resolved = await resolveProfile(requested);
|
|
65286
65473
|
if (!resolved) {
|
|
65287
|
-
process.stderr.write(
|
|
65474
|
+
process.stderr.write(import_picocolors15.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65288
65475
|
process.exit(2);
|
|
65289
65476
|
}
|
|
65290
65477
|
if (resolved.autoSelected) {
|
|
65291
|
-
process.stderr.write(
|
|
65478
|
+
process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65292
65479
|
`));
|
|
65293
65480
|
}
|
|
65294
65481
|
const { profile, name: profileName } = resolved;
|
|
@@ -65297,7 +65484,7 @@ async function send(amount, asset, opts) {
|
|
|
65297
65484
|
const amountNumber = Number(amount);
|
|
65298
65485
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
65299
65486
|
process.stderr.write(
|
|
65300
|
-
|
|
65487
|
+
import_picocolors15.default.red(`\u2715 amount must be a positive number (got ${import_picocolors15.default.bold(amount)}).
|
|
65301
65488
|
`)
|
|
65302
65489
|
);
|
|
65303
65490
|
process.exit(2);
|
|
@@ -65305,23 +65492,23 @@ async function send(amount, asset, opts) {
|
|
|
65305
65492
|
const assetNormalized = asset.toLowerCase();
|
|
65306
65493
|
if (assetNormalized !== "native" && assetNormalized !== "usdc") {
|
|
65307
65494
|
process.stderr.write(
|
|
65308
|
-
|
|
65309
|
-
`\u2715 asset must be ${
|
|
65495
|
+
import_picocolors15.default.red(
|
|
65496
|
+
`\u2715 asset must be ${import_picocolors15.default.bold("native")} or ${import_picocolors15.default.bold("usdc")} (got ${import_picocolors15.default.bold(asset)}).
|
|
65310
65497
|
`
|
|
65311
65498
|
)
|
|
65312
65499
|
);
|
|
65313
65500
|
process.exit(2);
|
|
65314
65501
|
}
|
|
65315
65502
|
if (!opts.to || opts.to.trim() === "") {
|
|
65316
|
-
process.stderr.write(
|
|
65503
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 --to <address> is required.
|
|
65317
65504
|
`));
|
|
65318
65505
|
process.exit(2);
|
|
65319
65506
|
}
|
|
65320
65507
|
if (isSolanaChainAlias(opts.chain)) {
|
|
65321
65508
|
if (EVM_ADDRESS_RE.test(opts.to)) {
|
|
65322
65509
|
process.stderr.write(
|
|
65323
|
-
|
|
65324
|
-
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${
|
|
65510
|
+
import_picocolors15.default.red(
|
|
65511
|
+
`\u2715 --to looks like an EVM address (0x-hex), but --chain is ${import_picocolors15.default.bold("solana")}. Pass a base58 Solana pubkey, or pick an EVM chain.
|
|
65325
65512
|
`
|
|
65326
65513
|
)
|
|
65327
65514
|
);
|
|
@@ -65329,10 +65516,10 @@ async function send(amount, asset, opts) {
|
|
|
65329
65516
|
}
|
|
65330
65517
|
if (!SOLANA_ADDRESS_RE.test(opts.to)) {
|
|
65331
65518
|
process.stderr.write(
|
|
65332
|
-
|
|
65333
|
-
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${
|
|
65519
|
+
import_picocolors15.default.red(
|
|
65520
|
+
`\u2715 --to must be a base58 Solana pubkey (32\u201344 chars, base58 alphabet) for --chain solana (got ${import_picocolors15.default.bold(opts.to)}).
|
|
65334
65521
|
`
|
|
65335
|
-
) +
|
|
65522
|
+
) + import_picocolors15.default.dim(
|
|
65336
65523
|
` SNS resolution is deferred to a future server-side change;
|
|
65337
65524
|
for now Solana sends require the literal pubkey.
|
|
65338
65525
|
`
|
|
@@ -65343,8 +65530,8 @@ async function send(amount, asset, opts) {
|
|
|
65343
65530
|
}
|
|
65344
65531
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
65345
65532
|
process.stderr.write(
|
|
65346
|
-
|
|
65347
|
-
`) +
|
|
65533
|
+
import_picocolors15.default.red(`\u2715 --user-stated <text> is required.
|
|
65534
|
+
`) + import_picocolors15.default.dim(
|
|
65348
65535
|
` This is the trust-gap defense: pass the verbatim user request so
|
|
65349
65536
|
the approval modal can cross-check what the agent thinks the user
|
|
65350
65537
|
asked for vs. the actual decoded transaction.
|
|
@@ -65362,7 +65549,7 @@ async function send(amount, asset, opts) {
|
|
|
65362
65549
|
const n2 = Number(opts.maxUsd);
|
|
65363
65550
|
if (!Number.isFinite(n2) || n2 <= 0) {
|
|
65364
65551
|
process.stderr.write(
|
|
65365
|
-
|
|
65552
|
+
import_picocolors15.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
|
|
65366
65553
|
`)
|
|
65367
65554
|
);
|
|
65368
65555
|
process.exit(2);
|
|
@@ -65404,7 +65591,7 @@ async function send(amount, asset, opts) {
|
|
|
65404
65591
|
profile: profileName,
|
|
65405
65592
|
jsonMode: jsonMode5,
|
|
65406
65593
|
origin: activeProfile.mcpOrigin,
|
|
65407
|
-
ttyHeader:
|
|
65594
|
+
ttyHeader: import_picocolors15.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
65408
65595
|
});
|
|
65409
65596
|
} catch (reloginErr) {
|
|
65410
65597
|
if (jsonMode5) {
|
|
@@ -65416,7 +65603,7 @@ async function send(amount, asset, opts) {
|
|
|
65416
65603
|
process.exit(1);
|
|
65417
65604
|
}
|
|
65418
65605
|
process.stderr.write(
|
|
65419
|
-
|
|
65606
|
+
import_picocolors15.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65420
65607
|
`)
|
|
65421
65608
|
);
|
|
65422
65609
|
process.exit(1);
|
|
@@ -65440,7 +65627,7 @@ async function send(amount, asset, opts) {
|
|
|
65440
65627
|
process.exit(1);
|
|
65441
65628
|
}
|
|
65442
65629
|
process.stderr.write(
|
|
65443
|
-
|
|
65630
|
+
import_picocolors15.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
65444
65631
|
`)
|
|
65445
65632
|
);
|
|
65446
65633
|
process.exit(1);
|
|
@@ -65457,7 +65644,7 @@ async function send(amount, asset, opts) {
|
|
|
65457
65644
|
});
|
|
65458
65645
|
process.exit(1);
|
|
65459
65646
|
}
|
|
65460
|
-
process.stderr.write(
|
|
65647
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65461
65648
|
`));
|
|
65462
65649
|
process.exit(1);
|
|
65463
65650
|
} else {
|
|
@@ -65483,17 +65670,17 @@ async function send(amount, asset, opts) {
|
|
|
65483
65670
|
if (proposed.detail) {
|
|
65484
65671
|
const d = proposed.detail;
|
|
65485
65672
|
process.stderr.write(
|
|
65486
|
-
|
|
65673
|
+
import_picocolors15.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
|
|
65487
65674
|
`
|
|
65488
65675
|
);
|
|
65489
65676
|
} else {
|
|
65490
|
-
process.stderr.write(
|
|
65677
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${proposed.reason}
|
|
65491
65678
|
`));
|
|
65492
65679
|
}
|
|
65493
65680
|
if (proposed.upgrade_url) {
|
|
65494
65681
|
process.stderr.write(
|
|
65495
65682
|
` Open this to grant access, then re-run the command:
|
|
65496
|
-
${
|
|
65683
|
+
${import_picocolors15.default.cyan(proposed.upgrade_url)}
|
|
65497
65684
|
`
|
|
65498
65685
|
);
|
|
65499
65686
|
}
|
|
@@ -65503,21 +65690,21 @@ async function send(amount, asset, opts) {
|
|
|
65503
65690
|
const a = proposed.recommended_actions[i];
|
|
65504
65691
|
process.stderr.write(` ${i + 1}. ${a.label}
|
|
65505
65692
|
`);
|
|
65506
|
-
if (a.reasoning) process.stderr.write(
|
|
65693
|
+
if (a.reasoning) process.stderr.write(import_picocolors15.default.dim(` ${a.reasoning}
|
|
65507
65694
|
`));
|
|
65508
65695
|
if (a.action_intent && a.action_intent.external_url) {
|
|
65509
65696
|
process.stderr.write(
|
|
65510
|
-
` ${
|
|
65697
|
+
` ${import_picocolors15.default.cyan(a.action_intent.external_url)}
|
|
65511
65698
|
`
|
|
65512
65699
|
);
|
|
65513
65700
|
}
|
|
65514
65701
|
}
|
|
65515
65702
|
}
|
|
65516
65703
|
if (proposed.suggestions && proposed.suggestions.length > 0) {
|
|
65517
|
-
process.stderr.write(
|
|
65704
|
+
process.stderr.write(import_picocolors15.default.dim("\n Other ways to fund:\n"));
|
|
65518
65705
|
for (const s of proposed.suggestions) {
|
|
65519
65706
|
if (s.kind === "ask_user") continue;
|
|
65520
|
-
process.stderr.write(
|
|
65707
|
+
process.stderr.write(import_picocolors15.default.dim(` \u2022 ${s.label}
|
|
65521
65708
|
`));
|
|
65522
65709
|
}
|
|
65523
65710
|
}
|
|
@@ -65544,8 +65731,8 @@ async function send(amount, asset, opts) {
|
|
|
65544
65731
|
} else {
|
|
65545
65732
|
process.stdout.write(
|
|
65546
65733
|
`
|
|
65547
|
-
${
|
|
65548
|
-
${
|
|
65734
|
+
${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
65735
|
+
${import_picocolors15.default.cyan(proposed.approval_url)}
|
|
65549
65736
|
|
|
65550
65737
|
`
|
|
65551
65738
|
);
|
|
@@ -65564,7 +65751,7 @@ ${import_picocolors14.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65564
65751
|
if (jsonMode5) {
|
|
65565
65752
|
emitNdjson({ status: s.status, intent_id: s.approval_id });
|
|
65566
65753
|
} else {
|
|
65567
|
-
process.stdout.write(` ${describeStatus(s.status)}${
|
|
65754
|
+
process.stdout.write(` ${describeStatus(s.status)}${import_picocolors15.default.dim("\u2026")}\r`);
|
|
65568
65755
|
}
|
|
65569
65756
|
}
|
|
65570
65757
|
});
|
|
@@ -65578,7 +65765,7 @@ ${import_picocolors14.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65578
65765
|
profile: profileName,
|
|
65579
65766
|
jsonMode: jsonMode5,
|
|
65580
65767
|
origin: activeProfile.mcpOrigin,
|
|
65581
|
-
ttyHeader:
|
|
65768
|
+
ttyHeader: import_picocolors15.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
|
|
65582
65769
|
});
|
|
65583
65770
|
} catch (reloginErr) {
|
|
65584
65771
|
if (jsonMode5) {
|
|
@@ -65591,7 +65778,7 @@ ${import_picocolors14.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65591
65778
|
process.exit(1);
|
|
65592
65779
|
}
|
|
65593
65780
|
process.stderr.write(
|
|
65594
|
-
"\n" +
|
|
65781
|
+
"\n" + import_picocolors15.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65595
65782
|
`)
|
|
65596
65783
|
);
|
|
65597
65784
|
process.exit(1);
|
|
@@ -65609,7 +65796,7 @@ ${import_picocolors14.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65609
65796
|
process.exit(1);
|
|
65610
65797
|
}
|
|
65611
65798
|
process.stderr.write(
|
|
65612
|
-
"\n" +
|
|
65799
|
+
"\n" + import_picocolors15.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
65613
65800
|
`)
|
|
65614
65801
|
);
|
|
65615
65802
|
process.exit(1);
|
|
@@ -65625,7 +65812,7 @@ ${import_picocolors14.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65625
65812
|
process.exit(1);
|
|
65626
65813
|
}
|
|
65627
65814
|
process.stderr.write(
|
|
65628
|
-
"\n" +
|
|
65815
|
+
"\n" + import_picocolors15.default.red(`\u2715 Status poll failed: ${err.message}
|
|
65629
65816
|
`)
|
|
65630
65817
|
);
|
|
65631
65818
|
process.exit(1);
|
|
@@ -65645,19 +65832,19 @@ ${import_picocolors14.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65645
65832
|
}
|
|
65646
65833
|
process.stdout.write("\n");
|
|
65647
65834
|
if (final.status === "mined") {
|
|
65648
|
-
process.stdout.write(
|
|
65835
|
+
process.stdout.write(import_picocolors15.default.green("\u2713 Mined.") + "\n");
|
|
65649
65836
|
if (final.tx_hash) {
|
|
65650
65837
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
65651
65838
|
`);
|
|
65652
65839
|
}
|
|
65653
65840
|
if (explorer) {
|
|
65654
|
-
process.stdout.write(` Explorer ${
|
|
65841
|
+
process.stdout.write(` Explorer ${import_picocolors15.default.cyan(explorer)}
|
|
65655
65842
|
`);
|
|
65656
65843
|
}
|
|
65657
65844
|
process.exit(0);
|
|
65658
65845
|
}
|
|
65659
65846
|
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}`;
|
|
65660
|
-
process.stderr.write(
|
|
65847
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${label}.
|
|
65661
65848
|
`));
|
|
65662
65849
|
process.exit(1);
|
|
65663
65850
|
}
|
|
@@ -65685,7 +65872,7 @@ function describeStatus(s) {
|
|
|
65685
65872
|
}
|
|
65686
65873
|
|
|
65687
65874
|
// src/commands/status.ts
|
|
65688
|
-
var
|
|
65875
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
65689
65876
|
var WATCH_GIVEUP_MS = 10 * 6e4;
|
|
65690
65877
|
function explorerUrl2(chainId, hash2) {
|
|
65691
65878
|
switch (chainId) {
|
|
@@ -65703,17 +65890,17 @@ function explorerUrl2(chainId, hash2) {
|
|
|
65703
65890
|
}
|
|
65704
65891
|
async function status2(intentId, opts) {
|
|
65705
65892
|
if (!intentId || intentId.trim() === "") {
|
|
65706
|
-
process.stderr.write(
|
|
65893
|
+
process.stderr.write(import_picocolors16.default.red("\u2715 Missing intent id.\n"));
|
|
65707
65894
|
process.exit(2);
|
|
65708
65895
|
}
|
|
65709
65896
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65710
65897
|
const resolved = await resolveProfile(requested);
|
|
65711
65898
|
if (!resolved) {
|
|
65712
|
-
process.stderr.write(
|
|
65899
|
+
process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65713
65900
|
process.exit(2);
|
|
65714
65901
|
}
|
|
65715
65902
|
if (resolved.autoSelected) {
|
|
65716
|
-
process.stderr.write(
|
|
65903
|
+
process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65717
65904
|
`));
|
|
65718
65905
|
}
|
|
65719
65906
|
const { profile, name: profileName } = resolved;
|
|
@@ -65722,7 +65909,7 @@ async function status2(intentId, opts) {
|
|
|
65722
65909
|
profile,
|
|
65723
65910
|
profileName,
|
|
65724
65911
|
jsonMode: jsonMode5,
|
|
65725
|
-
ttyHeader:
|
|
65912
|
+
ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
65726
65913
|
fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
|
|
65727
65914
|
});
|
|
65728
65915
|
if (outcome.kind === "auth_failed") {
|
|
@@ -65732,7 +65919,7 @@ async function status2(intentId, opts) {
|
|
|
65732
65919
|
);
|
|
65733
65920
|
process.exit(1);
|
|
65734
65921
|
}
|
|
65735
|
-
process.stderr.write(
|
|
65922
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${outcome.reason}.
|
|
65736
65923
|
`));
|
|
65737
65924
|
process.exit(1);
|
|
65738
65925
|
}
|
|
@@ -65740,11 +65927,11 @@ async function status2(intentId, opts) {
|
|
|
65740
65927
|
const err = outcome.error;
|
|
65741
65928
|
if (err instanceof ApiError) {
|
|
65742
65929
|
if (err.status === 404) {
|
|
65743
|
-
process.stderr.write(
|
|
65930
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 No intent with id ${intentId}.
|
|
65744
65931
|
`));
|
|
65745
65932
|
process.exit(1);
|
|
65746
65933
|
}
|
|
65747
|
-
process.stderr.write(
|
|
65934
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65748
65935
|
`));
|
|
65749
65936
|
process.exit(1);
|
|
65750
65937
|
}
|
|
@@ -65755,7 +65942,7 @@ async function status2(intentId, opts) {
|
|
|
65755
65942
|
if (opts.watch && !isTerminalStatus(snap.status)) {
|
|
65756
65943
|
if (!jsonMode5) {
|
|
65757
65944
|
printSnap(snap);
|
|
65758
|
-
process.stdout.write(
|
|
65945
|
+
process.stdout.write(import_picocolors16.default.dim("Watching\u2026\n"));
|
|
65759
65946
|
}
|
|
65760
65947
|
const runWatchPoll = (p) => streamStatusUntilTerminal({
|
|
65761
65948
|
intentId,
|
|
@@ -65766,7 +65953,7 @@ async function status2(intentId, opts) {
|
|
|
65766
65953
|
giveUpMs: WATCH_GIVEUP_MS,
|
|
65767
65954
|
onTick: (s) => {
|
|
65768
65955
|
if (!jsonMode5) {
|
|
65769
|
-
process.stdout.write(` ${
|
|
65956
|
+
process.stdout.write(` ${import_picocolors16.default.dim("\u2192")} ${s.status}
|
|
65770
65957
|
`);
|
|
65771
65958
|
}
|
|
65772
65959
|
}
|
|
@@ -65781,7 +65968,7 @@ async function status2(intentId, opts) {
|
|
|
65781
65968
|
profile: profileName,
|
|
65782
65969
|
jsonMode: jsonMode5,
|
|
65783
65970
|
origin: activeProfile.mcpOrigin,
|
|
65784
|
-
ttyHeader:
|
|
65971
|
+
ttyHeader: import_picocolors16.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
|
|
65785
65972
|
});
|
|
65786
65973
|
} catch (reloginErr) {
|
|
65787
65974
|
if (jsonMode5) {
|
|
@@ -65795,7 +65982,7 @@ async function status2(intentId, opts) {
|
|
|
65795
65982
|
process.exit(1);
|
|
65796
65983
|
}
|
|
65797
65984
|
process.stderr.write(
|
|
65798
|
-
|
|
65985
|
+
import_picocolors16.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65799
65986
|
`)
|
|
65800
65987
|
);
|
|
65801
65988
|
process.exit(1);
|
|
@@ -65803,12 +65990,12 @@ async function status2(intentId, opts) {
|
|
|
65803
65990
|
try {
|
|
65804
65991
|
final = await runWatchPoll(activeProfile);
|
|
65805
65992
|
} catch (retryErr) {
|
|
65806
|
-
process.stderr.write(
|
|
65993
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${retryErr.message}
|
|
65807
65994
|
`));
|
|
65808
65995
|
process.exit(1);
|
|
65809
65996
|
}
|
|
65810
65997
|
} else {
|
|
65811
|
-
process.stderr.write(
|
|
65998
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message}
|
|
65812
65999
|
`));
|
|
65813
66000
|
process.exit(1);
|
|
65814
66001
|
}
|
|
@@ -65829,7 +66016,7 @@ async function status2(intentId, opts) {
|
|
|
65829
66016
|
}
|
|
65830
66017
|
function printSnap(s) {
|
|
65831
66018
|
const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
|
|
65832
|
-
const colorFn = s.status === "mined" ?
|
|
66019
|
+
const colorFn = s.status === "mined" ? import_picocolors16.default.green : s.status === "rejected" || s.status === "expired" || s.status === "failed" ? import_picocolors16.default.red : import_picocolors16.default.cyan;
|
|
65833
66020
|
process.stdout.write(`Intent ${s.approval_id}
|
|
65834
66021
|
`);
|
|
65835
66022
|
process.stdout.write(`Status ${colorFn(s.status)}
|
|
@@ -65844,12 +66031,12 @@ function printSnap(s) {
|
|
|
65844
66031
|
process.stdout.write(`Tx ${s.tx_hash}
|
|
65845
66032
|
`);
|
|
65846
66033
|
if (explorer) {
|
|
65847
|
-
process.stdout.write(`Explorer ${
|
|
66034
|
+
process.stdout.write(`Explorer ${import_picocolors16.default.cyan(explorer)}
|
|
65848
66035
|
`);
|
|
65849
66036
|
}
|
|
65850
66037
|
}
|
|
65851
66038
|
if (!isTerminalStatus(s.status)) {
|
|
65852
|
-
process.stdout.write(`Approve ${
|
|
66039
|
+
process.stdout.write(`Approve ${import_picocolors16.default.cyan(s.approval_url)}
|
|
65853
66040
|
`);
|
|
65854
66041
|
}
|
|
65855
66042
|
process.stdout.write(`Created ${formatDate2(s.created_at)}
|
|
@@ -65866,7 +66053,7 @@ function formatDate2(iso) {
|
|
|
65866
66053
|
}
|
|
65867
66054
|
|
|
65868
66055
|
// src/commands/balance.ts
|
|
65869
|
-
var
|
|
66056
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
65870
66057
|
var CHAIN_ALIASES = {
|
|
65871
66058
|
"1": 1,
|
|
65872
66059
|
ethereum: 1,
|
|
@@ -65889,11 +66076,11 @@ async function balance(opts) {
|
|
|
65889
66076
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65890
66077
|
const resolved = await resolveProfile(requested);
|
|
65891
66078
|
if (!resolved) {
|
|
65892
|
-
process.stderr.write(
|
|
66079
|
+
process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65893
66080
|
process.exit(2);
|
|
65894
66081
|
}
|
|
65895
66082
|
if (resolved.autoSelected) {
|
|
65896
|
-
process.stderr.write(
|
|
66083
|
+
process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65897
66084
|
`));
|
|
65898
66085
|
}
|
|
65899
66086
|
const { profile, name: profileName } = resolved;
|
|
@@ -65903,8 +66090,8 @@ async function balance(opts) {
|
|
|
65903
66090
|
const id2 = CHAIN_ALIASES[key];
|
|
65904
66091
|
if (id2 === void 0) {
|
|
65905
66092
|
process.stderr.write(
|
|
65906
|
-
|
|
65907
|
-
`\u2715 Unknown chain ${
|
|
66093
|
+
import_picocolors17.default.red(
|
|
66094
|
+
`\u2715 Unknown chain ${import_picocolors17.default.bold(opts.chain)}. Supported: ${import_picocolors17.default.bold("1/ethereum")}, ${import_picocolors17.default.bold("137/polygon")}, ${import_picocolors17.default.bold("8453/base")}, ${import_picocolors17.default.bold("42161/arbitrum")}, ${import_picocolors17.default.bold("900/solana")}.
|
|
65908
66095
|
`
|
|
65909
66096
|
)
|
|
65910
66097
|
);
|
|
@@ -65917,7 +66104,7 @@ async function balance(opts) {
|
|
|
65917
66104
|
profile,
|
|
65918
66105
|
profileName,
|
|
65919
66106
|
jsonMode: jsonMode5,
|
|
65920
|
-
ttyHeader:
|
|
66107
|
+
ttyHeader: import_picocolors17.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
65921
66108
|
fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
|
|
65922
66109
|
});
|
|
65923
66110
|
if (outcome.kind === "auth_failed") {
|
|
@@ -65927,14 +66114,14 @@ async function balance(opts) {
|
|
|
65927
66114
|
);
|
|
65928
66115
|
process.exit(1);
|
|
65929
66116
|
}
|
|
65930
|
-
process.stderr.write(
|
|
66117
|
+
process.stderr.write(import_picocolors17.default.red(`\u2715 ${outcome.reason}.
|
|
65931
66118
|
`));
|
|
65932
66119
|
process.exit(1);
|
|
65933
66120
|
}
|
|
65934
66121
|
if (outcome.kind === "error") {
|
|
65935
66122
|
const err = outcome.error;
|
|
65936
66123
|
if (err instanceof ApiError) {
|
|
65937
|
-
process.stderr.write(
|
|
66124
|
+
process.stderr.write(import_picocolors17.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65938
66125
|
`));
|
|
65939
66126
|
process.exit(1);
|
|
65940
66127
|
}
|
|
@@ -65964,7 +66151,7 @@ async function balance(opts) {
|
|
|
65964
66151
|
}
|
|
65965
66152
|
if (filtered.length === 0) {
|
|
65966
66153
|
process.stdout.write(
|
|
65967
|
-
|
|
66154
|
+
import_picocolors17.default.dim(
|
|
65968
66155
|
chainFilter !== null ? `No balances on chain ${chainFilter}.
|
|
65969
66156
|
` : `No chain balances returned.
|
|
65970
66157
|
`
|
|
@@ -65976,7 +66163,7 @@ async function balance(opts) {
|
|
|
65976
66163
|
const errorLines = [];
|
|
65977
66164
|
for (const c of filtered) {
|
|
65978
66165
|
if (c.error) {
|
|
65979
|
-
errorLines.push(`${c.chainName} ${
|
|
66166
|
+
errorLines.push(`${c.chainName} ${import_picocolors17.default.red(`(read failed: ${c.error})`)}`);
|
|
65980
66167
|
continue;
|
|
65981
66168
|
}
|
|
65982
66169
|
if (c.native.balance > 0) {
|
|
@@ -65997,7 +66184,7 @@ async function balance(opts) {
|
|
|
65997
66184
|
}
|
|
65998
66185
|
}
|
|
65999
66186
|
if (rows.length === 0 && errorLines.length === 0) {
|
|
66000
|
-
process.stdout.write(
|
|
66187
|
+
process.stdout.write(import_picocolors17.default.dim(`All balances are zero.
|
|
66001
66188
|
`));
|
|
66002
66189
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
66003
66190
|
return;
|
|
@@ -66007,7 +66194,7 @@ async function balance(opts) {
|
|
|
66007
66194
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
66008
66195
|
const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
|
|
66009
66196
|
const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
|
|
66010
|
-
process.stdout.write(
|
|
66197
|
+
process.stdout.write(import_picocolors17.default.dim(header) + "\n");
|
|
66011
66198
|
for (const r of rows) {
|
|
66012
66199
|
process.stdout.write(
|
|
66013
66200
|
r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
|
|
@@ -66020,7 +66207,7 @@ async function balance(opts) {
|
|
|
66020
66207
|
`);
|
|
66021
66208
|
}
|
|
66022
66209
|
if (res.fetched_at) {
|
|
66023
|
-
process.stdout.write("\n" +
|
|
66210
|
+
process.stdout.write("\n" + import_picocolors17.default.dim(`Fetched ${res.fetched_at}
|
|
66024
66211
|
`));
|
|
66025
66212
|
}
|
|
66026
66213
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -66033,18 +66220,18 @@ function formatBalance(value, decimals) {
|
|
|
66033
66220
|
}
|
|
66034
66221
|
|
|
66035
66222
|
// src/commands/history.ts
|
|
66036
|
-
var
|
|
66223
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
66037
66224
|
var DEFAULT_LIMIT = 20;
|
|
66038
66225
|
var SERVER_MAX_LIMIT = 100;
|
|
66039
66226
|
async function history(opts) {
|
|
66040
66227
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66041
66228
|
const resolved = await resolveProfile(requested);
|
|
66042
66229
|
if (!resolved) {
|
|
66043
|
-
process.stderr.write(
|
|
66230
|
+
process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66044
66231
|
process.exit(2);
|
|
66045
66232
|
}
|
|
66046
66233
|
if (resolved.autoSelected) {
|
|
66047
|
-
process.stderr.write(
|
|
66234
|
+
process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66048
66235
|
`));
|
|
66049
66236
|
}
|
|
66050
66237
|
const { profile, name: profileName } = resolved;
|
|
@@ -66053,14 +66240,14 @@ async function history(opts) {
|
|
|
66053
66240
|
const n2 = Number(opts.limit);
|
|
66054
66241
|
if (!Number.isFinite(n2) || n2 <= 0 || !Number.isInteger(n2)) {
|
|
66055
66242
|
process.stderr.write(
|
|
66056
|
-
|
|
66243
|
+
import_picocolors18.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors18.default.bold(opts.limit)}).
|
|
66057
66244
|
`)
|
|
66058
66245
|
);
|
|
66059
66246
|
process.exit(2);
|
|
66060
66247
|
}
|
|
66061
66248
|
if (n2 > SERVER_MAX_LIMIT) {
|
|
66062
66249
|
process.stderr.write(
|
|
66063
|
-
|
|
66250
|
+
import_picocolors18.default.red(
|
|
66064
66251
|
`\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n2}.
|
|
66065
66252
|
`
|
|
66066
66253
|
)
|
|
@@ -66074,7 +66261,7 @@ async function history(opts) {
|
|
|
66074
66261
|
profile,
|
|
66075
66262
|
profileName,
|
|
66076
66263
|
jsonMode: jsonMode5,
|
|
66077
|
-
ttyHeader:
|
|
66264
|
+
ttyHeader: import_picocolors18.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
66078
66265
|
fn: (bearer, origin) => apiFetch(
|
|
66079
66266
|
`/api/history?limit=${encodeURIComponent(String(limit))}`,
|
|
66080
66267
|
{ bearer, origin }
|
|
@@ -66087,14 +66274,14 @@ async function history(opts) {
|
|
|
66087
66274
|
);
|
|
66088
66275
|
process.exit(1);
|
|
66089
66276
|
}
|
|
66090
|
-
process.stderr.write(
|
|
66277
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${outcome.reason}.
|
|
66091
66278
|
`));
|
|
66092
66279
|
process.exit(1);
|
|
66093
66280
|
}
|
|
66094
66281
|
if (outcome.kind === "error") {
|
|
66095
66282
|
const err = outcome.error;
|
|
66096
66283
|
if (err instanceof ApiError) {
|
|
66097
|
-
process.stderr.write(
|
|
66284
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
66098
66285
|
`));
|
|
66099
66286
|
process.exit(1);
|
|
66100
66287
|
}
|
|
@@ -66111,7 +66298,7 @@ async function history(opts) {
|
|
|
66111
66298
|
return;
|
|
66112
66299
|
}
|
|
66113
66300
|
if (res.txs.length === 0) {
|
|
66114
|
-
process.stdout.write(
|
|
66301
|
+
process.stdout.write(import_picocolors18.default.dim(`No activity yet.
|
|
66115
66302
|
`));
|
|
66116
66303
|
return;
|
|
66117
66304
|
}
|
|
@@ -66131,7 +66318,7 @@ async function history(opts) {
|
|
|
66131
66318
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
66132
66319
|
const colTo = Math.max(2, ...rows.map((r) => r.to.length));
|
|
66133
66320
|
const header = "When".padEnd(colWhen) + " " + "Chain".padEnd(colChain) + " " + "Type".padEnd(colType) + " " + "Amount".padStart(colAmount) + " " + "Asset".padEnd(colAsset) + " " + "To".padEnd(colTo) + " Hash";
|
|
66134
|
-
process.stdout.write(
|
|
66321
|
+
process.stdout.write(import_picocolors18.default.dim(header) + "\n");
|
|
66135
66322
|
for (const r of rows) {
|
|
66136
66323
|
process.stdout.write(
|
|
66137
66324
|
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"
|
|
@@ -66139,7 +66326,7 @@ async function history(opts) {
|
|
|
66139
66326
|
}
|
|
66140
66327
|
if (res.fetched_at) {
|
|
66141
66328
|
process.stdout.write(
|
|
66142
|
-
"\n" +
|
|
66329
|
+
"\n" + import_picocolors18.default.dim(
|
|
66143
66330
|
`Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
|
|
66144
66331
|
`
|
|
66145
66332
|
)
|
|
@@ -66226,10 +66413,10 @@ function prettyType(activityType, status3) {
|
|
|
66226
66413
|
}
|
|
66227
66414
|
|
|
66228
66415
|
// src/commands/swap.ts
|
|
66229
|
-
var
|
|
66416
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
66230
66417
|
|
|
66231
66418
|
// src/lib/intent-flow.ts
|
|
66232
|
-
var
|
|
66419
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
66233
66420
|
var STREAM_GIVEUP_MS = 10 * 6e4;
|
|
66234
66421
|
var SOLANA_CHAIN_ID2 = 900;
|
|
66235
66422
|
function isBlocked2(r) {
|
|
@@ -66304,7 +66491,7 @@ async function runIntentFlow(opts) {
|
|
|
66304
66491
|
profile: opts.profileName,
|
|
66305
66492
|
jsonMode: opts.jsonMode,
|
|
66306
66493
|
origin: activeProfile.mcpOrigin,
|
|
66307
|
-
ttyHeader:
|
|
66494
|
+
ttyHeader: import_picocolors19.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
66308
66495
|
});
|
|
66309
66496
|
} catch (reloginErr) {
|
|
66310
66497
|
if (opts.jsonMode) {
|
|
@@ -66316,7 +66503,7 @@ async function runIntentFlow(opts) {
|
|
|
66316
66503
|
process.exit(1);
|
|
66317
66504
|
}
|
|
66318
66505
|
process.stderr.write(
|
|
66319
|
-
|
|
66506
|
+
import_picocolors19.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
66320
66507
|
`)
|
|
66321
66508
|
);
|
|
66322
66509
|
process.exit(1);
|
|
@@ -66340,7 +66527,7 @@ async function runIntentFlow(opts) {
|
|
|
66340
66527
|
process.exit(1);
|
|
66341
66528
|
}
|
|
66342
66529
|
process.stderr.write(
|
|
66343
|
-
|
|
66530
|
+
import_picocolors19.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
66344
66531
|
`)
|
|
66345
66532
|
);
|
|
66346
66533
|
process.exit(1);
|
|
@@ -66357,7 +66544,7 @@ async function runIntentFlow(opts) {
|
|
|
66357
66544
|
});
|
|
66358
66545
|
process.exit(1);
|
|
66359
66546
|
}
|
|
66360
|
-
process.stderr.write(
|
|
66547
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
66361
66548
|
`));
|
|
66362
66549
|
process.exit(1);
|
|
66363
66550
|
} else {
|
|
@@ -66379,18 +66566,18 @@ async function runIntentFlow(opts) {
|
|
|
66379
66566
|
});
|
|
66380
66567
|
process.exit(1);
|
|
66381
66568
|
}
|
|
66382
|
-
process.stderr.write(
|
|
66569
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
|
|
66383
66570
|
`));
|
|
66384
66571
|
if (proposed.upgrade_url) {
|
|
66385
66572
|
process.stderr.write(
|
|
66386
66573
|
` Open this to grant access, then re-run the command:
|
|
66387
|
-
${
|
|
66574
|
+
${import_picocolors19.default.cyan(proposed.upgrade_url)}
|
|
66388
66575
|
`
|
|
66389
66576
|
);
|
|
66390
66577
|
}
|
|
66391
66578
|
if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
|
|
66392
66579
|
process.stderr.write(
|
|
66393
|
-
|
|
66580
|
+
import_picocolors19.default.dim(
|
|
66394
66581
|
` Suggested actions:
|
|
66395
66582
|
` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
|
|
66396
66583
|
)
|
|
@@ -66413,8 +66600,8 @@ async function runIntentFlow(opts) {
|
|
|
66413
66600
|
} else {
|
|
66414
66601
|
process.stdout.write(
|
|
66415
66602
|
`
|
|
66416
|
-
${
|
|
66417
|
-
${
|
|
66603
|
+
${import_picocolors19.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
66604
|
+
${import_picocolors19.default.cyan(proposed.approval_url)}
|
|
66418
66605
|
|
|
66419
66606
|
`
|
|
66420
66607
|
);
|
|
@@ -66436,7 +66623,7 @@ ${import_picocolors18.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66436
66623
|
if (opts.jsonMode) {
|
|
66437
66624
|
emitNdjson2({ status: s.status, intent_id: s.approval_id });
|
|
66438
66625
|
} else {
|
|
66439
|
-
process.stdout.write(` ${describeStatus2(s.status)}${
|
|
66626
|
+
process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors19.default.dim("\u2026")}\r`);
|
|
66440
66627
|
}
|
|
66441
66628
|
}
|
|
66442
66629
|
});
|
|
@@ -66450,7 +66637,7 @@ ${import_picocolors18.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66450
66637
|
profile: opts.profileName,
|
|
66451
66638
|
jsonMode: opts.jsonMode,
|
|
66452
66639
|
origin: activeProfile.mcpOrigin,
|
|
66453
|
-
ttyHeader:
|
|
66640
|
+
ttyHeader: import_picocolors19.default.dim(
|
|
66454
66641
|
"Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
|
|
66455
66642
|
)
|
|
66456
66643
|
});
|
|
@@ -66465,7 +66652,7 @@ ${import_picocolors18.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66465
66652
|
process.exit(1);
|
|
66466
66653
|
}
|
|
66467
66654
|
process.stderr.write(
|
|
66468
|
-
"\n" +
|
|
66655
|
+
"\n" + import_picocolors19.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
66469
66656
|
`)
|
|
66470
66657
|
);
|
|
66471
66658
|
process.exit(1);
|
|
@@ -66483,7 +66670,7 @@ ${import_picocolors18.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66483
66670
|
process.exit(1);
|
|
66484
66671
|
}
|
|
66485
66672
|
process.stderr.write(
|
|
66486
|
-
"\n" +
|
|
66673
|
+
"\n" + import_picocolors19.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
66487
66674
|
`)
|
|
66488
66675
|
);
|
|
66489
66676
|
process.exit(1);
|
|
@@ -66499,7 +66686,7 @@ ${import_picocolors18.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66499
66686
|
process.exit(1);
|
|
66500
66687
|
}
|
|
66501
66688
|
process.stderr.write(
|
|
66502
|
-
"\n" +
|
|
66689
|
+
"\n" + import_picocolors19.default.red(`\u2715 Status poll failed: ${err.message}
|
|
66503
66690
|
`)
|
|
66504
66691
|
);
|
|
66505
66692
|
process.exit(1);
|
|
@@ -66540,39 +66727,39 @@ ${import_picocolors18.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66540
66727
|
process.stdout.write("\n");
|
|
66541
66728
|
const printLegJournal = () => {
|
|
66542
66729
|
if (legs.length === 0) return;
|
|
66543
|
-
process.stdout.write(
|
|
66730
|
+
process.stdout.write(import_picocolors19.default.bold(" Legs:\n"));
|
|
66544
66731
|
for (const l of legs) {
|
|
66545
|
-
const line = l.status === "mined" ?
|
|
66732
|
+
const line = l.status === "mined" ? import_picocolors19.default.green(`\u2713 leg ${l.index + 1} mined`) + (l.tx_hash ? import_picocolors19.default.dim(` ${l.tx_hash}`) : "") : l.status === "failed" ? import_picocolors19.default.red(`\u2715 leg ${l.index + 1} failed`) + (l.failure?.message ? ` \u2014 ${l.failure.message}` : "") : l.status === "pending" || l.status === "rendered" ? import_picocolors19.default.dim(`\u2013 leg ${l.index + 1} not run`) : import_picocolors19.default.dim(`\u2026 leg ${l.index + 1} ${l.status}`);
|
|
66546
66733
|
process.stdout.write(` ${line}
|
|
66547
66734
|
`);
|
|
66548
66735
|
}
|
|
66549
66736
|
};
|
|
66550
66737
|
if (final.status === "mined") {
|
|
66551
|
-
process.stdout.write(
|
|
66738
|
+
process.stdout.write(import_picocolors19.default.green("\u2713 Mined.") + "\n");
|
|
66552
66739
|
if (final.tx_hash) {
|
|
66553
66740
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
66554
66741
|
`);
|
|
66555
66742
|
}
|
|
66556
66743
|
if (explorer) {
|
|
66557
|
-
process.stdout.write(` Explorer ${
|
|
66744
|
+
process.stdout.write(` Explorer ${import_picocolors19.default.cyan(explorer)}
|
|
66558
66745
|
`);
|
|
66559
66746
|
}
|
|
66560
66747
|
printLegJournal();
|
|
66561
66748
|
process.exit(0);
|
|
66562
66749
|
}
|
|
66563
66750
|
if (final.status === "failed" && failure?.message) {
|
|
66564
|
-
process.stderr.write(
|
|
66751
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${failure.message}
|
|
66565
66752
|
`));
|
|
66566
66753
|
if (retryCommand) {
|
|
66567
66754
|
process.stderr.write(` Retry:
|
|
66568
|
-
${
|
|
66755
|
+
${import_picocolors19.default.cyan(retryCommand)}
|
|
66569
66756
|
`);
|
|
66570
66757
|
}
|
|
66571
66758
|
printLegJournal();
|
|
66572
66759
|
process.exit(1);
|
|
66573
66760
|
}
|
|
66574
66761
|
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}`;
|
|
66575
|
-
process.stderr.write(
|
|
66762
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${label}.
|
|
66576
66763
|
`));
|
|
66577
66764
|
printLegJournal();
|
|
66578
66765
|
process.exit(1);
|
|
@@ -66592,7 +66779,7 @@ function isAsset(v) {
|
|
|
66592
66779
|
return ASSET_VALUES.has(v.toLowerCase());
|
|
66593
66780
|
}
|
|
66594
66781
|
function failArg(msg) {
|
|
66595
|
-
process.stderr.write(
|
|
66782
|
+
process.stderr.write(import_picocolors20.default.red(`\u2715 ${msg}
|
|
66596
66783
|
`));
|
|
66597
66784
|
process.exit(2);
|
|
66598
66785
|
}
|
|
@@ -66600,11 +66787,11 @@ async function swap(amount, fromAsset, opts) {
|
|
|
66600
66787
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66601
66788
|
const resolved = await resolveProfile(requested);
|
|
66602
66789
|
if (!resolved) {
|
|
66603
|
-
process.stderr.write(
|
|
66790
|
+
process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66604
66791
|
process.exit(2);
|
|
66605
66792
|
}
|
|
66606
66793
|
if (resolved.autoSelected) {
|
|
66607
|
-
process.stderr.write(
|
|
66794
|
+
process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66608
66795
|
`));
|
|
66609
66796
|
}
|
|
66610
66797
|
const { profile, name: profileName } = resolved;
|
|
@@ -66612,12 +66799,12 @@ async function swap(amount, fromAsset, opts) {
|
|
|
66612
66799
|
const jsonMode5 = opts.json === true || !stdoutIsTty;
|
|
66613
66800
|
const amountNumber = Number(amount);
|
|
66614
66801
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
66615
|
-
failArg(`amount must be a positive number (got ${
|
|
66802
|
+
failArg(`amount must be a positive number (got ${import_picocolors20.default.bold(amount)}).`);
|
|
66616
66803
|
}
|
|
66617
66804
|
const fromAssetNorm = fromAsset.toLowerCase();
|
|
66618
66805
|
if (!isAsset(fromAssetNorm)) {
|
|
66619
66806
|
failArg(
|
|
66620
|
-
`from-asset must be ${
|
|
66807
|
+
`from-asset must be ${import_picocolors20.default.bold("native")} or ${import_picocolors20.default.bold("usdc")} (got ${import_picocolors20.default.bold(fromAsset)}).`
|
|
66621
66808
|
);
|
|
66622
66809
|
}
|
|
66623
66810
|
if (!opts.toAsset) {
|
|
@@ -66626,7 +66813,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
66626
66813
|
const toAssetNorm = opts.toAsset.toLowerCase();
|
|
66627
66814
|
if (!isAsset(toAssetNorm)) {
|
|
66628
66815
|
failArg(
|
|
66629
|
-
`--to-asset must be ${
|
|
66816
|
+
`--to-asset must be ${import_picocolors20.default.bold("native")} or ${import_picocolors20.default.bold("usdc")} (got ${import_picocolors20.default.bold(opts.toAsset)}).`
|
|
66630
66817
|
);
|
|
66631
66818
|
}
|
|
66632
66819
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -66755,9 +66942,9 @@ async function swap(amount, fromAsset, opts) {
|
|
|
66755
66942
|
}
|
|
66756
66943
|
|
|
66757
66944
|
// src/commands/batch.ts
|
|
66758
|
-
var
|
|
66945
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
66759
66946
|
function failArg2(msg) {
|
|
66760
|
-
process.stderr.write(
|
|
66947
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${msg}
|
|
66761
66948
|
`));
|
|
66762
66949
|
process.exit(2);
|
|
66763
66950
|
}
|
|
@@ -66765,7 +66952,7 @@ async function batch(opts) {
|
|
|
66765
66952
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66766
66953
|
const resolved = await resolveProfile(requested);
|
|
66767
66954
|
if (!resolved) {
|
|
66768
|
-
process.stderr.write(
|
|
66955
|
+
process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66769
66956
|
process.exit(2);
|
|
66770
66957
|
}
|
|
66771
66958
|
const { name: profileName, profile } = resolved;
|
|
@@ -66819,14 +67006,14 @@ async function batch(opts) {
|
|
|
66819
67006
|
}
|
|
66820
67007
|
|
|
66821
67008
|
// src/commands/fund-wallet.ts
|
|
66822
|
-
var
|
|
67009
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
66823
67010
|
var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
|
|
66824
67011
|
var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
66825
67012
|
function isAddressTarget(target) {
|
|
66826
67013
|
return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
|
|
66827
67014
|
}
|
|
66828
67015
|
function failArg3(msg) {
|
|
66829
|
-
process.stderr.write(
|
|
67016
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${msg}
|
|
66830
67017
|
`));
|
|
66831
67018
|
process.exit(2);
|
|
66832
67019
|
}
|
|
@@ -66834,7 +67021,7 @@ async function fundWallet(address, opts) {
|
|
|
66834
67021
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66835
67022
|
const resolved = await resolveProfile(requested);
|
|
66836
67023
|
if (!resolved) {
|
|
66837
|
-
process.stderr.write(
|
|
67024
|
+
process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66838
67025
|
process.exit(2);
|
|
66839
67026
|
}
|
|
66840
67027
|
const { name: profileName, profile } = resolved;
|
|
@@ -66911,11 +67098,11 @@ async function fundWallet(address, opts) {
|
|
|
66911
67098
|
}
|
|
66912
67099
|
|
|
66913
67100
|
// src/commands/earn-supply.ts
|
|
66914
|
-
var
|
|
67101
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
66915
67102
|
var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
66916
67103
|
var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
66917
67104
|
function failArg4(msg) {
|
|
66918
|
-
process.stderr.write(
|
|
67105
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${msg}
|
|
66919
67106
|
`));
|
|
66920
67107
|
process.exit(2);
|
|
66921
67108
|
}
|
|
@@ -66923,11 +67110,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66923
67110
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66924
67111
|
const resolved = await resolveProfile(requested);
|
|
66925
67112
|
if (!resolved) {
|
|
66926
|
-
process.stderr.write(
|
|
67113
|
+
process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66927
67114
|
process.exit(2);
|
|
66928
67115
|
}
|
|
66929
67116
|
if (resolved.autoSelected) {
|
|
66930
|
-
process.stderr.write(
|
|
67117
|
+
process.stderr.write(import_picocolors23.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66931
67118
|
`));
|
|
66932
67119
|
}
|
|
66933
67120
|
const { profile, name: profileName } = resolved;
|
|
@@ -66935,12 +67122,12 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66935
67122
|
const jsonMode5 = opts.json === true || !stdoutIsTty;
|
|
66936
67123
|
const amountNumber = Number(amount);
|
|
66937
67124
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
66938
|
-
failArg4(`amount must be a positive number (got ${
|
|
67125
|
+
failArg4(`amount must be a positive number (got ${import_picocolors23.default.bold(amount)}).`);
|
|
66939
67126
|
}
|
|
66940
67127
|
const assetNorm = asset.toLowerCase();
|
|
66941
67128
|
if (!ASSET_VALUES2.has(assetNorm)) {
|
|
66942
67129
|
failArg4(
|
|
66943
|
-
`asset must be ${
|
|
67130
|
+
`asset must be ${import_picocolors23.default.bold("native")} or ${import_picocolors23.default.bold("usdc")} (got ${import_picocolors23.default.bold(asset)}).`
|
|
66944
67131
|
);
|
|
66945
67132
|
}
|
|
66946
67133
|
if (!opts.chain) {
|
|
@@ -66952,7 +67139,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66952
67139
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
66953
67140
|
if (!PROTOCOLS.has(protocolNorm)) {
|
|
66954
67141
|
failArg4(
|
|
66955
|
-
`--protocol must be ${
|
|
67142
|
+
`--protocol must be ${import_picocolors23.default.bold("aave_v3")} or ${import_picocolors23.default.bold("kamino_lend")} (got ${import_picocolors23.default.bold(opts.protocol)}).`
|
|
66956
67143
|
);
|
|
66957
67144
|
}
|
|
66958
67145
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -67004,11 +67191,11 @@ async function earnSupply(amount, asset, opts) {
|
|
|
67004
67191
|
}
|
|
67005
67192
|
|
|
67006
67193
|
// src/commands/earn-withdraw.ts
|
|
67007
|
-
var
|
|
67194
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
67008
67195
|
var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
67009
67196
|
var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
67010
67197
|
function failArg5(msg) {
|
|
67011
|
-
process.stderr.write(
|
|
67198
|
+
process.stderr.write(import_picocolors24.default.red(`\u2715 ${msg}
|
|
67012
67199
|
`));
|
|
67013
67200
|
process.exit(2);
|
|
67014
67201
|
}
|
|
@@ -67016,11 +67203,11 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
67016
67203
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67017
67204
|
const resolved = await resolveProfile(requested);
|
|
67018
67205
|
if (!resolved) {
|
|
67019
|
-
process.stderr.write(
|
|
67206
|
+
process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67020
67207
|
process.exit(2);
|
|
67021
67208
|
}
|
|
67022
67209
|
if (resolved.autoSelected) {
|
|
67023
|
-
process.stderr.write(
|
|
67210
|
+
process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67024
67211
|
`));
|
|
67025
67212
|
}
|
|
67026
67213
|
const { profile, name: profileName } = resolved;
|
|
@@ -67031,14 +67218,14 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
67031
67218
|
const amountNumber = Number(amountOrMax);
|
|
67032
67219
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
67033
67220
|
failArg5(
|
|
67034
|
-
`<amount-or-max> must be a positive number or the literal string "max" (got ${
|
|
67221
|
+
`<amount-or-max> must be a positive number or the literal string "max" (got ${import_picocolors24.default.bold(amountOrMax)}).`
|
|
67035
67222
|
);
|
|
67036
67223
|
}
|
|
67037
67224
|
}
|
|
67038
67225
|
const assetNorm = asset.toLowerCase();
|
|
67039
67226
|
if (!ASSET_VALUES3.has(assetNorm)) {
|
|
67040
67227
|
failArg5(
|
|
67041
|
-
`asset must be ${
|
|
67228
|
+
`asset must be ${import_picocolors24.default.bold("native")} or ${import_picocolors24.default.bold("usdc")} (got ${import_picocolors24.default.bold(asset)}).`
|
|
67042
67229
|
);
|
|
67043
67230
|
}
|
|
67044
67231
|
if (!opts.chain) {
|
|
@@ -67050,7 +67237,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
67050
67237
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
67051
67238
|
if (!PROTOCOLS2.has(protocolNorm)) {
|
|
67052
67239
|
failArg5(
|
|
67053
|
-
`--protocol must be ${
|
|
67240
|
+
`--protocol must be ${import_picocolors24.default.bold("aave_v3")} or ${import_picocolors24.default.bold("kamino_lend")} (got ${import_picocolors24.default.bold(opts.protocol)}).`
|
|
67054
67241
|
);
|
|
67055
67242
|
}
|
|
67056
67243
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -67102,7 +67289,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
67102
67289
|
}
|
|
67103
67290
|
|
|
67104
67291
|
// src/commands/eat.ts
|
|
67105
|
-
var
|
|
67292
|
+
var import_picocolors25 = __toESM(require_picocolors(), 1);
|
|
67106
67293
|
function parseLineJson(values) {
|
|
67107
67294
|
const lines = [];
|
|
67108
67295
|
for (const value of values) {
|
|
@@ -67129,11 +67316,11 @@ function parseLineJson(values) {
|
|
|
67129
67316
|
async function loadResolvedProfile(requested) {
|
|
67130
67317
|
const resolved = await resolveProfile(requested);
|
|
67131
67318
|
if (!resolved) {
|
|
67132
|
-
process.stderr.write(
|
|
67319
|
+
process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67133
67320
|
process.exit(2);
|
|
67134
67321
|
}
|
|
67135
67322
|
if (resolved.autoSelected) {
|
|
67136
|
-
process.stderr.write(
|
|
67323
|
+
process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67137
67324
|
`));
|
|
67138
67325
|
}
|
|
67139
67326
|
return resolved;
|
|
@@ -67144,12 +67331,12 @@ function printResult(res, jsonMode5) {
|
|
|
67144
67331
|
return;
|
|
67145
67332
|
}
|
|
67146
67333
|
if (res.blocked) {
|
|
67147
|
-
process.stderr.write(
|
|
67334
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
|
|
67148
67335
|
`));
|
|
67149
67336
|
if (res.upgrade_url) {
|
|
67150
67337
|
process.stderr.write(
|
|
67151
67338
|
` Open this to grant access, then re-run the command:
|
|
67152
|
-
${
|
|
67339
|
+
${import_picocolors25.default.cyan(res.upgrade_url)}
|
|
67153
67340
|
`
|
|
67154
67341
|
);
|
|
67155
67342
|
}
|
|
@@ -67180,7 +67367,7 @@ async function postRestaurant(path7, body, resolved, jsonMode5) {
|
|
|
67180
67367
|
profile: resolved.profile,
|
|
67181
67368
|
profileName: resolved.name,
|
|
67182
67369
|
jsonMode: jsonMode5,
|
|
67183
|
-
ttyHeader:
|
|
67370
|
+
ttyHeader: import_picocolors25.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
67184
67371
|
fn: (bearer, origin) => apiFetch(path7, { method: "POST", bearer, origin, body })
|
|
67185
67372
|
});
|
|
67186
67373
|
if (outcome.kind === "auth_failed") {
|
|
@@ -67190,7 +67377,7 @@ async function postRestaurant(path7, body, resolved, jsonMode5) {
|
|
|
67190
67377
|
);
|
|
67191
67378
|
process.exit(1);
|
|
67192
67379
|
}
|
|
67193
|
-
process.stderr.write(
|
|
67380
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${outcome.reason}.
|
|
67194
67381
|
`));
|
|
67195
67382
|
process.exit(1);
|
|
67196
67383
|
}
|
|
@@ -67203,7 +67390,7 @@ async function postRestaurant(path7, body, resolved, jsonMode5) {
|
|
|
67203
67390
|
);
|
|
67204
67391
|
process.exit(1);
|
|
67205
67392
|
}
|
|
67206
|
-
process.stderr.write(
|
|
67393
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
67207
67394
|
`));
|
|
67208
67395
|
process.exit(1);
|
|
67209
67396
|
}
|
|
@@ -67216,7 +67403,7 @@ async function searchFood(opts) {
|
|
|
67216
67403
|
const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
|
|
67217
67404
|
if (!opts.location && !opts.name) {
|
|
67218
67405
|
process.stderr.write(
|
|
67219
|
-
|
|
67406
|
+
import_picocolors25.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
|
|
67220
67407
|
);
|
|
67221
67408
|
process.exit(2);
|
|
67222
67409
|
}
|
|
@@ -67237,7 +67424,7 @@ async function menuFood(items, opts) {
|
|
|
67237
67424
|
const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
|
|
67238
67425
|
if (!opts.brand || !opts.address) {
|
|
67239
67426
|
process.stderr.write(
|
|
67240
|
-
|
|
67427
|
+
import_picocolors25.default.red(
|
|
67241
67428
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
67242
67429
|
)
|
|
67243
67430
|
);
|
|
@@ -67257,7 +67444,7 @@ async function orderFood(items, opts) {
|
|
|
67257
67444
|
const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
|
|
67258
67445
|
if (!opts.brand || !opts.address) {
|
|
67259
67446
|
process.stderr.write(
|
|
67260
|
-
|
|
67447
|
+
import_picocolors25.default.red(
|
|
67261
67448
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
67262
67449
|
)
|
|
67263
67450
|
);
|
|
@@ -67267,14 +67454,14 @@ async function orderFood(items, opts) {
|
|
|
67267
67454
|
try {
|
|
67268
67455
|
structuredLines = parseLineJson(opts.lineJson ?? []);
|
|
67269
67456
|
} catch (e) {
|
|
67270
|
-
process.stderr.write(
|
|
67457
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
|
|
67271
67458
|
`));
|
|
67272
67459
|
process.exit(2);
|
|
67273
67460
|
}
|
|
67274
67461
|
const lines = [...items ?? [], ...structuredLines];
|
|
67275
67462
|
if (lines.length === 0) {
|
|
67276
67463
|
process.stderr.write(
|
|
67277
|
-
|
|
67464
|
+
import_picocolors25.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")
|
|
67278
67465
|
);
|
|
67279
67466
|
process.exit(2);
|
|
67280
67467
|
}
|
|
@@ -67308,7 +67495,7 @@ async function orderFood(items, opts) {
|
|
|
67308
67495
|
if (!agentCard.will_attempt) {
|
|
67309
67496
|
if (!jsonMode5) {
|
|
67310
67497
|
process.stderr.write(
|
|
67311
|
-
|
|
67498
|
+
import_picocolors25.default.yellow(
|
|
67312
67499
|
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
67313
67500
|
`
|
|
67314
67501
|
)
|
|
@@ -67325,7 +67512,7 @@ async function orderFood(items, opts) {
|
|
|
67325
67512
|
}
|
|
67326
67513
|
if (verdict.status === "paid") {
|
|
67327
67514
|
process.stdout.write(
|
|
67328
|
-
|
|
67515
|
+
import_picocolors25.default.green(
|
|
67329
67516
|
`Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
|
|
67330
67517
|
)
|
|
67331
67518
|
);
|
|
@@ -67333,7 +67520,7 @@ async function orderFood(items, opts) {
|
|
|
67333
67520
|
}
|
|
67334
67521
|
if (verdict.status === "failed") {
|
|
67335
67522
|
process.stderr.write(
|
|
67336
|
-
|
|
67523
|
+
import_picocolors25.default.yellow(
|
|
67337
67524
|
`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.
|
|
67338
67525
|
`
|
|
67339
67526
|
)
|
|
@@ -67343,7 +67530,7 @@ async function orderFood(items, opts) {
|
|
|
67343
67530
|
}
|
|
67344
67531
|
if (verdict.status === "unconfirmed") {
|
|
67345
67532
|
process.stderr.write(
|
|
67346
|
-
|
|
67533
|
+
import_picocolors25.default.red(
|
|
67347
67534
|
"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}
|
|
67348
67535
|
` : "")
|
|
67349
67536
|
)
|
|
@@ -67352,7 +67539,7 @@ async function orderFood(items, opts) {
|
|
|
67352
67539
|
return;
|
|
67353
67540
|
}
|
|
67354
67541
|
process.stderr.write(
|
|
67355
|
-
|
|
67542
|
+
import_picocolors25.default.dim(
|
|
67356
67543
|
`Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
|
|
67357
67544
|
)
|
|
67358
67545
|
);
|
|
@@ -67377,7 +67564,7 @@ var POLL_BUDGET_MS = 1e5;
|
|
|
67377
67564
|
var POLL_INTERVAL_MS2 = 3500;
|
|
67378
67565
|
async function pollOrderVerdict(orderId, resolved, jsonMode5) {
|
|
67379
67566
|
if (!jsonMode5) {
|
|
67380
|
-
process.stderr.write(
|
|
67567
|
+
process.stderr.write(import_picocolors25.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
|
|
67381
67568
|
}
|
|
67382
67569
|
const deadline = Date.now() + POLL_BUDGET_MS;
|
|
67383
67570
|
let last = {
|
|
@@ -67447,16 +67634,16 @@ async function statusFood(orderId, opts) {
|
|
|
67447
67634
|
}
|
|
67448
67635
|
|
|
67449
67636
|
// src/commands/bounties.ts
|
|
67450
|
-
var
|
|
67637
|
+
var import_picocolors26 = __toESM(require_picocolors(), 1);
|
|
67451
67638
|
async function withProfile(opts, path7, init2) {
|
|
67452
67639
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67453
67640
|
const resolved = await resolveProfile(requested);
|
|
67454
67641
|
if (!resolved) {
|
|
67455
|
-
process.stderr.write(
|
|
67642
|
+
process.stderr.write(import_picocolors26.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67456
67643
|
process.exit(2);
|
|
67457
67644
|
}
|
|
67458
67645
|
if (resolved.autoSelected) {
|
|
67459
|
-
process.stderr.write(
|
|
67646
|
+
process.stderr.write(import_picocolors26.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67460
67647
|
`));
|
|
67461
67648
|
}
|
|
67462
67649
|
const { profile, name: profileName } = resolved;
|
|
@@ -67465,7 +67652,7 @@ async function withProfile(opts, path7, init2) {
|
|
|
67465
67652
|
profile,
|
|
67466
67653
|
profileName,
|
|
67467
67654
|
jsonMode: jsonMode5,
|
|
67468
|
-
ttyHeader:
|
|
67655
|
+
ttyHeader: import_picocolors26.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
67469
67656
|
fn: (bearer, origin) => apiFetch(path7, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
|
|
67470
67657
|
});
|
|
67471
67658
|
if (outcome.kind === "auth_failed") {
|
|
@@ -67473,14 +67660,14 @@ async function withProfile(opts, path7, init2) {
|
|
|
67473
67660
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
67474
67661
|
process.exit(1);
|
|
67475
67662
|
}
|
|
67476
|
-
process.stderr.write(
|
|
67663
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 ${outcome.reason}.
|
|
67477
67664
|
`));
|
|
67478
67665
|
process.exit(1);
|
|
67479
67666
|
}
|
|
67480
67667
|
if (outcome.kind === "error") {
|
|
67481
67668
|
const err = outcome.error;
|
|
67482
67669
|
if (err instanceof ApiError) {
|
|
67483
|
-
process.stderr.write(
|
|
67670
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
67484
67671
|
`));
|
|
67485
67672
|
process.exit(1);
|
|
67486
67673
|
}
|
|
@@ -67494,12 +67681,12 @@ function handleBlocked(res, jsonMode5) {
|
|
|
67494
67681
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
67495
67682
|
process.exit(1);
|
|
67496
67683
|
}
|
|
67497
|
-
process.stderr.write(
|
|
67684
|
+
process.stderr.write(import_picocolors26.default.yellow(`
|
|
67498
67685
|
${res.reason ?? "Blocked."}
|
|
67499
67686
|
`));
|
|
67500
67687
|
if (res.upgrade_url) {
|
|
67501
67688
|
process.stderr.write(`
|
|
67502
|
-
${
|
|
67689
|
+
${import_picocolors26.default.bold(res.upgrade_url)}
|
|
67503
67690
|
|
|
67504
67691
|
`);
|
|
67505
67692
|
}
|
|
@@ -67542,14 +67729,14 @@ function printTable(rows) {
|
|
|
67542
67729
|
const cLeft = w("left", 4);
|
|
67543
67730
|
const cSubs = w("subs", 4);
|
|
67544
67731
|
process.stdout.write(
|
|
67545
|
-
|
|
67732
|
+
import_picocolors26.default.dim(
|
|
67546
67733
|
"Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
|
|
67547
67734
|
) + "\n"
|
|
67548
67735
|
);
|
|
67549
67736
|
for (const c of cells) {
|
|
67550
|
-
const title = c.live ?
|
|
67737
|
+
const title = c.live ? import_picocolors26.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
|
|
67551
67738
|
process.stdout.write(
|
|
67552
|
-
|
|
67739
|
+
import_picocolors26.default.bold(c.amount.padStart(cAmount)) + " " + title + " " + c.chain.padEnd(cChain) + " " + c.ev.padEnd(cEv) + " " + c.left.padStart(cLeft) + " " + c.subs.padStart(cSubs) + " " + import_picocolors26.default.dim(c.id) + "\n"
|
|
67553
67740
|
);
|
|
67554
67741
|
}
|
|
67555
67742
|
}
|
|
@@ -67561,11 +67748,11 @@ async function listBounties(opts) {
|
|
|
67561
67748
|
const min = opts.min !== void 0 ? Number(opts.min) : void 0;
|
|
67562
67749
|
const max = opts.max !== void 0 ? Number(opts.max) : void 0;
|
|
67563
67750
|
if (min !== void 0 && !Number.isFinite(min)) {
|
|
67564
|
-
process.stderr.write(
|
|
67751
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 --min must be a number.\n"));
|
|
67565
67752
|
process.exit(2);
|
|
67566
67753
|
}
|
|
67567
67754
|
if (max !== void 0 && !Number.isFinite(max)) {
|
|
67568
|
-
process.stderr.write(
|
|
67755
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 --max must be a number.\n"));
|
|
67569
67756
|
process.exit(2);
|
|
67570
67757
|
}
|
|
67571
67758
|
rows = rows.filter((r) => {
|
|
@@ -67590,7 +67777,7 @@ async function listBounties(opts) {
|
|
|
67590
67777
|
});
|
|
67591
67778
|
const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
|
|
67592
67779
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
67593
|
-
process.stderr.write(
|
|
67780
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 --limit must be a positive number.\n"));
|
|
67594
67781
|
process.exit(2);
|
|
67595
67782
|
}
|
|
67596
67783
|
const shown2 = rows.slice(0, limit);
|
|
@@ -67599,13 +67786,13 @@ async function listBounties(opts) {
|
|
|
67599
67786
|
return;
|
|
67600
67787
|
}
|
|
67601
67788
|
if (shown2.length === 0) {
|
|
67602
|
-
process.stdout.write(
|
|
67789
|
+
process.stdout.write(import_picocolors26.default.dim("No active bounties match.\n"));
|
|
67603
67790
|
return;
|
|
67604
67791
|
}
|
|
67605
67792
|
printTable(shown2);
|
|
67606
67793
|
const clipped = rows.length - shown2.length;
|
|
67607
67794
|
process.stdout.write(
|
|
67608
|
-
"\n" +
|
|
67795
|
+
"\n" + import_picocolors26.default.dim(
|
|
67609
67796
|
`${shown2.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
|
|
67610
67797
|
`
|
|
67611
67798
|
)
|
|
@@ -67616,7 +67803,7 @@ async function showBounty(id2, opts) {
|
|
|
67616
67803
|
const jsonMode5 = opts.json === true;
|
|
67617
67804
|
const clean = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
|
|
67618
67805
|
if (!clean) {
|
|
67619
|
-
process.stderr.write(
|
|
67806
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
|
|
67620
67807
|
process.exit(2);
|
|
67621
67808
|
}
|
|
67622
67809
|
const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean)}`);
|
|
@@ -67627,26 +67814,26 @@ async function showBounty(id2, opts) {
|
|
|
67627
67814
|
}
|
|
67628
67815
|
const b2 = res.bounty;
|
|
67629
67816
|
if (!b2) {
|
|
67630
|
-
process.stdout.write(
|
|
67817
|
+
process.stdout.write(import_picocolors26.default.dim("Not found.\n"));
|
|
67631
67818
|
return;
|
|
67632
67819
|
}
|
|
67633
|
-
process.stdout.write("\n" +
|
|
67820
|
+
process.stdout.write("\n" + import_picocolors26.default.bold(b2.title) + "\n\n");
|
|
67634
67821
|
process.stdout.write(b2.description + "\n\n");
|
|
67635
67822
|
process.stdout.write(
|
|
67636
|
-
|
|
67823
|
+
import_picocolors26.default.bold(fmtAmount(b2.amount)) + import_picocolors26.default.dim(" USDC") + import_picocolors26.default.dim(` \xB7 ${chainOf2(b2)} \xB7 ${b2.status.toLowerCase()}`) + (b2.liveNow ? import_picocolors26.default.green(" \xB7 LIVE now") : "") + "\n"
|
|
67637
67824
|
);
|
|
67638
67825
|
if (b2.claimsAllowed && b2.claimsAllowed > 1) {
|
|
67639
67826
|
const left = Math.max(0, b2.claimsAllowed - (b2.claimsPaid ?? 0));
|
|
67640
67827
|
process.stdout.write(
|
|
67641
|
-
|
|
67828
|
+
import_picocolors26.default.dim(
|
|
67642
67829
|
`${left} of ${b2.claimsAllowed} claims left` + (b2.perClaimAmount != null ? `, ${fmtAmount(b2.perClaimAmount)} each` : "")
|
|
67643
67830
|
) + "\n"
|
|
67644
67831
|
);
|
|
67645
67832
|
}
|
|
67646
|
-
if (b2.evidenceType) process.stdout.write(
|
|
67647
|
-
if (b2.expiresAt) process.stdout.write(
|
|
67833
|
+
if (b2.evidenceType) process.stdout.write(import_picocolors26.default.dim(`Evidence required: ${b2.evidenceType}`) + "\n");
|
|
67834
|
+
if (b2.expiresAt) process.stdout.write(import_picocolors26.default.dim(`Expires in ${fmtExpiry(b2.expiresAt)}`) + "\n");
|
|
67648
67835
|
if (b2.geoLabel && b2.geoScope !== "global") {
|
|
67649
|
-
process.stdout.write(
|
|
67836
|
+
process.stdout.write(import_picocolors26.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
|
|
67650
67837
|
}
|
|
67651
67838
|
if (res.url) process.stdout.write("\n" + res.url + "\n");
|
|
67652
67839
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -67664,7 +67851,7 @@ async function myBounties(opts) {
|
|
|
67664
67851
|
}
|
|
67665
67852
|
if (rows.length === 0) {
|
|
67666
67853
|
process.stdout.write(
|
|
67667
|
-
|
|
67854
|
+
import_picocolors26.default.dim(
|
|
67668
67855
|
status3 ? `No bounties of yours are ${status3}.
|
|
67669
67856
|
` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
|
|
67670
67857
|
)
|
|
@@ -67674,7 +67861,7 @@ async function myBounties(opts) {
|
|
|
67674
67861
|
printTable(rows);
|
|
67675
67862
|
const subs = res.submissions ?? [];
|
|
67676
67863
|
if (subs.length > 0) {
|
|
67677
|
-
process.stdout.write("\n" +
|
|
67864
|
+
process.stdout.write("\n" + import_picocolors26.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
|
|
67678
67865
|
`));
|
|
67679
67866
|
}
|
|
67680
67867
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -67693,19 +67880,19 @@ async function bountyFeed(opts) {
|
|
|
67693
67880
|
}
|
|
67694
67881
|
const subs = res.submissions ?? [];
|
|
67695
67882
|
if (subs.length === 0) {
|
|
67696
|
-
process.stdout.write(
|
|
67883
|
+
process.stdout.write(import_picocolors26.default.dim("Nothing in the feed for that filter.\n"));
|
|
67697
67884
|
return;
|
|
67698
67885
|
}
|
|
67699
67886
|
process.stdout.write(
|
|
67700
|
-
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ?
|
|
67887
|
+
`${subs.length} submission(s) shown of ${res.total ?? subs.length} total.` + (res.hasMore ? import_picocolors26.default.dim(" More available.") : "") + "\n"
|
|
67701
67888
|
);
|
|
67702
|
-
process.stdout.write(
|
|
67889
|
+
process.stdout.write(import_picocolors26.default.dim("Use --json for the full rows.\n"));
|
|
67703
67890
|
}
|
|
67704
67891
|
async function draftBounty(opts) {
|
|
67705
67892
|
const jsonMode5 = opts.json === true;
|
|
67706
67893
|
const amountNum = Number(opts.amount);
|
|
67707
67894
|
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
67708
|
-
process.stderr.write(
|
|
67895
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 --amount must be a positive number of USDC.\n"));
|
|
67709
67896
|
process.exit(2);
|
|
67710
67897
|
}
|
|
67711
67898
|
const res = await withProfile(opts, "/api/bounties", {
|
|
@@ -67723,20 +67910,20 @@ async function draftBounty(opts) {
|
|
|
67723
67910
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
67724
67911
|
return;
|
|
67725
67912
|
}
|
|
67726
|
-
process.stdout.write("\n" +
|
|
67913
|
+
process.stdout.write("\n" + import_picocolors26.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
|
|
67727
67914
|
|
|
67728
67915
|
`);
|
|
67729
|
-
process.stdout.write(
|
|
67916
|
+
process.stdout.write(import_picocolors26.default.dim("It is a draft. Nobody can see or claim it until you fund the escrow.\n"));
|
|
67730
67917
|
if (res.fund_url) {
|
|
67731
|
-
process.stdout.write("\nFund it here:\n" +
|
|
67732
|
-
process.stdout.write(
|
|
67918
|
+
process.stdout.write("\nFund it here:\n" + import_picocolors26.default.bold(res.fund_url) + "\n\n");
|
|
67919
|
+
process.stdout.write(import_picocolors26.default.dim("Funding happens in your browser with your own wallet.\n"));
|
|
67733
67920
|
}
|
|
67734
67921
|
}
|
|
67735
67922
|
|
|
67736
67923
|
// src/commands/bounty-money.ts
|
|
67737
|
-
var
|
|
67924
|
+
var import_picocolors27 = __toESM(require_picocolors(), 1);
|
|
67738
67925
|
function failArg6(message) {
|
|
67739
|
-
process.stderr.write(
|
|
67926
|
+
process.stderr.write(import_picocolors27.default.red(`${message}
|
|
67740
67927
|
`));
|
|
67741
67928
|
process.exit(2);
|
|
67742
67929
|
}
|
|
@@ -67748,12 +67935,12 @@ async function loadProfileOrExit(requested, jsonMode5) {
|
|
|
67748
67935
|
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
|
|
67749
67936
|
);
|
|
67750
67937
|
} else {
|
|
67751
|
-
process.stderr.write(
|
|
67938
|
+
process.stderr.write(import_picocolors27.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67752
67939
|
}
|
|
67753
67940
|
process.exit(2);
|
|
67754
67941
|
}
|
|
67755
67942
|
if (resolved.autoSelected && !jsonMode5) {
|
|
67756
|
-
process.stderr.write(
|
|
67943
|
+
process.stderr.write(import_picocolors27.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67757
67944
|
`));
|
|
67758
67945
|
}
|
|
67759
67946
|
return { profile: resolved.profile, profileName: resolved.name };
|
|
@@ -67858,16 +68045,16 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
67858
68045
|
}
|
|
67859
68046
|
|
|
67860
68047
|
// src/commands/bounty-work.ts
|
|
67861
|
-
var
|
|
68048
|
+
var import_picocolors28 = __toESM(require_picocolors(), 1);
|
|
67862
68049
|
async function runWork(path7, body, opts) {
|
|
67863
68050
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67864
68051
|
const resolved = await resolveProfile(requested);
|
|
67865
68052
|
if (!resolved) {
|
|
67866
|
-
process.stderr.write(
|
|
68053
|
+
process.stderr.write(import_picocolors28.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67867
68054
|
process.exit(2);
|
|
67868
68055
|
}
|
|
67869
68056
|
if (resolved.autoSelected) {
|
|
67870
|
-
process.stderr.write(
|
|
68057
|
+
process.stderr.write(import_picocolors28.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67871
68058
|
`));
|
|
67872
68059
|
}
|
|
67873
68060
|
const jsonMode5 = opts.json === true;
|
|
@@ -67875,7 +68062,7 @@ async function runWork(path7, body, opts) {
|
|
|
67875
68062
|
profile: resolved.profile,
|
|
67876
68063
|
profileName: resolved.name,
|
|
67877
68064
|
jsonMode: jsonMode5,
|
|
67878
|
-
ttyHeader:
|
|
68065
|
+
ttyHeader: import_picocolors28.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
67879
68066
|
fn: (bearer, origin) => apiFetch(path7, { bearer, origin, method: "POST", body })
|
|
67880
68067
|
});
|
|
67881
68068
|
if (outcome.kind === "auth_failed") {
|
|
@@ -67883,7 +68070,7 @@ async function runWork(path7, body, opts) {
|
|
|
67883
68070
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
67884
68071
|
process.exit(1);
|
|
67885
68072
|
}
|
|
67886
|
-
process.stderr.write(
|
|
68073
|
+
process.stderr.write(import_picocolors28.default.red(`\u2715 ${outcome.reason}.
|
|
67887
68074
|
`));
|
|
67888
68075
|
process.exit(1);
|
|
67889
68076
|
}
|
|
@@ -67893,7 +68080,7 @@ async function runWork(path7, body, opts) {
|
|
|
67893
68080
|
if (jsonMode5) {
|
|
67894
68081
|
process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
|
|
67895
68082
|
} else {
|
|
67896
|
-
process.stderr.write(
|
|
68083
|
+
process.stderr.write(import_picocolors28.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
67897
68084
|
`));
|
|
67898
68085
|
}
|
|
67899
68086
|
process.exit(1);
|
|
@@ -67906,11 +68093,11 @@ async function runWork(path7, body, opts) {
|
|
|
67906
68093
|
process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
|
|
67907
68094
|
process.exit(1);
|
|
67908
68095
|
}
|
|
67909
|
-
process.stderr.write(
|
|
68096
|
+
process.stderr.write(import_picocolors28.default.yellow(`
|
|
67910
68097
|
${data4.reason ?? "Blocked."}
|
|
67911
68098
|
`));
|
|
67912
68099
|
if (data4.upgrade_url) process.stderr.write(`
|
|
67913
|
-
${
|
|
68100
|
+
${import_picocolors28.default.bold(data4.upgrade_url)}
|
|
67914
68101
|
|
|
67915
68102
|
`);
|
|
67916
68103
|
process.exit(1);
|
|
@@ -67919,7 +68106,7 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
|
|
|
67919
68106
|
if (jsonMode5) {
|
|
67920
68107
|
process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
|
|
67921
68108
|
} else {
|
|
67922
|
-
process.stderr.write(
|
|
68109
|
+
process.stderr.write(import_picocolors28.default.red(`\u2715 ${data4.error}
|
|
67923
68110
|
`));
|
|
67924
68111
|
}
|
|
67925
68112
|
process.exit(1);
|
|
@@ -67962,7 +68149,7 @@ async function bountyRetention(bountyId, opts) {
|
|
|
67962
68149
|
}
|
|
67963
68150
|
|
|
67964
68151
|
// src/commands/bounty-deliver.ts
|
|
67965
|
-
var
|
|
68152
|
+
var import_picocolors29 = __toESM(require_picocolors(), 1);
|
|
67966
68153
|
import { spawn as spawn2 } from "node:child_process";
|
|
67967
68154
|
var FLUSH_MS = 400;
|
|
67968
68155
|
var FLUSH_BYTES = 2048;
|
|
@@ -67971,11 +68158,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
67971
68158
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67972
68159
|
const resolved = await resolveProfile(requested);
|
|
67973
68160
|
if (!resolved) {
|
|
67974
|
-
process.stderr.write(
|
|
68161
|
+
process.stderr.write(import_picocolors29.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67975
68162
|
process.exit(2);
|
|
67976
68163
|
}
|
|
67977
68164
|
if (resolved.autoSelected && !jsonMode5) {
|
|
67978
|
-
process.stderr.write(
|
|
68165
|
+
process.stderr.write(import_picocolors29.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67979
68166
|
`));
|
|
67980
68167
|
}
|
|
67981
68168
|
const post = async (path7, body) => {
|
|
@@ -67983,7 +68170,7 @@ async function deliver(bountyId, command, opts) {
|
|
|
67983
68170
|
profile: resolved.profile,
|
|
67984
68171
|
profileName: resolved.name,
|
|
67985
68172
|
jsonMode: jsonMode5,
|
|
67986
|
-
ttyHeader:
|
|
68173
|
+
ttyHeader: import_picocolors29.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
67987
68174
|
fn: (bearer, origin) => apiFetch(path7, { bearer, origin, method: "POST", body })
|
|
67988
68175
|
});
|
|
67989
68176
|
if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
|
|
@@ -67994,11 +68181,11 @@ async function deliver(bountyId, command, opts) {
|
|
|
67994
68181
|
if (jsonMode5) {
|
|
67995
68182
|
process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
|
|
67996
68183
|
} else {
|
|
67997
|
-
process.stderr.write(
|
|
68184
|
+
process.stderr.write(import_picocolors29.default.red(`
|
|
67998
68185
|
\u2715 ${msg}
|
|
67999
68186
|
`));
|
|
68000
68187
|
if (data4?.upgrade_url) process.stderr.write(`
|
|
68001
|
-
${
|
|
68188
|
+
${import_picocolors29.default.bold(data4.upgrade_url)}
|
|
68002
68189
|
|
|
68003
68190
|
`);
|
|
68004
68191
|
}
|
|
@@ -68023,7 +68210,7 @@ ${import_picocolors28.default.bold(data4.upgrade_url)}
|
|
|
68023
68210
|
if (!runId) return void die("The service opened a run but did not name it.");
|
|
68024
68211
|
if (!jsonMode5) {
|
|
68025
68212
|
process.stderr.write(
|
|
68026
|
-
|
|
68213
|
+
import_picocolors29.default.bold("\n\u25CF LIVE ") + import_picocolors29.default.dim("everything below is going onto the bounty page as it happens\n") + import_picocolors29.default.dim(` ${started.url ?? ""}
|
|
68027
68214
|
|
|
68028
68215
|
`)
|
|
68029
68216
|
);
|
|
@@ -68075,10 +68262,10 @@ ${import_picocolors28.default.bold(data4.upgrade_url)}
|
|
|
68075
68262
|
child.stdout.on("data", (d) => consume(d));
|
|
68076
68263
|
child.stderr.setEncoding("utf8");
|
|
68077
68264
|
child.stderr.on("data", (d) => {
|
|
68078
|
-
if (!jsonMode5) process.stderr.write(
|
|
68265
|
+
if (!jsonMode5) process.stderr.write(import_picocolors29.default.dim(d));
|
|
68079
68266
|
});
|
|
68080
68267
|
child.on("error", (err) => {
|
|
68081
|
-
process.stderr.write(
|
|
68268
|
+
process.stderr.write(import_picocolors29.default.red(`
|
|
68082
68269
|
\u2715 Could not run ${command[0]}: ${err.message}
|
|
68083
68270
|
`));
|
|
68084
68271
|
resolve2(127);
|
|
@@ -68115,14 +68302,14 @@ ${import_picocolors28.default.bold(data4.upgrade_url)}
|
|
|
68115
68302
|
}
|
|
68116
68303
|
if (appendFailure) {
|
|
68117
68304
|
process.stderr.write(
|
|
68118
|
-
|
|
68305
|
+
import_picocolors29.default.yellow(`
|
|
68119
68306
|
! Some output did not reach the page: ${appendFailure}
|
|
68120
|
-
`) +
|
|
68307
|
+
`) + import_picocolors29.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
|
|
68121
68308
|
);
|
|
68122
68309
|
}
|
|
68123
68310
|
if (exitCode) {
|
|
68124
68311
|
process.stderr.write(
|
|
68125
|
-
|
|
68312
|
+
import_picocolors29.default.yellow(`
|
|
68126
68313
|
! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
|
|
68127
68314
|
`)
|
|
68128
68315
|
);
|
|
@@ -68132,7 +68319,7 @@ ${import_picocolors28.default.bold(data4.upgrade_url)}
|
|
|
68132
68319
|
}
|
|
68133
68320
|
|
|
68134
68321
|
// src/commands/trade.ts
|
|
68135
|
-
var
|
|
68322
|
+
var import_picocolors30 = __toESM(require_picocolors(), 1);
|
|
68136
68323
|
|
|
68137
68324
|
// src/lib/trade-sol.ts
|
|
68138
68325
|
var import_web3 = __toESM(require_index_cjs(), 1);
|
|
@@ -68494,11 +68681,11 @@ async function runTrade(args) {
|
|
|
68494
68681
|
}
|
|
68495
68682
|
|
|
68496
68683
|
// src/commands/trade.ts
|
|
68497
|
-
function
|
|
68684
|
+
function fail2(message, json2) {
|
|
68498
68685
|
if (json2) {
|
|
68499
68686
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
68500
68687
|
} else {
|
|
68501
|
-
process.stderr.write(
|
|
68688
|
+
process.stderr.write(import_picocolors30.default.red(`\u2715 ${message}
|
|
68502
68689
|
`));
|
|
68503
68690
|
}
|
|
68504
68691
|
process.exit(1);
|
|
@@ -68508,7 +68695,7 @@ async function withContext(opts, fn) {
|
|
|
68508
68695
|
const ctx2 = await resolveTradeContext();
|
|
68509
68696
|
return await fn(ctx2);
|
|
68510
68697
|
} catch (err) {
|
|
68511
|
-
|
|
68698
|
+
fail2(err.message, opts.json);
|
|
68512
68699
|
}
|
|
68513
68700
|
}
|
|
68514
68701
|
function servedFloorUnits(ctx2) {
|
|
@@ -68534,7 +68721,7 @@ async function tradeKey(opts) {
|
|
|
68534
68721
|
];
|
|
68535
68722
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
68536
68723
|
} catch (err) {
|
|
68537
|
-
|
|
68724
|
+
fail2(err.message, opts.json);
|
|
68538
68725
|
}
|
|
68539
68726
|
}
|
|
68540
68727
|
async function tradeStatus(opts) {
|
|
@@ -68591,7 +68778,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
68591
68778
|
const coin = await resolveCoin(coinArg);
|
|
68592
68779
|
const amountNumber = Number(amount);
|
|
68593
68780
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
68594
|
-
|
|
68781
|
+
fail2(`Amount "${amount}" is not a positive number.`, opts.json);
|
|
68595
68782
|
}
|
|
68596
68783
|
const res = await fetch(`${CREATORS_ORIGIN}/api/launch-quote`, {
|
|
68597
68784
|
method: "POST",
|
|
@@ -68605,7 +68792,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
68605
68792
|
});
|
|
68606
68793
|
const body = await res.json().catch(() => null);
|
|
68607
68794
|
if (!res.ok || !body) {
|
|
68608
|
-
|
|
68795
|
+
fail2(`Quote failed: ${body?.error ?? `HTTP ${res.status}`}`, opts.json);
|
|
68609
68796
|
}
|
|
68610
68797
|
const floor = servedFloorUnits(ctx2);
|
|
68611
68798
|
const belowFloor = side === "buy" && floor !== null && parseDecimalToUnits(amount, USDC_DECIMALS, "Amount") < floor.units;
|
|
@@ -68680,16 +68867,16 @@ async function tradeBuy(coinArg, amount, opts) {
|
|
|
68680
68867
|
try {
|
|
68681
68868
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
|
|
68682
68869
|
} catch (err) {
|
|
68683
|
-
|
|
68870
|
+
fail2(err.message, opts.json);
|
|
68684
68871
|
}
|
|
68685
|
-
if (units <= 0n)
|
|
68872
|
+
if (units <= 0n) fail2("Buy amount must be above zero.", opts.json);
|
|
68686
68873
|
const floor = servedFloorUnits(ctx2);
|
|
68687
68874
|
if (floor && units < floor.units) {
|
|
68688
|
-
|
|
68875
|
+
fail2(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
68689
68876
|
}
|
|
68690
68877
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
68691
68878
|
if (created && !opts.json) {
|
|
68692
|
-
process.stderr.write(
|
|
68879
|
+
process.stderr.write(import_picocolors30.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
68693
68880
|
`));
|
|
68694
68881
|
}
|
|
68695
68882
|
const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
@@ -68700,23 +68887,23 @@ async function tradeSell(coinArg, amount, opts) {
|
|
|
68700
68887
|
await withContext(opts, async (ctx2) => {
|
|
68701
68888
|
const coin = await resolveCoin(coinArg);
|
|
68702
68889
|
const key = await loadTradeKey();
|
|
68703
|
-
if (!key)
|
|
68890
|
+
if (!key) fail2("No agent trading key yet (nothing to sell with). Run: agentgates trade key", opts.json);
|
|
68704
68891
|
let sellAmount = amount.trim();
|
|
68705
68892
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
68706
68893
|
if (sellAmount === "all" || pct) {
|
|
68707
68894
|
const bal = await readTokenBalance(rpcConnection(), key.state.address, coin.mint);
|
|
68708
|
-
if (!bal)
|
|
68709
|
-
if (bal.units <= 0n)
|
|
68895
|
+
if (!bal) fail2("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
|
|
68896
|
+
if (bal.units <= 0n) fail2("This key holds none of that coin.", opts.json);
|
|
68710
68897
|
let units = bal.units;
|
|
68711
68898
|
if (pct) {
|
|
68712
68899
|
const p = BigInt(pct[1]);
|
|
68713
|
-
if (p <= 0n || p > 100n)
|
|
68900
|
+
if (p <= 0n || p > 100n) fail2(`Percentage must be 1-100, got "${amount}".`, opts.json);
|
|
68714
68901
|
units = bal.units * p / 100n;
|
|
68715
68902
|
}
|
|
68716
|
-
if (units <= 0n)
|
|
68903
|
+
if (units <= 0n) fail2("Sell amount rounds to zero.", opts.json);
|
|
68717
68904
|
sellAmount = formatUnits2(units, bal.decimals);
|
|
68718
68905
|
} else if (!/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
68719
|
-
|
|
68906
|
+
fail2(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
68720
68907
|
}
|
|
68721
68908
|
const result = await runTrade({ ctx: ctx2, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
|
|
68722
68909
|
await reportTrade(ctx2, opts, { side: "sell", coin, address: key.state.address, amount: sellAmount, result });
|
|
@@ -68731,19 +68918,19 @@ function describeOrder(o) {
|
|
|
68731
68918
|
async function tradeOrderPlace(coinArg, opts) {
|
|
68732
68919
|
await withContext(opts, async (ctx2) => {
|
|
68733
68920
|
if (opts.buy === void 0 === (opts.sell === void 0)) {
|
|
68734
|
-
|
|
68921
|
+
fail2("Pass exactly one of --buy <usdc> or --sell <amount|N%|all>.", opts.json);
|
|
68735
68922
|
}
|
|
68736
68923
|
if (opts.at === void 0 === (opts.onGraduation !== true)) {
|
|
68737
|
-
|
|
68924
|
+
fail2("Pass exactly one trigger: --at <value> (price, or mcap with --mcap) or --on-graduation.", opts.json);
|
|
68738
68925
|
}
|
|
68739
68926
|
const coin = await resolveCoin(coinArg);
|
|
68740
68927
|
const side = opts.buy !== void 0 ? "buy" : "sell";
|
|
68741
68928
|
const kind = opts.onGraduation ? side === "buy" ? "buy_on_graduation" : "sell_on_graduation" : side === "buy" ? "buy_at" : "sell_at";
|
|
68742
|
-
if (opts.stop && kind !== "sell_at")
|
|
68743
|
-
if (opts.mcap && !opts.at)
|
|
68929
|
+
if (opts.stop && kind !== "sell_at") fail2("--stop only applies to a --sell order with --at.", opts.json);
|
|
68930
|
+
if (opts.mcap && !opts.at) fail2("--mcap qualifies --at.", opts.json);
|
|
68744
68931
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
68745
68932
|
if (created && !opts.json) {
|
|
68746
|
-
process.stderr.write(
|
|
68933
|
+
process.stderr.write(import_picocolors30.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
68747
68934
|
`));
|
|
68748
68935
|
}
|
|
68749
68936
|
let amount;
|
|
@@ -68752,11 +68939,11 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
68752
68939
|
try {
|
|
68753
68940
|
units = parseDecimalToUnits(opts.buy, USDC_DECIMALS, "Buy amount");
|
|
68754
68941
|
} catch (err) {
|
|
68755
|
-
|
|
68942
|
+
fail2(err.message, opts.json);
|
|
68756
68943
|
}
|
|
68757
68944
|
const floor = servedFloorUnits(ctx2);
|
|
68758
68945
|
if (floor && units < floor.units) {
|
|
68759
|
-
|
|
68946
|
+
fail2(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
68760
68947
|
}
|
|
68761
68948
|
amount = opts.buy;
|
|
68762
68949
|
} else {
|
|
@@ -68764,24 +68951,24 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
68764
68951
|
const pct = amount.match(/^(\d+)%$/);
|
|
68765
68952
|
if (amount === "all" || pct) {
|
|
68766
68953
|
const bal = await readTokenBalance(rpcConnection(), state.address, coin.mint);
|
|
68767
|
-
if (!bal)
|
|
68768
|
-
if (bal.units <= 0n)
|
|
68954
|
+
if (!bal) fail2("Could not read the coin balance from the RPC; pass an explicit amount.", opts.json);
|
|
68955
|
+
if (bal.units <= 0n) fail2("This key holds none of that coin.", opts.json);
|
|
68769
68956
|
let units = bal.units;
|
|
68770
68957
|
if (pct) {
|
|
68771
68958
|
const p = BigInt(pct[1]);
|
|
68772
|
-
if (p <= 0n || p > 100n)
|
|
68959
|
+
if (p <= 0n || p > 100n) fail2(`Percentage must be 1-100, got "${opts.sell}".`, opts.json);
|
|
68773
68960
|
units = bal.units * p / 100n;
|
|
68774
68961
|
}
|
|
68775
|
-
if (units <= 0n)
|
|
68962
|
+
if (units <= 0n) fail2("Sell amount rounds to zero.", opts.json);
|
|
68776
68963
|
amount = formatUnits2(units, bal.decimals);
|
|
68777
68964
|
} else if (!/^\d+(\.\d+)?$/.test(amount)) {
|
|
68778
|
-
|
|
68965
|
+
fail2(`Sell amount "${opts.sell}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
68779
68966
|
}
|
|
68780
68967
|
}
|
|
68781
68968
|
let expiresInDays;
|
|
68782
68969
|
if (opts.expiresDays !== void 0) {
|
|
68783
68970
|
const n2 = Number(opts.expiresDays);
|
|
68784
|
-
if (!Number.isInteger(n2) || n2 < 1)
|
|
68971
|
+
if (!Number.isInteger(n2) || n2 < 1) fail2(`--expires-days must be a positive integer, got "${opts.expiresDays}".`, opts.json);
|
|
68785
68972
|
expiresInDays = n2;
|
|
68786
68973
|
}
|
|
68787
68974
|
const prepared = await prepareOrder({
|
|
@@ -68817,7 +69004,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
68817
69004
|
async function tradeOrdersList(opts) {
|
|
68818
69005
|
await withContext(opts, async (ctx2) => {
|
|
68819
69006
|
const key = await loadTradeKey();
|
|
68820
|
-
if (!key)
|
|
69007
|
+
if (!key) fail2("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
68821
69008
|
const token = opts.coin ? (await resolveCoin(opts.coin)).mint : void 0;
|
|
68822
69009
|
const res = await listOrders(key.state.address, token);
|
|
68823
69010
|
if (opts.json) {
|
|
@@ -68837,15 +69024,15 @@ async function tradeOrdersList(opts) {
|
|
|
68837
69024
|
async function tradeOrderCancel(id2, opts) {
|
|
68838
69025
|
await withContext(opts, async (_ctx) => {
|
|
68839
69026
|
const key = await loadTradeKey();
|
|
68840
|
-
if (!key)
|
|
69027
|
+
if (!key) fail2("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
68841
69028
|
try {
|
|
68842
69029
|
await cancelOrder(id2, key.state.address);
|
|
68843
69030
|
} catch (err) {
|
|
68844
69031
|
if (err instanceof RelayError && err.status === 409) {
|
|
68845
|
-
|
|
69032
|
+
fail2(`Order ${id2} already fired or ended; nothing to cancel.`, opts.json);
|
|
68846
69033
|
}
|
|
68847
69034
|
if (err instanceof RelayError && err.status === 404) {
|
|
68848
|
-
|
|
69035
|
+
fail2(`No order ${id2} for this key (already canceled, or never placed).`, opts.json);
|
|
68849
69036
|
}
|
|
68850
69037
|
throw err;
|
|
68851
69038
|
}
|
|
@@ -68860,12 +69047,12 @@ async function tradeOrderCancel(id2, opts) {
|
|
|
68860
69047
|
async function tradePositions(opts) {
|
|
68861
69048
|
await withContext(opts, async (ctx2) => {
|
|
68862
69049
|
const key = await loadTradeKey();
|
|
68863
|
-
if (!key)
|
|
69050
|
+
if (!key) fail2("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
68864
69051
|
let body;
|
|
68865
69052
|
try {
|
|
68866
69053
|
body = await relayGet(`/launch-portfolio?address=${encodeURIComponent(key.state.address)}`);
|
|
68867
69054
|
} catch (err) {
|
|
68868
|
-
if (err instanceof RelayError)
|
|
69055
|
+
if (err instanceof RelayError) fail2(`Positions read failed: ${err.message}`, opts.json);
|
|
68869
69056
|
throw err;
|
|
68870
69057
|
}
|
|
68871
69058
|
const rows = body?.tokens ?? [];
|
|
@@ -68908,7 +69095,7 @@ async function tradePositions(opts) {
|
|
|
68908
69095
|
}
|
|
68909
69096
|
|
|
68910
69097
|
// src/commands/desk.ts
|
|
68911
|
-
var
|
|
69098
|
+
var import_picocolors31 = __toESM(require_picocolors(), 1);
|
|
68912
69099
|
|
|
68913
69100
|
// src/lib/desk-sol.ts
|
|
68914
69101
|
var import_web32 = __toESM(require_index_cjs(), 1);
|
|
@@ -69078,11 +69265,11 @@ async function runDeskTrade(args) {
|
|
|
69078
69265
|
}
|
|
69079
69266
|
|
|
69080
69267
|
// src/commands/desk.ts
|
|
69081
|
-
function
|
|
69268
|
+
function fail3(message, json2) {
|
|
69082
69269
|
if (json2) {
|
|
69083
69270
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
69084
69271
|
} else {
|
|
69085
|
-
process.stderr.write(
|
|
69272
|
+
process.stderr.write(import_picocolors31.default.red(`\u2715 ${message}
|
|
69086
69273
|
`));
|
|
69087
69274
|
}
|
|
69088
69275
|
process.exit(1);
|
|
@@ -69092,7 +69279,7 @@ async function withDesk(opts, fn) {
|
|
|
69092
69279
|
const ctx2 = await resolveDeskContext();
|
|
69093
69280
|
return await fn(ctx2);
|
|
69094
69281
|
} catch (err) {
|
|
69095
|
-
|
|
69282
|
+
fail3(err.message, opts.json);
|
|
69096
69283
|
}
|
|
69097
69284
|
}
|
|
69098
69285
|
function servedFloorUnits2(ctx2) {
|
|
@@ -69103,7 +69290,7 @@ function servedFloorUnits2(ctx2) {
|
|
|
69103
69290
|
async function requireOwner(opts) {
|
|
69104
69291
|
const key = await loadTradeKey();
|
|
69105
69292
|
if (!key) {
|
|
69106
|
-
|
|
69293
|
+
fail3("No agent trading key yet (the desk's owner). Run: agentgates trade key", opts.json);
|
|
69107
69294
|
}
|
|
69108
69295
|
return key;
|
|
69109
69296
|
}
|
|
@@ -69172,7 +69359,7 @@ async function deskStatus(opts) {
|
|
|
69172
69359
|
if (opts.fills !== void 0) {
|
|
69173
69360
|
const n2 = Number(opts.fills);
|
|
69174
69361
|
if (!Number.isInteger(n2) || n2 <= 0) {
|
|
69175
|
-
|
|
69362
|
+
fail3(`--fills must be a positive integer, got "${opts.fills}".`, opts.json);
|
|
69176
69363
|
}
|
|
69177
69364
|
fillsLimit = n2;
|
|
69178
69365
|
}
|
|
@@ -69220,12 +69407,12 @@ async function deskDeposit(amount, opts) {
|
|
|
69220
69407
|
try {
|
|
69221
69408
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Deposit amount");
|
|
69222
69409
|
} catch (err) {
|
|
69223
|
-
|
|
69410
|
+
fail3(err.message, opts.json);
|
|
69224
69411
|
}
|
|
69225
|
-
if (units <= 0n)
|
|
69412
|
+
if (units <= 0n) fail3("Deposit amount must be above zero.", opts.json);
|
|
69226
69413
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
69227
69414
|
if (created && !opts.json) {
|
|
69228
|
-
process.stderr.write(
|
|
69415
|
+
process.stderr.write(import_picocolors31.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
69229
69416
|
`));
|
|
69230
69417
|
}
|
|
69231
69418
|
const result = await runDeskCeremony({
|
|
@@ -69266,7 +69453,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
69266
69453
|
const trimmed = amount.trim();
|
|
69267
69454
|
if (trimmed !== "all") {
|
|
69268
69455
|
if (!/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
69269
|
-
|
|
69456
|
+
fail3(`Withdraw amount "${amount}" is not a decimal amount or "all".`, opts.json);
|
|
69270
69457
|
}
|
|
69271
69458
|
}
|
|
69272
69459
|
const result = await runDeskCeremony({
|
|
@@ -69305,28 +69492,28 @@ async function deskWithdraw(amount, opts) {
|
|
|
69305
69492
|
}
|
|
69306
69493
|
async function deskSessionRegister(opts) {
|
|
69307
69494
|
await withDesk(opts, async (ctx2) => {
|
|
69308
|
-
if (!opts.cap)
|
|
69309
|
-
if (!opts.minutes)
|
|
69495
|
+
if (!opts.cap) fail3("--cap <usdc> is required: the per-trade cap is your risk statement, never defaulted.", opts.json);
|
|
69496
|
+
if (!opts.minutes) fail3("--minutes <n> is required: the session expiry is your risk statement, never defaulted.", opts.json);
|
|
69310
69497
|
let capUnits;
|
|
69311
69498
|
try {
|
|
69312
69499
|
capUnits = parseDecimalToUnits(opts.cap, USDC_DECIMALS, "Per-trade cap");
|
|
69313
69500
|
} catch (err) {
|
|
69314
|
-
|
|
69501
|
+
fail3(err.message, opts.json);
|
|
69315
69502
|
}
|
|
69316
|
-
if (capUnits <= 0n)
|
|
69503
|
+
if (capUnits <= 0n) fail3("Per-trade cap must be above zero.", opts.json);
|
|
69317
69504
|
const minutes = Number(opts.minutes);
|
|
69318
69505
|
if (!Number.isInteger(minutes) || minutes <= 0) {
|
|
69319
|
-
|
|
69506
|
+
fail3(`--minutes must be a positive integer, got "${opts.minutes}".`, opts.json);
|
|
69320
69507
|
}
|
|
69321
69508
|
const owner = await loadOrCreateTradeKey();
|
|
69322
69509
|
if (owner.created && !opts.json) {
|
|
69323
|
-
process.stderr.write(
|
|
69510
|
+
process.stderr.write(import_picocolors31.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
|
|
69324
69511
|
`));
|
|
69325
69512
|
}
|
|
69326
69513
|
const session = await loadOrCreateDeskSessionKey();
|
|
69327
69514
|
if (session.created && !opts.json) {
|
|
69328
69515
|
process.stderr.write(
|
|
69329
|
-
|
|
69516
|
+
import_picocolors31.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
|
|
69330
69517
|
`)
|
|
69331
69518
|
);
|
|
69332
69519
|
}
|
|
@@ -69400,7 +69587,7 @@ async function deskSessionRevoke(opts) {
|
|
|
69400
69587
|
async function requireSessionKeypair(opts) {
|
|
69401
69588
|
const session = await loadDeskSessionKey();
|
|
69402
69589
|
if (!session) {
|
|
69403
|
-
|
|
69590
|
+
fail3(
|
|
69404
69591
|
"No desk session key on this terminal. Register one: agentgates desk session register --cap <usdc> --minutes <n>",
|
|
69405
69592
|
opts.json
|
|
69406
69593
|
);
|
|
@@ -69444,12 +69631,12 @@ async function deskBuy(coinArg, amount, opts) {
|
|
|
69444
69631
|
try {
|
|
69445
69632
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
|
|
69446
69633
|
} catch (err) {
|
|
69447
|
-
|
|
69634
|
+
fail3(err.message, opts.json);
|
|
69448
69635
|
}
|
|
69449
|
-
if (units <= 0n)
|
|
69636
|
+
if (units <= 0n) fail3("Buy amount must be above zero.", opts.json);
|
|
69450
69637
|
const floor = servedFloorUnits2(ctx2);
|
|
69451
69638
|
if (floor && units < floor.units) {
|
|
69452
|
-
|
|
69639
|
+
fail3(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
69453
69640
|
}
|
|
69454
69641
|
const owner = await requireOwner(opts);
|
|
69455
69642
|
const session = await requireSessionKeypair(opts);
|
|
@@ -69474,16 +69661,16 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
69474
69661
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
69475
69662
|
if (pct) {
|
|
69476
69663
|
const state = await deskState(owner.state.address, coin.mint);
|
|
69477
|
-
if (!state.coin)
|
|
69664
|
+
if (!state.coin) fail3("The desk holds none of that coin for this owner.", opts.json);
|
|
69478
69665
|
const credit = BigInt(state.coin.creditUnits);
|
|
69479
|
-
if (credit <= 0n)
|
|
69666
|
+
if (credit <= 0n) fail3("The desk holds none of that coin for this owner.", opts.json);
|
|
69480
69667
|
const p = BigInt(pct[1]);
|
|
69481
|
-
if (p <= 0n || p > 100n)
|
|
69668
|
+
if (p <= 0n || p > 100n) fail3(`Percentage must be 1-100, got "${amount}".`, opts.json);
|
|
69482
69669
|
const units = credit * p / 100n;
|
|
69483
|
-
if (units <= 0n)
|
|
69670
|
+
if (units <= 0n) fail3("Sell amount rounds to zero.", opts.json);
|
|
69484
69671
|
sellAmount = formatUnits2(units, state.coin.decimals);
|
|
69485
69672
|
} else if (sellAmount !== "all" && !/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
69486
|
-
|
|
69673
|
+
fail3(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
69487
69674
|
}
|
|
69488
69675
|
const result = await runDeskTrade({
|
|
69489
69676
|
ctx: ctx2,
|
|
@@ -69868,7 +70055,7 @@ program2.command("fund").description(
|
|
|
69868
70055
|
}
|
|
69869
70056
|
if (opts.usdc || opts.gas || opts.chain) {
|
|
69870
70057
|
process.stderr.write(
|
|
69871
|
-
|
|
70058
|
+
import_picocolors32.default.red(
|
|
69872
70059
|
`\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
|
|
69873
70060
|
`
|
|
69874
70061
|
)
|
|
@@ -70071,6 +70258,16 @@ program2.command("init").description(
|
|
|
70071
70258
|
).option("--seed <twelve words>", "bring the phrase (quote it)").option("--reveal-seed", "print this key's words again, with the handoff for your human").option("--import <hex>", "bring a bare 32-byte secp256k1 private key (64 hex chars) instead of words").option("--replace", "with --seed or --import: overwrite what is already here").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
70072
70259
|
await passwordsInit(opts);
|
|
70073
70260
|
});
|
|
70261
|
+
var keys = program2.command("keys").description("The login keys on this account (Agent APIs): what this machine sends on every call instead of the words. Signed by the words; a key never mints a key.");
|
|
70262
|
+
keys.command("list", { isDefault: true }).description("List the account's login keys with their last use; marks this machine's.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
70263
|
+
await keysList(opts);
|
|
70264
|
+
});
|
|
70265
|
+
keys.command("create").description("Mint a login key by name, shown once. --keep makes it this machine's from now on.").option("--name <name>", "what to call it (64 chars); defaults to cli <hostname>").option("--keep", "keep it in the key file: this machine sends it on every call").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
70266
|
+
await keysCreate(opts);
|
|
70267
|
+
});
|
|
70268
|
+
keys.command("revoke <id>").description("End a login key. Revoking this machine's own key makes it sign with the words until keys create --keep.").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (id2, opts) => {
|
|
70269
|
+
await keysRevoke(id2, opts);
|
|
70270
|
+
});
|
|
70074
70271
|
program2.command("update").description("Bring this copy to the version npm serves as latest, in the place it runs from (the installer's ~/.agentgates, or a global npm install).").option("--check", "say whether a newer version is out; install nothing").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
70075
70272
|
await update(opts);
|
|
70076
70273
|
});
|
|
@@ -70088,10 +70285,10 @@ browser.command("balance").description("The prepaid balance every step draws fro
|
|
|
70088
70285
|
await browserBalance(opts);
|
|
70089
70286
|
});
|
|
70090
70287
|
program2.parseAsync(process.argv).catch((err) => {
|
|
70091
|
-
process.stderr.write(
|
|
70288
|
+
process.stderr.write(import_picocolors32.default.red(`\u2715 ${err.message}
|
|
70092
70289
|
`));
|
|
70093
70290
|
if (process.env.BOUNTY_DEBUG) {
|
|
70094
|
-
process.stderr.write(
|
|
70291
|
+
process.stderr.write(import_picocolors32.default.dim((err.stack ?? "") + "\n"));
|
|
70095
70292
|
}
|
|
70096
70293
|
process.exit(1);
|
|
70097
70294
|
});
|