nous-token 0.3.3 → 0.3.5

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 CHANGED
@@ -21,7 +21,7 @@ function loadWallet(): string {
21
21
  }
22
22
 
23
23
  function saveWallet(wallet: string): void {
24
- writeFileSync(NOUS_CONFIG, wallet);
24
+ writeFileSync(NOUS_CONFIG, wallet, { mode: 0o600 });
25
25
  }
26
26
 
27
27
  function gatewayUrl(provider: string, apiPath: string, wallet: string): string {
@@ -240,7 +240,8 @@ if (configured > 0) {
240
240
  console.log(" \x1b[1mAll terminals (permanent):\x1b[0m");
241
241
  const shell = process.env.SHELL || "/bin/bash";
242
242
  const rcFile = shell.includes("zsh") ? "~/.zshrc" : "~/.bashrc";
243
- console.log(` \x1b[36mecho '${cmds.join("\\n")}' >> ${rcFile} && source ${rcFile}\x1b[0m\n`);
243
+ const echoCmd = cmds.map(c => `echo '${c}' >> ${rcFile}`).join(" && ");
244
+ console.log(` \x1b[36m${echoCmd} && source ${rcFile}\x1b[0m\n`);
244
245
  console.log(` See your usage at \x1b[4mhttps://token.nousai.cc\x1b[0m`);
245
246
  } else {
246
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
- baseUrl: `${GATEWAY}${walletSegment}/v1`,
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
  };
@@ -2,7 +2,7 @@
2
2
  "id": "nous-token",
3
3
  "name": "nous-token",
4
4
  "description": "Track your AI usage on the global leaderboard. Routes LLM calls through the nous-token gateway to record real token consumption. Supports 11 providers out of the box + unlimited custom providers. No prompt or response content is stored.",
5
- "version": "0.2.0",
5
+ "version": "0.3.4",
6
6
  "kind": "provider",
7
7
  "providers": [
8
8
  "nous-openai", "nous-anthropic", "nous-deepseek", "nous-google",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nous-token",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Open-source AI usage tracker. One command to track all your AI spending.",
5
5
  "type": "module",
6
6
  "main": "index.ts",