@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
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
import { logger } from "../../utils.js";
|
|
10
10
|
import {
|
|
11
11
|
DidNotEnable,
|
|
12
|
+
isModuleNotFound,
|
|
12
13
|
type Integration,
|
|
13
14
|
type IntegrationHandles,
|
|
14
15
|
type IntegrationSetupContext,
|
|
15
16
|
} from "./base.js";
|
|
16
17
|
|
|
17
|
-
export { DidNotEnable };
|
|
18
|
+
export { DidNotEnable, isModuleNotFound };
|
|
18
19
|
export type { Integration, IntegrationHandles, IntegrationSetupContext };
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
* Built-in integrations, loaded lazily. Each
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* skipped. Order matters only for `deactivates` resolution (handled below).
|
|
22
|
+
* Built-in integrations, loaded lazily. Each integration probes its optional
|
|
23
|
+
* framework package at runtime, so importing the OTel barrel never requires
|
|
24
|
+
* every optional framework SDK to be installed.
|
|
25
25
|
*/
|
|
26
26
|
const BUILTIN_INTEGRATIONS: ReadonlyArray<
|
|
27
27
|
() => Promise<{ default: Integration }>
|
|
@@ -41,26 +41,27 @@ const installed = new Set<string>();
|
|
|
41
41
|
// prototype patch), run by teardownIntegrations() on shutdown.
|
|
42
42
|
const teardowns: Array<() => void> = [];
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
async function availableIntegrations(
|
|
45
|
+
integrations: Integration[],
|
|
46
|
+
): Promise<Integration[]> {
|
|
47
|
+
const available: Integration[] = [];
|
|
48
|
+
|
|
49
|
+
for (const integration of integrations) {
|
|
50
|
+
if (integration.isAvailable && !(await integration.isAvailable())) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
available.push(integration);
|
|
52
54
|
}
|
|
53
|
-
|
|
54
|
-
return
|
|
55
|
+
|
|
56
|
+
return available;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* Return the built-in integrations whose framework is importable.
|
|
59
61
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* warn level rather than silently swallowed — it's a bug, not an absent peer.
|
|
62
|
+
* Missing optional peer packages are expected and skipped quietly. Any OTHER
|
|
63
|
+
* failure is surfaced at warn level rather than silently swallowed — it's a
|
|
64
|
+
* bug, not an absent peer.
|
|
64
65
|
*/
|
|
65
66
|
export async function discoverIntegrations(): Promise<Integration[]> {
|
|
66
67
|
const found: Integration[] = [];
|
|
@@ -80,7 +81,7 @@ export async function discoverIntegrations(): Promise<Integration[]> {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
return found;
|
|
84
|
+
return availableIntegrations(found);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
/**
|
|
@@ -88,13 +89,13 @@ export async function discoverIntegrations(): Promise<Integration[]> {
|
|
|
88
89
|
*
|
|
89
90
|
* @returns the set of identifiers installed so far this process.
|
|
90
91
|
*/
|
|
91
|
-
export function setupIntegrations(
|
|
92
|
+
export async function setupIntegrations(
|
|
92
93
|
integrations: Integration[],
|
|
93
94
|
ctx: IntegrationSetupContext,
|
|
94
|
-
): Set<string
|
|
95
|
+
): Promise<Set<string>> {
|
|
95
96
|
// First-wins de-dupe by identifier.
|
|
96
97
|
const byId = new Map<string, Integration>();
|
|
97
|
-
for (const integration of integrations) {
|
|
98
|
+
for (const integration of await availableIntegrations(integrations)) {
|
|
98
99
|
if (!byId.has(integration.identifier)) {
|
|
99
100
|
byId.set(integration.identifier, integration);
|
|
100
101
|
}
|
|
@@ -114,7 +115,7 @@ export function setupIntegrations(
|
|
|
114
115
|
}
|
|
115
116
|
if (installed.has(identifier)) continue;
|
|
116
117
|
try {
|
|
117
|
-
const teardown = integration.setupOnce(ctx);
|
|
118
|
+
const teardown = await integration.setupOnce(ctx);
|
|
118
119
|
if (typeof teardown === "function") teardowns.push(teardown);
|
|
119
120
|
installed.add(identifier);
|
|
120
121
|
} catch (e) {
|
|
@@ -10,14 +10,25 @@
|
|
|
10
10
|
* patch would double-trace it.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
import {
|
|
14
|
+
importOptionalPeer,
|
|
15
|
+
isOptionalPeerInstalled,
|
|
16
|
+
OPTIONAL_PEERS,
|
|
17
|
+
type Integration,
|
|
18
|
+
} from "./base.js";
|
|
19
|
+
import type { IntrospectionCallbackHandler } from "../langchain-handler.js";
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
import
|
|
21
|
+
const importLocal = (specifier: string) =>
|
|
22
|
+
import(specifier) as Promise<{
|
|
23
|
+
IntrospectionCallbackHandler: new (
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
options: any,
|
|
26
|
+
) => IntrospectionCallbackHandler;
|
|
27
|
+
}>;
|
|
18
28
|
|
|
19
29
|
const integration: Integration = {
|
|
20
30
|
identifier: "langchain",
|
|
31
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.langchainCallbacks),
|
|
21
32
|
// Intentional, and matches the Python SDK: when @langchain/core is present,
|
|
22
33
|
// auto-discovery skips the always-on raw-Anthropic prototype patch so a
|
|
23
34
|
// LangChain → ChatAnthropic call isn't traced twice (once by LangChain's
|
|
@@ -29,7 +40,11 @@ const integration: Integration = {
|
|
|
29
40
|
// `new AnthropicInstrumentor().instrumentClass(...)`, or call
|
|
30
41
|
// `init({ autoDiscover: false, integrations: [anthropicIntegration] })`.
|
|
31
42
|
deactivates: ["anthropic"],
|
|
32
|
-
setupOnce({ token, serviceName, baseUrl, advanced, handles }) {
|
|
43
|
+
async setupOnce({ token, serviceName, baseUrl, advanced, handles }) {
|
|
44
|
+
await importOptionalPeer(OPTIONAL_PEERS.langchainCallbacks);
|
|
45
|
+
const { IntrospectionCallbackHandler } = await importLocal(
|
|
46
|
+
"../langchain-handler.js",
|
|
47
|
+
);
|
|
33
48
|
handles.langchainHandler = new IntrospectionCallbackHandler({
|
|
34
49
|
token,
|
|
35
50
|
serviceName,
|
|
@@ -9,12 +9,30 @@
|
|
|
9
9
|
* is the presence gate: a missing Mastra makes discovery skip this shim.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
12
|
+
import {
|
|
13
|
+
importOptionalPeer,
|
|
14
|
+
isOptionalPeerInstalled,
|
|
15
|
+
OPTIONAL_PEERS,
|
|
16
|
+
type Integration,
|
|
17
|
+
} from "./base.js";
|
|
18
|
+
|
|
19
|
+
const importLocal = (specifier: string) =>
|
|
20
|
+
import(specifier) as Promise<{
|
|
21
|
+
IntrospectionMastraExporter: new (
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
options: any,
|
|
24
|
+
) => unknown;
|
|
25
|
+
}>;
|
|
14
26
|
|
|
15
27
|
const integration: Integration = {
|
|
16
28
|
identifier: "mastra",
|
|
17
|
-
|
|
29
|
+
isAvailable: () =>
|
|
30
|
+
isOptionalPeerInstalled(OPTIONAL_PEERS.mastraObservability),
|
|
31
|
+
async setupOnce({ token, baseUrl, advanced, handles }) {
|
|
32
|
+
await importOptionalPeer(OPTIONAL_PEERS.mastraObservability);
|
|
33
|
+
const { IntrospectionMastraExporter } = await importLocal(
|
|
34
|
+
"../mastra-exporter.js",
|
|
35
|
+
);
|
|
18
36
|
handles.mastraExporter = new IntrospectionMastraExporter({
|
|
19
37
|
token,
|
|
20
38
|
baseUrl,
|
|
@@ -6,14 +6,30 @@
|
|
|
6
6
|
* other integrations (e.g. a vendor exporter) already registered.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { addTraceProcessor } from "@openai/agents";
|
|
10
|
-
|
|
11
9
|
import { IntrospectionTracingProcessor } from "../tracing-processor.js";
|
|
12
|
-
import
|
|
10
|
+
import {
|
|
11
|
+
importOptionalPeer,
|
|
12
|
+
isOptionalPeerInstalled,
|
|
13
|
+
OPTIONAL_PEERS,
|
|
14
|
+
type Integration,
|
|
15
|
+
} from "./base.js";
|
|
16
|
+
|
|
17
|
+
interface OpenAIAgentsModule {
|
|
18
|
+
addTraceProcessor?: (processor: IntrospectionTracingProcessor) => void;
|
|
19
|
+
}
|
|
13
20
|
|
|
14
21
|
const integration: Integration = {
|
|
15
22
|
identifier: "openai_agents",
|
|
16
|
-
|
|
23
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.openaiAgents),
|
|
24
|
+
async setupOnce({ token, serviceName, baseUrl, advanced }) {
|
|
25
|
+
const { addTraceProcessor } = await importOptionalPeer<OpenAIAgentsModule>(
|
|
26
|
+
OPTIONAL_PEERS.openaiAgents,
|
|
27
|
+
);
|
|
28
|
+
if (!addTraceProcessor) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"Invalid @openai/agents module: addTraceProcessor missing",
|
|
31
|
+
);
|
|
32
|
+
}
|
|
17
33
|
addTraceProcessor(
|
|
18
34
|
new IntrospectionTracingProcessor({
|
|
19
35
|
token,
|
|
@@ -6,15 +6,19 @@
|
|
|
6
6
|
* publishes it via `introspection.instrumentPi(agent, meta)`.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
// Presence gate.
|
|
10
|
-
import "@earendil-works/pi-agent-core";
|
|
11
|
-
|
|
12
9
|
import { IntrospectionPiInstrumentor } from "../pi.js";
|
|
13
|
-
import
|
|
10
|
+
import {
|
|
11
|
+
importOptionalPeer,
|
|
12
|
+
isOptionalPeerInstalled,
|
|
13
|
+
OPTIONAL_PEERS,
|
|
14
|
+
type Integration,
|
|
15
|
+
} from "./base.js";
|
|
14
16
|
|
|
15
17
|
const integration: Integration = {
|
|
16
18
|
identifier: "pi",
|
|
17
|
-
|
|
19
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.piAgentCore),
|
|
20
|
+
async setupOnce({ handles }) {
|
|
21
|
+
await importOptionalPeer(OPTIONAL_PEERS.piAgentCore);
|
|
18
22
|
// The instrumentor emits onto the global tracer, which `init()` has just
|
|
19
23
|
// registered with the shared IntrospectionSpanProcessor.
|
|
20
24
|
handles.piInstrumentor = new IntrospectionPiInstrumentor();
|
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
* (via its top-level import) is skipped when `ai` is not installed.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
import {
|
|
13
|
+
isOptionalPeerInstalled,
|
|
14
|
+
OPTIONAL_PEERS,
|
|
15
|
+
type Integration,
|
|
16
|
+
} from "./base.js";
|
|
16
17
|
|
|
17
18
|
const integration: Integration = {
|
|
18
19
|
identifier: "vercel",
|
|
20
|
+
isAvailable: () => isOptionalPeerInstalled(OPTIONAL_PEERS.vercelAi),
|
|
19
21
|
setupOnce() {
|
|
20
22
|
// No-op: the shared IntrospectionSpanProcessor converts AI SDK spans.
|
|
21
23
|
},
|