@tokagent/tokagentos 2.0.9 → 2.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokagent/tokagentos",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "description": "tokagentOS CLI - Create and upgrade tokagentOS project templates",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokagent/plugin-tokagent-billing",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "elizaOS plugin: Web3 credit-billing routes and middleware for the tokagentos LLM gateway.",
5
5
  "type": "module",
6
6
  "publishConfig": { "access": "public" },
@@ -80,13 +80,21 @@ export function send(res: RouteResponse, upstream: ProxyResponse): void {
80
80
  }
81
81
  }
82
82
 
83
- res.status(upstream.status);
83
+ // Use the CHAINED form (`res.status(n).json(body)`) instead of two separate
84
+ // calls. The agent's runtime-plugin-routes shim historically only exposed
85
+ // `.json()` / `.send()` on the object RETURNED by `.status(n)`, not on `res`
86
+ // directly. Older agent versions (< v0.5.x of @tokagentos/agent) crash with
87
+ // "res.json is not a function" if `.json()` is called on `res` after a bare
88
+ // `.status(n)`. The agent shim has since been fixed to attach the helpers
89
+ // both ways, but using the chained form here works against both old and new
90
+ // agent runtimes.
91
+ const chained = res.status(upstream.status);
84
92
  if (upstream.body === null) {
85
93
  res.end?.();
86
94
  } else if (typeof upstream.body === "string") {
87
- res.send(upstream.body);
95
+ chained.send(upstream.body);
88
96
  } else {
89
- res.json(upstream.body as object);
97
+ chained.json(upstream.body as object);
90
98
  }
91
99
  }
92
100
 
@@ -89,9 +89,25 @@ function buildConfigJs(runtime: IAgentRuntime): string {
89
89
  10: "https://optimistic.etherscan.io",
90
90
  };
91
91
 
92
+ // In client-mode the dashboard talks to the upstream gateway DIRECTLY via
93
+ // CORS rather than forwarding through the local agent. This sidesteps three
94
+ // bugs in vanilla elizaOS that the scaffolder pins (the auth-gate runs
95
+ // before plugin route resolution and rejects /v1/* with 401 when the
96
+ // operator has TOKAGENT_API_TOKEN set; the runtime-plugin-routes shim
97
+ // historically only exposed res.json on the inline object returned by
98
+ // .status(); the plugin-prefixed mount path drops JSON body parsing). The
99
+ // Railway-hosted gateway has all three patched in its own fork. Server-mode
100
+ // keeps PROXY_BASE="" so same-origin calls hit the plugin's own
101
+ // serverAuthRoutes handlers locally — no upstream needed there.
102
+ const billingMode =
103
+ get("BILLING_MODE").toLowerCase() === "client" ? "client" : "server";
104
+ const proxyBase =
105
+ billingMode === "client"
106
+ ? get("TOKAGENT_GATEWAY_URL").replace(/\/+$/, "")
107
+ : "";
108
+
92
109
  const config = {
93
- // Same-origin: the dashboard is served by the same agent API server.
94
- PROXY_BASE: "",
110
+ PROXY_BASE: proxyBase,
95
111
  CHAIN_ID: chainId,
96
112
  CHAIN_NAME: chainNames[chainId] ?? `chain-${chainId}`,
97
113
  CHAIN_RPC_URL: get("BILLING_CHAIN_RPC_URL"),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": "1.0.0",
3
- "generatedAt": "2026-05-19T11:28:01.700Z",
3
+ "generatedAt": "2026-05-19T12:22:51.161Z",
4
4
  "repoUrl": "https://github.com/elizaos/eliza",
5
5
  "templates": [
6
6
  {