@struct-ai/sdk 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.
- package/LICENSE +201 -0
- package/README.md +168 -0
- package/dist/commonjs/content-capture.d.ts +10 -0
- package/dist/commonjs/content-capture.js +23 -0
- package/dist/commonjs/context.d.ts +30 -0
- package/dist/commonjs/context.js +94 -0
- package/dist/commonjs/core.d.ts +120 -0
- package/dist/commonjs/core.js +408 -0
- package/dist/commonjs/events.d.ts +12 -0
- package/dist/commonjs/events.js +103 -0
- package/dist/commonjs/index.d.ts +6 -0
- package/dist/commonjs/index.js +10 -0
- package/dist/commonjs/integrations/anthropic-content.d.ts +24 -0
- package/dist/commonjs/integrations/anthropic-content.js +178 -0
- package/dist/commonjs/integrations/anthropic.d.ts +34 -0
- package/dist/commonjs/integrations/anthropic.js +377 -0
- package/dist/commonjs/integrations/index.d.ts +5 -0
- package/dist/commonjs/integrations/index.js +47 -0
- package/dist/commonjs/integrations/langchain-callback.d.ts +134 -0
- package/dist/commonjs/integrations/langchain-callback.js +723 -0
- package/dist/commonjs/integrations/langchain-content.d.ts +35 -0
- package/dist/commonjs/integrations/langchain-content.js +307 -0
- package/dist/commonjs/integrations/langchain.d.ts +11 -0
- package/dist/commonjs/integrations/langchain.js +100 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/semconv.d.ts +54 -0
- package/dist/commonjs/semconv.js +74 -0
- package/dist/commonjs/truncation.d.ts +10 -0
- package/dist/commonjs/truncation.js +103 -0
- package/dist/esm/content-capture.d.ts +10 -0
- package/dist/esm/content-capture.js +17 -0
- package/dist/esm/context.d.ts +30 -0
- package/dist/esm/context.js +80 -0
- package/dist/esm/core.d.ts +120 -0
- package/dist/esm/core.js +403 -0
- package/dist/esm/events.d.ts +12 -0
- package/dist/esm/events.js +99 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/integrations/anthropic-content.d.ts +24 -0
- package/dist/esm/integrations/anthropic-content.js +168 -0
- package/dist/esm/integrations/anthropic.d.ts +34 -0
- package/dist/esm/integrations/anthropic.js +370 -0
- package/dist/esm/integrations/index.d.ts +5 -0
- package/dist/esm/integrations/index.js +42 -0
- package/dist/esm/integrations/langchain-callback.d.ts +134 -0
- package/dist/esm/integrations/langchain-callback.js +719 -0
- package/dist/esm/integrations/langchain-content.d.ts +35 -0
- package/dist/esm/integrations/langchain-content.js +294 -0
- package/dist/esm/integrations/langchain.d.ts +11 -0
- package/dist/esm/integrations/langchain.js +95 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/semconv.d.ts +54 -0
- package/dist/esm/semconv.js +71 -0
- package/dist/esm/truncation.d.ts +10 -0
- package/dist/esm/truncation.js +96 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/content-capture.d.ts +10 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/context.d.ts +30 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/core.d.ts +120 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/events.d.ts +12 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/index.d.ts +6 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/anthropic-content.d.ts +24 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/anthropic.d.ts +34 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/index.d.ts +5 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain-callback.d.ts +134 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain-content.d.ts +35 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain.d.ts +11 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/package.json +3 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/semconv.d.ts +54 -0
- package/dist/node_modules/@struct-ai/sdk/dist/commonjs/truncation.d.ts +10 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/content-capture.d.ts +10 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/context.d.ts +30 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/core.d.ts +120 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/events.d.ts +12 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/index.d.ts +6 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/anthropic-content.d.ts +24 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/anthropic.d.ts +34 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/index.d.ts +5 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain-callback.d.ts +134 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain-content.d.ts +35 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain.d.ts +11 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/package.json +3 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/semconv.d.ts +54 -0
- package/dist/node_modules/@struct-ai/sdk/dist/esm/truncation.d.ts +10 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/commonjs/package.json +3 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/esm/package.json +3 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/package.json +100 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/package.json +103 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/package.json +118 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/package.json +916 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/package.json +188 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api/package.json +96 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api-logs/package.json +91 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/core/package.json +96 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-logs-otlp-proto/package.json +108 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-trace-otlp-proto/package.json +105 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/resources/package.json +100 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-logs/package.json +109 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-base/package.json +100 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-node/package.json +76 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/package.json +140 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/nock/package.json +89 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/tshy/package.json +81 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/typescript/package.json +120 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/vitest/package.json +239 -0
- package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/package.json +100 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/core.d.ts +244 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/error.d.ts +54 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/index.d.ts +188 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/package.json +103 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/pagination.d.ts +26 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/resource.d.ts +6 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/streaming.d.ts +41 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/uploads.d.ts +75 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/version.d.ts +2 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/experimental.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/index.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/package.json +118 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/agents.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/caches.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/chat_history.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/context.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/documents.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/embeddings.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/example_selectors.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/index.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/indexing.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/load.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/memory.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/messages.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/output_parsers.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/outputs.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/package.json +916 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/prompt_values.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/prompts.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/retrievers.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/runnables.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/singletons.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/stores.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/structured_query.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/tools.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/vectorstores.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/index.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/package.json +188 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/prebuilt.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/pregel.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/remote.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/web.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/zod.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api/package.json +96 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api-logs/package.json +91 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/core/package.json +96 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-logs-otlp-proto/package.json +108 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-trace-otlp-proto/package.json +105 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/resources/package.json +100 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-logs/package.json +109 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-base/package.json +100 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-node/package.json +76 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/assert.d.ts +1062 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/async_hooks.d.ts +605 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/buffer.buffer.d.ts +471 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/buffer.d.ts +1936 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/child_process.d.ts +1475 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/cluster.d.ts +577 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/console.d.ts +452 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/constants.d.ts +21 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/crypto.d.ts +4590 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/dgram.d.ts +597 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/dns.d.ts +871 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/domain.d.ts +170 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/events.d.ts +977 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/fs.d.ts +4375 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/globals.d.ts +172 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/http.d.ts +2049 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/http2.d.ts +2631 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/https.d.ts +578 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/index.d.ts +93 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/inspector.generated.d.ts +3966 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/module.d.ts +539 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/net.d.ts +1031 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/os.d.ts +506 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/package.json +140 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/path.d.ts +200 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/perf_hooks.d.ts +961 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/process.d.ts +1961 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/punycode.d.ts +117 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/querystring.d.ts +152 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/readline.d.ts +589 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/repl.d.ts +430 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/sea.d.ts +153 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/stream.d.ts +1698 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/test.d.ts +1787 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/timers.d.ts +286 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/tls.d.ts +1259 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/trace_events.d.ts +197 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/tty.d.ts +208 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/url.d.ts +964 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/util.d.ts +2331 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/v8.d.ts +809 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/vm.d.ts +1001 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/wasi.d.ts +181 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/worker_threads.d.ts +715 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/zlib.d.ts +598 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/nock/package.json +89 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/tshy/package.json +81 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/typescript/package.json +120 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/config.d.ts +3 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/coverage.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/environments.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/globals.d.ts +22 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/import-meta.d.ts +5 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/importMeta.d.ts +4 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/jsdom.d.ts +6 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/mocker.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/node.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/optional-runtime-types.d.ts +6 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/optional-types.d.ts +7 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/package.json +239 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/reporters.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/runners.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/snapshot.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/suite.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/worker.d.ts +1 -0
- package/dist/node_modules/@struct-ai/sdk/package.json +100 -0
- package/package.json +100 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type Tracer } from "@opentelemetry/api";
|
|
2
|
+
import type { Logger } from "@opentelemetry/api-logs";
|
|
3
|
+
import { type StructSDK } from "../core.js";
|
|
4
|
+
type Serialized = {
|
|
5
|
+
lc?: number;
|
|
6
|
+
type?: string;
|
|
7
|
+
id?: string[];
|
|
8
|
+
kwargs?: Record<string, unknown>;
|
|
9
|
+
name?: string;
|
|
10
|
+
};
|
|
11
|
+
type UnknownMessage = unknown;
|
|
12
|
+
interface ChatGenerationLike {
|
|
13
|
+
text?: string;
|
|
14
|
+
message?: UnknownMessage;
|
|
15
|
+
generationInfo?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
interface LLMResultLike {
|
|
18
|
+
generations: ChatGenerationLike[][];
|
|
19
|
+
llmOutput?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* LangChain CallbackHandler — creates OTel spans from LangChain callbacks.
|
|
23
|
+
*
|
|
24
|
+
* Parent-child linkage comes from `parentRunId` fields LangChain passes to us,
|
|
25
|
+
* NOT from OTel's async context. This survives LangGraph's internal task
|
|
26
|
+
* shuffling, which is why the callback API is the industry-standard integration
|
|
27
|
+
* point (LangSmith, OpenInference, Traceloop, Langfuse all use it).
|
|
28
|
+
*
|
|
29
|
+
* thread_id vs gen_ai.conversation.id
|
|
30
|
+
* -----------------------------------
|
|
31
|
+
* These are distinct concepts and Struct keeps them separate:
|
|
32
|
+
*
|
|
33
|
+
* - `config.configurable.thread_id` is LangGraph's checkpoint identifier,
|
|
34
|
+
* keying a conversation's state in the checkpointer. Multiple turns of
|
|
35
|
+
* the same conversation reuse one thread_id so history accumulates.
|
|
36
|
+
*
|
|
37
|
+
* - `gen_ai.conversation.id` is the OTel GenAI-spec conversation identifier
|
|
38
|
+
* and Struct's UI grouping unit — one value = one entry in the sessions
|
|
39
|
+
* list. For the top-level agent we auto-derive it from thread_id, so a
|
|
40
|
+
* stable thread_id across multi-turn chats collapses into one session.
|
|
41
|
+
*
|
|
42
|
+
* For SUBAGENTS (an agent invoked from inside another's tool body) we
|
|
43
|
+
* deliberately assign a DIFFERENT conversation.id — either from the subagent's
|
|
44
|
+
* own thread_id if supplied, or a fresh UUID. The resulting session is
|
|
45
|
+
* linked back to the outer agent's session via the
|
|
46
|
+
* `struct.agent.parent_session_id` span attribute (what powers "Spawned
|
|
47
|
+
* by" / subagent navigation in the UI). Without this split the subagent's
|
|
48
|
+
* spans would collapse into the outer session, burying delegation.
|
|
49
|
+
*
|
|
50
|
+
* LangChain quirk (handled automatically): when `agent.invoke(...)` runs
|
|
51
|
+
* nested inside a parent call, LangChain's config-merge inherits the
|
|
52
|
+
* parent's `metadata.thread_id` onto the child even if its config provided
|
|
53
|
+
* a different one. We detect that by comparing against the nearest agent
|
|
54
|
+
* ancestor's session; if they match, treat it as "inherited, not
|
|
55
|
+
* user-intended" and assign a fresh UUID to the subagent.
|
|
56
|
+
*
|
|
57
|
+
* End-user guidance:
|
|
58
|
+
* - Use thread_id per conversation; multi-turn chats reuse it.
|
|
59
|
+
* - For a subagent call, pass a DIFFERENT thread_id (or omit it and let
|
|
60
|
+
* LangGraph generate one). Each subagent then surfaces as its own
|
|
61
|
+
* session in the UI, linked back via parent_session_id.
|
|
62
|
+
*/
|
|
63
|
+
export declare class StructCallbackHandler {
|
|
64
|
+
private readonly sdk;
|
|
65
|
+
private readonly tracer;
|
|
66
|
+
private readonly logger;
|
|
67
|
+
readonly name = "struct";
|
|
68
|
+
readonly lc_namespace: readonly string[];
|
|
69
|
+
readonly lc_serializable = false;
|
|
70
|
+
readonly awaitHandlers = false;
|
|
71
|
+
readonly ignoreLLM = false;
|
|
72
|
+
readonly ignoreChain = false;
|
|
73
|
+
readonly ignoreAgent = false;
|
|
74
|
+
readonly ignoreRetriever = false;
|
|
75
|
+
readonly ignoreCustomEvent = true;
|
|
76
|
+
/**
|
|
77
|
+
* LangChain reads `raiseError` to decide whether a callback throw should
|
|
78
|
+
* abort the user's run. We keep this `false` because every callback method
|
|
79
|
+
* is wrapped in `safe()` and never throws — but a `true` here would tell
|
|
80
|
+
* LangChain to surface our (impossible) throws into the user's call.
|
|
81
|
+
* Locked by `test_handler_raiseError_is_false`.
|
|
82
|
+
*/
|
|
83
|
+
readonly raiseError = false;
|
|
84
|
+
private readonly runs;
|
|
85
|
+
private readonly internalLogger;
|
|
86
|
+
constructor(sdk: StructSDK, tracer: Tracer, logger: Logger | undefined);
|
|
87
|
+
handleChainStart: (chain: Serialized, inputs: unknown, runId: string, parentRunId?: string, _tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string) => void;
|
|
88
|
+
handleChainEnd: (_outputs: unknown, runId: string) => void;
|
|
89
|
+
handleChainError: (err: Error, runId: string) => void;
|
|
90
|
+
handleChatModelStart: (llm: Serialized, messages: UnknownMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, _tags?: string[], metadata?: Record<string, unknown>, runName?: string) => void;
|
|
91
|
+
handleLLMStart: (llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string) => void;
|
|
92
|
+
handleLLMEnd: (output: LLMResultLike, runId: string) => void;
|
|
93
|
+
handleLLMError: (err: Error, runId: string) => void;
|
|
94
|
+
handleToolStart: (tool: Serialized, input: string, runId: string, parentRunId?: string, _tags?: string[], metadata?: Record<string, unknown>, runName?: string) => void;
|
|
95
|
+
handleToolEnd: (output: unknown, runId: string) => void;
|
|
96
|
+
handleToolError: (err: Error, runId: string) => void;
|
|
97
|
+
handleRetrieverStart: (retriever: Serialized, query: string, runId: string, parentRunId?: string, _tags?: string[], metadata?: Record<string, unknown>, runName?: string) => void;
|
|
98
|
+
handleRetrieverEnd: (documents: unknown[], runId: string) => void;
|
|
99
|
+
handleRetrieverError: (err: Error, runId: string) => void;
|
|
100
|
+
private resolveParent;
|
|
101
|
+
/**
|
|
102
|
+
* Conversation-id resolution for chat/tool/retriever spans — INHERIT from
|
|
103
|
+
* the parent agent so everything rolls up under one gen_ai.conversation.id.
|
|
104
|
+
*/
|
|
105
|
+
private resolveSessionId;
|
|
106
|
+
/**
|
|
107
|
+
* Walk the run tree to find the nearest ``invoke_agent`` ancestor's
|
|
108
|
+
* gen_ai.conversation.id.
|
|
109
|
+
*
|
|
110
|
+
* The immediate ``parentRunId`` might be a tool, LLM, retriever, or a
|
|
111
|
+
* filtered RunnableSequence — none of which are agents themselves. We
|
|
112
|
+
* populate ``nearestAgentSessionId`` at each run's creation so any
|
|
113
|
+
* descendant can read it in O(1).
|
|
114
|
+
*
|
|
115
|
+
* Used to set ``struct.agent.parent_session_id`` on nested ``invoke_agent``
|
|
116
|
+
* spans (our UI's "Spawned by" / "Subagents" linkage).
|
|
117
|
+
*/
|
|
118
|
+
private inheritedAgentSessionId;
|
|
119
|
+
/**
|
|
120
|
+
* Conversation-id resolution for AGENT spans — each agent invocation gets
|
|
121
|
+
* its own gen_ai.conversation.id. We deliberately do NOT inherit from the
|
|
122
|
+
* parent run, so subagents surface as separate entries in the sessions
|
|
123
|
+
* list. Parent linkage is preserved via `struct.agent.parent_session_id`.
|
|
124
|
+
*
|
|
125
|
+
* LangChain inherits `metadata.thread_id` from the parent invoke's config
|
|
126
|
+
* when a nested invoke runs inside it (even if the child config supplied
|
|
127
|
+
* its own). We detect that inheritance by comparing against the parent's
|
|
128
|
+
* resolved session and ignore the inherited value.
|
|
129
|
+
*/
|
|
130
|
+
private resolveAgentSessionId;
|
|
131
|
+
private propagateUserPrompt;
|
|
132
|
+
}
|
|
133
|
+
export {};
|
|
134
|
+
//# sourceMappingURL=langchain-callback.d.ts.map
|