agent-operator 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/init.js +27 -16
- package/package.json +1 -1
package/dist/cli/init.js
CHANGED
|
@@ -106,29 +106,40 @@ async function promptWallet() {
|
|
|
106
106
|
secret: wh.secret || undefined,
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
// try to
|
|
109
|
+
// try to find or create OWS wallet
|
|
110
110
|
let walletId = "";
|
|
111
111
|
try {
|
|
112
112
|
const ows = await import("@open-wallet-standard/core");
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
}
|
|
118
137
|
}
|
|
119
|
-
|
|
120
|
-
console.log(
|
|
138
|
+
else {
|
|
139
|
+
console.log(`\nNo OWS wallets found. Creating one...`);
|
|
121
140
|
const created = ows.createWallet(name);
|
|
122
141
|
walletId = created.id;
|
|
123
142
|
console.log(` ✅ Wallet created: ${name} (id: ${walletId})`);
|
|
124
|
-
// generate API key
|
|
125
|
-
try {
|
|
126
|
-
const apiKey = ows.createApiKey(name, [walletId], [], "");
|
|
127
|
-
console.log(` ✅ API key generated: ${apiKey.id}`);
|
|
128
|
-
}
|
|
129
|
-
catch {
|
|
130
|
-
console.log(` ⚠️ Could not generate API key — set up manually`);
|
|
131
|
-
}
|
|
132
143
|
}
|
|
133
144
|
}
|
|
134
145
|
catch {
|