@introspection-sdk/introspection-node 0.4.0 → 0.4.2
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/.turbo/turbo-build.log +1 -1
- package/LICENSE +191 -0
- package/dist/ai-sdk-integration.d.ts.map +1 -1
- package/dist/ai-sdk-integration.js +2 -2
- package/dist/claude-hooks.d.ts.map +1 -1
- package/dist/claude-hooks.js +3 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -3
- package/dist/converters/ai-sdk.d.ts +1 -1
- package/dist/converters/ai-sdk.d.ts.map +1 -1
- package/dist/converters/ai-sdk.js +24 -1
- package/dist/converters/claude.d.ts +2 -2
- package/dist/converters/claude.d.ts.map +1 -1
- package/dist/converters/claude.js +1 -1
- package/dist/converters/openai.d.ts +1 -1
- package/dist/converters/openai.d.ts.map +1 -1
- package/dist/converters/openinference.d.ts +1 -1
- package/dist/converters/openinference.d.ts.map +1 -1
- package/dist/converters/openinference.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/langchain-handler.d.ts +7 -5
- package/dist/langchain-handler.d.ts.map +1 -1
- package/dist/langchain-handler.js +57 -28
- package/dist/mastra-exporter.d.ts.map +1 -1
- package/dist/mastra-exporter.js +2 -2
- package/dist/span-processor.d.ts.map +1 -1
- package/dist/span-processor.js +6 -3
- package/dist/tracing-processor.d.ts.map +1 -1
- package/dist/tracing-processor.js +3 -3
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +13 -0
- package/package.json +19 -16
- package/src/ai-sdk-integration.ts +5 -3
- package/src/anthropic.ts +1 -1
- package/src/claude-hooks.ts +7 -5
- package/src/client.ts +7 -5
- package/src/converters/ai-sdk.ts +27 -2
- package/src/converters/claude.ts +3 -3
- package/src/converters/openai.ts +1 -1
- package/src/converters/openinference.ts +2 -2
- package/src/index.ts +2 -2
- package/src/langchain-handler.ts +68 -35
- package/src/mastra-exporter.ts +5 -3
- package/src/span-processor.ts +10 -5
- package/src/tracing-processor.ts +7 -5
- package/src/utils.ts +15 -0
- package/.turbo/turbo-check-types.log +0 -5
- package/.turbo/turbo-lint.log +0 -5
- package/dist/converters/openclaw.d.ts +0 -16
- package/dist/converters/openclaw.d.ts.map +0 -1
- package/dist/converters/openclaw.js +0 -49
- package/dist/types/genai.d.ts +0 -165
- package/dist/types/genai.d.ts.map +0 -1
- package/dist/types/genai.js +0 -82
- package/src/types/genai.ts +0 -264
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
import { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
|
29
|
-
import { context as otelContext, trace as otelTrace, } from "@opentelemetry/api";
|
|
29
|
+
import { context as otelContext, ROOT_CONTEXT, SpanStatusCode, trace as otelTrace, } from "@opentelemetry/api";
|
|
30
30
|
import { BasicTracerProvider, BatchSpanProcessor, SimpleSpanProcessor, } from "@opentelemetry/sdk-trace-base";
|
|
31
31
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
32
32
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
33
33
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
34
34
|
import { randomUUID } from "crypto";
|
|
35
|
-
import { logger } from "./utils.js";
|
|
35
|
+
import { logger, withOtlpHttpsProxy } from "./utils.js";
|
|
36
36
|
import { VERSION } from "./version.js";
|
|
37
37
|
// ---------------------------------------------------------------------------
|
|
38
38
|
// Handler
|
|
@@ -49,11 +49,11 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
49
49
|
_tracerProvider;
|
|
50
50
|
_tracer;
|
|
51
51
|
_spans = new Map();
|
|
52
|
-
_rootSpan = null;
|
|
53
52
|
_conversationId;
|
|
54
53
|
// Track span names and parents so children can resolve gen_ai.agent.name
|
|
55
54
|
_spanNames = new Map();
|
|
56
55
|
_spanParents = new Map();
|
|
56
|
+
_runRoots = new Map();
|
|
57
57
|
// LangChain wrapper names to skip when resolving agent names
|
|
58
58
|
static _wrapperNames = new Set([
|
|
59
59
|
"RunnableSequence",
|
|
@@ -93,7 +93,7 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
93
93
|
...options.additionalHeaders,
|
|
94
94
|
};
|
|
95
95
|
logger.info(`IntrospectionCallbackHandler initialized: endpoint=${endpoint}`);
|
|
96
|
-
const spanExporter = new OTLPTraceExporter({ url: endpoint, headers });
|
|
96
|
+
const spanExporter = new OTLPTraceExporter(withOtlpHttpsProxy({ url: endpoint, headers }));
|
|
97
97
|
const effectiveBatchSize = token.startsWith("intro_dev") || token.startsWith("intro_staging")
|
|
98
98
|
? 1
|
|
99
99
|
: undefined;
|
|
@@ -128,20 +128,29 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
128
128
|
this._tracer = this._tracerProvider.getTracer("langchain", VERSION);
|
|
129
129
|
this._conversationId = `intro_conv_${randomUUID().replace(/-/g, "")}`;
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
_rootRunId(runId, parentRunId) {
|
|
132
|
+
if (!parentRunId)
|
|
133
|
+
return runId;
|
|
134
|
+
return this._runRoots.get(parentRunId) || parentRunId;
|
|
135
|
+
}
|
|
136
|
+
/** Keep the top-level run span aligned with child conversation IDs. */
|
|
137
|
+
_setRootConversationId(conversationId, runId, parentRunId) {
|
|
138
|
+
const root = this._spans.get(this._rootRunId(runId, parentRunId));
|
|
139
|
+
root?.setAttribute("gen_ai.conversation.id", conversationId);
|
|
138
140
|
}
|
|
139
|
-
|
|
141
|
+
_endRootIfComplete(runId) {
|
|
142
|
+
this._runRoots.delete(runId);
|
|
143
|
+
this._spanNames.delete(runId);
|
|
144
|
+
this._spanParents.delete(runId);
|
|
145
|
+
}
|
|
146
|
+
/** Create a span under a LangChain parent when one exists.
|
|
140
147
|
* Sets gen_ai.agent.name to the parent span's name for hierarchy. */
|
|
141
148
|
_createChildSpan(name, runId, parentRunId) {
|
|
142
|
-
const parent =
|
|
143
|
-
|
|
144
|
-
const ctx =
|
|
149
|
+
const parent = parentRunId ? this._spans.get(parentRunId) : undefined;
|
|
150
|
+
this._runRoots.set(runId, this._rootRunId(runId, parentRunId));
|
|
151
|
+
const ctx = parent
|
|
152
|
+
? otelTrace.setSpan(otelContext.active(), parent)
|
|
153
|
+
: ROOT_CONTEXT;
|
|
145
154
|
const span = this._tracer.startSpan(name, {}, ctx);
|
|
146
155
|
this._spanNames.set(runId, name);
|
|
147
156
|
if (parentRunId) {
|
|
@@ -163,6 +172,7 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
163
172
|
const otelSpan = this._createChildSpan(spanName, runId, parentRunId);
|
|
164
173
|
this._spans.set(runId, otelSpan);
|
|
165
174
|
const conversationId = this._getConversationId(metadata);
|
|
175
|
+
this._setRootConversationId(conversationId, runId, parentRunId);
|
|
166
176
|
otelSpan.setAttribute("gen_ai.operation.name", "chat");
|
|
167
177
|
otelSpan.setAttribute("gen_ai.conversation.id", conversationId);
|
|
168
178
|
otelSpan.setAttribute("openinference.span.kind", "LLM");
|
|
@@ -205,6 +215,7 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
205
215
|
const otelSpan = this._createChildSpan(spanName, runId, parentRunId);
|
|
206
216
|
this._spans.set(runId, otelSpan);
|
|
207
217
|
const conversationId = this._getConversationId(metadata);
|
|
218
|
+
this._setRootConversationId(conversationId, runId, parentRunId);
|
|
208
219
|
otelSpan.setAttribute("gen_ai.operation.name", "chat");
|
|
209
220
|
otelSpan.setAttribute("gen_ai.conversation.id", conversationId);
|
|
210
221
|
otelSpan.setAttribute("openinference.span.kind", "LLM");
|
|
@@ -227,6 +238,7 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
227
238
|
this._spans.delete(runId);
|
|
228
239
|
this._spanNames.delete(runId);
|
|
229
240
|
this._llmInputs.delete(runId);
|
|
241
|
+
this._endRootIfComplete(runId);
|
|
230
242
|
const generations = output.generations?.[0];
|
|
231
243
|
if (generations && generations.length > 0) {
|
|
232
244
|
const parts = [];
|
|
@@ -290,8 +302,10 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
290
302
|
this._spans.delete(runId);
|
|
291
303
|
this._spanNames.delete(runId);
|
|
292
304
|
this._llmInputs.delete(runId);
|
|
293
|
-
|
|
294
|
-
otelSpan.
|
|
305
|
+
this._endRootIfComplete(runId);
|
|
306
|
+
otelSpan.recordException(err);
|
|
307
|
+
otelSpan.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
|
|
308
|
+
otelSpan.setAttribute("exception.message", err.message);
|
|
295
309
|
otelSpan.end();
|
|
296
310
|
}
|
|
297
311
|
// -------------------------------------------------------------------------
|
|
@@ -302,6 +316,7 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
302
316
|
const otelSpan = this._createChildSpan(name, runId, parentRunId);
|
|
303
317
|
this._spans.set(runId, otelSpan);
|
|
304
318
|
const conversationId = this._getConversationId(metadata);
|
|
319
|
+
this._setRootConversationId(conversationId, runId, parentRunId);
|
|
305
320
|
otelSpan.setAttribute("gen_ai.conversation.id", conversationId);
|
|
306
321
|
}
|
|
307
322
|
handleChainEnd(_outputs, runId) {
|
|
@@ -309,6 +324,7 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
309
324
|
if (!otelSpan)
|
|
310
325
|
return;
|
|
311
326
|
this._spans.delete(runId);
|
|
327
|
+
this._endRootIfComplete(runId);
|
|
312
328
|
otelSpan.end();
|
|
313
329
|
}
|
|
314
330
|
handleChainError(err, runId) {
|
|
@@ -316,27 +332,32 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
316
332
|
if (!otelSpan)
|
|
317
333
|
return;
|
|
318
334
|
this._spans.delete(runId);
|
|
319
|
-
|
|
320
|
-
otelSpan.
|
|
335
|
+
this._endRootIfComplete(runId);
|
|
336
|
+
otelSpan.recordException(err);
|
|
337
|
+
otelSpan.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
|
|
338
|
+
otelSpan.setAttribute("exception.message", err.message);
|
|
321
339
|
otelSpan.end();
|
|
322
340
|
}
|
|
323
341
|
// -------------------------------------------------------------------------
|
|
324
342
|
// Tool callbacks
|
|
325
343
|
// -------------------------------------------------------------------------
|
|
326
|
-
handleToolStart(tool, input, runId, parentRunId, _tags,
|
|
344
|
+
handleToolStart(tool, input, runId, parentRunId, _tags, metadata, runName) {
|
|
327
345
|
const toolName = runName || tool?.name || tool?.id?.[tool.id.length - 1] || "tool";
|
|
328
346
|
const otelSpan = this._createChildSpan(toolName, runId, parentRunId);
|
|
329
347
|
this._spans.set(runId, otelSpan);
|
|
348
|
+
const conversationId = this._getConversationId(metadata);
|
|
349
|
+
this._setRootConversationId(conversationId, runId, parentRunId);
|
|
330
350
|
otelSpan.setAttribute("gen_ai.tool.name", toolName);
|
|
331
351
|
otelSpan.setAttribute("openinference.span.kind", "TOOL");
|
|
332
352
|
otelSpan.setAttribute("gen_ai.tool.input", input);
|
|
333
|
-
otelSpan.setAttribute("gen_ai.conversation.id",
|
|
353
|
+
otelSpan.setAttribute("gen_ai.conversation.id", conversationId);
|
|
334
354
|
}
|
|
335
355
|
handleToolEnd(output, runId) {
|
|
336
356
|
const otelSpan = this._spans.get(runId);
|
|
337
357
|
if (!otelSpan)
|
|
338
358
|
return;
|
|
339
359
|
this._spans.delete(runId);
|
|
360
|
+
this._endRootIfComplete(runId);
|
|
340
361
|
if (output != null) {
|
|
341
362
|
otelSpan.setAttribute("gen_ai.tool.output", typeof output === "string" ? output : JSON.stringify(output));
|
|
342
363
|
}
|
|
@@ -347,8 +368,10 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
347
368
|
if (!otelSpan)
|
|
348
369
|
return;
|
|
349
370
|
this._spans.delete(runId);
|
|
350
|
-
|
|
351
|
-
otelSpan.
|
|
371
|
+
this._endRootIfComplete(runId);
|
|
372
|
+
otelSpan.recordException(err);
|
|
373
|
+
otelSpan.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
|
|
374
|
+
otelSpan.setAttribute("exception.message", err.message);
|
|
352
375
|
otelSpan.end();
|
|
353
376
|
}
|
|
354
377
|
// -------------------------------------------------------------------------
|
|
@@ -358,10 +381,9 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
358
381
|
for (const span of this._spans.values())
|
|
359
382
|
span.end();
|
|
360
383
|
this._spans.clear();
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
384
|
+
this._spanNames.clear();
|
|
385
|
+
this._spanParents.clear();
|
|
386
|
+
this._runRoots.clear();
|
|
365
387
|
await this._tracerProvider.shutdown();
|
|
366
388
|
}
|
|
367
389
|
async forceFlush() {
|
|
@@ -408,7 +430,14 @@ export class IntrospectionCallbackHandler extends BaseCallbackHandler {
|
|
|
408
430
|
}
|
|
409
431
|
_getConversationId(metadata) {
|
|
410
432
|
const metaConvId = metadata?.["gen_ai.conversation.id"];
|
|
411
|
-
|
|
433
|
+
if (metaConvId !== undefined && metaConvId !== null) {
|
|
434
|
+
return String(metaConvId);
|
|
435
|
+
}
|
|
436
|
+
const threadId = metadata?.["thread_id"];
|
|
437
|
+
if (threadId !== undefined && threadId !== null) {
|
|
438
|
+
return String(threadId);
|
|
439
|
+
}
|
|
440
|
+
return this._conversationId;
|
|
412
441
|
}
|
|
413
442
|
_convertMessages(messages) {
|
|
414
443
|
const inputMessages = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra-exporter.d.ts","sourceRoot":"","sources":["../src/mastra-exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,uBA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AsBnB;;4DAEwD;IACxD,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,eAAe;IAoCvB,OAAO,CAAC,gBAAgB;IA+HxB,OAAO,CAAC,eAAe;IAiCvB,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,aAAa;IAiDrB,OAAO,CAAC,cAAc;IA6CtB,OAAO,CAAC,aAAa;CA6DtB"}
|
package/dist/mastra-exporter.js
CHANGED
|
@@ -33,7 +33,7 @@ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
|
33
33
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
34
34
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
35
35
|
import { randomUUID } from "crypto";
|
|
36
|
-
import { logger } from "./utils.js";
|
|
36
|
+
import { logger, withOtlpHttpsProxy } from "./utils.js";
|
|
37
37
|
import { VERSION } from "./version.js";
|
|
38
38
|
// ---------------------------------------------------------------------------
|
|
39
39
|
// Exporter
|
|
@@ -101,7 +101,7 @@ export class IntrospectionMastraExporter extends BaseExporter {
|
|
|
101
101
|
Authorization: `Bearer ${token}`,
|
|
102
102
|
...opts.additionalHeaders,
|
|
103
103
|
};
|
|
104
|
-
const spanExporter = new OTLPTraceExporter({ url: endpoint, headers });
|
|
104
|
+
const spanExporter = new OTLPTraceExporter(withOtlpHttpsProxy({ url: endpoint, headers }));
|
|
105
105
|
const effectiveBatchSize = token.startsWith("intro_dev") || token.startsWith("intro_staging")
|
|
106
106
|
? 1
|
|
107
107
|
: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span-processor.d.ts","sourceRoot":"","sources":["../src/span-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,IAAI,EAGL,MAAM,+BAA+B,CAAC;AAMvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"span-processor.d.ts","sourceRoot":"","sources":["../src/span-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,IAAI,EAGL,MAAM,+BAA+B,CAAC;AAMvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA8FlD,MAAM,WAAW,iCAAiC;IAChD,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,0BAA2B,YAAW,aAAa;IAC9D,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAkC;gBAE9C,OAAO,GAAE,iCAAsC;IA0H3D;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI;IAIjD;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IA2H/B;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
package/dist/span-processor.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
|
5
5
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
6
6
|
import { ExportResultCode } from "@opentelemetry/core";
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
8
|
-
import { logger } from "./utils.js";
|
|
8
|
+
import { logger, withOtlpHttpsProxy } from "./utils.js";
|
|
9
9
|
import { isOpenInferenceSpan, replaceOpenInferenceWithGenAI, isVercelAISpan, convertVercelAIToGenAI, } from "./converters/index.js";
|
|
10
10
|
/**
|
|
11
11
|
* A {@link ReadableSpan} wrapper that substitutes the original attributes with
|
|
@@ -32,6 +32,9 @@ class ConvertedReadableSpan {
|
|
|
32
32
|
spanContext() {
|
|
33
33
|
return this._original.spanContext();
|
|
34
34
|
}
|
|
35
|
+
get parentSpanContext() {
|
|
36
|
+
return this._original.parentSpanContext;
|
|
37
|
+
}
|
|
35
38
|
get startTime() {
|
|
36
39
|
return this._original.startTime;
|
|
37
40
|
}
|
|
@@ -117,10 +120,10 @@ export class IntrospectionSpanProcessor {
|
|
|
117
120
|
logger.info(`IntrospectionSpanProcessor initialized: endpoint=${endpoint}${serviceName ? `, serviceName=${serviceName}` : ""}`);
|
|
118
121
|
// Use custom spanExporter if provided (for testing), otherwise create OTLP exporter
|
|
119
122
|
const baseExporter = advanced.spanExporter ||
|
|
120
|
-
new OTLPTraceExporter({
|
|
123
|
+
new OTLPTraceExporter(withOtlpHttpsProxy({
|
|
121
124
|
url: endpoint,
|
|
122
125
|
headers,
|
|
123
|
-
});
|
|
126
|
+
}));
|
|
124
127
|
// Wrap exporter to add v1/v2 compatibility and basic validation
|
|
125
128
|
const exporter = {
|
|
126
129
|
export: (spans, resultCallback) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing-processor.d.ts","sourceRoot":"","sources":["../src/tracing-processor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,+BAA+B,CAAC;AAoBvC,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,IAAI,EACJ,QAAQ,EAMT,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,+BAA+B;IAC9C,oEAAoE;IACpE,YAAY,CAAC,EAAE,YAAY,CAA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AAoB;IA0F5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAwC9B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
|
@@ -11,7 +11,7 @@ import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
|
11
11
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
13
|
import { convertResponsesInputsToSemconv, convertResponsesOutputsToSemconv, convertResponsesToolsToSemconv, convertResponsesInstructionsToSemconv, } from "./converters/openai.js";
|
|
14
|
-
import { logger } from "./utils.js";
|
|
14
|
+
import { logger, withOtlpHttpsProxy } from "./utils.js";
|
|
15
15
|
import { VERSION } from "./version.js";
|
|
16
16
|
/**
|
|
17
17
|
* {@link TracingProcessor} that forwards OpenAI agent traces to the
|
|
@@ -63,10 +63,10 @@ export class IntrospectionTracingProcessor {
|
|
|
63
63
|
: `${baseUrl.replace(/\/$/, "")}/v1/traces`;
|
|
64
64
|
logger.info(`IntrospectionTracingProcessor initialized: endpoint=${endpoint}`);
|
|
65
65
|
// Setup OTLP exporter
|
|
66
|
-
const spanExporter = new OTLPTraceExporter({
|
|
66
|
+
const spanExporter = new OTLPTraceExporter(withOtlpHttpsProxy({
|
|
67
67
|
url: endpoint,
|
|
68
68
|
headers,
|
|
69
|
-
});
|
|
69
|
+
}));
|
|
70
70
|
// Use SimpleSpanProcessor for maxExportBatchSize=1 (sequential export),
|
|
71
71
|
// otherwise BatchSpanProcessor with configurable batch size.
|
|
72
72
|
// Default to sequential export for dev/staging tokens.
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAO9D,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAQlE;AAED;;;GAGG;AACH,cAAM,mBAAoB,YAAW,UAAU;IAC7C,OAAO,CAAC,QAAQ,CAAe;;IAS/B,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,SAAS;IAIjB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM9B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM/B,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAKlC;AAED,eAAO,MAAM,MAAM,qBAA4B,CAAC"}
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { DiagLogLevel } from "@opentelemetry/api";
|
|
2
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
3
|
+
function getHttpsProxyUrl() {
|
|
4
|
+
return process.env.HTTPS_PROXY || undefined;
|
|
5
|
+
}
|
|
6
|
+
export function withOtlpHttpsProxy(options) {
|
|
7
|
+
const proxyUrl = getHttpsProxyUrl();
|
|
8
|
+
if (!proxyUrl)
|
|
9
|
+
return options;
|
|
10
|
+
return {
|
|
11
|
+
...options,
|
|
12
|
+
httpAgentOptions: () => new HttpsProxyAgent(proxyUrl),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
2
15
|
/**
|
|
3
16
|
* Logger for introspection-sdk package.
|
|
4
17
|
* Uses OpenTelemetry's diagnostic logger.
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@introspection-sdk/introspection-node",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Introspection observability SDK for Node.js",
|
|
4
6
|
"type": "module",
|
|
5
7
|
"main": "./dist/index.js",
|
|
6
8
|
"types": "./dist/index.d.ts",
|
|
@@ -19,13 +21,13 @@
|
|
|
19
21
|
}
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
|
-
"@openai/agents": "^0.
|
|
24
|
+
"@openai/agents": "^0.11.4",
|
|
23
25
|
"@types/node": "^22.15.3",
|
|
24
26
|
"eslint": "^9.39.1",
|
|
25
|
-
"@langchain/core": "^1.
|
|
26
|
-
"@mastra/core": "^1.
|
|
27
|
-
"@mastra/observability": "^1.
|
|
28
|
-
"openai": "^6.
|
|
27
|
+
"@langchain/core": "^1.1.46",
|
|
28
|
+
"@mastra/core": "^1.33.0",
|
|
29
|
+
"@mastra/observability": "^1.12.0",
|
|
30
|
+
"openai": "^6.37.0",
|
|
29
31
|
"typescript": "5.9.3",
|
|
30
32
|
"@repo/eslint-config": "0.0.0",
|
|
31
33
|
"@repo/typescript-config": "0.0.0"
|
|
@@ -59,16 +61,17 @@
|
|
|
59
61
|
}
|
|
60
62
|
},
|
|
61
63
|
"dependencies": {
|
|
62
|
-
"@opentelemetry/api": "^1.9.
|
|
63
|
-
"@opentelemetry/api-logs": "^0.
|
|
64
|
-
"@opentelemetry/core": "^2.
|
|
65
|
-
"@opentelemetry/exporter-logs-otlp-proto": "^0.
|
|
66
|
-
"@opentelemetry/exporter-trace-otlp-proto": "^0.
|
|
67
|
-
"@opentelemetry/resources": "^2.
|
|
68
|
-
"@opentelemetry/sdk-logs": "^0.
|
|
69
|
-
"@opentelemetry/sdk-trace-base": "^2.
|
|
70
|
-
"@opentelemetry/semantic-conventions": "^1.
|
|
71
|
-
"
|
|
64
|
+
"@opentelemetry/api": "^1.9.1",
|
|
65
|
+
"@opentelemetry/api-logs": "^0.217.0",
|
|
66
|
+
"@opentelemetry/core": "^2.7.1",
|
|
67
|
+
"@opentelemetry/exporter-logs-otlp-proto": "^0.217.0",
|
|
68
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.217.0",
|
|
69
|
+
"@opentelemetry/resources": "^2.7.1",
|
|
70
|
+
"@opentelemetry/sdk-logs": "^0.217.0",
|
|
71
|
+
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
72
|
+
"@opentelemetry/semantic-conventions": "^1.41.1",
|
|
73
|
+
"https-proxy-agent": "^7.0.6",
|
|
74
|
+
"@introspection-sdk/types": "0.4.2"
|
|
72
75
|
},
|
|
73
76
|
"scripts": {
|
|
74
77
|
"lint": "eslint . --max-warnings 0",
|
|
@@ -55,8 +55,8 @@ import {
|
|
|
55
55
|
buildOutputMessages,
|
|
56
56
|
convertToolsToToolDefinitions,
|
|
57
57
|
} from "./converters/ai-sdk.js";
|
|
58
|
-
import type { InputMessage } from "
|
|
59
|
-
import { logger } from "./utils.js";
|
|
58
|
+
import type { InputMessage } from "@introspection-sdk/types";
|
|
59
|
+
import { logger, withOtlpHttpsProxy } from "./utils.js";
|
|
60
60
|
import { VERSION } from "./version.js";
|
|
61
61
|
|
|
62
62
|
// ---------------------------------------------------------------------------
|
|
@@ -159,7 +159,9 @@ export class IntrospectionAISDKIntegration {
|
|
|
159
159
|
`IntrospectionAISDKIntegration initialized: endpoint=${endpoint}`,
|
|
160
160
|
);
|
|
161
161
|
|
|
162
|
-
const spanExporter = new OTLPTraceExporter(
|
|
162
|
+
const spanExporter = new OTLPTraceExporter(
|
|
163
|
+
withOtlpHttpsProxy({ url: endpoint, headers }),
|
|
164
|
+
);
|
|
163
165
|
|
|
164
166
|
// Use SimpleSpanProcessor for sequential export (dev/staging tokens)
|
|
165
167
|
const effectiveBatchSize =
|
package/src/anthropic.ts
CHANGED
|
@@ -22,7 +22,7 @@ import type {
|
|
|
22
22
|
OutputMessage,
|
|
23
23
|
MessagePart,
|
|
24
24
|
ReasoningPart,
|
|
25
|
-
} from "
|
|
25
|
+
} from "@introspection-sdk/types";
|
|
26
26
|
|
|
27
27
|
import { trace, SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
28
28
|
import type { Tracer, Span } from "@opentelemetry/api";
|
package/src/claude-hooks.ts
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "@opentelemetry/resources";
|
|
29
29
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
30
30
|
|
|
31
|
-
import { logger } from "./utils.js";
|
|
31
|
+
import { logger, withOtlpHttpsProxy } from "./utils.js";
|
|
32
32
|
import { VERSION } from "./version.js";
|
|
33
33
|
import {
|
|
34
34
|
convertClaudeSessionToOtelAttributes,
|
|
@@ -372,10 +372,12 @@ export class IntrospectionClaudeHooks {
|
|
|
372
372
|
`IntrospectionClaudeHooks initialized: service=${serviceName}, endpoint=${endpoint}`,
|
|
373
373
|
);
|
|
374
374
|
|
|
375
|
-
const spanExporter = new OTLPTraceExporter(
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
375
|
+
const spanExporter = new OTLPTraceExporter(
|
|
376
|
+
withOtlpHttpsProxy({
|
|
377
|
+
url: endpoint,
|
|
378
|
+
headers,
|
|
379
|
+
}),
|
|
380
|
+
);
|
|
379
381
|
|
|
380
382
|
// Default to sequential export for dev/staging tokens.
|
|
381
383
|
const useSimple =
|
package/src/client.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "@opentelemetry/resources";
|
|
19
19
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
20
20
|
import { propagation, context } from "@opentelemetry/api";
|
|
21
|
-
import { logger as sdkLogger } from "./utils.js";
|
|
21
|
+
import { logger as sdkLogger, withOtlpHttpsProxy } from "./utils.js";
|
|
22
22
|
import { VERSION } from "./version.js";
|
|
23
23
|
import {
|
|
24
24
|
generateEventId,
|
|
@@ -86,10 +86,12 @@ export class IntrospectionClient {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// Create OTLP log exporter
|
|
89
|
-
const exporter = new OTLPLogExporter(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
const exporter = new OTLPLogExporter(
|
|
90
|
+
withOtlpHttpsProxy({
|
|
91
|
+
url: endpoint,
|
|
92
|
+
headers,
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
93
95
|
|
|
94
96
|
// Create batch processor
|
|
95
97
|
const processor = new BatchLogRecordProcessor(exporter, {
|
package/src/converters/ai-sdk.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
SystemInstruction,
|
|
15
15
|
ToolDefinition,
|
|
16
16
|
MessagePart,
|
|
17
|
-
} from "
|
|
17
|
+
} from "@introspection-sdk/types";
|
|
18
18
|
|
|
19
19
|
// ---------------------------------------------------------------------------
|
|
20
20
|
// Local types — minimal shapes matching AI SDK data structures.
|
|
@@ -192,7 +192,7 @@ export function convertToolsToToolDefinitions(
|
|
|
192
192
|
name,
|
|
193
193
|
description:
|
|
194
194
|
typeof t.description === "string" ? t.description : undefined,
|
|
195
|
-
parameters: extractToolParameters(t.parameters),
|
|
195
|
+
parameters: extractToolParameters(t.inputSchema ?? t.parameters),
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -284,6 +284,31 @@ function extractToolParameters(
|
|
|
284
284
|
if (!parameters || typeof parameters !== "object") return undefined;
|
|
285
285
|
const p = parameters as Record<string, unknown>;
|
|
286
286
|
|
|
287
|
+
// Zod 4 schema — exposes a toJSONSchema() method.
|
|
288
|
+
if (typeof p.toJSONSchema === "function") {
|
|
289
|
+
const jsonSchema = p.toJSONSchema();
|
|
290
|
+
if (jsonSchema && typeof jsonSchema === "object") {
|
|
291
|
+
return jsonSchema as Record<string, unknown>;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// AI SDK v6 tools expose inputSchema instead of parameters. Zod-backed
|
|
296
|
+
// schemas usually carry a JSON Schema factory on this property.
|
|
297
|
+
if (p["~standard"] && typeof p["~standard"] === "object") {
|
|
298
|
+
const standard = p["~standard"] as Record<string, unknown>;
|
|
299
|
+
const standardJsonSchema = standard.jsonSchema;
|
|
300
|
+
if (standardJsonSchema && typeof standardJsonSchema === "object") {
|
|
301
|
+
const input = (standardJsonSchema as Record<string, unknown>).input;
|
|
302
|
+
if (typeof input === "function") {
|
|
303
|
+
const jsonSchema = input();
|
|
304
|
+
if (jsonSchema && typeof jsonSchema === "object") {
|
|
305
|
+
return jsonSchema as Record<string, unknown>;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return standardJsonSchema as Record<string, unknown>;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
287
312
|
// jsonSchema() wrapper — has a jsonSchema property
|
|
288
313
|
if (p.jsonSchema && typeof p.jsonSchema === "object") {
|
|
289
314
|
return p.jsonSchema as Record<string, unknown>;
|
package/src/converters/claude.ts
CHANGED
|
@@ -12,8 +12,8 @@ import type {
|
|
|
12
12
|
ReasoningPart,
|
|
13
13
|
GenAiAttributes,
|
|
14
14
|
ToolDefinition,
|
|
15
|
-
} from "
|
|
16
|
-
import { toAttributes } from "
|
|
15
|
+
} from "@introspection-sdk/types";
|
|
16
|
+
import { toAttributes } from "@introspection-sdk/types";
|
|
17
17
|
|
|
18
18
|
/** A plain-text content block from the Claude API. */
|
|
19
19
|
export interface ClaudeTextBlock {
|
|
@@ -318,7 +318,7 @@ export function convertClaudeSessionToGenAI(
|
|
|
318
318
|
*/
|
|
319
319
|
export function convertClaudeSessionToOtelAttributes(
|
|
320
320
|
data: ClaudeSessionData,
|
|
321
|
-
): Record<string, string | number> {
|
|
321
|
+
): Record<string, string | number | string[] | number[]> {
|
|
322
322
|
const genaiAttrs = convertClaudeSessionToGenAI(data);
|
|
323
323
|
const result = toAttributes(genaiAttrs);
|
|
324
324
|
|
package/src/converters/openai.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
ReasoningPart,
|
|
15
15
|
ToolDefinition,
|
|
16
16
|
SystemInstruction,
|
|
17
|
-
} from "
|
|
17
|
+
} from "@introspection-sdk/types";
|
|
18
18
|
|
|
19
19
|
/** Re-export OpenAI types used by callers (e.g. tracing-processor). */
|
|
20
20
|
export type ResponseInputItem = Responses.ResponseInputItem;
|
|
@@ -7,8 +7,8 @@ import type {
|
|
|
7
7
|
ReasoningPart,
|
|
8
8
|
SystemInstruction,
|
|
9
9
|
ToolDefinition,
|
|
10
|
-
} from "
|
|
11
|
-
import { toAttributes } from "
|
|
10
|
+
} from "@introspection-sdk/types";
|
|
11
|
+
import { toAttributes } from "@introspection-sdk/types";
|
|
12
12
|
|
|
13
13
|
const OI = {
|
|
14
14
|
MODEL_NAME: "llm.model_name",
|
package/src/index.ts
CHANGED
|
@@ -82,8 +82,8 @@ export type {
|
|
|
82
82
|
ToolCallRequestPart,
|
|
83
83
|
ToolCallResponsePart,
|
|
84
84
|
MessagePart,
|
|
85
|
-
} from "
|
|
86
|
-
export { toAttributes } from "
|
|
85
|
+
} from "@introspection-sdk/types";
|
|
86
|
+
export { toAttributes } from "@introspection-sdk/types";
|
|
87
87
|
|
|
88
88
|
// OpenAI converter exports
|
|
89
89
|
export {
|