@introspection-sdk/introspection-node 0.4.6 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/README.md +262 -0
- package/dist/otel/init.js +1 -1
- package/dist/otel/init.js.map +1 -1
- package/dist/otel/integrations/anthropic.d.ts +1 -1
- package/dist/otel/integrations/anthropic.d.ts.map +1 -1
- package/dist/otel/integrations/anthropic.js +8 -4
- package/dist/otel/integrations/anthropic.js.map +1 -1
- package/dist/otel/integrations/base.d.ts +30 -1
- package/dist/otel/integrations/base.d.ts.map +1 -1
- package/dist/otel/integrations/base.js +50 -0
- package/dist/otel/integrations/base.js.map +1 -1
- package/dist/otel/integrations/claude-agent.d.ts +1 -2
- package/dist/otel/integrations/claude-agent.d.ts.map +1 -1
- package/dist/otel/integrations/claude-agent.js +4 -3
- package/dist/otel/integrations/claude-agent.js.map +1 -1
- package/dist/otel/integrations/gemini.d.ts +1 -1
- package/dist/otel/integrations/gemini.d.ts.map +1 -1
- package/dist/otel/integrations/gemini.js +4 -2
- package/dist/otel/integrations/gemini.js.map +1 -1
- package/dist/otel/integrations/index.d.ts +6 -12
- package/dist/otel/integrations/index.d.ts.map +1 -1
- package/dist/otel/integrations/index.js +20 -24
- package/dist/otel/integrations/index.js.map +1 -1
- package/dist/otel/integrations/langchain.d.ts +1 -2
- package/dist/otel/integrations/langchain.d.ts.map +1 -1
- package/dist/otel/integrations/langchain.js +6 -4
- package/dist/otel/integrations/langchain.js.map +1 -1
- package/dist/otel/integrations/mastra.d.ts +1 -1
- package/dist/otel/integrations/mastra.d.ts.map +1 -1
- package/dist/otel/integrations/mastra.js +6 -2
- package/dist/otel/integrations/mastra.js.map +1 -1
- package/dist/otel/integrations/openai-agents.d.ts +1 -1
- package/dist/otel/integrations/openai-agents.d.ts.map +1 -1
- package/dist/otel/integrations/openai-agents.js +7 -2
- package/dist/otel/integrations/openai-agents.js.map +1 -1
- package/dist/otel/integrations/pi.d.ts +1 -2
- package/dist/otel/integrations/pi.d.ts.map +1 -1
- package/dist/otel/integrations/pi.js +4 -3
- package/dist/otel/integrations/pi.js.map +1 -1
- package/dist/otel/integrations/vercel.d.ts +1 -2
- package/dist/otel/integrations/vercel.d.ts.map +1 -1
- package/dist/otel/integrations/vercel.js +2 -2
- package/dist/otel/integrations/vercel.js.map +1 -1
- package/package.json +12 -12
- package/src/otel/init.ts +1 -1
- package/src/otel/integrations/anthropic.ts +16 -6
- package/src/otel/integrations/base.ts +64 -1
- package/src/otel/integrations/claude-agent.ts +9 -5
- package/src/otel/integrations/gemini.ts +9 -4
- package/src/otel/integrations/index.ts +25 -24
- package/src/otel/integrations/langchain.ts +20 -5
- package/src/otel/integrations/mastra.ts +21 -3
- package/src/otel/integrations/openai-agents.ts +20 -4
- package/src/otel/integrations/pi.ts +9 -5
- package/src/otel/integrations/vercel.ts +6 -4
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
* once per identifier per process, and an integration may `deactivate` others.
|
|
7
7
|
*/
|
|
8
8
|
import { logger } from "../../utils.js";
|
|
9
|
-
import { DidNotEnable, } from "./base.js";
|
|
10
|
-
export { DidNotEnable };
|
|
9
|
+
import { DidNotEnable, isModuleNotFound, } from "./base.js";
|
|
10
|
+
export { DidNotEnable, isModuleNotFound };
|
|
11
11
|
/**
|
|
12
|
-
* Built-in integrations, loaded lazily. Each
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* skipped. Order matters only for `deactivates` resolution (handled below).
|
|
12
|
+
* Built-in integrations, loaded lazily. Each integration probes its optional
|
|
13
|
+
* framework package at runtime, so importing the OTel barrel never requires
|
|
14
|
+
* every optional framework SDK to be installed.
|
|
16
15
|
*/
|
|
17
16
|
const BUILTIN_INTEGRATIONS = [
|
|
18
17
|
() => import("./anthropic.js"),
|
|
@@ -28,25 +27,22 @@ const installed = new Set();
|
|
|
28
27
|
// Teardown callbacks returned by integration setupOnce (e.g. uninstrument a
|
|
29
28
|
// prototype patch), run by teardownIntegrations() on shutdown.
|
|
30
29
|
const teardowns = [];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return true;
|
|
30
|
+
async function availableIntegrations(integrations) {
|
|
31
|
+
const available = [];
|
|
32
|
+
for (const integration of integrations) {
|
|
33
|
+
if (integration.isAvailable && !(await integration.isAvailable())) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
available.push(integration);
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
return /Cannot find (module|package)|Failed to resolve/i.test(msg);
|
|
38
|
+
return available;
|
|
42
39
|
}
|
|
43
40
|
/**
|
|
44
41
|
* Return the built-in integrations whose framework is importable.
|
|
45
42
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* warn level rather than silently swallowed — it's a bug, not an absent peer.
|
|
43
|
+
* Missing optional peer packages are expected and skipped quietly. Any OTHER
|
|
44
|
+
* failure is surfaced at warn level rather than silently swallowed — it's a
|
|
45
|
+
* bug, not an absent peer.
|
|
50
46
|
*/
|
|
51
47
|
export async function discoverIntegrations() {
|
|
52
48
|
const found = [];
|
|
@@ -65,17 +61,17 @@ export async function discoverIntegrations() {
|
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
|
-
return found;
|
|
64
|
+
return availableIntegrations(found);
|
|
69
65
|
}
|
|
70
66
|
/**
|
|
71
67
|
* Run each integration's `setupOnce` once, honouring `deactivates`.
|
|
72
68
|
*
|
|
73
69
|
* @returns the set of identifiers installed so far this process.
|
|
74
70
|
*/
|
|
75
|
-
export function setupIntegrations(integrations, ctx) {
|
|
71
|
+
export async function setupIntegrations(integrations, ctx) {
|
|
76
72
|
// First-wins de-dupe by identifier.
|
|
77
73
|
const byId = new Map();
|
|
78
|
-
for (const integration of integrations) {
|
|
74
|
+
for (const integration of await availableIntegrations(integrations)) {
|
|
79
75
|
if (!byId.has(integration.identifier)) {
|
|
80
76
|
byId.set(integration.identifier, integration);
|
|
81
77
|
}
|
|
@@ -93,7 +89,7 @@ export function setupIntegrations(integrations, ctx) {
|
|
|
93
89
|
if (installed.has(identifier))
|
|
94
90
|
continue;
|
|
95
91
|
try {
|
|
96
|
-
const teardown = integration.setupOnce(ctx);
|
|
92
|
+
const teardown = await integration.setupOnce(ctx);
|
|
97
93
|
if (typeof teardown === "function")
|
|
98
94
|
teardowns.push(teardown);
|
|
99
95
|
installed.add(identifier);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/otel/integrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/otel/integrations/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* model, the handler already traces the call, so the prototype-level Anthropic
|
|
10
10
|
* patch would double-trace it.
|
|
11
11
|
*/
|
|
12
|
-
import "
|
|
13
|
-
import type { Integration } from "./base.js";
|
|
12
|
+
import { type Integration } from "./base.js";
|
|
14
13
|
declare const integration: Integration;
|
|
15
14
|
export default integration;
|
|
16
15
|
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAWnB,QAAA,MAAM,WAAW,EAAE,WA6BlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* model, the handler already traces the call, so the prototype-level Anthropic
|
|
10
10
|
* patch would double-trace it.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
import { IntrospectionCallbackHandler } from "../langchain-handler.js";
|
|
12
|
+
import { importOptionalPeer, isOptionalPeerInstalled, OPTIONAL_PEERS, } from "./base.js";
|
|
13
|
+
const importLocal = (specifier) => import(specifier);
|
|
15
14
|
const integration = {
|
|
16
15
|
identifier: "langchain",
|
|
16
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.langchainCallbacks),
|
|
17
17
|
// Intentional, and matches the Python SDK: when @langchain/core is present,
|
|
18
18
|
// auto-discovery skips the always-on raw-Anthropic prototype patch so a
|
|
19
19
|
// LangChain → ChatAnthropic call isn't traced twice (once by LangChain's
|
|
@@ -25,7 +25,9 @@ const integration = {
|
|
|
25
25
|
// `new AnthropicInstrumentor().instrumentClass(...)`, or call
|
|
26
26
|
// `init({ autoDiscover: false, integrations: [anthropicIntegration] })`.
|
|
27
27
|
deactivates: ["anthropic"],
|
|
28
|
-
setupOnce({ token, serviceName, baseUrl, advanced, handles }) {
|
|
28
|
+
async setupOnce({ token, serviceName, baseUrl, advanced, handles }) {
|
|
29
|
+
await importOptionalPeer(OPTIONAL_PEERS.langchainCallbacks);
|
|
30
|
+
const { IntrospectionCallbackHandler } = await importLocal("../langchain-handler.js");
|
|
29
31
|
handles.langchainHandler = new IntrospectionCallbackHandler({
|
|
30
32
|
token,
|
|
31
33
|
serviceName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langchain.js","sourceRoot":"","sources":["../../../src/otel/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,
|
|
1
|
+
{"version":3,"file":"langchain.js","sourceRoot":"","sources":["../../../src/otel/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GAEf,MAAM,WAAW,CAAC;AAGnB,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,EAAE,CACxC,MAAM,CAAC,SAAS,CAKd,CAAC;AAEL,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,WAAW;IACvB,WAAW,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,cAAc,CAAC,kBAAkB,CAAC;IAC7E,4EAA4E;IAC5E,wEAAwE;IACxE,yEAAyE;IACzE,8DAA8D;IAC9D,EAAE;IACF,0EAA0E;IAC1E,yEAAyE;IACzE,kEAAkE;IAClE,8DAA8D;IAC9D,yEAAyE;IACzE,WAAW,EAAE,CAAC,WAAW,CAAC;IAC1B,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;QAChE,MAAM,kBAAkB,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;QAC5D,MAAM,EAAE,4BAA4B,EAAE,GAAG,MAAM,WAAW,CACxD,yBAAyB,CAC1B,CAAC;QACF,OAAO,CAAC,gBAAgB,GAAG,IAAI,4BAA4B,CAAC;YAC1D,KAAK;YACL,WAAW;YACX,OAAO;YACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;YAC9C,QAAQ,EAAE,QAAQ,EAAE,YAAY;gBAC9B,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE;gBACzC,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Importing `../mastra-exporter.js` (which requires `@mastra/observability`)
|
|
9
9
|
* is the presence gate: a missing Mastra makes discovery skip this shim.
|
|
10
10
|
*/
|
|
11
|
-
import type
|
|
11
|
+
import { type Integration } from "./base.js";
|
|
12
12
|
declare const integration: Integration;
|
|
13
13
|
export default integration;
|
|
14
14
|
//# sourceMappingURL=mastra.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/mastra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"mastra.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/mastra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAUnB,QAAA,MAAM,WAAW,EAAE,WAmBlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
* Importing `../mastra-exporter.js` (which requires `@mastra/observability`)
|
|
9
9
|
* is the presence gate: a missing Mastra makes discovery skip this shim.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { importOptionalPeer, isOptionalPeerInstalled, OPTIONAL_PEERS, } from "./base.js";
|
|
12
|
+
const importLocal = (specifier) => import(specifier);
|
|
12
13
|
const integration = {
|
|
13
14
|
identifier: "mastra",
|
|
14
|
-
|
|
15
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.mastraObservability),
|
|
16
|
+
async setupOnce({ token, baseUrl, advanced, handles }) {
|
|
17
|
+
await importOptionalPeer(OPTIONAL_PEERS.mastraObservability);
|
|
18
|
+
const { IntrospectionMastraExporter } = await importLocal("../mastra-exporter.js");
|
|
15
19
|
handles.mastraExporter = new IntrospectionMastraExporter({
|
|
16
20
|
token,
|
|
17
21
|
baseUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra.js","sourceRoot":"","sources":["../../../src/otel/integrations/mastra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"mastra.js","sourceRoot":"","sources":["../../../src/otel/integrations/mastra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,EAAE,CACxC,MAAM,CAAC,SAAS,CAKd,CAAC;AAEL,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,GAAG,EAAE,CAChB,uBAAuB,CAAC,cAAc,CAAC,mBAAmB,CAAC;IAC7D,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE;QACnD,MAAM,kBAAkB,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;QAC7D,MAAM,EAAE,2BAA2B,EAAE,GAAG,MAAM,WAAW,CACvD,uBAAuB,CACxB,CAAC;QACF,OAAO,CAAC,cAAc,GAAG,IAAI,2BAA2B,CAAC;YACvD,KAAK;YACL,OAAO;YACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;YAC9C,KAAK,EAAE,QAAQ,EAAE,KAAK;YACtB,QAAQ,EAAE,QAAQ,EAAE,YAAY;gBAC9B,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE;gBACzC,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* global trace pipeline. `addTraceProcessor` appends, preserving any processors
|
|
6
6
|
* other integrations (e.g. a vendor exporter) already registered.
|
|
7
7
|
*/
|
|
8
|
-
import type
|
|
8
|
+
import { type Integration } from "./base.js";
|
|
9
9
|
declare const integration: Integration;
|
|
10
10
|
export default integration;
|
|
11
11
|
//# sourceMappingURL=openai-agents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/openai-agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/openai-agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAMnB,QAAA,MAAM,WAAW,EAAE,WAwBlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -5,11 +5,16 @@
|
|
|
5
5
|
* global trace pipeline. `addTraceProcessor` appends, preserving any processors
|
|
6
6
|
* other integrations (e.g. a vendor exporter) already registered.
|
|
7
7
|
*/
|
|
8
|
-
import { addTraceProcessor } from "@openai/agents";
|
|
9
8
|
import { IntrospectionTracingProcessor } from "../tracing-processor.js";
|
|
9
|
+
import { importOptionalPeer, isOptionalPeerInstalled, OPTIONAL_PEERS, } from "./base.js";
|
|
10
10
|
const integration = {
|
|
11
11
|
identifier: "openai_agents",
|
|
12
|
-
|
|
12
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.openaiAgents),
|
|
13
|
+
async setupOnce({ token, serviceName, baseUrl, advanced }) {
|
|
14
|
+
const { addTraceProcessor } = await importOptionalPeer(OPTIONAL_PEERS.openaiAgents);
|
|
15
|
+
if (!addTraceProcessor) {
|
|
16
|
+
throw new Error("Invalid @openai/agents module: addTraceProcessor missing");
|
|
17
|
+
}
|
|
13
18
|
addTraceProcessor(new IntrospectionTracingProcessor({
|
|
14
19
|
token,
|
|
15
20
|
serviceName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-agents.js","sourceRoot":"","sources":["../../../src/otel/integrations/openai-agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"openai-agents.js","sourceRoot":"","sources":["../../../src/otel/integrations/openai-agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GAEf,MAAM,WAAW,CAAC;AAMnB,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,eAAe;IAC3B,WAAW,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,cAAc,CAAC,YAAY,CAAC;IACvE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE;QACvD,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,kBAAkB,CACpD,cAAc,CAAC,YAAY,CAC5B,CAAC;QACF,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;QACJ,CAAC;QACD,iBAAiB,CACf,IAAI,6BAA6B,CAAC;YAChC,KAAK;YACL,WAAW;YACX,OAAO;YACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;YAC9C,QAAQ,EAAE,QAAQ,EAAE,YAAY;gBAC9B,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE;gBACzC,CAAC,CAAC,SAAS;SACd,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* builds the instrumentor — bound to the shared provider's global tracer — and
|
|
6
6
|
* publishes it via `introspection.instrumentPi(agent, meta)`.
|
|
7
7
|
*/
|
|
8
|
-
import "
|
|
9
|
-
import type { Integration } from "./base.js";
|
|
8
|
+
import { type Integration } from "./base.js";
|
|
10
9
|
declare const integration: Integration;
|
|
11
10
|
export default integration;
|
|
12
11
|
//# sourceMappingURL=pi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO
|
|
1
|
+
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAEnB,QAAA,MAAM,WAAW,EAAE,WASlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
* builds the instrumentor — bound to the shared provider's global tracer — and
|
|
6
6
|
* publishes it via `introspection.instrumentPi(agent, meta)`.
|
|
7
7
|
*/
|
|
8
|
-
// Presence gate.
|
|
9
|
-
import "@earendil-works/pi-agent-core";
|
|
10
8
|
import { IntrospectionPiInstrumentor } from "../pi.js";
|
|
9
|
+
import { importOptionalPeer, isOptionalPeerInstalled, OPTIONAL_PEERS, } from "./base.js";
|
|
11
10
|
const integration = {
|
|
12
11
|
identifier: "pi",
|
|
13
|
-
|
|
12
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.piAgentCore),
|
|
13
|
+
async setupOnce({ handles }) {
|
|
14
|
+
await importOptionalPeer(OPTIONAL_PEERS.piAgentCore);
|
|
14
15
|
// The instrumentor emits onto the global tracer, which `init()` has just
|
|
15
16
|
// registered with the shared IntrospectionSpanProcessor.
|
|
16
17
|
handles.piInstrumentor = new IntrospectionPiInstrumentor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.js","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,
|
|
1
|
+
{"version":3,"file":"pi.js","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,cAAc,CAAC,WAAW,CAAC;IACtE,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE;QACzB,MAAM,kBAAkB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACrD,yEAAyE;QACzE,yDAAyD;QACzD,OAAO,CAAC,cAAc,GAAG,IAAI,2BAA2B,EAAE,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
* This integration exists so auto-discovery reports the AI SDK as detected and
|
|
9
9
|
* (via its top-level import) is skipped when `ai` is not installed.
|
|
10
10
|
*/
|
|
11
|
-
import "
|
|
12
|
-
import type { Integration } from "./base.js";
|
|
11
|
+
import { type Integration } from "./base.js";
|
|
13
12
|
declare const integration: Integration;
|
|
14
13
|
export default integration;
|
|
15
14
|
//# sourceMappingURL=vercel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/vercel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/vercel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAEnB,QAAA,MAAM,WAAW,EAAE,WAMlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* This integration exists so auto-discovery reports the AI SDK as detected and
|
|
9
9
|
* (via its top-level import) is skipped when `ai` is not installed.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
import "ai";
|
|
11
|
+
import { isOptionalPeerInstalled, OPTIONAL_PEERS, } from "./base.js";
|
|
13
12
|
const integration = {
|
|
14
13
|
identifier: "vercel",
|
|
14
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.vercelAi),
|
|
15
15
|
setupOnce() {
|
|
16
16
|
// No-op: the shared IntrospectionSpanProcessor converts AI SDK spans.
|
|
17
17
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel.js","sourceRoot":"","sources":["../../../src/otel/integrations/vercel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,
|
|
1
|
+
{"version":3,"file":"vercel.js","sourceRoot":"","sources":["../../../src/otel/integrations/vercel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,uBAAuB,EACvB,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,cAAc,CAAC,QAAQ,CAAC;IACnE,SAAS;QACP,sEAAsE;IACxE,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@introspection-sdk/introspection-node",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Introspection observability SDK for Node.js",
|
|
6
6
|
"engines": {
|
|
@@ -43,18 +43,18 @@
|
|
|
43
43
|
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
44
44
|
"@opentelemetry/sdk-trace-node": "^2.7.1",
|
|
45
45
|
"@opentelemetry/semantic-conventions": "^1.41.1",
|
|
46
|
-
"@types/node": "^22.19.
|
|
46
|
+
"@types/node": "^22.19.20",
|
|
47
47
|
"eslint": "^9.39.4",
|
|
48
48
|
"@langchain/core": "^1.1.48",
|
|
49
|
-
"@mastra/core": "^1.
|
|
50
|
-
"@mastra/observability": "^1.14.
|
|
49
|
+
"@mastra/core": "^1.41.0",
|
|
50
|
+
"@mastra/observability": "^1.14.1",
|
|
51
51
|
"@earendil-works/pi-agent-core": "^0.75.4",
|
|
52
52
|
"@earendil-works/pi-ai": "^0.75.4",
|
|
53
|
-
"@anthropic-ai/sdk": "^0.
|
|
54
|
-
"@anthropic-ai/claude-agent-sdk": "^0.3.
|
|
55
|
-
"@google/genai": "^2.
|
|
56
|
-
"ai": "^6.0.
|
|
57
|
-
"openai": "^6.
|
|
53
|
+
"@anthropic-ai/sdk": "^0.102.0",
|
|
54
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.168",
|
|
55
|
+
"@google/genai": "^2.8.0",
|
|
56
|
+
"ai": "^6.0.197",
|
|
57
|
+
"openai": "^6.42.0",
|
|
58
58
|
"typescript": "5.9.3",
|
|
59
59
|
"@repo/typescript-config": "0.0.0",
|
|
60
60
|
"@repo/eslint-config": "0.0.0"
|
|
@@ -138,9 +138,9 @@
|
|
|
138
138
|
"dependencies": {
|
|
139
139
|
"@opentelemetry/api": "^1.9.1",
|
|
140
140
|
"https-proxy-agent": "^7.0.6",
|
|
141
|
-
"@introspection-sdk/
|
|
142
|
-
"@introspection-sdk/
|
|
143
|
-
"@introspection-sdk/introspection-
|
|
141
|
+
"@introspection-sdk/types": "0.4.8",
|
|
142
|
+
"@introspection-sdk/introspection-proxy": "0.4.8",
|
|
143
|
+
"@introspection-sdk/introspection-pi": "0.4.8"
|
|
144
144
|
},
|
|
145
145
|
"scripts": {
|
|
146
146
|
"lint": "eslint . --max-warnings 0",
|
package/src/otel/init.ts
CHANGED
|
@@ -184,7 +184,7 @@ export async function init(options: InitOptions = {}): Promise<TracerProvider> {
|
|
|
184
184
|
toInstall.push(...(await discoverIntegrations()));
|
|
185
185
|
}
|
|
186
186
|
if (options.integrations) toInstall.push(...options.integrations);
|
|
187
|
-
setupIntegrations(toInstall, ctx);
|
|
187
|
+
await setupIntegrations(toInstall, ctx);
|
|
188
188
|
} catch (e) {
|
|
189
189
|
state.handles = {};
|
|
190
190
|
throw e;
|
|
@@ -5,16 +5,26 @@
|
|
|
5
5
|
* client is traced against the shared provider — no per-client wiring.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
// Top-level import gates availability: if `@anthropic-ai/sdk` is not installed
|
|
9
|
-
// the dynamic import of this module rejects and discovery skips the shim.
|
|
10
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
11
|
-
|
|
12
8
|
import { AnthropicInstrumentor } from "../anthropic.js";
|
|
13
|
-
import
|
|
9
|
+
import {
|
|
10
|
+
importOptionalPeer,
|
|
11
|
+
isOptionalPeerInstalled,
|
|
12
|
+
OPTIONAL_PEERS,
|
|
13
|
+
type Integration,
|
|
14
|
+
} from "./base.js";
|
|
15
|
+
|
|
16
|
+
async function loadAnthropicSdk(): Promise<unknown> {
|
|
17
|
+
const mod = await importOptionalPeer<{ default?: unknown }>(
|
|
18
|
+
OPTIONAL_PEERS.anthropic,
|
|
19
|
+
);
|
|
20
|
+
return mod.default ?? mod;
|
|
21
|
+
}
|
|
14
22
|
|
|
15
23
|
const integration: Integration = {
|
|
16
24
|
identifier: "anthropic",
|
|
17
|
-
|
|
25
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.anthropic),
|
|
26
|
+
async setupOnce({ tracerProvider }) {
|
|
27
|
+
const Anthropic = await loadAnthropicSdk();
|
|
18
28
|
const instrumentor = new AnthropicInstrumentor();
|
|
19
29
|
instrumentor.instrumentClass({ anthropic: Anthropic, tracerProvider });
|
|
20
30
|
// Restore the original prototype on shutdown so a later init() re-patches
|
|
@@ -15,6 +15,17 @@ import type { InstrumentedClaudeAgentSDK } from "../claude-wrapper.js";
|
|
|
15
15
|
import type { IntrospectionCallbackHandler } from "../langchain-handler.js";
|
|
16
16
|
import type { IntrospectionPiInstrumentor } from "../pi.js";
|
|
17
17
|
|
|
18
|
+
export const OPTIONAL_PEERS = {
|
|
19
|
+
anthropic: "@anthropic-ai/sdk",
|
|
20
|
+
claudeAgent: "@anthropic-ai/claude-agent-sdk",
|
|
21
|
+
gemini: "@google/genai",
|
|
22
|
+
langchainCallbacks: "@langchain/core/callbacks/base",
|
|
23
|
+
mastraObservability: "@mastra/observability",
|
|
24
|
+
openaiAgents: "@openai/agents",
|
|
25
|
+
piAgentCore: "@earendil-works/pi-agent-core",
|
|
26
|
+
vercelAi: "ai",
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
18
29
|
/**
|
|
19
30
|
* Bound framework handles published by instance/config-based integrations.
|
|
20
31
|
*
|
|
@@ -50,6 +61,50 @@ export class DidNotEnable extends Error {
|
|
|
50
61
|
}
|
|
51
62
|
}
|
|
52
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Distinguish "framework package not installed" (expected — skip quietly) from
|
|
66
|
+
* a real error inside an installed integration (a bug we shouldn't hide).
|
|
67
|
+
*/
|
|
68
|
+
export function isModuleNotFound(e: unknown): boolean {
|
|
69
|
+
const code = (e as { code?: string } | null)?.code;
|
|
70
|
+
if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
74
|
+
return /Cannot find (module|package)|Failed to resolve/i.test(msg);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Import an optional peer without leaving a static import edge for bundlers.
|
|
79
|
+
* Keep the `import()` argument variable-based: built-in framework integrations
|
|
80
|
+
* use this so importing `@introspection-sdk/introspection-node/otel` does not
|
|
81
|
+
* require every optional framework SDK to be installed.
|
|
82
|
+
*/
|
|
83
|
+
export async function importOptionalPeer<T = unknown>(
|
|
84
|
+
specifier: string,
|
|
85
|
+
): Promise<T> {
|
|
86
|
+
try {
|
|
87
|
+
return (await import(specifier)) as T;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
if (isModuleNotFound(e)) {
|
|
90
|
+
throw new DidNotEnable(`Optional peer ${specifier} is not installed`);
|
|
91
|
+
}
|
|
92
|
+
throw e;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function isOptionalPeerInstalled(
|
|
97
|
+
specifier: (typeof OPTIONAL_PEERS)[keyof typeof OPTIONAL_PEERS],
|
|
98
|
+
): Promise<boolean> {
|
|
99
|
+
try {
|
|
100
|
+
await importOptionalPeer(specifier);
|
|
101
|
+
return true;
|
|
102
|
+
} catch (e) {
|
|
103
|
+
if (e instanceof DidNotEnable) return false;
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
53
108
|
/**
|
|
54
109
|
* Everything an integration needs to wire itself into the shared pipeline.
|
|
55
110
|
*
|
|
@@ -85,11 +140,19 @@ export interface Integration {
|
|
|
85
140
|
* wrapping framework (e.g. LangChain) does not double-trace the SDK it wraps.
|
|
86
141
|
*/
|
|
87
142
|
readonly deactivates?: readonly string[];
|
|
143
|
+
/**
|
|
144
|
+
* Optional availability probe for built-in integrations backed by optional
|
|
145
|
+
* peer packages. Missing peers should return false so their `deactivates`
|
|
146
|
+
* rules do not affect installed integrations.
|
|
147
|
+
*/
|
|
148
|
+
isAvailable?(): boolean | Promise<boolean>;
|
|
88
149
|
/**
|
|
89
150
|
* Wire the framework into the shared pipeline. Runs once; may throw
|
|
90
151
|
* {@link DidNotEnable}. May return a teardown callback (e.g. to uninstrument a
|
|
91
152
|
* prototype patch) that `introspection.shutdown()` runs so a later `init()`
|
|
92
153
|
* re-installs cleanly against the rebuilt provider.
|
|
93
154
|
*/
|
|
94
|
-
setupOnce(
|
|
155
|
+
setupOnce(
|
|
156
|
+
ctx: IntegrationSetupContext,
|
|
157
|
+
): void | (() => void) | Promise<void | (() => void)>;
|
|
95
158
|
}
|
|
@@ -7,15 +7,19 @@
|
|
|
7
7
|
* `init()` re-exposes as `introspection.instrumentClaudeAgent(sdk)`.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
// Presence gate.
|
|
11
|
-
import "@anthropic-ai/claude-agent-sdk";
|
|
12
|
-
|
|
13
10
|
import { withIntrospection } from "../claude-wrapper.js";
|
|
14
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
importOptionalPeer,
|
|
13
|
+
isOptionalPeerInstalled,
|
|
14
|
+
OPTIONAL_PEERS,
|
|
15
|
+
type Integration,
|
|
16
|
+
} from "./base.js";
|
|
15
17
|
|
|
16
18
|
const integration: Integration = {
|
|
17
19
|
identifier: "claude_agent",
|
|
18
|
-
|
|
20
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.claudeAgent),
|
|
21
|
+
async setupOnce({ token, serviceName, baseUrl, advanced, handles }) {
|
|
22
|
+
await importOptionalPeer(OPTIONAL_PEERS.claudeAgent);
|
|
19
23
|
handles.instrumentClaudeAgent = (sdk) =>
|
|
20
24
|
withIntrospection(sdk, {
|
|
21
25
|
token,
|
|
@@ -6,14 +6,19 @@
|
|
|
6
6
|
* capture the standalone `GeminiInstrumentor` is built for.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import * as genai from "@google/genai";
|
|
10
|
-
|
|
11
9
|
import { GeminiInstrumentor } from "../gemini.js";
|
|
12
|
-
import
|
|
10
|
+
import {
|
|
11
|
+
importOptionalPeer,
|
|
12
|
+
isOptionalPeerInstalled,
|
|
13
|
+
OPTIONAL_PEERS,
|
|
14
|
+
type Integration,
|
|
15
|
+
} from "./base.js";
|
|
13
16
|
|
|
14
17
|
const integration: Integration = {
|
|
15
18
|
identifier: "gemini",
|
|
16
|
-
|
|
19
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.gemini),
|
|
20
|
+
async setupOnce({ tracerProvider }) {
|
|
21
|
+
const genai = await importOptionalPeer(OPTIONAL_PEERS.gemini);
|
|
17
22
|
const instrumentor = new GeminiInstrumentor();
|
|
18
23
|
instrumentor.instrumentClass({ genai, tracerProvider });
|
|
19
24
|
// Restore the original prototype on shutdown so a later init() re-patches
|