@paid-ai/paid-node 1.0.1-alpha8 → 1.0.1-alpha9
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/Client.js +2 -2
- package/dist/cjs/tracing/aiSdkSpanProcessor.js +0 -3
- package/dist/cjs/tracing/autoInstrumentation.d.ts +24 -7
- package/dist/cjs/tracing/autoInstrumentation.js +68 -38
- package/dist/cjs/tracing/index.d.ts +1 -2
- package/dist/cjs/tracing/index.js +1 -3
- package/dist/cjs/tracing/tracing.d.ts +0 -2
- package/dist/cjs/tracing/tracing.js +40 -45
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/tracing/aiSdkSpanProcessor.mjs +0 -3
- package/dist/esm/tracing/autoInstrumentation.d.mts +24 -7
- package/dist/esm/tracing/autoInstrumentation.mjs +67 -38
- package/dist/esm/tracing/index.d.mts +1 -2
- package/dist/esm/tracing/index.mjs +1 -2
- package/dist/esm/tracing/tracing.d.mts +0 -2
- package/dist/esm/tracing/tracing.mjs +41 -43
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +216 -201
package/dist/cjs/Client.js
CHANGED
|
@@ -48,8 +48,8 @@ class PaidClient {
|
|
|
48
48
|
this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
|
|
49
49
|
"X-Fern-Language": "JavaScript",
|
|
50
50
|
"X-Fern-SDK-Name": "@paid-ai/paid-node",
|
|
51
|
-
"X-Fern-SDK-Version": "1.0.1-
|
|
52
|
-
"User-Agent": "@paid-ai/paid-node/1.0.1-
|
|
51
|
+
"X-Fern-SDK-Version": "1.0.1-alpha9",
|
|
52
|
+
"User-Agent": "@paid-ai/paid-node/1.0.1-alpha9",
|
|
53
53
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
54
54
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
55
55
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
anthropic?: typeof anthropic.Anthropic;
|
|
1
|
+
export type SupportedLibrary = "openai" | "anthropic";
|
|
2
|
+
export interface InstrumentModules {
|
|
3
|
+
openai?: any;
|
|
4
|
+
anthropic?: any;
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Auto-instrument supported libraries using require-in-the-middle hooks.
|
|
8
|
+
* Works in plain Node.js (CJS). Does NOT work in bundled environments (Next.js/webpack).
|
|
9
|
+
* For bundled environments, use {@link paidAutoInstrumentModules} instead.
|
|
10
|
+
*
|
|
11
|
+
* @param libraries - Optional list of libraries to instrument. If omitted, all available libraries are instrumented.
|
|
12
|
+
*/
|
|
13
|
+
export declare function paidAutoInstrument(libraries?: SupportedLibrary[]): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Instrument supported libraries by directly patching the provided module references.
|
|
16
|
+
* Required for bundled environments (Next.js/webpack) where require-in-the-middle hooks don't work.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import OpenAI from "openai";
|
|
21
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
22
|
+
* await paidAutoInstrumentModules({ openAI: OpenAI, anthropic: Anthropic });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function paidAutoInstrumentModules(modules: InstrumentModules): Promise<void>;
|
|
@@ -43,73 +43,103 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.paidAutoInstrument = paidAutoInstrument;
|
|
46
|
-
|
|
46
|
+
exports.paidAutoInstrumentModules = paidAutoInstrumentModules;
|
|
47
47
|
const tracing_js_1 = require("./tracing.js");
|
|
48
48
|
let IS_INITIALIZED = false;
|
|
49
|
-
const getInstrumentations = (tracerProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const getInstrumentations = (tracerProvider, libraries) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
50
|
const instrumentations = [];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
instrumentations.push(new OpenAIInstrumentation({ tracerProvider }));
|
|
54
|
-
}
|
|
55
|
-
catch (_a) {
|
|
56
|
-
tracing_js_1.logger.debug("OpenAI instrumentation not available - openai package not installed");
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
const { AnthropicInstrumentation } = yield Promise.resolve().then(() => __importStar(require("@arizeai/openinference-instrumentation-anthropic")));
|
|
60
|
-
instrumentations.push(new AnthropicInstrumentation({ tracerProvider }));
|
|
61
|
-
}
|
|
62
|
-
catch (_b) {
|
|
63
|
-
tracing_js_1.logger.debug("Anthropic instrumentation not available - @anthropic-ai/sdk package not installed");
|
|
64
|
-
}
|
|
65
|
-
return instrumentations;
|
|
66
|
-
});
|
|
67
|
-
const getManualInstrumentations = (tracerProvider, libraries) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
-
const instrumentations = [];
|
|
69
|
-
if (libraries.openai) {
|
|
51
|
+
const shouldInstrument = (lib) => !libraries || libraries.includes(lib);
|
|
52
|
+
if (shouldInstrument("openai")) {
|
|
70
53
|
try {
|
|
71
54
|
const { OpenAIInstrumentation } = yield Promise.resolve().then(() => __importStar(require("@arizeai/openinference-instrumentation-openai")));
|
|
72
|
-
|
|
73
|
-
instrumentations.push(openaiInstrumentation);
|
|
74
|
-
openaiInstrumentation.manuallyInstrument(libraries.openai);
|
|
55
|
+
instrumentations.push(new OpenAIInstrumentation({ tracerProvider }));
|
|
75
56
|
}
|
|
76
57
|
catch (_a) {
|
|
77
|
-
|
|
58
|
+
console.debug("OpenAI instrumentation not available - openai package not installed");
|
|
78
59
|
}
|
|
79
60
|
}
|
|
80
|
-
if (
|
|
61
|
+
if (shouldInstrument("anthropic")) {
|
|
81
62
|
try {
|
|
82
63
|
const { AnthropicInstrumentation } = yield Promise.resolve().then(() => __importStar(require("@arizeai/openinference-instrumentation-anthropic")));
|
|
83
|
-
|
|
84
|
-
instrumentations.push(anthropicInstrumentation);
|
|
85
|
-
anthropicInstrumentation.manuallyInstrument(libraries.anthropic);
|
|
64
|
+
instrumentations.push(new AnthropicInstrumentation({ tracerProvider }));
|
|
86
65
|
}
|
|
87
66
|
catch (_b) {
|
|
88
|
-
|
|
67
|
+
console.debug("Anthropic instrumentation not available - @anthropic-ai/sdk package not installed");
|
|
89
68
|
}
|
|
90
69
|
}
|
|
91
70
|
return instrumentations;
|
|
92
71
|
});
|
|
72
|
+
/**
|
|
73
|
+
* Auto-instrument supported libraries using require-in-the-middle hooks.
|
|
74
|
+
* Works in plain Node.js (CJS). Does NOT work in bundled environments (Next.js/webpack).
|
|
75
|
+
* For bundled environments, use {@link paidAutoInstrumentModules} instead.
|
|
76
|
+
*
|
|
77
|
+
* @param libraries - Optional list of libraries to instrument. If omitted, all available libraries are instrumented.
|
|
78
|
+
*/
|
|
93
79
|
function paidAutoInstrument(libraries) {
|
|
94
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
81
|
if (IS_INITIALIZED) {
|
|
96
|
-
|
|
82
|
+
console.info("Auto instrumentation is already initialized");
|
|
97
83
|
return;
|
|
98
84
|
}
|
|
99
|
-
(0, tracing_js_1.initializeTracing)();
|
|
85
|
+
(0, tracing_js_1.initializeTracing)();
|
|
100
86
|
const tracerProvider = (0, tracing_js_1.getPaidTracerProvider)();
|
|
101
87
|
if (!tracerProvider) {
|
|
102
|
-
|
|
88
|
+
console.error("Could not get tracer provider, make sure you ran 'initializeTracing()' or check your environment variables");
|
|
103
89
|
return;
|
|
104
90
|
}
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
: yield getInstrumentations(tracerProvider);
|
|
109
|
-
(0, instrumentation_1.registerInstrumentations)({
|
|
91
|
+
const instrumentations = yield getInstrumentations(tracerProvider, libraries);
|
|
92
|
+
const { registerInstrumentations } = yield Promise.resolve().then(() => __importStar(require("@opentelemetry/instrumentation")));
|
|
93
|
+
registerInstrumentations({
|
|
110
94
|
instrumentations,
|
|
111
95
|
tracerProvider,
|
|
112
96
|
});
|
|
113
97
|
IS_INITIALIZED = true;
|
|
114
98
|
});
|
|
115
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Instrument supported libraries by directly patching the provided module references.
|
|
102
|
+
* Required for bundled environments (Next.js/webpack) where require-in-the-middle hooks don't work.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* import OpenAI from "openai";
|
|
107
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
108
|
+
* await paidAutoInstrumentModules({ openAI: OpenAI, anthropic: Anthropic });
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
function paidAutoInstrumentModules(modules) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
if (IS_INITIALIZED) {
|
|
114
|
+
console.info("Auto instrumentation is already initialized");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
(0, tracing_js_1.initializeTracing)();
|
|
118
|
+
const tracerProvider = (0, tracing_js_1.getPaidTracerProvider)();
|
|
119
|
+
if (!tracerProvider) {
|
|
120
|
+
console.error("Could not get tracer provider, make sure you ran 'initializeTracing()' or check your environment variables");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (modules.openai) {
|
|
124
|
+
try {
|
|
125
|
+
const { OpenAIInstrumentation } = yield Promise.resolve().then(() => __importStar(require("@arizeai/openinference-instrumentation-openai")));
|
|
126
|
+
const inst = new OpenAIInstrumentation({ tracerProvider });
|
|
127
|
+
inst.manuallyInstrument(modules.openai);
|
|
128
|
+
}
|
|
129
|
+
catch (_a) {
|
|
130
|
+
console.debug("OpenAI instrumentation not available");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (modules.anthropic) {
|
|
134
|
+
try {
|
|
135
|
+
const { AnthropicInstrumentation } = yield Promise.resolve().then(() => __importStar(require("@arizeai/openinference-instrumentation-anthropic")));
|
|
136
|
+
const inst = new AnthropicInstrumentation({ tracerProvider });
|
|
137
|
+
inst.manuallyInstrument(modules.anthropic);
|
|
138
|
+
}
|
|
139
|
+
catch (_b) {
|
|
140
|
+
console.debug("Anthropic instrumentation not available");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
IS_INITIALIZED = true;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace } from "./tracing.js";
|
|
2
|
-
import { paidAutoInstrument } from "./autoInstrumentation.js";
|
|
3
2
|
import { signal } from "./signal.js";
|
|
4
3
|
import { AISDKSpanProcessor } from "./aiSdkSpanProcessor.js";
|
|
5
|
-
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal,
|
|
4
|
+
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal, AISDKSpanProcessor };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AISDKSpanProcessor = exports.
|
|
3
|
+
exports.AISDKSpanProcessor = exports.signal = exports.trace = exports.initializeTracing = exports.getPaidTracerProvider = exports.getPaidTracer = void 0;
|
|
4
4
|
const tracing_js_1 = require("./tracing.js");
|
|
5
5
|
Object.defineProperty(exports, "getPaidTracer", { enumerable: true, get: function () { return tracing_js_1.getPaidTracer; } });
|
|
6
6
|
Object.defineProperty(exports, "getPaidTracerProvider", { enumerable: true, get: function () { return tracing_js_1.getPaidTracerProvider; } });
|
|
7
7
|
Object.defineProperty(exports, "initializeTracing", { enumerable: true, get: function () { return tracing_js_1.initializeTracing; } });
|
|
8
8
|
Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return tracing_js_1.trace; } });
|
|
9
|
-
const autoInstrumentation_js_1 = require("./autoInstrumentation.js");
|
|
10
|
-
Object.defineProperty(exports, "paidAutoInstrument", { enumerable: true, get: function () { return autoInstrumentation_js_1.paidAutoInstrument; } });
|
|
11
9
|
const signal_js_1 = require("./signal.js");
|
|
12
10
|
Object.defineProperty(exports, "signal", { enumerable: true, get: function () { return signal_js_1.signal; } });
|
|
13
11
|
const aiSdkSpanProcessor_js_1 = require("./aiSdkSpanProcessor.js");
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Tracer } from "@opentelemetry/api";
|
|
2
2
|
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
3
|
-
import winston from "winston";
|
|
4
|
-
export declare const logger: winston.Logger;
|
|
5
3
|
export declare function getToken(): string | undefined;
|
|
6
4
|
export declare function getPaidTracerProvider(): NodeTracerProvider | undefined;
|
|
7
5
|
export declare function getPaidTracer(): Tracer | undefined;
|
|
@@ -8,32 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.logger = void 0;
|
|
16
12
|
exports.getToken = getToken;
|
|
17
13
|
exports.getPaidTracerProvider = getPaidTracerProvider;
|
|
18
14
|
exports.getPaidTracer = getPaidTracer;
|
|
19
15
|
exports.initializeTracing = initializeTracing;
|
|
20
16
|
exports.trace = trace;
|
|
21
17
|
const api_1 = require("@opentelemetry/api");
|
|
18
|
+
const context_async_hooks_1 = require("@opentelemetry/context-async-hooks");
|
|
22
19
|
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
|
|
23
20
|
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
24
|
-
const winston_1 = __importDefault(require("winston"));
|
|
25
21
|
const tracingContext_js_1 = require("./tracingContext.js");
|
|
26
22
|
const spanProcessor_js_1 = require("./spanProcessor.js");
|
|
27
23
|
const aiSdkSpanProcessor_js_1 = require("./aiSdkSpanProcessor.js");
|
|
28
|
-
exports.logger = winston_1.default.createLogger({
|
|
29
|
-
level: "silent", // Default to 'silent' to avoid logging unless set via environment variable
|
|
30
|
-
format: winston_1.default.format.simple(),
|
|
31
|
-
transports: [new winston_1.default.transports.Console()],
|
|
32
|
-
});
|
|
33
|
-
const logLevel = process.env.PAID_LOG_LEVEL;
|
|
34
|
-
if (logLevel) {
|
|
35
|
-
exports.logger.level = logLevel;
|
|
36
|
-
}
|
|
37
24
|
const DEFAULT_COLLECTOR_ENDPOINT = process.env["PAID_OTEL_COLLECTOR_ENDPOINT"] || "https://collector.agentpaid.io:4318/v1/traces";
|
|
38
25
|
let paidApiToken = undefined;
|
|
39
26
|
function getToken() {
|
|
@@ -57,26 +44,26 @@ const setupGracefulShutdown = (shuttable) => {
|
|
|
57
44
|
_isShuttingDown = true;
|
|
58
45
|
shuttable
|
|
59
46
|
.shutdown()
|
|
60
|
-
.then(() =>
|
|
61
|
-
.catch((error) =>
|
|
47
|
+
.then(() => console.info(`Paid tracing SDK shut down from signal: ${signal}`))
|
|
48
|
+
.catch((error) => console.error(`Error shutting down Paid tracing SDK ${error}`));
|
|
62
49
|
});
|
|
63
50
|
});
|
|
64
51
|
};
|
|
65
52
|
function initializeTracing(apiKey, collectorEndpoint) {
|
|
66
53
|
const paidEnabled = (process.env.PAID_ENABLED || "true") !== "false";
|
|
67
54
|
if (!paidEnabled) {
|
|
68
|
-
|
|
55
|
+
console.info("Paid tracing is disabled via PAID_ENABLED environment variable");
|
|
69
56
|
return;
|
|
70
57
|
}
|
|
71
58
|
const token = getToken();
|
|
72
59
|
if (!!token) {
|
|
73
|
-
|
|
60
|
+
console.info("Tracing is already initialized - skipping re-intialization");
|
|
74
61
|
return;
|
|
75
62
|
}
|
|
76
63
|
if (!apiKey) {
|
|
77
64
|
const envKey = process.env.PAID_API_KEY;
|
|
78
65
|
if (!envKey) {
|
|
79
|
-
|
|
66
|
+
console.error("API key must be provided via PAID_API_KEY environment variable");
|
|
80
67
|
return;
|
|
81
68
|
}
|
|
82
69
|
paidApiToken = envKey;
|
|
@@ -92,11 +79,17 @@ function initializeTracing(apiKey, collectorEndpoint) {
|
|
|
92
79
|
paidTracerProvider = new sdk_trace_node_1.NodeTracerProvider({
|
|
93
80
|
spanProcessors: [new spanProcessor_js_1.PaidSpanProcessor(), new aiSdkSpanProcessor_js_1.AISDKSpanProcessor(), spanProcessor],
|
|
94
81
|
});
|
|
95
|
-
//
|
|
96
|
-
// This
|
|
82
|
+
// Set up context propagation without registering the provider globally.
|
|
83
|
+
// This gives us async parent-child linking via AsyncLocalStorage
|
|
84
|
+
// without polluting the global trace provider.
|
|
85
|
+
const contextManager = new context_async_hooks_1.AsyncLocalStorageContextManager();
|
|
86
|
+
contextManager.enable();
|
|
87
|
+
if (!api_1.context.setGlobalContextManager(contextManager)) {
|
|
88
|
+
contextManager.disable();
|
|
89
|
+
}
|
|
97
90
|
paidTracer = paidTracerProvider.getTracer("paid.node");
|
|
98
91
|
setupGracefulShutdown(spanProcessor);
|
|
99
|
-
|
|
92
|
+
console.info(`Paid tracing SDK initialized with collector endpoint: ${url}`);
|
|
100
93
|
}
|
|
101
94
|
function trace(options, fn, ...args) {
|
|
102
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -104,32 +97,34 @@ function trace(options, fn, ...args) {
|
|
|
104
97
|
const tracer = getPaidTracer();
|
|
105
98
|
if (!token || !tracer) {
|
|
106
99
|
// don't throw, tracing should not crash user app.
|
|
107
|
-
|
|
100
|
+
console.error("Paid tracing is not initialized. Make sure to call initializeTracing() first.");
|
|
108
101
|
return yield fn(...args);
|
|
109
102
|
}
|
|
110
103
|
const { externalCustomerId, externalProductId: externalAgentId, storePrompt, metadata } = options;
|
|
111
|
-
return yield
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
104
|
+
return yield (0, tracingContext_js_1.runWithTracingContext)({
|
|
105
|
+
externalCustomerId,
|
|
106
|
+
externalProductId: externalAgentId,
|
|
107
|
+
storePrompt,
|
|
108
|
+
metadata,
|
|
109
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
return yield tracer.startActiveSpan("parent_span", (span) => __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
try {
|
|
112
|
+
const res = yield fn(...args);
|
|
113
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
span.setStatus({
|
|
118
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
119
|
+
message: error.message,
|
|
120
|
+
});
|
|
121
|
+
span.recordException(error);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
span.end();
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
133
128
|
}));
|
|
134
129
|
});
|
|
135
130
|
}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.1-
|
|
1
|
+
export declare const SDK_VERSION = "1.0.1-alpha9";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/Client.mjs
CHANGED
|
@@ -12,8 +12,8 @@ export class PaidClient {
|
|
|
12
12
|
this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
|
|
13
13
|
"X-Fern-Language": "JavaScript",
|
|
14
14
|
"X-Fern-SDK-Name": "@paid-ai/paid-node",
|
|
15
|
-
"X-Fern-SDK-Version": "1.0.1-
|
|
16
|
-
"User-Agent": "@paid-ai/paid-node/1.0.1-
|
|
15
|
+
"X-Fern-SDK-Version": "1.0.1-alpha9",
|
|
16
|
+
"User-Agent": "@paid-ai/paid-node/1.0.1-alpha9",
|
|
17
17
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
18
18
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
19
19
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -83,9 +83,6 @@ export class AISDKSpanProcessor {
|
|
|
83
83
|
if (!finalName.startsWith("paid.trace.")) {
|
|
84
84
|
finalName = `paid.trace.${finalName}`;
|
|
85
85
|
}
|
|
86
|
-
if (!finalName.endsWith(".signal")) {
|
|
87
|
-
finalName = `${finalName}.signal`;
|
|
88
|
-
}
|
|
89
86
|
span.name = finalName;
|
|
90
87
|
}
|
|
91
88
|
shutdown() {
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
anthropic?: typeof anthropic.Anthropic;
|
|
1
|
+
export type SupportedLibrary = "openai" | "anthropic";
|
|
2
|
+
export interface InstrumentModules {
|
|
3
|
+
openai?: any;
|
|
4
|
+
anthropic?: any;
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Auto-instrument supported libraries using require-in-the-middle hooks.
|
|
8
|
+
* Works in plain Node.js (CJS). Does NOT work in bundled environments (Next.js/webpack).
|
|
9
|
+
* For bundled environments, use {@link paidAutoInstrumentModules} instead.
|
|
10
|
+
*
|
|
11
|
+
* @param libraries - Optional list of libraries to instrument. If omitted, all available libraries are instrumented.
|
|
12
|
+
*/
|
|
13
|
+
export declare function paidAutoInstrument(libraries?: SupportedLibrary[]): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Instrument supported libraries by directly patching the provided module references.
|
|
16
|
+
* Required for bundled environments (Next.js/webpack) where require-in-the-middle hooks don't work.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import OpenAI from "openai";
|
|
21
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
22
|
+
* await paidAutoInstrumentModules({ openAI: OpenAI, anthropic: Anthropic });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function paidAutoInstrumentModules(modules: InstrumentModules): Promise<void>;
|
|
@@ -7,69 +7,52 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
11
|
-
import { getPaidTracerProvider, initializeTracing, logger } from "./tracing.mjs";
|
|
10
|
+
import { getPaidTracerProvider, initializeTracing } from "./tracing.mjs";
|
|
12
11
|
let IS_INITIALIZED = false;
|
|
13
|
-
const getInstrumentations = (tracerProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const getInstrumentations = (tracerProvider, libraries) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
13
|
const instrumentations = [];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
instrumentations.push(new OpenAIInstrumentation({ tracerProvider }));
|
|
18
|
-
}
|
|
19
|
-
catch (_a) {
|
|
20
|
-
logger.debug("OpenAI instrumentation not available - openai package not installed");
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const { AnthropicInstrumentation } = yield import("@arizeai/openinference-instrumentation-anthropic");
|
|
24
|
-
instrumentations.push(new AnthropicInstrumentation({ tracerProvider }));
|
|
25
|
-
}
|
|
26
|
-
catch (_b) {
|
|
27
|
-
logger.debug("Anthropic instrumentation not available - @anthropic-ai/sdk package not installed");
|
|
28
|
-
}
|
|
29
|
-
return instrumentations;
|
|
30
|
-
});
|
|
31
|
-
const getManualInstrumentations = (tracerProvider, libraries) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
const instrumentations = [];
|
|
33
|
-
if (libraries.openai) {
|
|
14
|
+
const shouldInstrument = (lib) => !libraries || libraries.includes(lib);
|
|
15
|
+
if (shouldInstrument("openai")) {
|
|
34
16
|
try {
|
|
35
17
|
const { OpenAIInstrumentation } = yield import("@arizeai/openinference-instrumentation-openai");
|
|
36
|
-
|
|
37
|
-
instrumentations.push(openaiInstrumentation);
|
|
38
|
-
openaiInstrumentation.manuallyInstrument(libraries.openai);
|
|
18
|
+
instrumentations.push(new OpenAIInstrumentation({ tracerProvider }));
|
|
39
19
|
}
|
|
40
20
|
catch (_a) {
|
|
41
|
-
|
|
21
|
+
console.debug("OpenAI instrumentation not available - openai package not installed");
|
|
42
22
|
}
|
|
43
23
|
}
|
|
44
|
-
if (
|
|
24
|
+
if (shouldInstrument("anthropic")) {
|
|
45
25
|
try {
|
|
46
26
|
const { AnthropicInstrumentation } = yield import("@arizeai/openinference-instrumentation-anthropic");
|
|
47
|
-
|
|
48
|
-
instrumentations.push(anthropicInstrumentation);
|
|
49
|
-
anthropicInstrumentation.manuallyInstrument(libraries.anthropic);
|
|
27
|
+
instrumentations.push(new AnthropicInstrumentation({ tracerProvider }));
|
|
50
28
|
}
|
|
51
29
|
catch (_b) {
|
|
52
|
-
|
|
30
|
+
console.debug("Anthropic instrumentation not available - @anthropic-ai/sdk package not installed");
|
|
53
31
|
}
|
|
54
32
|
}
|
|
55
33
|
return instrumentations;
|
|
56
34
|
});
|
|
35
|
+
/**
|
|
36
|
+
* Auto-instrument supported libraries using require-in-the-middle hooks.
|
|
37
|
+
* Works in plain Node.js (CJS). Does NOT work in bundled environments (Next.js/webpack).
|
|
38
|
+
* For bundled environments, use {@link paidAutoInstrumentModules} instead.
|
|
39
|
+
*
|
|
40
|
+
* @param libraries - Optional list of libraries to instrument. If omitted, all available libraries are instrumented.
|
|
41
|
+
*/
|
|
57
42
|
export function paidAutoInstrument(libraries) {
|
|
58
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
44
|
if (IS_INITIALIZED) {
|
|
60
|
-
|
|
45
|
+
console.info("Auto instrumentation is already initialized");
|
|
61
46
|
return;
|
|
62
47
|
}
|
|
63
|
-
initializeTracing();
|
|
48
|
+
initializeTracing();
|
|
64
49
|
const tracerProvider = getPaidTracerProvider();
|
|
65
50
|
if (!tracerProvider) {
|
|
66
|
-
|
|
51
|
+
console.error("Could not get tracer provider, make sure you ran 'initializeTracing()' or check your environment variables");
|
|
67
52
|
return;
|
|
68
53
|
}
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
? yield getManualInstrumentations(tracerProvider, libraries)
|
|
72
|
-
: yield getInstrumentations(tracerProvider);
|
|
54
|
+
const instrumentations = yield getInstrumentations(tracerProvider, libraries);
|
|
55
|
+
const { registerInstrumentations } = yield import("@opentelemetry/instrumentation");
|
|
73
56
|
registerInstrumentations({
|
|
74
57
|
instrumentations,
|
|
75
58
|
tracerProvider,
|
|
@@ -77,3 +60,49 @@ export function paidAutoInstrument(libraries) {
|
|
|
77
60
|
IS_INITIALIZED = true;
|
|
78
61
|
});
|
|
79
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Instrument supported libraries by directly patching the provided module references.
|
|
65
|
+
* Required for bundled environments (Next.js/webpack) where require-in-the-middle hooks don't work.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import OpenAI from "openai";
|
|
70
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
71
|
+
* await paidAutoInstrumentModules({ openAI: OpenAI, anthropic: Anthropic });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function paidAutoInstrumentModules(modules) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (IS_INITIALIZED) {
|
|
77
|
+
console.info("Auto instrumentation is already initialized");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
initializeTracing();
|
|
81
|
+
const tracerProvider = getPaidTracerProvider();
|
|
82
|
+
if (!tracerProvider) {
|
|
83
|
+
console.error("Could not get tracer provider, make sure you ran 'initializeTracing()' or check your environment variables");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (modules.openai) {
|
|
87
|
+
try {
|
|
88
|
+
const { OpenAIInstrumentation } = yield import("@arizeai/openinference-instrumentation-openai");
|
|
89
|
+
const inst = new OpenAIInstrumentation({ tracerProvider });
|
|
90
|
+
inst.manuallyInstrument(modules.openai);
|
|
91
|
+
}
|
|
92
|
+
catch (_a) {
|
|
93
|
+
console.debug("OpenAI instrumentation not available");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (modules.anthropic) {
|
|
97
|
+
try {
|
|
98
|
+
const { AnthropicInstrumentation } = yield import("@arizeai/openinference-instrumentation-anthropic");
|
|
99
|
+
const inst = new AnthropicInstrumentation({ tracerProvider });
|
|
100
|
+
inst.manuallyInstrument(modules.anthropic);
|
|
101
|
+
}
|
|
102
|
+
catch (_b) {
|
|
103
|
+
console.debug("Anthropic instrumentation not available");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
IS_INITIALIZED = true;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace } from "./tracing.mjs";
|
|
2
|
-
import { paidAutoInstrument } from "./autoInstrumentation.mjs";
|
|
3
2
|
import { signal } from "./signal.mjs";
|
|
4
3
|
import { AISDKSpanProcessor } from "./aiSdkSpanProcessor.mjs";
|
|
5
|
-
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal,
|
|
4
|
+
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal, AISDKSpanProcessor };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace } from "./tracing.mjs";
|
|
2
|
-
import { paidAutoInstrument } from "./autoInstrumentation.mjs";
|
|
3
2
|
import { signal } from "./signal.mjs";
|
|
4
3
|
import { AISDKSpanProcessor } from "./aiSdkSpanProcessor.mjs";
|
|
5
|
-
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal,
|
|
4
|
+
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal, AISDKSpanProcessor };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Tracer } from "@opentelemetry/api";
|
|
2
2
|
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
3
|
-
import winston from "winston";
|
|
4
|
-
export declare const logger: winston.Logger;
|
|
5
3
|
export declare function getToken(): string | undefined;
|
|
6
4
|
export declare function getPaidTracerProvider(): NodeTracerProvider | undefined;
|
|
7
5
|
export declare function getPaidTracer(): Tracer | undefined;
|
|
@@ -7,23 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { SpanStatusCode } from "@opentelemetry/api";
|
|
10
|
+
import { SpanStatusCode, context } from "@opentelemetry/api";
|
|
11
|
+
import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
|
|
11
12
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
12
|
-
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
13
13
|
import { NodeTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
|
|
14
|
-
import winston from "winston";
|
|
15
14
|
import { runWithTracingContext } from "./tracingContext.mjs";
|
|
16
15
|
import { PaidSpanProcessor } from "./spanProcessor.mjs";
|
|
17
16
|
import { AISDKSpanProcessor } from "./aiSdkSpanProcessor.mjs";
|
|
18
|
-
export const logger = winston.createLogger({
|
|
19
|
-
level: "silent", // Default to 'silent' to avoid logging unless set via environment variable
|
|
20
|
-
format: winston.format.simple(),
|
|
21
|
-
transports: [new winston.transports.Console()],
|
|
22
|
-
});
|
|
23
|
-
const logLevel = process.env.PAID_LOG_LEVEL;
|
|
24
|
-
if (logLevel) {
|
|
25
|
-
logger.level = logLevel;
|
|
26
|
-
}
|
|
27
17
|
const DEFAULT_COLLECTOR_ENDPOINT = process.env["PAID_OTEL_COLLECTOR_ENDPOINT"] || "https://collector.agentpaid.io:4318/v1/traces";
|
|
28
18
|
let paidApiToken = undefined;
|
|
29
19
|
export function getToken() {
|
|
@@ -47,26 +37,26 @@ const setupGracefulShutdown = (shuttable) => {
|
|
|
47
37
|
_isShuttingDown = true;
|
|
48
38
|
shuttable
|
|
49
39
|
.shutdown()
|
|
50
|
-
.then(() =>
|
|
51
|
-
.catch((error) =>
|
|
40
|
+
.then(() => console.info(`Paid tracing SDK shut down from signal: ${signal}`))
|
|
41
|
+
.catch((error) => console.error(`Error shutting down Paid tracing SDK ${error}`));
|
|
52
42
|
});
|
|
53
43
|
});
|
|
54
44
|
};
|
|
55
45
|
export function initializeTracing(apiKey, collectorEndpoint) {
|
|
56
46
|
const paidEnabled = (process.env.PAID_ENABLED || "true") !== "false";
|
|
57
47
|
if (!paidEnabled) {
|
|
58
|
-
|
|
48
|
+
console.info("Paid tracing is disabled via PAID_ENABLED environment variable");
|
|
59
49
|
return;
|
|
60
50
|
}
|
|
61
51
|
const token = getToken();
|
|
62
52
|
if (!!token) {
|
|
63
|
-
|
|
53
|
+
console.info("Tracing is already initialized - skipping re-intialization");
|
|
64
54
|
return;
|
|
65
55
|
}
|
|
66
56
|
if (!apiKey) {
|
|
67
57
|
const envKey = process.env.PAID_API_KEY;
|
|
68
58
|
if (!envKey) {
|
|
69
|
-
|
|
59
|
+
console.error("API key must be provided via PAID_API_KEY environment variable");
|
|
70
60
|
return;
|
|
71
61
|
}
|
|
72
62
|
paidApiToken = envKey;
|
|
@@ -82,11 +72,17 @@ export function initializeTracing(apiKey, collectorEndpoint) {
|
|
|
82
72
|
paidTracerProvider = new NodeTracerProvider({
|
|
83
73
|
spanProcessors: [new PaidSpanProcessor(), new AISDKSpanProcessor(), spanProcessor],
|
|
84
74
|
});
|
|
85
|
-
//
|
|
86
|
-
// This
|
|
75
|
+
// Set up context propagation without registering the provider globally.
|
|
76
|
+
// This gives us async parent-child linking via AsyncLocalStorage
|
|
77
|
+
// without polluting the global trace provider.
|
|
78
|
+
const contextManager = new AsyncLocalStorageContextManager();
|
|
79
|
+
contextManager.enable();
|
|
80
|
+
if (!context.setGlobalContextManager(contextManager)) {
|
|
81
|
+
contextManager.disable();
|
|
82
|
+
}
|
|
87
83
|
paidTracer = paidTracerProvider.getTracer("paid.node");
|
|
88
84
|
setupGracefulShutdown(spanProcessor);
|
|
89
|
-
|
|
85
|
+
console.info(`Paid tracing SDK initialized with collector endpoint: ${url}`);
|
|
90
86
|
}
|
|
91
87
|
export function trace(options, fn, ...args) {
|
|
92
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -94,32 +90,34 @@ export function trace(options, fn, ...args) {
|
|
|
94
90
|
const tracer = getPaidTracer();
|
|
95
91
|
if (!token || !tracer) {
|
|
96
92
|
// don't throw, tracing should not crash user app.
|
|
97
|
-
|
|
93
|
+
console.error("Paid tracing is not initialized. Make sure to call initializeTracing() first.");
|
|
98
94
|
return yield fn(...args);
|
|
99
95
|
}
|
|
100
96
|
const { externalCustomerId, externalProductId: externalAgentId, storePrompt, metadata } = options;
|
|
101
|
-
return yield
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
97
|
+
return yield runWithTracingContext({
|
|
98
|
+
externalCustomerId,
|
|
99
|
+
externalProductId: externalAgentId,
|
|
100
|
+
storePrompt,
|
|
101
|
+
metadata,
|
|
102
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
return yield tracer.startActiveSpan("parent_span", (span) => __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
try {
|
|
105
|
+
const res = yield fn(...args);
|
|
106
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
107
|
+
return res;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
span.setStatus({
|
|
111
|
+
code: SpanStatusCode.ERROR,
|
|
112
|
+
message: error.message,
|
|
113
|
+
});
|
|
114
|
+
span.recordException(error);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
span.end();
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
123
121
|
}));
|
|
124
122
|
});
|
|
125
123
|
}
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.1-
|
|
1
|
+
export declare const SDK_VERSION = "1.0.1-alpha9";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.1-
|
|
1
|
+
export const SDK_VERSION = "1.0.1-alpha9";
|
package/package.json
CHANGED
|
@@ -1,211 +1,226 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
"./package.json": "./package.json",
|
|
24
|
-
"./openai": {
|
|
25
|
-
"types": "./dist/cjs/openai-wrapper/index.d.ts",
|
|
26
|
-
"import": {
|
|
27
|
-
"types": "./dist/esm/openai-wrapper/index.d.mts",
|
|
28
|
-
"default": "./dist/esm/openai-wrapper/index.mjs"
|
|
29
|
-
},
|
|
30
|
-
"require": {
|
|
31
|
-
"types": "./dist/cjs/openai-wrapper/index.d.ts",
|
|
32
|
-
"default": "./dist/cjs/openai-wrapper/index.js"
|
|
33
|
-
},
|
|
34
|
-
"default": "./dist/cjs/openai-wrapper/index.js"
|
|
35
|
-
},
|
|
36
|
-
"./anthropic": {
|
|
37
|
-
"types": "./dist/cjs/anthropic-wrapper/index.d.ts",
|
|
38
|
-
"import": {
|
|
39
|
-
"types": "./dist/esm/anthropic-wrapper/index.d.mts",
|
|
40
|
-
"default": "./dist/esm/anthropic-wrapper/index.mjs"
|
|
41
|
-
},
|
|
42
|
-
"require": {
|
|
43
|
-
"types": "./dist/cjs/anthropic-wrapper/index.d.ts",
|
|
44
|
-
"default": "./dist/cjs/anthropic-wrapper/index.js"
|
|
45
|
-
},
|
|
46
|
-
"default": "./dist/cjs/anthropic-wrapper/index.js"
|
|
47
|
-
},
|
|
48
|
-
"./mistral": {
|
|
49
|
-
"types": "./dist/cjs/mistral-wrapper/index.d.ts",
|
|
50
|
-
"import": {
|
|
51
|
-
"types": "./dist/esm/mistral-wrapper/index.d.mts",
|
|
52
|
-
"default": "./dist/esm/mistral-wrapper/index.mjs"
|
|
53
|
-
},
|
|
54
|
-
"require": {
|
|
55
|
-
"types": "./dist/cjs/mistral-wrapper/index.d.ts",
|
|
56
|
-
"default": "./dist/cjs/mistral-wrapper/index.js"
|
|
57
|
-
},
|
|
58
|
-
"default": "./dist/cjs/mistral-wrapper/index.js"
|
|
59
|
-
},
|
|
60
|
-
"./langchain": {
|
|
61
|
-
"types": "./dist/cjs/langchain-wrapper/index.d.ts",
|
|
62
|
-
"import": {
|
|
63
|
-
"types": "./dist/esm/langchain-wrapper/index.d.mts",
|
|
64
|
-
"default": "./dist/esm/langchain-wrapper/index.mjs"
|
|
65
|
-
},
|
|
66
|
-
"require": {
|
|
67
|
-
"types": "./dist/cjs/langchain-wrapper/index.d.ts",
|
|
68
|
-
"default": "./dist/cjs/langchain-wrapper/index.js"
|
|
69
|
-
},
|
|
70
|
-
"default": "./dist/cjs/langchain-wrapper/index.js"
|
|
71
|
-
},
|
|
72
|
-
"./vercel": {
|
|
73
|
-
"types": "./dist/cjs/vercel-wrapper/index.d.ts",
|
|
74
|
-
"import": {
|
|
75
|
-
"types": "./dist/esm/vercel-wrapper/index.d.mts",
|
|
76
|
-
"default": "./dist/esm/vercel-wrapper/index.mjs"
|
|
77
|
-
},
|
|
78
|
-
"require": {
|
|
79
|
-
"types": "./dist/cjs/vercel-wrapper/index.d.ts",
|
|
80
|
-
"default": "./dist/cjs/vercel-wrapper/index.js"
|
|
81
|
-
},
|
|
82
|
-
"default": "./dist/cjs/vercel-wrapper/index.js"
|
|
83
|
-
},
|
|
84
|
-
"./tracing": {
|
|
85
|
-
"types": "./dist/cjs/tracing/index.d.ts",
|
|
86
|
-
"import": {
|
|
87
|
-
"types": "./dist/esm/tracing/index.d.mts",
|
|
88
|
-
"default": "./dist/esm/tracing/index.mjs"
|
|
89
|
-
},
|
|
90
|
-
"require": {
|
|
91
|
-
"types": "./dist/cjs/tracing/index.d.ts",
|
|
92
|
-
"default": "./dist/cjs/tracing/index.js"
|
|
93
|
-
},
|
|
94
|
-
"default": "./dist/cjs/tracing/index.js"
|
|
95
|
-
}
|
|
2
|
+
"name": "@paid-ai/paid-node",
|
|
3
|
+
"version": "1.0.1-alpha9",
|
|
4
|
+
"private": false,
|
|
5
|
+
"repository": "github:paid-ai/paid-node",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"main": "./dist/cjs/index.js",
|
|
8
|
+
"module": "./dist/esm/index.mjs",
|
|
9
|
+
"types": "./dist/cjs/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/cjs/index.d.ts",
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/esm/index.d.mts",
|
|
15
|
+
"default": "./dist/esm/index.mjs"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/cjs/index.d.ts",
|
|
19
|
+
"default": "./dist/cjs/index.js"
|
|
20
|
+
},
|
|
21
|
+
"default": "./dist/cjs/index.js"
|
|
96
22
|
},
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"check:fix": "biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
|
|
110
|
-
"build": "pnpm build:cjs && pnpm build:esm",
|
|
111
|
-
"build:cjs": "tsc --project ./tsconfig.cjs.json",
|
|
112
|
-
"build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm",
|
|
113
|
-
"test": "vitest",
|
|
114
|
-
"test:unit": "vitest --project unit",
|
|
115
|
-
"test:wire": "vitest --project wire"
|
|
23
|
+
"./package.json": "./package.json",
|
|
24
|
+
"./openai": {
|
|
25
|
+
"types": "./dist/cjs/openai-wrapper/index.d.ts",
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/esm/openai-wrapper/index.d.mts",
|
|
28
|
+
"default": "./dist/esm/openai-wrapper/index.mjs"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/cjs/openai-wrapper/index.d.ts",
|
|
32
|
+
"default": "./dist/cjs/openai-wrapper/index.js"
|
|
33
|
+
},
|
|
34
|
+
"default": "./dist/cjs/openai-wrapper/index.js"
|
|
116
35
|
},
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"@arizeai/openinference-instrumentation-openai": ">=4.0.0",
|
|
129
|
-
"@arizeai/openinference-semantic-conventions": ">=2.1.2",
|
|
130
|
-
"@traceloop/instrumentation-bedrock": ">=0.22.0",
|
|
131
|
-
"winston": ">=3.0.0"
|
|
36
|
+
"./anthropic": {
|
|
37
|
+
"types": "./dist/cjs/anthropic-wrapper/index.d.ts",
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/esm/anthropic-wrapper/index.d.mts",
|
|
40
|
+
"default": "./dist/esm/anthropic-wrapper/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/cjs/anthropic-wrapper/index.d.ts",
|
|
44
|
+
"default": "./dist/cjs/anthropic-wrapper/index.js"
|
|
45
|
+
},
|
|
46
|
+
"default": "./dist/cjs/anthropic-wrapper/index.js"
|
|
132
47
|
},
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
|
|
48
|
+
"./mistral": {
|
|
49
|
+
"types": "./dist/cjs/mistral-wrapper/index.d.ts",
|
|
50
|
+
"import": {
|
|
51
|
+
"types": "./dist/esm/mistral-wrapper/index.d.mts",
|
|
52
|
+
"default": "./dist/esm/mistral-wrapper/index.mjs"
|
|
53
|
+
},
|
|
54
|
+
"require": {
|
|
55
|
+
"types": "./dist/cjs/mistral-wrapper/index.d.ts",
|
|
56
|
+
"default": "./dist/cjs/mistral-wrapper/index.js"
|
|
57
|
+
},
|
|
58
|
+
"default": "./dist/cjs/mistral-wrapper/index.js"
|
|
140
59
|
},
|
|
141
|
-
"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
"optional": true
|
|
153
|
-
},
|
|
154
|
-
"ai": {
|
|
155
|
-
"optional": true
|
|
156
|
-
},
|
|
157
|
-
"openai": {
|
|
158
|
-
"optional": true
|
|
159
|
-
}
|
|
60
|
+
"./langchain": {
|
|
61
|
+
"types": "./dist/cjs/langchain-wrapper/index.d.ts",
|
|
62
|
+
"import": {
|
|
63
|
+
"types": "./dist/esm/langchain-wrapper/index.d.mts",
|
|
64
|
+
"default": "./dist/esm/langchain-wrapper/index.mjs"
|
|
65
|
+
},
|
|
66
|
+
"require": {
|
|
67
|
+
"types": "./dist/cjs/langchain-wrapper/index.d.ts",
|
|
68
|
+
"default": "./dist/cjs/langchain-wrapper/index.js"
|
|
69
|
+
},
|
|
70
|
+
"default": "./dist/cjs/langchain-wrapper/index.js"
|
|
160
71
|
},
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
"
|
|
169
|
-
"
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"@mistralai/mistralai": ">=1.0.0",
|
|
173
|
-
"ai": ">=5.0.0",
|
|
174
|
-
"openai": ">=4.85.4",
|
|
175
|
-
"nock": ">=14.0.0",
|
|
176
|
-
"zod": ">=3.0.0"
|
|
72
|
+
"./vercel": {
|
|
73
|
+
"types": "./dist/cjs/vercel-wrapper/index.d.ts",
|
|
74
|
+
"import": {
|
|
75
|
+
"types": "./dist/esm/vercel-wrapper/index.d.mts",
|
|
76
|
+
"default": "./dist/esm/vercel-wrapper/index.mjs"
|
|
77
|
+
},
|
|
78
|
+
"require": {
|
|
79
|
+
"types": "./dist/cjs/vercel-wrapper/index.d.ts",
|
|
80
|
+
"default": "./dist/cjs/vercel-wrapper/index.js"
|
|
81
|
+
},
|
|
82
|
+
"default": "./dist/cjs/vercel-wrapper/index.js"
|
|
177
83
|
},
|
|
178
|
-
"
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
"
|
|
182
|
-
"
|
|
84
|
+
"./tracing": {
|
|
85
|
+
"types": "./dist/cjs/tracing/index.d.ts",
|
|
86
|
+
"import": {
|
|
87
|
+
"types": "./dist/esm/tracing/index.d.mts",
|
|
88
|
+
"default": "./dist/esm/tracing/index.mjs"
|
|
89
|
+
},
|
|
90
|
+
"require": {
|
|
91
|
+
"types": "./dist/cjs/tracing/index.d.ts",
|
|
92
|
+
"default": "./dist/cjs/tracing/index.js"
|
|
93
|
+
},
|
|
94
|
+
"default": "./dist/cjs/tracing/index.js"
|
|
183
95
|
},
|
|
184
|
-
"
|
|
185
|
-
|
|
186
|
-
|
|
96
|
+
"./tracing/auto": {
|
|
97
|
+
"types": "./dist/cjs/tracing/autoInstrumentation.d.ts",
|
|
98
|
+
"import": {
|
|
99
|
+
"types": "./dist/esm/tracing/autoInstrumentation.d.mts",
|
|
100
|
+
"default": "./dist/esm/tracing/autoInstrumentation.mjs"
|
|
101
|
+
},
|
|
102
|
+
"require": {
|
|
103
|
+
"types": "./dist/cjs/tracing/autoInstrumentation.d.ts",
|
|
104
|
+
"default": "./dist/cjs/tracing/autoInstrumentation.js"
|
|
105
|
+
},
|
|
106
|
+
"default": "./dist/cjs/tracing/autoInstrumentation.js"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"files": [
|
|
110
|
+
"dist",
|
|
111
|
+
"reference.md",
|
|
112
|
+
"README.md",
|
|
113
|
+
"LICENSE"
|
|
114
|
+
],
|
|
115
|
+
"scripts": {
|
|
116
|
+
"format": "biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
|
|
117
|
+
"format:check": "biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
|
|
118
|
+
"lint": "biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
|
|
119
|
+
"lint:fix": "biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
|
|
120
|
+
"check": "biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
|
|
121
|
+
"check:fix": "biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
|
|
122
|
+
"build": "pnpm build:cjs && pnpm build:esm",
|
|
123
|
+
"build:cjs": "tsc --project ./tsconfig.cjs.json",
|
|
124
|
+
"build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm",
|
|
125
|
+
"test": "vitest",
|
|
126
|
+
"test:unit": "vitest --project unit",
|
|
127
|
+
"test:wire": "vitest --project wire"
|
|
128
|
+
},
|
|
129
|
+
"dependencies": {
|
|
130
|
+
"@opentelemetry/api": ">=1.9.0",
|
|
131
|
+
"@opentelemetry/context-async-hooks": ">=0.208.0",
|
|
132
|
+
"@opentelemetry/exporter-trace-otlp-http": ">=0.208.0",
|
|
133
|
+
"@opentelemetry/exporter-trace-otlp-proto": ">=0.208.0",
|
|
134
|
+
"@opentelemetry/instrumentation": ">=0.208.0",
|
|
135
|
+
"@opentelemetry/resources": ">=1.38.0",
|
|
136
|
+
"@opentelemetry/sdk-node": ">=0.208.0",
|
|
137
|
+
"@opentelemetry/sdk-trace-base": ">=1.38.0",
|
|
138
|
+
"@opentelemetry/sdk-trace-node": "^2.2.0",
|
|
139
|
+
"@opentelemetry/semantic-conventions": ">=1.38.0",
|
|
140
|
+
"@arizeai/openinference-instrumentation-anthropic": ">=0.1.2",
|
|
141
|
+
"@arizeai/openinference-instrumentation-openai": ">=4.0.0",
|
|
142
|
+
"@arizeai/openinference-semantic-conventions": ">=2.1.2",
|
|
143
|
+
"@traceloop/instrumentation-bedrock": ">=0.22.0"
|
|
144
|
+
},
|
|
145
|
+
"peerDependencies": {
|
|
146
|
+
"@ai-sdk/openai": ">=1.0.0",
|
|
147
|
+
"@anthropic-ai/sdk": ">=0.36.3",
|
|
148
|
+
"@langchain/core": ">=0.3.0",
|
|
149
|
+
"@mistralai/mistralai": ">=1.0.0",
|
|
150
|
+
"ai": ">=5.0.0",
|
|
151
|
+
"openai": ">=4.85.4"
|
|
152
|
+
},
|
|
153
|
+
"peerDependenciesMeta": {
|
|
154
|
+
"@ai-sdk/openai": {
|
|
155
|
+
"optional": true
|
|
156
|
+
},
|
|
157
|
+
"@anthropic-ai/sdk": {
|
|
158
|
+
"optional": true
|
|
159
|
+
},
|
|
160
|
+
"@langchain/core": {
|
|
161
|
+
"optional": true
|
|
187
162
|
},
|
|
188
|
-
"
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
163
|
+
"@mistralai/mistralai": {
|
|
164
|
+
"optional": true
|
|
165
|
+
},
|
|
166
|
+
"ai": {
|
|
167
|
+
"optional": true
|
|
168
|
+
},
|
|
169
|
+
"openai": {
|
|
170
|
+
"optional": true
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"devDependencies": {
|
|
174
|
+
"webpack": "^5.97.1",
|
|
175
|
+
"ts-loader": "^9.5.1",
|
|
176
|
+
"vitest": "^3.2.4",
|
|
177
|
+
"msw": ">=2.0.0",
|
|
178
|
+
"@types/node": "^18.19.70",
|
|
179
|
+
"typescript": "~5.7.2",
|
|
180
|
+
"@biomejs/biome": "2.3.1",
|
|
181
|
+
"@ai-sdk/openai": ">=1.0.0",
|
|
182
|
+
"@anthropic-ai/sdk": ">=0.36.3",
|
|
183
|
+
"@langchain/core": ">=0.3.0",
|
|
184
|
+
"@mistralai/mistralai": ">=1.0.0",
|
|
185
|
+
"ai": ">=5.0.0",
|
|
186
|
+
"openai": ">=4.85.4",
|
|
187
|
+
"nock": ">=14.0.0",
|
|
188
|
+
"zod": ">=3.0.0"
|
|
189
|
+
},
|
|
190
|
+
"browser": {
|
|
191
|
+
"fs": false,
|
|
192
|
+
"os": false,
|
|
193
|
+
"path": false,
|
|
194
|
+
"stream": false
|
|
195
|
+
},
|
|
196
|
+
"packageManager": "pnpm@10.14.0",
|
|
197
|
+
"engines": {
|
|
198
|
+
"node": ">=18.0.0"
|
|
199
|
+
},
|
|
200
|
+
"sideEffects": false,
|
|
201
|
+
"typesVersions": {
|
|
202
|
+
"*": {
|
|
203
|
+
"openai": [
|
|
204
|
+
"./dist/cjs/openai-wrapper/index.d.ts"
|
|
205
|
+
],
|
|
206
|
+
"anthropic": [
|
|
207
|
+
"./dist/cjs/anthropic-wrapper/index.d.ts"
|
|
208
|
+
],
|
|
209
|
+
"mistral": [
|
|
210
|
+
"./dist/cjs/mistral-wrapper/index.d.ts"
|
|
211
|
+
],
|
|
212
|
+
"langchain": [
|
|
213
|
+
"./dist/cjs/langchain-wrapper/index.d.ts"
|
|
214
|
+
],
|
|
215
|
+
"vercel": [
|
|
216
|
+
"./dist/cjs/vercel-wrapper/index.d.ts"
|
|
217
|
+
],
|
|
218
|
+
"tracing": [
|
|
219
|
+
"./dist/cjs/tracing/index.d.ts"
|
|
220
|
+
],
|
|
221
|
+
"tracing/auto": [
|
|
222
|
+
"./dist/cjs/tracing/autoInstrumentation.d.ts"
|
|
223
|
+
]
|
|
210
224
|
}
|
|
211
|
-
}
|
|
225
|
+
}
|
|
226
|
+
}
|