@rheonic/sdk 0.1.0-beta.7 → 0.1.0-beta.8

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/client.d.ts CHANGED
@@ -42,6 +42,7 @@ export declare class Client {
42
42
  private warmupCompleted;
43
43
  constructor(config: ClientConfig);
44
44
  captureEvent(event: EventPayload): Promise<void>;
45
+ captureEventAndFlush(event: EventPayload): Promise<void>;
45
46
  getStats(): ClientStats;
46
47
  flush(): Promise<void>;
47
48
  evaluateProtectDecision(context: ProtectContext): Promise<ProtectEvaluation>;
package/dist/client.js CHANGED
@@ -98,6 +98,10 @@ export class Client {
98
98
  return;
99
99
  }
100
100
  }
101
+ async captureEventAndFlush(event) {
102
+ await this.captureEvent(event);
103
+ await this.flushWithTimeout();
104
+ }
101
105
  getStats() {
102
106
  return {
103
107
  queued: this.queue.length,
@@ -48,7 +48,7 @@ export function instrumentAnthropic(anthropicClient, options) {
48
48
  markClampAppliedIfChanged(protectDecision, extractMaxOutputTokens(args), extractMaxOutputTokens(callArgs));
49
49
  try {
50
50
  const response = await originalCreate(...callArgs);
51
- void options.client.captureEvent(buildEvent({
51
+ await options.client.captureEventAndFlush(buildEvent({
52
52
  provider: "anthropic",
53
53
  model: extractResponseModel(response) ?? requestedModel,
54
54
  environment: options.environment ?? options.client.environment,
@@ -69,7 +69,7 @@ export function instrumentAnthropic(anthropicClient, options) {
69
69
  return response;
70
70
  }
71
71
  catch (error) {
72
- void options.client.captureEvent(buildEvent({
72
+ await options.client.captureEventAndFlush(buildEvent({
73
73
  provider: "anthropic",
74
74
  model: requestedModel,
75
75
  environment: options.environment ?? options.client.environment,
@@ -48,7 +48,7 @@ export function instrumentGoogle(googleModel, options) {
48
48
  markClampAppliedIfChanged(protectDecision, extractMaxOutputTokens(args), extractMaxOutputTokens(callArgs));
49
49
  try {
50
50
  const response = await originalGenerate(...callArgs);
51
- void options.client.captureEvent(buildEvent({
51
+ await options.client.captureEventAndFlush(buildEvent({
52
52
  provider: "google",
53
53
  model: requestedModel,
54
54
  environment: options.environment ?? options.client.environment,
@@ -69,7 +69,7 @@ export function instrumentGoogle(googleModel, options) {
69
69
  return response;
70
70
  }
71
71
  catch (error) {
72
- void options.client.captureEvent(buildEvent({
72
+ await options.client.captureEventAndFlush(buildEvent({
73
73
  provider: "google",
74
74
  model: requestedModel,
75
75
  environment: options.environment ?? options.client.environment,
@@ -49,7 +49,7 @@ export function instrumentOpenAI(openaiClient, options) {
49
49
  markClampAppliedIfChanged(protectDecision, extractMaxOutputTokens(args), extractMaxOutputTokens(callArgs));
50
50
  try {
51
51
  const response = await originalCreate(...callArgs);
52
- void options.client.captureEvent(buildEvent({
52
+ await options.client.captureEventAndFlush(buildEvent({
53
53
  provider: "openai",
54
54
  model: extractResponseModel(response) ?? model,
55
55
  environment: options.environment ?? options.client.environment,
@@ -69,7 +69,7 @@ export function instrumentOpenAI(openaiClient, options) {
69
69
  return response;
70
70
  }
71
71
  catch (error) {
72
- void options.client.captureEvent(buildEvent({
72
+ await options.client.captureEventAndFlush(buildEvent({
73
73
  provider: "openai",
74
74
  model,
75
75
  environment: options.environment ?? options.client.environment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rheonic/sdk",
3
- "version": "0.1.0-beta.7",
3
+ "version": "0.1.0-beta.8",
4
4
  "description": "Node.js SDK for Rheonic observability and protect preflight enforcement.",
5
5
  "author": "Rheonic <founder@rheonic.dev>",
6
6
  "license": "MIT",