nous-token 0.3.2 → 0.3.4
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/cli/setup.ts +6 -4
- package/index.ts +6 -2
- package/package.json +1 -1
package/cli/setup.ts
CHANGED
|
@@ -156,10 +156,10 @@ const tools: Tool[] = [
|
|
|
156
156
|
// ── Shell env helper ──
|
|
157
157
|
|
|
158
158
|
// Collect env vars to set — don't write to shell rc file
|
|
159
|
-
const envCommands: string
|
|
159
|
+
const envCommands: Map<string, string> = new Map();
|
|
160
160
|
|
|
161
161
|
function setShellEnv(key: string, value: string, toolName: string): ConfigResult {
|
|
162
|
-
envCommands.
|
|
162
|
+
envCommands.set(key, `export ${key}="${value}"`);
|
|
163
163
|
return { success: true, message: `${key}` };
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -233,13 +233,15 @@ for (const tool of tools) {
|
|
|
233
233
|
console.log("");
|
|
234
234
|
|
|
235
235
|
if (configured > 0) {
|
|
236
|
+
const cmds = [...envCommands.values()];
|
|
236
237
|
console.log(` \x1b[32m${configured} tool(s) detected.\x1b[0m\n`);
|
|
237
238
|
console.log(" \x1b[1mThis terminal only:\x1b[0m");
|
|
238
|
-
console.log(` \x1b[36m${
|
|
239
|
+
console.log(` \x1b[36m${cmds.join(" && ")}\x1b[0m\n`);
|
|
239
240
|
console.log(" \x1b[1mAll terminals (permanent):\x1b[0m");
|
|
240
241
|
const shell = process.env.SHELL || "/bin/bash";
|
|
241
242
|
const rcFile = shell.includes("zsh") ? "~/.zshrc" : "~/.bashrc";
|
|
242
|
-
|
|
243
|
+
const echoCmd = cmds.map(c => `echo '${c}' >> ${rcFile}`).join(" && ");
|
|
244
|
+
console.log(` \x1b[36m${echoCmd} && source ${rcFile}\x1b[0m\n`);
|
|
243
245
|
console.log(` See your usage at \x1b[4mhttps://token.nousai.cc\x1b[0m`);
|
|
244
246
|
} else {
|
|
245
247
|
console.log(" No AI tools found. Install Claude Code, Cursor, or any OpenAI-compatible tool.");
|
package/index.ts
CHANGED
|
@@ -57,10 +57,13 @@ export default function plugin(api: OpenClawPluginApi): void {
|
|
|
57
57
|
if (cfg.customProviders) {
|
|
58
58
|
for (const [name, { upstream, envVar, api: apiType }] of Object.entries(cfg.customProviders)) {
|
|
59
59
|
registerProvider(api, name, {
|
|
60
|
-
|
|
60
|
+
// Custom providers can't use /provider/w/wallet/ path (no provider prefix to strip).
|
|
61
|
+
// Wallet is sent via X-Nous-Wallet header instead.
|
|
62
|
+
baseUrl: `${GATEWAY}/v1`,
|
|
61
63
|
apiType: apiType || "openai-completions",
|
|
62
64
|
envVars: [envVar],
|
|
63
65
|
upstreamHeader: upstream,
|
|
66
|
+
walletHeader: wallet,
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
}
|
|
@@ -75,7 +78,7 @@ export default function plugin(api: OpenClawPluginApi): void {
|
|
|
75
78
|
function registerProvider(
|
|
76
79
|
api: OpenClawPluginApi,
|
|
77
80
|
providerKey: string,
|
|
78
|
-
opts: { baseUrl: string; apiType: string; envVars: string[]; upstreamHeader?: string }
|
|
81
|
+
opts: { baseUrl: string; apiType: string; envVars: string[]; upstreamHeader?: string; walletHeader?: string }
|
|
79
82
|
): void {
|
|
80
83
|
const nousId = `nous-${providerKey}`;
|
|
81
84
|
|
|
@@ -123,6 +126,7 @@ function registerProvider(
|
|
|
123
126
|
...params.headers,
|
|
124
127
|
"x-nous-user": keyHash,
|
|
125
128
|
...(opts.upstreamHeader ? { "x-nous-upstream": opts.upstreamHeader } : {}),
|
|
129
|
+
...(opts.walletHeader ? { "x-nous-wallet": opts.walletHeader } : {}),
|
|
126
130
|
};
|
|
127
131
|
return inner(params);
|
|
128
132
|
};
|