agent-operator 0.2.1 → 0.2.2
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/init.js +95 -54
- package/package.json +1 -1
package/dist/cli/init.js
CHANGED
|
@@ -3,14 +3,85 @@ import { writeFileSync, existsSync, readFileSync } from "node:fs";
|
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
const CONFIG_FILE = "agent-operator.json";
|
|
5
5
|
async function promptWallet() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
// 1. OWS wallet selection — first thing
|
|
7
|
+
let walletId = "";
|
|
8
|
+
let walletName = "";
|
|
9
|
+
try {
|
|
10
|
+
const ows = await import("@open-wallet-standard/core");
|
|
11
|
+
const existing = ows.listWallets();
|
|
12
|
+
if (existing.length > 0) {
|
|
13
|
+
const { walletChoice } = await prompts({
|
|
14
|
+
type: "select",
|
|
15
|
+
name: "walletChoice",
|
|
16
|
+
message: "Select OWS wallet",
|
|
17
|
+
choices: [
|
|
18
|
+
...existing.map((w) => ({
|
|
19
|
+
title: `${w.name} (${w.id.slice(0, 8)}...)`,
|
|
20
|
+
value: w.id,
|
|
21
|
+
})),
|
|
22
|
+
{ title: "Create new wallet", value: "__new__" },
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
if (walletChoice === undefined)
|
|
26
|
+
return null;
|
|
27
|
+
if (walletChoice !== "__new__") {
|
|
28
|
+
const picked = existing.find((w) => w.id === walletChoice);
|
|
29
|
+
walletId = picked.id;
|
|
30
|
+
walletName = picked.name;
|
|
31
|
+
console.log(` → Using wallet: ${walletName} (${walletId})`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const { name } = await prompts({
|
|
35
|
+
type: "text",
|
|
36
|
+
name: "name",
|
|
37
|
+
message: "New wallet name",
|
|
38
|
+
validate: (v) => (v.length > 0 ? true : "Name is required"),
|
|
39
|
+
});
|
|
40
|
+
if (!name)
|
|
41
|
+
return null;
|
|
42
|
+
const created = ows.createWallet(name);
|
|
43
|
+
walletId = created.id;
|
|
44
|
+
walletName = name;
|
|
45
|
+
console.log(` ✅ Wallet created: ${walletName} (${walletId})`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log("No OWS wallets found. Creating one...\n");
|
|
50
|
+
const { name } = await prompts({
|
|
51
|
+
type: "text",
|
|
52
|
+
name: "name",
|
|
53
|
+
message: "Wallet name",
|
|
54
|
+
validate: (v) => (v.length > 0 ? true : "Name is required"),
|
|
55
|
+
});
|
|
56
|
+
if (!name)
|
|
57
|
+
return null;
|
|
58
|
+
const created = ows.createWallet(name);
|
|
59
|
+
walletId = created.id;
|
|
60
|
+
walletName = name;
|
|
61
|
+
console.log(` ✅ Wallet created: ${walletName} (${walletId})`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
console.log("⚠️ OWS not available.\n");
|
|
66
|
+
const answers = await prompts([
|
|
67
|
+
{
|
|
68
|
+
type: "text",
|
|
69
|
+
name: "name",
|
|
70
|
+
message: "Wallet name",
|
|
71
|
+
validate: (v) => (v.length > 0 ? true : "Name is required"),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: "text",
|
|
75
|
+
name: "id",
|
|
76
|
+
message: "OWS wallet ID",
|
|
77
|
+
},
|
|
78
|
+
]);
|
|
79
|
+
if (!answers.name)
|
|
80
|
+
return null;
|
|
81
|
+
walletName = answers.name;
|
|
82
|
+
walletId = answers.id || "PLACEHOLDER";
|
|
83
|
+
}
|
|
84
|
+
// 2. Chain selection
|
|
14
85
|
const { chains } = await prompts({
|
|
15
86
|
type: "multiselect",
|
|
16
87
|
name: "chains",
|
|
@@ -24,6 +95,19 @@ async function promptWallet() {
|
|
|
24
95
|
});
|
|
25
96
|
if (!chains || chains.length === 0)
|
|
26
97
|
return null;
|
|
98
|
+
// 3. Network
|
|
99
|
+
const { network } = await prompts({
|
|
100
|
+
type: "select",
|
|
101
|
+
name: "network",
|
|
102
|
+
message: "Network",
|
|
103
|
+
choices: [
|
|
104
|
+
{ title: "Mainnet", value: "mainnet" },
|
|
105
|
+
{ title: "Testnet", value: "testnet" },
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
if (network === undefined)
|
|
109
|
+
return null;
|
|
110
|
+
// 4. Policies
|
|
27
111
|
const policies = await prompts([
|
|
28
112
|
{
|
|
29
113
|
type: "number",
|
|
@@ -56,6 +140,7 @@ async function promptWallet() {
|
|
|
56
140
|
initial: 200,
|
|
57
141
|
},
|
|
58
142
|
]);
|
|
143
|
+
// 5. Notifications
|
|
59
144
|
const { provider } = await prompts({
|
|
60
145
|
type: "select",
|
|
61
146
|
name: "provider",
|
|
@@ -106,56 +191,12 @@ async function promptWallet() {
|
|
|
106
191
|
secret: wh.secret || undefined,
|
|
107
192
|
};
|
|
108
193
|
}
|
|
109
|
-
// try to find or create OWS wallet
|
|
110
|
-
let walletId = "";
|
|
111
|
-
try {
|
|
112
|
-
const ows = await import("@open-wallet-standard/core");
|
|
113
|
-
const existing = ows.listWallets();
|
|
114
|
-
if (existing.length > 0) {
|
|
115
|
-
const { walletChoice } = await prompts({
|
|
116
|
-
type: "select",
|
|
117
|
-
name: "walletChoice",
|
|
118
|
-
message: "OWS wallet",
|
|
119
|
-
choices: [
|
|
120
|
-
...existing.map((w) => ({
|
|
121
|
-
title: `${w.name} (${w.id.slice(0, 8)}...)`,
|
|
122
|
-
value: w.id,
|
|
123
|
-
})),
|
|
124
|
-
{ title: "Create new wallet", value: "__new__" },
|
|
125
|
-
],
|
|
126
|
-
});
|
|
127
|
-
if (walletChoice && walletChoice !== "__new__") {
|
|
128
|
-
walletId = walletChoice;
|
|
129
|
-
const picked = existing.find((w) => w.id === walletChoice);
|
|
130
|
-
console.log(` → Using wallet: ${picked?.name} (${walletId})`);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
const created = ows.createWallet(name);
|
|
134
|
-
walletId = created.id;
|
|
135
|
-
console.log(` ✅ Wallet created: ${name} (id: ${walletId})`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
console.log(`\nNo OWS wallets found. Creating one...`);
|
|
140
|
-
const created = ows.createWallet(name);
|
|
141
|
-
walletId = created.id;
|
|
142
|
-
console.log(` ✅ Wallet created: ${name} (id: ${walletId})`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
console.log(`\n⚠️ OWS not available. Enter wallet ID manually.`);
|
|
147
|
-
const { id } = await prompts({
|
|
148
|
-
type: "text",
|
|
149
|
-
name: "id",
|
|
150
|
-
message: "OWS wallet ID",
|
|
151
|
-
});
|
|
152
|
-
walletId = id || "PLACEHOLDER";
|
|
153
|
-
}
|
|
154
194
|
return {
|
|
155
|
-
name,
|
|
195
|
+
name: walletName,
|
|
156
196
|
wallet: {
|
|
157
197
|
walletId,
|
|
158
198
|
chains,
|
|
199
|
+
network,
|
|
159
200
|
policies: {
|
|
160
201
|
dailyLimit: policies.dailyLimit,
|
|
161
202
|
sessionCap: policies.sessionCap,
|