@radaros/transport 0.3.40 → 0.3.42

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/dist/index.cjs CHANGED
@@ -855,7 +855,8 @@ var SCHEMAS = {
855
855
  reasoningTokens: { type: "number", description: "Tokens used for chain-of-thought reasoning" },
856
856
  cachedTokens: { type: "number", description: "Prompt tokens served from cache" },
857
857
  audioInputTokens: { type: "number", description: "Audio input tokens" },
858
- audioOutputTokens: { type: "number", description: "Audio output tokens" }
858
+ audioOutputTokens: { type: "number", description: "Audio output tokens" },
859
+ providerMetrics: { type: "object", description: "Raw usage metrics from the underlying provider API" }
859
860
  }
860
861
  },
861
862
  structured: { description: "Parsed structured output (if schema is configured)" },
@@ -995,7 +996,11 @@ function generateOpenAPISpec(routerOpts, swaggerOpts = {}) {
995
996
  reasoningTokens: { type: "number", description: "Tokens used for chain-of-thought reasoning" },
996
997
  cachedTokens: { type: "number", description: "Prompt tokens served from cache" },
997
998
  audioInputTokens: { type: "number", description: "Audio input tokens" },
998
- audioOutputTokens: { type: "number", description: "Audio output tokens" }
999
+ audioOutputTokens: { type: "number", description: "Audio output tokens" },
1000
+ providerMetrics: {
1001
+ type: "object",
1002
+ description: "Raw usage metrics from the underlying provider API"
1003
+ }
999
1004
  }
1000
1005
  },
1001
1006
  structured: {
@@ -1967,6 +1972,7 @@ function createAgentGateway(opts) {
1967
1972
  const apiKey = data.apiKey ?? socket.handshake?.auth?.apiKey;
1968
1973
  const sessionId = data.sessionId ?? socket.id;
1969
1974
  let fullText = "";
1975
+ let usage;
1970
1976
  for await (const chunk of agent.stream(data.input, {
1971
1977
  sessionId,
1972
1978
  apiKey
@@ -1981,9 +1987,11 @@ function createAgentGateway(opts) {
1981
1987
  });
1982
1988
  } else if (chunk.type === "tool_call_end") {
1983
1989
  socket.emit("agent.tool.done", { toolCallId: chunk.toolCallId });
1990
+ } else if (chunk.type === "finish" && chunk.usage) {
1991
+ usage = chunk.usage;
1984
1992
  }
1985
1993
  }
1986
- socket.emit("agent.done", { output: { text: fullText } });
1994
+ socket.emit("agent.done", { output: { text: fullText, usage } });
1987
1995
  } catch (error) {
1988
1996
  socket.emit("agent.error", { error: error.message });
1989
1997
  }
package/dist/index.js CHANGED
@@ -812,7 +812,8 @@ var SCHEMAS = {
812
812
  reasoningTokens: { type: "number", description: "Tokens used for chain-of-thought reasoning" },
813
813
  cachedTokens: { type: "number", description: "Prompt tokens served from cache" },
814
814
  audioInputTokens: { type: "number", description: "Audio input tokens" },
815
- audioOutputTokens: { type: "number", description: "Audio output tokens" }
815
+ audioOutputTokens: { type: "number", description: "Audio output tokens" },
816
+ providerMetrics: { type: "object", description: "Raw usage metrics from the underlying provider API" }
816
817
  }
817
818
  },
818
819
  structured: { description: "Parsed structured output (if schema is configured)" },
@@ -952,7 +953,11 @@ function generateOpenAPISpec(routerOpts, swaggerOpts = {}) {
952
953
  reasoningTokens: { type: "number", description: "Tokens used for chain-of-thought reasoning" },
953
954
  cachedTokens: { type: "number", description: "Prompt tokens served from cache" },
954
955
  audioInputTokens: { type: "number", description: "Audio input tokens" },
955
- audioOutputTokens: { type: "number", description: "Audio output tokens" }
956
+ audioOutputTokens: { type: "number", description: "Audio output tokens" },
957
+ providerMetrics: {
958
+ type: "object",
959
+ description: "Raw usage metrics from the underlying provider API"
960
+ }
956
961
  }
957
962
  },
958
963
  structured: {
@@ -1924,6 +1929,7 @@ function createAgentGateway(opts) {
1924
1929
  const apiKey = data.apiKey ?? socket.handshake?.auth?.apiKey;
1925
1930
  const sessionId = data.sessionId ?? socket.id;
1926
1931
  let fullText = "";
1932
+ let usage;
1927
1933
  for await (const chunk of agent.stream(data.input, {
1928
1934
  sessionId,
1929
1935
  apiKey
@@ -1938,9 +1944,11 @@ function createAgentGateway(opts) {
1938
1944
  });
1939
1945
  } else if (chunk.type === "tool_call_end") {
1940
1946
  socket.emit("agent.tool.done", { toolCallId: chunk.toolCallId });
1947
+ } else if (chunk.type === "finish" && chunk.usage) {
1948
+ usage = chunk.usage;
1941
1949
  }
1942
1950
  }
1943
- socket.emit("agent.done", { output: { text: fullText } });
1951
+ socket.emit("agent.done", { output: { text: fullText, usage } });
1944
1952
  } catch (error) {
1945
1953
  socket.emit("agent.error", { error: error.message });
1946
1954
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radaros/transport",
3
- "version": "0.3.40",
3
+ "version": "0.3.42",
4
4
  "description": "HTTP and WebSocket transport layer for RadarOS agents",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "typescript": "^5.6.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@radaros/core": "^0.3.40",
45
+ "@radaros/core": "^0.3.42",
46
46
  "@types/express": "^4.0.0 || ^5.0.0",
47
47
  "express": "^4.0.0 || ^5.0.0",
48
48
  "multer": ">=2.0.0",