jev-gateway 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Fixed
6
+ - Token metering now works with Codex on a ChatGPT subscription. That backend streams its replies
7
+ without a content-type header, so 0.2.0 read them as plain JSON and recorded no tokens at all.
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Added
package/dist/usage.js CHANGED
@@ -44,7 +44,9 @@ function collect(payload, into) {
44
44
  */
45
45
  export async function readUsage(response) {
46
46
  const found = {};
47
- const streaming = response.headers.get("content-type")?.includes("text/event-stream") ?? false;
47
+ // Told apart by content, not by header: the ChatGPT Codex backend streams events without
48
+ // sending any content-type at all.
49
+ let streaming;
48
50
  let pending = "";
49
51
  const scan = (line) => {
50
52
  // Most stream events are text deltas; only the few that mention usage are worth parsing.
@@ -60,6 +62,7 @@ export async function readUsage(response) {
60
62
  try {
61
63
  for await (const chunk of response.body?.pipeThrough(new TextDecoderStream()) ?? []) {
62
64
  pending += chunk;
65
+ streaming ??= /^\s*$/.test(pending) ? undefined : !/^\s*[{[]/.test(pending);
63
66
  if (!streaming)
64
67
  continue;
65
68
  const lines = pending.split("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jev-gateway",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Local LLM gateway that lets TypeSafe's Jev model pick the tool for coding agents. Launchers for Codex and Claude Code, with a monitoring dashboard.",
5
5
  "keywords": [
6
6
  "llm",