agent-operator 0.2.0 → 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.
Files changed (2) hide show
  1. package/dist/cli/init.js +95 -43
  2. 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
- const { name } = await prompts({
7
- type: "text",
8
- name: "name",
9
- message: "Wallet name",
10
- validate: (v) => (v.length > 0 ? true : "Name is required"),
11
- });
12
- if (!name)
13
- return null;
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,45 +191,12 @@ async function promptWallet() {
106
191
  secret: wh.secret || undefined,
107
192
  };
108
193
  }
109
- // try to create/find OWS wallet
110
- let walletId = "";
111
- try {
112
- const ows = await import("@open-wallet-standard/core");
113
- console.log(`\nChecking for OWS wallet "${name}"...`);
114
- try {
115
- const existing = ows.getWallet(name);
116
- walletId = existing.id;
117
- console.log(` → Found existing wallet: ${walletId}`);
118
- }
119
- catch {
120
- console.log(` → Not found. Creating wallet via OWS...`);
121
- const created = ows.createWallet(name);
122
- walletId = created.id;
123
- 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
- }
133
- }
134
- catch {
135
- console.log(`\n⚠️ OWS not available. Enter wallet ID manually.`);
136
- const { id } = await prompts({
137
- type: "text",
138
- name: "id",
139
- message: "OWS wallet ID",
140
- });
141
- walletId = id || "PLACEHOLDER";
142
- }
143
194
  return {
144
- name,
195
+ name: walletName,
145
196
  wallet: {
146
197
  walletId,
147
198
  chains,
199
+ network,
148
200
  policies: {
149
201
  dailyLimit: policies.dailyLimit,
150
202
  sessionCap: policies.sessionCap,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-operator",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Drop-in toolkit for governed, observable AI agent payments",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",