@rheonic/sdk 0.1.0-beta.4 → 0.1.0-beta.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/README.md CHANGED
@@ -120,12 +120,14 @@ await client.captureEvent(
120
120
  buildEvent({
121
121
  provider: "openai",
122
122
  model: "gpt-4o-mini",
123
- request: { endpoint: "/chat/completions", feature: "assistant" },
123
+ request: { endpoint: "/chat/completions", feature: "assistant", token_explosion_tokens: 64 },
124
124
  response: { total_tokens: 64, latency_ms: 120, http_status: 200 },
125
125
  }),
126
126
  );
127
127
  ```
128
128
 
129
+ `token_explosion_tokens` is optional. Set it only for custom/manual events when you want token-explosion detection to use the same request-context signal that the SDK instrumentation sends to both protect and ingest.
130
+
129
131
  ## Reference
130
132
 
131
133
  Full quickstart:
@@ -3,6 +3,7 @@ export interface EventRequest {
3
3
  feature?: string;
4
4
  input_tokens?: number;
5
5
  input_tokens_estimate?: number;
6
+ token_explosion_tokens?: number;
6
7
  max_output_tokens?: number;
7
8
  protect_decision?: string;
8
9
  protect_reason?: string;
@@ -55,6 +55,7 @@ export function instrumentAnthropic(anthropicClient, options) {
55
55
  request: {
56
56
  endpoint: options.endpoint,
57
57
  feature: options.feature,
58
+ token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
58
59
  input_tokens_estimate: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
59
60
  protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
60
61
  protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
@@ -75,6 +76,7 @@ export function instrumentAnthropic(anthropicClient, options) {
75
76
  request: {
76
77
  endpoint: options.endpoint,
77
78
  feature: options.feature,
79
+ token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
78
80
  input_tokens_estimate: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
79
81
  protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
80
82
  protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
@@ -55,6 +55,7 @@ export function instrumentGoogle(googleModel, options) {
55
55
  request: {
56
56
  endpoint: options.endpoint,
57
57
  feature: options.feature,
58
+ token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
58
59
  input_tokens_estimate: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
59
60
  protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
60
61
  protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
@@ -75,6 +76,7 @@ export function instrumentGoogle(googleModel, options) {
75
76
  request: {
76
77
  endpoint: options.endpoint,
77
78
  feature: options.feature,
79
+ token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
78
80
  input_tokens_estimate: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
79
81
  protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
80
82
  protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
@@ -56,6 +56,7 @@ export function instrumentOpenAI(openaiClient, options) {
56
56
  request: {
57
57
  endpoint: options.endpoint,
58
58
  feature: options.feature,
59
+ token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
59
60
  protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
60
61
  protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
61
62
  },
@@ -75,6 +76,7 @@ export function instrumentOpenAI(openaiClient, options) {
75
76
  request: {
76
77
  endpoint: options.endpoint,
77
78
  feature: options.feature,
79
+ token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
78
80
  protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
79
81
  protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
80
82
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rheonic/sdk",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-beta.5",
4
4
  "description": "Node.js SDK for Rheonic observability and protect preflight enforcement.",
5
5
  "author": "Rheonic <founder@rheonic.dev>",
6
6
  "license": "MIT",