clawmoney 0.15.21 → 0.15.23
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/commands/relay-setup.js +29 -39
- package/package.json +1 -1
|
@@ -5,7 +5,8 @@ import { join } from "node:path";
|
|
|
5
5
|
import { intro, outro, multiselect, confirm, select, spinner, isCancel, cancel, log, } from "@clack/prompts";
|
|
6
6
|
import chalk from "chalk";
|
|
7
7
|
import { apiPost } from "../utils/api.js";
|
|
8
|
-
import { requireConfig } from "../utils/config.js";
|
|
8
|
+
import { loadConfig, requireConfig } from "../utils/config.js";
|
|
9
|
+
import { setupCommand } from "./setup.js";
|
|
9
10
|
import { API_PRICES, RELAY_DISCOUNT, PLATFORM_FEE } from "../relay/pricing.js";
|
|
10
11
|
// ── Per-cli_type model catalogs ──
|
|
11
12
|
//
|
|
@@ -119,9 +120,6 @@ function detectInstalledClis() {
|
|
|
119
120
|
return results;
|
|
120
121
|
}
|
|
121
122
|
// ── Helpers ──
|
|
122
|
-
function formatPrice(input, output) {
|
|
123
|
-
return `$${input}/$${output} per 1M`;
|
|
124
|
-
}
|
|
125
123
|
function formatBuyerPrice(input, output) {
|
|
126
124
|
const buyerInput = (input * RELAY_DISCOUNT).toFixed(3);
|
|
127
125
|
const buyerOutput = (output * RELAY_DISCOUNT).toFixed(3);
|
|
@@ -129,6 +127,27 @@ function formatBuyerPrice(input, output) {
|
|
|
129
127
|
}
|
|
130
128
|
// ── Main command ──
|
|
131
129
|
export async function relaySetupCommand() {
|
|
130
|
+
// ── Step 0: ensure the agent is logged in ──
|
|
131
|
+
//
|
|
132
|
+
// Relay setup relies on an ACTIVE ClawMoney agent (api_key + agent_id
|
|
133
|
+
// in ~/.clawmoney/config.yaml) to register provider rows and to auth
|
|
134
|
+
// the daemon's WS connection. If the user runs `clawmoney relay setup`
|
|
135
|
+
// before ever running `clawmoney setup`, we inline the login flow
|
|
136
|
+
// here instead of throwing a raw "No config found" error. The nested
|
|
137
|
+
// setupCommand uses its own ora/prompt UI — visually different from
|
|
138
|
+
// the clack wizard below, but that's acceptable since it only runs on
|
|
139
|
+
// the first-time-user path.
|
|
140
|
+
let existing = loadConfig();
|
|
141
|
+
if (!existing) {
|
|
142
|
+
console.log(chalk.yellow("\n You're not logged in yet — running `clawmoney setup` first.\n"));
|
|
143
|
+
await setupCommand();
|
|
144
|
+
existing = loadConfig();
|
|
145
|
+
if (!existing) {
|
|
146
|
+
console.log(chalk.red("\n Login did not complete. Run `clawmoney setup` manually, then re-run `clawmoney relay setup`.\n"));
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
console.log("");
|
|
150
|
+
}
|
|
132
151
|
const config = requireConfig();
|
|
133
152
|
intro(chalk.cyan(" ClawMoney Relay Setup "));
|
|
134
153
|
log.message("Sell your spare Claude Max / ChatGPT Pro / Google subscription capacity to other AI agents.");
|
|
@@ -173,44 +192,15 @@ export async function relaySetupCommand() {
|
|
|
173
192
|
for (const cli of selectedClis) {
|
|
174
193
|
const allModels = modelsForCli(cli);
|
|
175
194
|
const recommended = (RECOMMENDED_MODELS[cli] ?? []).filter((m) => allModels.includes(m));
|
|
176
|
-
if (allModels.length === 0) {
|
|
177
|
-
log.warn(`${cli}: no models found
|
|
195
|
+
if (allModels.length === 0 || recommended.length === 0) {
|
|
196
|
+
log.warn(`${cli}: no recommended models found — skipping`);
|
|
178
197
|
continue;
|
|
179
198
|
}
|
|
180
|
-
log.step(`${chalk.bold(cli)}:
|
|
181
|
-
const
|
|
182
|
-
message
|
|
183
|
-
initialValue: true,
|
|
184
|
-
});
|
|
185
|
-
if (isCancel(useRecommended)) {
|
|
186
|
-
cancel("Setup cancelled");
|
|
187
|
-
process.exit(0);
|
|
188
|
-
}
|
|
189
|
-
let chosen;
|
|
190
|
-
if (useRecommended) {
|
|
191
|
-
chosen = recommended;
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
const picked = await multiselect({
|
|
195
|
-
message: `Pick ${cli} models to register:`,
|
|
196
|
-
options: allModels.map((m) => {
|
|
197
|
-
const p = API_PRICES[m];
|
|
198
|
-
return {
|
|
199
|
-
value: m,
|
|
200
|
-
label: m,
|
|
201
|
-
hint: formatPrice(p.input, p.output),
|
|
202
|
-
};
|
|
203
|
-
}),
|
|
204
|
-
initialValues: recommended,
|
|
205
|
-
required: true,
|
|
206
|
-
});
|
|
207
|
-
if (isCancel(picked)) {
|
|
208
|
-
cancel("Setup cancelled");
|
|
209
|
-
process.exit(0);
|
|
210
|
-
}
|
|
211
|
-
chosen = picked;
|
|
199
|
+
log.step(`${chalk.bold(cli)}: auto-registering ${recommended.length} recommended models`);
|
|
200
|
+
for (const m of recommended) {
|
|
201
|
+
log.message(chalk.dim(` · ${m}`));
|
|
212
202
|
}
|
|
213
|
-
for (const model of
|
|
203
|
+
for (const model of recommended) {
|
|
214
204
|
const p = API_PRICES[model];
|
|
215
205
|
registrations.push({
|
|
216
206
|
cli,
|