@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 +1 -1
- package/templates/fullstack-app/plugins/plugin-tokagent-billing/package.json +1 -1
- package/templates/fullstack-app/plugins/plugin-tokagent-billing/src/lib/forward.ts +11 -3
- package/templates/fullstack-app/plugins/plugin-tokagent-billing/src/routes/dashboard-routes.ts +18 -2
- package/templates-manifest.json +1 -1
package/package.json
CHANGED
|
@@ -80,13 +80,21 @@ export function send(res: RouteResponse, upstream: ProxyResponse): void {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
res.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
|
-
|
|
95
|
+
chained.send(upstream.body);
|
|
88
96
|
} else {
|
|
89
|
-
|
|
97
|
+
chained.json(upstream.body as object);
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
|
package/templates/fullstack-app/plugins/plugin-tokagent-billing/src/routes/dashboard-routes.ts
CHANGED
|
@@ -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
|
-
|
|
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"),
|