@observyze/sdk 0.1.4 → 0.1.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/LICENSE +21 -0
- package/README.md +145 -198
- package/dist/{chunk-FQBYUOJB.mjs → chunk-53PSEBAD.mjs} +67 -21
- package/dist/{index-IZdiaORv.d.mts → index-ClE8H5jj.d.mts} +264 -95
- package/dist/{index-IZdiaORv.d.ts → index-ClE8H5jj.d.ts} +264 -95
- package/dist/index.d.mts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +1087 -344
- package/dist/index.mjs +1012 -321
- package/dist/opentelemetry/index.d.mts +1 -2
- package/dist/opentelemetry/index.d.ts +1 -2
- package/dist/opentelemetry/index.js +50 -23
- package/dist/opentelemetry/index.mjs +1 -1
- package/package.json +60 -57
- package/dist/chunk-YSYKPKKX.mjs +0 -357
- package/dist/index--b41_E-1.d.mts +0 -440
- package/dist/index--b41_E-1.d.ts +0 -440
- package/dist/index-Cr-FN-y5.d.mts +0 -405
- package/dist/index-Cr-FN-y5.d.ts +0 -405
- package/dist/index-D4UXMom5.d.mts +0 -429
- package/dist/index-D4UXMom5.d.ts +0 -429
|
@@ -1,20 +1,107 @@
|
|
|
1
|
-
import { SpanType, TokenUsage, Span as Span$1, TraceStatus, Trace as Trace$1 } from '@observyze/types';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* SDK Configuration and Types
|
|
5
3
|
*/
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Type of span operation
|
|
6
|
+
*/
|
|
7
|
+
declare enum SpanType {
|
|
8
|
+
LLM = "llm",
|
|
9
|
+
TOOL = "tool",
|
|
10
|
+
AGENT = "agent",
|
|
11
|
+
CHAIN = "chain",
|
|
12
|
+
RETRIEVAL = "retrieval",
|
|
13
|
+
EMBEDDING = "embedding",
|
|
14
|
+
CUSTOM = "custom"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Status of trace execution
|
|
18
|
+
*/
|
|
19
|
+
declare enum TraceStatus {
|
|
20
|
+
SUCCESS = "success",
|
|
21
|
+
ERROR = "error",
|
|
22
|
+
TIMEOUT = "timeout",
|
|
23
|
+
RUNNING = "running"
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Error information for a span
|
|
27
|
+
*/
|
|
28
|
+
interface SpanError {
|
|
29
|
+
message: string;
|
|
30
|
+
stack?: string;
|
|
31
|
+
code?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Token usage information
|
|
35
|
+
*/
|
|
36
|
+
interface TokenUsage {
|
|
37
|
+
input: number;
|
|
38
|
+
output: number;
|
|
39
|
+
total: number;
|
|
40
|
+
computed_pixels?: number;
|
|
41
|
+
audio_seconds?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Individual operation within a trace
|
|
45
|
+
*/
|
|
46
|
+
interface Span$1 {
|
|
47
|
+
span_id: string;
|
|
48
|
+
parent_span_id?: string;
|
|
49
|
+
name: string;
|
|
50
|
+
type: SpanType;
|
|
51
|
+
start_time: Date;
|
|
52
|
+
end_time: Date;
|
|
53
|
+
duration_ms: number;
|
|
54
|
+
input: any;
|
|
55
|
+
output: any;
|
|
56
|
+
error?: SpanError;
|
|
57
|
+
metadata: {
|
|
58
|
+
model?: string;
|
|
59
|
+
provider?: string;
|
|
60
|
+
temperature?: number;
|
|
61
|
+
max_tokens?: number;
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
};
|
|
64
|
+
tokens?: TokenUsage;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Complete record of an AI workflow execution
|
|
68
|
+
*/
|
|
69
|
+
interface Trace$1 {
|
|
70
|
+
trace_id: string;
|
|
71
|
+
organization_id: string;
|
|
72
|
+
project_id?: string;
|
|
73
|
+
name: string;
|
|
74
|
+
provider?: string;
|
|
75
|
+
model?: string;
|
|
76
|
+
status: TraceStatus;
|
|
77
|
+
start_time: Date;
|
|
78
|
+
end_time: Date;
|
|
79
|
+
duration_ms: number;
|
|
80
|
+
metadata: Record<string, any>;
|
|
81
|
+
spans: Span$1[];
|
|
82
|
+
tags: string[];
|
|
83
|
+
user_id?: string;
|
|
84
|
+
session_id?: string;
|
|
85
|
+
cost?: number;
|
|
86
|
+
cost_breakdown?: {
|
|
87
|
+
tokens: number;
|
|
88
|
+
pixels: number;
|
|
89
|
+
audio: number;
|
|
90
|
+
};
|
|
91
|
+
created_at: Date;
|
|
92
|
+
updated_at: Date;
|
|
93
|
+
}
|
|
7
94
|
/**
|
|
8
95
|
* Configuration for Observyze SDK client
|
|
9
96
|
*/
|
|
10
97
|
interface ClientConfig {
|
|
11
98
|
/**
|
|
12
|
-
* API key for authentication with Observyze
|
|
99
|
+
* API key for authentication with Observyze
|
|
13
100
|
*/
|
|
14
101
|
apiKey: string;
|
|
15
102
|
/**
|
|
16
|
-
* Endpoint URL for the
|
|
17
|
-
* @default '
|
|
103
|
+
* Endpoint URL for the Observyze API
|
|
104
|
+
* @default 'https://api.observyze.com'
|
|
18
105
|
*/
|
|
19
106
|
endpoint?: string;
|
|
20
107
|
/**
|
|
@@ -28,10 +115,10 @@ interface ClientConfig {
|
|
|
28
115
|
*/
|
|
29
116
|
flushInterval?: number;
|
|
30
117
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @default
|
|
118
|
+
* Timeout for each ingestion HTTP attempt in milliseconds.
|
|
119
|
+
* @default 10000
|
|
33
120
|
*/
|
|
34
|
-
|
|
121
|
+
requestTimeoutMs?: number;
|
|
35
122
|
/**
|
|
36
123
|
* Organization ID (optional, can be extracted from API key)
|
|
37
124
|
*/
|
|
@@ -46,63 +133,68 @@ interface ClientConfig {
|
|
|
46
133
|
*/
|
|
47
134
|
debug?: boolean;
|
|
48
135
|
/**
|
|
49
|
-
* Dry run mode
|
|
136
|
+
* Dry run mode — don't send traces to server (useful for testing)
|
|
50
137
|
* @default false
|
|
51
138
|
*/
|
|
52
139
|
dryRun?: boolean;
|
|
53
140
|
/**
|
|
54
|
-
*
|
|
141
|
+
* Automatically scrub PII from trace output before network transmission
|
|
55
142
|
* @default true
|
|
56
143
|
*/
|
|
57
144
|
enablePiiRedaction?: boolean;
|
|
58
145
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
146
|
+
* Capture prompt/completion content and arbitrary user metadata in traces.
|
|
147
|
+
* Set to false for metadata-only telemetry: names, inputs, outputs, errors,
|
|
148
|
+
* user/session identifiers, and tags are omitted locally before a trace
|
|
149
|
+
* can enter the dispatch buffer.
|
|
150
|
+
* @default true
|
|
151
|
+
*/
|
|
152
|
+
captureContent?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Hallucination threshold for checkGuardrails() calls.
|
|
61
155
|
* @default 0.8
|
|
62
156
|
*/
|
|
63
157
|
hallucinationThreshold?: number;
|
|
64
158
|
/**
|
|
65
|
-
*
|
|
66
|
-
* Safety score threshold (0-1) above which execution is blocked
|
|
159
|
+
* Safety threshold for checkGuardrails() calls.
|
|
67
160
|
* @default 0.9
|
|
68
161
|
*/
|
|
69
162
|
safetyThreshold?: number;
|
|
70
163
|
/**
|
|
71
|
-
* Minimum confidence threshold for
|
|
72
|
-
*
|
|
164
|
+
* Minimum confidence threshold for guardrail blocking (0-1).
|
|
165
|
+
* When confidence is below this value, high scores trigger an alert-only
|
|
166
|
+
* response instead of halting execution.
|
|
73
167
|
* @default 0.4
|
|
74
168
|
*/
|
|
75
169
|
confidenceThreshold?: number;
|
|
76
170
|
/**
|
|
77
|
-
* Evaluation service URL for
|
|
78
|
-
*
|
|
79
|
-
* @default 'http://localhost:3000'
|
|
171
|
+
* Evaluation service URL for guardrail checks.
|
|
172
|
+
* Defaults to the same value as `endpoint`.
|
|
80
173
|
*/
|
|
81
174
|
evalEndpoint?: string;
|
|
82
175
|
/**
|
|
83
|
-
* Enable
|
|
176
|
+
* Enable explicit guardrail methods (checkGuardrails, executeWithCircuitBreaker).
|
|
84
177
|
* @default true
|
|
85
178
|
*/
|
|
86
179
|
enableCircuitBreaker?: boolean;
|
|
87
180
|
/**
|
|
88
|
-
* Fail closed when evaluation service is unreachable.
|
|
89
|
-
*
|
|
90
|
-
*
|
|
181
|
+
* Fail closed when the evaluation service is unreachable.
|
|
182
|
+
* true = block execution on errors (safe default).
|
|
183
|
+
* false = allow execution on errors.
|
|
91
184
|
* @default true
|
|
92
185
|
*/
|
|
93
186
|
failClosed?: boolean;
|
|
94
187
|
/**
|
|
95
|
-
* Automatically redirect
|
|
96
|
-
* to
|
|
188
|
+
* Automatically redirect OpenAI/Anthropic base URLs through the Observyze
|
|
189
|
+
* proxy gateway to enforce Redis-backed circuit breakers.
|
|
97
190
|
* @default true
|
|
98
191
|
*/
|
|
99
192
|
enableProxyRedirect?: boolean;
|
|
100
193
|
}
|
|
101
194
|
/**
|
|
102
|
-
* Internal configuration with defaults applied
|
|
195
|
+
* Internal configuration with all defaults applied
|
|
103
196
|
*/
|
|
104
|
-
|
|
105
|
-
}
|
|
197
|
+
type ResolvedClientConfig = Required<ClientConfig>;
|
|
106
198
|
/**
|
|
107
199
|
* Result of a connection test.
|
|
108
200
|
* Verifies the SDK can reach Observyze and send a real trace end-to-end.
|
|
@@ -133,7 +225,7 @@ interface GuardrailResult {
|
|
|
133
225
|
reason?: string;
|
|
134
226
|
/** How the evaluation was performed */
|
|
135
227
|
evaluationSource?: 'live' | 'consensus' | 'nli_fast_path' | 'error' | 'disabled' | 'fallback';
|
|
136
|
-
/** Why a live evaluation didn't happen
|
|
228
|
+
/** Why a live evaluation didn't happen */
|
|
137
229
|
fallbackReason?: string;
|
|
138
230
|
}
|
|
139
231
|
|
|
@@ -147,7 +239,8 @@ interface GuardrailResult {
|
|
|
147
239
|
declare class Span {
|
|
148
240
|
private data;
|
|
149
241
|
private startTime;
|
|
150
|
-
|
|
242
|
+
private readonly captureContent;
|
|
243
|
+
constructor(name: string, type: SpanType, parentSpanId?: string, captureContent?: boolean);
|
|
151
244
|
/**
|
|
152
245
|
* Set the input data for this span
|
|
153
246
|
*/
|
|
@@ -193,7 +286,8 @@ declare class Trace {
|
|
|
193
286
|
private startTime;
|
|
194
287
|
private spans;
|
|
195
288
|
private ended;
|
|
196
|
-
|
|
289
|
+
private readonly captureContent;
|
|
290
|
+
constructor(name: string, organizationId: string, projectId?: string, captureContent?: boolean);
|
|
197
291
|
/**
|
|
198
292
|
* Start a new span within this trace
|
|
199
293
|
*/
|
|
@@ -240,30 +334,135 @@ declare class Trace {
|
|
|
240
334
|
toJSON(): Omit<Trace$1, '_id' | 'created_at' | 'updated_at'>;
|
|
241
335
|
}
|
|
242
336
|
|
|
337
|
+
interface LangChainRunnableLike {
|
|
338
|
+
invoke: (input: unknown, config?: unknown) => Promise<unknown>;
|
|
339
|
+
stream?: (input: unknown, config?: unknown) => Promise<AsyncIterable<unknown>> | AsyncIterable<unknown>;
|
|
340
|
+
[key: string]: unknown;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Instruments a LangChain-compatible Runnable boundary without taking a hard
|
|
344
|
+
* dependency on LangChain. It captures invoke() and stream(); provider-specific
|
|
345
|
+
* inner spans still require wrapping the underlying provider client.
|
|
346
|
+
*/
|
|
347
|
+
declare function wrapLangChain<T extends LangChainRunnableLike>(runnable: T, nwClient: ObservyzeClient): T;
|
|
348
|
+
|
|
349
|
+
type Callable$2 = (...args: any[]) => any;
|
|
350
|
+
type GeminiMethodSurface = ({
|
|
351
|
+
generateContent: Callable$2;
|
|
352
|
+
generateContentStream?: Callable$2;
|
|
353
|
+
} | {
|
|
354
|
+
generateContent?: Callable$2;
|
|
355
|
+
generateContentStream: Callable$2;
|
|
356
|
+
}) & Record<string, unknown>;
|
|
357
|
+
type GeminiClientLike = GeminiMethodSurface | ({
|
|
358
|
+
models: GeminiMethodSurface;
|
|
359
|
+
} & Record<string, unknown>);
|
|
360
|
+
/** Supports both @google/generative-ai model objects and @google/genai clients. */
|
|
361
|
+
declare function wrapGemini<T extends GeminiClientLike>(client: T, nwClient: ObservyzeClient): T;
|
|
362
|
+
|
|
363
|
+
type Callable$1 = (...args: any[]) => any;
|
|
364
|
+
type VercelAILike = ({
|
|
365
|
+
generateText: Callable$1;
|
|
366
|
+
streamText?: Callable$1;
|
|
367
|
+
} | {
|
|
368
|
+
generateText?: Callable$1;
|
|
369
|
+
streamText: Callable$1;
|
|
370
|
+
}) & Record<string, unknown>;
|
|
371
|
+
/**
|
|
372
|
+
* Wraps the Vercel AI SDK function surface. A new object is returned because
|
|
373
|
+
* ESM namespace imports are immutable and cannot be monkey-patched safely.
|
|
374
|
+
*/
|
|
375
|
+
declare function wrapVercelAI<T extends VercelAILike>(sdk: T, nwClient: ObservyzeClient): T;
|
|
376
|
+
|
|
377
|
+
type Callable = (...args: any[]) => any;
|
|
378
|
+
type LlamaIndexEngineLike = ({
|
|
379
|
+
query: Callable;
|
|
380
|
+
chat?: Callable;
|
|
381
|
+
} | {
|
|
382
|
+
query?: Callable;
|
|
383
|
+
chat: Callable;
|
|
384
|
+
}) & Record<string, unknown>;
|
|
385
|
+
/** Instruments LlamaIndex QueryEngine and ChatEngine method boundaries. */
|
|
386
|
+
declare function wrapLlamaIndex<T extends LlamaIndexEngineLike>(engine: T, nwClient: ObservyzeClient): T;
|
|
387
|
+
|
|
243
388
|
/**
|
|
244
389
|
* Auto-Instrumentation API
|
|
245
390
|
* Provides nw.wrap() API for instrumenting LLM clients
|
|
246
391
|
*/
|
|
247
392
|
|
|
393
|
+
type ClientMethod = (...args: any[]) => any;
|
|
248
394
|
/**
|
|
249
395
|
* Supported client types for auto-instrumentation
|
|
250
396
|
*/
|
|
251
397
|
type SupportedClient = {
|
|
252
398
|
chat: {
|
|
253
399
|
completions: {
|
|
254
|
-
create:
|
|
400
|
+
create: ClientMethod;
|
|
255
401
|
};
|
|
256
402
|
};
|
|
257
403
|
} | {
|
|
258
404
|
messages: {
|
|
259
|
-
create:
|
|
405
|
+
create: ClientMethod;
|
|
260
406
|
};
|
|
261
|
-
};
|
|
407
|
+
} | GeminiClientLike | VercelAILike | LlamaIndexEngineLike | LangChainRunnableLike;
|
|
262
408
|
/**
|
|
263
409
|
* Detect the type of LLM client and apply appropriate instrumentation
|
|
264
410
|
*/
|
|
265
411
|
declare function wrap<T extends SupportedClient>(client: T, nwClient: ObservyzeClient): T;
|
|
266
412
|
|
|
413
|
+
interface ExecutionBudgetOptions {
|
|
414
|
+
/** Maximum provider/tool operations allowed in this run. */
|
|
415
|
+
maxCalls: number;
|
|
416
|
+
/** Maximum cumulative tokens. Omit when token usage is not available. */
|
|
417
|
+
maxTokens?: number;
|
|
418
|
+
/** Wall-clock deadline for the complete run in milliseconds. */
|
|
419
|
+
timeoutMs: number;
|
|
420
|
+
}
|
|
421
|
+
interface ExecutionBudgetStats {
|
|
422
|
+
callsUsed: number;
|
|
423
|
+
tokensUsed: number;
|
|
424
|
+
elapsedMs: number;
|
|
425
|
+
remainingCalls: number;
|
|
426
|
+
remainingTokens: number | null;
|
|
427
|
+
remainingMs: number;
|
|
428
|
+
aborted: boolean;
|
|
429
|
+
}
|
|
430
|
+
declare class ExecutionBudgetExceededError extends Error {
|
|
431
|
+
readonly dimension: 'calls' | 'tokens' | 'time';
|
|
432
|
+
readonly code = "OBSERVYZE_EXECUTION_BUDGET_EXCEEDED";
|
|
433
|
+
constructor(dimension: 'calls' | 'tokens' | 'time', message: string);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Active, process-local agent execution budget. Use one instance for one
|
|
437
|
+
* agent/session run and execute every provider/tool action through run().
|
|
438
|
+
* The callback receives an AbortSignal and must pass it to the underlying SDK
|
|
439
|
+
* for transport-level cancellation; run() still rejects at the deadline if a
|
|
440
|
+
* third-party SDK ignores the signal.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```typescript
|
|
444
|
+
* const budget = new ExecutionBudget({ maxCalls: 20, maxTokens: 50_000, timeoutMs: 30_000 })
|
|
445
|
+
*
|
|
446
|
+
* const result = await budget.run(async (signal) => {
|
|
447
|
+
* return openai.chat.completions.create({ ... }, { signal })
|
|
448
|
+
* })
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
declare class ExecutionBudget {
|
|
452
|
+
private readonly options;
|
|
453
|
+
private readonly startedAt;
|
|
454
|
+
private readonly controller;
|
|
455
|
+
private callsUsed;
|
|
456
|
+
private tokensUsed;
|
|
457
|
+
constructor(options: ExecutionBudgetOptions);
|
|
458
|
+
get signal(): AbortSignal;
|
|
459
|
+
get stats(): ExecutionBudgetStats;
|
|
460
|
+
abort(reason?: string): void;
|
|
461
|
+
consumeTokens(tokens: number): void;
|
|
462
|
+
run<T>(operation: (signal: AbortSignal) => Promise<T>, reservedTokens?: number): Promise<T>;
|
|
463
|
+
private assertTime;
|
|
464
|
+
}
|
|
465
|
+
|
|
267
466
|
/**
|
|
268
467
|
* Observyze SDK Client
|
|
269
468
|
* Main entry point for instrumenting AI applications
|
|
@@ -279,16 +478,9 @@ declare class ObservyzeClient {
|
|
|
279
478
|
private isShuttingDown;
|
|
280
479
|
private readonly MAX_QUEUE_SIZE;
|
|
281
480
|
private readonly RETRY_DELAYS;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
* The api-gateway error handler includes these fields in every error response.
|
|
285
|
-
*/
|
|
481
|
+
private static readBoundedResponse;
|
|
482
|
+
private static retryAfterMs;
|
|
286
483
|
private static parseApiError;
|
|
287
|
-
/**
|
|
288
|
-
* Format an API error into a user-friendly message with trace_id for correlation.
|
|
289
|
-
* Example output:
|
|
290
|
-
* "Observyze API error (401 [ref: err_a1b2c3d4]): MISSING_PROVIDER_KEY — No API key configured..."
|
|
291
|
-
*/
|
|
292
484
|
private static formatApiError;
|
|
293
485
|
constructor(config: ClientConfig);
|
|
294
486
|
/**
|
|
@@ -304,7 +496,7 @@ declare class ObservyzeClient {
|
|
|
304
496
|
*/
|
|
305
497
|
private startFlushTimer;
|
|
306
498
|
/**
|
|
307
|
-
* Flush all buffered traces to
|
|
499
|
+
* Flush all buffered traces to Observyze
|
|
308
500
|
*/
|
|
309
501
|
flush(): Promise<void>;
|
|
310
502
|
/**
|
|
@@ -324,7 +516,9 @@ declare class ObservyzeClient {
|
|
|
324
516
|
*/
|
|
325
517
|
getConfig(): Readonly<ResolvedClientConfig>;
|
|
326
518
|
/**
|
|
327
|
-
* Wrap
|
|
519
|
+
* Wrap a supported LLM client or framework boundary to enable auto-instrumentation.
|
|
520
|
+
*
|
|
521
|
+
* Supports: OpenAI, Anthropic, Google Gemini, Vercel AI SDK, LangChain, LlamaIndex.
|
|
328
522
|
*
|
|
329
523
|
* @example
|
|
330
524
|
* ```typescript
|
|
@@ -332,86 +526,61 @@ declare class ObservyzeClient {
|
|
|
332
526
|
* import { ObservyzeClient } from '@observyze/sdk'
|
|
333
527
|
*
|
|
334
528
|
* const nw = new ObservyzeClient({ apiKey: 'your-api-key' })
|
|
335
|
-
* const openai = new OpenAI({ apiKey: 'openai-key' })
|
|
336
|
-
*
|
|
337
|
-
* // Wrap the client to enable auto-instrumentation
|
|
338
|
-
* nw.wrap(openai)
|
|
529
|
+
* const openai = nw.wrap(new OpenAI({ apiKey: 'openai-key' }))
|
|
339
530
|
*
|
|
340
531
|
* // All calls are now automatically traced
|
|
341
532
|
* const response = await openai.chat.completions.create({
|
|
342
|
-
* model: 'gpt-
|
|
533
|
+
* model: 'gpt-4o',
|
|
343
534
|
* messages: [{ role: 'user', content: 'Hello!' }]
|
|
344
535
|
* })
|
|
345
536
|
* ```
|
|
346
537
|
*/
|
|
347
538
|
wrap<T extends SupportedClient>(client: T): T;
|
|
539
|
+
/** Create an active call/token/time budget for one agent execution. */
|
|
540
|
+
createExecutionBudget(options: ExecutionBudgetOptions): ExecutionBudget;
|
|
348
541
|
/**
|
|
349
542
|
* Verify that the SDK can reach Observyze and send traces end-to-end.
|
|
350
543
|
*
|
|
351
|
-
* This is the definitive "is my integration working?" test for SDK users.
|
|
352
|
-
* It sends a real test trace through the EXACT same pipeline used by
|
|
353
|
-
* `flush()` / the wrapped LLM clients (same endpoint, apiKey, retry logic),
|
|
354
|
-
* so a successful call proves the whole chain works from your code:
|
|
355
|
-
* - apiKey is valid and authorized
|
|
356
|
-
* - endpoint is reachable from your environment
|
|
357
|
-
* - organization / project resolution works
|
|
358
|
-
* - the ingest pipeline accepts and stores traces
|
|
359
|
-
*
|
|
360
544
|
* @example
|
|
361
545
|
* ```typescript
|
|
362
546
|
* const nw = new ObservyzeClient({ apiKey: process.env.OBSERVYZE_API_KEY })
|
|
363
547
|
* const result = await nw.testConnection()
|
|
364
|
-
* // { ok: true, traceId: '
|
|
548
|
+
* // { ok: true, traceId: '...', message: 'Connection successful...' }
|
|
365
549
|
* ```
|
|
366
|
-
*
|
|
367
|
-
* The returned traceId can be searched in the Observyze dashboard (Traces →
|
|
368
|
-
* search the trace name "Observyze Connection Test") to confirm it landed.
|
|
369
550
|
*/
|
|
370
551
|
testConnection(): Promise<TestConnectionResult>;
|
|
371
552
|
/**
|
|
372
|
-
* Sync local agent .history file to Observyze cloud
|
|
373
|
-
* Parses JSON/NDJSON agent history and sends to ingestion endpoint.
|
|
553
|
+
* Sync a local agent .history file to Observyze cloud.
|
|
554
|
+
* Parses JSON/NDJSON agent history and sends to the ingestion endpoint.
|
|
374
555
|
*/
|
|
375
556
|
syncLocalHistory(filePath: string): Promise<void>;
|
|
376
557
|
/**
|
|
377
|
-
* Industry-grade PII
|
|
378
|
-
*
|
|
379
|
-
|
|
380
|
-
* Coverage: emails, JWTs, bearer tokens, AWS/API keys, SSNs, credit cards,
|
|
381
|
-
* phone numbers (US + E.164), IPv4/IPv6, passport numbers, ZIP codes, plus
|
|
382
|
-
* key-based redaction for sensitive JSON fields (password, token, api_key, etc.).
|
|
383
|
-
*
|
|
384
|
-
* Design:
|
|
385
|
-
* - Pure function, never mutates the original object
|
|
386
|
-
* - Depth-limited to 16 levels to prevent stack overflow on deep agent outputs
|
|
387
|
-
* - Key-aware: sensitive key names are fully redacted regardless of value format
|
|
388
|
-
*/
|
|
389
|
-
private static readonly PII_PATTERNS;
|
|
390
|
-
private static readonly SENSITIVE_KEYS;
|
|
391
|
-
private static isSensitiveKey;
|
|
558
|
+
* Industry-grade PII redaction.
|
|
559
|
+
* Recursively scrubs PII from trace data before transmission.
|
|
560
|
+
*/
|
|
392
561
|
private sanitizePII;
|
|
393
562
|
/**
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
* If hallucination score > hallucinationThreshold, the SDK blocks execution.
|
|
563
|
+
* Explicitly evaluate content before an application action.
|
|
564
|
+
* Requires an active Observyze subscription with guardrails enabled.
|
|
397
565
|
*
|
|
398
566
|
* Returns GuardrailResult with score: null when evaluation couldn't be performed.
|
|
399
|
-
* In failClosed mode, null scores
|
|
400
|
-
*
|
|
567
|
+
* In failClosed mode (default), null scores block execution.
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```typescript
|
|
571
|
+
* const result = await nw.checkGuardrails(llmOutput)
|
|
572
|
+
* if (!result.pass) {
|
|
573
|
+
* throw new Error('Guardrail blocked: ' + result.reason)
|
|
574
|
+
* }
|
|
575
|
+
* ```
|
|
401
576
|
*/
|
|
402
577
|
checkGuardrails(content: string | any): Promise<GuardrailResult>;
|
|
403
578
|
/**
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
* Pauses execution if hallucination score >= hallucinationThreshold and requests human review.
|
|
579
|
+
* Execute an application action only after an explicit pre-execution
|
|
580
|
+
* guardrail check passes.
|
|
407
581
|
* @throws Error when execution is blocked by circuit breaker
|
|
408
582
|
*/
|
|
409
583
|
executeWithCircuitBreaker<T>(agentExecution: () => Promise<T>, traceContext?: any): Promise<T>;
|
|
410
|
-
/**
|
|
411
|
-
* Phase 4: Bug Bounty Protocol (Automated) (Requirement 4.2)
|
|
412
|
-
* Automatically shard persistent failure cases to external security researcher endpoints (e.g. HackerOne wrapper)
|
|
413
|
-
*/
|
|
414
|
-
reportBugBounty(traceId: string, securityEndpoint: string, failureContext: any): Promise<void>;
|
|
415
584
|
}
|
|
416
585
|
|
|
417
586
|
/**
|
|
@@ -474,4 +643,4 @@ declare class ObservyzeSpanExporter {
|
|
|
474
643
|
forceFlush(): Promise<void>;
|
|
475
644
|
}
|
|
476
645
|
|
|
477
|
-
export { type ClientConfig as C, ObservyzeClient as O, type ResolvedClientConfig as R, Span as S, type TestConnectionResult as T, type
|
|
646
|
+
export { type ClientConfig as C, ExecutionBudget as E, type GeminiClientLike as G, type LangChainRunnableLike as L, ObservyzeClient as O, type ResolvedClientConfig as R, Span as S, type TestConnectionResult as T, type VercelAILike as V, ExecutionBudgetExceededError as a, type ExecutionBudgetOptions as b, type ExecutionBudgetStats as c, type GuardrailResult as d, type LlamaIndexEngineLike as e, type ObservyzeExporterConfig as f, ObservyzeSpanExporter as g, type Span$1 as h, type SpanError as i, SpanType as j, type SupportedClient as k, type TokenUsage as l, Trace as m, type Trace$1 as n, TraceStatus as o, wrapGemini as p, wrapLangChain as q, wrapLlamaIndex as r, wrapVercelAI as s, wrap as w };
|