@heyamiko/amiko-cli 0.5.10 → 0.5.11
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/index.js +165 -159
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23856,7 +23856,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
23856
23856
|
let accum = [];
|
|
23857
23857
|
let accumBytes = 0;
|
|
23858
23858
|
let abort = false;
|
|
23859
|
-
return new Body.Promise(function(
|
|
23859
|
+
return new Body.Promise(function(resolve2, reject) {
|
|
23860
23860
|
let resTimeout;
|
|
23861
23861
|
if (_this4.timeout) {
|
|
23862
23862
|
resTimeout = setTimeout(function() {
|
|
@@ -23890,7 +23890,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
23890
23890
|
}
|
|
23891
23891
|
clearTimeout(resTimeout);
|
|
23892
23892
|
try {
|
|
23893
|
-
|
|
23893
|
+
resolve2(Buffer.concat(accum, accumBytes));
|
|
23894
23894
|
} catch (err) {
|
|
23895
23895
|
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
23896
23896
|
}
|
|
@@ -24489,7 +24489,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
24489
24489
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
24490
24490
|
}
|
|
24491
24491
|
Body.Promise = fetch2.Promise;
|
|
24492
|
-
return new fetch2.Promise(function(
|
|
24492
|
+
return new fetch2.Promise(function(resolve2, reject) {
|
|
24493
24493
|
const request = new Request2(url, opts);
|
|
24494
24494
|
const options = getNodeRequestOptions(request);
|
|
24495
24495
|
const send = (options.protocol === "https:" ? https : http).request;
|
|
@@ -24624,7 +24624,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
24624
24624
|
requestOpts.body = undefined;
|
|
24625
24625
|
requestOpts.headers.delete("content-length");
|
|
24626
24626
|
}
|
|
24627
|
-
|
|
24627
|
+
resolve2(fetch2(new Request2(locationURL, requestOpts)));
|
|
24628
24628
|
finalize();
|
|
24629
24629
|
return;
|
|
24630
24630
|
}
|
|
@@ -24646,7 +24646,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
24646
24646
|
const codings = headers.get("Content-Encoding");
|
|
24647
24647
|
if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
24648
24648
|
response = new Response(body, response_options);
|
|
24649
|
-
|
|
24649
|
+
resolve2(response);
|
|
24650
24650
|
return;
|
|
24651
24651
|
}
|
|
24652
24652
|
const zlibOptions = {
|
|
@@ -24656,7 +24656,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
24656
24656
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
24657
24657
|
body = body.pipe(zlib.createGunzip(zlibOptions));
|
|
24658
24658
|
response = new Response(body, response_options);
|
|
24659
|
-
|
|
24659
|
+
resolve2(response);
|
|
24660
24660
|
return;
|
|
24661
24661
|
}
|
|
24662
24662
|
if (codings == "deflate" || codings == "x-deflate") {
|
|
@@ -24668,12 +24668,12 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
24668
24668
|
body = body.pipe(zlib.createInflateRaw());
|
|
24669
24669
|
}
|
|
24670
24670
|
response = new Response(body, response_options);
|
|
24671
|
-
|
|
24671
|
+
resolve2(response);
|
|
24672
24672
|
});
|
|
24673
24673
|
raw.on("end", function() {
|
|
24674
24674
|
if (!response) {
|
|
24675
24675
|
response = new Response(body, response_options);
|
|
24676
|
-
|
|
24676
|
+
resolve2(response);
|
|
24677
24677
|
}
|
|
24678
24678
|
});
|
|
24679
24679
|
return;
|
|
@@ -24681,11 +24681,11 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
24681
24681
|
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
|
|
24682
24682
|
body = body.pipe(zlib.createBrotliDecompress());
|
|
24683
24683
|
response = new Response(body, response_options);
|
|
24684
|
-
|
|
24684
|
+
resolve2(response);
|
|
24685
24685
|
return;
|
|
24686
24686
|
}
|
|
24687
24687
|
response = new Response(body, response_options);
|
|
24688
|
-
|
|
24688
|
+
resolve2(response);
|
|
24689
24689
|
});
|
|
24690
24690
|
writeToStream(req, request);
|
|
24691
24691
|
});
|
|
@@ -24785,10 +24785,10 @@ var require_node_gyp_build = __commonJS((exports, module) => {
|
|
|
24785
24785
|
if (debug)
|
|
24786
24786
|
return debug;
|
|
24787
24787
|
}
|
|
24788
|
-
var prebuild =
|
|
24788
|
+
var prebuild = resolve2(dir);
|
|
24789
24789
|
if (prebuild)
|
|
24790
24790
|
return prebuild;
|
|
24791
|
-
var nearby =
|
|
24791
|
+
var nearby = resolve2(path.dirname(process.execPath));
|
|
24792
24792
|
if (nearby)
|
|
24793
24793
|
return nearby;
|
|
24794
24794
|
var target = [
|
|
@@ -24806,7 +24806,7 @@ var require_node_gyp_build = __commonJS((exports, module) => {
|
|
|
24806
24806
|
throw new Error("No native build was found for " + target + `
|
|
24807
24807
|
loaded from: ` + dir + `
|
|
24808
24808
|
`);
|
|
24809
|
-
function
|
|
24809
|
+
function resolve2(dir2) {
|
|
24810
24810
|
var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
24811
24811
|
var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
|
|
24812
24812
|
if (!tuple)
|
|
@@ -28659,7 +28659,7 @@ var require_dist3 = __commonJS((exports) => {
|
|
|
28659
28659
|
ws_opts = timeout;
|
|
28660
28660
|
timeout = null;
|
|
28661
28661
|
}
|
|
28662
|
-
return new Promise((
|
|
28662
|
+
return new Promise((resolve2, reject) => {
|
|
28663
28663
|
if (!this.ready)
|
|
28664
28664
|
return reject(new Error("socket not ready"));
|
|
28665
28665
|
const rpc_id = this.generate_request_id(method, params);
|
|
@@ -28672,7 +28672,7 @@ var require_dist3 = __commonJS((exports) => {
|
|
|
28672
28672
|
this.socket.send(this.dataPack.encode(message), ws_opts, (error3) => {
|
|
28673
28673
|
if (error3)
|
|
28674
28674
|
return reject(error3);
|
|
28675
|
-
this.queue[rpc_id] = { promise: [
|
|
28675
|
+
this.queue[rpc_id] = { promise: [resolve2, reject] };
|
|
28676
28676
|
if (timeout) {
|
|
28677
28677
|
this.queue[rpc_id].timeout = setTimeout(() => {
|
|
28678
28678
|
delete this.queue[rpc_id];
|
|
@@ -28692,7 +28692,7 @@ var require_dist3 = __commonJS((exports) => {
|
|
|
28692
28692
|
return await this.call("__listMethods");
|
|
28693
28693
|
}
|
|
28694
28694
|
notify(method, params) {
|
|
28695
|
-
return new Promise((
|
|
28695
|
+
return new Promise((resolve2, reject) => {
|
|
28696
28696
|
if (!this.ready)
|
|
28697
28697
|
return reject(new Error("socket not ready"));
|
|
28698
28698
|
const message = {
|
|
@@ -28703,7 +28703,7 @@ var require_dist3 = __commonJS((exports) => {
|
|
|
28703
28703
|
this.socket.send(this.dataPack.encode(message), (error3) => {
|
|
28704
28704
|
if (error3)
|
|
28705
28705
|
return reject(error3);
|
|
28706
|
-
|
|
28706
|
+
resolve2();
|
|
28707
28707
|
});
|
|
28708
28708
|
});
|
|
28709
28709
|
}
|
|
@@ -28983,11 +28983,11 @@ var require_dist3 = __commonJS((exports) => {
|
|
|
28983
28983
|
};
|
|
28984
28984
|
}
|
|
28985
28985
|
close() {
|
|
28986
|
-
return new Promise((
|
|
28986
|
+
return new Promise((resolve2, reject) => {
|
|
28987
28987
|
try {
|
|
28988
28988
|
this.wss.close();
|
|
28989
28989
|
this.emit("close");
|
|
28990
|
-
|
|
28990
|
+
resolve2();
|
|
28991
28991
|
} catch (error3) {
|
|
28992
28992
|
reject(error3);
|
|
28993
28993
|
}
|
|
@@ -32013,7 +32013,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
32013
32013
|
return signature2;
|
|
32014
32014
|
}
|
|
32015
32015
|
function sleep(ms) {
|
|
32016
|
-
return new Promise((
|
|
32016
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
32017
32017
|
}
|
|
32018
32018
|
function encodeData2(type, fields) {
|
|
32019
32019
|
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
@@ -32468,7 +32468,7 @@ class Loader {
|
|
|
32468
32468
|
break;
|
|
32469
32469
|
}
|
|
32470
32470
|
} catch {}
|
|
32471
|
-
await new Promise((
|
|
32471
|
+
await new Promise((resolve2) => setTimeout(resolve2, Math.round(MS_PER_SLOT / 2)));
|
|
32472
32472
|
}
|
|
32473
32473
|
}
|
|
32474
32474
|
return true;
|
|
@@ -33759,12 +33759,12 @@ Message: ${transactionMessage}.
|
|
|
33759
33759
|
}
|
|
33760
33760
|
async getLogs(connection) {
|
|
33761
33761
|
if (!Array.isArray(this.transactionLogs)) {
|
|
33762
|
-
this.transactionLogs = new Promise((
|
|
33762
|
+
this.transactionLogs = new Promise((resolve2, reject) => {
|
|
33763
33763
|
connection.getTransaction(this.signature).then((tx) => {
|
|
33764
33764
|
if (tx && tx.meta && tx.meta.logMessages) {
|
|
33765
33765
|
const logs = tx.meta.logMessages;
|
|
33766
33766
|
this.transactionLogs = logs;
|
|
33767
|
-
|
|
33767
|
+
resolve2(logs);
|
|
33768
33768
|
} else {
|
|
33769
33769
|
reject(new Error("Log messages not found"));
|
|
33770
33770
|
}
|
|
@@ -44827,17 +44827,17 @@ var init_transport = __esm(() => {
|
|
|
44827
44827
|
|
|
44828
44828
|
// node_modules/viem/_esm/utils/promise/withResolvers.js
|
|
44829
44829
|
function withResolvers() {
|
|
44830
|
-
let
|
|
44830
|
+
let resolve2 = () => {
|
|
44831
44831
|
return;
|
|
44832
44832
|
};
|
|
44833
44833
|
let reject = () => {
|
|
44834
44834
|
return;
|
|
44835
44835
|
};
|
|
44836
44836
|
const promise = new Promise((resolve_, reject_) => {
|
|
44837
|
-
|
|
44837
|
+
resolve2 = resolve_;
|
|
44838
44838
|
reject = reject_;
|
|
44839
44839
|
});
|
|
44840
|
-
return { promise, resolve, reject };
|
|
44840
|
+
return { promise, resolve: resolve2, reject };
|
|
44841
44841
|
}
|
|
44842
44842
|
|
|
44843
44843
|
// node_modules/viem/_esm/utils/promise/createBatchScheduler.js
|
|
@@ -44852,8 +44852,8 @@ function createBatchScheduler({ fn, id, shouldSplitBatch, wait = 0, sort }) {
|
|
|
44852
44852
|
if (sort && Array.isArray(data))
|
|
44853
44853
|
data.sort(sort);
|
|
44854
44854
|
for (let i15 = 0;i15 < scheduler.length; i15++) {
|
|
44855
|
-
const { resolve } = scheduler[i15];
|
|
44856
|
-
|
|
44855
|
+
const { resolve: resolve2 } = scheduler[i15];
|
|
44856
|
+
resolve2?.([data[i15], data]);
|
|
44857
44857
|
}
|
|
44858
44858
|
}).catch((err) => {
|
|
44859
44859
|
for (let i15 = 0;i15 < scheduler.length; i15++) {
|
|
@@ -44869,16 +44869,16 @@ function createBatchScheduler({ fn, id, shouldSplitBatch, wait = 0, sort }) {
|
|
|
44869
44869
|
return {
|
|
44870
44870
|
flush,
|
|
44871
44871
|
async schedule(args) {
|
|
44872
|
-
const { promise, resolve, reject } = withResolvers();
|
|
44872
|
+
const { promise, resolve: resolve2, reject } = withResolvers();
|
|
44873
44873
|
const split2 = shouldSplitBatch?.([...getBatchedArgs(), args]);
|
|
44874
44874
|
if (split2)
|
|
44875
44875
|
exec();
|
|
44876
44876
|
const hasActiveScheduler = getScheduler().length > 0;
|
|
44877
44877
|
if (hasActiveScheduler) {
|
|
44878
|
-
setScheduler({ args, resolve, reject });
|
|
44878
|
+
setScheduler({ args, resolve: resolve2, reject });
|
|
44879
44879
|
return promise;
|
|
44880
44880
|
}
|
|
44881
|
-
setScheduler({ args, resolve, reject });
|
|
44881
|
+
setScheduler({ args, resolve: resolve2, reject });
|
|
44882
44882
|
setTimeout(exec, wait);
|
|
44883
44883
|
return promise;
|
|
44884
44884
|
}
|
|
@@ -44891,7 +44891,7 @@ var init_createBatchScheduler = __esm(() => {
|
|
|
44891
44891
|
|
|
44892
44892
|
// node_modules/viem/_esm/utils/promise/withTimeout.js
|
|
44893
44893
|
function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, signal }) {
|
|
44894
|
-
return new Promise((
|
|
44894
|
+
return new Promise((resolve2, reject) => {
|
|
44895
44895
|
(async () => {
|
|
44896
44896
|
let timeoutId;
|
|
44897
44897
|
try {
|
|
@@ -44905,7 +44905,7 @@ function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, sign
|
|
|
44905
44905
|
}
|
|
44906
44906
|
}, timeout);
|
|
44907
44907
|
}
|
|
44908
|
-
|
|
44908
|
+
resolve2(await fn({ signal: controller?.signal || null }));
|
|
44909
44909
|
} catch (err) {
|
|
44910
44910
|
if (err?.name === "AbortError")
|
|
44911
44911
|
reject(errorInstance);
|
|
@@ -45474,7 +45474,7 @@ async function wait(time) {
|
|
|
45474
45474
|
|
|
45475
45475
|
// node_modules/viem/_esm/utils/promise/withRetry.js
|
|
45476
45476
|
function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry = () => true } = {}) {
|
|
45477
|
-
return new Promise((
|
|
45477
|
+
return new Promise((resolve2, reject) => {
|
|
45478
45478
|
const attemptRetry = async ({ count = 0 } = {}) => {
|
|
45479
45479
|
const retry = async ({ error: error3 }) => {
|
|
45480
45480
|
const delay = typeof delay_ === "function" ? delay_({ count, error: error3 }) : delay_;
|
|
@@ -45484,7 +45484,7 @@ function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry = () =
|
|
|
45484
45484
|
};
|
|
45485
45485
|
try {
|
|
45486
45486
|
const data = await fn();
|
|
45487
|
-
|
|
45487
|
+
resolve2(data);
|
|
45488
45488
|
} catch (err) {
|
|
45489
45489
|
if (count < retryCount && await shouldRetry({ count, error: err }))
|
|
45490
45490
|
return retry({ error: err });
|
|
@@ -49414,13 +49414,13 @@ async function isImageUri(uri) {
|
|
|
49414
49414
|
}
|
|
49415
49415
|
if (!globalThis.hasOwnProperty("Image"))
|
|
49416
49416
|
return false;
|
|
49417
|
-
return new Promise((
|
|
49417
|
+
return new Promise((resolve2) => {
|
|
49418
49418
|
const img = new Image;
|
|
49419
49419
|
img.onload = () => {
|
|
49420
|
-
|
|
49420
|
+
resolve2(true);
|
|
49421
49421
|
};
|
|
49422
49422
|
img.onerror = () => {
|
|
49423
|
-
|
|
49423
|
+
resolve2(false);
|
|
49424
49424
|
};
|
|
49425
49425
|
img.src = uri;
|
|
49426
49426
|
});
|
|
@@ -53917,13 +53917,13 @@ async function waitForTransactionReceipt(client, parameters) {
|
|
|
53917
53917
|
let retrying = false;
|
|
53918
53918
|
let _unobserve;
|
|
53919
53919
|
let _unwatch;
|
|
53920
|
-
const { promise, resolve, reject } = withResolvers();
|
|
53920
|
+
const { promise, resolve: resolve2, reject } = withResolvers();
|
|
53921
53921
|
const timer = timeout ? setTimeout(() => {
|
|
53922
53922
|
_unwatch();
|
|
53923
53923
|
_unobserve();
|
|
53924
53924
|
reject(new WaitForTransactionReceiptTimeoutError({ hash: hash2 }));
|
|
53925
53925
|
}, timeout) : undefined;
|
|
53926
|
-
_unobserve = observe(observerId, { onReplaced, resolve, reject }, async (emit) => {
|
|
53926
|
+
_unobserve = observe(observerId, { onReplaced, resolve: resolve2, reject }, async (emit) => {
|
|
53927
53927
|
receipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: hash2 }).catch(() => {
|
|
53928
53928
|
return;
|
|
53929
53929
|
});
|
|
@@ -71823,6 +71823,115 @@ function normalizeConfig(config) {
|
|
|
71823
71823
|
return normalized;
|
|
71824
71824
|
}
|
|
71825
71825
|
|
|
71826
|
+
// src/lib/agent-config.ts
|
|
71827
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
71828
|
+
import { join as join2, resolve } from "node:path";
|
|
71829
|
+
function loadAgentConfig() {
|
|
71830
|
+
const knownPaths = [
|
|
71831
|
+
process.env.OPENCLAW_WORKSPACE_DIR ? join2(process.env.OPENCLAW_WORKSPACE_DIR, ".amiko.json") : "",
|
|
71832
|
+
process.env.OPENCLAW_HOME ? join2(process.env.OPENCLAW_HOME, ".openclaw", "workspace", ".amiko.json") : "",
|
|
71833
|
+
"/data/.openclaw/workspace/.amiko.json",
|
|
71834
|
+
"/data/.amiko.json"
|
|
71835
|
+
].filter(Boolean);
|
|
71836
|
+
for (const p of knownPaths) {
|
|
71837
|
+
const result = tryLoadConfig(p);
|
|
71838
|
+
if (result)
|
|
71839
|
+
return result;
|
|
71840
|
+
}
|
|
71841
|
+
let dir = process.cwd();
|
|
71842
|
+
const root = resolve("/");
|
|
71843
|
+
while (dir !== root) {
|
|
71844
|
+
const result = tryLoadConfig(join2(dir, ".amiko.json"));
|
|
71845
|
+
if (result)
|
|
71846
|
+
return result;
|
|
71847
|
+
dir = resolve(dir, "..");
|
|
71848
|
+
}
|
|
71849
|
+
return null;
|
|
71850
|
+
}
|
|
71851
|
+
function tryLoadConfig(filePath) {
|
|
71852
|
+
if (!existsSync2(filePath))
|
|
71853
|
+
return null;
|
|
71854
|
+
try {
|
|
71855
|
+
const raw = readFileSync2(filePath, "utf-8");
|
|
71856
|
+
const parsed = JSON.parse(raw);
|
|
71857
|
+
const config = {};
|
|
71858
|
+
config.twinToken = parsed.amikoTwinToken || parsed.AMIKO_TWIN_TOKEN || parsed.AMIKO_USER_TOKEN;
|
|
71859
|
+
config.twinId = parsed.amikoTwinId || parsed.AMIKO_TWIN_ID;
|
|
71860
|
+
config.userId = parsed.amikoUserId || parsed.AMIKO_USER_ID;
|
|
71861
|
+
config.platformUrl = parsed.amikoPlatformUrl || parsed.AMIKO_PLATFORM_URL;
|
|
71862
|
+
if (parsed.billingBase)
|
|
71863
|
+
config.billingBase = parsed.billingBase;
|
|
71864
|
+
if (parsed.platformKey)
|
|
71865
|
+
config.platformKey = parsed.platformKey;
|
|
71866
|
+
if (Array.isArray(parsed.agentWallets))
|
|
71867
|
+
config.agentWallets = parsed.agentWallets;
|
|
71868
|
+
return Object.keys(config).length > 0 ? config : null;
|
|
71869
|
+
} catch {
|
|
71870
|
+
return null;
|
|
71871
|
+
}
|
|
71872
|
+
}
|
|
71873
|
+
function resolveAuth(cliConfig) {
|
|
71874
|
+
if (cliConfig.agentWallets?.length) {
|
|
71875
|
+
return {
|
|
71876
|
+
mode: "connected",
|
|
71877
|
+
platformUrl: cliConfig.platformUrl,
|
|
71878
|
+
billingBase: cliConfig.billingBase,
|
|
71879
|
+
twinId: cliConfig.twinId,
|
|
71880
|
+
twinToken: cliConfig.twinToken,
|
|
71881
|
+
platformKey: cliConfig.apiKey,
|
|
71882
|
+
privyToken: cliConfig.privyToken,
|
|
71883
|
+
connectedKeyId: cliConfig.connectedKeyId,
|
|
71884
|
+
userId: cliConfig.userId,
|
|
71885
|
+
agentWallets: cliConfig.agentWallets
|
|
71886
|
+
};
|
|
71887
|
+
}
|
|
71888
|
+
if (cliConfig.privyToken && cliConfig.connectedKeyId) {
|
|
71889
|
+
return {
|
|
71890
|
+
mode: "connected",
|
|
71891
|
+
billingBase: cliConfig.billingBase,
|
|
71892
|
+
platformKey: cliConfig.privyToken,
|
|
71893
|
+
privyToken: cliConfig.privyToken,
|
|
71894
|
+
connectedKeyId: cliConfig.connectedKeyId,
|
|
71895
|
+
userId: cliConfig.userId
|
|
71896
|
+
};
|
|
71897
|
+
}
|
|
71898
|
+
if (cliConfig.apiKey) {
|
|
71899
|
+
return {
|
|
71900
|
+
mode: "connected",
|
|
71901
|
+
billingBase: cliConfig.billingBase,
|
|
71902
|
+
platformKey: cliConfig.apiKey,
|
|
71903
|
+
userId: cliConfig.userId,
|
|
71904
|
+
twinId: cliConfig.twinId,
|
|
71905
|
+
twinToken: cliConfig.twinToken
|
|
71906
|
+
};
|
|
71907
|
+
}
|
|
71908
|
+
const envToken = process.env.AMIKO_USER_TOKEN;
|
|
71909
|
+
if (envToken) {
|
|
71910
|
+
return {
|
|
71911
|
+
mode: "agent",
|
|
71912
|
+
twinId: process.env.AMIKO_TWIN_ID,
|
|
71913
|
+
twinToken: envToken,
|
|
71914
|
+
userId: process.env.AMIKO_USER_ID,
|
|
71915
|
+
billingBase: process.env.API_SERVICE_URL || process.env.BILLING_BASE,
|
|
71916
|
+
platformUrl: process.env.AMIKO_PLATFORM_URL
|
|
71917
|
+
};
|
|
71918
|
+
}
|
|
71919
|
+
const agentConfig = loadAgentConfig();
|
|
71920
|
+
if (agentConfig?.twinToken) {
|
|
71921
|
+
return {
|
|
71922
|
+
mode: "agent",
|
|
71923
|
+
platformUrl: agentConfig.platformUrl,
|
|
71924
|
+
billingBase: agentConfig.billingBase,
|
|
71925
|
+
twinId: agentConfig.twinId,
|
|
71926
|
+
twinToken: agentConfig.twinToken,
|
|
71927
|
+
platformKey: agentConfig.platformKey,
|
|
71928
|
+
userId: agentConfig.userId,
|
|
71929
|
+
agentWallets: agentConfig.agentWallets
|
|
71930
|
+
};
|
|
71931
|
+
}
|
|
71932
|
+
return { mode: "none" };
|
|
71933
|
+
}
|
|
71934
|
+
|
|
71826
71935
|
// src/lib/format.ts
|
|
71827
71936
|
function table(rows) {
|
|
71828
71937
|
if (rows.length === 0)
|
|
@@ -71883,14 +71992,19 @@ var SKIP_COMMANDS = new Set([
|
|
|
71883
71992
|
"whoami",
|
|
71884
71993
|
"connect",
|
|
71885
71994
|
"credits",
|
|
71995
|
+
"swap",
|
|
71996
|
+
"wallet",
|
|
71997
|
+
"bridge",
|
|
71998
|
+
"browse",
|
|
71999
|
+
"call",
|
|
71886
72000
|
"update"
|
|
71887
72001
|
]);
|
|
71888
72002
|
function prompt(question) {
|
|
71889
72003
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
71890
|
-
return new Promise((
|
|
72004
|
+
return new Promise((resolve2) => {
|
|
71891
72005
|
rl.question(question, (answer) => {
|
|
71892
72006
|
rl.close();
|
|
71893
|
-
|
|
72007
|
+
resolve2(answer.trim());
|
|
71894
72008
|
});
|
|
71895
72009
|
});
|
|
71896
72010
|
}
|
|
@@ -71901,6 +72015,9 @@ async function runOnboarding(argv) {
|
|
|
71901
72015
|
const config = loadConfig();
|
|
71902
72016
|
if (config.wallet || config.privyToken || config.apiKey || config.twinToken || config.agentWallets?.length)
|
|
71903
72017
|
return false;
|
|
72018
|
+
const auth = resolveAuth(config);
|
|
72019
|
+
if (auth.mode !== "none")
|
|
72020
|
+
return false;
|
|
71904
72021
|
console.log("");
|
|
71905
72022
|
console.log(heading("Welcome to Amiko CLI"));
|
|
71906
72023
|
console.log(dim("The AI agent marketplace on Tempo"));
|
|
@@ -73080,10 +73197,10 @@ import { createInterface as createInterface2 } from "node:readline";
|
|
|
73080
73197
|
|
|
73081
73198
|
// src/lib/tempo.ts
|
|
73082
73199
|
import { execFile, execFileSync as execFileSync2 } from "node:child_process";
|
|
73083
|
-
import { existsSync as
|
|
73200
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
73084
73201
|
import { homedir as homedir2 } from "node:os";
|
|
73085
|
-
import { join as
|
|
73086
|
-
var TEMPO_PATHS = [
|
|
73202
|
+
import { join as join3 } from "node:path";
|
|
73203
|
+
var TEMPO_PATHS = [join3(homedir2(), ".tempo", "bin", "tempo"), "tempo"];
|
|
73087
73204
|
function findTempo() {
|
|
73088
73205
|
for (const p of TEMPO_PATHS) {
|
|
73089
73206
|
if (p === "tempo") {
|
|
@@ -73093,7 +73210,7 @@ function findTempo() {
|
|
|
73093
73210
|
} catch {
|
|
73094
73211
|
continue;
|
|
73095
73212
|
}
|
|
73096
|
-
} else if (
|
|
73213
|
+
} else if (existsSync3(p)) {
|
|
73097
73214
|
return p;
|
|
73098
73215
|
}
|
|
73099
73216
|
}
|
|
@@ -73106,14 +73223,14 @@ function runTempo(args, timeoutMs = 60000) {
|
|
|
73106
73223
|
const bin = findTempo();
|
|
73107
73224
|
if (!bin)
|
|
73108
73225
|
throw new Error("Tempo CLI not installed. Install: curl -fsSL https://tempo.xyz/install | bash");
|
|
73109
|
-
return new Promise((
|
|
73226
|
+
return new Promise((resolve2, reject) => {
|
|
73110
73227
|
execFile(bin, args, { timeout: timeoutMs, maxBuffer: 1024 * 1024 * 10 }, (err, stdout, stderr) => {
|
|
73111
73228
|
if (err) {
|
|
73112
73229
|
const msg = stderr?.trim() || stdout?.trim() || err.message;
|
|
73113
73230
|
reject(new Error(msg));
|
|
73114
73231
|
return;
|
|
73115
73232
|
}
|
|
73116
|
-
|
|
73233
|
+
resolve2(stdout.trim() || stderr.trim());
|
|
73117
73234
|
});
|
|
73118
73235
|
});
|
|
73119
73236
|
}
|
|
@@ -74135,117 +74252,6 @@ function registerMarketplaceCommand(program2) {
|
|
|
74135
74252
|
import { createServer } from "node:http";
|
|
74136
74253
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
74137
74254
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
74138
|
-
|
|
74139
|
-
// src/lib/agent-config.ts
|
|
74140
|
-
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "node:fs";
|
|
74141
|
-
import { join as join3, resolve } from "node:path";
|
|
74142
|
-
function loadAgentConfig() {
|
|
74143
|
-
const knownPaths = [
|
|
74144
|
-
process.env.OPENCLAW_WORKSPACE_DIR ? join3(process.env.OPENCLAW_WORKSPACE_DIR, ".amiko.json") : "",
|
|
74145
|
-
process.env.OPENCLAW_HOME ? join3(process.env.OPENCLAW_HOME, ".openclaw", "workspace", ".amiko.json") : "",
|
|
74146
|
-
"/data/.openclaw/workspace/.amiko.json",
|
|
74147
|
-
"/data/.amiko.json"
|
|
74148
|
-
].filter(Boolean);
|
|
74149
|
-
for (const p13 of knownPaths) {
|
|
74150
|
-
const result = tryLoadConfig(p13);
|
|
74151
|
-
if (result)
|
|
74152
|
-
return result;
|
|
74153
|
-
}
|
|
74154
|
-
let dir = process.cwd();
|
|
74155
|
-
const root2 = resolve("/");
|
|
74156
|
-
while (dir !== root2) {
|
|
74157
|
-
const result = tryLoadConfig(join3(dir, ".amiko.json"));
|
|
74158
|
-
if (result)
|
|
74159
|
-
return result;
|
|
74160
|
-
dir = resolve(dir, "..");
|
|
74161
|
-
}
|
|
74162
|
-
return null;
|
|
74163
|
-
}
|
|
74164
|
-
function tryLoadConfig(filePath) {
|
|
74165
|
-
if (!existsSync3(filePath))
|
|
74166
|
-
return null;
|
|
74167
|
-
try {
|
|
74168
|
-
const raw = readFileSync2(filePath, "utf-8");
|
|
74169
|
-
const parsed = JSON.parse(raw);
|
|
74170
|
-
const config = {};
|
|
74171
|
-
config.twinToken = parsed.amikoTwinToken || parsed.AMIKO_TWIN_TOKEN || parsed.AMIKO_USER_TOKEN;
|
|
74172
|
-
config.twinId = parsed.amikoTwinId || parsed.AMIKO_TWIN_ID;
|
|
74173
|
-
config.userId = parsed.amikoUserId || parsed.AMIKO_USER_ID;
|
|
74174
|
-
config.platformUrl = parsed.amikoPlatformUrl || parsed.AMIKO_PLATFORM_URL;
|
|
74175
|
-
if (parsed.billingBase)
|
|
74176
|
-
config.billingBase = parsed.billingBase;
|
|
74177
|
-
if (parsed.platformKey)
|
|
74178
|
-
config.platformKey = parsed.platformKey;
|
|
74179
|
-
if (Array.isArray(parsed.agentWallets))
|
|
74180
|
-
config.agentWallets = parsed.agentWallets;
|
|
74181
|
-
return Object.keys(config).length > 0 ? config : null;
|
|
74182
|
-
} catch {
|
|
74183
|
-
return null;
|
|
74184
|
-
}
|
|
74185
|
-
}
|
|
74186
|
-
function resolveAuth(cliConfig) {
|
|
74187
|
-
if (cliConfig.agentWallets?.length) {
|
|
74188
|
-
return {
|
|
74189
|
-
mode: "connected",
|
|
74190
|
-
platformUrl: cliConfig.platformUrl,
|
|
74191
|
-
billingBase: cliConfig.billingBase,
|
|
74192
|
-
twinId: cliConfig.twinId,
|
|
74193
|
-
twinToken: cliConfig.twinToken,
|
|
74194
|
-
platformKey: cliConfig.apiKey,
|
|
74195
|
-
privyToken: cliConfig.privyToken,
|
|
74196
|
-
connectedKeyId: cliConfig.connectedKeyId,
|
|
74197
|
-
userId: cliConfig.userId,
|
|
74198
|
-
agentWallets: cliConfig.agentWallets
|
|
74199
|
-
};
|
|
74200
|
-
}
|
|
74201
|
-
if (cliConfig.privyToken && cliConfig.connectedKeyId) {
|
|
74202
|
-
return {
|
|
74203
|
-
mode: "connected",
|
|
74204
|
-
billingBase: cliConfig.billingBase,
|
|
74205
|
-
platformKey: cliConfig.privyToken,
|
|
74206
|
-
privyToken: cliConfig.privyToken,
|
|
74207
|
-
connectedKeyId: cliConfig.connectedKeyId,
|
|
74208
|
-
userId: cliConfig.userId
|
|
74209
|
-
};
|
|
74210
|
-
}
|
|
74211
|
-
if (cliConfig.apiKey) {
|
|
74212
|
-
return {
|
|
74213
|
-
mode: "connected",
|
|
74214
|
-
billingBase: cliConfig.billingBase,
|
|
74215
|
-
platformKey: cliConfig.apiKey,
|
|
74216
|
-
userId: cliConfig.userId,
|
|
74217
|
-
twinId: cliConfig.twinId,
|
|
74218
|
-
twinToken: cliConfig.twinToken
|
|
74219
|
-
};
|
|
74220
|
-
}
|
|
74221
|
-
const envToken = process.env.AMIKO_USER_TOKEN;
|
|
74222
|
-
if (envToken) {
|
|
74223
|
-
return {
|
|
74224
|
-
mode: "agent",
|
|
74225
|
-
twinId: process.env.AMIKO_TWIN_ID,
|
|
74226
|
-
twinToken: envToken,
|
|
74227
|
-
userId: process.env.AMIKO_USER_ID,
|
|
74228
|
-
billingBase: process.env.API_SERVICE_URL || process.env.BILLING_BASE,
|
|
74229
|
-
platformUrl: process.env.AMIKO_PLATFORM_URL
|
|
74230
|
-
};
|
|
74231
|
-
}
|
|
74232
|
-
const agentConfig = loadAgentConfig();
|
|
74233
|
-
if (agentConfig?.twinToken) {
|
|
74234
|
-
return {
|
|
74235
|
-
mode: "agent",
|
|
74236
|
-
platformUrl: agentConfig.platformUrl,
|
|
74237
|
-
billingBase: agentConfig.billingBase,
|
|
74238
|
-
twinId: agentConfig.twinId,
|
|
74239
|
-
twinToken: agentConfig.twinToken,
|
|
74240
|
-
platformKey: agentConfig.platformKey,
|
|
74241
|
-
userId: agentConfig.userId,
|
|
74242
|
-
agentWallets: agentConfig.agentWallets
|
|
74243
|
-
};
|
|
74244
|
-
}
|
|
74245
|
-
return { mode: "none" };
|
|
74246
|
-
}
|
|
74247
|
-
|
|
74248
|
-
// src/commands/login.ts
|
|
74249
74255
|
function buildVerifiedAuthConfig(token, bootstrap) {
|
|
74250
74256
|
return {
|
|
74251
74257
|
privyToken: token,
|