@superbased/sdk 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +438 -2
  4. package/dist/cjs/admit.d.ts +139 -0
  5. package/dist/cjs/admit.js +442 -0
  6. package/dist/cjs/admit.js.map +1 -0
  7. package/dist/cjs/attrs.d.ts +113 -0
  8. package/dist/cjs/attrs.js +183 -0
  9. package/dist/cjs/attrs.js.map +1 -0
  10. package/dist/cjs/config.d.ts +202 -0
  11. package/dist/cjs/config.js +386 -0
  12. package/dist/cjs/config.js.map +1 -0
  13. package/dist/cjs/context.d.ts +102 -0
  14. package/dist/cjs/context.js +234 -0
  15. package/dist/cjs/context.js.map +1 -0
  16. package/dist/cjs/control.d.ts +99 -0
  17. package/dist/cjs/control.js +243 -0
  18. package/dist/cjs/control.js.map +1 -0
  19. package/dist/cjs/cost.d.ts +108 -0
  20. package/dist/cjs/cost.js +211 -0
  21. package/dist/cjs/cost.js.map +1 -0
  22. package/dist/cjs/destination.d.ts +125 -0
  23. package/dist/cjs/destination.js +357 -0
  24. package/dist/cjs/destination.js.map +1 -0
  25. package/dist/cjs/experiments.d.ts +237 -0
  26. package/dist/cjs/experiments.js +678 -0
  27. package/dist/cjs/experiments.js.map +1 -0
  28. package/dist/cjs/export.d.ts +84 -0
  29. package/dist/cjs/export.js +328 -0
  30. package/dist/cjs/export.js.map +1 -0
  31. package/dist/cjs/index.d.ts +168 -0
  32. package/dist/cjs/index.js +581 -0
  33. package/dist/cjs/index.js.map +1 -0
  34. package/dist/cjs/instrument.d.ts +88 -0
  35. package/dist/cjs/instrument.js +397 -0
  36. package/dist/cjs/instrument.js.map +1 -0
  37. package/dist/cjs/package.json +1 -0
  38. package/dist/cjs/policy.d.ts +77 -0
  39. package/dist/cjs/policy.js +252 -0
  40. package/dist/cjs/policy.js.map +1 -0
  41. package/dist/cjs/prompts.d.ts +175 -0
  42. package/dist/cjs/prompts.js +476 -0
  43. package/dist/cjs/prompts.js.map +1 -0
  44. package/dist/cjs/propagation.d.ts +34 -0
  45. package/dist/cjs/propagation.js +151 -0
  46. package/dist/cjs/propagation.js.map +1 -0
  47. package/dist/cjs/req.d.ts +10 -0
  48. package/dist/cjs/req.js +3 -0
  49. package/dist/cjs/req.js.map +1 -0
  50. package/dist/cjs/runtime.d.ts +44 -0
  51. package/dist/cjs/runtime.js +67 -0
  52. package/dist/cjs/runtime.js.map +1 -0
  53. package/dist/cjs/scores.d.ts +102 -0
  54. package/dist/cjs/scores.js +226 -0
  55. package/dist/cjs/scores.js.map +1 -0
  56. package/dist/cjs/spans.d.ts +193 -0
  57. package/dist/cjs/spans.js +398 -0
  58. package/dist/cjs/spans.js.map +1 -0
  59. package/dist/cjs/vendor.d.ts +33 -0
  60. package/dist/cjs/vendor.js +67 -0
  61. package/dist/cjs/vendor.js.map +1 -0
  62. package/dist/esm/admit.d.ts +139 -0
  63. package/dist/esm/admit.js +432 -0
  64. package/dist/esm/admit.js.map +1 -0
  65. package/dist/esm/attrs.d.ts +113 -0
  66. package/dist/esm/attrs.js +179 -0
  67. package/dist/esm/attrs.js.map +1 -0
  68. package/dist/esm/config.d.ts +202 -0
  69. package/dist/esm/config.js +364 -0
  70. package/dist/esm/config.js.map +1 -0
  71. package/dist/esm/context.d.ts +102 -0
  72. package/dist/esm/context.js +221 -0
  73. package/dist/esm/context.js.map +1 -0
  74. package/dist/esm/control.d.ts +99 -0
  75. package/dist/esm/control.js +230 -0
  76. package/dist/esm/control.js.map +1 -0
  77. package/dist/esm/cost.d.ts +108 -0
  78. package/dist/esm/cost.js +202 -0
  79. package/dist/esm/cost.js.map +1 -0
  80. package/dist/esm/destination.d.ts +125 -0
  81. package/dist/esm/destination.js +346 -0
  82. package/dist/esm/destination.js.map +1 -0
  83. package/dist/esm/experiments.d.ts +237 -0
  84. package/dist/esm/experiments.js +666 -0
  85. package/dist/esm/experiments.js.map +1 -0
  86. package/dist/esm/export.d.ts +84 -0
  87. package/dist/esm/export.js +314 -0
  88. package/dist/esm/export.js.map +1 -0
  89. package/dist/esm/index.d.ts +168 -0
  90. package/dist/esm/index.js +500 -0
  91. package/dist/esm/index.js.map +1 -0
  92. package/dist/esm/instrument.d.ts +88 -0
  93. package/dist/esm/instrument.js +391 -0
  94. package/dist/esm/instrument.js.map +1 -0
  95. package/dist/esm/policy.d.ts +77 -0
  96. package/dist/esm/policy.js +240 -0
  97. package/dist/esm/policy.js.map +1 -0
  98. package/dist/esm/prompts.d.ts +175 -0
  99. package/dist/esm/prompts.js +460 -0
  100. package/dist/esm/prompts.js.map +1 -0
  101. package/dist/esm/propagation.d.ts +34 -0
  102. package/dist/esm/propagation.js +145 -0
  103. package/dist/esm/propagation.js.map +1 -0
  104. package/dist/esm/req.d.ts +10 -0
  105. package/dist/esm/req.js +2 -0
  106. package/dist/esm/req.js.map +1 -0
  107. package/dist/esm/runtime.d.ts +44 -0
  108. package/dist/esm/runtime.js +59 -0
  109. package/dist/esm/runtime.js.map +1 -0
  110. package/dist/esm/scores.d.ts +102 -0
  111. package/dist/esm/scores.js +219 -0
  112. package/dist/esm/scores.js.map +1 -0
  113. package/dist/esm/spans.d.ts +193 -0
  114. package/dist/esm/spans.js +378 -0
  115. package/dist/esm/spans.js.map +1 -0
  116. package/dist/esm/vendor.d.ts +33 -0
  117. package/dist/esm/vendor.js +61 -0
  118. package/dist/esm/vendor.js.map +1 -0
  119. package/package.json +130 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAuB,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC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CAAC,EAAE,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACrB,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,gBAAgB,EAAE,CAAC;IACnB,qBAAqB,EAAE,CAAC;IACxB,oBAAoB,EAAE,CAAC;IACvB,eAAe,EAAE,CAAC;IAClB,gBAAgB,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * superbased SDK for TypeScript / Node: send LLM-app and agent traces to\n * superbased over OpenTelemetry (OTLP/HTTP).\n *\n * A thin layer over OpenTelemetry JS 2.x that exports spans to the Observer\n * on this machine (`http://127.0.0.1:4318/v1/traces` by default), to an org\n * or SaaS OTLP gateway, or to both, and tags them with superbased attributes.\n * Anything it does, a raw OTel exporter pointed at Observer does too.\n *\n * IMPORTANT: never set `sbo.emitted_by=observer`: that is Observer's own\n * echo-guard marker and such a resource is DROPPED at ingestion.\n */\n\nimport { ProxyTracerProvider, trace, type TracerProvider } from \"@opentelemetry/api\";\nimport { OTLPTraceExporter } from \"@opentelemetry/exporter-trace-otlp-http\";\nimport { defaultResource, resourceFromAttributes } from \"@opentelemetry/resources\";\nimport {\n BatchSpanProcessor,\n ConsoleSpanExporter,\n SimpleSpanProcessor,\n type SpanExporter,\n type SpanProcessor,\n} from \"@opentelemetry/sdk-trace-base\";\nimport { NodeTracerProvider } from \"@opentelemetry/sdk-trace-node\";\n\nimport { K } from \"./attrs.js\";\nimport {\n destinationProblems,\n destinations,\n localEndpointNamed,\n resolveDestinationChoice,\n resolveSettings,\n type Destination,\n type DestinationChoice,\n type Settings,\n type SettingsInput,\n} from \"./config.js\";\nimport { _resetContextForTests, Scope } from \"./context.js\";\nimport { discoverDestination, PendingProcessor, withDiscovered } from \"./destination.js\";\nimport {\n bounded,\n CountingExporter,\n Fanout,\n SwitchableProcessor,\n flushBounded,\n maybeLogFailures,\n resetStats,\n shutdownBounded,\n snapshot,\n stats,\n} from \"./export.js\";\nimport { controlIdle, controlStats, resetControlForTests } from \"./control.js\";\nimport { policyStats, resetPolicyStats, SwitchableSampler, type MaskFn, type ShouldExportFn } from \"./policy.js\";\nimport { applyVendorTracing, dropScopePrefixes, resetVendorTracingForTests, type VendorTracing } from \"./vendor.js\";\nimport { _resetNetInputWarningForTests } from \"./spans.js\";\nimport { clearPromptCache } from \"./prompts.js\";\nimport { resetRuntime, runtime, SDK_MARKER, TRACER_NAME, VERSION } from \"./runtime.js\";\n\nexport { VERSION } from \"./runtime.js\";\nexport {\n admit,\n Degraded,\n DEFAULT_ADMISSION_ENDPOINT,\n DEFAULT_ADMIT_TIMEOUT_MS,\n SDK_ADMIT_PATH,\n parseVerdict,\n type AdmitOptions,\n type Verdict,\n} from \"./admit.js\";\nimport { admitStats, resetAdmitStats } from \"./admit.js\";\nexport {\n DEFAULT_DISCOVER_TIMEOUT_MS,\n DEFAULT_ENDPOINT,\n DEFAULT_EXPORT_TIMEOUT_MS,\n DEFAULT_MAX_CONTENT_CHARS,\n DEFAULT_API_TIMEOUT_MS,\n DEFAULT_NODE_URL,\n DEFAULT_PROMPT_CACHE_TTL_MS,\n DEFAULT_SERVICE_NAME,\n DEFAULT_SHUTDOWN_TIMEOUT_MS,\n DESTINATION_CHOICES,\n destinations,\n parseKvList,\n resolveSettings,\n type Destination,\n type DestinationChoice,\n type Settings,\n type SettingsInput,\n} from \"./config.js\";\nexport { K as Attr, LIMITS, REQUEST_PARAMS, SEMCONV_COMMIT, SEMCONV_SCHEMA_URL } from \"./attrs.js\";\nexport {\n getCurrentAttributes,\n identify,\n propagateAttributes,\n type AttributeScope,\n type PropagateOptions,\n type TraceAttributes,\n} from \"./context.js\";\nexport { DISCOVERY_PATH, isLoopbackUrl, parseDiscovery, readCredentialFile, type Discovered } from \"./destination.js\";\nexport { keepTrace, TRUNCATED_MARK, type MaskFn, type ShouldExportFn } from \"./policy.js\";\nexport { continueTrace, extract, getTraceparent, inject, type Carrier } from \"./propagation.js\";\nexport {\n Kind,\n getCurrentSpanId,\n getCurrentTraceId,\n observe,\n setContent,\n setDocuments,\n setInput,\n setOutput,\n setRequestParams,\n setToolResult,\n setUsage,\n withAgentSpan,\n withEmbeddingSpan,\n withLlmSpan,\n withRetrieverSpan,\n withSpan,\n withToolSpan,\n type AgentInfo,\n type Content,\n type Document,\n type EmbeddingInfo,\n type LlmInfo,\n type ObserveOptions,\n type PromptRef,\n type RequestParams,\n type RetrieverInfo,\n type SpanOptions,\n type SpanKind,\n type ToolInfo,\n type Usage,\n} from \"./spans.js\";\nexport * from \"./scores.js\";\nexport * from \"./cost.js\";\nexport * from \"./prompts.js\";\nexport * from \"./experiments.js\";\nexport * from \"./instrument.js\";\n\nexport interface InitOptions extends SettingsInput {\n /** Also print spans to stdout (debugging). Env: SUPERBASED_CONSOLE. */\n console?: boolean;\n /** A SpanExporter to use instead of OTLP/HTTP (tests, custom transport). Replaces every destination. */\n exporter?: SpanExporter;\n /**\n * A tracer provider to hold the SDK's spans instead of the global one. An\n * OTel JS 1.x provider gets the SDK's processor added; a 2.x provider must\n * have been built with `spanProcessors: [spanProcessor()]`.\n */\n tracerProvider?: TracerProvider;\n /** Rewrite each content value before export (fail-safe: a throw withholds the value). Code only. */\n mask?: MaskFn;\n /** Return false to drop a finished span. Code only. */\n shouldExport?: ShouldExportFn;\n}\n\n/** How the SDK holds spans: its own registered provider, the host's provider, or a private one. */\nexport type Mode = \"\" | \"owned\" | \"attached\" | \"standalone\";\n\ninterface State {\n provider: TracerProvider | null;\n ownProvider: NodeTracerProvider | null;\n mode: Mode;\n configKey: string;\n exitHooked: boolean;\n /** The destinations actually exporting (for diagnostics). */\n active: Destination[];\n problems: string[];\n /** Informational lines (discovery not answering); logged only with debug. */\n notes: string[];\n /** What the machine said about sign-in (null when no machine answered). */\n signedIn: boolean | null;\n /** The settings in force after discovery filled them in. */\n effective: Settings | null;\n ready: Promise<void>;\n /** Model client libraries that trace themselves, as the last init() left them (vendor.ts). */\n vendorTracing: Record<string, VendorTracing>;\n}\n\nconst processor = new SwitchableProcessor();\nconst sampler = new SwitchableSampler();\nlet processorHandedOut = false;\nconst state: State = {\n provider: null,\n ownProvider: null,\n mode: \"\",\n configKey: \"\",\n exitHooked: false,\n active: [],\n problems: [],\n notes: [],\n signedIn: null,\n effective: null,\n ready: Promise.resolve(),\n vendorTracing: {},\n};\nlet ownResource: Record<string, unknown> = {};\nconst objectIds = new WeakMap<object, number>();\nlet nextObjectId = 1;\nlet initGeneration = 0;\n\nfunction oid(o: object | undefined): number {\n if (!o) return 0;\n let id = objectIds.get(o);\n if (!id) {\n id = nextObjectId++;\n objectIds.set(o, id);\n }\n return id;\n}\n\n/**\n * The SDK's span processor, for an app on OpenTelemetry JS 2.x that builds its\n * own provider (2.x providers take processors only at construction):\n *\n * ```ts\n * const provider = new NodeTracerProvider({ spanProcessors: [spanProcessor(), ...yours] });\n * provider.register();\n * init({ serviceName: \"my-app\" }); // exports through that provider\n * ```\n */\nexport function spanProcessor(): SpanProcessor {\n processorHandedOut = true;\n return processor;\n}\n\nfunction globalDelegate(): TracerProvider | null {\n const tp = trace.getTracerProvider();\n const d = tp instanceof ProxyTracerProvider ? tp.getDelegate() : tp;\n const noop = new ProxyTracerProvider().getDelegate();\n if (!d || d.constructor === noop.constructor) return null;\n return d;\n}\n\nfunction addable(tp: TracerProvider): tp is TracerProvider & { addSpanProcessor(p: SpanProcessor): void } {\n return typeof (tp as { addSpanProcessor?: unknown }).addSpanProcessor === \"function\";\n}\n\nfunction warnOnce(lines: string[]): void {\n for (const l of lines) {\n stats.lastError = l;\n stats.lastErrorAt = Date.now();\n try {\n console.warn(`@superbased/sdk: ${l}`);\n } catch {\n // ignore\n }\n }\n}\n\n/** One exporter per destination; each on its own batch processor, so one failing never blocks another. */\nfunction buildDelegate(dests: Destination[], exporter: SpanExporter | undefined, console: boolean): SpanProcessor | null {\n const targets: Destination[] = exporter ? [dests[0] ?? { name: \"local\", endpoint: \"\", headers: {}, timeoutMs: 5000 }] : dests;\n const procs: SpanProcessor[] = targets.map(\n (d) =>\n new BatchSpanProcessor(\n new CountingExporter(\n exporter ?? new OTLPTraceExporter({ url: d.endpoint, headers: d.headers, timeoutMillis: d.timeoutMs }),\n ),\n { exportTimeoutMillis: d.timeoutMs },\n ),\n );\n if (console) procs.push(new SimpleSpanProcessor(new ConsoleSpanExporter()));\n if (procs.length === 0) return null;\n // Each destination's CountingExporter counts a span on its own; the console\n // processor counts nothing (review E-31).\n if (procs.length === 1 && targets.length === 1) return procs[0];\n return new Fanout(procs, targets.length);\n}\n\n/** A delegate that drops (and counts) every span: an online-only choice with no online URL. */\nclass DroppingProcessor implements SpanProcessor {\n onStart(): void {}\n onEnd(): void {\n stats.droppedSpans += 1;\n }\n async forceFlush(): Promise<void> {}\n async shutdown(): Promise<void> {}\n}\n\nfunction installExitHook(): void {\n if (state.exitHooked || typeof process === \"undefined\" || typeof process.on !== \"function\") return;\n state.exitHooked = true;\n let running = false;\n process.on(\"beforeExit\", () => {\n // beforeExit fires again after the flush's work drains; only flush when\n // something is pending, so the loop ends.\n if (running || !runtime.settings?.exitHook || !processor.active) return;\n if (Number(snapshot().pendingSpans) === 0) return;\n running = true;\n void flush().finally(() => {\n running = false;\n });\n });\n}\n\n/**\n * The destination when it can be known without the machine; null = ask the\n * machine first (contract destination.md section 3; sdk-api-surface.md\n * section 6). The machine is asked when nothing chose a destination, and\n * also when an explicit `online` / `both` still lacks a gateway URL or a\n * credential, which discovery supplies (review finding R-B09; Python does\n * the same), and when an explicit `local` / `both` has no endpoint the app\n * named for the local destination: the machine advertises its receiver\n * (live finding L-01). A named endpoint (the option or\n * SUPERBASED_OTLP_ENDPOINT, or under `local` an OTEL_* one) needs no answer.\n */\nfunction syncChoice(opts: InitOptions, env: Record<string, string | undefined>, s: Settings): [DestinationChoice | \"\", string] | null {\n const chosen = resolveDestinationChoice(opts.destination, env);\n const onlineGap = (c: string) => (c === \"online\" || c === \"both\") && (!s.orgUrl || !s.apiKey);\n // A local destination the app named no endpoint for exports to the receiver\n // the machine advertises (a machine on other ports; live finding L-01).\n const localGap = (c: string) => (c === \"local\" || c === \"both\") && !localEndpointNamed(s, c as DestinationChoice);\n const canAsk = s.discover && s.discoverTimeoutMs > 0;\n // A caller-supplied exporter takes every span; control calls follow the choice (\"\" = online when configured, else local).\n if (opts.exporter) return [chosen.choice, \"exporter\"];\n if (chosen.choice && !(canAsk && (onlineGap(chosen.choice) || localGap(chosen.choice)))) return [chosen.choice, chosen.source];\n if (!canAsk) return chosen.choice ? [chosen.choice, chosen.source] : s.orgUrl && s.apiKey ? [\"online\", \"inferred\"] : [\"local\", \"default\"];\n return null;\n}\n\n/** No destination chosen and no machine answered: a gateway and a credential given to the app mean `online`. */\nfunction inferred(s: Settings, otherwise: DestinationChoice): DestinationChoice {\n return s.orgUrl && s.apiKey ? \"online\" : otherwise;\n}\n\nfunction activate(\n s: Settings,\n choice: DestinationChoice | \"\",\n source: string,\n opts: InitOptions,\n printSpans: boolean,\n extraProblems: string[] = [],\n notes: string[] = [],\n signedIn: boolean | null = null,\n): SpanProcessor {\n runtime.settings = s;\n runtime.resourceService = \"\"; // a new init: the next span says which service\n state.effective = s;\n state.notes = notes;\n state.signedIn = signedIn;\n if (s.debug) for (const n of notes) console.info(`@superbased/sdk: ${n}`);\n runtime.destination = choice;\n runtime.destinationSource = source;\n const dests = destinations(s, choice);\n state.active = opts.exporter ? dests.slice(0, 1) : dests;\n state.problems = [\n ...(s.destinationInvalid ? [s.destinationInvalid] : []),\n ...(s.samplingInvalid ? [s.samplingInvalid] : []),\n ...extraProblems,\n ...(opts.exporter ? [] : destinationProblems(s, choice)),\n ];\n if (state.problems.length) warnOnce(state.problems);\n return buildDelegate(dests, opts.exporter, printSpans) ?? new DroppingProcessor();\n}\n\n/**\n * Configure tracing to export to superbased over OTLP/HTTP. Idempotent.\n *\n * Every option maps to an env var (`SUPERBASED_*`, then the standard `OTEL_*`\n * one where it exists); an explicit option wins. See the README's settings\n * table.\n *\n * Destination (D18): `local` (this machine), `online` (the org or SaaS\n * gateway) or `both`, from the option, `SUPERBASED_DESTINATION`, the local\n * Observer's default, then a fallback. See {@link ready}.\n *\n * - No provider registered yet: the SDK registers its own (mode `owned`).\n * - An OTel JS 1.x SDK provider is registered: the SDK adds its processor to\n * it (mode `attached`).\n * - An OTel JS 2.x provider built with `spanProcessors: [spanProcessor()]`:\n * the SDK exports through it (mode `attached`).\n * - Any other provider is registered: the SDK keeps a private provider for\n * its own spans (mode `standalone`); they still join the active trace.\n *\n * A second call with the same settings is a no-op; with different settings it\n * replaces the SDK's exporters in place, shutting the previous ones down.\n */\nexport function init(opts: InitOptions = {}): Settings {\n const { console: consoleOpt, exporter, tracerProvider, mask, shouldExport, ...input } = opts;\n const env = (typeof process !== \"undefined\" ? process.env : {}) as Record<string, string | undefined>;\n const s = resolveSettings(env, input);\n const printSpans = consoleOpt ?? [\"1\", \"true\", \"yes\", \"on\"].includes((env.SUPERBASED_CONSOLE ?? \"\").toLowerCase());\n runtime.settings = s;\n runtime.resourceService = \"\"; // a new init: the next span says which service\n runtime.captureContent = s.captureContent;\n runtime.maxContentChars = s.maxContentChars;\n stats.debug = s.debug;\n sampler.set(s.sampleRate, s.parentBased);\n // A model client library that traces itself (the Anthropic SDKs) would\n // record every call a second time on the provider registered below.\n state.vendorTracing = applyVendorTracing();\n processor.policy = {\n captureContent: s.captureContent,\n maxContentChars: s.maxContentChars,\n mask,\n shouldExport,\n exportRatio: state.mode === \"attached\" ? s.sampleRate : undefined,\n dropScopePrefixes: dropScopePrefixes(state.vendorTracing),\n };\n\n const {\n captureContent: _c,\n maxContentChars: _m,\n exitHook: _e,\n debug: _d,\n sampleRate: _r,\n parentBased: _pb,\n discoverTimeoutMs: _t,\n apiTimeoutMs: _a,\n promptCacheTtlMs: _p,\n ...exportShape\n } = s;\n const configKey = JSON.stringify([exportShape, printSpans, oid(exporter), oid(tracerProvider)]);\n if (processor.active && configKey === state.configKey) return publicView(s);\n\n // Process-wide identity on the resource (contract section 2): release and\n // environment as the standard service.version / deployment.environment.name.\n const base = new Scope().merged({ tenant: s.tenant, user: s.user, sessionId: s.sessionId, tags: s.tags, metadata: s.metadata });\n const ident: Record<string, unknown> = { [K.sdk]: SDK_MARKER, ...base.attributes() };\n if (s.release) ident[K.serviceVersion] = s.release;\n if (s.environment) ident[K.deploymentEnvironment] = s.environment;\n if (!state.provider || (tracerProvider && tracerProvider !== state.provider)) {\n const candidate = tracerProvider ?? globalDelegate();\n if (candidate && candidate === state.ownProvider) {\n state.provider = candidate;\n state.mode = \"owned\";\n } else if (candidate && addable(candidate)) {\n candidate.addSpanProcessor(processor);\n state.provider = candidate;\n state.mode = \"attached\";\n } else if (candidate && processorHandedOut) {\n state.provider = candidate;\n state.mode = \"attached\";\n } else {\n ownResource = { ...s.resourceAttributes, ...ident, \"service.name\": s.serviceName };\n const own = new NodeTracerProvider({\n resource: defaultResource().merge(resourceFromAttributes(ownResource as Record<string, string>)),\n spanProcessors: [processor],\n sampler,\n });\n state.ownProvider = own;\n state.provider = own;\n if (candidate) {\n state.mode = \"standalone\";\n } else {\n own.register();\n state.mode = \"owned\";\n }\n }\n }\n const provider = state.provider!;\n processor.policy.exportRatio = state.mode === \"attached\" ? s.sampleRate : undefined;\n // Identity the holding provider's resource does not carry is stamped on spans.\n const resAttrs = state.mode === \"owned\" || state.mode === \"standalone\" ? ownResource : {};\n const stamp: Record<string, string | string[]> = {};\n for (const [k, v] of Object.entries(ident)) {\n if (JSON.stringify(resAttrs[k]) !== JSON.stringify(v)) stamp[k] = v as string | string[];\n }\n\n processor.shutdownTimeoutMs = s.shutdownTimeoutMs;\n const gen = ++initGeneration;\n const sync = syncChoice(opts, env, s);\n let delegate: SpanProcessor;\n runtime.admissionUrl = \"\";\n if (sync) {\n delegate = activate(s, sync[0], sync[1], opts, printSpans);\n state.ready = Promise.resolve();\n } else {\n const pending = new PendingProcessor();\n delegate = pending;\n runtime.destination = \"\";\n runtime.destinationSource = \"discovering\";\n state.active = [];\n state.problems = [];\n const chosen = resolveDestinationChoice(opts.destination, env);\n state.ready = discoverDestination(s.nodeUrl, s.discoverTimeoutMs).then(({ found, error }) => {\n if (gen !== initGeneration) {\n pending.resolve(null);\n return;\n }\n const notes = error && error !== \"discovery off\" ? [error] : [];\n if (!found) {\n // No machine answered: the explicit choice, else inferred online, else local (a NOTE, not a warning).\n const choice = chosen.choice || inferred(s, \"local\");\n const source = chosen.choice ? chosen.source : choice === \"online\" ? \"inferred\" : \"default\";\n pending.resolve(activate(s, choice, source, opts, printSpans, [], notes));\n return;\n }\n const choice = chosen.choice || found.destination;\n const source = chosen.choice ? chosen.source : \"machine\";\n const { settings: merged, problems } = withDiscovered(s, found, choice);\n runtime.admissionUrl = found.admissionUrl;\n pending.resolve(activate(merged, choice, source, opts, printSpans, problems, notes, found.signedIn));\n });\n }\n // Control calls wait for the destination (review E-33); never rejects.\n runtime.ready = state.ready.then(\n () => undefined,\n () => undefined,\n );\n const old = processor.swap(delegate, stamp);\n if (old) void shutdownBounded(old, s.shutdownTimeoutMs);\n state.configKey = configKey;\n runtime.tracer = provider.getTracer(TRACER_NAME, VERSION);\n runtime.provider = provider;\n installExitHook();\n return publicView(s);\n}\n\nconst views = new WeakMap<Settings, Settings>();\n/** The fields that carry the credential (Python's repr=False fields). */\nconst SECRET_FIELDS = [\"apiKey\", \"headers\", \"onlineHeaders\"] as const;\n\n/**\n * The settings as handed to the app: the same values, with the credential\n * fields (`apiKey`, and the header maps, which may carry `Authorization`)\n * readable but not enumerable, so `console.log`, `JSON.stringify` and a\n * spread never print the key (as Python's Settings repr hides it; review\n * R-C33). The SDK's own copy is unchanged.\n */\nfunction publicView(s: Settings): Settings {\n let v = views.get(s);\n if (!v) {\n v = { ...s };\n for (const f of SECRET_FIELDS) Object.defineProperty(v, f, { value: s[f], enumerable: false, writable: false, configurable: false });\n views.set(s, v);\n }\n return v;\n}\n\n/**\n * Resolves once the destination is known (immediately unless init is asking\n * the local Observer for its default, which takes at most\n * `discoverTimeoutMs`). Spans finished before then are held, not lost.\n */\nexport async function ready(): Promise<DestinationChoice | \"\"> {\n await state.ready;\n return runtime.destination;\n}\n\n/**\n * The settings the last `init()` resolved (null before init). `apiKey` and the\n * header maps are readable but not enumerable, so logging the object never\n * prints the credential.\n */\nexport function settings(): Settings | null {\n return runtime.settings ? publicView(runtime.settings) : null;\n}\n\n/**\n * Export every finished span now. Bounded by `timeoutMs` (default: the\n * shutdownTimeoutMs setting). Resolves true when everything went out in time;\n * never rejects. Await it at the end of a serverless handler.\n */\nexport async function flush(timeoutMs?: number): Promise<boolean> {\n const ms = timeoutMs ?? runtime.settings?.shutdownTimeoutMs ?? 2000;\n const control = bounded(controlIdle(), ms); // pending score / experiment writes\n const d = processor.current;\n let ok = true;\n try {\n if (d) ok = await flushBounded(d, ms);\n } catch {\n ok = false;\n }\n return (await control) && ok;\n}\n\n/**\n * Flush and stop the SDK's exporters. Bounded by `timeoutMs` even when an\n * endpoint is down; never rejects (ECONNREFUSED, 302 and 401 included). The\n * host's provider, when the SDK attached to one, keeps running. A later\n * `init()` starts exporting again.\n */\nexport async function shutdown(timeoutMs?: number): Promise<boolean> {\n const old = processor.swap(null, {});\n state.configKey = \"\";\n if (!old) return true;\n try {\n return await shutdownBounded(old, timeoutMs ?? runtime.settings?.shutdownTimeoutMs ?? 2000);\n } catch {\n return false;\n } finally {\n maybeLogFailures();\n }\n}\n\nexport interface Diagnostics {\n mode: Mode;\n initialized: boolean;\n /** local, online or both, or \"\" while discovering (or before init). */\n destination: DestinationChoice | \"\";\n /** Where it came from: argument, env, machine, inferred, default, exporter, or discovering. */\n destinationSource: string;\n /** The exporters running now. */\n destinations: Array<{ name: string; endpoint: string }>;\n /** Why the destination could not be honoured in full (also logged once as warnings). */\n destinationProblems: string[];\n /** The gateway's base URL in force (\"\" when none). */\n gatewayUrl: string;\n /** The degraded reason (\"\" when the destination is honoured in full; contract destination.md section 7). */\n degraded: string;\n /** Informational lines, for example why discovery got no answer. */\n notes: string[];\n /** What the machine reported about sign-in; null when no machine answered. */\n signedIn: boolean | null;\n /** Where the credential came from: argument, env, file, or \"\" (never the credential itself). */\n credentialSource: string;\n pendingSpans: number;\n exportedSpans: number;\n failedExports: number;\n droppedSpans: number;\n /** Spans left out by head sampling (sampleRate). */\n sampledOutSpans: number;\n /** Spans dropped by shouldExport. */\n filteredSpans: number;\n /** shouldExport hooks that threw (the span was kept). */\n shouldExportErrors: number;\n /** mask hooks that threw (that value was dropped). */\n maskErrors: number;\n lastHookError: string;\n lastError: string;\n /** Epoch ms of the last error, 0 when none. */\n lastErrorAt: number;\n /** Control API calls (scores, prompts, datasets, experiments) made and failed. */\n controlCalls: number;\n controlFailures: number;\n controlLastError: string;\n /** admit() calls that got no decision (admitted, or denied under failClosed), and why the last one (review E-39). */\n admissionDegraded: number;\n admissionLastError: string;\n /** Epoch ms of that last one, 0 when none. */\n admissionLastErrorAt: number;\n /** Per model client library that traces itself (`anthropic`): `off` (init() turned its own spans off; `instrument([...])` records the calls) or `kept` (the app set its switch, e.g. `ANTHROPIC_OPEN_TELEMETRY=true`). */\n vendorTracing: Record<string, VendorTracing>;\n /** Spans from such a library dropped at export (a client built before init()). */\n vendorSpansDropped: number;\n /** setUsage calls whose inputTokens was below its cache parts, recorded as a net count (input + cache). */\n usageNetInputCorrected: number;\n}\n\n/** A snapshot of the SDK's export health. */\nexport function diagnostics(): Diagnostics {\n const snap = snapshot();\n return {\n mode: state.mode,\n initialized: processor.active,\n destination: runtime.destination,\n destinationSource: runtime.destinationSource,\n destinations: state.active.map((d) => ({ name: d.name, endpoint: d.endpoint })),\n destinationProblems: [...state.problems],\n gatewayUrl: state.effective?.orgUrl ?? \"\",\n degraded: state.effective && runtime.destination ? (destinationProblems(state.effective, runtime.destination)[0] ?? \"\") : \"\",\n notes: [...state.notes],\n signedIn: state.signedIn,\n credentialSource: state.effective?.credentialSource ?? \"\",\n pendingSpans: Number(snap.pendingSpans),\n exportedSpans: Number(snap.exportedSpans),\n failedExports: Number(snap.failedExports),\n droppedSpans: Number(snap.droppedSpans),\n sampledOutSpans: Number(snap.sampledOutSpans),\n filteredSpans: Number(snap.filteredSpans),\n shouldExportErrors: Number(snap.shouldExportErrors),\n maskErrors: Number(snap.maskErrors),\n lastHookError: String(snap.lastHookError),\n lastError: String(snap.lastError),\n lastErrorAt: Number(snap.lastErrorAt),\n controlCalls: controlStats.calls,\n controlFailures: controlStats.failures,\n controlLastError: controlStats.lastError,\n admissionDegraded: admitStats.degraded,\n admissionLastError: admitStats.lastError,\n admissionLastErrorAt: admitStats.lastErrorAt,\n vendorTracing: { ...state.vendorTracing },\n vendorSpansDropped: policyStats.vendorSpansDropped,\n usageNetInputCorrected: policyStats.usageNetInputCorrected,\n };\n}\n\n/** Forget all SDK state (tests only). Does not touch the global provider. */\nexport async function _resetForTests(): Promise<void> {\n const old = processor.swap(null, {});\n if (old) await shutdownBounded(old, 1000);\n Object.assign(state, {\n provider: null,\n ownProvider: null,\n mode: \"\",\n configKey: \"\",\n active: [],\n problems: [],\n notes: [],\n signedIn: null,\n effective: null,\n ready: Promise.resolve(),\n vendorTracing: {},\n });\n resetVendorTracingForTests();\n _resetNetInputWarningForTests();\n initGeneration++;\n processorHandedOut = false;\n ownResource = {};\n processor.policy = { captureContent: true, maxContentChars: 0 };\n sampler.set(1, true);\n resetRuntime();\n resetStats();\n resetPolicyStats();\n _resetContextForTests();\n resetControlForTests();\n resetAdmitStats();\n clearPromptCache();\n}\n"]}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * `instrument([...])`: framework auto-instrumentation over the upstream
3
+ * OpenInference JS instrumentations, or OpenLLMetry's (Traceloop) where
4
+ * OpenInference has no JS one (Gemini's `@google/genai`, LlamaIndex.TS)
5
+ * (plan D10: depend on them, own only the wiring and the conformance
6
+ * fixtures; contract sdk-api-surface.md section 10). CrewAI and Pydantic AI
7
+ * are Python-only, so they have no row ({@link PYTHON_ONLY}).
8
+ *
9
+ * Each target is a row of {@link TARGETS}. The instrumentation packages are
10
+ * optional peer dependencies: install the one you need next to the framework
11
+ * (`npm i @arizeai/openinference-instrumentation-openai`). A missing package
12
+ * or framework is reported, never thrown. The spans go through the SDK's
13
+ * provider, so identity, sampling, masking and the destination apply to them
14
+ * like to the SDK's own spans.
15
+ *
16
+ * CommonJS apps: `instrument()` patches the framework module `require`
17
+ * returns, before or after your own `require`. ESM apps import their own
18
+ * copy of the framework, so hand it over: `instrument(["openai"], { modules:
19
+ * { openai: await import("openai") } })`. `vercel-ai` is an AI SDK v7
20
+ * telemetry integration (Node 22+, ESM), registered with `registerTelemetry`;
21
+ * the AI SDK's own spans already use the pinned GenAI semconv, so no
22
+ * OpenInference layer is needed there.
23
+ */
24
+ import { type TracerProvider } from "@opentelemetry/api";
25
+ export declare const INSTRUMENTED = "instrumented";
26
+ export declare const ALREADY = "already";
27
+ export declare const NOT_INSTALLED = "not-installed";
28
+ export type InstrumentTarget = "openai" | "anthropic" | "langchain" | "mcp" | "vercel-ai" | "gemini" | "bedrock" | "llama-index" | "openai-agents";
29
+ interface Ctx {
30
+ provider: TracerProvider;
31
+ /** The framework module(s) the caller handed over, if any. */
32
+ module: unknown;
33
+ }
34
+ interface Active {
35
+ undo(): void;
36
+ }
37
+ /** One instrumentable framework. */
38
+ interface Target {
39
+ name: InstrumentTarget;
40
+ /** The instrumentation package (an optional peer dependency). */
41
+ package: string;
42
+ /** The framework module that must load. */
43
+ library: string;
44
+ note: string;
45
+ /** Instrument; throws on failure. `null` = the host already did. */
46
+ install(ctx: Ctx): Active | null;
47
+ }
48
+ /** The table: one row per target, walked in order. */
49
+ export declare const TARGETS: readonly Target[];
50
+ /** Other names for a target. */
51
+ export declare const ALIASES: Readonly<Record<string, InstrumentTarget>>;
52
+ /**
53
+ * Frameworks that exist only for Python, so this SDK has no row for them.
54
+ * Asking for one is a TypeError naming the reason (not "unknown target").
55
+ */
56
+ export declare const PYTHON_ONLY: Readonly<Record<string, string>>;
57
+ export interface InstrumentOptions {
58
+ /**
59
+ * The framework modules, for an ESM app (or to patch a specific copy):
60
+ * `openai` (the namespace, `await import("openai")`), `anthropic`
61
+ * (`@anthropic-ai/sdk`), `langchain` (`@langchain/core/callbacks/manager`),
62
+ * `mcp` (`{ clientStreamableHTTPModule, serverStreamableHTTPModule, ... }`),
63
+ * `vercel-ai` (`{ ai, otel }`: the `ai` and `@ai-sdk/otel` modules),
64
+ * `gemini` (a COPY of `@google/genai`: `{ ...(await import("@google/genai")) }`,
65
+ * then build `new copy.GoogleGenAI(...)` from it, because the instrumentation
66
+ * replaces the class export), `bedrock` (`@aws-sdk/client-bedrock-runtime`),
67
+ * `llama-index` (`{ llamaindex, openai }`: the `llamaindex` module and,
68
+ * optionally, `@llamaindex/openai`), `openai-agents` (`@openai/agents`).
69
+ */
70
+ modules?: Partial<Record<InstrumentTarget, unknown>>;
71
+ /** The provider the instrumentations write to (default: the SDK's, else the global one). */
72
+ tracerProvider?: TracerProvider;
73
+ }
74
+ /**
75
+ * Turn on auto-instrumentation for `targets` (`openai`, `anthropic`,
76
+ * `langchain` (also `langgraph`), `mcp`, `vercel-ai`, `gemini`, `bedrock`,
77
+ * `llama-index`, `openai-agents`); none given
78
+ * instruments every installed one. Returns `{ target: status }`, status one
79
+ * of `instrumented`, `already`, `not-installed` (install the
80
+ * instrumentation package and the framework) or `error: <message>`. An
81
+ * unknown target is a TypeError. Call after `init()`; idempotent.
82
+ */
83
+ export declare function instrument(targets?: readonly string[], opts?: InstrumentOptions): Record<string, string>;
84
+ /** Undo `instrument()` for `targets` (none given: every instrumented one). Never throws for one that was not instrumented. */
85
+ export declare function uninstrument(targets?: readonly string[]): void;
86
+ /** The targets instrumented now. */
87
+ export declare function instrumented(): InstrumentTarget[];
88
+ export {};
@@ -0,0 +1,391 @@
1
+ /**
2
+ * `instrument([...])`: framework auto-instrumentation over the upstream
3
+ * OpenInference JS instrumentations, or OpenLLMetry's (Traceloop) where
4
+ * OpenInference has no JS one (Gemini's `@google/genai`, LlamaIndex.TS)
5
+ * (plan D10: depend on them, own only the wiring and the conformance
6
+ * fixtures; contract sdk-api-surface.md section 10). CrewAI and Pydantic AI
7
+ * are Python-only, so they have no row ({@link PYTHON_ONLY}).
8
+ *
9
+ * Each target is a row of {@link TARGETS}. The instrumentation packages are
10
+ * optional peer dependencies: install the one you need next to the framework
11
+ * (`npm i @arizeai/openinference-instrumentation-openai`). A missing package
12
+ * or framework is reported, never thrown. The spans go through the SDK's
13
+ * provider, so identity, sampling, masking and the destination apply to them
14
+ * like to the SDK's own spans.
15
+ *
16
+ * CommonJS apps: `instrument()` patches the framework module `require`
17
+ * returns, before or after your own `require`. ESM apps import their own
18
+ * copy of the framework, so hand it over: `instrument(["openai"], { modules:
19
+ * { openai: await import("openai") } })`. `vercel-ai` is an AI SDK v7
20
+ * telemetry integration (Node 22+, ESM), registered with `registerTelemetry`;
21
+ * the AI SDK's own spans already use the pinned GenAI semconv, so no
22
+ * OpenInference layer is needed there.
23
+ */
24
+ import { realpathSync } from "node:fs";
25
+ import { createRequire } from "node:module";
26
+ import { join } from "node:path";
27
+ import { trace } from "@opentelemetry/api";
28
+ import { req } from "./req.js";
29
+ import { runtime } from "./runtime.js";
30
+ export const INSTRUMENTED = "instrumented";
31
+ export const ALREADY = "already";
32
+ export const NOT_INSTALLED = "not-installed";
33
+ /**
34
+ * Load an optional peer (an instrumentation package, or a framework not
35
+ * handed over): from this package's location first, then from the app's.
36
+ *
37
+ * The second look matters when the app installed the SDK from a folder
38
+ * (`npm install ./sdk/typescript`): npm links the folder, Node resolves from
39
+ * its real path, and the peers the app installed beside the framework are
40
+ * not on that path. The app is found from its entry script, then the
41
+ * working directory.
42
+ */
43
+ function load(spec) {
44
+ try {
45
+ return req(spec);
46
+ }
47
+ catch (err) {
48
+ if (err.code !== "MODULE_NOT_FOUND")
49
+ throw err;
50
+ for (const app of appRequires()) {
51
+ try {
52
+ return app(spec);
53
+ }
54
+ catch {
55
+ // not there either; the original error says what is missing
56
+ }
57
+ }
58
+ throw err;
59
+ }
60
+ }
61
+ /** `require`s anchored at the app: its entry script's folder, then the working directory. */
62
+ function appRequires() {
63
+ const anchors = [];
64
+ const entry = typeof process !== "undefined" ? process.argv?.[1] : undefined;
65
+ if (entry) {
66
+ try {
67
+ anchors.push(realpathSync(entry));
68
+ }
69
+ catch {
70
+ anchors.push(entry);
71
+ }
72
+ }
73
+ if (typeof process !== "undefined" && typeof process.cwd === "function")
74
+ anchors.push(join(process.cwd(), "noop.js"));
75
+ const out = [];
76
+ for (const a of anchors) {
77
+ try {
78
+ out.push(createRequire(a));
79
+ }
80
+ catch {
81
+ // an anchor that is not a path
82
+ }
83
+ }
84
+ return out;
85
+ }
86
+ /** An OpenInference class instrumentation patched onto one framework module. */
87
+ function oiClass(name, pkg, cls, library, note = "") {
88
+ return {
89
+ name,
90
+ package: pkg,
91
+ library,
92
+ note,
93
+ install({ provider, module }) {
94
+ const mod = load(pkg);
95
+ if (typeof mod.isPatched === "function" && mod.isPatched())
96
+ return null;
97
+ const Cls = mod[cls];
98
+ const inst = new Cls({ tracerProvider: provider, instrumentationConfig: { enabled: false } });
99
+ inst.setTracerProvider?.(provider);
100
+ const target = module ?? load(library);
101
+ inst.manuallyInstrument(target);
102
+ return {
103
+ undo() {
104
+ inst.disable();
105
+ // Some instrumentations' disable() leaves a manual patch in place (LangChain): unpatch it.
106
+ if (typeof mod.isPatched === "function" && mod.isPatched())
107
+ inst.unpatch?.(target);
108
+ },
109
+ };
110
+ },
111
+ };
112
+ }
113
+ /**
114
+ * An ESM module namespace is sealed: an instrumentation that replaces an
115
+ * export (rather than patching a prototype) cannot write to it. Refuse with
116
+ * the fix instead of a TypeError from deep inside the instrumentation.
117
+ */
118
+ function writable(mod, what, spread) {
119
+ if (mod && typeof mod === "object" && (Object.prototype.toString.call(mod) === "[object Module]" || !Object.isExtensible(mod))) {
120
+ throw new TypeError(`${what} is an ESM module namespace, which cannot be patched; hand over a copy and build the client from it: const m = { ...(await import("${spread}")) }; instrument([...], { modules: { ... m } }); new m.<Client>(...)`);
121
+ }
122
+ }
123
+ /** Call a method of an instrumentation that its types keep private (the unpatch half of a manual patch). */
124
+ function callPrivate(inst, method, ...args) {
125
+ const fn = inst[method];
126
+ if (typeof fn === "function")
127
+ fn.apply(inst, args);
128
+ }
129
+ function traceloop(pkg, cls, provider) {
130
+ const Cls = load(pkg)[cls];
131
+ const inst = new Cls({ enabled: false });
132
+ inst.setTracerProvider(provider);
133
+ return inst;
134
+ }
135
+ const MCP_MODULES = {
136
+ clientStdioModule: "@modelcontextprotocol/sdk/client/stdio.js",
137
+ serverStdioModule: "@modelcontextprotocol/sdk/server/stdio.js",
138
+ clientSSEModule: "@modelcontextprotocol/sdk/client/sse.js",
139
+ serverSSEModule: "@modelcontextprotocol/sdk/server/sse.js",
140
+ clientStreamableHTTPModule: "@modelcontextprotocol/sdk/client/streamableHttp.js",
141
+ serverStreamableHTTPModule: "@modelcontextprotocol/sdk/server/streamableHttp.js",
142
+ };
143
+ /** The table: one row per target, walked in order. */
144
+ export const TARGETS = [
145
+ oiClass("openai", "@arizeai/openinference-instrumentation-openai", "OpenAIInstrumentation", "openai"),
146
+ oiClass("anthropic", "@arizeai/openinference-instrumentation-anthropic", "AnthropicInstrumentation", "@anthropic-ai/sdk"),
147
+ oiClass("langchain", "@arizeai/openinference-instrumentation-langchain", "LangChainInstrumentation", "@langchain/core/callbacks/manager", "covers LangGraph (its runs are LangChain runs)"),
148
+ {
149
+ name: "mcp",
150
+ package: "@arizeai/openinference-instrumentation-mcp",
151
+ library: "@modelcontextprotocol/sdk/client/index.js",
152
+ note: "carries trace context across MCP client and server transports, so server-side spans join the caller's trace",
153
+ install({ module }) {
154
+ const mod = load("@arizeai/openinference-instrumentation-mcp");
155
+ const Cls = mod.MCPInstrumentation;
156
+ const inst = new Cls({ instrumentationConfig: { enabled: false } });
157
+ const given = (module ?? {});
158
+ const mods = {};
159
+ for (const [k, spec] of Object.entries(MCP_MODULES)) {
160
+ if (given[k])
161
+ mods[k] = given[k];
162
+ else if (!module) {
163
+ try {
164
+ mods[k] = load(spec);
165
+ }
166
+ catch {
167
+ // a transport this SDK version lacks
168
+ }
169
+ }
170
+ }
171
+ inst.manuallyInstrument(mods);
172
+ return { undo: () => inst.disable() };
173
+ },
174
+ },
175
+ {
176
+ name: "vercel-ai",
177
+ package: "@ai-sdk/otel",
178
+ library: "ai",
179
+ note: "AI SDK v7 (Node 22+): registers an @ai-sdk/otel telemetry integration, which emits the pinned GenAI semconv spans Observer reads natively",
180
+ install({ provider, module }) {
181
+ const given = (module ?? {});
182
+ const ai = given.ai ?? load("ai");
183
+ const otel = given.otel ?? load("@ai-sdk/otel");
184
+ const OpenTelemetry = otel.OpenTelemetry;
185
+ const integration = new OpenTelemetry({ tracer: provider.getTracer("ai"), usage: true, embedding: true, toolChoice: true });
186
+ ai.registerTelemetry(integration);
187
+ return {
188
+ undo() {
189
+ const list = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS;
190
+ const i = list?.indexOf(integration) ?? -1;
191
+ if (list && i >= 0)
192
+ list.splice(i, 1);
193
+ },
194
+ };
195
+ },
196
+ },
197
+ {
198
+ name: "gemini",
199
+ package: "@traceloop/instrumentation-google-generativeai",
200
+ library: "@google/genai",
201
+ note: "Google Gen AI SDK (@google/genai, Node 22+) over OpenLLMetry's instrumentation: generateContent and generateContentStream on clients built after instrument()",
202
+ install({ provider, module }) {
203
+ const genai = (module ?? load("@google/genai"));
204
+ writable(genai, "the @google/genai module", "@google/genai");
205
+ const inst = traceloop("@traceloop/instrumentation-google-generativeai", "GenAIInstrumentation", provider);
206
+ inst.manuallyInstrument(genai);
207
+ return {
208
+ undo() {
209
+ callPrivate(inst, "unwrap", genai);
210
+ inst.disable();
211
+ },
212
+ };
213
+ },
214
+ },
215
+ {
216
+ name: "bedrock",
217
+ package: "@arizeai/openinference-instrumentation-bedrock",
218
+ library: "@aws-sdk/client-bedrock-runtime",
219
+ note: "AWS Bedrock Runtime (@aws-sdk/client-bedrock-runtime): InvokeModel, Converse and their streaming forms, patched on BedrockRuntimeClient.prototype.send",
220
+ install({ provider, module }) {
221
+ const mod = load("@arizeai/openinference-instrumentation-bedrock");
222
+ if (typeof mod.isPatched === "function" && mod.isPatched())
223
+ return null;
224
+ const Cls = mod.BedrockInstrumentation;
225
+ const inst = new Cls({ tracerProvider: provider, instrumentationConfig: { enabled: false } });
226
+ inst.setTracerProvider?.(provider);
227
+ const target = module ?? load("@aws-sdk/client-bedrock-runtime");
228
+ inst.manuallyInstrument(target);
229
+ return {
230
+ undo() {
231
+ inst.disable();
232
+ if (typeof mod.isPatched === "function" && mod.isPatched())
233
+ callPrivate(inst, "unpatch", target);
234
+ },
235
+ };
236
+ },
237
+ },
238
+ {
239
+ name: "llama-index",
240
+ package: "@traceloop/instrumentation-llamaindex",
241
+ library: "llamaindex",
242
+ note: "LlamaIndex.TS over OpenLLMetry's instrumentation: query and chat engines, retrievers, synthesizers, embeddings and every LLM class the module exports (and @llamaindex/openai's OpenAI when handed over as { llamaindex, openai })",
243
+ install({ provider, module }) {
244
+ const given = module;
245
+ const li = given?.llamaindex ?? (given && !("llamaindex" in given) && !("openai" in given) ? given : load("llamaindex"));
246
+ let oa = given?.openai;
247
+ if (!oa && !given) {
248
+ try {
249
+ oa = load("@llamaindex/openai");
250
+ }
251
+ catch {
252
+ // the OpenAI provider package is optional
253
+ }
254
+ }
255
+ const inst = traceloop("@traceloop/instrumentation-llamaindex", "LlamaIndexInstrumentation", provider);
256
+ inst.manuallyInstrument(li, oa);
257
+ return {
258
+ undo() {
259
+ callPrivate(inst, "unpatch", li);
260
+ if (oa)
261
+ callPrivate(inst, "unpatchOpenAI", oa);
262
+ inst.disable();
263
+ },
264
+ };
265
+ },
266
+ },
267
+ {
268
+ name: "openai-agents",
269
+ package: "@arizeai/openinference-instrumentation-openai-agents",
270
+ library: "@openai/agents",
271
+ note: "OpenAI Agents SDK (@openai/agents): an OpenInference tracing processor added beside the SDK's own processors (agent, generation, function-tool and handoff spans); the app's existing trace processors keep running",
272
+ install({ provider, module }) {
273
+ const mod = load("@arizeai/openinference-instrumentation-openai-agents");
274
+ if (typeof mod.isPatched === "function" && mod.isPatched())
275
+ return null;
276
+ const Cls = mod.OpenAIAgentsInstrumentation;
277
+ const inst = new Cls({ tracerProvider: provider, exclusiveProcessor: false, instrumentationConfig: { enabled: false } });
278
+ inst.manuallyInstrument(module ?? load("@openai/agents"), { exclusiveProcessor: false });
279
+ return {
280
+ undo() {
281
+ inst.uninstrument();
282
+ inst.disable();
283
+ },
284
+ };
285
+ },
286
+ },
287
+ ];
288
+ /** Other names for a target. */
289
+ export const ALIASES = {
290
+ langgraph: "langchain",
291
+ vercel: "vercel-ai",
292
+ ai: "vercel-ai",
293
+ google: "gemini",
294
+ "google-genai": "gemini",
295
+ "aws-bedrock": "bedrock",
296
+ llamaindex: "llama-index",
297
+ llama_index: "llama-index",
298
+ agents: "openai-agents",
299
+ "openai_agents": "openai-agents",
300
+ };
301
+ /**
302
+ * Frameworks that exist only for Python, so this SDK has no row for them.
303
+ * Asking for one is a TypeError naming the reason (not "unknown target").
304
+ */
305
+ export const PYTHON_ONLY = {
306
+ crewai: "CrewAI is a Python framework; there is no JavaScript CrewAI to instrument (use the Python SDK, superbased-sdk[crewai])",
307
+ "pydantic-ai": "Pydantic AI is a Python framework; there is no JavaScript Pydantic AI to instrument (use the Python SDK)",
308
+ pydantic_ai: "Pydantic AI is a Python framework; there is no JavaScript Pydantic AI to instrument (use the Python SDK)",
309
+ };
310
+ const byName = new Map(TARGETS.map((t) => [t.name, t]));
311
+ const active = new Map();
312
+ function names(targets) {
313
+ if (!targets)
314
+ return TARGETS.map((t) => t.name);
315
+ const out = [];
316
+ for (const raw of targets) {
317
+ const n = String(raw).trim().toLowerCase();
318
+ const name = (ALIASES[n] ?? n);
319
+ if (PYTHON_ONLY[n])
320
+ throw new TypeError(`@superbased/sdk: ${PYTHON_ONLY[n]}`);
321
+ if (!byName.has(name)) {
322
+ const known = [...byName.keys(), ...Object.keys(ALIASES)].sort().join(", ");
323
+ throw new TypeError(`@superbased/sdk: unknown instrument target ${JSON.stringify(raw)}; known: ${known}`);
324
+ }
325
+ if (!out.includes(name))
326
+ out.push(name);
327
+ }
328
+ return out;
329
+ }
330
+ function missing(err) {
331
+ const code = err.code;
332
+ return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
333
+ }
334
+ /**
335
+ * Turn on auto-instrumentation for `targets` (`openai`, `anthropic`,
336
+ * `langchain` (also `langgraph`), `mcp`, `vercel-ai`, `gemini`, `bedrock`,
337
+ * `llama-index`, `openai-agents`); none given
338
+ * instruments every installed one. Returns `{ target: status }`, status one
339
+ * of `instrumented`, `already`, `not-installed` (install the
340
+ * instrumentation package and the framework) or `error: <message>`. An
341
+ * unknown target is a TypeError. Call after `init()`; idempotent.
342
+ */
343
+ export function instrument(targets, opts = {}) {
344
+ const list = names(targets ?? (opts.modules ? Object.keys(opts.modules) : undefined));
345
+ const provider = opts.tracerProvider ?? runtime.provider ?? trace.getTracerProvider();
346
+ const out = {};
347
+ for (const name of list) {
348
+ if (active.has(name)) {
349
+ out[name] = ALREADY;
350
+ continue;
351
+ }
352
+ const t = byName.get(name);
353
+ try {
354
+ const got = t.install({ provider, module: opts.modules?.[name] });
355
+ if (got === null) {
356
+ out[name] = ALREADY; // the host instrumented it first
357
+ continue;
358
+ }
359
+ active.set(name, got);
360
+ out[name] = INSTRUMENTED;
361
+ }
362
+ catch (err) {
363
+ if (missing(err)) {
364
+ out[name] = NOT_INSTALLED;
365
+ continue;
366
+ }
367
+ const e = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
368
+ out[name] = `error: ${e}`.slice(0, 300);
369
+ }
370
+ }
371
+ return out;
372
+ }
373
+ /** Undo `instrument()` for `targets` (none given: every instrumented one). Never throws for one that was not instrumented. */
374
+ export function uninstrument(targets) {
375
+ const list = targets ? names(targets) : [...active.keys()];
376
+ for (const name of list) {
377
+ const a = active.get(name);
378
+ active.delete(name);
379
+ try {
380
+ a?.undo();
381
+ }
382
+ catch {
383
+ // ignore
384
+ }
385
+ }
386
+ }
387
+ /** The targets instrumented now. */
388
+ export function instrumented() {
389
+ return [...active.keys()];
390
+ }
391
+ //# sourceMappingURL=instrument.js.map