@llmtracer/sdk 1.1.0 → 2.1.0
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/cjs/auto.d.ts +2 -0
- package/dist/cjs/auto.d.ts.map +1 -0
- package/dist/cjs/auto.js +5 -0
- package/dist/cjs/auto.js.map +1 -0
- package/dist/cjs/caller.d.ts +6 -0
- package/dist/cjs/caller.d.ts.map +1 -0
- package/dist/cjs/caller.js +62 -0
- package/dist/cjs/caller.js.map +1 -0
- package/dist/cjs/config.d.ts +7 -0
- package/dist/cjs/config.d.ts.map +1 -0
- package/dist/cjs/config.js +10 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/context.d.ts +9 -0
- package/dist/cjs/context.d.ts.map +1 -0
- package/dist/cjs/context.js +21 -0
- package/dist/cjs/context.js.map +1 -0
- package/dist/cjs/index.d.ts +20 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +93 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/patcher.d.ts +4 -0
- package/dist/cjs/patcher.d.ts.map +1 -0
- package/dist/cjs/patcher.js +93 -0
- package/dist/cjs/patcher.js.map +1 -0
- package/dist/cjs/providers/anthropic.d.ts +4 -0
- package/dist/cjs/providers/anthropic.d.ts.map +1 -0
- package/dist/cjs/providers/anthropic.js +111 -0
- package/dist/cjs/providers/anthropic.js.map +1 -0
- package/dist/cjs/providers/index.d.ts +3 -0
- package/dist/cjs/providers/index.d.ts.map +1 -0
- package/dist/cjs/providers/index.js +10 -0
- package/dist/cjs/providers/index.js.map +1 -0
- package/dist/cjs/providers/openai.d.ts +4 -0
- package/dist/cjs/providers/openai.d.ts.map +1 -0
- package/dist/cjs/providers/openai.js +108 -0
- package/dist/cjs/providers/openai.js.map +1 -0
- package/dist/cjs/schema.d.ts +18 -0
- package/dist/cjs/schema.d.ts.map +1 -0
- package/dist/cjs/schema.js +93 -0
- package/dist/cjs/schema.js.map +1 -0
- package/dist/cjs/transport.d.ts +6 -0
- package/dist/cjs/transport.d.ts.map +1 -0
- package/dist/cjs/transport.js +69 -0
- package/dist/cjs/transport.js.map +1 -0
- package/dist/cjs/wrapper.d.ts +3 -0
- package/dist/cjs/wrapper.d.ts.map +1 -0
- package/dist/cjs/wrapper.js +86 -0
- package/dist/cjs/wrapper.js.map +1 -0
- package/dist/esm/auto.d.ts +2 -0
- package/dist/esm/auto.d.ts.map +1 -0
- package/dist/esm/auto.js +3 -0
- package/dist/esm/auto.js.map +1 -0
- package/dist/esm/caller.d.ts +6 -0
- package/dist/esm/caller.d.ts.map +1 -0
- package/dist/esm/caller.js +59 -0
- package/dist/esm/caller.js.map +1 -0
- package/dist/esm/config.d.ts +7 -0
- package/dist/esm/config.d.ts.map +1 -0
- package/dist/esm/config.js +7 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/context.d.ts +9 -0
- package/dist/esm/context.d.ts.map +1 -0
- package/dist/esm/context.js +17 -0
- package/dist/esm/context.js.map +1 -0
- package/dist/esm/index.d.ts +20 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +53 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/patcher.d.ts +4 -0
- package/dist/esm/patcher.d.ts.map +1 -0
- package/dist/esm/patcher.js +88 -0
- package/dist/esm/patcher.js.map +1 -0
- package/dist/esm/providers/anthropic.d.ts +4 -0
- package/dist/esm/providers/anthropic.d.ts.map +1 -0
- package/dist/esm/providers/anthropic.js +74 -0
- package/dist/esm/providers/anthropic.js.map +1 -0
- package/dist/esm/providers/index.d.ts +3 -0
- package/dist/esm/providers/index.d.ts.map +1 -0
- package/dist/esm/providers/index.js +3 -0
- package/dist/esm/providers/index.js.map +1 -0
- package/dist/esm/providers/openai.d.ts +4 -0
- package/dist/esm/providers/openai.d.ts.map +1 -0
- package/dist/esm/providers/openai.js +71 -0
- package/dist/esm/providers/openai.js.map +1 -0
- package/dist/esm/schema.d.ts +18 -0
- package/dist/esm/schema.d.ts.map +1 -0
- package/dist/esm/schema.js +88 -0
- package/dist/esm/schema.js.map +1 -0
- package/dist/esm/transport.d.ts +6 -0
- package/dist/esm/transport.d.ts.map +1 -0
- package/dist/esm/transport.js +62 -0
- package/dist/esm/transport.js.map +1 -0
- package/dist/esm/wrapper.d.ts +3 -0
- package/dist/esm/wrapper.d.ts.map +1 -0
- package/dist/esm/wrapper.js +50 -0
- package/dist/esm/wrapper.js.map +1 -0
- package/package.json +56 -11
- package/dist/index.d.ts +0 -118
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -568
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { config } from './config';
|
|
2
|
+
import * as context from './context';
|
|
3
|
+
import * as transport from './transport';
|
|
4
|
+
import * as patcher from './patcher';
|
|
5
|
+
export const __version__ = '2.0.0';
|
|
6
|
+
export function init(options) {
|
|
7
|
+
try {
|
|
8
|
+
config.apiKey = options?.apiKey || process.env.LLMTRACER_API_KEY || '';
|
|
9
|
+
config.debug = options?.debug || false;
|
|
10
|
+
config.endpoint = options?.endpoint || 'https://us-central1-llmtracer-alt.cloudfunctions.net/v1Events';
|
|
11
|
+
config.enabled = Boolean(config.apiKey);
|
|
12
|
+
if (!config.enabled) {
|
|
13
|
+
if (config.debug)
|
|
14
|
+
console.log('[llmtracer] No API key found. Tracing disabled.');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
transport.start();
|
|
18
|
+
patcher.patchOpenAI(config.debug);
|
|
19
|
+
patcher.patchAnthropic(config.debug);
|
|
20
|
+
if (config.debug)
|
|
21
|
+
console.log('[llmtracer] Ready. Events \u2192 dashboard.llmtracer.com');
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
config.enabled = false;
|
|
25
|
+
if (config.debug)
|
|
26
|
+
console.log(`[llmtracer] init() failed: ${e}. Tracing disabled.`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function trace(tags, fn) {
|
|
30
|
+
try {
|
|
31
|
+
if (!config.enabled) {
|
|
32
|
+
return fn();
|
|
33
|
+
}
|
|
34
|
+
return context.run(tags, fn);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return fn();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function flush() {
|
|
41
|
+
try {
|
|
42
|
+
await transport.flush();
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// crash-proof: never throw
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// For testing only — not part of public API
|
|
49
|
+
export { patcher as _patcher, transport as _transport, config as _config };
|
|
50
|
+
// Default export for ESM: import llmtracer from 'llmtracer'
|
|
51
|
+
const llmtracer = { init, trace, flush, __version__ };
|
|
52
|
+
export default llmtracer;
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,MAAM,UAAU,IAAI,CAAC,OAAiE;IACpF,IAAI,CAAC;QACH,MAAM,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC;QACvE,MAAM,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,KAAK,CAAC;QACvC,MAAM,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,+DAA+D,CAAC;QACvG,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,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,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AACtD,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patcher.d.ts","sourceRoot":"","sources":["../../src/patcher.ts"],"names":[],"mappings":"AA4BA,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAyBhD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAyBnD;AAED,wBAAgB,UAAU,IAAI,IAAI,CAMjC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { makeAsyncWrapper } from './wrapper';
|
|
2
|
+
import { parseOpenAIResponse, wrapOpenAIStream } from './providers/openai';
|
|
3
|
+
import { parseAnthropicResponse, wrapAnthropicStream } from './providers/anthropic';
|
|
4
|
+
const originals = new Map();
|
|
5
|
+
function getPackageVersion(packageName) {
|
|
6
|
+
try {
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const entryPoint = require.resolve(packageName);
|
|
10
|
+
let dir = path.dirname(entryPoint);
|
|
11
|
+
while (dir !== path.dirname(dir)) {
|
|
12
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
13
|
+
try {
|
|
14
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
15
|
+
if (pkg.name === packageName)
|
|
16
|
+
return pkg.version || 'unknown';
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// no package.json here, keep walking up
|
|
20
|
+
}
|
|
21
|
+
dir = path.dirname(dir);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// ignore
|
|
26
|
+
}
|
|
27
|
+
return 'unknown';
|
|
28
|
+
}
|
|
29
|
+
export function patchOpenAI(debug) {
|
|
30
|
+
try {
|
|
31
|
+
const completionsModule = require('openai/resources/chat/completions');
|
|
32
|
+
const CompletionsProto = completionsModule.Completions?.prototype;
|
|
33
|
+
if (!CompletionsProto)
|
|
34
|
+
throw new Error('Completions prototype not found');
|
|
35
|
+
if (CompletionsProto._llmtracer_patched)
|
|
36
|
+
return;
|
|
37
|
+
const originalCreate = CompletionsProto.create;
|
|
38
|
+
CompletionsProto.create = makeAsyncWrapper(originalCreate, 'openai', parseOpenAIResponse, wrapOpenAIStream);
|
|
39
|
+
CompletionsProto._llmtracer_patched = true;
|
|
40
|
+
originals.set('openai.Completions.create', {
|
|
41
|
+
target: CompletionsProto,
|
|
42
|
+
methodName: 'create',
|
|
43
|
+
original: originalCreate,
|
|
44
|
+
});
|
|
45
|
+
if (debug) {
|
|
46
|
+
const version = getPackageVersion('openai');
|
|
47
|
+
console.log(`[llmtracer] \u2713 Patched openai (v${version})`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
if (debug)
|
|
52
|
+
console.log(`[llmtracer] \u2717 openai not found or patch failed: ${e}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function patchAnthropic(debug) {
|
|
56
|
+
try {
|
|
57
|
+
const messagesModule = require('@anthropic-ai/sdk/resources/messages');
|
|
58
|
+
const MessagesProto = messagesModule.Messages?.prototype;
|
|
59
|
+
if (!MessagesProto)
|
|
60
|
+
throw new Error('Messages prototype not found');
|
|
61
|
+
if (MessagesProto._llmtracer_patched)
|
|
62
|
+
return;
|
|
63
|
+
const originalCreate = MessagesProto.create;
|
|
64
|
+
MessagesProto.create = makeAsyncWrapper(originalCreate, 'anthropic', parseAnthropicResponse, wrapAnthropicStream);
|
|
65
|
+
MessagesProto._llmtracer_patched = true;
|
|
66
|
+
originals.set('anthropic.Messages.create', {
|
|
67
|
+
target: MessagesProto,
|
|
68
|
+
methodName: 'create',
|
|
69
|
+
original: originalCreate,
|
|
70
|
+
});
|
|
71
|
+
if (debug) {
|
|
72
|
+
const version = getPackageVersion('@anthropic-ai/sdk');
|
|
73
|
+
console.log(`[llmtracer] \u2713 Patched anthropic (v${version})`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
if (debug)
|
|
78
|
+
console.log(`[llmtracer] \u2717 anthropic not found or patch failed: ${e}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function unpatchAll() {
|
|
82
|
+
for (const [, entry] of originals) {
|
|
83
|
+
entry.target[entry.methodName] = entry.original;
|
|
84
|
+
delete entry.target._llmtracer_patched;
|
|
85
|
+
}
|
|
86
|
+
originals.clear();
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=patcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patcher.js","sourceRoot":"","sources":["../../src/patcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEpF,MAAM,SAAS,GAAyE,IAAI,GAAG,EAAE,CAAC;AAElG,SAAS,iBAAiB,CAAC,WAAmB;IAC5C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,OAAO,GAAG,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YAC/C,IAAI,CAAC;gBACH,MAAM,GAAG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;QAChD,OAAO,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC;IACzC,CAAC;IACD,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ContextData, ResponseData } from '../schema';
|
|
2
|
+
export declare function parseAnthropicResponse(result: any): ResponseData;
|
|
3
|
+
export declare function wrapAnthropicStream(result: any, context: ContextData, elapsedMs: number, args: any[]): any;
|
|
4
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGhF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,GAAG,GAAG,YAAY,CAQhE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CA4D1G"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { config } from '../config';
|
|
2
|
+
import { buildEvent, printCapture } from '../schema';
|
|
3
|
+
import * as transport from '../transport';
|
|
4
|
+
export function parseAnthropicResponse(result) {
|
|
5
|
+
return {
|
|
6
|
+
provider: 'anthropic',
|
|
7
|
+
model: result?.model || 'unknown',
|
|
8
|
+
input_tokens: result?.usage?.input_tokens || 0,
|
|
9
|
+
output_tokens: result?.usage?.output_tokens || 0,
|
|
10
|
+
status: result?.stop_reason ? 'success' : 'error',
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function wrapAnthropicStream(result, context, elapsedMs, args) {
|
|
14
|
+
let model = 'unknown';
|
|
15
|
+
let inputTokens = 0;
|
|
16
|
+
let outputTokens = 0;
|
|
17
|
+
function record() {
|
|
18
|
+
const event = buildEvent(context, {
|
|
19
|
+
provider: 'anthropic',
|
|
20
|
+
model,
|
|
21
|
+
input_tokens: inputTokens,
|
|
22
|
+
output_tokens: outputTokens,
|
|
23
|
+
status: 'success',
|
|
24
|
+
}, elapsedMs);
|
|
25
|
+
transport.enqueue(event);
|
|
26
|
+
if (config.debug)
|
|
27
|
+
printCapture(event);
|
|
28
|
+
}
|
|
29
|
+
return new Proxy(result, {
|
|
30
|
+
get(target, prop) {
|
|
31
|
+
if (prop === Symbol.asyncIterator) {
|
|
32
|
+
return function () {
|
|
33
|
+
const originalIterator = target[Symbol.asyncIterator]();
|
|
34
|
+
return {
|
|
35
|
+
async next() {
|
|
36
|
+
const iterResult = await originalIterator.next();
|
|
37
|
+
if (!iterResult.done) {
|
|
38
|
+
const event = iterResult.value;
|
|
39
|
+
// Anthropic stream events:
|
|
40
|
+
// - message_start: contains model and input token count
|
|
41
|
+
// - message_delta: contains output token count
|
|
42
|
+
// - content_block_delta: contains text deltas
|
|
43
|
+
if (event?.type === 'message_start' && event.message) {
|
|
44
|
+
model = event.message.model || model;
|
|
45
|
+
inputTokens = event.message.usage?.input_tokens || inputTokens;
|
|
46
|
+
}
|
|
47
|
+
if (event?.type === 'message_delta' && event.usage) {
|
|
48
|
+
outputTokens = event.usage.output_tokens || outputTokens;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (iterResult.done) {
|
|
52
|
+
try {
|
|
53
|
+
record();
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// swallow
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return iterResult;
|
|
60
|
+
},
|
|
61
|
+
return: originalIterator.return?.bind(originalIterator),
|
|
62
|
+
throw: originalIterator.throw?.bind(originalIterator),
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const value = target[prop];
|
|
67
|
+
if (typeof value === 'function') {
|
|
68
|
+
return value.bind(target);
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,YAAY,EAA6B,MAAM,WAAW,CAAC;AAChF,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,MAAM,UAAU,sBAAsB,CAAC,MAAW;IAChD,OAAO;QACL,QAAQ,EAAE,WAAW;QACrB,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,SAAS;QACjC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,IAAI,CAAC;QAC9C,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,IAAI,CAAC;QAChD,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;KAClD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAW,EAAE,OAAoB,EAAE,SAAiB,EAAE,IAAW;IACnG,IAAI,KAAK,GAAG,SAAS,CAAC;IACtB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,SAAS,MAAM;QACb,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE;YAChC,QAAQ,EAAE,WAAW;YACrB,KAAK;YACL,YAAY,EAAE,WAAW;YACzB,aAAa,EAAE,YAAY;YAC3B,MAAM,EAAE,SAAS;SAClB,EAAE,SAAS,CAAC,CAAC;QACd,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,MAAM,CAAC,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,IAAI,KAAK,CAAC,MAAM,EAA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AC;YACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAC3B,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ContextData, ResponseData } from '../schema';
|
|
2
|
+
export declare function parseOpenAIResponse(result: any): ResponseData;
|
|
3
|
+
export declare function wrapOpenAIStream(result: any, context: ContextData, elapsedMs: number, args: any[]): any;
|
|
4
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/providers/openai.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGhF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,YAAY,CAQ7D;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CA0DvG"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { config } from '../config';
|
|
2
|
+
import { buildEvent, printCapture } from '../schema';
|
|
3
|
+
import * as transport from '../transport';
|
|
4
|
+
export function parseOpenAIResponse(result) {
|
|
5
|
+
return {
|
|
6
|
+
provider: 'openai',
|
|
7
|
+
model: result?.model || 'unknown',
|
|
8
|
+
input_tokens: result?.usage?.prompt_tokens || 0,
|
|
9
|
+
output_tokens: result?.usage?.completion_tokens || 0,
|
|
10
|
+
status: 'success',
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function wrapOpenAIStream(result, context, elapsedMs, args) {
|
|
14
|
+
const chunks = [];
|
|
15
|
+
function record() {
|
|
16
|
+
// Look for usage in final chunks (OpenAI includes it when stream_options.include_usage = true)
|
|
17
|
+
let usage = null;
|
|
18
|
+
for (let i = chunks.length - 1; i >= 0; i--) {
|
|
19
|
+
if (chunks[i]?.usage) {
|
|
20
|
+
usage = chunks[i].usage;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const model = chunks[0]?.model || 'unknown';
|
|
25
|
+
const event = buildEvent(context, {
|
|
26
|
+
provider: 'openai',
|
|
27
|
+
model,
|
|
28
|
+
input_tokens: usage?.prompt_tokens || 0,
|
|
29
|
+
output_tokens: usage?.completion_tokens || 0,
|
|
30
|
+
status: 'success',
|
|
31
|
+
}, elapsedMs);
|
|
32
|
+
transport.enqueue(event);
|
|
33
|
+
if (config.debug)
|
|
34
|
+
printCapture(event);
|
|
35
|
+
}
|
|
36
|
+
// Create a proxy that wraps the async iterator while forwarding everything else
|
|
37
|
+
return new Proxy(result, {
|
|
38
|
+
get(target, prop) {
|
|
39
|
+
if (prop === Symbol.asyncIterator) {
|
|
40
|
+
return function () {
|
|
41
|
+
const originalIterator = target[Symbol.asyncIterator]();
|
|
42
|
+
return {
|
|
43
|
+
async next() {
|
|
44
|
+
const iterResult = await originalIterator.next();
|
|
45
|
+
if (!iterResult.done) {
|
|
46
|
+
chunks.push(iterResult.value);
|
|
47
|
+
}
|
|
48
|
+
if (iterResult.done) {
|
|
49
|
+
try {
|
|
50
|
+
record();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// swallow
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return iterResult;
|
|
57
|
+
},
|
|
58
|
+
return: originalIterator.return?.bind(originalIterator),
|
|
59
|
+
throw: originalIterator.throw?.bind(originalIterator),
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const value = target[prop];
|
|
64
|
+
if (typeof value === 'function') {
|
|
65
|
+
return value.bind(target);
|
|
66
|
+
}
|
|
67
|
+
return value;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,YAAY,EAA6B,MAAM,WAAW,CAAC;AAChF,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,MAAM,UAAU,mBAAmB,CAAC,MAAW;IAC7C,OAAO;QACL,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,SAAS;QACjC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,IAAI,CAAC;QAC/C,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,IAAI,CAAC;QACpD,MAAM,EAAE,SAAS;KAClB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAW,EAAE,OAAoB,EAAE,SAAiB,EAAE,IAAW;IAChG,MAAM,MAAM,GAAU,EAAE,CAA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BAChC,CAAC;4BACD,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;gCACpB,IAAI,CAAC;oCACH,MAAM,EAAE,CAAC;gCACX,CAAC;gCAAC,MAAM,CAAC;oCACP,UAAU;gCACZ,CAAC;4BACH,CAAC;4BACD,OAAO,UAAU,CAAC;wBACpB,CAAC;wBACD,MAAM,EAAE,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC;wBACvD,KAAK,EAAE,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC;qBACtD,CAAC;gBACJ,CAAC,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAC3B,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TraceContext } from './context';
|
|
2
|
+
import { getCallerInfo } from './caller';
|
|
3
|
+
export interface ContextData {
|
|
4
|
+
context: TraceContext | undefined;
|
|
5
|
+
caller: ReturnType<typeof getCallerInfo>;
|
|
6
|
+
provider: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ResponseData {
|
|
9
|
+
provider: string;
|
|
10
|
+
model: string;
|
|
11
|
+
input_tokens: number;
|
|
12
|
+
output_tokens: number;
|
|
13
|
+
status: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildContext(provider: string, args: any[]): ContextData;
|
|
16
|
+
export declare function buildEvent(contextData: ContextData, responseData: ResponseData, latencyMs: number): Record<string, any>;
|
|
17
|
+
export declare function printCapture(event: Record<string, any>): void;
|
|
18
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAc,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKzC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,YAAY,GAAG,SAAS,CAAC;IAClC,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAMvE;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAuBvH;AAmCD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAyB7D"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import { getCurrent } from './context';
|
|
3
|
+
import { getCallerInfo } from './caller';
|
|
4
|
+
const SDK_VERSION = '2.0.0';
|
|
5
|
+
const SDK_LANGUAGE = 'typescript';
|
|
6
|
+
export function buildContext(provider, args) {
|
|
7
|
+
return {
|
|
8
|
+
context: getCurrent(),
|
|
9
|
+
caller: getCallerInfo(),
|
|
10
|
+
provider,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function buildEvent(contextData, responseData, latencyMs) {
|
|
14
|
+
const event = {
|
|
15
|
+
event_id: randomUUID(),
|
|
16
|
+
timestamp: new Date().toISOString(),
|
|
17
|
+
latency_ms: latencyMs,
|
|
18
|
+
sdk_version: SDK_VERSION,
|
|
19
|
+
sdk_language: SDK_LANGUAGE,
|
|
20
|
+
...responseData,
|
|
21
|
+
...contextData.caller,
|
|
22
|
+
};
|
|
23
|
+
if (contextData.context) {
|
|
24
|
+
event.trace_id = contextData.context.traceId;
|
|
25
|
+
event.span_id = contextData.context.spanId;
|
|
26
|
+
if (contextData.context.parentSpanId) {
|
|
27
|
+
event.parent_span_id = contextData.context.parentSpanId;
|
|
28
|
+
}
|
|
29
|
+
if (contextData.context.tags && Object.keys(contextData.context.tags).length > 0) {
|
|
30
|
+
event.tags = { ...contextData.context.tags };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return event;
|
|
34
|
+
}
|
|
35
|
+
// Cost lookup table for debug printing (per 1M tokens)
|
|
36
|
+
const COST_PER_M = {
|
|
37
|
+
'gpt-4o': [2.5, 10],
|
|
38
|
+
'gpt-4o-mini': [0.15, 0.6],
|
|
39
|
+
'gpt-4-turbo': [10, 30],
|
|
40
|
+
'gpt-4': [30, 60],
|
|
41
|
+
'gpt-3.5-turbo': [0.5, 1.5],
|
|
42
|
+
'o1': [15, 60],
|
|
43
|
+
'o1-mini': [3, 12],
|
|
44
|
+
'o3-mini': [1.1, 4.4],
|
|
45
|
+
'claude-3-5-sonnet': [3, 15],
|
|
46
|
+
'claude-3-5-haiku': [0.8, 4],
|
|
47
|
+
'claude-3-opus': [15, 75],
|
|
48
|
+
'claude-sonnet-4-5': [3, 15],
|
|
49
|
+
'claude-haiku-4-5': [0.8, 4],
|
|
50
|
+
'claude-opus-4-6': [15, 75],
|
|
51
|
+
};
|
|
52
|
+
function estimateCost(model, inputTokens, outputTokens) {
|
|
53
|
+
// Try exact match first, then prefix match
|
|
54
|
+
let rates = COST_PER_M[model];
|
|
55
|
+
if (!rates) {
|
|
56
|
+
for (const key of Object.keys(COST_PER_M)) {
|
|
57
|
+
if (model.startsWith(key)) {
|
|
58
|
+
rates = COST_PER_M[key];
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!rates)
|
|
64
|
+
return 0;
|
|
65
|
+
return (inputTokens * rates[0] + outputTokens * rates[1]) / 1000000;
|
|
66
|
+
}
|
|
67
|
+
export function printCapture(event) {
|
|
68
|
+
const model = event.model || 'unknown';
|
|
69
|
+
const input = (event.input_tokens || 0).toLocaleString();
|
|
70
|
+
const output = (event.output_tokens || 0).toLocaleString();
|
|
71
|
+
const cost = estimateCost(model, event.input_tokens || 0, event.output_tokens || 0);
|
|
72
|
+
const latency = ((event.latency_ms || 0) / 1000).toFixed(1);
|
|
73
|
+
let file = '';
|
|
74
|
+
if (event.caller_file) {
|
|
75
|
+
const parts = event.caller_file.replace(/\\/g, '/').split('/');
|
|
76
|
+
const filename = parts[parts.length - 1];
|
|
77
|
+
file = event.caller_line ? `${filename}:${event.caller_line}` : filename;
|
|
78
|
+
}
|
|
79
|
+
let traceInfo = '';
|
|
80
|
+
if (event.tags) {
|
|
81
|
+
const firstValue = Object.values(event.tags)[0];
|
|
82
|
+
if (firstValue)
|
|
83
|
+
traceInfo = ` trace:${firstValue}`;
|
|
84
|
+
}
|
|
85
|
+
const costStr = cost > 0 ? ` $${cost.toFixed(4)}` : '';
|
|
86
|
+
console.log(`[llmtracer] ${event.provider}/${model} ${input}\u2192${output} tokens${costStr} ${latency}s (${file})${traceInfo}`);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAgB,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,GAAG,OAAO,CAAC;AAC5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CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAExD,OAAO,CAAC,GAAG,CACT,eAAe,KAAK,CAAC,QAAQ,IAAI,KAAK,KAAK,KAAK,SAAS,MAAM,UAAU,OAAO,KAAK,OAAO,OAAO,IAAI,IAAI,SAAS,EAAE,CACvH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function start(): void;
|
|
2
|
+
export declare function enqueue(event: Record<string, any>): void;
|
|
3
|
+
export declare function flush(): Promise<void>;
|
|
4
|
+
export declare function stop(): void;
|
|
5
|
+
export declare function getQueueLength(): number;
|
|
6
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAMA,wBAAgB,KAAK,IAAI,IAAI,CAG5B;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAWxD;AAED,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3C;AAED,wBAAgB,IAAI,IAAI,IAAI,CAO3B;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { config } from './config';
|
|
2
|
+
let eventQueue = [];
|
|
3
|
+
let flushTimer = null;
|
|
4
|
+
let firstBatch = true;
|
|
5
|
+
export function start() {
|
|
6
|
+
// Reset state for fresh start
|
|
7
|
+
firstBatch = true;
|
|
8
|
+
}
|
|
9
|
+
export function enqueue(event) {
|
|
10
|
+
eventQueue.push(event);
|
|
11
|
+
if (firstBatch) {
|
|
12
|
+
firstBatch = false;
|
|
13
|
+
// Flush immediately on first event
|
|
14
|
+
setImmediate(() => doFlush());
|
|
15
|
+
// Start regular 5s interval
|
|
16
|
+
flushTimer = setInterval(() => doFlush(), 5000);
|
|
17
|
+
flushTimer.unref();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function flush() {
|
|
21
|
+
await doFlush();
|
|
22
|
+
}
|
|
23
|
+
export function stop() {
|
|
24
|
+
if (flushTimer) {
|
|
25
|
+
clearInterval(flushTimer);
|
|
26
|
+
flushTimer = null;
|
|
27
|
+
}
|
|
28
|
+
eventQueue = [];
|
|
29
|
+
firstBatch = true;
|
|
30
|
+
}
|
|
31
|
+
export function getQueueLength() {
|
|
32
|
+
return eventQueue.length;
|
|
33
|
+
}
|
|
34
|
+
async function doFlush() {
|
|
35
|
+
if (eventQueue.length === 0)
|
|
36
|
+
return;
|
|
37
|
+
const events = eventQueue.splice(0);
|
|
38
|
+
try {
|
|
39
|
+
const payload = JSON.stringify({ events });
|
|
40
|
+
const response = await fetch(config.endpoint, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: {
|
|
43
|
+
'Content-Type': 'application/json',
|
|
44
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
45
|
+
},
|
|
46
|
+
body: payload,
|
|
47
|
+
signal: AbortSignal.timeout(10000),
|
|
48
|
+
});
|
|
49
|
+
if (config.debug) {
|
|
50
|
+
console.log(`[llmtracer] Flushed ${events.length} events \u2192 ${response.status}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
if (config.debug) {
|
|
55
|
+
console.log(`[llmtracer] Flush failed: ${e}`);
|
|
56
|
+
}
|
|
57
|
+
// Re-queue up to 100 events for retry
|
|
58
|
+
const requeue = events.slice(0, 100);
|
|
59
|
+
eventQueue.unshift(...requeue);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,IAAI,UAAU,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,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,eAAe,EAAE,UAAU,MAAM,CAAC,MAAM,EAAE;aAC3C;YACD,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;SACnC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,uBAAuB,MAAM,CAAC,MAAM,kBAAkB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,sCAAsC;QACtC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACrC,UAAU,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ResponseData } from './schema';
|
|
2
|
+
export declare function makeAsyncWrapper(originalFn: Function, provider: string, parseResponseFn: (result: any) => ResponseData, wrapStreamFn: (result: any, context: any, elapsedMs: number, args: any[]) => any): Function;
|
|
3
|
+
//# sourceMappingURL=wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/wrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAA0C,YAAY,EAAE,MAAM,UAAU,CAAC;AAGhF,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,QAAQ,EACpB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,YAAY,EAC9C,YAAY,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAC/E,QAAQ,CAgDV"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { config } from './config';
|
|
2
|
+
import { buildContext, buildEvent, printCapture } from './schema';
|
|
3
|
+
import * as transport from './transport';
|
|
4
|
+
export function makeAsyncWrapper(originalFn, provider, parseResponseFn, wrapStreamFn) {
|
|
5
|
+
const wrapped = async function (...args) {
|
|
6
|
+
if (!config.enabled) {
|
|
7
|
+
return originalFn.apply(this, args);
|
|
8
|
+
}
|
|
9
|
+
// 1. Capture context (safe, no-throw)
|
|
10
|
+
let context = null;
|
|
11
|
+
try {
|
|
12
|
+
context = buildContext(provider, args);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// context stays null
|
|
16
|
+
}
|
|
17
|
+
// 2. Detect streaming
|
|
18
|
+
const isStream = args[0]?.stream === true;
|
|
19
|
+
// 3. ALWAYS call original — never blocked, never modified
|
|
20
|
+
const start = performance.now();
|
|
21
|
+
const result = await originalFn.apply(this, args);
|
|
22
|
+
const elapsedMs = Math.round(performance.now() - start);
|
|
23
|
+
// 4. Handle streaming result
|
|
24
|
+
if (isStream && context) {
|
|
25
|
+
try {
|
|
26
|
+
return wrapStreamFn(result, context, elapsedMs, args);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// 5. Handle non-streaming result
|
|
33
|
+
if (context) {
|
|
34
|
+
try {
|
|
35
|
+
const event = buildEvent(context, parseResponseFn(result), elapsedMs);
|
|
36
|
+
transport.enqueue(event);
|
|
37
|
+
if (config.debug)
|
|
38
|
+
printCapture(event);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// swallow silently
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
// Preserve function name for debugging
|
|
47
|
+
Object.defineProperty(wrapped, 'name', { value: originalFn.name });
|
|
48
|
+
return wrapped;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AAChF,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,gBAAgB,CAC9B,UAAoB,EACpB,QAAgB,EAChB,eAA8C,EAC9C,YAAgF;IAEhF,MAAM,OAAO,GAAG,KAAK,WAAsB,GAAG,IAAW;QACvD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC;QAED,sCAAsC;QACtC,IAAI,OAAO,GAAQ,IAAI,CAAC;QACxB,IAAI,CAAC;YACH,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACP,qBAAqB;QACvB,CAAC;QAED,sBAAsB;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;QAE1C,0DAA0D;QAC1D,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;QAExD,6BAA6B;QAC7B,IAAI,QAAQ,IAAI,OAAO,EAAE,CA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