@agentgates/cli 0.19.1 → 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 +1141 -830
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -981,7 +981,7 @@ var require_command = __commonJS({
|
|
|
981
981
|
"node_modules/commander/lib/command.js"(exports) {
|
|
982
982
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
983
983
|
var childProcess2 = __require("node:child_process");
|
|
984
|
-
var
|
|
984
|
+
var path7 = __require("node:path");
|
|
985
985
|
var fs10 = __require("node:fs");
|
|
986
986
|
var process8 = __require("node:process");
|
|
987
987
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -1914,9 +1914,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1914
1914
|
let launchWithNode = false;
|
|
1915
1915
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1916
1916
|
function findFile(baseDir, baseName) {
|
|
1917
|
-
const localBin =
|
|
1917
|
+
const localBin = path7.resolve(baseDir, baseName);
|
|
1918
1918
|
if (fs10.existsSync(localBin)) return localBin;
|
|
1919
|
-
if (sourceExt.includes(
|
|
1919
|
+
if (sourceExt.includes(path7.extname(baseName))) return void 0;
|
|
1920
1920
|
const foundExt = sourceExt.find(
|
|
1921
1921
|
(ext) => fs10.existsSync(`${localBin}${ext}`)
|
|
1922
1922
|
);
|
|
@@ -1934,17 +1934,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1934
1934
|
} catch (err) {
|
|
1935
1935
|
resolvedScriptPath = this._scriptPath;
|
|
1936
1936
|
}
|
|
1937
|
-
executableDir =
|
|
1938
|
-
|
|
1937
|
+
executableDir = path7.resolve(
|
|
1938
|
+
path7.dirname(resolvedScriptPath),
|
|
1939
1939
|
executableDir
|
|
1940
1940
|
);
|
|
1941
1941
|
}
|
|
1942
1942
|
if (executableDir) {
|
|
1943
1943
|
let localFile = findFile(executableDir, executableFile);
|
|
1944
1944
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1945
|
-
const legacyName =
|
|
1945
|
+
const legacyName = path7.basename(
|
|
1946
1946
|
this._scriptPath,
|
|
1947
|
-
|
|
1947
|
+
path7.extname(this._scriptPath)
|
|
1948
1948
|
);
|
|
1949
1949
|
if (legacyName !== this._name) {
|
|
1950
1950
|
localFile = findFile(
|
|
@@ -1955,7 +1955,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1955
1955
|
}
|
|
1956
1956
|
executableFile = localFile || executableFile;
|
|
1957
1957
|
}
|
|
1958
|
-
launchWithNode = sourceExt.includes(
|
|
1958
|
+
launchWithNode = sourceExt.includes(path7.extname(executableFile));
|
|
1959
1959
|
let proc;
|
|
1960
1960
|
if (process8.platform !== "win32") {
|
|
1961
1961
|
if (launchWithNode) {
|
|
@@ -2795,7 +2795,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2795
2795
|
* @return {Command}
|
|
2796
2796
|
*/
|
|
2797
2797
|
nameFromFilename(filename) {
|
|
2798
|
-
this._name =
|
|
2798
|
+
this._name = path7.basename(filename, path7.extname(filename));
|
|
2799
2799
|
return this;
|
|
2800
2800
|
}
|
|
2801
2801
|
/**
|
|
@@ -2809,9 +2809,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2809
2809
|
* @param {string} [path]
|
|
2810
2810
|
* @return {(string|null|Command)}
|
|
2811
2811
|
*/
|
|
2812
|
-
executableDir(
|
|
2813
|
-
if (
|
|
2814
|
-
this._executableDir =
|
|
2812
|
+
executableDir(path8) {
|
|
2813
|
+
if (path8 === void 0) return this._executableDir;
|
|
2814
|
+
this._executableDir = path8;
|
|
2815
2815
|
return this;
|
|
2816
2816
|
}
|
|
2817
2817
|
/**
|
|
@@ -3232,7 +3232,7 @@ var require_constants = __commonJS({
|
|
|
3232
3232
|
var require_node_gyp_build = __commonJS({
|
|
3233
3233
|
"node_modules/node-gyp-build/node-gyp-build.js"(exports, module) {
|
|
3234
3234
|
var fs10 = __require("fs");
|
|
3235
|
-
var
|
|
3235
|
+
var path7 = __require("path");
|
|
3236
3236
|
var os5 = __require("os");
|
|
3237
3237
|
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
3238
3238
|
var vars = process.config && process.config.variables || {};
|
|
@@ -3249,21 +3249,21 @@ var require_node_gyp_build = __commonJS({
|
|
|
3249
3249
|
return runtimeRequire(load.resolve(dir));
|
|
3250
3250
|
}
|
|
3251
3251
|
load.resolve = load.path = function(dir) {
|
|
3252
|
-
dir =
|
|
3252
|
+
dir = path7.resolve(dir || ".");
|
|
3253
3253
|
try {
|
|
3254
|
-
var name = runtimeRequire(
|
|
3254
|
+
var name = runtimeRequire(path7.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
|
|
3255
3255
|
if (process.env[name + "_PREBUILD"]) dir = process.env[name + "_PREBUILD"];
|
|
3256
3256
|
} catch (err) {
|
|
3257
3257
|
}
|
|
3258
3258
|
if (!prebuildsOnly) {
|
|
3259
|
-
var release = getFirst(
|
|
3259
|
+
var release = getFirst(path7.join(dir, "build/Release"), matchBuild);
|
|
3260
3260
|
if (release) return release;
|
|
3261
|
-
var debug = getFirst(
|
|
3261
|
+
var debug = getFirst(path7.join(dir, "build/Debug"), matchBuild);
|
|
3262
3262
|
if (debug) return debug;
|
|
3263
3263
|
}
|
|
3264
3264
|
var prebuild = resolve2(dir);
|
|
3265
3265
|
if (prebuild) return prebuild;
|
|
3266
|
-
var nearby = resolve2(
|
|
3266
|
+
var nearby = resolve2(path7.dirname(process.execPath));
|
|
3267
3267
|
if (nearby) return nearby;
|
|
3268
3268
|
var target = [
|
|
3269
3269
|
"platform=" + platform2,
|
|
@@ -3280,14 +3280,14 @@ var require_node_gyp_build = __commonJS({
|
|
|
3280
3280
|
].filter(Boolean).join(" ");
|
|
3281
3281
|
throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
|
|
3282
3282
|
function resolve2(dir2) {
|
|
3283
|
-
var tuples = readdirSync(
|
|
3283
|
+
var tuples = readdirSync(path7.join(dir2, "prebuilds")).map(parseTuple);
|
|
3284
3284
|
var tuple = tuples.filter(matchTuple(platform2, arch2)).sort(compareTuples)[0];
|
|
3285
3285
|
if (!tuple) return;
|
|
3286
|
-
var prebuilds =
|
|
3286
|
+
var prebuilds = path7.join(dir2, "prebuilds", tuple.name);
|
|
3287
3287
|
var parsed = readdirSync(prebuilds).map(parseTags);
|
|
3288
3288
|
var candidates = parsed.filter(matchTags(runtime, abi));
|
|
3289
3289
|
var winner = candidates.sort(compareTags(runtime))[0];
|
|
3290
|
-
if (winner) return
|
|
3290
|
+
if (winner) return path7.join(prebuilds, winner.file);
|
|
3291
3291
|
}
|
|
3292
3292
|
};
|
|
3293
3293
|
function readdirSync(dir) {
|
|
@@ -3299,7 +3299,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
3299
3299
|
}
|
|
3300
3300
|
function getFirst(dir, filter) {
|
|
3301
3301
|
var files = readdirSync(dir).filter(filter);
|
|
3302
|
-
return files[0] &&
|
|
3302
|
+
return files[0] && path7.join(dir, files[0]);
|
|
3303
3303
|
}
|
|
3304
3304
|
function matchBuild(name) {
|
|
3305
3305
|
return /\.node$/.test(name);
|
|
@@ -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",
|
|
@@ -17398,8 +17398,8 @@ var require_dist = __commonJS({
|
|
|
17398
17398
|
constructor(failure, failures) {
|
|
17399
17399
|
let cached;
|
|
17400
17400
|
const { message, explanation, ...rest } = failure;
|
|
17401
|
-
const { path:
|
|
17402
|
-
const msg =
|
|
17401
|
+
const { path: path7 } = failure;
|
|
17402
|
+
const msg = path7.length === 0 ? message : `At path: ${path7.join(".")} -- ${message}`;
|
|
17403
17403
|
super(explanation ?? msg);
|
|
17404
17404
|
if (explanation != null)
|
|
17405
17405
|
this.cause = msg;
|
|
@@ -17444,15 +17444,15 @@ var require_dist = __commonJS({
|
|
|
17444
17444
|
} else if (typeof result === "string") {
|
|
17445
17445
|
result = { message: result };
|
|
17446
17446
|
}
|
|
17447
|
-
const { path:
|
|
17447
|
+
const { path: path7, branch } = context;
|
|
17448
17448
|
const { type: type2 } = struct2;
|
|
17449
17449
|
const { refinement, message = `Expected a value of type \`${type2}\`${refinement ? ` with refinement \`${refinement}\`` : ""}, but received: \`${print(value)}\`` } = result;
|
|
17450
17450
|
return {
|
|
17451
17451
|
value,
|
|
17452
17452
|
type: type2,
|
|
17453
17453
|
refinement,
|
|
17454
|
-
key:
|
|
17455
|
-
path:
|
|
17454
|
+
key: path7[path7.length - 1],
|
|
17455
|
+
path: path7,
|
|
17456
17456
|
branch,
|
|
17457
17457
|
...result,
|
|
17458
17458
|
message
|
|
@@ -17470,8 +17470,8 @@ var require_dist = __commonJS({
|
|
|
17470
17470
|
}
|
|
17471
17471
|
}
|
|
17472
17472
|
function* run(value, struct2, options = {}) {
|
|
17473
|
-
const { path:
|
|
17474
|
-
const ctx2 = { path:
|
|
17473
|
+
const { path: path7 = [], branch = [value], coerce: coerce2 = false, mask: mask3 = false } = options;
|
|
17474
|
+
const ctx2 = { path: path7, branch, mask: mask3 };
|
|
17475
17475
|
if (coerce2) {
|
|
17476
17476
|
value = struct2.coercer(value, ctx2);
|
|
17477
17477
|
}
|
|
@@ -17483,7 +17483,7 @@ var require_dist = __commonJS({
|
|
|
17483
17483
|
}
|
|
17484
17484
|
for (let [k, v, s] of struct2.entries(value, ctx2)) {
|
|
17485
17485
|
const ts = run(v, s, {
|
|
17486
|
-
path: k === void 0 ?
|
|
17486
|
+
path: k === void 0 ? path7 : [...path7, k],
|
|
17487
17487
|
branch: k === void 0 ? branch : [...branch, v],
|
|
17488
17488
|
coerce: coerce2,
|
|
17489
17489
|
mask: mask3,
|
|
@@ -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");
|
|
@@ -19413,14 +19413,14 @@ var require_url_state_machine = __commonJS({
|
|
|
19413
19413
|
return url.replace(/\u0009|\u000A|\u000D/g, "");
|
|
19414
19414
|
}
|
|
19415
19415
|
function shortenPath(url) {
|
|
19416
|
-
const
|
|
19417
|
-
if (
|
|
19416
|
+
const path7 = url.path;
|
|
19417
|
+
if (path7.length === 0) {
|
|
19418
19418
|
return;
|
|
19419
19419
|
}
|
|
19420
|
-
if (url.scheme === "file" &&
|
|
19420
|
+
if (url.scheme === "file" && path7.length === 1 && isNormalizedWindowsDriveLetter(path7[0])) {
|
|
19421
19421
|
return;
|
|
19422
19422
|
}
|
|
19423
|
-
|
|
19423
|
+
path7.pop();
|
|
19424
19424
|
}
|
|
19425
19425
|
function includesCredentials(url) {
|
|
19426
19426
|
return url.username !== "" || url.password !== "";
|
|
@@ -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);
|
|
@@ -38847,7 +38847,7 @@ function shortAddress(addr) {
|
|
|
38847
38847
|
}
|
|
38848
38848
|
|
|
38849
38849
|
// src/commands/onboard.ts
|
|
38850
|
-
var
|
|
38850
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
38851
38851
|
import { createInterface } from "node:readline/promises";
|
|
38852
38852
|
|
|
38853
38853
|
// src/lib/water.ts
|
|
@@ -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,18 +42027,18 @@ 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) {
|
|
42035
42035
|
const errors = [];
|
|
42036
|
-
const checkErrors = function(
|
|
42036
|
+
const checkErrors = function(path7, object2) {
|
|
42037
42037
|
if (!Array.isArray(object2)) {
|
|
42038
42038
|
return;
|
|
42039
42039
|
}
|
|
42040
42040
|
for (let key in object2) {
|
|
42041
|
-
const childPath =
|
|
42041
|
+
const childPath = path7.slice();
|
|
42042
42042
|
childPath.push(key);
|
|
42043
42043
|
try {
|
|
42044
42044
|
checkErrors(childPath, object2[key]);
|
|
@@ -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);
|
|
@@ -60645,9 +60645,9 @@ var IpcSocketProvider = class extends SocketProvider {
|
|
|
60645
60645
|
get socket() {
|
|
60646
60646
|
return this.#socket;
|
|
60647
60647
|
}
|
|
60648
|
-
constructor(
|
|
60648
|
+
constructor(path7, network, options) {
|
|
60649
60649
|
super(network, options);
|
|
60650
|
-
this.#socket = connect(
|
|
60650
|
+
this.#socket = connect(path7);
|
|
60651
60651
|
this.socket.on("ready", async () => {
|
|
60652
60652
|
try {
|
|
60653
60653
|
await this._start();
|
|
@@ -61479,11 +61479,11 @@ function getPassword(password) {
|
|
|
61479
61479
|
function spelunk(object2, _path) {
|
|
61480
61480
|
const match = _path.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i);
|
|
61481
61481
|
assertArgument(match != null, "invalid path", "path", _path);
|
|
61482
|
-
const
|
|
61482
|
+
const path7 = match[1];
|
|
61483
61483
|
const type = match[3];
|
|
61484
61484
|
const reqd = match[4] === "!";
|
|
61485
61485
|
let cur = object2;
|
|
61486
|
-
for (const comp of
|
|
61486
|
+
for (const comp of path7.toLowerCase().split(".")) {
|
|
61487
61487
|
if (Array.isArray(cur)) {
|
|
61488
61488
|
if (!comp.match(/^[0-9]+$/)) {
|
|
61489
61489
|
break;
|
|
@@ -61505,7 +61505,7 @@ function spelunk(object2, _path) {
|
|
|
61505
61505
|
break;
|
|
61506
61506
|
}
|
|
61507
61507
|
}
|
|
61508
|
-
assertArgument(!reqd || cur != null, "missing required value", "path",
|
|
61508
|
+
assertArgument(!reqd || cur != null, "missing required value", "path", path7);
|
|
61509
61509
|
if (type && cur != null) {
|
|
61510
61510
|
if (type === "int") {
|
|
61511
61511
|
if (typeof cur === "string" && cur.match(/^-?[0-9]+$/)) {
|
|
@@ -61530,7 +61530,7 @@ function spelunk(object2, _path) {
|
|
|
61530
61530
|
if (type === typeof cur) {
|
|
61531
61531
|
return cur;
|
|
61532
61532
|
}
|
|
61533
|
-
assertArgument(false, `wrong type found for ${type} `, "path",
|
|
61533
|
+
assertArgument(false, `wrong type found for ${type} `, "path", path7);
|
|
61534
61534
|
}
|
|
61535
61535
|
return cur;
|
|
61536
61536
|
}
|
|
@@ -61710,7 +61710,7 @@ function _encryptKeystore(key, kdf, account, options) {
|
|
|
61710
61710
|
};
|
|
61711
61711
|
if (account.mnemonic) {
|
|
61712
61712
|
const client = options.client != null ? options.client : `ethers/${version}`;
|
|
61713
|
-
const
|
|
61713
|
+
const path7 = account.mnemonic.path || defaultPath;
|
|
61714
61714
|
const locale = account.mnemonic.locale || "en";
|
|
61715
61715
|
const mnemonicKey = key.slice(32, 64);
|
|
61716
61716
|
const entropy = getBytes(account.mnemonic.entropy, "account.mnemonic.entropy");
|
|
@@ -61723,7 +61723,7 @@ function _encryptKeystore(key, kdf, account, options) {
|
|
|
61723
61723
|
data4["x-ethers"] = {
|
|
61724
61724
|
client,
|
|
61725
61725
|
gethFilename,
|
|
61726
|
-
path:
|
|
61726
|
+
path: path7,
|
|
61727
61727
|
locale,
|
|
61728
61728
|
mnemonicCounter: hexlify(mnemonicIv).substring(2),
|
|
61729
61729
|
mnemonicCiphertext: hexlify(mnemonicCiphertext).substring(2),
|
|
@@ -61791,11 +61791,11 @@ function ser_I(index, chainCode, publicKey, privateKey) {
|
|
|
61791
61791
|
const I = getBytes(computeHmac("sha512", chainCode, data4));
|
|
61792
61792
|
return { IL: I.slice(0, 32), IR: I.slice(32) };
|
|
61793
61793
|
}
|
|
61794
|
-
function derivePath(node,
|
|
61795
|
-
const components =
|
|
61796
|
-
assertArgument(components.length > 0, "invalid path", "path",
|
|
61794
|
+
function derivePath(node, path7) {
|
|
61795
|
+
const components = path7.split("/");
|
|
61796
|
+
assertArgument(components.length > 0, "invalid path", "path", path7);
|
|
61797
61797
|
if (components[0] === "m") {
|
|
61798
|
-
assertArgument(node.depth === 0, `cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${node.depth}`, "path",
|
|
61798
|
+
assertArgument(node.depth === 0, `cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${node.depth}`, "path", path7);
|
|
61799
61799
|
components.shift();
|
|
61800
61800
|
}
|
|
61801
61801
|
let result = node;
|
|
@@ -61865,7 +61865,7 @@ var HDNodeWallet = class _HDNodeWallet extends BaseWallet {
|
|
|
61865
61865
|
/**
|
|
61866
61866
|
* @private
|
|
61867
61867
|
*/
|
|
61868
|
-
constructor(guard, signingKey, parentFingerprint, chainCode,
|
|
61868
|
+
constructor(guard, signingKey, parentFingerprint, chainCode, path7, index, depth, mnemonic, provider) {
|
|
61869
61869
|
super(signingKey, provider);
|
|
61870
61870
|
assertPrivate(guard, _guard6, "HDNodeWallet");
|
|
61871
61871
|
defineProperties(this, { publicKey: signingKey.compressedPublicKey });
|
|
@@ -61874,7 +61874,7 @@ var HDNodeWallet = class _HDNodeWallet extends BaseWallet {
|
|
|
61874
61874
|
parentFingerprint,
|
|
61875
61875
|
fingerprint,
|
|
61876
61876
|
chainCode,
|
|
61877
|
-
path:
|
|
61877
|
+
path: path7,
|
|
61878
61878
|
index,
|
|
61879
61879
|
depth
|
|
61880
61880
|
});
|
|
@@ -61958,22 +61958,22 @@ var HDNodeWallet = class _HDNodeWallet extends BaseWallet {
|
|
|
61958
61958
|
deriveChild(_index) {
|
|
61959
61959
|
const index = getNumber(_index, "index");
|
|
61960
61960
|
assertArgument(index <= 4294967295, "invalid index", "index", index);
|
|
61961
|
-
let
|
|
61962
|
-
if (
|
|
61963
|
-
|
|
61961
|
+
let path7 = this.path;
|
|
61962
|
+
if (path7) {
|
|
61963
|
+
path7 += "/" + (index & ~HardenedBit);
|
|
61964
61964
|
if (index & HardenedBit) {
|
|
61965
|
-
|
|
61965
|
+
path7 += "'";
|
|
61966
61966
|
}
|
|
61967
61967
|
}
|
|
61968
61968
|
const { IR, IL } = ser_I(index, this.chainCode, this.publicKey, this.privateKey);
|
|
61969
61969
|
const ki = new SigningKey(toBeHex((toBigInt(IL) + BigInt(this.privateKey)) % N2, 32));
|
|
61970
|
-
return new _HDNodeWallet(_guard6, ki, this.fingerprint, hexlify(IR),
|
|
61970
|
+
return new _HDNodeWallet(_guard6, ki, this.fingerprint, hexlify(IR), path7, index, this.depth + 1, this.mnemonic, this.provider);
|
|
61971
61971
|
}
|
|
61972
61972
|
/**
|
|
61973
61973
|
* Return the HDNode for %%path%% from this node.
|
|
61974
61974
|
*/
|
|
61975
|
-
derivePath(
|
|
61976
|
-
return derivePath(this,
|
|
61975
|
+
derivePath(path7) {
|
|
61976
|
+
return derivePath(this, path7);
|
|
61977
61977
|
}
|
|
61978
61978
|
static #fromSeed(_seed, mnemonic) {
|
|
61979
61979
|
assertArgument(isBytesLike(_seed), "invalid seed", "seed", "[REDACTED]");
|
|
@@ -62018,43 +62018,43 @@ var HDNodeWallet = class _HDNodeWallet extends BaseWallet {
|
|
|
62018
62018
|
/**
|
|
62019
62019
|
* Creates a new random HDNode.
|
|
62020
62020
|
*/
|
|
62021
|
-
static createRandom(password,
|
|
62021
|
+
static createRandom(password, path7, wordlist9) {
|
|
62022
62022
|
if (password == null) {
|
|
62023
62023
|
password = "";
|
|
62024
62024
|
}
|
|
62025
|
-
if (
|
|
62026
|
-
|
|
62025
|
+
if (path7 == null) {
|
|
62026
|
+
path7 = defaultPath2;
|
|
62027
62027
|
}
|
|
62028
62028
|
if (wordlist9 == null) {
|
|
62029
62029
|
wordlist9 = LangEn.wordlist();
|
|
62030
62030
|
}
|
|
62031
62031
|
const mnemonic = Mnemonic.fromEntropy(randomBytes3(16), password, wordlist9);
|
|
62032
|
-
return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(
|
|
62032
|
+
return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path7);
|
|
62033
62033
|
}
|
|
62034
62034
|
/**
|
|
62035
62035
|
* Create an HD Node from %%mnemonic%%.
|
|
62036
62036
|
*/
|
|
62037
|
-
static fromMnemonic(mnemonic,
|
|
62038
|
-
if (!
|
|
62039
|
-
|
|
62037
|
+
static fromMnemonic(mnemonic, path7) {
|
|
62038
|
+
if (!path7) {
|
|
62039
|
+
path7 = defaultPath2;
|
|
62040
62040
|
}
|
|
62041
|
-
return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(
|
|
62041
|
+
return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path7);
|
|
62042
62042
|
}
|
|
62043
62043
|
/**
|
|
62044
62044
|
* Creates an HD Node from a mnemonic %%phrase%%.
|
|
62045
62045
|
*/
|
|
62046
|
-
static fromPhrase(phrase, password,
|
|
62046
|
+
static fromPhrase(phrase, password, path7, wordlist9) {
|
|
62047
62047
|
if (password == null) {
|
|
62048
62048
|
password = "";
|
|
62049
62049
|
}
|
|
62050
|
-
if (
|
|
62051
|
-
|
|
62050
|
+
if (path7 == null) {
|
|
62051
|
+
path7 = defaultPath2;
|
|
62052
62052
|
}
|
|
62053
62053
|
if (wordlist9 == null) {
|
|
62054
62054
|
wordlist9 = LangEn.wordlist();
|
|
62055
62055
|
}
|
|
62056
62056
|
const mnemonic = Mnemonic.fromPhrase(phrase, password, wordlist9);
|
|
62057
|
-
return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(
|
|
62057
|
+
return _HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path7);
|
|
62058
62058
|
}
|
|
62059
62059
|
/**
|
|
62060
62060
|
* Creates an HD Node from a %%seed%%.
|
|
@@ -62106,7 +62106,7 @@ var HDNodeVoidWallet = class _HDNodeVoidWallet extends VoidSigner {
|
|
|
62106
62106
|
/**
|
|
62107
62107
|
* @private
|
|
62108
62108
|
*/
|
|
62109
|
-
constructor(guard, address, publicKey, parentFingerprint, chainCode,
|
|
62109
|
+
constructor(guard, address, publicKey, parentFingerprint, chainCode, path7, index, depth, provider) {
|
|
62110
62110
|
super(address, provider);
|
|
62111
62111
|
assertPrivate(guard, _guard6, "HDNodeVoidWallet");
|
|
62112
62112
|
defineProperties(this, { publicKey });
|
|
@@ -62116,7 +62116,7 @@ var HDNodeVoidWallet = class _HDNodeVoidWallet extends VoidSigner {
|
|
|
62116
62116
|
fingerprint,
|
|
62117
62117
|
parentFingerprint,
|
|
62118
62118
|
chainCode,
|
|
62119
|
-
path:
|
|
62119
|
+
path: path7,
|
|
62120
62120
|
index,
|
|
62121
62121
|
depth
|
|
62122
62122
|
});
|
|
@@ -62154,23 +62154,23 @@ var HDNodeVoidWallet = class _HDNodeVoidWallet extends VoidSigner {
|
|
|
62154
62154
|
deriveChild(_index) {
|
|
62155
62155
|
const index = getNumber(_index, "index");
|
|
62156
62156
|
assertArgument(index <= 4294967295, "invalid index", "index", index);
|
|
62157
|
-
let
|
|
62158
|
-
if (
|
|
62159
|
-
|
|
62157
|
+
let path7 = this.path;
|
|
62158
|
+
if (path7) {
|
|
62159
|
+
path7 += "/" + (index & ~HardenedBit);
|
|
62160
62160
|
if (index & HardenedBit) {
|
|
62161
|
-
|
|
62161
|
+
path7 += "'";
|
|
62162
62162
|
}
|
|
62163
62163
|
}
|
|
62164
62164
|
const { IR, IL } = ser_I(index, this.chainCode, this.publicKey, null);
|
|
62165
62165
|
const Ki = SigningKey.addPoints(IL, this.publicKey, true);
|
|
62166
62166
|
const address = computeAddress(Ki);
|
|
62167
|
-
return new _HDNodeVoidWallet(_guard6, address, Ki, this.fingerprint, hexlify(IR),
|
|
62167
|
+
return new _HDNodeVoidWallet(_guard6, address, Ki, this.fingerprint, hexlify(IR), path7, index, this.depth + 1, this.provider);
|
|
62168
62168
|
}
|
|
62169
62169
|
/**
|
|
62170
62170
|
* Return the signer for %%path%% from this node.
|
|
62171
62171
|
*/
|
|
62172
|
-
derivePath(
|
|
62173
|
-
return derivePath(this,
|
|
62172
|
+
derivePath(path7) {
|
|
62173
|
+
return derivePath(this, path7);
|
|
62174
62174
|
}
|
|
62175
62175
|
};
|
|
62176
62176
|
function getAccountPath(_index) {
|
|
@@ -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, path6) {
|
|
63007
|
-
const timestamp = Math.floor(Date.now() / 1e3);
|
|
63008
|
-
const nonce = randomBytes4(16).toString("hex");
|
|
63009
|
-
const signature = await wallet.signMessage(`${method.toUpperCase()}
|
|
63010
|
-
${path6}
|
|
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, path6, body, timeoutMs = 13e4) {
|
|
63016
|
-
const headers = {
|
|
63017
|
-
accept: "application/json",
|
|
63018
|
-
"user-agent": CLI_USER_AGENT,
|
|
63019
|
-
"x-wallet-auth": await ownerAuthHeader(wallet, method, path6)
|
|
63020
|
-
};
|
|
63021
|
-
if (body !== void 0) headers["content-type"] = "application/json";
|
|
63022
|
-
let res;
|
|
63023
|
-
try {
|
|
63024
|
-
res = await fetch(`${identityOrigin()}${path6}`, {
|
|
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,25 +64630,145 @@ 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);
|
|
64562
64649
|
}
|
|
64563
64650
|
}
|
|
64564
64651
|
|
|
64652
|
+
// src/lib/self-update.ts
|
|
64653
|
+
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
64654
|
+
import path4 from "node:path";
|
|
64655
|
+
import { spawn } from "node:child_process";
|
|
64656
|
+
var PKG = "@agentgates/cli";
|
|
64657
|
+
var LOCAL_VERSION = require_package().version;
|
|
64658
|
+
function olderThan(a, b2) {
|
|
64659
|
+
const num = (v) => v.replace(/^v/, "").split("-")[0].split(".").map((n2) => parseInt(n2, 10) || 0);
|
|
64660
|
+
const [x, y] = [num(a), num(b2)];
|
|
64661
|
+
for (let i = 0; i < Math.max(x.length, y.length); i++) {
|
|
64662
|
+
const d = (y[i] ?? 0) - (x[i] ?? 0);
|
|
64663
|
+
if (d !== 0) return d > 0;
|
|
64664
|
+
}
|
|
64665
|
+
return false;
|
|
64666
|
+
}
|
|
64667
|
+
async function fetchLatest(timeoutMs = 2500) {
|
|
64668
|
+
try {
|
|
64669
|
+
const ctl = new AbortController();
|
|
64670
|
+
const timer = setTimeout(() => ctl.abort(), timeoutMs);
|
|
64671
|
+
const res = await fetch(`https://registry.npmjs.org/${PKG}/latest`, { headers: { accept: "application/json" }, signal: ctl.signal }).finally(() => clearTimeout(timer));
|
|
64672
|
+
if (!res.ok) return null;
|
|
64673
|
+
const { version: version4 } = await res.json();
|
|
64674
|
+
return typeof version4 === "string" ? version4 : null;
|
|
64675
|
+
} catch {
|
|
64676
|
+
return null;
|
|
64677
|
+
}
|
|
64678
|
+
}
|
|
64679
|
+
function installPlace(binPath = process.argv[1] ?? "", env = process.env) {
|
|
64680
|
+
const real = path4.resolve(binPath);
|
|
64681
|
+
const home = env.AGENTGATES_HOME || agentgatesHome();
|
|
64682
|
+
const homePkg = path4.join(home, "node_modules", ...PKG.split("/"));
|
|
64683
|
+
if (real.startsWith(path4.resolve(homePkg) + path4.sep)) {
|
|
64684
|
+
return { kind: "home", home, command: ["install", "--prefix", home, "--prefer-online", "--ignore-scripts", "--no-fund", "--no-audit", `${PKG}@latest`] };
|
|
64685
|
+
}
|
|
64686
|
+
const pkgDir = path4.resolve(path4.dirname(real), "..");
|
|
64687
|
+
if (existsSync(path4.join(pkgDir, "src", "main.ts"))) return { kind: "checkout", dir: pkgDir };
|
|
64688
|
+
return { kind: "global", command: ["install", "-g", "--prefer-online", "--ignore-scripts", "--no-fund", "--no-audit", `${PKG}@latest`] };
|
|
64689
|
+
}
|
|
64690
|
+
function runNpm(args) {
|
|
64691
|
+
return new Promise((resolve2) => {
|
|
64692
|
+
const child = spawn("npm", args, { stdio: "inherit", env: { ...process.env, NODE_NO_WARNINGS: "1" } });
|
|
64693
|
+
child.on("error", () => resolve2(127));
|
|
64694
|
+
child.on("exit", (code) => resolve2(code ?? 1));
|
|
64695
|
+
});
|
|
64696
|
+
}
|
|
64697
|
+
function installedVersionAt(place) {
|
|
64698
|
+
try {
|
|
64699
|
+
if (place.kind === "home") {
|
|
64700
|
+
return JSON.parse(readFileSync2(path4.join(place.home, "node_modules", ...PKG.split("/"), "package.json"), "utf8")).version ?? null;
|
|
64701
|
+
}
|
|
64702
|
+
if (place.kind === "checkout") {
|
|
64703
|
+
return JSON.parse(readFileSync2(path4.join(place.dir, "package.json"), "utf8")).version ?? null;
|
|
64704
|
+
}
|
|
64705
|
+
} catch {
|
|
64706
|
+
return null;
|
|
64707
|
+
}
|
|
64708
|
+
return null;
|
|
64709
|
+
}
|
|
64710
|
+
|
|
64711
|
+
// src/commands/update.ts
|
|
64712
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
64713
|
+
var jsonMode4 = (opts) => opts.json === true || !process.stdout.isTTY;
|
|
64714
|
+
async function update(opts = {}) {
|
|
64715
|
+
const latest = await fetchLatest();
|
|
64716
|
+
const place = installPlace();
|
|
64717
|
+
const stale = !!latest && olderThan(LOCAL_VERSION, latest);
|
|
64718
|
+
const base = { ok: true, package: PKG, current: LOCAL_VERSION, latest, stale, runsFrom: place.kind, ...place.kind === "home" ? { home: place.home } : place.kind === "checkout" ? { dir: place.dir } : {} };
|
|
64719
|
+
if (!latest) {
|
|
64720
|
+
if (jsonMode4(opts)) process.stdout.write(JSON.stringify({ ...base, ok: false, code: "registry_unreachable", error: "npm's registry did not answer; try again in a moment" }, null, 2) + "\n");
|
|
64721
|
+
else process.stderr.write(` ${import_picocolors10.default.red("\u2715")} npm's registry did not answer; try again in a moment
|
|
64722
|
+
`);
|
|
64723
|
+
process.exit(1);
|
|
64724
|
+
}
|
|
64725
|
+
if (opts.check || !stale) {
|
|
64726
|
+
if (jsonMode4(opts)) process.stdout.write(JSON.stringify(base, null, 2) + "\n");
|
|
64727
|
+
else if (stale) process.stdout.write(`
|
|
64728
|
+
${import_picocolors10.default.yellow("\u2191")} ${latest} is out; this copy is ${LOCAL_VERSION}. ${import_picocolors10.default.dim("agentgates update \xB7 installs it")}
|
|
64729
|
+
|
|
64730
|
+
`);
|
|
64731
|
+
else process.stdout.write(`
|
|
64732
|
+
${import_picocolors10.default.green("\u2713")} ${LOCAL_VERSION} is the latest
|
|
64733
|
+
|
|
64734
|
+
`);
|
|
64735
|
+
return;
|
|
64736
|
+
}
|
|
64737
|
+
if (place.kind === "checkout") {
|
|
64738
|
+
const line = `cd ${place.dir} && git pull --ff-only && npm run build`;
|
|
64739
|
+
if (jsonMode4(opts)) process.stdout.write(JSON.stringify({ ...base, ok: false, code: "checkout", line, error: "this copy runs from a repository checkout; pull it" }, null, 2) + "\n");
|
|
64740
|
+
else process.stdout.write(`
|
|
64741
|
+
this copy runs from a checkout at ${import_picocolors10.default.bold(place.dir)}; update it with
|
|
64742
|
+
${import_picocolors10.default.cyan(line)}
|
|
64743
|
+
|
|
64744
|
+
`);
|
|
64745
|
+
return;
|
|
64746
|
+
}
|
|
64747
|
+
if (!jsonMode4(opts)) process.stdout.write(`
|
|
64748
|
+
${import_picocolors10.default.bold("UPDATE")} ${LOCAL_VERSION} \u2192 ${latest} ${import_picocolors10.default.dim(place.kind === "home" ? `into ${place.home}` : "the global npm install")}
|
|
64749
|
+
${import_picocolors10.default.dim(`npm ${place.command.join(" ")}`)}
|
|
64750
|
+
|
|
64751
|
+
`);
|
|
64752
|
+
const code = await runNpm(place.command);
|
|
64753
|
+
const now = installedVersionAt(place);
|
|
64754
|
+
const done = code === 0 && (place.kind !== "home" || now === latest);
|
|
64755
|
+
if (jsonMode4(opts)) {
|
|
64756
|
+
process.stdout.write(JSON.stringify({ ...base, ok: done, code: done ? void 0 : "npm_failed", installed: now ?? void 0, exit: code }, null, 2) + "\n");
|
|
64757
|
+
} else if (done) {
|
|
64758
|
+
process.stdout.write(`
|
|
64759
|
+
${import_picocolors10.default.green("\u2713")} ${PKG} ${now ?? latest} is in. New terminals run it; this one already did.
|
|
64760
|
+
|
|
64761
|
+
`);
|
|
64762
|
+
} else {
|
|
64763
|
+
process.stderr.write(`
|
|
64764
|
+
${import_picocolors10.default.red("\u2715")} npm exited ${code}. Run it by hand to see why:
|
|
64765
|
+
npm ${place.command.join(" ")}
|
|
64766
|
+
|
|
64767
|
+
`);
|
|
64768
|
+
}
|
|
64769
|
+
if (!done) process.exit(1);
|
|
64770
|
+
}
|
|
64771
|
+
|
|
64565
64772
|
// src/commands/onboard.ts
|
|
64566
64773
|
var WORDMARK = [
|
|
64567
64774
|
" _ _",
|
|
@@ -64571,33 +64778,14 @@ var WORDMARK = [
|
|
|
64571
64778
|
" |___/ |___/"
|
|
64572
64779
|
].join("\n");
|
|
64573
64780
|
var TAGLINE = "Confidential virtual machines, inference, phone numbers and email, paid per use in USDC.";
|
|
64574
|
-
var
|
|
64575
|
-
function olderThan(a, b2) {
|
|
64576
|
-
const pa = a.split(".").map(Number);
|
|
64577
|
-
const pb = b2.split(".").map(Number);
|
|
64578
|
-
for (let i = 0; i < 3; i++) {
|
|
64579
|
-
if ((pa[i] ?? 0) < (pb[i] ?? 0)) return true;
|
|
64580
|
-
if ((pa[i] ?? 0) > (pb[i] ?? 0)) return false;
|
|
64581
|
-
}
|
|
64582
|
-
return false;
|
|
64583
|
-
}
|
|
64781
|
+
var latestSeen = null;
|
|
64584
64782
|
async function staleLine() {
|
|
64585
|
-
|
|
64586
|
-
|
|
64587
|
-
|
|
64588
|
-
|
|
64589
|
-
headers: { accept: "application/json" },
|
|
64590
|
-
signal: ctl.signal
|
|
64591
|
-
}).finally(() => clearTimeout(timer));
|
|
64592
|
-
if (!res.ok) return null;
|
|
64593
|
-
const { version: latest } = await res.json();
|
|
64594
|
-
if (!latest || !olderThan(LOCAL_VERSION, latest)) return null;
|
|
64595
|
-
return ` ${import_picocolors10.default.yellow("\u2191")} ${latest} is out, this copy is ${LOCAL_VERSION} \xB7 curl -fsSL ${CREATORS_ORIGIN}/api/cli/install | sh
|
|
64783
|
+
const latest = await fetchLatest(900);
|
|
64784
|
+
if (!latest || !olderThan(LOCAL_VERSION, latest)) return null;
|
|
64785
|
+
latestSeen = latest;
|
|
64786
|
+
return ` ${import_picocolors11.default.yellow("\u2191")} ${latest} is out, this copy is ${LOCAL_VERSION} \xB7 ${import_picocolors11.default.bold("agentgates update")} installs it
|
|
64596
64787
|
|
|
64597
64788
|
`;
|
|
64598
|
-
} catch {
|
|
64599
|
-
return null;
|
|
64600
|
-
}
|
|
64601
64789
|
}
|
|
64602
64790
|
function makePut(w) {
|
|
64603
64791
|
return (s) => {
|
|
@@ -64607,14 +64795,15 @@ function makePut(w) {
|
|
|
64607
64795
|
}
|
|
64608
64796
|
function banner() {
|
|
64609
64797
|
const w = water();
|
|
64610
|
-
if (!w) process.stdout.write("\n" +
|
|
64798
|
+
if (!w) process.stdout.write("\n" + import_picocolors11.default.cyan(WORDMARK) + "\n\n");
|
|
64611
64799
|
const put = makePut(w);
|
|
64612
|
-
put(` ${
|
|
64800
|
+
put(` ${import_picocolors11.default.dim(TAGLINE)}
|
|
64613
64801
|
|
|
64614
64802
|
`);
|
|
64615
64803
|
return { w, put };
|
|
64616
64804
|
}
|
|
64617
64805
|
var MENU = {
|
|
64806
|
+
update: { label: "update the CLI to the latest", hint: "(agentgates update)" },
|
|
64618
64807
|
account: { label: "log in: mint my twelve words, or show my account", hint: "(agentgates init)" },
|
|
64619
64808
|
seed: { label: "show my twelve words", hint: "(agentgates init --reveal-seed)" },
|
|
64620
64809
|
balance: { label: "my balance and the address that tops it up", hint: "(agentgates browser balance)" },
|
|
@@ -64642,17 +64831,17 @@ function lanesLedBy(lane) {
|
|
|
64642
64831
|
const lead = leadLane(lane);
|
|
64643
64832
|
return [lead, ...LANE_ORDER.filter((l) => l !== lead)];
|
|
64644
64833
|
}
|
|
64645
|
-
function menuOrder(lane, hasAccount) {
|
|
64834
|
+
function menuOrder(lane, hasAccount, stale) {
|
|
64646
64835
|
const browse = lanesLedBy(lane).map((l) => LANES[l].key);
|
|
64647
64836
|
const account = hasAccount ? ["account", "seed", "balance"] : ["account"];
|
|
64648
|
-
return [...account, ...browse, "docs", "poke", "wallet"];
|
|
64837
|
+
return [...stale ? ["update"] : [], ...account, ...browse, "docs", "poke", "wallet"];
|
|
64649
64838
|
}
|
|
64650
64839
|
function printMenu(put, order, first) {
|
|
64651
|
-
put(` ${
|
|
64840
|
+
put(` ${import_picocolors11.default.bold(first ? "choose how to start:" : "what next:")}
|
|
64652
64841
|
`);
|
|
64653
64842
|
order.forEach((k, i) => {
|
|
64654
64843
|
const item = MENU[k];
|
|
64655
|
-
put(` ${
|
|
64844
|
+
put(` ${import_picocolors11.default.cyan(`${i + 1}.`)} ${item.label}${item.hint ? ` ${import_picocolors11.default.dim(item.hint)}` : ""}
|
|
64656
64845
|
`);
|
|
64657
64846
|
});
|
|
64658
64847
|
}
|
|
@@ -64664,17 +64853,17 @@ async function printDocs(put, lane) {
|
|
|
64664
64853
|
if (!res.ok) throw new Error(String(res.status));
|
|
64665
64854
|
const md = (await res.text()).replace(/\s+$/, "");
|
|
64666
64855
|
put(`
|
|
64667
|
-
${
|
|
64856
|
+
${import_picocolors11.default.bold(`THE ${LANES[lead].name.toUpperCase()} CONTRACT`)} ${import_picocolors11.default.dim(url(lead))}
|
|
64668
64857
|
|
|
64669
64858
|
`);
|
|
64670
64859
|
put(md + "\n\n");
|
|
64671
|
-
for (const other of others) put(` ${
|
|
64860
|
+
for (const other of others) put(` ${import_picocolors11.default.dim(`the ${LANES[other].name} contract:`)} ${url(other)}
|
|
64672
64861
|
`);
|
|
64673
64862
|
put("\n");
|
|
64674
64863
|
} catch {
|
|
64675
|
-
put(` ${
|
|
64864
|
+
put(` ${import_picocolors11.default.red("\u2715")} could not fetch the contract; the URLs:
|
|
64676
64865
|
`);
|
|
64677
|
-
for (const l of LANE_ORDER) put(` ${
|
|
64866
|
+
for (const l of LANE_ORDER) put(` ${import_picocolors11.default.cyan(LANES[l].name.padEnd(16))} ${url(l)}
|
|
64678
64867
|
`);
|
|
64679
64868
|
put("\n");
|
|
64680
64869
|
}
|
|
@@ -64684,16 +64873,16 @@ async function onboard(opts = {}) {
|
|
|
64684
64873
|
const { w, put } = banner();
|
|
64685
64874
|
const existing = await loadProfile(profileName).catch(() => null);
|
|
64686
64875
|
if (existing) {
|
|
64687
|
-
put(` ${
|
|
64876
|
+
put(` ${import_picocolors11.default.green("\u2713")} already paired as ${import_picocolors11.default.bold(existing.walletAddress ?? existing.userId)}
|
|
64688
64877
|
`);
|
|
64689
64878
|
}
|
|
64690
64879
|
const account = await loadPasswordsKey().catch(() => null);
|
|
64691
64880
|
if (account) {
|
|
64692
|
-
put(` ${
|
|
64881
|
+
put(` ${import_picocolors11.default.green("\u2713")} logged in as ${import_picocolors11.default.bold(account.state.address)} ${import_picocolors11.default.dim(account.state.mnemonic ? "(twelve words on this machine)" : "(a bare key)")}
|
|
64693
64882
|
|
|
64694
64883
|
`);
|
|
64695
64884
|
} else {
|
|
64696
|
-
put(` ${
|
|
64885
|
+
put(` ${import_picocolors11.default.dim("no account on this machine yet: option 1 mints your twelve words")}
|
|
64697
64886
|
|
|
64698
64887
|
`);
|
|
64699
64888
|
}
|
|
@@ -64701,39 +64890,39 @@ async function onboard(opts = {}) {
|
|
|
64701
64890
|
put(` No terminal attached, so no menu. The machine door:
|
|
64702
64891
|
|
|
64703
64892
|
`);
|
|
64704
|
-
put(` agentgates compute plans --json ${
|
|
64893
|
+
put(` agentgates compute plans --json ${import_picocolors11.default.dim("\xB7 virtual machine pricing, JSON")}
|
|
64705
64894
|
`);
|
|
64706
|
-
put(` agentgates inference models --json ${
|
|
64895
|
+
put(` agentgates inference models --json ${import_picocolors11.default.dim("\xB7 model pricing, JSON; --tier --tag --org --search filter it")}
|
|
64707
64896
|
`);
|
|
64708
|
-
put(` agentgates phone pricing --json ${
|
|
64897
|
+
put(` agentgates phone pricing --json ${import_picocolors11.default.dim("\xB7 number plans, usage and payphone windows, JSON")}
|
|
64709
64898
|
`);
|
|
64710
|
-
put(` agentgates email pricing --json ${
|
|
64899
|
+
put(` agentgates email pricing --json ${import_picocolors11.default.dim("\xB7 the free inbox, plans and per-send price, JSON")}
|
|
64711
64900
|
`);
|
|
64712
|
-
put(` agentgates passwords pricing --json ${
|
|
64901
|
+
put(` agentgates passwords pricing --json ${import_picocolors11.default.dim("\xB7 plans and per-use meter")}
|
|
64713
64902
|
`);
|
|
64714
|
-
put(` agentgates init ${
|
|
64903
|
+
put(` agentgates init ${import_picocolors11.default.dim("\xB7 mint your twelve words: your account, printed once with what to tell your human")}
|
|
64715
64904
|
`);
|
|
64716
|
-
put(` agentgates init --reveal-seed ${
|
|
64905
|
+
put(` agentgates init --reveal-seed ${import_picocolors11.default.dim("\xB7 print them again")}
|
|
64717
64906
|
`);
|
|
64718
|
-
put(` agentgates browser balance --json ${
|
|
64907
|
+
put(` agentgates browser balance --json ${import_picocolors11.default.dim("\xB7 your balance and the address that tops it up (USDC on Base or Polygon)")}
|
|
64719
64908
|
`);
|
|
64720
|
-
put(` agentgates open ${
|
|
64909
|
+
put(` agentgates open ${import_picocolors11.default.dim("\xB7 hand this session to a human's browser on this machine")}
|
|
64721
64910
|
`);
|
|
64722
|
-
put(` ${CREATORS_ORIGIN}/api/compute/docs ${
|
|
64911
|
+
put(` ${CREATORS_ORIGIN}/api/compute/docs ${import_picocolors11.default.dim("\xB7 the buy/read/renew/destroy contract")}
|
|
64723
64912
|
`);
|
|
64724
|
-
put(` ${CREATORS_ORIGIN}/api/inference/docs ${
|
|
64913
|
+
put(` ${CREATORS_ORIGIN}/api/inference/docs ${import_picocolors11.default.dim("\xB7 the chat contract, x402 or Bearer")}
|
|
64725
64914
|
`);
|
|
64726
|
-
put(` ${CREATORS_ORIGIN}/api/identity/docs/phone ${
|
|
64915
|
+
put(` ${CREATORS_ORIGIN}/api/identity/docs/phone ${import_picocolors11.default.dim("\xB7 the phone contract: numbers, texts, calls, the payphone")}
|
|
64727
64916
|
`);
|
|
64728
|
-
put(` ${CREATORS_ORIGIN}/api/identity/docs/email ${
|
|
64917
|
+
put(` ${CREATORS_ORIGIN}/api/identity/docs/email ${import_picocolors11.default.dim("\xB7 the email contract: inboxes, plans, sends, wait-code")}
|
|
64729
64918
|
`);
|
|
64730
|
-
put(` ${CREATORS_ORIGIN}/api/identity/docs/passwords ${
|
|
64919
|
+
put(` ${CREATORS_ORIGIN}/api/identity/docs/passwords ${import_picocolors11.default.dim("\xB7 the passwords contract: store, permits, uses")}
|
|
64731
64920
|
`);
|
|
64732
|
-
put(` ${CREATORS_ORIGIN}/llms.txt ${
|
|
64921
|
+
put(` ${CREATORS_ORIGIN}/llms.txt ${import_picocolors11.default.dim("\xB7 the whole surface")}
|
|
64733
64922
|
|
|
64734
64923
|
`);
|
|
64735
64924
|
if (!existing) {
|
|
64736
|
-
put(` Pairing a wallet needs a human at a browser: ${
|
|
64925
|
+
put(` Pairing a wallet needs a human at a browser: ${import_picocolors11.default.bold("agentgates onboard")} in a real terminal.
|
|
64737
64926
|
|
|
64738
64927
|
`);
|
|
64739
64928
|
}
|
|
@@ -64743,7 +64932,7 @@ async function onboard(opts = {}) {
|
|
|
64743
64932
|
}
|
|
64744
64933
|
const stale = await staleLine();
|
|
64745
64934
|
if (stale) put(stale);
|
|
64746
|
-
const order = menuOrder(opts.lane, !!account).filter((k) => existing ? k !== "wallet" : true);
|
|
64935
|
+
const order = menuOrder(opts.lane, !!account, latestSeen !== null).filter((k) => existing ? k !== "wallet" : true);
|
|
64747
64936
|
printMenu(put, order, true);
|
|
64748
64937
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
64749
64938
|
const exitDefault = String(order.indexOf("poke") + 1);
|
|
@@ -64754,7 +64943,7 @@ async function onboard(opts = {}) {
|
|
|
64754
64943
|
const fallback = first ? "1" : exitDefault;
|
|
64755
64944
|
let choice;
|
|
64756
64945
|
try {
|
|
64757
|
-
choice = (await rl.question(` ${
|
|
64946
|
+
choice = (await rl.question(` ${import_picocolors11.default.dim(`choice [${fallback}]:`)} `)).trim() || fallback;
|
|
64758
64947
|
} catch {
|
|
64759
64948
|
if (first) w?.stop();
|
|
64760
64949
|
process.stdout.write("\n");
|
|
@@ -64778,7 +64967,16 @@ async function onboard(opts = {}) {
|
|
|
64778
64967
|
await runLoginFlow({ profile: profileName, jsonMode: false, ttyHeader: "Pairing this terminal with your wallet\u2026" });
|
|
64779
64968
|
process.stdout.write("\n");
|
|
64780
64969
|
} catch {
|
|
64781
|
-
plain(` ${
|
|
64970
|
+
plain(` ${import_picocolors11.default.red("\u2715")} pairing didn't complete
|
|
64971
|
+
|
|
64972
|
+
`);
|
|
64973
|
+
}
|
|
64974
|
+
break;
|
|
64975
|
+
case "update":
|
|
64976
|
+
try {
|
|
64977
|
+
await update({});
|
|
64978
|
+
} catch {
|
|
64979
|
+
plain(` ${import_picocolors11.default.red("\u2715")} the update did not run; try: agentgates update
|
|
64782
64980
|
|
|
64783
64981
|
`);
|
|
64784
64982
|
}
|
|
@@ -64787,7 +64985,7 @@ async function onboard(opts = {}) {
|
|
|
64787
64985
|
try {
|
|
64788
64986
|
await passwordsInit({});
|
|
64789
64987
|
} catch {
|
|
64790
|
-
plain(` ${
|
|
64988
|
+
plain(` ${import_picocolors11.default.red("\u2715")} the account could not be read or minted
|
|
64791
64989
|
|
|
64792
64990
|
`);
|
|
64793
64991
|
}
|
|
@@ -64796,7 +64994,7 @@ async function onboard(opts = {}) {
|
|
|
64796
64994
|
try {
|
|
64797
64995
|
await passwordsInit({ revealSeed: true });
|
|
64798
64996
|
} catch {
|
|
64799
|
-
plain(` ${
|
|
64997
|
+
plain(` ${import_picocolors11.default.red("\u2715")} the words could not be read
|
|
64800
64998
|
|
|
64801
64999
|
`);
|
|
64802
65000
|
}
|
|
@@ -64805,7 +65003,7 @@ async function onboard(opts = {}) {
|
|
|
64805
65003
|
try {
|
|
64806
65004
|
await browserBalance({});
|
|
64807
65005
|
} catch {
|
|
64808
|
-
plain(` ${
|
|
65006
|
+
plain(` ${import_picocolors11.default.red("\u2715")} the balance could not be read
|
|
64809
65007
|
|
|
64810
65008
|
`);
|
|
64811
65009
|
}
|
|
@@ -64814,7 +65012,7 @@ async function onboard(opts = {}) {
|
|
|
64814
65012
|
try {
|
|
64815
65013
|
await computePlans({});
|
|
64816
65014
|
} catch {
|
|
64817
|
-
plain(` ${
|
|
65015
|
+
plain(` ${import_picocolors11.default.red("\u2715")} could not read the compute catalog
|
|
64818
65016
|
|
|
64819
65017
|
`);
|
|
64820
65018
|
}
|
|
@@ -64823,7 +65021,7 @@ async function onboard(opts = {}) {
|
|
|
64823
65021
|
try {
|
|
64824
65022
|
await inferenceModels({});
|
|
64825
65023
|
} catch {
|
|
64826
|
-
plain(` ${
|
|
65024
|
+
plain(` ${import_picocolors11.default.red("\u2715")} could not read the model catalog
|
|
64827
65025
|
|
|
64828
65026
|
`);
|
|
64829
65027
|
}
|
|
@@ -64832,7 +65030,7 @@ async function onboard(opts = {}) {
|
|
|
64832
65030
|
try {
|
|
64833
65031
|
await phonePricing({});
|
|
64834
65032
|
} catch {
|
|
64835
|
-
plain(` ${
|
|
65033
|
+
plain(` ${import_picocolors11.default.red("\u2715")} could not read the phone catalog
|
|
64836
65034
|
|
|
64837
65035
|
`);
|
|
64838
65036
|
}
|
|
@@ -64841,7 +65039,7 @@ async function onboard(opts = {}) {
|
|
|
64841
65039
|
try {
|
|
64842
65040
|
await emailPricing({});
|
|
64843
65041
|
} catch {
|
|
64844
|
-
plain(` ${
|
|
65042
|
+
plain(` ${import_picocolors11.default.red("\u2715")} could not read the email catalog
|
|
64845
65043
|
|
|
64846
65044
|
`);
|
|
64847
65045
|
}
|
|
@@ -64850,7 +65048,7 @@ async function onboard(opts = {}) {
|
|
|
64850
65048
|
try {
|
|
64851
65049
|
await passwordsPricing({});
|
|
64852
65050
|
} catch {
|
|
64853
|
-
plain(` ${
|
|
65051
|
+
plain(` ${import_picocolors11.default.red("\u2715")} could not read the passwords catalog
|
|
64854
65052
|
|
|
64855
65053
|
`);
|
|
64856
65054
|
}
|
|
@@ -64866,36 +65064,136 @@ async function onboard(opts = {}) {
|
|
|
64866
65064
|
}
|
|
64867
65065
|
}
|
|
64868
65066
|
function printNext(put) {
|
|
64869
|
-
put(` ${
|
|
65067
|
+
put(` ${import_picocolors11.default.dim("agentgates init")} ${import_picocolors11.default.dim("\xB7 your account: mint the twelve words, or show it; --reveal-seed prints the words")}
|
|
64870
65068
|
`);
|
|
64871
|
-
put(` ${
|
|
65069
|
+
put(` ${import_picocolors11.default.dim("agentgates browser balance")} ${import_picocolors11.default.dim("\xB7 your balance and the address that tops it up")}
|
|
64872
65070
|
`);
|
|
64873
|
-
put(` ${
|
|
65071
|
+
put(` ${import_picocolors11.default.dim("agentgates compute plans")} ${import_picocolors11.default.dim("\xB7 virtual machines by the hour")}
|
|
64874
65072
|
`);
|
|
64875
|
-
put(` ${
|
|
65073
|
+
put(` ${import_picocolors11.default.dim("agentgates inference models")} ${import_picocolors11.default.dim("\xB7 models by the token")}
|
|
64876
65074
|
`);
|
|
64877
|
-
put(` ${
|
|
65075
|
+
put(` ${import_picocolors11.default.dim("agentgates phone pricing")} ${import_picocolors11.default.dim("\xB7 numbers by the month, calls by the minute")}
|
|
64878
65076
|
`);
|
|
64879
|
-
put(` ${
|
|
65077
|
+
put(` ${import_picocolors11.default.dim("agentgates email pricing")} ${import_picocolors11.default.dim("\xB7 inboxes free on a balance, sends per message")}
|
|
64880
65078
|
`);
|
|
64881
|
-
put(` ${
|
|
65079
|
+
put(` ${import_picocolors11.default.dim("agentgates passwords pricing")} ${import_picocolors11.default.dim("\xB7 logins an agent uses and never sees")}
|
|
64882
65080
|
`);
|
|
64883
|
-
put(` ${
|
|
65081
|
+
put(` ${import_picocolors11.default.dim("agentgates --help")} ${import_picocolors11.default.dim("\xB7 everything else")}
|
|
64884
65082
|
|
|
64885
65083
|
`);
|
|
64886
65084
|
}
|
|
64887
65085
|
|
|
65086
|
+
// src/commands/keys.ts
|
|
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
|
+
|
|
64888
65186
|
// src/commands/logout.ts
|
|
64889
|
-
var
|
|
65187
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
64890
65188
|
async function logout(opts) {
|
|
64891
65189
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
64892
65190
|
const resolved = await resolveProfile(requested);
|
|
64893
65191
|
if (!resolved) {
|
|
64894
|
-
process.stdout.write(
|
|
65192
|
+
process.stdout.write(import_picocolors13.default.dim("Not logged in \u2014 nothing to log out.\n"));
|
|
64895
65193
|
return;
|
|
64896
65194
|
}
|
|
64897
65195
|
if (resolved.autoSelected) {
|
|
64898
|
-
process.stderr.write(
|
|
65196
|
+
process.stderr.write(import_picocolors13.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
64899
65197
|
`));
|
|
64900
65198
|
}
|
|
64901
65199
|
const { profile, name: profileName } = resolved;
|
|
@@ -64920,15 +65218,15 @@ async function logout(opts) {
|
|
|
64920
65218
|
const removed = await deleteProfile(profileName);
|
|
64921
65219
|
if (removed) {
|
|
64922
65220
|
process.stdout.write(
|
|
64923
|
-
|
|
65221
|
+
import_picocolors13.default.green(`\u2713 Logged out of profile ${import_picocolors13.default.bold(profileName)}.
|
|
64924
65222
|
`)
|
|
64925
65223
|
);
|
|
64926
65224
|
}
|
|
64927
65225
|
if (serverError) {
|
|
64928
65226
|
process.stderr.write(
|
|
64929
|
-
|
|
65227
|
+
import_picocolors13.default.yellow(
|
|
64930
65228
|
`\u26A0 Couldn't revoke server-side: ${serverError}
|
|
64931
|
-
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")}.
|
|
64932
65230
|
`
|
|
64933
65231
|
)
|
|
64934
65232
|
);
|
|
@@ -64936,49 +65234,49 @@ async function logout(opts) {
|
|
|
64936
65234
|
}
|
|
64937
65235
|
|
|
64938
65236
|
// src/commands/whoami.ts
|
|
64939
|
-
var
|
|
65237
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
64940
65238
|
async function whoami(opts) {
|
|
64941
65239
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
64942
65240
|
const resolved = await resolveProfile(requested);
|
|
64943
65241
|
if (!resolved) {
|
|
64944
|
-
process.stderr.write(
|
|
65242
|
+
process.stderr.write(import_picocolors14.default.red("Not logged in. Run agentgates login first.\n"));
|
|
64945
65243
|
process.exit(2);
|
|
64946
65244
|
}
|
|
64947
65245
|
if (resolved.autoSelected) {
|
|
64948
|
-
process.stderr.write(
|
|
65246
|
+
process.stderr.write(import_picocolors14.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
64949
65247
|
`));
|
|
64950
65248
|
}
|
|
64951
65249
|
const { profile, name: profileName } = resolved;
|
|
64952
|
-
const
|
|
65250
|
+
const jsonMode5 = opts.json === true;
|
|
64953
65251
|
const outcome = await callWithAutoRelogin({
|
|
64954
65252
|
profile,
|
|
64955
65253
|
profileName,
|
|
64956
|
-
jsonMode:
|
|
64957
|
-
ttyHeader:
|
|
65254
|
+
jsonMode: jsonMode5,
|
|
65255
|
+
ttyHeader: import_picocolors14.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
64958
65256
|
fn: (bearer, origin) => apiFetch("/api/whoami", { bearer, origin })
|
|
64959
65257
|
});
|
|
64960
65258
|
if (outcome.kind === "auth_failed") {
|
|
64961
|
-
if (
|
|
65259
|
+
if (jsonMode5) {
|
|
64962
65260
|
process.stdout.write(
|
|
64963
65261
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
64964
65262
|
);
|
|
64965
65263
|
process.exit(1);
|
|
64966
65264
|
}
|
|
64967
|
-
process.stderr.write(
|
|
65265
|
+
process.stderr.write(import_picocolors14.default.red(`\u2715 ${outcome.reason}.
|
|
64968
65266
|
`));
|
|
64969
65267
|
process.exit(1);
|
|
64970
65268
|
}
|
|
64971
65269
|
if (outcome.kind === "error") {
|
|
64972
65270
|
const err = outcome.error;
|
|
64973
65271
|
if (err instanceof ApiError) {
|
|
64974
|
-
process.stderr.write(
|
|
65272
|
+
process.stderr.write(import_picocolors14.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
64975
65273
|
`));
|
|
64976
65274
|
process.exit(1);
|
|
64977
65275
|
}
|
|
64978
65276
|
throw err;
|
|
64979
65277
|
}
|
|
64980
65278
|
const me = outcome.result;
|
|
64981
|
-
if (
|
|
65279
|
+
if (jsonMode5) {
|
|
64982
65280
|
process.stdout.write(JSON.stringify(me, null, 2) + "\n");
|
|
64983
65281
|
return;
|
|
64984
65282
|
}
|
|
@@ -64992,7 +65290,7 @@ async function whoami(opts) {
|
|
|
64992
65290
|
process.stdout.write(`Solana ${me.solanaAddress}
|
|
64993
65291
|
`);
|
|
64994
65292
|
}
|
|
64995
|
-
process.stdout.write(`Scopes ${me.scopes.join(", ") ||
|
|
65293
|
+
process.stdout.write(`Scopes ${me.scopes.join(", ") || import_picocolors14.default.dim("(none)")}
|
|
64996
65294
|
`);
|
|
64997
65295
|
const txCap = me.perTxUSD == null ? "No limit/tx" : `$${me.perTxUSD}/tx`;
|
|
64998
65296
|
const dayCap = me.perDayUSD == null ? "No limit/day" : `$${me.perDayUSD}/day`;
|
|
@@ -65009,7 +65307,7 @@ async function whoami(opts) {
|
|
|
65009
65307
|
`
|
|
65010
65308
|
);
|
|
65011
65309
|
process.stdout.write(
|
|
65012
|
-
`Profile ${profileName === DEFAULT_PROFILE ?
|
|
65310
|
+
`Profile ${profileName === DEFAULT_PROFILE ? import_picocolors14.default.dim("(default)") : profileName}
|
|
65013
65311
|
`
|
|
65014
65312
|
);
|
|
65015
65313
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -65023,7 +65321,7 @@ function formatDate(iso) {
|
|
|
65023
65321
|
}
|
|
65024
65322
|
|
|
65025
65323
|
// src/commands/send.ts
|
|
65026
|
-
var
|
|
65324
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
65027
65325
|
|
|
65028
65326
|
// src/lib/status.ts
|
|
65029
65327
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -65173,20 +65471,20 @@ async function send(amount, asset, opts) {
|
|
|
65173
65471
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65174
65472
|
const resolved = await resolveProfile(requested);
|
|
65175
65473
|
if (!resolved) {
|
|
65176
|
-
process.stderr.write(
|
|
65474
|
+
process.stderr.write(import_picocolors15.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65177
65475
|
process.exit(2);
|
|
65178
65476
|
}
|
|
65179
65477
|
if (resolved.autoSelected) {
|
|
65180
|
-
process.stderr.write(
|
|
65478
|
+
process.stderr.write(import_picocolors15.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65181
65479
|
`));
|
|
65182
65480
|
}
|
|
65183
65481
|
const { profile, name: profileName } = resolved;
|
|
65184
65482
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
65185
|
-
const
|
|
65483
|
+
const jsonMode5 = opts.json === true || !stdoutIsTty;
|
|
65186
65484
|
const amountNumber = Number(amount);
|
|
65187
65485
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
65188
65486
|
process.stderr.write(
|
|
65189
|
-
|
|
65487
|
+
import_picocolors15.default.red(`\u2715 amount must be a positive number (got ${import_picocolors15.default.bold(amount)}).
|
|
65190
65488
|
`)
|
|
65191
65489
|
);
|
|
65192
65490
|
process.exit(2);
|
|
@@ -65194,23 +65492,23 @@ async function send(amount, asset, opts) {
|
|
|
65194
65492
|
const assetNormalized = asset.toLowerCase();
|
|
65195
65493
|
if (assetNormalized !== "native" && assetNormalized !== "usdc") {
|
|
65196
65494
|
process.stderr.write(
|
|
65197
|
-
|
|
65198
|
-
`\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)}).
|
|
65199
65497
|
`
|
|
65200
65498
|
)
|
|
65201
65499
|
);
|
|
65202
65500
|
process.exit(2);
|
|
65203
65501
|
}
|
|
65204
65502
|
if (!opts.to || opts.to.trim() === "") {
|
|
65205
|
-
process.stderr.write(
|
|
65503
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 --to <address> is required.
|
|
65206
65504
|
`));
|
|
65207
65505
|
process.exit(2);
|
|
65208
65506
|
}
|
|
65209
65507
|
if (isSolanaChainAlias(opts.chain)) {
|
|
65210
65508
|
if (EVM_ADDRESS_RE.test(opts.to)) {
|
|
65211
65509
|
process.stderr.write(
|
|
65212
|
-
|
|
65213
|
-
`\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.
|
|
65214
65512
|
`
|
|
65215
65513
|
)
|
|
65216
65514
|
);
|
|
@@ -65218,10 +65516,10 @@ async function send(amount, asset, opts) {
|
|
|
65218
65516
|
}
|
|
65219
65517
|
if (!SOLANA_ADDRESS_RE.test(opts.to)) {
|
|
65220
65518
|
process.stderr.write(
|
|
65221
|
-
|
|
65222
|
-
`\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)}).
|
|
65223
65521
|
`
|
|
65224
|
-
) +
|
|
65522
|
+
) + import_picocolors15.default.dim(
|
|
65225
65523
|
` SNS resolution is deferred to a future server-side change;
|
|
65226
65524
|
for now Solana sends require the literal pubkey.
|
|
65227
65525
|
`
|
|
@@ -65232,8 +65530,8 @@ async function send(amount, asset, opts) {
|
|
|
65232
65530
|
}
|
|
65233
65531
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
65234
65532
|
process.stderr.write(
|
|
65235
|
-
|
|
65236
|
-
`) +
|
|
65533
|
+
import_picocolors15.default.red(`\u2715 --user-stated <text> is required.
|
|
65534
|
+
`) + import_picocolors15.default.dim(
|
|
65237
65535
|
` This is the trust-gap defense: pass the verbatim user request so
|
|
65238
65536
|
the approval modal can cross-check what the agent thinks the user
|
|
65239
65537
|
asked for vs. the actual decoded transaction.
|
|
@@ -65251,7 +65549,7 @@ async function send(amount, asset, opts) {
|
|
|
65251
65549
|
const n2 = Number(opts.maxUsd);
|
|
65252
65550
|
if (!Number.isFinite(n2) || n2 <= 0) {
|
|
65253
65551
|
process.stderr.write(
|
|
65254
|
-
|
|
65552
|
+
import_picocolors15.default.red(`\u2715 --max-usd must be a positive number (got ${opts.maxUsd}).
|
|
65255
65553
|
`)
|
|
65256
65554
|
);
|
|
65257
65555
|
process.exit(2);
|
|
@@ -65291,12 +65589,12 @@ async function send(amount, asset, opts) {
|
|
|
65291
65589
|
try {
|
|
65292
65590
|
activeProfile = await runLoginFlow({
|
|
65293
65591
|
profile: profileName,
|
|
65294
|
-
jsonMode:
|
|
65592
|
+
jsonMode: jsonMode5,
|
|
65295
65593
|
origin: activeProfile.mcpOrigin,
|
|
65296
|
-
ttyHeader:
|
|
65594
|
+
ttyHeader: import_picocolors15.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
65297
65595
|
});
|
|
65298
65596
|
} catch (reloginErr) {
|
|
65299
|
-
if (
|
|
65597
|
+
if (jsonMode5) {
|
|
65300
65598
|
emitNdjson({
|
|
65301
65599
|
ok: false,
|
|
65302
65600
|
status: "auth_failed",
|
|
@@ -65305,7 +65603,7 @@ async function send(amount, asset, opts) {
|
|
|
65305
65603
|
process.exit(1);
|
|
65306
65604
|
}
|
|
65307
65605
|
process.stderr.write(
|
|
65308
|
-
|
|
65606
|
+
import_picocolors15.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65309
65607
|
`)
|
|
65310
65608
|
);
|
|
65311
65609
|
process.exit(1);
|
|
@@ -65319,7 +65617,7 @@ async function send(amount, asset, opts) {
|
|
|
65319
65617
|
});
|
|
65320
65618
|
} catch (retryErr) {
|
|
65321
65619
|
if (retryErr instanceof ApiError) {
|
|
65322
|
-
if (
|
|
65620
|
+
if (jsonMode5) {
|
|
65323
65621
|
emitNdjson({
|
|
65324
65622
|
ok: false,
|
|
65325
65623
|
status: retryErr.status === 401 ? "auth_failed" : "propose_failed",
|
|
@@ -65329,7 +65627,7 @@ async function send(amount, asset, opts) {
|
|
|
65329
65627
|
process.exit(1);
|
|
65330
65628
|
}
|
|
65331
65629
|
process.stderr.write(
|
|
65332
|
-
|
|
65630
|
+
import_picocolors15.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
65333
65631
|
`)
|
|
65334
65632
|
);
|
|
65335
65633
|
process.exit(1);
|
|
@@ -65337,7 +65635,7 @@ async function send(amount, asset, opts) {
|
|
|
65337
65635
|
throw retryErr;
|
|
65338
65636
|
}
|
|
65339
65637
|
} else if (err instanceof ApiError) {
|
|
65340
|
-
if (
|
|
65638
|
+
if (jsonMode5) {
|
|
65341
65639
|
emitNdjson({
|
|
65342
65640
|
ok: false,
|
|
65343
65641
|
status: "propose_failed",
|
|
@@ -65346,7 +65644,7 @@ async function send(amount, asset, opts) {
|
|
|
65346
65644
|
});
|
|
65347
65645
|
process.exit(1);
|
|
65348
65646
|
}
|
|
65349
|
-
process.stderr.write(
|
|
65647
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65350
65648
|
`));
|
|
65351
65649
|
process.exit(1);
|
|
65352
65650
|
} else {
|
|
@@ -65354,7 +65652,7 @@ async function send(amount, asset, opts) {
|
|
|
65354
65652
|
}
|
|
65355
65653
|
}
|
|
65356
65654
|
if (isBlocked(proposed)) {
|
|
65357
|
-
if (
|
|
65655
|
+
if (jsonMode5) {
|
|
65358
65656
|
const envelope = {
|
|
65359
65657
|
ok: false,
|
|
65360
65658
|
status: "blocked",
|
|
@@ -65372,17 +65670,17 @@ async function send(amount, asset, opts) {
|
|
|
65372
65670
|
if (proposed.detail) {
|
|
65373
65671
|
const d = proposed.detail;
|
|
65374
65672
|
process.stderr.write(
|
|
65375
|
-
|
|
65673
|
+
import_picocolors15.default.red(`\u2715 ${d.asset_symbol ?? "Asset"} on ${d.chain_name ?? "chain"}: `) + `have ${d.balance}, need ${d.required} (short ${d.deficit})
|
|
65376
65674
|
`
|
|
65377
65675
|
);
|
|
65378
65676
|
} else {
|
|
65379
|
-
process.stderr.write(
|
|
65677
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${proposed.reason}
|
|
65380
65678
|
`));
|
|
65381
65679
|
}
|
|
65382
65680
|
if (proposed.upgrade_url) {
|
|
65383
65681
|
process.stderr.write(
|
|
65384
65682
|
` Open this to grant access, then re-run the command:
|
|
65385
|
-
${
|
|
65683
|
+
${import_picocolors15.default.cyan(proposed.upgrade_url)}
|
|
65386
65684
|
`
|
|
65387
65685
|
);
|
|
65388
65686
|
}
|
|
@@ -65392,21 +65690,21 @@ async function send(amount, asset, opts) {
|
|
|
65392
65690
|
const a = proposed.recommended_actions[i];
|
|
65393
65691
|
process.stderr.write(` ${i + 1}. ${a.label}
|
|
65394
65692
|
`);
|
|
65395
|
-
if (a.reasoning) process.stderr.write(
|
|
65693
|
+
if (a.reasoning) process.stderr.write(import_picocolors15.default.dim(` ${a.reasoning}
|
|
65396
65694
|
`));
|
|
65397
65695
|
if (a.action_intent && a.action_intent.external_url) {
|
|
65398
65696
|
process.stderr.write(
|
|
65399
|
-
` ${
|
|
65697
|
+
` ${import_picocolors15.default.cyan(a.action_intent.external_url)}
|
|
65400
65698
|
`
|
|
65401
65699
|
);
|
|
65402
65700
|
}
|
|
65403
65701
|
}
|
|
65404
65702
|
}
|
|
65405
65703
|
if (proposed.suggestions && proposed.suggestions.length > 0) {
|
|
65406
|
-
process.stderr.write(
|
|
65704
|
+
process.stderr.write(import_picocolors15.default.dim("\n Other ways to fund:\n"));
|
|
65407
65705
|
for (const s of proposed.suggestions) {
|
|
65408
65706
|
if (s.kind === "ask_user") continue;
|
|
65409
|
-
process.stderr.write(
|
|
65707
|
+
process.stderr.write(import_picocolors15.default.dim(` \u2022 ${s.label}
|
|
65410
65708
|
`));
|
|
65411
65709
|
}
|
|
65412
65710
|
}
|
|
@@ -65418,7 +65716,7 @@ async function send(amount, asset, opts) {
|
|
|
65418
65716
|
if (process.env.CI === "1" || process.env.CI === "true") return false;
|
|
65419
65717
|
return true;
|
|
65420
65718
|
})();
|
|
65421
|
-
if (
|
|
65719
|
+
if (jsonMode5) {
|
|
65422
65720
|
emitNdjson({
|
|
65423
65721
|
ok: true,
|
|
65424
65722
|
status: "proposed",
|
|
@@ -65433,8 +65731,8 @@ async function send(amount, asset, opts) {
|
|
|
65433
65731
|
} else {
|
|
65434
65732
|
process.stdout.write(
|
|
65435
65733
|
`
|
|
65436
|
-
${
|
|
65437
|
-
${
|
|
65734
|
+
${import_picocolors15.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
65735
|
+
${import_picocolors15.default.cyan(proposed.approval_url)}
|
|
65438
65736
|
|
|
65439
65737
|
`
|
|
65440
65738
|
);
|
|
@@ -65450,10 +65748,10 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65450
65748
|
intervalMs: POLL_INTERVAL_MS,
|
|
65451
65749
|
giveUpMs: POLL_GIVEUP_MS,
|
|
65452
65750
|
onTick: (s) => {
|
|
65453
|
-
if (
|
|
65751
|
+
if (jsonMode5) {
|
|
65454
65752
|
emitNdjson({ status: s.status, intent_id: s.approval_id });
|
|
65455
65753
|
} else {
|
|
65456
|
-
process.stdout.write(` ${describeStatus(s.status)}${
|
|
65754
|
+
process.stdout.write(` ${describeStatus(s.status)}${import_picocolors15.default.dim("\u2026")}\r`);
|
|
65457
65755
|
}
|
|
65458
65756
|
}
|
|
65459
65757
|
});
|
|
@@ -65465,12 +65763,12 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65465
65763
|
try {
|
|
65466
65764
|
activeProfile = await runLoginFlow({
|
|
65467
65765
|
profile: profileName,
|
|
65468
|
-
jsonMode:
|
|
65766
|
+
jsonMode: jsonMode5,
|
|
65469
65767
|
origin: activeProfile.mcpOrigin,
|
|
65470
|
-
ttyHeader:
|
|
65768
|
+
ttyHeader: import_picocolors15.default.dim("Bearer expired mid-poll \u2014 re-pairing this terminal\u2026")
|
|
65471
65769
|
});
|
|
65472
65770
|
} catch (reloginErr) {
|
|
65473
|
-
if (
|
|
65771
|
+
if (jsonMode5) {
|
|
65474
65772
|
emitNdjson({
|
|
65475
65773
|
ok: false,
|
|
65476
65774
|
status: "auth_failed",
|
|
@@ -65480,7 +65778,7 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65480
65778
|
process.exit(1);
|
|
65481
65779
|
}
|
|
65482
65780
|
process.stderr.write(
|
|
65483
|
-
"\n" +
|
|
65781
|
+
"\n" + import_picocolors15.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65484
65782
|
`)
|
|
65485
65783
|
);
|
|
65486
65784
|
process.exit(1);
|
|
@@ -65488,7 +65786,7 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65488
65786
|
try {
|
|
65489
65787
|
final = await runPoll(activeProfile);
|
|
65490
65788
|
} catch (retryErr) {
|
|
65491
|
-
if (
|
|
65789
|
+
if (jsonMode5) {
|
|
65492
65790
|
emitNdjson({
|
|
65493
65791
|
ok: false,
|
|
65494
65792
|
status: retryErr instanceof ApiError && retryErr.status === 401 ? "auth_failed" : "poll_failed",
|
|
@@ -65498,13 +65796,13 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65498
65796
|
process.exit(1);
|
|
65499
65797
|
}
|
|
65500
65798
|
process.stderr.write(
|
|
65501
|
-
"\n" +
|
|
65799
|
+
"\n" + import_picocolors15.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
65502
65800
|
`)
|
|
65503
65801
|
);
|
|
65504
65802
|
process.exit(1);
|
|
65505
65803
|
}
|
|
65506
65804
|
} else {
|
|
65507
|
-
if (
|
|
65805
|
+
if (jsonMode5) {
|
|
65508
65806
|
emitNdjson({
|
|
65509
65807
|
ok: false,
|
|
65510
65808
|
status: "poll_failed",
|
|
@@ -65514,14 +65812,14 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65514
65812
|
process.exit(1);
|
|
65515
65813
|
}
|
|
65516
65814
|
process.stderr.write(
|
|
65517
|
-
"\n" +
|
|
65815
|
+
"\n" + import_picocolors15.default.red(`\u2715 Status poll failed: ${err.message}
|
|
65518
65816
|
`)
|
|
65519
65817
|
);
|
|
65520
65818
|
process.exit(1);
|
|
65521
65819
|
}
|
|
65522
65820
|
}
|
|
65523
65821
|
const explorer = final.tx_hash != null ? explorerUrl(final.chain_id, final.tx_hash) : null;
|
|
65524
|
-
if (
|
|
65822
|
+
if (jsonMode5) {
|
|
65525
65823
|
emitNdjson({
|
|
65526
65824
|
ok: final.status === "mined",
|
|
65527
65825
|
status: final.status,
|
|
@@ -65534,19 +65832,19 @@ ${import_picocolors13.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
65534
65832
|
}
|
|
65535
65833
|
process.stdout.write("\n");
|
|
65536
65834
|
if (final.status === "mined") {
|
|
65537
|
-
process.stdout.write(
|
|
65835
|
+
process.stdout.write(import_picocolors15.default.green("\u2713 Mined.") + "\n");
|
|
65538
65836
|
if (final.tx_hash) {
|
|
65539
65837
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
65540
65838
|
`);
|
|
65541
65839
|
}
|
|
65542
65840
|
if (explorer) {
|
|
65543
|
-
process.stdout.write(` Explorer ${
|
|
65841
|
+
process.stdout.write(` Explorer ${import_picocolors15.default.cyan(explorer)}
|
|
65544
65842
|
`);
|
|
65545
65843
|
}
|
|
65546
65844
|
process.exit(0);
|
|
65547
65845
|
}
|
|
65548
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}`;
|
|
65549
|
-
process.stderr.write(
|
|
65847
|
+
process.stderr.write(import_picocolors15.default.red(`\u2715 ${label}.
|
|
65550
65848
|
`));
|
|
65551
65849
|
process.exit(1);
|
|
65552
65850
|
}
|
|
@@ -65574,7 +65872,7 @@ function describeStatus(s) {
|
|
|
65574
65872
|
}
|
|
65575
65873
|
|
|
65576
65874
|
// src/commands/status.ts
|
|
65577
|
-
var
|
|
65875
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
65578
65876
|
var WATCH_GIVEUP_MS = 10 * 6e4;
|
|
65579
65877
|
function explorerUrl2(chainId, hash2) {
|
|
65580
65878
|
switch (chainId) {
|
|
@@ -65592,36 +65890,36 @@ function explorerUrl2(chainId, hash2) {
|
|
|
65592
65890
|
}
|
|
65593
65891
|
async function status2(intentId, opts) {
|
|
65594
65892
|
if (!intentId || intentId.trim() === "") {
|
|
65595
|
-
process.stderr.write(
|
|
65893
|
+
process.stderr.write(import_picocolors16.default.red("\u2715 Missing intent id.\n"));
|
|
65596
65894
|
process.exit(2);
|
|
65597
65895
|
}
|
|
65598
65896
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65599
65897
|
const resolved = await resolveProfile(requested);
|
|
65600
65898
|
if (!resolved) {
|
|
65601
|
-
process.stderr.write(
|
|
65899
|
+
process.stderr.write(import_picocolors16.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65602
65900
|
process.exit(2);
|
|
65603
65901
|
}
|
|
65604
65902
|
if (resolved.autoSelected) {
|
|
65605
|
-
process.stderr.write(
|
|
65903
|
+
process.stderr.write(import_picocolors16.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65606
65904
|
`));
|
|
65607
65905
|
}
|
|
65608
65906
|
const { profile, name: profileName } = resolved;
|
|
65609
|
-
const
|
|
65907
|
+
const jsonMode5 = opts.json === true;
|
|
65610
65908
|
const outcome = await callWithAutoRelogin({
|
|
65611
65909
|
profile,
|
|
65612
65910
|
profileName,
|
|
65613
|
-
jsonMode:
|
|
65614
|
-
ttyHeader:
|
|
65911
|
+
jsonMode: jsonMode5,
|
|
65912
|
+
ttyHeader: import_picocolors16.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
65615
65913
|
fn: (bearer, origin) => fetchStatus({ intentId, bearer, origin })
|
|
65616
65914
|
});
|
|
65617
65915
|
if (outcome.kind === "auth_failed") {
|
|
65618
|
-
if (
|
|
65916
|
+
if (jsonMode5) {
|
|
65619
65917
|
process.stdout.write(
|
|
65620
65918
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
65621
65919
|
);
|
|
65622
65920
|
process.exit(1);
|
|
65623
65921
|
}
|
|
65624
|
-
process.stderr.write(
|
|
65922
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${outcome.reason}.
|
|
65625
65923
|
`));
|
|
65626
65924
|
process.exit(1);
|
|
65627
65925
|
}
|
|
@@ -65629,11 +65927,11 @@ async function status2(intentId, opts) {
|
|
|
65629
65927
|
const err = outcome.error;
|
|
65630
65928
|
if (err instanceof ApiError) {
|
|
65631
65929
|
if (err.status === 404) {
|
|
65632
|
-
process.stderr.write(
|
|
65930
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 No intent with id ${intentId}.
|
|
65633
65931
|
`));
|
|
65634
65932
|
process.exit(1);
|
|
65635
65933
|
}
|
|
65636
|
-
process.stderr.write(
|
|
65934
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65637
65935
|
`));
|
|
65638
65936
|
process.exit(1);
|
|
65639
65937
|
}
|
|
@@ -65642,9 +65940,9 @@ async function status2(intentId, opts) {
|
|
|
65642
65940
|
let snap = outcome.result;
|
|
65643
65941
|
let activeProfile = outcome.profile;
|
|
65644
65942
|
if (opts.watch && !isTerminalStatus(snap.status)) {
|
|
65645
|
-
if (!
|
|
65943
|
+
if (!jsonMode5) {
|
|
65646
65944
|
printSnap(snap);
|
|
65647
|
-
process.stdout.write(
|
|
65945
|
+
process.stdout.write(import_picocolors16.default.dim("Watching\u2026\n"));
|
|
65648
65946
|
}
|
|
65649
65947
|
const runWatchPoll = (p) => streamStatusUntilTerminal({
|
|
65650
65948
|
intentId,
|
|
@@ -65654,8 +65952,8 @@ async function status2(intentId, opts) {
|
|
|
65654
65952
|
intervalMs: 0,
|
|
65655
65953
|
giveUpMs: WATCH_GIVEUP_MS,
|
|
65656
65954
|
onTick: (s) => {
|
|
65657
|
-
if (!
|
|
65658
|
-
process.stdout.write(` ${
|
|
65955
|
+
if (!jsonMode5) {
|
|
65956
|
+
process.stdout.write(` ${import_picocolors16.default.dim("\u2192")} ${s.status}
|
|
65659
65957
|
`);
|
|
65660
65958
|
}
|
|
65661
65959
|
}
|
|
@@ -65668,12 +65966,12 @@ async function status2(intentId, opts) {
|
|
|
65668
65966
|
try {
|
|
65669
65967
|
activeProfile = await runLoginFlow({
|
|
65670
65968
|
profile: profileName,
|
|
65671
|
-
jsonMode:
|
|
65969
|
+
jsonMode: jsonMode5,
|
|
65672
65970
|
origin: activeProfile.mcpOrigin,
|
|
65673
|
-
ttyHeader:
|
|
65971
|
+
ttyHeader: import_picocolors16.default.dim("Bearer expired mid-watch \u2014 re-pairing\u2026")
|
|
65674
65972
|
});
|
|
65675
65973
|
} catch (reloginErr) {
|
|
65676
|
-
if (
|
|
65974
|
+
if (jsonMode5) {
|
|
65677
65975
|
process.stdout.write(
|
|
65678
65976
|
JSON.stringify({
|
|
65679
65977
|
ok: false,
|
|
@@ -65684,7 +65982,7 @@ async function status2(intentId, opts) {
|
|
|
65684
65982
|
process.exit(1);
|
|
65685
65983
|
}
|
|
65686
65984
|
process.stderr.write(
|
|
65687
|
-
|
|
65985
|
+
import_picocolors16.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
65688
65986
|
`)
|
|
65689
65987
|
);
|
|
65690
65988
|
process.exit(1);
|
|
@@ -65692,24 +65990,24 @@ async function status2(intentId, opts) {
|
|
|
65692
65990
|
try {
|
|
65693
65991
|
final = await runWatchPoll(activeProfile);
|
|
65694
65992
|
} catch (retryErr) {
|
|
65695
|
-
process.stderr.write(
|
|
65993
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${retryErr.message}
|
|
65696
65994
|
`));
|
|
65697
65995
|
process.exit(1);
|
|
65698
65996
|
}
|
|
65699
65997
|
} else {
|
|
65700
|
-
process.stderr.write(
|
|
65998
|
+
process.stderr.write(import_picocolors16.default.red(`\u2715 ${err.message}
|
|
65701
65999
|
`));
|
|
65702
66000
|
process.exit(1);
|
|
65703
66001
|
}
|
|
65704
66002
|
}
|
|
65705
|
-
if (
|
|
66003
|
+
if (jsonMode5) {
|
|
65706
66004
|
process.stdout.write(JSON.stringify(final, null, 2) + "\n");
|
|
65707
66005
|
} else {
|
|
65708
66006
|
printSnap(final);
|
|
65709
66007
|
}
|
|
65710
66008
|
process.exit(final.status === "mined" ? 0 : 1);
|
|
65711
66009
|
}
|
|
65712
|
-
if (
|
|
66010
|
+
if (jsonMode5) {
|
|
65713
66011
|
process.stdout.write(JSON.stringify(snap, null, 2) + "\n");
|
|
65714
66012
|
process.exit(snap.status === "mined" ? 0 : 0);
|
|
65715
66013
|
}
|
|
@@ -65718,7 +66016,7 @@ async function status2(intentId, opts) {
|
|
|
65718
66016
|
}
|
|
65719
66017
|
function printSnap(s) {
|
|
65720
66018
|
const explorer = s.tx_hash ? explorerUrl2(s.chain_id, s.tx_hash) : null;
|
|
65721
|
-
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;
|
|
65722
66020
|
process.stdout.write(`Intent ${s.approval_id}
|
|
65723
66021
|
`);
|
|
65724
66022
|
process.stdout.write(`Status ${colorFn(s.status)}
|
|
@@ -65733,12 +66031,12 @@ function printSnap(s) {
|
|
|
65733
66031
|
process.stdout.write(`Tx ${s.tx_hash}
|
|
65734
66032
|
`);
|
|
65735
66033
|
if (explorer) {
|
|
65736
|
-
process.stdout.write(`Explorer ${
|
|
66034
|
+
process.stdout.write(`Explorer ${import_picocolors16.default.cyan(explorer)}
|
|
65737
66035
|
`);
|
|
65738
66036
|
}
|
|
65739
66037
|
}
|
|
65740
66038
|
if (!isTerminalStatus(s.status)) {
|
|
65741
|
-
process.stdout.write(`Approve ${
|
|
66039
|
+
process.stdout.write(`Approve ${import_picocolors16.default.cyan(s.approval_url)}
|
|
65742
66040
|
`);
|
|
65743
66041
|
}
|
|
65744
66042
|
process.stdout.write(`Created ${formatDate2(s.created_at)}
|
|
@@ -65755,7 +66053,7 @@ function formatDate2(iso) {
|
|
|
65755
66053
|
}
|
|
65756
66054
|
|
|
65757
66055
|
// src/commands/balance.ts
|
|
65758
|
-
var
|
|
66056
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
65759
66057
|
var CHAIN_ALIASES = {
|
|
65760
66058
|
"1": 1,
|
|
65761
66059
|
ethereum: 1,
|
|
@@ -65778,11 +66076,11 @@ async function balance(opts) {
|
|
|
65778
66076
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65779
66077
|
const resolved = await resolveProfile(requested);
|
|
65780
66078
|
if (!resolved) {
|
|
65781
|
-
process.stderr.write(
|
|
66079
|
+
process.stderr.write(import_picocolors17.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65782
66080
|
process.exit(2);
|
|
65783
66081
|
}
|
|
65784
66082
|
if (resolved.autoSelected) {
|
|
65785
|
-
process.stderr.write(
|
|
66083
|
+
process.stderr.write(import_picocolors17.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65786
66084
|
`));
|
|
65787
66085
|
}
|
|
65788
66086
|
const { profile, name: profileName } = resolved;
|
|
@@ -65792,8 +66090,8 @@ async function balance(opts) {
|
|
|
65792
66090
|
const id2 = CHAIN_ALIASES[key];
|
|
65793
66091
|
if (id2 === void 0) {
|
|
65794
66092
|
process.stderr.write(
|
|
65795
|
-
|
|
65796
|
-
`\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")}.
|
|
65797
66095
|
`
|
|
65798
66096
|
)
|
|
65799
66097
|
);
|
|
@@ -65801,29 +66099,29 @@ async function balance(opts) {
|
|
|
65801
66099
|
}
|
|
65802
66100
|
chainFilter = id2;
|
|
65803
66101
|
}
|
|
65804
|
-
const
|
|
66102
|
+
const jsonMode5 = opts.json === true;
|
|
65805
66103
|
const outcome = await callWithAutoRelogin({
|
|
65806
66104
|
profile,
|
|
65807
66105
|
profileName,
|
|
65808
|
-
jsonMode:
|
|
65809
|
-
ttyHeader:
|
|
66106
|
+
jsonMode: jsonMode5,
|
|
66107
|
+
ttyHeader: import_picocolors17.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
65810
66108
|
fn: (bearer, origin) => apiFetch("/api/balances", { bearer, origin })
|
|
65811
66109
|
});
|
|
65812
66110
|
if (outcome.kind === "auth_failed") {
|
|
65813
|
-
if (
|
|
66111
|
+
if (jsonMode5) {
|
|
65814
66112
|
process.stdout.write(
|
|
65815
66113
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
65816
66114
|
);
|
|
65817
66115
|
process.exit(1);
|
|
65818
66116
|
}
|
|
65819
|
-
process.stderr.write(
|
|
66117
|
+
process.stderr.write(import_picocolors17.default.red(`\u2715 ${outcome.reason}.
|
|
65820
66118
|
`));
|
|
65821
66119
|
process.exit(1);
|
|
65822
66120
|
}
|
|
65823
66121
|
if (outcome.kind === "error") {
|
|
65824
66122
|
const err = outcome.error;
|
|
65825
66123
|
if (err instanceof ApiError) {
|
|
65826
|
-
process.stderr.write(
|
|
66124
|
+
process.stderr.write(import_picocolors17.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65827
66125
|
`));
|
|
65828
66126
|
process.exit(1);
|
|
65829
66127
|
}
|
|
@@ -65831,7 +66129,7 @@ async function balance(opts) {
|
|
|
65831
66129
|
}
|
|
65832
66130
|
const res = outcome.result;
|
|
65833
66131
|
const filtered = chainFilter !== null ? res.chains.filter((c) => c.chainId === chainFilter) : res.chains;
|
|
65834
|
-
if (
|
|
66132
|
+
if (jsonMode5) {
|
|
65835
66133
|
process.stdout.write(
|
|
65836
66134
|
JSON.stringify(
|
|
65837
66135
|
chainFilter !== null ? { ...res, chains: filtered } : res,
|
|
@@ -65853,7 +66151,7 @@ async function balance(opts) {
|
|
|
65853
66151
|
}
|
|
65854
66152
|
if (filtered.length === 0) {
|
|
65855
66153
|
process.stdout.write(
|
|
65856
|
-
|
|
66154
|
+
import_picocolors17.default.dim(
|
|
65857
66155
|
chainFilter !== null ? `No balances on chain ${chainFilter}.
|
|
65858
66156
|
` : `No chain balances returned.
|
|
65859
66157
|
`
|
|
@@ -65865,7 +66163,7 @@ async function balance(opts) {
|
|
|
65865
66163
|
const errorLines = [];
|
|
65866
66164
|
for (const c of filtered) {
|
|
65867
66165
|
if (c.error) {
|
|
65868
|
-
errorLines.push(`${c.chainName} ${
|
|
66166
|
+
errorLines.push(`${c.chainName} ${import_picocolors17.default.red(`(read failed: ${c.error})`)}`);
|
|
65869
66167
|
continue;
|
|
65870
66168
|
}
|
|
65871
66169
|
if (c.native.balance > 0) {
|
|
@@ -65886,7 +66184,7 @@ async function balance(opts) {
|
|
|
65886
66184
|
}
|
|
65887
66185
|
}
|
|
65888
66186
|
if (rows.length === 0 && errorLines.length === 0) {
|
|
65889
|
-
process.stdout.write(
|
|
66187
|
+
process.stdout.write(import_picocolors17.default.dim(`All balances are zero.
|
|
65890
66188
|
`));
|
|
65891
66189
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
65892
66190
|
return;
|
|
@@ -65896,7 +66194,7 @@ async function balance(opts) {
|
|
|
65896
66194
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
65897
66195
|
const colBalance = Math.max(7, ...rows.map((r) => r.balance.length));
|
|
65898
66196
|
const header = "Chain".padEnd(colChain) + " " + "Asset".padEnd(colAsset) + " " + "Balance".padStart(colBalance);
|
|
65899
|
-
process.stdout.write(
|
|
66197
|
+
process.stdout.write(import_picocolors17.default.dim(header) + "\n");
|
|
65900
66198
|
for (const r of rows) {
|
|
65901
66199
|
process.stdout.write(
|
|
65902
66200
|
r.chain.padEnd(colChain) + " " + r.asset.padEnd(colAsset) + " " + r.balance.padStart(colBalance) + "\n"
|
|
@@ -65909,7 +66207,7 @@ async function balance(opts) {
|
|
|
65909
66207
|
`);
|
|
65910
66208
|
}
|
|
65911
66209
|
if (res.fetched_at) {
|
|
65912
|
-
process.stdout.write("\n" +
|
|
66210
|
+
process.stdout.write("\n" + import_picocolors17.default.dim(`Fetched ${res.fetched_at}
|
|
65913
66211
|
`));
|
|
65914
66212
|
}
|
|
65915
66213
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
@@ -65922,18 +66220,18 @@ function formatBalance(value, decimals) {
|
|
|
65922
66220
|
}
|
|
65923
66221
|
|
|
65924
66222
|
// src/commands/history.ts
|
|
65925
|
-
var
|
|
66223
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
65926
66224
|
var DEFAULT_LIMIT = 20;
|
|
65927
66225
|
var SERVER_MAX_LIMIT = 100;
|
|
65928
66226
|
async function history(opts) {
|
|
65929
66227
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
65930
66228
|
const resolved = await resolveProfile(requested);
|
|
65931
66229
|
if (!resolved) {
|
|
65932
|
-
process.stderr.write(
|
|
66230
|
+
process.stderr.write(import_picocolors18.default.red("Not logged in. Run agentgates login first.\n"));
|
|
65933
66231
|
process.exit(2);
|
|
65934
66232
|
}
|
|
65935
66233
|
if (resolved.autoSelected) {
|
|
65936
|
-
process.stderr.write(
|
|
66234
|
+
process.stderr.write(import_picocolors18.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
65937
66235
|
`));
|
|
65938
66236
|
}
|
|
65939
66237
|
const { profile, name: profileName } = resolved;
|
|
@@ -65942,14 +66240,14 @@ async function history(opts) {
|
|
|
65942
66240
|
const n2 = Number(opts.limit);
|
|
65943
66241
|
if (!Number.isFinite(n2) || n2 <= 0 || !Number.isInteger(n2)) {
|
|
65944
66242
|
process.stderr.write(
|
|
65945
|
-
|
|
66243
|
+
import_picocolors18.default.red(`\u2715 --limit must be a positive integer (got ${import_picocolors18.default.bold(opts.limit)}).
|
|
65946
66244
|
`)
|
|
65947
66245
|
);
|
|
65948
66246
|
process.exit(2);
|
|
65949
66247
|
}
|
|
65950
66248
|
if (n2 > SERVER_MAX_LIMIT) {
|
|
65951
66249
|
process.stderr.write(
|
|
65952
|
-
|
|
66250
|
+
import_picocolors18.default.red(
|
|
65953
66251
|
`\u2715 --limit max is ${SERVER_MAX_LIMIT} (the server's wallet://history hard cap). Got ${n2}.
|
|
65954
66252
|
`
|
|
65955
66253
|
)
|
|
@@ -65958,39 +66256,39 @@ async function history(opts) {
|
|
|
65958
66256
|
}
|
|
65959
66257
|
limit = n2;
|
|
65960
66258
|
}
|
|
65961
|
-
const
|
|
66259
|
+
const jsonMode5 = opts.json === true;
|
|
65962
66260
|
const outcome = await callWithAutoRelogin({
|
|
65963
66261
|
profile,
|
|
65964
66262
|
profileName,
|
|
65965
|
-
jsonMode:
|
|
65966
|
-
ttyHeader:
|
|
66263
|
+
jsonMode: jsonMode5,
|
|
66264
|
+
ttyHeader: import_picocolors18.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
65967
66265
|
fn: (bearer, origin) => apiFetch(
|
|
65968
66266
|
`/api/history?limit=${encodeURIComponent(String(limit))}`,
|
|
65969
66267
|
{ bearer, origin }
|
|
65970
66268
|
)
|
|
65971
66269
|
});
|
|
65972
66270
|
if (outcome.kind === "auth_failed") {
|
|
65973
|
-
if (
|
|
66271
|
+
if (jsonMode5) {
|
|
65974
66272
|
process.stdout.write(
|
|
65975
66273
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
65976
66274
|
);
|
|
65977
66275
|
process.exit(1);
|
|
65978
66276
|
}
|
|
65979
|
-
process.stderr.write(
|
|
66277
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${outcome.reason}.
|
|
65980
66278
|
`));
|
|
65981
66279
|
process.exit(1);
|
|
65982
66280
|
}
|
|
65983
66281
|
if (outcome.kind === "error") {
|
|
65984
66282
|
const err = outcome.error;
|
|
65985
66283
|
if (err instanceof ApiError) {
|
|
65986
|
-
process.stderr.write(
|
|
66284
|
+
process.stderr.write(import_picocolors18.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
65987
66285
|
`));
|
|
65988
66286
|
process.exit(1);
|
|
65989
66287
|
}
|
|
65990
66288
|
throw err;
|
|
65991
66289
|
}
|
|
65992
66290
|
const res = outcome.result;
|
|
65993
|
-
if (
|
|
66291
|
+
if (jsonMode5) {
|
|
65994
66292
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
65995
66293
|
return;
|
|
65996
66294
|
}
|
|
@@ -66000,7 +66298,7 @@ async function history(opts) {
|
|
|
66000
66298
|
return;
|
|
66001
66299
|
}
|
|
66002
66300
|
if (res.txs.length === 0) {
|
|
66003
|
-
process.stdout.write(
|
|
66301
|
+
process.stdout.write(import_picocolors18.default.dim(`No activity yet.
|
|
66004
66302
|
`));
|
|
66005
66303
|
return;
|
|
66006
66304
|
}
|
|
@@ -66020,7 +66318,7 @@ async function history(opts) {
|
|
|
66020
66318
|
const colAsset = Math.max(5, ...rows.map((r) => r.asset.length));
|
|
66021
66319
|
const colTo = Math.max(2, ...rows.map((r) => r.to.length));
|
|
66022
66320
|
const header = "When".padEnd(colWhen) + " " + "Chain".padEnd(colChain) + " " + "Type".padEnd(colType) + " " + "Amount".padStart(colAmount) + " " + "Asset".padEnd(colAsset) + " " + "To".padEnd(colTo) + " Hash";
|
|
66023
|
-
process.stdout.write(
|
|
66321
|
+
process.stdout.write(import_picocolors18.default.dim(header) + "\n");
|
|
66024
66322
|
for (const r of rows) {
|
|
66025
66323
|
process.stdout.write(
|
|
66026
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"
|
|
@@ -66028,7 +66326,7 @@ async function history(opts) {
|
|
|
66028
66326
|
}
|
|
66029
66327
|
if (res.fetched_at) {
|
|
66030
66328
|
process.stdout.write(
|
|
66031
|
-
"\n" +
|
|
66329
|
+
"\n" + import_picocolors18.default.dim(
|
|
66032
66330
|
`Showing ${rows.length} of limit ${res.limit ?? limit} \xB7 fetched ${res.fetched_at}
|
|
66033
66331
|
`
|
|
66034
66332
|
)
|
|
@@ -66115,10 +66413,10 @@ function prettyType(activityType, status3) {
|
|
|
66115
66413
|
}
|
|
66116
66414
|
|
|
66117
66415
|
// src/commands/swap.ts
|
|
66118
|
-
var
|
|
66416
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
66119
66417
|
|
|
66120
66418
|
// src/lib/intent-flow.ts
|
|
66121
|
-
var
|
|
66419
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
66122
66420
|
var STREAM_GIVEUP_MS = 10 * 6e4;
|
|
66123
66421
|
var SOLANA_CHAIN_ID2 = 900;
|
|
66124
66422
|
function isBlocked2(r) {
|
|
@@ -66193,7 +66491,7 @@ async function runIntentFlow(opts) {
|
|
|
66193
66491
|
profile: opts.profileName,
|
|
66194
66492
|
jsonMode: opts.jsonMode,
|
|
66195
66493
|
origin: activeProfile.mcpOrigin,
|
|
66196
|
-
ttyHeader:
|
|
66494
|
+
ttyHeader: import_picocolors19.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026")
|
|
66197
66495
|
});
|
|
66198
66496
|
} catch (reloginErr) {
|
|
66199
66497
|
if (opts.jsonMode) {
|
|
@@ -66205,7 +66503,7 @@ async function runIntentFlow(opts) {
|
|
|
66205
66503
|
process.exit(1);
|
|
66206
66504
|
}
|
|
66207
66505
|
process.stderr.write(
|
|
66208
|
-
|
|
66506
|
+
import_picocolors19.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
66209
66507
|
`)
|
|
66210
66508
|
);
|
|
66211
66509
|
process.exit(1);
|
|
@@ -66229,7 +66527,7 @@ async function runIntentFlow(opts) {
|
|
|
66229
66527
|
process.exit(1);
|
|
66230
66528
|
}
|
|
66231
66529
|
process.stderr.write(
|
|
66232
|
-
|
|
66530
|
+
import_picocolors19.default.red(`\u2715 ${retryErr.message} (HTTP ${retryErr.status})
|
|
66233
66531
|
`)
|
|
66234
66532
|
);
|
|
66235
66533
|
process.exit(1);
|
|
@@ -66246,7 +66544,7 @@ async function runIntentFlow(opts) {
|
|
|
66246
66544
|
});
|
|
66247
66545
|
process.exit(1);
|
|
66248
66546
|
}
|
|
66249
|
-
process.stderr.write(
|
|
66547
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
66250
66548
|
`));
|
|
66251
66549
|
process.exit(1);
|
|
66252
66550
|
} else {
|
|
@@ -66268,18 +66566,18 @@ async function runIntentFlow(opts) {
|
|
|
66268
66566
|
});
|
|
66269
66567
|
process.exit(1);
|
|
66270
66568
|
}
|
|
66271
|
-
process.stderr.write(
|
|
66569
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 Blocked (${proposed.code}): ${proposed.reason}
|
|
66272
66570
|
`));
|
|
66273
66571
|
if (proposed.upgrade_url) {
|
|
66274
66572
|
process.stderr.write(
|
|
66275
66573
|
` Open this to grant access, then re-run the command:
|
|
66276
|
-
${
|
|
66574
|
+
${import_picocolors19.default.cyan(proposed.upgrade_url)}
|
|
66277
66575
|
`
|
|
66278
66576
|
);
|
|
66279
66577
|
}
|
|
66280
66578
|
if (proposed.recommended_actions && proposed.recommended_actions.length > 0) {
|
|
66281
66579
|
process.stderr.write(
|
|
66282
|
-
|
|
66580
|
+
import_picocolors19.default.dim(
|
|
66283
66581
|
` Suggested actions:
|
|
66284
66582
|
` + proposed.recommended_actions.map((a) => ` \u2022 ${JSON.stringify(a)}`).join("\n") + "\n"
|
|
66285
66583
|
)
|
|
@@ -66302,8 +66600,8 @@ async function runIntentFlow(opts) {
|
|
|
66302
66600
|
} else {
|
|
66303
66601
|
process.stdout.write(
|
|
66304
66602
|
`
|
|
66305
|
-
${
|
|
66306
|
-
${
|
|
66603
|
+
${import_picocolors19.default.bold("Proposed.")} Open this URL to approve with biometric:
|
|
66604
|
+
${import_picocolors19.default.cyan(proposed.approval_url)}
|
|
66307
66605
|
|
|
66308
66606
|
`
|
|
66309
66607
|
);
|
|
@@ -66325,7 +66623,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66325
66623
|
if (opts.jsonMode) {
|
|
66326
66624
|
emitNdjson2({ status: s.status, intent_id: s.approval_id });
|
|
66327
66625
|
} else {
|
|
66328
|
-
process.stdout.write(` ${describeStatus2(s.status)}${
|
|
66626
|
+
process.stdout.write(` ${describeStatus2(s.status)}${import_picocolors19.default.dim("\u2026")}\r`);
|
|
66329
66627
|
}
|
|
66330
66628
|
}
|
|
66331
66629
|
});
|
|
@@ -66339,7 +66637,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66339
66637
|
profile: opts.profileName,
|
|
66340
66638
|
jsonMode: opts.jsonMode,
|
|
66341
66639
|
origin: activeProfile.mcpOrigin,
|
|
66342
|
-
ttyHeader:
|
|
66640
|
+
ttyHeader: import_picocolors19.default.dim(
|
|
66343
66641
|
"Bearer expired mid-poll \u2014 re-pairing this terminal\u2026"
|
|
66344
66642
|
)
|
|
66345
66643
|
});
|
|
@@ -66354,7 +66652,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66354
66652
|
process.exit(1);
|
|
66355
66653
|
}
|
|
66356
66654
|
process.stderr.write(
|
|
66357
|
-
"\n" +
|
|
66655
|
+
"\n" + import_picocolors19.default.red(`\u2715 Auto-relogin failed: ${reloginErr.message}
|
|
66358
66656
|
`)
|
|
66359
66657
|
);
|
|
66360
66658
|
process.exit(1);
|
|
@@ -66372,7 +66670,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66372
66670
|
process.exit(1);
|
|
66373
66671
|
}
|
|
66374
66672
|
process.stderr.write(
|
|
66375
|
-
"\n" +
|
|
66673
|
+
"\n" + import_picocolors19.default.red(`\u2715 Status poll failed: ${retryErr.message}
|
|
66376
66674
|
`)
|
|
66377
66675
|
);
|
|
66378
66676
|
process.exit(1);
|
|
@@ -66388,7 +66686,7 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66388
66686
|
process.exit(1);
|
|
66389
66687
|
}
|
|
66390
66688
|
process.stderr.write(
|
|
66391
|
-
"\n" +
|
|
66689
|
+
"\n" + import_picocolors19.default.red(`\u2715 Status poll failed: ${err.message}
|
|
66392
66690
|
`)
|
|
66393
66691
|
);
|
|
66394
66692
|
process.exit(1);
|
|
@@ -66429,39 +66727,39 @@ ${import_picocolors17.default.bold("Proposed.")} Open this URL to approve with b
|
|
|
66429
66727
|
process.stdout.write("\n");
|
|
66430
66728
|
const printLegJournal = () => {
|
|
66431
66729
|
if (legs.length === 0) return;
|
|
66432
|
-
process.stdout.write(
|
|
66730
|
+
process.stdout.write(import_picocolors19.default.bold(" Legs:\n"));
|
|
66433
66731
|
for (const l of legs) {
|
|
66434
|
-
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}`);
|
|
66435
66733
|
process.stdout.write(` ${line}
|
|
66436
66734
|
`);
|
|
66437
66735
|
}
|
|
66438
66736
|
};
|
|
66439
66737
|
if (final.status === "mined") {
|
|
66440
|
-
process.stdout.write(
|
|
66738
|
+
process.stdout.write(import_picocolors19.default.green("\u2713 Mined.") + "\n");
|
|
66441
66739
|
if (final.tx_hash) {
|
|
66442
66740
|
process.stdout.write(` Tx ${final.tx_hash}
|
|
66443
66741
|
`);
|
|
66444
66742
|
}
|
|
66445
66743
|
if (explorer) {
|
|
66446
|
-
process.stdout.write(` Explorer ${
|
|
66744
|
+
process.stdout.write(` Explorer ${import_picocolors19.default.cyan(explorer)}
|
|
66447
66745
|
`);
|
|
66448
66746
|
}
|
|
66449
66747
|
printLegJournal();
|
|
66450
66748
|
process.exit(0);
|
|
66451
66749
|
}
|
|
66452
66750
|
if (final.status === "failed" && failure?.message) {
|
|
66453
|
-
process.stderr.write(
|
|
66751
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${failure.message}
|
|
66454
66752
|
`));
|
|
66455
66753
|
if (retryCommand) {
|
|
66456
66754
|
process.stderr.write(` Retry:
|
|
66457
|
-
${
|
|
66755
|
+
${import_picocolors19.default.cyan(retryCommand)}
|
|
66458
66756
|
`);
|
|
66459
66757
|
}
|
|
66460
66758
|
printLegJournal();
|
|
66461
66759
|
process.exit(1);
|
|
66462
66760
|
}
|
|
66463
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}`;
|
|
66464
|
-
process.stderr.write(
|
|
66762
|
+
process.stderr.write(import_picocolors19.default.red(`\u2715 ${label}.
|
|
66465
66763
|
`));
|
|
66466
66764
|
printLegJournal();
|
|
66467
66765
|
process.exit(1);
|
|
@@ -66481,7 +66779,7 @@ function isAsset(v) {
|
|
|
66481
66779
|
return ASSET_VALUES.has(v.toLowerCase());
|
|
66482
66780
|
}
|
|
66483
66781
|
function failArg(msg) {
|
|
66484
|
-
process.stderr.write(
|
|
66782
|
+
process.stderr.write(import_picocolors20.default.red(`\u2715 ${msg}
|
|
66485
66783
|
`));
|
|
66486
66784
|
process.exit(2);
|
|
66487
66785
|
}
|
|
@@ -66489,24 +66787,24 @@ async function swap(amount, fromAsset, opts) {
|
|
|
66489
66787
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66490
66788
|
const resolved = await resolveProfile(requested);
|
|
66491
66789
|
if (!resolved) {
|
|
66492
|
-
process.stderr.write(
|
|
66790
|
+
process.stderr.write(import_picocolors20.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66493
66791
|
process.exit(2);
|
|
66494
66792
|
}
|
|
66495
66793
|
if (resolved.autoSelected) {
|
|
66496
|
-
process.stderr.write(
|
|
66794
|
+
process.stderr.write(import_picocolors20.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66497
66795
|
`));
|
|
66498
66796
|
}
|
|
66499
66797
|
const { profile, name: profileName } = resolved;
|
|
66500
66798
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
66501
|
-
const
|
|
66799
|
+
const jsonMode5 = opts.json === true || !stdoutIsTty;
|
|
66502
66800
|
const amountNumber = Number(amount);
|
|
66503
66801
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
66504
|
-
failArg(`amount must be a positive number (got ${
|
|
66802
|
+
failArg(`amount must be a positive number (got ${import_picocolors20.default.bold(amount)}).`);
|
|
66505
66803
|
}
|
|
66506
66804
|
const fromAssetNorm = fromAsset.toLowerCase();
|
|
66507
66805
|
if (!isAsset(fromAssetNorm)) {
|
|
66508
66806
|
failArg(
|
|
66509
|
-
`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)}).`
|
|
66510
66808
|
);
|
|
66511
66809
|
}
|
|
66512
66810
|
if (!opts.toAsset) {
|
|
@@ -66515,7 +66813,7 @@ async function swap(amount, fromAsset, opts) {
|
|
|
66515
66813
|
const toAssetNorm = opts.toAsset.toLowerCase();
|
|
66516
66814
|
if (!isAsset(toAssetNorm)) {
|
|
66517
66815
|
failArg(
|
|
66518
|
-
`--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)}).`
|
|
66519
66817
|
);
|
|
66520
66818
|
}
|
|
66521
66819
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -66637,16 +66935,16 @@ async function swap(amount, fromAsset, opts) {
|
|
|
66637
66935
|
body: proposeBody,
|
|
66638
66936
|
profileName,
|
|
66639
66937
|
initialProfile: profile,
|
|
66640
|
-
jsonMode:
|
|
66938
|
+
jsonMode: jsonMode5,
|
|
66641
66939
|
shouldOpenBrowser,
|
|
66642
66940
|
buildRetryCommand
|
|
66643
66941
|
});
|
|
66644
66942
|
}
|
|
66645
66943
|
|
|
66646
66944
|
// src/commands/batch.ts
|
|
66647
|
-
var
|
|
66945
|
+
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
66648
66946
|
function failArg2(msg) {
|
|
66649
|
-
process.stderr.write(
|
|
66947
|
+
process.stderr.write(import_picocolors21.default.red(`\u2715 ${msg}
|
|
66650
66948
|
`));
|
|
66651
66949
|
process.exit(2);
|
|
66652
66950
|
}
|
|
@@ -66654,11 +66952,11 @@ async function batch(opts) {
|
|
|
66654
66952
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66655
66953
|
const resolved = await resolveProfile(requested);
|
|
66656
66954
|
if (!resolved) {
|
|
66657
|
-
process.stderr.write(
|
|
66955
|
+
process.stderr.write(import_picocolors21.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66658
66956
|
process.exit(2);
|
|
66659
66957
|
}
|
|
66660
66958
|
const { name: profileName, profile } = resolved;
|
|
66661
|
-
const
|
|
66959
|
+
const jsonMode5 = opts.json === true || !process.stdout.isTTY;
|
|
66662
66960
|
let legs;
|
|
66663
66961
|
try {
|
|
66664
66962
|
legs = JSON.parse(opts.legsJson);
|
|
@@ -66702,20 +67000,20 @@ async function batch(opts) {
|
|
|
66702
67000
|
},
|
|
66703
67001
|
profileName,
|
|
66704
67002
|
initialProfile: profile,
|
|
66705
|
-
jsonMode:
|
|
67003
|
+
jsonMode: jsonMode5,
|
|
66706
67004
|
shouldOpenBrowser
|
|
66707
67005
|
});
|
|
66708
67006
|
}
|
|
66709
67007
|
|
|
66710
67008
|
// src/commands/fund-wallet.ts
|
|
66711
|
-
var
|
|
67009
|
+
var import_picocolors22 = __toESM(require_picocolors(), 1);
|
|
66712
67010
|
var EVM_ADDRESS_RE2 = /^0x[0-9a-fA-F]{40}$/;
|
|
66713
67011
|
var SOLANA_ADDRESS_RE2 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
66714
67012
|
function isAddressTarget(target) {
|
|
66715
67013
|
return EVM_ADDRESS_RE2.test(target) || SOLANA_ADDRESS_RE2.test(target);
|
|
66716
67014
|
}
|
|
66717
67015
|
function failArg3(msg) {
|
|
66718
|
-
process.stderr.write(
|
|
67016
|
+
process.stderr.write(import_picocolors22.default.red(`\u2715 ${msg}
|
|
66719
67017
|
`));
|
|
66720
67018
|
process.exit(2);
|
|
66721
67019
|
}
|
|
@@ -66723,11 +67021,11 @@ async function fundWallet(address, opts) {
|
|
|
66723
67021
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66724
67022
|
const resolved = await resolveProfile(requested);
|
|
66725
67023
|
if (!resolved) {
|
|
66726
|
-
process.stderr.write(
|
|
67024
|
+
process.stderr.write(import_picocolors22.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66727
67025
|
process.exit(2);
|
|
66728
67026
|
}
|
|
66729
67027
|
const { name: profileName, profile } = resolved;
|
|
66730
|
-
const
|
|
67028
|
+
const jsonMode5 = opts.json === true || !process.stdout.isTTY;
|
|
66731
67029
|
if (!opts.chain) {
|
|
66732
67030
|
failArg3("--chain is required (1/137/8453/42161/900 or shortName).");
|
|
66733
67031
|
}
|
|
@@ -66779,7 +67077,7 @@ async function fundWallet(address, opts) {
|
|
|
66779
67077
|
},
|
|
66780
67078
|
profileName,
|
|
66781
67079
|
initialProfile: profile,
|
|
66782
|
-
jsonMode:
|
|
67080
|
+
jsonMode: jsonMode5,
|
|
66783
67081
|
shouldOpenBrowser
|
|
66784
67082
|
});
|
|
66785
67083
|
}
|
|
@@ -66794,17 +67092,17 @@ async function fundWallet(address, opts) {
|
|
|
66794
67092
|
},
|
|
66795
67093
|
profileName,
|
|
66796
67094
|
initialProfile: profile,
|
|
66797
|
-
jsonMode:
|
|
67095
|
+
jsonMode: jsonMode5,
|
|
66798
67096
|
shouldOpenBrowser
|
|
66799
67097
|
});
|
|
66800
67098
|
}
|
|
66801
67099
|
|
|
66802
67100
|
// src/commands/earn-supply.ts
|
|
66803
|
-
var
|
|
67101
|
+
var import_picocolors23 = __toESM(require_picocolors(), 1);
|
|
66804
67102
|
var ASSET_VALUES2 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
66805
67103
|
var PROTOCOLS = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
66806
67104
|
function failArg4(msg) {
|
|
66807
|
-
process.stderr.write(
|
|
67105
|
+
process.stderr.write(import_picocolors23.default.red(`\u2715 ${msg}
|
|
66808
67106
|
`));
|
|
66809
67107
|
process.exit(2);
|
|
66810
67108
|
}
|
|
@@ -66812,24 +67110,24 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66812
67110
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66813
67111
|
const resolved = await resolveProfile(requested);
|
|
66814
67112
|
if (!resolved) {
|
|
66815
|
-
process.stderr.write(
|
|
67113
|
+
process.stderr.write(import_picocolors23.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66816
67114
|
process.exit(2);
|
|
66817
67115
|
}
|
|
66818
67116
|
if (resolved.autoSelected) {
|
|
66819
|
-
process.stderr.write(
|
|
67117
|
+
process.stderr.write(import_picocolors23.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66820
67118
|
`));
|
|
66821
67119
|
}
|
|
66822
67120
|
const { profile, name: profileName } = resolved;
|
|
66823
67121
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
66824
|
-
const
|
|
67122
|
+
const jsonMode5 = opts.json === true || !stdoutIsTty;
|
|
66825
67123
|
const amountNumber = Number(amount);
|
|
66826
67124
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
66827
|
-
failArg4(`amount must be a positive number (got ${
|
|
67125
|
+
failArg4(`amount must be a positive number (got ${import_picocolors23.default.bold(amount)}).`);
|
|
66828
67126
|
}
|
|
66829
67127
|
const assetNorm = asset.toLowerCase();
|
|
66830
67128
|
if (!ASSET_VALUES2.has(assetNorm)) {
|
|
66831
67129
|
failArg4(
|
|
66832
|
-
`asset must be ${
|
|
67130
|
+
`asset must be ${import_picocolors23.default.bold("native")} or ${import_picocolors23.default.bold("usdc")} (got ${import_picocolors23.default.bold(asset)}).`
|
|
66833
67131
|
);
|
|
66834
67132
|
}
|
|
66835
67133
|
if (!opts.chain) {
|
|
@@ -66841,7 +67139,7 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66841
67139
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
66842
67140
|
if (!PROTOCOLS.has(protocolNorm)) {
|
|
66843
67141
|
failArg4(
|
|
66844
|
-
`--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)}).`
|
|
66845
67143
|
);
|
|
66846
67144
|
}
|
|
66847
67145
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -66887,17 +67185,17 @@ async function earnSupply(amount, asset, opts) {
|
|
|
66887
67185
|
body: proposeBody,
|
|
66888
67186
|
profileName,
|
|
66889
67187
|
initialProfile: profile,
|
|
66890
|
-
jsonMode:
|
|
67188
|
+
jsonMode: jsonMode5,
|
|
66891
67189
|
shouldOpenBrowser
|
|
66892
67190
|
});
|
|
66893
67191
|
}
|
|
66894
67192
|
|
|
66895
67193
|
// src/commands/earn-withdraw.ts
|
|
66896
|
-
var
|
|
67194
|
+
var import_picocolors24 = __toESM(require_picocolors(), 1);
|
|
66897
67195
|
var ASSET_VALUES3 = /* @__PURE__ */ new Set(["native", "usdc"]);
|
|
66898
67196
|
var PROTOCOLS2 = /* @__PURE__ */ new Set(["aave_v3", "kamino_lend"]);
|
|
66899
67197
|
function failArg5(msg) {
|
|
66900
|
-
process.stderr.write(
|
|
67198
|
+
process.stderr.write(import_picocolors24.default.red(`\u2715 ${msg}
|
|
66901
67199
|
`));
|
|
66902
67200
|
process.exit(2);
|
|
66903
67201
|
}
|
|
@@ -66905,29 +67203,29 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
66905
67203
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
66906
67204
|
const resolved = await resolveProfile(requested);
|
|
66907
67205
|
if (!resolved) {
|
|
66908
|
-
process.stderr.write(
|
|
67206
|
+
process.stderr.write(import_picocolors24.default.red("Not logged in. Run agentgates login first.\n"));
|
|
66909
67207
|
process.exit(2);
|
|
66910
67208
|
}
|
|
66911
67209
|
if (resolved.autoSelected) {
|
|
66912
|
-
process.stderr.write(
|
|
67210
|
+
process.stderr.write(import_picocolors24.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
66913
67211
|
`));
|
|
66914
67212
|
}
|
|
66915
67213
|
const { profile, name: profileName } = resolved;
|
|
66916
67214
|
const stdoutIsTty = process.stdout.isTTY === true;
|
|
66917
|
-
const
|
|
67215
|
+
const jsonMode5 = opts.json === true || !stdoutIsTty;
|
|
66918
67216
|
const isMax = amountOrMax.toLowerCase() === "max";
|
|
66919
67217
|
if (!isMax) {
|
|
66920
67218
|
const amountNumber = Number(amountOrMax);
|
|
66921
67219
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
66922
67220
|
failArg5(
|
|
66923
|
-
`<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)}).`
|
|
66924
67222
|
);
|
|
66925
67223
|
}
|
|
66926
67224
|
}
|
|
66927
67225
|
const assetNorm = asset.toLowerCase();
|
|
66928
67226
|
if (!ASSET_VALUES3.has(assetNorm)) {
|
|
66929
67227
|
failArg5(
|
|
66930
|
-
`asset must be ${
|
|
67228
|
+
`asset must be ${import_picocolors24.default.bold("native")} or ${import_picocolors24.default.bold("usdc")} (got ${import_picocolors24.default.bold(asset)}).`
|
|
66931
67229
|
);
|
|
66932
67230
|
}
|
|
66933
67231
|
if (!opts.chain) {
|
|
@@ -66939,7 +67237,7 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
66939
67237
|
const protocolNorm = opts.protocol.toLowerCase();
|
|
66940
67238
|
if (!PROTOCOLS2.has(protocolNorm)) {
|
|
66941
67239
|
failArg5(
|
|
66942
|
-
`--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)}).`
|
|
66943
67241
|
);
|
|
66944
67242
|
}
|
|
66945
67243
|
if (!opts.userStated || opts.userStated.trim() === "") {
|
|
@@ -66985,13 +67283,13 @@ async function earnWithdraw(amountOrMax, asset, opts) {
|
|
|
66985
67283
|
body: proposeBody,
|
|
66986
67284
|
profileName,
|
|
66987
67285
|
initialProfile: profile,
|
|
66988
|
-
jsonMode:
|
|
67286
|
+
jsonMode: jsonMode5,
|
|
66989
67287
|
shouldOpenBrowser
|
|
66990
67288
|
});
|
|
66991
67289
|
}
|
|
66992
67290
|
|
|
66993
67291
|
// src/commands/eat.ts
|
|
66994
|
-
var
|
|
67292
|
+
var import_picocolors25 = __toESM(require_picocolors(), 1);
|
|
66995
67293
|
function parseLineJson(values) {
|
|
66996
67294
|
const lines = [];
|
|
66997
67295
|
for (const value of values) {
|
|
@@ -67018,27 +67316,27 @@ function parseLineJson(values) {
|
|
|
67018
67316
|
async function loadResolvedProfile(requested) {
|
|
67019
67317
|
const resolved = await resolveProfile(requested);
|
|
67020
67318
|
if (!resolved) {
|
|
67021
|
-
process.stderr.write(
|
|
67319
|
+
process.stderr.write(import_picocolors25.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67022
67320
|
process.exit(2);
|
|
67023
67321
|
}
|
|
67024
67322
|
if (resolved.autoSelected) {
|
|
67025
|
-
process.stderr.write(
|
|
67323
|
+
process.stderr.write(import_picocolors25.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67026
67324
|
`));
|
|
67027
67325
|
}
|
|
67028
67326
|
return resolved;
|
|
67029
67327
|
}
|
|
67030
|
-
function printResult(res,
|
|
67031
|
-
if (
|
|
67328
|
+
function printResult(res, jsonMode5) {
|
|
67329
|
+
if (jsonMode5) {
|
|
67032
67330
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
67033
67331
|
return;
|
|
67034
67332
|
}
|
|
67035
67333
|
if (res.blocked) {
|
|
67036
|
-
process.stderr.write(
|
|
67334
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${res.reason ?? res.code ?? "Blocked"}
|
|
67037
67335
|
`));
|
|
67038
67336
|
if (res.upgrade_url) {
|
|
67039
67337
|
process.stderr.write(
|
|
67040
67338
|
` Open this to grant access, then re-run the command:
|
|
67041
|
-
${
|
|
67339
|
+
${import_picocolors25.default.cyan(res.upgrade_url)}
|
|
67042
67340
|
`
|
|
67043
67341
|
);
|
|
67044
67342
|
}
|
|
@@ -67050,49 +67348,49 @@ function printResult(res, jsonMode4) {
|
|
|
67050
67348
|
}
|
|
67051
67349
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
67052
67350
|
}
|
|
67053
|
-
async function postRestaurantQuiet(
|
|
67351
|
+
async function postRestaurantQuiet(path7, body, resolved) {
|
|
67054
67352
|
try {
|
|
67055
67353
|
const outcome = await callWithAutoRelogin({
|
|
67056
67354
|
profile: resolved.profile,
|
|
67057
67355
|
profileName: resolved.name,
|
|
67058
67356
|
jsonMode: true,
|
|
67059
67357
|
ttyHeader: "",
|
|
67060
|
-
fn: (bearer, origin) => apiFetch(
|
|
67358
|
+
fn: (bearer, origin) => apiFetch(path7, { method: "POST", bearer, origin, body })
|
|
67061
67359
|
});
|
|
67062
67360
|
return outcome.kind === "ok" ? outcome.result : null;
|
|
67063
67361
|
} catch {
|
|
67064
67362
|
return null;
|
|
67065
67363
|
}
|
|
67066
67364
|
}
|
|
67067
|
-
async function postRestaurant(
|
|
67365
|
+
async function postRestaurant(path7, body, resolved, jsonMode5) {
|
|
67068
67366
|
const outcome = await callWithAutoRelogin({
|
|
67069
67367
|
profile: resolved.profile,
|
|
67070
67368
|
profileName: resolved.name,
|
|
67071
|
-
jsonMode:
|
|
67072
|
-
ttyHeader:
|
|
67073
|
-
fn: (bearer, origin) => apiFetch(
|
|
67369
|
+
jsonMode: jsonMode5,
|
|
67370
|
+
ttyHeader: import_picocolors25.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
67371
|
+
fn: (bearer, origin) => apiFetch(path7, { method: "POST", bearer, origin, body })
|
|
67074
67372
|
});
|
|
67075
67373
|
if (outcome.kind === "auth_failed") {
|
|
67076
|
-
if (
|
|
67374
|
+
if (jsonMode5) {
|
|
67077
67375
|
process.stdout.write(
|
|
67078
67376
|
JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n"
|
|
67079
67377
|
);
|
|
67080
67378
|
process.exit(1);
|
|
67081
67379
|
}
|
|
67082
|
-
process.stderr.write(
|
|
67380
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${outcome.reason}.
|
|
67083
67381
|
`));
|
|
67084
67382
|
process.exit(1);
|
|
67085
67383
|
}
|
|
67086
67384
|
if (outcome.kind === "error") {
|
|
67087
67385
|
const err = outcome.error;
|
|
67088
67386
|
if (err instanceof ApiError) {
|
|
67089
|
-
if (
|
|
67387
|
+
if (jsonMode5) {
|
|
67090
67388
|
process.stdout.write(
|
|
67091
67389
|
JSON.stringify({ ok: false, status: "request_failed", error: err.message, http_status: err.status }) + "\n"
|
|
67092
67390
|
);
|
|
67093
67391
|
process.exit(1);
|
|
67094
67392
|
}
|
|
67095
|
-
process.stderr.write(
|
|
67393
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
67096
67394
|
`));
|
|
67097
67395
|
process.exit(1);
|
|
67098
67396
|
}
|
|
@@ -67102,10 +67400,10 @@ async function postRestaurant(path6, body, resolved, jsonMode4) {
|
|
|
67102
67400
|
}
|
|
67103
67401
|
async function searchFood(opts) {
|
|
67104
67402
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
67105
|
-
const
|
|
67403
|
+
const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
|
|
67106
67404
|
if (!opts.location && !opts.name) {
|
|
67107
67405
|
process.stderr.write(
|
|
67108
|
-
|
|
67406
|
+
import_picocolors25.default.red("\u2715 Pass --location (search near a place) or --name (look one store up).\n")
|
|
67109
67407
|
);
|
|
67110
67408
|
process.exit(2);
|
|
67111
67409
|
}
|
|
@@ -67118,15 +67416,15 @@ async function searchFood(opts) {
|
|
|
67118
67416
|
if (opts.radiusMiles !== void 0) body.radius_miles = Number(opts.radiusMiles);
|
|
67119
67417
|
if (opts.openOnly !== void 0) body.open_only = opts.openOnly;
|
|
67120
67418
|
if (opts.limit !== void 0) body.limit = Number(opts.limit);
|
|
67121
|
-
const result = await postRestaurant("/api/restaurants/search", body, resolved,
|
|
67122
|
-
if (result) printResult(result,
|
|
67419
|
+
const result = await postRestaurant("/api/restaurants/search", body, resolved, jsonMode5);
|
|
67420
|
+
if (result) printResult(result, jsonMode5);
|
|
67123
67421
|
}
|
|
67124
67422
|
async function menuFood(items, opts) {
|
|
67125
67423
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
67126
|
-
const
|
|
67424
|
+
const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
|
|
67127
67425
|
if (!opts.brand || !opts.address) {
|
|
67128
67426
|
process.stderr.write(
|
|
67129
|
-
|
|
67427
|
+
import_picocolors25.default.red(
|
|
67130
67428
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
67131
67429
|
)
|
|
67132
67430
|
);
|
|
@@ -67138,15 +67436,15 @@ async function menuFood(items, opts) {
|
|
|
67138
67436
|
intent: opts.intent,
|
|
67139
67437
|
items: items ?? []
|
|
67140
67438
|
};
|
|
67141
|
-
const result = await postRestaurant("/api/restaurants/menu", body, resolved,
|
|
67142
|
-
if (result) printResult(result,
|
|
67439
|
+
const result = await postRestaurant("/api/restaurants/menu", body, resolved, jsonMode5);
|
|
67440
|
+
if (result) printResult(result, jsonMode5);
|
|
67143
67441
|
}
|
|
67144
67442
|
async function orderFood(items, opts) {
|
|
67145
67443
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
67146
|
-
const
|
|
67444
|
+
const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
|
|
67147
67445
|
if (!opts.brand || !opts.address) {
|
|
67148
67446
|
process.stderr.write(
|
|
67149
|
-
|
|
67447
|
+
import_picocolors25.default.red(
|
|
67150
67448
|
"\u2715 --brand and --address are required \u2014 use the pair a `agentgates eat search` result gave you, verbatim.\n"
|
|
67151
67449
|
)
|
|
67152
67450
|
);
|
|
@@ -67156,14 +67454,14 @@ async function orderFood(items, opts) {
|
|
|
67156
67454
|
try {
|
|
67157
67455
|
structuredLines = parseLineJson(opts.lineJson ?? []);
|
|
67158
67456
|
} catch (e) {
|
|
67159
|
-
process.stderr.write(
|
|
67457
|
+
process.stderr.write(import_picocolors25.default.red(`\u2715 ${e instanceof Error ? e.message : String(e)}
|
|
67160
67458
|
`));
|
|
67161
67459
|
process.exit(2);
|
|
67162
67460
|
}
|
|
67163
67461
|
const lines = [...items ?? [], ...structuredLines];
|
|
67164
67462
|
if (lines.length === 0) {
|
|
67165
67463
|
process.stderr.write(
|
|
67166
|
-
|
|
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")
|
|
67167
67465
|
);
|
|
67168
67466
|
process.exit(2);
|
|
67169
67467
|
}
|
|
@@ -67174,9 +67472,9 @@ async function orderFood(items, opts) {
|
|
|
67174
67472
|
fulfillment: opts.fulfillment,
|
|
67175
67473
|
intent: opts.intent
|
|
67176
67474
|
};
|
|
67177
|
-
const result = await postRestaurant("/api/restaurants/order", body, resolved,
|
|
67475
|
+
const result = await postRestaurant("/api/restaurants/order", body, resolved, jsonMode5);
|
|
67178
67476
|
if (!result) return;
|
|
67179
|
-
printResult(result,
|
|
67477
|
+
printResult(result, jsonMode5);
|
|
67180
67478
|
const approvalUrl = typeof result.approval_url === "string" ? result.approval_url : null;
|
|
67181
67479
|
const browserAllowed = (() => {
|
|
67182
67480
|
if (opts.browserMode === "open") return true;
|
|
@@ -67195,9 +67493,9 @@ async function orderFood(items, opts) {
|
|
|
67195
67493
|
return;
|
|
67196
67494
|
}
|
|
67197
67495
|
if (!agentCard.will_attempt) {
|
|
67198
|
-
if (!
|
|
67496
|
+
if (!jsonMode5) {
|
|
67199
67497
|
process.stderr.write(
|
|
67200
|
-
|
|
67498
|
+
import_picocolors25.default.yellow(
|
|
67201
67499
|
`This order is over your saved card's per-order cap (${fmtCents(agentCard.max_per_order_cents)}), so it needs you.
|
|
67202
67500
|
`
|
|
67203
67501
|
)
|
|
@@ -67206,15 +67504,15 @@ async function orderFood(items, opts) {
|
|
|
67206
67504
|
openApproval();
|
|
67207
67505
|
return;
|
|
67208
67506
|
}
|
|
67209
|
-
const verdict = await pollOrderVerdict(orderId, resolved,
|
|
67210
|
-
if (
|
|
67507
|
+
const verdict = await pollOrderVerdict(orderId, resolved, jsonMode5);
|
|
67508
|
+
if (jsonMode5) {
|
|
67211
67509
|
process.stdout.write(JSON.stringify(verdict) + "\n");
|
|
67212
67510
|
if (verdict.status === "failed") return;
|
|
67213
67511
|
return;
|
|
67214
67512
|
}
|
|
67215
67513
|
if (verdict.status === "paid") {
|
|
67216
67514
|
process.stdout.write(
|
|
67217
|
-
|
|
67515
|
+
import_picocolors25.default.green(
|
|
67218
67516
|
`Paid with your saved card ending ${agentCard.last4}.` + (verdict.failure_detail ? ` ${verdict.failure_detail}` : "") + " Nothing to do.\n"
|
|
67219
67517
|
)
|
|
67220
67518
|
);
|
|
@@ -67222,7 +67520,7 @@ async function orderFood(items, opts) {
|
|
|
67222
67520
|
}
|
|
67223
67521
|
if (verdict.status === "failed") {
|
|
67224
67522
|
process.stderr.write(
|
|
67225
|
-
|
|
67523
|
+
import_picocolors25.default.yellow(
|
|
67226
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.
|
|
67227
67525
|
`
|
|
67228
67526
|
)
|
|
@@ -67232,7 +67530,7 @@ async function orderFood(items, opts) {
|
|
|
67232
67530
|
}
|
|
67233
67531
|
if (verdict.status === "unconfirmed") {
|
|
67234
67532
|
process.stderr.write(
|
|
67235
|
-
|
|
67533
|
+
import_picocolors25.default.red(
|
|
67236
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}
|
|
67237
67535
|
` : "")
|
|
67238
67536
|
)
|
|
@@ -67241,7 +67539,7 @@ async function orderFood(items, opts) {
|
|
|
67241
67539
|
return;
|
|
67242
67540
|
}
|
|
67243
67541
|
process.stderr.write(
|
|
67244
|
-
|
|
67542
|
+
import_picocolors25.default.dim(
|
|
67245
67543
|
`Still being attempted. Check with: agentgates eat status ${orderId}` + (approvalUrl ? ` \u2014 or pay yourself: ${approvalUrl}` : "") + "\n"
|
|
67246
67544
|
)
|
|
67247
67545
|
);
|
|
@@ -67264,9 +67562,9 @@ function fmtCents(cents) {
|
|
|
67264
67562
|
}
|
|
67265
67563
|
var POLL_BUDGET_MS = 1e5;
|
|
67266
67564
|
var POLL_INTERVAL_MS2 = 3500;
|
|
67267
|
-
async function pollOrderVerdict(orderId, resolved,
|
|
67268
|
-
if (!
|
|
67269
|
-
process.stderr.write(
|
|
67565
|
+
async function pollOrderVerdict(orderId, resolved, jsonMode5) {
|
|
67566
|
+
if (!jsonMode5) {
|
|
67567
|
+
process.stderr.write(import_picocolors25.default.dim("Your saved card is paying this \u2014 watching for the result\u2026\n"));
|
|
67270
67568
|
}
|
|
67271
67569
|
const deadline = Date.now() + POLL_BUDGET_MS;
|
|
67272
67570
|
let last = {
|
|
@@ -67296,19 +67594,19 @@ async function pollOrderVerdict(orderId, resolved, jsonMode4) {
|
|
|
67296
67594
|
}
|
|
67297
67595
|
async function statusFood(orderId, opts) {
|
|
67298
67596
|
const resolved = await loadResolvedProfile(opts.profile ?? DEFAULT_PROFILE);
|
|
67299
|
-
const
|
|
67597
|
+
const jsonMode5 = opts.json === true || process.stdout.isTTY !== true;
|
|
67300
67598
|
const result = await postRestaurant(
|
|
67301
67599
|
"/api/restaurants/order-status",
|
|
67302
67600
|
{ order_id: orderId.trim() },
|
|
67303
67601
|
resolved,
|
|
67304
|
-
|
|
67602
|
+
jsonMode5
|
|
67305
67603
|
);
|
|
67306
67604
|
if (!result) return;
|
|
67307
67605
|
if (result.blocked) {
|
|
67308
|
-
printResult(result,
|
|
67606
|
+
printResult(result, jsonMode5);
|
|
67309
67607
|
return;
|
|
67310
67608
|
}
|
|
67311
|
-
if (
|
|
67609
|
+
if (jsonMode5) {
|
|
67312
67610
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
67313
67611
|
return;
|
|
67314
67612
|
}
|
|
@@ -67336,40 +67634,40 @@ async function statusFood(orderId, opts) {
|
|
|
67336
67634
|
}
|
|
67337
67635
|
|
|
67338
67636
|
// src/commands/bounties.ts
|
|
67339
|
-
var
|
|
67340
|
-
async function withProfile(opts,
|
|
67637
|
+
var import_picocolors26 = __toESM(require_picocolors(), 1);
|
|
67638
|
+
async function withProfile(opts, path7, init2) {
|
|
67341
67639
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67342
67640
|
const resolved = await resolveProfile(requested);
|
|
67343
67641
|
if (!resolved) {
|
|
67344
|
-
process.stderr.write(
|
|
67642
|
+
process.stderr.write(import_picocolors26.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67345
67643
|
process.exit(2);
|
|
67346
67644
|
}
|
|
67347
67645
|
if (resolved.autoSelected) {
|
|
67348
|
-
process.stderr.write(
|
|
67646
|
+
process.stderr.write(import_picocolors26.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67349
67647
|
`));
|
|
67350
67648
|
}
|
|
67351
67649
|
const { profile, name: profileName } = resolved;
|
|
67352
|
-
const
|
|
67650
|
+
const jsonMode5 = opts.json === true;
|
|
67353
67651
|
const outcome = await callWithAutoRelogin({
|
|
67354
67652
|
profile,
|
|
67355
67653
|
profileName,
|
|
67356
|
-
jsonMode:
|
|
67357
|
-
ttyHeader:
|
|
67358
|
-
fn: (bearer, origin) => apiFetch(
|
|
67654
|
+
jsonMode: jsonMode5,
|
|
67655
|
+
ttyHeader: import_picocolors26.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
67656
|
+
fn: (bearer, origin) => apiFetch(path7, init2 ? { bearer, origin, method: init2.method, body: init2.body } : { bearer, origin })
|
|
67359
67657
|
});
|
|
67360
67658
|
if (outcome.kind === "auth_failed") {
|
|
67361
|
-
if (
|
|
67659
|
+
if (jsonMode5) {
|
|
67362
67660
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
67363
67661
|
process.exit(1);
|
|
67364
67662
|
}
|
|
67365
|
-
process.stderr.write(
|
|
67663
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 ${outcome.reason}.
|
|
67366
67664
|
`));
|
|
67367
67665
|
process.exit(1);
|
|
67368
67666
|
}
|
|
67369
67667
|
if (outcome.kind === "error") {
|
|
67370
67668
|
const err = outcome.error;
|
|
67371
67669
|
if (err instanceof ApiError) {
|
|
67372
|
-
process.stderr.write(
|
|
67670
|
+
process.stderr.write(import_picocolors26.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
67373
67671
|
`));
|
|
67374
67672
|
process.exit(1);
|
|
67375
67673
|
}
|
|
@@ -67377,18 +67675,18 @@ async function withProfile(opts, path6, init2) {
|
|
|
67377
67675
|
}
|
|
67378
67676
|
return outcome.result;
|
|
67379
67677
|
}
|
|
67380
|
-
function handleBlocked(res,
|
|
67678
|
+
function handleBlocked(res, jsonMode5) {
|
|
67381
67679
|
if (!res.blocked) return false;
|
|
67382
|
-
if (
|
|
67680
|
+
if (jsonMode5) {
|
|
67383
67681
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
67384
67682
|
process.exit(1);
|
|
67385
67683
|
}
|
|
67386
|
-
process.stderr.write(
|
|
67684
|
+
process.stderr.write(import_picocolors26.default.yellow(`
|
|
67387
67685
|
${res.reason ?? "Blocked."}
|
|
67388
67686
|
`));
|
|
67389
67687
|
if (res.upgrade_url) {
|
|
67390
67688
|
process.stderr.write(`
|
|
67391
|
-
${
|
|
67689
|
+
${import_picocolors26.default.bold(res.upgrade_url)}
|
|
67392
67690
|
|
|
67393
67691
|
`);
|
|
67394
67692
|
}
|
|
@@ -67431,30 +67729,30 @@ function printTable(rows) {
|
|
|
67431
67729
|
const cLeft = w("left", 4);
|
|
67432
67730
|
const cSubs = w("subs", 4);
|
|
67433
67731
|
process.stdout.write(
|
|
67434
|
-
|
|
67732
|
+
import_picocolors26.default.dim(
|
|
67435
67733
|
"Amount".padStart(cAmount) + " " + "Title".padEnd(cTitle) + " " + "Chain".padEnd(cChain) + " " + "Evidence".padEnd(cEv) + " " + "Left".padStart(cLeft) + " " + "Subs".padStart(cSubs) + " ID"
|
|
67436
67734
|
) + "\n"
|
|
67437
67735
|
);
|
|
67438
67736
|
for (const c of cells) {
|
|
67439
|
-
const title = c.live ?
|
|
67737
|
+
const title = c.live ? import_picocolors26.default.green(c.title.padEnd(cTitle)) : c.title.padEnd(cTitle);
|
|
67440
67738
|
process.stdout.write(
|
|
67441
|
-
|
|
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"
|
|
67442
67740
|
);
|
|
67443
67741
|
}
|
|
67444
67742
|
}
|
|
67445
67743
|
async function listBounties(opts) {
|
|
67446
|
-
const
|
|
67744
|
+
const jsonMode5 = opts.json === true;
|
|
67447
67745
|
const res = await withProfile(opts, "/api/bounties");
|
|
67448
|
-
handleBlocked(res,
|
|
67746
|
+
handleBlocked(res, jsonMode5);
|
|
67449
67747
|
let rows = res.bounties ?? [];
|
|
67450
67748
|
const min = opts.min !== void 0 ? Number(opts.min) : void 0;
|
|
67451
67749
|
const max = opts.max !== void 0 ? Number(opts.max) : void 0;
|
|
67452
67750
|
if (min !== void 0 && !Number.isFinite(min)) {
|
|
67453
|
-
process.stderr.write(
|
|
67751
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 --min must be a number.\n"));
|
|
67454
67752
|
process.exit(2);
|
|
67455
67753
|
}
|
|
67456
67754
|
if (max !== void 0 && !Number.isFinite(max)) {
|
|
67457
|
-
process.stderr.write(
|
|
67755
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 --max must be a number.\n"));
|
|
67458
67756
|
process.exit(2);
|
|
67459
67757
|
}
|
|
67460
67758
|
rows = rows.filter((r) => {
|
|
@@ -67479,22 +67777,22 @@ async function listBounties(opts) {
|
|
|
67479
67777
|
});
|
|
67480
67778
|
const limit = opts.limit !== void 0 ? Number(opts.limit) : 20;
|
|
67481
67779
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
67482
|
-
process.stderr.write(
|
|
67780
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 --limit must be a positive number.\n"));
|
|
67483
67781
|
process.exit(2);
|
|
67484
67782
|
}
|
|
67485
67783
|
const shown2 = rows.slice(0, limit);
|
|
67486
|
-
if (
|
|
67784
|
+
if (jsonMode5) {
|
|
67487
67785
|
process.stdout.write(JSON.stringify({ bounties: shown2, matched: rows.length }, null, 2) + "\n");
|
|
67488
67786
|
return;
|
|
67489
67787
|
}
|
|
67490
67788
|
if (shown2.length === 0) {
|
|
67491
|
-
process.stdout.write(
|
|
67789
|
+
process.stdout.write(import_picocolors26.default.dim("No active bounties match.\n"));
|
|
67492
67790
|
return;
|
|
67493
67791
|
}
|
|
67494
67792
|
printTable(shown2);
|
|
67495
67793
|
const clipped = rows.length - shown2.length;
|
|
67496
67794
|
process.stdout.write(
|
|
67497
|
-
"\n" +
|
|
67795
|
+
"\n" + import_picocolors26.default.dim(
|
|
67498
67796
|
`${shown2.length} of ${rows.length} matching${clipped > 0 ? ` (${clipped} more \u2014 raise --limit)` : ""}. agentgates show <id> for detail.
|
|
67499
67797
|
`
|
|
67500
67798
|
)
|
|
@@ -67502,58 +67800,58 @@ async function listBounties(opts) {
|
|
|
67502
67800
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
67503
67801
|
}
|
|
67504
67802
|
async function showBounty(id2, opts) {
|
|
67505
|
-
const
|
|
67803
|
+
const jsonMode5 = opts.json === true;
|
|
67506
67804
|
const clean = id2.trim().replace(/^.*\/bounty\//, "").replace(/[?#].*$/, "").trim();
|
|
67507
67805
|
if (!clean) {
|
|
67508
|
-
process.stderr.write(
|
|
67806
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 Give a bounty id, or a agentgates.ai/bounty/<id> link.\n"));
|
|
67509
67807
|
process.exit(2);
|
|
67510
67808
|
}
|
|
67511
67809
|
const res = await withProfile(opts, `/api/bounties/${encodeURIComponent(clean)}`);
|
|
67512
|
-
handleBlocked(res,
|
|
67513
|
-
if (
|
|
67810
|
+
handleBlocked(res, jsonMode5);
|
|
67811
|
+
if (jsonMode5) {
|
|
67514
67812
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
67515
67813
|
return;
|
|
67516
67814
|
}
|
|
67517
67815
|
const b2 = res.bounty;
|
|
67518
67816
|
if (!b2) {
|
|
67519
|
-
process.stdout.write(
|
|
67817
|
+
process.stdout.write(import_picocolors26.default.dim("Not found.\n"));
|
|
67520
67818
|
return;
|
|
67521
67819
|
}
|
|
67522
|
-
process.stdout.write("\n" +
|
|
67820
|
+
process.stdout.write("\n" + import_picocolors26.default.bold(b2.title) + "\n\n");
|
|
67523
67821
|
process.stdout.write(b2.description + "\n\n");
|
|
67524
67822
|
process.stdout.write(
|
|
67525
|
-
|
|
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"
|
|
67526
67824
|
);
|
|
67527
67825
|
if (b2.claimsAllowed && b2.claimsAllowed > 1) {
|
|
67528
67826
|
const left = Math.max(0, b2.claimsAllowed - (b2.claimsPaid ?? 0));
|
|
67529
67827
|
process.stdout.write(
|
|
67530
|
-
|
|
67828
|
+
import_picocolors26.default.dim(
|
|
67531
67829
|
`${left} of ${b2.claimsAllowed} claims left` + (b2.perClaimAmount != null ? `, ${fmtAmount(b2.perClaimAmount)} each` : "")
|
|
67532
67830
|
) + "\n"
|
|
67533
67831
|
);
|
|
67534
67832
|
}
|
|
67535
|
-
if (b2.evidenceType) process.stdout.write(
|
|
67536
|
-
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");
|
|
67537
67835
|
if (b2.geoLabel && b2.geoScope !== "global") {
|
|
67538
|
-
process.stdout.write(
|
|
67836
|
+
process.stdout.write(import_picocolors26.default.dim(`Creator says: ${b2.geoLabel}`) + "\n");
|
|
67539
67837
|
}
|
|
67540
67838
|
if (res.url) process.stdout.write("\n" + res.url + "\n");
|
|
67541
67839
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
67542
67840
|
}
|
|
67543
67841
|
async function myBounties(opts) {
|
|
67544
|
-
const
|
|
67842
|
+
const jsonMode5 = opts.json === true;
|
|
67545
67843
|
const res = await withProfile(opts, "/api/bounties?mine=1");
|
|
67546
|
-
handleBlocked(res,
|
|
67844
|
+
handleBlocked(res, jsonMode5);
|
|
67547
67845
|
const all = res.bounties ?? [];
|
|
67548
67846
|
const status3 = opts.status?.trim().toUpperCase();
|
|
67549
67847
|
const rows = status3 ? all.filter((r) => (r.status ?? "").toUpperCase() === status3) : all;
|
|
67550
|
-
if (
|
|
67848
|
+
if (jsonMode5) {
|
|
67551
67849
|
process.stdout.write(JSON.stringify({ bounties: rows, submissions: res.submissions ?? [] }, null, 2) + "\n");
|
|
67552
67850
|
return;
|
|
67553
67851
|
}
|
|
67554
67852
|
if (rows.length === 0) {
|
|
67555
67853
|
process.stdout.write(
|
|
67556
|
-
|
|
67854
|
+
import_picocolors26.default.dim(
|
|
67557
67855
|
status3 ? `No bounties of yours are ${status3}.
|
|
67558
67856
|
` : "You have not created any bounties yet. `agentgates draft` starts one.\n"
|
|
67559
67857
|
)
|
|
@@ -67563,38 +67861,38 @@ async function myBounties(opts) {
|
|
|
67563
67861
|
printTable(rows);
|
|
67564
67862
|
const subs = res.submissions ?? [];
|
|
67565
67863
|
if (subs.length > 0) {
|
|
67566
|
-
process.stdout.write("\n" +
|
|
67864
|
+
process.stdout.write("\n" + import_picocolors26.default.dim(`Plus ${subs.length} submission(s) on other people's bounties.
|
|
67567
67865
|
`));
|
|
67568
67866
|
}
|
|
67569
67867
|
process.stdout.write(AI_DIRECTIVE + "\n");
|
|
67570
67868
|
}
|
|
67571
67869
|
async function bountyFeed(opts) {
|
|
67572
|
-
const
|
|
67870
|
+
const jsonMode5 = opts.json === true;
|
|
67573
67871
|
const params = new URLSearchParams();
|
|
67574
67872
|
if (opts.limit) params.set("limit", opts.limit);
|
|
67575
67873
|
if (opts.type) params.set("type", opts.type);
|
|
67576
67874
|
const qs = params.toString();
|
|
67577
67875
|
const res = await withProfile(opts, `/api/bounties/feed${qs ? `?${qs}` : ""}`);
|
|
67578
|
-
handleBlocked(res,
|
|
67579
|
-
if (
|
|
67876
|
+
handleBlocked(res, jsonMode5);
|
|
67877
|
+
if (jsonMode5) {
|
|
67580
67878
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
67581
67879
|
return;
|
|
67582
67880
|
}
|
|
67583
67881
|
const subs = res.submissions ?? [];
|
|
67584
67882
|
if (subs.length === 0) {
|
|
67585
|
-
process.stdout.write(
|
|
67883
|
+
process.stdout.write(import_picocolors26.default.dim("Nothing in the feed for that filter.\n"));
|
|
67586
67884
|
return;
|
|
67587
67885
|
}
|
|
67588
67886
|
process.stdout.write(
|
|
67589
|
-
`${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"
|
|
67590
67888
|
);
|
|
67591
|
-
process.stdout.write(
|
|
67889
|
+
process.stdout.write(import_picocolors26.default.dim("Use --json for the full rows.\n"));
|
|
67592
67890
|
}
|
|
67593
67891
|
async function draftBounty(opts) {
|
|
67594
|
-
const
|
|
67892
|
+
const jsonMode5 = opts.json === true;
|
|
67595
67893
|
const amountNum = Number(opts.amount);
|
|
67596
67894
|
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
67597
|
-
process.stderr.write(
|
|
67895
|
+
process.stderr.write(import_picocolors26.default.red("\u2715 --amount must be a positive number of USDC.\n"));
|
|
67598
67896
|
process.exit(2);
|
|
67599
67897
|
}
|
|
67600
67898
|
const res = await withProfile(opts, "/api/bounties", {
|
|
@@ -67607,42 +67905,42 @@ async function draftBounty(opts) {
|
|
|
67607
67905
|
evidenceType: opts.evidenceType
|
|
67608
67906
|
}
|
|
67609
67907
|
});
|
|
67610
|
-
handleBlocked(res,
|
|
67611
|
-
if (
|
|
67908
|
+
handleBlocked(res, jsonMode5);
|
|
67909
|
+
if (jsonMode5) {
|
|
67612
67910
|
process.stdout.write(JSON.stringify(res, null, 2) + "\n");
|
|
67613
67911
|
return;
|
|
67614
67912
|
}
|
|
67615
|
-
process.stdout.write("\n" +
|
|
67913
|
+
process.stdout.write("\n" + import_picocolors26.default.green("\u2713") + ` Drafted "${opts.title}" for $${opts.amount} USDC.
|
|
67616
67914
|
|
|
67617
67915
|
`);
|
|
67618
|
-
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"));
|
|
67619
67917
|
if (res.fund_url) {
|
|
67620
|
-
process.stdout.write("\nFund it here:\n" +
|
|
67621
|
-
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"));
|
|
67622
67920
|
}
|
|
67623
67921
|
}
|
|
67624
67922
|
|
|
67625
67923
|
// src/commands/bounty-money.ts
|
|
67626
|
-
var
|
|
67924
|
+
var import_picocolors27 = __toESM(require_picocolors(), 1);
|
|
67627
67925
|
function failArg6(message) {
|
|
67628
|
-
process.stderr.write(
|
|
67926
|
+
process.stderr.write(import_picocolors27.default.red(`${message}
|
|
67629
67927
|
`));
|
|
67630
67928
|
process.exit(2);
|
|
67631
67929
|
}
|
|
67632
|
-
async function loadProfileOrExit(requested,
|
|
67930
|
+
async function loadProfileOrExit(requested, jsonMode5) {
|
|
67633
67931
|
const resolved = await resolveProfile(requested);
|
|
67634
67932
|
if (!resolved) {
|
|
67635
|
-
if (
|
|
67933
|
+
if (jsonMode5) {
|
|
67636
67934
|
process.stdout.write(
|
|
67637
67935
|
JSON.stringify({ ok: false, status: "auth_failed", error: "Not logged in. Run agentgates login first." }) + "\n"
|
|
67638
67936
|
);
|
|
67639
67937
|
} else {
|
|
67640
|
-
process.stderr.write(
|
|
67938
|
+
process.stderr.write(import_picocolors27.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67641
67939
|
}
|
|
67642
67940
|
process.exit(2);
|
|
67643
67941
|
}
|
|
67644
|
-
if (resolved.autoSelected && !
|
|
67645
|
-
process.stderr.write(
|
|
67942
|
+
if (resolved.autoSelected && !jsonMode5) {
|
|
67943
|
+
process.stderr.write(import_picocolors27.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67646
67944
|
`));
|
|
67647
67945
|
}
|
|
67648
67946
|
return { profile: resolved.profile, profileName: resolved.name };
|
|
@@ -67661,8 +67959,8 @@ function resolveMaxUsd(opts, profile, fallbackHint) {
|
|
|
67661
67959
|
);
|
|
67662
67960
|
}
|
|
67663
67961
|
async function fundBounty(bountyId, opts) {
|
|
67664
|
-
const
|
|
67665
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
67962
|
+
const jsonMode5 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
67963
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode5);
|
|
67666
67964
|
const maxUsd = resolveMaxUsd(opts, profile, "agentgates fund");
|
|
67667
67965
|
return runIntentFlow({
|
|
67668
67966
|
endpoint: "/api/intents/propose-fund-bounty",
|
|
@@ -67681,17 +67979,17 @@ async function fundBounty(bountyId, opts) {
|
|
|
67681
67979
|
},
|
|
67682
67980
|
profileName,
|
|
67683
67981
|
initialProfile: profile,
|
|
67684
|
-
jsonMode:
|
|
67982
|
+
jsonMode: jsonMode5,
|
|
67685
67983
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
67686
67984
|
});
|
|
67687
67985
|
}
|
|
67688
67986
|
async function tipBounty(bountyId, amount, opts) {
|
|
67689
|
-
const
|
|
67987
|
+
const jsonMode5 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
67690
67988
|
const amt = Number(amount);
|
|
67691
67989
|
if (!Number.isFinite(amt) || amt <= 0) {
|
|
67692
67990
|
failArg6(`amount must be a positive USDC number (got ${amount}).`);
|
|
67693
67991
|
}
|
|
67694
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
67992
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode5);
|
|
67695
67993
|
const maxUsd = opts.maxUsd !== void 0 ? resolveMaxUsd(opts, profile, "agentgates tip") : Math.ceil(amt * 1.01 * 100) / 100;
|
|
67696
67994
|
return runIntentFlow({
|
|
67697
67995
|
endpoint: "/api/intents/propose-tip",
|
|
@@ -67711,17 +68009,17 @@ async function tipBounty(bountyId, amount, opts) {
|
|
|
67711
68009
|
},
|
|
67712
68010
|
profileName,
|
|
67713
68011
|
initialProfile: profile,
|
|
67714
|
-
jsonMode:
|
|
68012
|
+
jsonMode: jsonMode5,
|
|
67715
68013
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
67716
68014
|
});
|
|
67717
68015
|
}
|
|
67718
68016
|
async function subscribeCreator(creatorUserId, opts) {
|
|
67719
|
-
const
|
|
68017
|
+
const jsonMode5 = Boolean(opts.json) || !process.stdout.isTTY;
|
|
67720
68018
|
const months = opts.months === void 0 ? 1 : Number(opts.months);
|
|
67721
68019
|
if (![1, 3, 12].includes(months)) {
|
|
67722
68020
|
failArg6(`--months must be 1, 3 or 12 (got ${opts.months}). Prepaid periods only \u2014 no auto-renew exists.`);
|
|
67723
68021
|
}
|
|
67724
|
-
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE,
|
|
68022
|
+
const { profile, profileName } = await loadProfileOrExit(opts.profile ?? DEFAULT_PROFILE, jsonMode5);
|
|
67725
68023
|
const maxUsd = resolveMaxUsd(opts, profile, "agentgates subscribe");
|
|
67726
68024
|
return runIntentFlow({
|
|
67727
68025
|
endpoint: "/api/intents/propose-subscribe",
|
|
@@ -67741,48 +68039,48 @@ async function subscribeCreator(creatorUserId, opts) {
|
|
|
67741
68039
|
},
|
|
67742
68040
|
profileName,
|
|
67743
68041
|
initialProfile: profile,
|
|
67744
|
-
jsonMode:
|
|
68042
|
+
jsonMode: jsonMode5,
|
|
67745
68043
|
shouldOpenBrowser: resolveBrowserDefault(opts.browserMode ?? "auto")
|
|
67746
68044
|
});
|
|
67747
68045
|
}
|
|
67748
68046
|
|
|
67749
68047
|
// src/commands/bounty-work.ts
|
|
67750
|
-
var
|
|
67751
|
-
async function runWork(
|
|
68048
|
+
var import_picocolors28 = __toESM(require_picocolors(), 1);
|
|
68049
|
+
async function runWork(path7, body, opts) {
|
|
67752
68050
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67753
68051
|
const resolved = await resolveProfile(requested);
|
|
67754
68052
|
if (!resolved) {
|
|
67755
|
-
process.stderr.write(
|
|
68053
|
+
process.stderr.write(import_picocolors28.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67756
68054
|
process.exit(2);
|
|
67757
68055
|
}
|
|
67758
68056
|
if (resolved.autoSelected) {
|
|
67759
|
-
process.stderr.write(
|
|
68057
|
+
process.stderr.write(import_picocolors28.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67760
68058
|
`));
|
|
67761
68059
|
}
|
|
67762
|
-
const
|
|
68060
|
+
const jsonMode5 = opts.json === true;
|
|
67763
68061
|
const outcome = await callWithAutoRelogin({
|
|
67764
68062
|
profile: resolved.profile,
|
|
67765
68063
|
profileName: resolved.name,
|
|
67766
|
-
jsonMode:
|
|
67767
|
-
ttyHeader:
|
|
67768
|
-
fn: (bearer, origin) => apiFetch(
|
|
68064
|
+
jsonMode: jsonMode5,
|
|
68065
|
+
ttyHeader: import_picocolors28.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
68066
|
+
fn: (bearer, origin) => apiFetch(path7, { bearer, origin, method: "POST", body })
|
|
67769
68067
|
});
|
|
67770
68068
|
if (outcome.kind === "auth_failed") {
|
|
67771
|
-
if (
|
|
68069
|
+
if (jsonMode5) {
|
|
67772
68070
|
process.stdout.write(JSON.stringify({ ok: false, status: "auth_failed", error: outcome.reason }) + "\n");
|
|
67773
68071
|
process.exit(1);
|
|
67774
68072
|
}
|
|
67775
|
-
process.stderr.write(
|
|
68073
|
+
process.stderr.write(import_picocolors28.default.red(`\u2715 ${outcome.reason}.
|
|
67776
68074
|
`));
|
|
67777
68075
|
process.exit(1);
|
|
67778
68076
|
}
|
|
67779
68077
|
if (outcome.kind === "error") {
|
|
67780
68078
|
const err = outcome.error;
|
|
67781
68079
|
if (err instanceof ApiError) {
|
|
67782
|
-
if (
|
|
68080
|
+
if (jsonMode5) {
|
|
67783
68081
|
process.stdout.write(JSON.stringify({ ok: false, error: err.message, http_status: err.status }) + "\n");
|
|
67784
68082
|
} else {
|
|
67785
|
-
process.stderr.write(
|
|
68083
|
+
process.stderr.write(import_picocolors28.default.red(`\u2715 ${err.message} (HTTP ${err.status})
|
|
67786
68084
|
`));
|
|
67787
68085
|
}
|
|
67788
68086
|
process.exit(1);
|
|
@@ -67791,29 +68089,29 @@ async function runWork(path6, body, opts) {
|
|
|
67791
68089
|
}
|
|
67792
68090
|
const data4 = outcome.result;
|
|
67793
68091
|
if (data4.blocked) {
|
|
67794
|
-
if (
|
|
68092
|
+
if (jsonMode5) {
|
|
67795
68093
|
process.stdout.write(JSON.stringify({ ok: false, ...data4 }) + "\n");
|
|
67796
68094
|
process.exit(1);
|
|
67797
68095
|
}
|
|
67798
|
-
process.stderr.write(
|
|
68096
|
+
process.stderr.write(import_picocolors28.default.yellow(`
|
|
67799
68097
|
${data4.reason ?? "Blocked."}
|
|
67800
68098
|
`));
|
|
67801
68099
|
if (data4.upgrade_url) process.stderr.write(`
|
|
67802
|
-
${
|
|
68100
|
+
${import_picocolors28.default.bold(data4.upgrade_url)}
|
|
67803
68101
|
|
|
67804
68102
|
`);
|
|
67805
68103
|
process.exit(1);
|
|
67806
68104
|
}
|
|
67807
68105
|
if (typeof data4.error === "string" && data4.error) {
|
|
67808
|
-
if (
|
|
68106
|
+
if (jsonMode5) {
|
|
67809
68107
|
process.stdout.write(JSON.stringify({ ok: false, error: data4.error }) + "\n");
|
|
67810
68108
|
} else {
|
|
67811
|
-
process.stderr.write(
|
|
68109
|
+
process.stderr.write(import_picocolors28.default.red(`\u2715 ${data4.error}
|
|
67812
68110
|
`));
|
|
67813
68111
|
}
|
|
67814
68112
|
process.exit(1);
|
|
67815
68113
|
}
|
|
67816
|
-
if (
|
|
68114
|
+
if (jsonMode5) {
|
|
67817
68115
|
process.stdout.write(JSON.stringify({ ok: true, ...data4 }) + "\n");
|
|
67818
68116
|
return;
|
|
67819
68117
|
}
|
|
@@ -67851,43 +68149,43 @@ async function bountyRetention(bountyId, opts) {
|
|
|
67851
68149
|
}
|
|
67852
68150
|
|
|
67853
68151
|
// src/commands/bounty-deliver.ts
|
|
67854
|
-
var
|
|
67855
|
-
import { spawn } from "node:child_process";
|
|
68152
|
+
var import_picocolors29 = __toESM(require_picocolors(), 1);
|
|
68153
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
67856
68154
|
var FLUSH_MS = 400;
|
|
67857
68155
|
var FLUSH_BYTES = 2048;
|
|
67858
68156
|
async function deliver(bountyId, command, opts) {
|
|
67859
|
-
const
|
|
68157
|
+
const jsonMode5 = opts.json === true;
|
|
67860
68158
|
const requested = opts.profile ?? DEFAULT_PROFILE;
|
|
67861
68159
|
const resolved = await resolveProfile(requested);
|
|
67862
68160
|
if (!resolved) {
|
|
67863
|
-
process.stderr.write(
|
|
68161
|
+
process.stderr.write(import_picocolors29.default.red("Not logged in. Run agentgates login first.\n"));
|
|
67864
68162
|
process.exit(2);
|
|
67865
68163
|
}
|
|
67866
|
-
if (resolved.autoSelected && !
|
|
67867
|
-
process.stderr.write(
|
|
68164
|
+
if (resolved.autoSelected && !jsonMode5) {
|
|
68165
|
+
process.stderr.write(import_picocolors29.default.dim(`Using profile "${resolved.name}" (pass --profile to choose)
|
|
67868
68166
|
`));
|
|
67869
68167
|
}
|
|
67870
|
-
const post = async (
|
|
68168
|
+
const post = async (path7, body) => {
|
|
67871
68169
|
const outcome = await callWithAutoRelogin({
|
|
67872
68170
|
profile: resolved.profile,
|
|
67873
68171
|
profileName: resolved.name,
|
|
67874
|
-
jsonMode:
|
|
67875
|
-
ttyHeader:
|
|
67876
|
-
fn: (bearer, origin) => apiFetch(
|
|
68172
|
+
jsonMode: jsonMode5,
|
|
68173
|
+
ttyHeader: import_picocolors29.default.dim("Bearer expired \u2014 re-pairing this terminal\u2026"),
|
|
68174
|
+
fn: (bearer, origin) => apiFetch(path7, { bearer, origin, method: "POST", body })
|
|
67877
68175
|
});
|
|
67878
68176
|
if (outcome.kind === "auth_failed") throw new Error(outcome.reason);
|
|
67879
68177
|
if (outcome.kind === "error") throw outcome.error;
|
|
67880
68178
|
return outcome.result;
|
|
67881
68179
|
};
|
|
67882
68180
|
const die = (msg, data4) => {
|
|
67883
|
-
if (
|
|
68181
|
+
if (jsonMode5) {
|
|
67884
68182
|
process.stdout.write(JSON.stringify({ ok: false, error: msg, ...data4 ?? {} }) + "\n");
|
|
67885
68183
|
} else {
|
|
67886
|
-
process.stderr.write(
|
|
68184
|
+
process.stderr.write(import_picocolors29.default.red(`
|
|
67887
68185
|
\u2715 ${msg}
|
|
67888
68186
|
`));
|
|
67889
68187
|
if (data4?.upgrade_url) process.stderr.write(`
|
|
67890
|
-
${
|
|
68188
|
+
${import_picocolors29.default.bold(data4.upgrade_url)}
|
|
67891
68189
|
|
|
67892
68190
|
`);
|
|
67893
68191
|
}
|
|
@@ -67910,9 +68208,9 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
|
|
|
67910
68208
|
if (started.error) return void die(started.error, started);
|
|
67911
68209
|
const runId = started.run_id;
|
|
67912
68210
|
if (!runId) return void die("The service opened a run but did not name it.");
|
|
67913
|
-
if (!
|
|
68211
|
+
if (!jsonMode5) {
|
|
67914
68212
|
process.stderr.write(
|
|
67915
|
-
|
|
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 ?? ""}
|
|
67916
68214
|
|
|
67917
68215
|
`)
|
|
67918
68216
|
);
|
|
@@ -67941,7 +68239,7 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
|
|
|
67941
68239
|
const timer = setInterval(() => flush(true), FLUSH_MS);
|
|
67942
68240
|
const consume = (data4) => {
|
|
67943
68241
|
buffer += data4;
|
|
67944
|
-
if (!opts.quiet && !
|
|
68242
|
+
if (!opts.quiet && !jsonMode5) process.stderr.write(data4);
|
|
67945
68243
|
flush();
|
|
67946
68244
|
};
|
|
67947
68245
|
let exitCode = 0;
|
|
@@ -67956,7 +68254,7 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
|
|
|
67956
68254
|
});
|
|
67957
68255
|
} else {
|
|
67958
68256
|
exitCode = await new Promise((resolve2) => {
|
|
67959
|
-
const child =
|
|
68257
|
+
const child = spawn2(command[0], command.slice(1), {
|
|
67960
68258
|
stdio: ["inherit", "pipe", "pipe"],
|
|
67961
68259
|
env: process.env
|
|
67962
68260
|
});
|
|
@@ -67964,10 +68262,10 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
|
|
|
67964
68262
|
child.stdout.on("data", (d) => consume(d));
|
|
67965
68263
|
child.stderr.setEncoding("utf8");
|
|
67966
68264
|
child.stderr.on("data", (d) => {
|
|
67967
|
-
if (!
|
|
68265
|
+
if (!jsonMode5) process.stderr.write(import_picocolors29.default.dim(d));
|
|
67968
68266
|
});
|
|
67969
68267
|
child.on("error", (err) => {
|
|
67970
|
-
process.stderr.write(
|
|
68268
|
+
process.stderr.write(import_picocolors29.default.red(`
|
|
67971
68269
|
\u2715 Could not run ${command[0]}: ${err.message}
|
|
67972
68270
|
`));
|
|
67973
68271
|
resolve2(127);
|
|
@@ -67989,7 +68287,7 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
|
|
|
67989
68287
|
}
|
|
67990
68288
|
if (finished.blocked) return void die(finished.reason ?? "Blocked.", finished);
|
|
67991
68289
|
if (finished.error) return void die(finished.error, finished);
|
|
67992
|
-
if (
|
|
68290
|
+
if (jsonMode5) {
|
|
67993
68291
|
process.stdout.write(
|
|
67994
68292
|
JSON.stringify({
|
|
67995
68293
|
ok: true,
|
|
@@ -68004,14 +68302,14 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
|
|
|
68004
68302
|
}
|
|
68005
68303
|
if (appendFailure) {
|
|
68006
68304
|
process.stderr.write(
|
|
68007
|
-
|
|
68305
|
+
import_picocolors29.default.yellow(`
|
|
68008
68306
|
! Some output did not reach the page: ${appendFailure}
|
|
68009
|
-
`) +
|
|
68307
|
+
`) + import_picocolors29.default.yellow(" What did arrive is sealed below. Check it before you submit.\n")
|
|
68010
68308
|
);
|
|
68011
68309
|
}
|
|
68012
68310
|
if (exitCode) {
|
|
68013
68311
|
process.stderr.write(
|
|
68014
|
-
|
|
68312
|
+
import_picocolors29.default.yellow(`
|
|
68015
68313
|
! ${command[0]} exited ${exitCode}. The run was sealed with what it produced.
|
|
68016
68314
|
`)
|
|
68017
68315
|
);
|
|
@@ -68021,12 +68319,12 @@ ${import_picocolors27.default.bold(data4.upgrade_url)}
|
|
|
68021
68319
|
}
|
|
68022
68320
|
|
|
68023
68321
|
// src/commands/trade.ts
|
|
68024
|
-
var
|
|
68322
|
+
var import_picocolors30 = __toESM(require_picocolors(), 1);
|
|
68025
68323
|
|
|
68026
68324
|
// src/lib/trade-sol.ts
|
|
68027
68325
|
var import_web3 = __toESM(require_index_cjs(), 1);
|
|
68028
68326
|
import { promises as fs8 } from "node:fs";
|
|
68029
|
-
import * as
|
|
68327
|
+
import * as path5 from "node:path";
|
|
68030
68328
|
import * as os3 from "node:os";
|
|
68031
68329
|
var TRADE_CHAIN_ID = 901;
|
|
68032
68330
|
if (TRADE_CHAIN_ID === 900) {
|
|
@@ -68117,7 +68415,7 @@ async function relayGet(pathname) {
|
|
|
68117
68415
|
return parsed;
|
|
68118
68416
|
}
|
|
68119
68417
|
function tradeSolPath() {
|
|
68120
|
-
return
|
|
68418
|
+
return path5.join(os3.homedir(), ".agentgates", "trade-sol.json");
|
|
68121
68419
|
}
|
|
68122
68420
|
async function loadTradeKey() {
|
|
68123
68421
|
let raw;
|
|
@@ -68149,7 +68447,7 @@ async function loadOrCreateTradeKey() {
|
|
|
68149
68447
|
secretKey: Array.from(keypair.secretKey),
|
|
68150
68448
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
68151
68449
|
};
|
|
68152
|
-
const dir =
|
|
68450
|
+
const dir = path5.dirname(tradeSolPath());
|
|
68153
68451
|
await fs8.mkdir(dir, { recursive: true, mode: 448 });
|
|
68154
68452
|
await fs8.chmod(dir, 448).catch(() => {
|
|
68155
68453
|
});
|
|
@@ -68383,11 +68681,11 @@ async function runTrade(args) {
|
|
|
68383
68681
|
}
|
|
68384
68682
|
|
|
68385
68683
|
// src/commands/trade.ts
|
|
68386
|
-
function
|
|
68684
|
+
function fail2(message, json2) {
|
|
68387
68685
|
if (json2) {
|
|
68388
68686
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
68389
68687
|
} else {
|
|
68390
|
-
process.stderr.write(
|
|
68688
|
+
process.stderr.write(import_picocolors30.default.red(`\u2715 ${message}
|
|
68391
68689
|
`));
|
|
68392
68690
|
}
|
|
68393
68691
|
process.exit(1);
|
|
@@ -68397,7 +68695,7 @@ async function withContext(opts, fn) {
|
|
|
68397
68695
|
const ctx2 = await resolveTradeContext();
|
|
68398
68696
|
return await fn(ctx2);
|
|
68399
68697
|
} catch (err) {
|
|
68400
|
-
|
|
68698
|
+
fail2(err.message, opts.json);
|
|
68401
68699
|
}
|
|
68402
68700
|
}
|
|
68403
68701
|
function servedFloorUnits(ctx2) {
|
|
@@ -68423,7 +68721,7 @@ async function tradeKey(opts) {
|
|
|
68423
68721
|
];
|
|
68424
68722
|
process.stdout.write(lines.join("\n") + "\n" + AI_DIRECTIVE + "\n");
|
|
68425
68723
|
} catch (err) {
|
|
68426
|
-
|
|
68724
|
+
fail2(err.message, opts.json);
|
|
68427
68725
|
}
|
|
68428
68726
|
}
|
|
68429
68727
|
async function tradeStatus(opts) {
|
|
@@ -68480,7 +68778,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
68480
68778
|
const coin = await resolveCoin(coinArg);
|
|
68481
68779
|
const amountNumber = Number(amount);
|
|
68482
68780
|
if (!Number.isFinite(amountNumber) || amountNumber <= 0) {
|
|
68483
|
-
|
|
68781
|
+
fail2(`Amount "${amount}" is not a positive number.`, opts.json);
|
|
68484
68782
|
}
|
|
68485
68783
|
const res = await fetch(`${CREATORS_ORIGIN}/api/launch-quote`, {
|
|
68486
68784
|
method: "POST",
|
|
@@ -68494,7 +68792,7 @@ async function tradeQuote(coinArg, amount, opts) {
|
|
|
68494
68792
|
});
|
|
68495
68793
|
const body = await res.json().catch(() => null);
|
|
68496
68794
|
if (!res.ok || !body) {
|
|
68497
|
-
|
|
68795
|
+
fail2(`Quote failed: ${body?.error ?? `HTTP ${res.status}`}`, opts.json);
|
|
68498
68796
|
}
|
|
68499
68797
|
const floor = servedFloorUnits(ctx2);
|
|
68500
68798
|
const belowFloor = side === "buy" && floor !== null && parseDecimalToUnits(amount, USDC_DECIMALS, "Amount") < floor.units;
|
|
@@ -68569,16 +68867,16 @@ async function tradeBuy(coinArg, amount, opts) {
|
|
|
68569
68867
|
try {
|
|
68570
68868
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
|
|
68571
68869
|
} catch (err) {
|
|
68572
|
-
|
|
68870
|
+
fail2(err.message, opts.json);
|
|
68573
68871
|
}
|
|
68574
|
-
if (units <= 0n)
|
|
68872
|
+
if (units <= 0n) fail2("Buy amount must be above zero.", opts.json);
|
|
68575
68873
|
const floor = servedFloorUnits(ctx2);
|
|
68576
68874
|
if (floor && units < floor.units) {
|
|
68577
|
-
|
|
68875
|
+
fail2(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
68578
68876
|
}
|
|
68579
68877
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
68580
68878
|
if (created && !opts.json) {
|
|
68581
|
-
process.stderr.write(
|
|
68879
|
+
process.stderr.write(import_picocolors30.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
68582
68880
|
`));
|
|
68583
68881
|
}
|
|
68584
68882
|
const result = await runTrade({ ctx: ctx2, keypair, token: coin.mint, side: "buy", amount, minOut: opts.minOut });
|
|
@@ -68589,23 +68887,23 @@ async function tradeSell(coinArg, amount, opts) {
|
|
|
68589
68887
|
await withContext(opts, async (ctx2) => {
|
|
68590
68888
|
const coin = await resolveCoin(coinArg);
|
|
68591
68889
|
const key = await loadTradeKey();
|
|
68592
|
-
if (!key)
|
|
68890
|
+
if (!key) fail2("No agent trading key yet (nothing to sell with). Run: agentgates trade key", opts.json);
|
|
68593
68891
|
let sellAmount = amount.trim();
|
|
68594
68892
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
68595
68893
|
if (sellAmount === "all" || pct) {
|
|
68596
68894
|
const bal = await readTokenBalance(rpcConnection(), key.state.address, coin.mint);
|
|
68597
|
-
if (!bal)
|
|
68598
|
-
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);
|
|
68599
68897
|
let units = bal.units;
|
|
68600
68898
|
if (pct) {
|
|
68601
68899
|
const p = BigInt(pct[1]);
|
|
68602
|
-
if (p <= 0n || p > 100n)
|
|
68900
|
+
if (p <= 0n || p > 100n) fail2(`Percentage must be 1-100, got "${amount}".`, opts.json);
|
|
68603
68901
|
units = bal.units * p / 100n;
|
|
68604
68902
|
}
|
|
68605
|
-
if (units <= 0n)
|
|
68903
|
+
if (units <= 0n) fail2("Sell amount rounds to zero.", opts.json);
|
|
68606
68904
|
sellAmount = formatUnits2(units, bal.decimals);
|
|
68607
68905
|
} else if (!/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
68608
|
-
|
|
68906
|
+
fail2(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
68609
68907
|
}
|
|
68610
68908
|
const result = await runTrade({ ctx: ctx2, keypair: key.keypair, token: coin.mint, side: "sell", amount: sellAmount, minOut: opts.minOut });
|
|
68611
68909
|
await reportTrade(ctx2, opts, { side: "sell", coin, address: key.state.address, amount: sellAmount, result });
|
|
@@ -68620,19 +68918,19 @@ function describeOrder(o) {
|
|
|
68620
68918
|
async function tradeOrderPlace(coinArg, opts) {
|
|
68621
68919
|
await withContext(opts, async (ctx2) => {
|
|
68622
68920
|
if (opts.buy === void 0 === (opts.sell === void 0)) {
|
|
68623
|
-
|
|
68921
|
+
fail2("Pass exactly one of --buy <usdc> or --sell <amount|N%|all>.", opts.json);
|
|
68624
68922
|
}
|
|
68625
68923
|
if (opts.at === void 0 === (opts.onGraduation !== true)) {
|
|
68626
|
-
|
|
68924
|
+
fail2("Pass exactly one trigger: --at <value> (price, or mcap with --mcap) or --on-graduation.", opts.json);
|
|
68627
68925
|
}
|
|
68628
68926
|
const coin = await resolveCoin(coinArg);
|
|
68629
68927
|
const side = opts.buy !== void 0 ? "buy" : "sell";
|
|
68630
68928
|
const kind = opts.onGraduation ? side === "buy" ? "buy_on_graduation" : "sell_on_graduation" : side === "buy" ? "buy_at" : "sell_at";
|
|
68631
|
-
if (opts.stop && kind !== "sell_at")
|
|
68632
|
-
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);
|
|
68633
68931
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
68634
68932
|
if (created && !opts.json) {
|
|
68635
|
-
process.stderr.write(
|
|
68933
|
+
process.stderr.write(import_picocolors30.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
68636
68934
|
`));
|
|
68637
68935
|
}
|
|
68638
68936
|
let amount;
|
|
@@ -68641,11 +68939,11 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
68641
68939
|
try {
|
|
68642
68940
|
units = parseDecimalToUnits(opts.buy, USDC_DECIMALS, "Buy amount");
|
|
68643
68941
|
} catch (err) {
|
|
68644
|
-
|
|
68942
|
+
fail2(err.message, opts.json);
|
|
68645
68943
|
}
|
|
68646
68944
|
const floor = servedFloorUnits(ctx2);
|
|
68647
68945
|
if (floor && units < floor.units) {
|
|
68648
|
-
|
|
68946
|
+
fail2(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
68649
68947
|
}
|
|
68650
68948
|
amount = opts.buy;
|
|
68651
68949
|
} else {
|
|
@@ -68653,24 +68951,24 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
68653
68951
|
const pct = amount.match(/^(\d+)%$/);
|
|
68654
68952
|
if (amount === "all" || pct) {
|
|
68655
68953
|
const bal = await readTokenBalance(rpcConnection(), state.address, coin.mint);
|
|
68656
|
-
if (!bal)
|
|
68657
|
-
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);
|
|
68658
68956
|
let units = bal.units;
|
|
68659
68957
|
if (pct) {
|
|
68660
68958
|
const p = BigInt(pct[1]);
|
|
68661
|
-
if (p <= 0n || p > 100n)
|
|
68959
|
+
if (p <= 0n || p > 100n) fail2(`Percentage must be 1-100, got "${opts.sell}".`, opts.json);
|
|
68662
68960
|
units = bal.units * p / 100n;
|
|
68663
68961
|
}
|
|
68664
|
-
if (units <= 0n)
|
|
68962
|
+
if (units <= 0n) fail2("Sell amount rounds to zero.", opts.json);
|
|
68665
68963
|
amount = formatUnits2(units, bal.decimals);
|
|
68666
68964
|
} else if (!/^\d+(\.\d+)?$/.test(amount)) {
|
|
68667
|
-
|
|
68965
|
+
fail2(`Sell amount "${opts.sell}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
68668
68966
|
}
|
|
68669
68967
|
}
|
|
68670
68968
|
let expiresInDays;
|
|
68671
68969
|
if (opts.expiresDays !== void 0) {
|
|
68672
68970
|
const n2 = Number(opts.expiresDays);
|
|
68673
|
-
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);
|
|
68674
68972
|
expiresInDays = n2;
|
|
68675
68973
|
}
|
|
68676
68974
|
const prepared = await prepareOrder({
|
|
@@ -68706,7 +69004,7 @@ async function tradeOrderPlace(coinArg, opts) {
|
|
|
68706
69004
|
async function tradeOrdersList(opts) {
|
|
68707
69005
|
await withContext(opts, async (ctx2) => {
|
|
68708
69006
|
const key = await loadTradeKey();
|
|
68709
|
-
if (!key)
|
|
69007
|
+
if (!key) fail2("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
68710
69008
|
const token = opts.coin ? (await resolveCoin(opts.coin)).mint : void 0;
|
|
68711
69009
|
const res = await listOrders(key.state.address, token);
|
|
68712
69010
|
if (opts.json) {
|
|
@@ -68726,15 +69024,15 @@ async function tradeOrdersList(opts) {
|
|
|
68726
69024
|
async function tradeOrderCancel(id2, opts) {
|
|
68727
69025
|
await withContext(opts, async (_ctx) => {
|
|
68728
69026
|
const key = await loadTradeKey();
|
|
68729
|
-
if (!key)
|
|
69027
|
+
if (!key) fail2("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
68730
69028
|
try {
|
|
68731
69029
|
await cancelOrder(id2, key.state.address);
|
|
68732
69030
|
} catch (err) {
|
|
68733
69031
|
if (err instanceof RelayError && err.status === 409) {
|
|
68734
|
-
|
|
69032
|
+
fail2(`Order ${id2} already fired or ended; nothing to cancel.`, opts.json);
|
|
68735
69033
|
}
|
|
68736
69034
|
if (err instanceof RelayError && err.status === 404) {
|
|
68737
|
-
|
|
69035
|
+
fail2(`No order ${id2} for this key (already canceled, or never placed).`, opts.json);
|
|
68738
69036
|
}
|
|
68739
69037
|
throw err;
|
|
68740
69038
|
}
|
|
@@ -68749,12 +69047,12 @@ async function tradeOrderCancel(id2, opts) {
|
|
|
68749
69047
|
async function tradePositions(opts) {
|
|
68750
69048
|
await withContext(opts, async (ctx2) => {
|
|
68751
69049
|
const key = await loadTradeKey();
|
|
68752
|
-
if (!key)
|
|
69050
|
+
if (!key) fail2("No agent trading key yet. Run: agentgates trade key", opts.json);
|
|
68753
69051
|
let body;
|
|
68754
69052
|
try {
|
|
68755
69053
|
body = await relayGet(`/launch-portfolio?address=${encodeURIComponent(key.state.address)}`);
|
|
68756
69054
|
} catch (err) {
|
|
68757
|
-
if (err instanceof RelayError)
|
|
69055
|
+
if (err instanceof RelayError) fail2(`Positions read failed: ${err.message}`, opts.json);
|
|
68758
69056
|
throw err;
|
|
68759
69057
|
}
|
|
68760
69058
|
const rows = body?.tokens ?? [];
|
|
@@ -68797,12 +69095,12 @@ async function tradePositions(opts) {
|
|
|
68797
69095
|
}
|
|
68798
69096
|
|
|
68799
69097
|
// src/commands/desk.ts
|
|
68800
|
-
var
|
|
69098
|
+
var import_picocolors31 = __toESM(require_picocolors(), 1);
|
|
68801
69099
|
|
|
68802
69100
|
// src/lib/desk-sol.ts
|
|
68803
69101
|
var import_web32 = __toESM(require_index_cjs(), 1);
|
|
68804
69102
|
import { promises as fs9 } from "node:fs";
|
|
68805
|
-
import * as
|
|
69103
|
+
import * as path6 from "node:path";
|
|
68806
69104
|
import * as os4 from "node:os";
|
|
68807
69105
|
async function resolveDeskContext() {
|
|
68808
69106
|
const ctx2 = await resolveTradeContext();
|
|
@@ -68815,7 +69113,7 @@ async function resolveDeskContext() {
|
|
|
68815
69113
|
return { ...ctx2, desk: desk2 };
|
|
68816
69114
|
}
|
|
68817
69115
|
function deskSessionPath() {
|
|
68818
|
-
return
|
|
69116
|
+
return path6.join(os4.homedir(), ".agentgates", "desk-session-sol.json");
|
|
68819
69117
|
}
|
|
68820
69118
|
function deskSessionKeyPath() {
|
|
68821
69119
|
return deskSessionPath();
|
|
@@ -68851,7 +69149,7 @@ async function loadOrCreateDeskSessionKey() {
|
|
|
68851
69149
|
secretKey: Array.from(keypair.secretKey),
|
|
68852
69150
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
68853
69151
|
};
|
|
68854
|
-
const dir =
|
|
69152
|
+
const dir = path6.dirname(deskSessionPath());
|
|
68855
69153
|
await fs9.mkdir(dir, { recursive: true, mode: 448 });
|
|
68856
69154
|
await fs9.chmod(dir, 448).catch(() => {
|
|
68857
69155
|
});
|
|
@@ -68967,11 +69265,11 @@ async function runDeskTrade(args) {
|
|
|
68967
69265
|
}
|
|
68968
69266
|
|
|
68969
69267
|
// src/commands/desk.ts
|
|
68970
|
-
function
|
|
69268
|
+
function fail3(message, json2) {
|
|
68971
69269
|
if (json2) {
|
|
68972
69270
|
process.stdout.write(JSON.stringify({ ok: false, error: message }) + "\n");
|
|
68973
69271
|
} else {
|
|
68974
|
-
process.stderr.write(
|
|
69272
|
+
process.stderr.write(import_picocolors31.default.red(`\u2715 ${message}
|
|
68975
69273
|
`));
|
|
68976
69274
|
}
|
|
68977
69275
|
process.exit(1);
|
|
@@ -68981,7 +69279,7 @@ async function withDesk(opts, fn) {
|
|
|
68981
69279
|
const ctx2 = await resolveDeskContext();
|
|
68982
69280
|
return await fn(ctx2);
|
|
68983
69281
|
} catch (err) {
|
|
68984
|
-
|
|
69282
|
+
fail3(err.message, opts.json);
|
|
68985
69283
|
}
|
|
68986
69284
|
}
|
|
68987
69285
|
function servedFloorUnits2(ctx2) {
|
|
@@ -68992,7 +69290,7 @@ function servedFloorUnits2(ctx2) {
|
|
|
68992
69290
|
async function requireOwner(opts) {
|
|
68993
69291
|
const key = await loadTradeKey();
|
|
68994
69292
|
if (!key) {
|
|
68995
|
-
|
|
69293
|
+
fail3("No agent trading key yet (the desk's owner). Run: agentgates trade key", opts.json);
|
|
68996
69294
|
}
|
|
68997
69295
|
return key;
|
|
68998
69296
|
}
|
|
@@ -69061,7 +69359,7 @@ async function deskStatus(opts) {
|
|
|
69061
69359
|
if (opts.fills !== void 0) {
|
|
69062
69360
|
const n2 = Number(opts.fills);
|
|
69063
69361
|
if (!Number.isInteger(n2) || n2 <= 0) {
|
|
69064
|
-
|
|
69362
|
+
fail3(`--fills must be a positive integer, got "${opts.fills}".`, opts.json);
|
|
69065
69363
|
}
|
|
69066
69364
|
fillsLimit = n2;
|
|
69067
69365
|
}
|
|
@@ -69109,12 +69407,12 @@ async function deskDeposit(amount, opts) {
|
|
|
69109
69407
|
try {
|
|
69110
69408
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Deposit amount");
|
|
69111
69409
|
} catch (err) {
|
|
69112
|
-
|
|
69410
|
+
fail3(err.message, opts.json);
|
|
69113
69411
|
}
|
|
69114
|
-
if (units <= 0n)
|
|
69412
|
+
if (units <= 0n) fail3("Deposit amount must be above zero.", opts.json);
|
|
69115
69413
|
const { keypair, state, created } = await loadOrCreateTradeKey();
|
|
69116
69414
|
if (created && !opts.json) {
|
|
69117
|
-
process.stderr.write(
|
|
69415
|
+
process.stderr.write(import_picocolors31.default.dim(`Generated the agent trading key ${state.address} (${tradeKeyPath()}).
|
|
69118
69416
|
`));
|
|
69119
69417
|
}
|
|
69120
69418
|
const result = await runDeskCeremony({
|
|
@@ -69155,7 +69453,7 @@ async function deskWithdraw(amount, opts) {
|
|
|
69155
69453
|
const trimmed = amount.trim();
|
|
69156
69454
|
if (trimmed !== "all") {
|
|
69157
69455
|
if (!/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
69158
|
-
|
|
69456
|
+
fail3(`Withdraw amount "${amount}" is not a decimal amount or "all".`, opts.json);
|
|
69159
69457
|
}
|
|
69160
69458
|
}
|
|
69161
69459
|
const result = await runDeskCeremony({
|
|
@@ -69194,28 +69492,28 @@ async function deskWithdraw(amount, opts) {
|
|
|
69194
69492
|
}
|
|
69195
69493
|
async function deskSessionRegister(opts) {
|
|
69196
69494
|
await withDesk(opts, async (ctx2) => {
|
|
69197
|
-
if (!opts.cap)
|
|
69198
|
-
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);
|
|
69199
69497
|
let capUnits;
|
|
69200
69498
|
try {
|
|
69201
69499
|
capUnits = parseDecimalToUnits(opts.cap, USDC_DECIMALS, "Per-trade cap");
|
|
69202
69500
|
} catch (err) {
|
|
69203
|
-
|
|
69501
|
+
fail3(err.message, opts.json);
|
|
69204
69502
|
}
|
|
69205
|
-
if (capUnits <= 0n)
|
|
69503
|
+
if (capUnits <= 0n) fail3("Per-trade cap must be above zero.", opts.json);
|
|
69206
69504
|
const minutes = Number(opts.minutes);
|
|
69207
69505
|
if (!Number.isInteger(minutes) || minutes <= 0) {
|
|
69208
|
-
|
|
69506
|
+
fail3(`--minutes must be a positive integer, got "${opts.minutes}".`, opts.json);
|
|
69209
69507
|
}
|
|
69210
69508
|
const owner = await loadOrCreateTradeKey();
|
|
69211
69509
|
if (owner.created && !opts.json) {
|
|
69212
|
-
process.stderr.write(
|
|
69510
|
+
process.stderr.write(import_picocolors31.default.dim(`Generated the agent trading key ${owner.state.address} (${tradeKeyPath()}).
|
|
69213
69511
|
`));
|
|
69214
69512
|
}
|
|
69215
69513
|
const session = await loadOrCreateDeskSessionKey();
|
|
69216
69514
|
if (session.created && !opts.json) {
|
|
69217
69515
|
process.stderr.write(
|
|
69218
|
-
|
|
69516
|
+
import_picocolors31.default.dim(`Generated the desk session key ${session.state.address} (${deskSessionKeyPath()}).
|
|
69219
69517
|
`)
|
|
69220
69518
|
);
|
|
69221
69519
|
}
|
|
@@ -69289,7 +69587,7 @@ async function deskSessionRevoke(opts) {
|
|
|
69289
69587
|
async function requireSessionKeypair(opts) {
|
|
69290
69588
|
const session = await loadDeskSessionKey();
|
|
69291
69589
|
if (!session) {
|
|
69292
|
-
|
|
69590
|
+
fail3(
|
|
69293
69591
|
"No desk session key on this terminal. Register one: agentgates desk session register --cap <usdc> --minutes <n>",
|
|
69294
69592
|
opts.json
|
|
69295
69593
|
);
|
|
@@ -69333,12 +69631,12 @@ async function deskBuy(coinArg, amount, opts) {
|
|
|
69333
69631
|
try {
|
|
69334
69632
|
units = parseDecimalToUnits(amount, USDC_DECIMALS, "Buy amount");
|
|
69335
69633
|
} catch (err) {
|
|
69336
|
-
|
|
69634
|
+
fail3(err.message, opts.json);
|
|
69337
69635
|
}
|
|
69338
|
-
if (units <= 0n)
|
|
69636
|
+
if (units <= 0n) fail3("Buy amount must be above zero.", opts.json);
|
|
69339
69637
|
const floor = servedFloorUnits2(ctx2);
|
|
69340
69638
|
if (floor && units < floor.units) {
|
|
69341
|
-
|
|
69639
|
+
fail3(`Buys start at $${floor.usdc} (served by launch-config; the relay refuses below it).`, opts.json);
|
|
69342
69640
|
}
|
|
69343
69641
|
const owner = await requireOwner(opts);
|
|
69344
69642
|
const session = await requireSessionKeypair(opts);
|
|
@@ -69363,16 +69661,16 @@ async function deskSell(coinArg, amount, opts) {
|
|
|
69363
69661
|
const pct = sellAmount.match(/^(\d+)%$/);
|
|
69364
69662
|
if (pct) {
|
|
69365
69663
|
const state = await deskState(owner.state.address, coin.mint);
|
|
69366
|
-
if (!state.coin)
|
|
69664
|
+
if (!state.coin) fail3("The desk holds none of that coin for this owner.", opts.json);
|
|
69367
69665
|
const credit = BigInt(state.coin.creditUnits);
|
|
69368
|
-
if (credit <= 0n)
|
|
69666
|
+
if (credit <= 0n) fail3("The desk holds none of that coin for this owner.", opts.json);
|
|
69369
69667
|
const p = BigInt(pct[1]);
|
|
69370
|
-
if (p <= 0n || p > 100n)
|
|
69668
|
+
if (p <= 0n || p > 100n) fail3(`Percentage must be 1-100, got "${amount}".`, opts.json);
|
|
69371
69669
|
const units = credit * p / 100n;
|
|
69372
|
-
if (units <= 0n)
|
|
69670
|
+
if (units <= 0n) fail3("Sell amount rounds to zero.", opts.json);
|
|
69373
69671
|
sellAmount = formatUnits2(units, state.coin.decimals);
|
|
69374
69672
|
} else if (sellAmount !== "all" && !/^\d+(\.\d+)?$/.test(sellAmount)) {
|
|
69375
|
-
|
|
69673
|
+
fail3(`Sell amount "${amount}" is not a coin amount, a percentage like 50%, or "all".`, opts.json);
|
|
69376
69674
|
}
|
|
69377
69675
|
const result = await runDeskTrade({
|
|
69378
69676
|
ctx: ctx2,
|
|
@@ -69757,7 +70055,7 @@ program2.command("fund").description(
|
|
|
69757
70055
|
}
|
|
69758
70056
|
if (opts.usdc || opts.gas || opts.chain) {
|
|
69759
70057
|
process.stderr.write(
|
|
69760
|
-
|
|
70058
|
+
import_picocolors32.default.red(
|
|
69761
70059
|
`\u2715 --usdc/--gas/--chain go with an ADDRESS target (0x\u2026 or Solana base58); "${target}" reads as a bounty id.
|
|
69762
70060
|
`
|
|
69763
70061
|
)
|
|
@@ -69960,6 +70258,19 @@ program2.command("init").description(
|
|
|
69960
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) => {
|
|
69961
70259
|
await passwordsInit(opts);
|
|
69962
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
|
+
});
|
|
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) => {
|
|
70272
|
+
await update(opts);
|
|
70273
|
+
});
|
|
69963
70274
|
program2.command("open").description(
|
|
69964
70275
|
"Hand this session to a human: opens agentgates.ai in the browser already logged in as this key's account. The words travel once over 127.0.0.1 with a one-time token; never a server, never a URL, never a page that stays."
|
|
69965
70276
|
).option("--wait <seconds>", "how long the link stays alive (300)").option("--no-browser", "print the link instead of opening it").option("--print-url", "print the link as well as opening it").option("--json", "machine-readable output (default when stdout is not a TTY)").action(async (opts) => {
|
|
@@ -69974,10 +70285,10 @@ browser.command("balance").description("The prepaid balance every step draws fro
|
|
|
69974
70285
|
await browserBalance(opts);
|
|
69975
70286
|
});
|
|
69976
70287
|
program2.parseAsync(process.argv).catch((err) => {
|
|
69977
|
-
process.stderr.write(
|
|
70288
|
+
process.stderr.write(import_picocolors32.default.red(`\u2715 ${err.message}
|
|
69978
70289
|
`));
|
|
69979
70290
|
if (process.env.BOUNTY_DEBUG) {
|
|
69980
|
-
process.stderr.write(
|
|
70291
|
+
process.stderr.write(import_picocolors32.default.dim((err.stack ?? "") + "\n"));
|
|
69981
70292
|
}
|
|
69982
70293
|
process.exit(1);
|
|
69983
70294
|
});
|