@rheonic/sdk 0.1.0-beta.5 → 0.1.0-beta.6

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.
@@ -1,4 +1,4 @@
1
- export type ProtectDecision = "allow" | "warn" | "block";
1
+ export type ProtectDecision = "allow" | "clamp" | "block";
2
2
  export type ProtectFailMode = "open" | "closed";
3
3
  export interface ProtectContext {
4
4
  provider: string;
@@ -229,7 +229,7 @@ function parseBlockedUntilMs(value) {
229
229
  return parsed;
230
230
  }
231
231
  function parseDecision(value) {
232
- if (value === "warn" || value === "block" || value === "allow") {
232
+ if (value === "clamp" || value === "block" || value === "allow") {
233
233
  return value;
234
234
  }
235
235
  return "allow";
@@ -57,8 +57,8 @@ export function instrumentAnthropic(anthropicClient, options) {
57
57
  feature: options.feature,
58
58
  token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
59
59
  input_tokens_estimate: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
60
- protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
61
- protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
60
+ protect_decision: protectDecision.decision !== "allow" ? protectDecision.decision : undefined,
61
+ protect_reason: protectDecision.decision !== "allow" ? protectDecision.reason : undefined,
62
62
  },
63
63
  response: {
64
64
  latency_ms: Date.now() - startedAt,
@@ -78,8 +78,8 @@ export function instrumentAnthropic(anthropicClient, options) {
78
78
  feature: options.feature,
79
79
  token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
80
80
  input_tokens_estimate: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
81
- protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
82
- protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
81
+ protect_decision: protectDecision.decision !== "allow" ? protectDecision.decision : undefined,
82
+ protect_reason: protectDecision.decision !== "allow" ? protectDecision.reason : undefined,
83
83
  },
84
84
  response: {
85
85
  latency_ms: Date.now() - startedAt,
@@ -155,7 +155,7 @@ function extractHttpStatus(error) {
155
155
  return undefined;
156
156
  }
157
157
  function maybeApplyAnthropicClamp(args, decision) {
158
- if (decision.decision !== "warn" || decision.reason !== "near_cap") {
158
+ if (decision.decision !== "clamp") {
159
159
  return args;
160
160
  }
161
161
  if (!decision.applyClampEnabled) {
@@ -57,8 +57,8 @@ export function instrumentGoogle(googleModel, options) {
57
57
  feature: options.feature,
58
58
  token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
59
59
  input_tokens_estimate: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
60
- protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
61
- protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
60
+ protect_decision: protectDecision.decision !== "allow" ? protectDecision.decision : undefined,
61
+ protect_reason: protectDecision.decision !== "allow" ? protectDecision.reason : undefined,
62
62
  },
63
63
  response: {
64
64
  latency_ms: Date.now() - startedAt,
@@ -78,8 +78,8 @@ export function instrumentGoogle(googleModel, options) {
78
78
  feature: options.feature,
79
79
  token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
80
80
  input_tokens_estimate: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
81
- protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
82
- protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
81
+ protect_decision: protectDecision.decision !== "allow" ? protectDecision.decision : undefined,
82
+ protect_reason: protectDecision.decision !== "allow" ? protectDecision.reason : undefined,
83
83
  },
84
84
  response: {
85
85
  latency_ms: Date.now() - startedAt,
@@ -168,7 +168,7 @@ function extractHttpStatus(error) {
168
168
  return undefined;
169
169
  }
170
170
  function maybeApplyGoogleClamp(args, decision) {
171
- if (decision.decision !== "warn" || decision.reason !== "near_cap") {
171
+ if (decision.decision !== "clamp") {
172
172
  return args;
173
173
  }
174
174
  if (!decision.applyClampEnabled) {
@@ -57,8 +57,8 @@ export function instrumentOpenAI(openaiClient, options) {
57
57
  endpoint: options.endpoint,
58
58
  feature: options.feature,
59
59
  token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
60
- protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
61
- protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
60
+ protect_decision: protectDecision.decision !== "allow" ? protectDecision.decision : undefined,
61
+ protect_reason: protectDecision.decision !== "allow" ? protectDecision.reason : undefined,
62
62
  },
63
63
  response: {
64
64
  latency_ms: Date.now() - startedAt,
@@ -77,8 +77,8 @@ export function instrumentOpenAI(openaiClient, options) {
77
77
  endpoint: options.endpoint,
78
78
  feature: options.feature,
79
79
  token_explosion_tokens: typeof estimatedInputTokens === "number" ? estimatedInputTokens : undefined,
80
- protect_decision: protectDecision.decision === "warn" ? "warn" : undefined,
81
- protect_reason: protectDecision.decision === "warn" ? protectDecision.reason : undefined,
80
+ protect_decision: protectDecision.decision !== "allow" ? protectDecision.decision : undefined,
81
+ protect_reason: protectDecision.decision !== "allow" ? protectDecision.reason : undefined,
82
82
  },
83
83
  response: {
84
84
  latency_ms: Date.now() - startedAt,
@@ -120,7 +120,7 @@ function extractMaxOutputTokens(args) {
120
120
  return undefined;
121
121
  }
122
122
  function maybeApplyOpenAIClamp(args, decision) {
123
- if (decision.decision !== "warn" || decision.reason !== "near_cap") {
123
+ if (decision.decision !== "clamp") {
124
124
  return args;
125
125
  }
126
126
  if (!decision.applyClampEnabled) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rheonic/sdk",
3
- "version": "0.1.0-beta.5",
3
+ "version": "0.1.0-beta.6",
4
4
  "description": "Node.js SDK for Rheonic observability and protect preflight enforcement.",
5
5
  "author": "Rheonic <founder@rheonic.dev>",
6
6
  "license": "MIT",