@agent-inspect/langchain 6.31.34 → 6.31.36

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/dist/index.d.cts DELETED
@@ -1,261 +0,0 @@
1
- import { AgentAction, AgentFinish } from '@langchain/core/agents';
2
- import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
3
- import { Serialized } from '@langchain/core/load/serializable';
4
- import { LLMResult } from '@langchain/core/outputs';
5
- import { ChainValues } from '@langchain/core/utils/types';
6
-
7
- type AttributionConfidence = "explicit" | "correlated" | "heuristic" | "unknown";
8
- type InspectKind = "RUN" | "AGENT" | "LLM" | "TOOL" | "CHAIN" | "RETRIEVER" | "DECISION" | "RESULT" | "ERROR" | "LOGIC" | "LOG" | "OUTCOME";
9
- interface EventSource {
10
- type: "manual" | "json-log" | "log4js" | "pino" | "winston" | "adapter";
11
- file?: string;
12
- line?: number;
13
- }
14
- interface InspectEvent {
15
- eventId: string;
16
- runId: string;
17
- parentId?: string;
18
- name: string;
19
- kind: InspectKind;
20
- timestamp: number;
21
- status?: "running" | "ok" | "error";
22
- durationMs?: number;
23
- attributes?: Record<string, unknown>;
24
- confidence: AttributionConfidence;
25
- source: EventSource;
26
- }
27
-
28
- type RedactionStrategy = "full" | "prefix" | "hash";
29
- type RedactionRule = string | {
30
- key: string;
31
- strategy: RedactionStrategy;
32
- keep?: number;
33
- };
34
-
35
- /** Named redaction presets for trace writing and share-safe exports (v1.3.0+). */
36
- type RedactionProfile = "local" | "share" | "strict";
37
-
38
- /**
39
- * Capture policy shared by the official adapters.
40
- *
41
- * `metadata-only` is the default everywhere and never persists framework
42
- * payload content. `preview` opts into bounded, redacted previews.
43
- */
44
- type AdapterCaptureMode = "metadata-only" | "preview";
45
- /** Stable diagnostic codes emitted by shared preview capture. */
46
- declare const ADAPTER_CAPTURE_DIAGNOSTIC_CODES: readonly ["AI_CAPTURE_FIELD_UNAVAILABLE", "AI_CAPTURE_PREVIEW_TRUNCATED", "AI_CAPTURE_PREVIEW_REDACTED"];
47
- type AdapterCaptureDiagnosticCode = (typeof ADAPTER_CAPTURE_DIAGNOSTIC_CODES)[number];
48
- /** One bounded diagnostic. Never contains preview content or filesystem paths. */
49
- interface AdapterCaptureDiagnostic {
50
- readonly code: AdapterCaptureDiagnosticCode;
51
- readonly message: string;
52
- /** Persisted attribute name the diagnostic refers to (e.g. `inputPreview`). */
53
- readonly field: string;
54
- readonly capture: AdapterCaptureMode;
55
- }
56
- /** Optional consumer hook for adapter capture diagnostics. */
57
- type AdapterDiagnosticListener = (diagnostic: AdapterCaptureDiagnostic) => void;
58
- /** Bounded capture counters for adapter `getDiagnostics()` surfaces. */
59
- interface AdapterCaptureDiagnostics {
60
- readonly capture: AdapterCaptureMode;
61
- readonly redactionProfile: RedactionProfile;
62
- readonly maxPreviewChars: number;
63
- readonly previewFieldsCaptured: number;
64
- readonly previewFieldsUnavailable: number;
65
- readonly previewFieldsTruncated: number;
66
- readonly previewFieldsRedacted: number;
67
- readonly lastDiagnosticCode?: AdapterCaptureDiagnosticCode;
68
- readonly lastDiagnosticMessage?: string;
69
- }
70
-
71
- type CaptureMode = "none" | "metadata-only" | "preview";
72
- interface LangChainStreamingOptions {
73
- /**
74
- * Capture streaming lifecycle metadata (chunk counts, duration).
75
- * Does not capture full token text by default.
76
- */
77
- stream?: boolean;
78
- /**
79
- * Maximum streamed preview characters when `capture: "preview"`.
80
- * Defaults to `maxPreviewChars` when omitted.
81
- */
82
- maxStreamPreviewChars?: number;
83
- }
84
- interface AgentInspectCallbackOptions extends LangChainStreamingOptions {
85
- runName?: string;
86
- /** Trace directory for JSONL. When set and `persist` is omitted, persistence is enabled. */
87
- traceDir?: string;
88
- silent?: boolean;
89
- capture?: CaptureMode;
90
- redact?: RedactionRule[];
91
- maxPreviewChars?: number;
92
- /**
93
- * Redaction profile applied to preview attributes before persistence.
94
- * `share` and `strict` also cap `maxPreviewChars`.
95
- *
96
- * @experimental Effective only when `capture: "preview"`.
97
- */
98
- redactionProfile?: RedactionProfile;
99
- /**
100
- * Receives bounded capture diagnostics such as
101
- * `AI_CAPTURE_FIELD_UNAVAILABLE`. Listener failures are isolated.
102
- *
103
- * @experimental
104
- */
105
- onDiagnostic?: AdapterDiagnosticListener;
106
- /**
107
- * Persist callback lifecycle as schemaVersion "0.1" JSONL.
108
- * When omitted: enabled if `traceDir` is set, otherwise in-memory only.
109
- * Explicit `false` forces in-memory even when `traceDir` is set.
110
- */
111
- persist?: boolean;
112
- /** Optional run id for standalone persisted runs (defaults to generated id). */
113
- runId?: string;
114
- }
115
- interface LangChainRunMetadata {
116
- runId: string;
117
- parentRunId?: string;
118
- runName?: string;
119
- tags?: string[];
120
- metadata?: Record<string, unknown>;
121
- }
122
-
123
- /** Subpaths like `@langchain/core/messages/base` are not package exports; derive from the handler contract. */
124
- type ChatModelMessages = Parameters<NonNullable<BaseCallbackHandler["handleChatModelStart"]>>[1];
125
- type RetrieverDocuments = Parameters<NonNullable<BaseCallbackHandler["handleRetrieverEnd"]>>[0];
126
-
127
- declare class AgentInspectCallback extends BaseCallbackHandler {
128
- #private;
129
- name: string;
130
- /**
131
- * Ensure LangGraph/LangChain awaits async handler work (persistence) before
132
- * invoke/stream settles. Required for deterministic standalone envelopes.
133
- */
134
- awaitHandlers: boolean;
135
- constructor(options?: AgentInspectCallbackOptions);
136
- getEvents(): InspectEvent[];
137
- clear(): void;
138
- /**
139
- * Bounded adapter diagnostics for the current invocation (counts only).
140
- * Safe for CLI/MCP summaries — no absolute paths or payloads.
141
- *
142
- * @experimental
143
- */
144
- getDiagnostics(): {
145
- lateEventCount: number;
146
- activeRunCount: number;
147
- endedRunCount: number;
148
- pendingRelationshipCount: number;
149
- knownRelationshipCount: number;
150
- syntheticGroupCount: number;
151
- selfParentRejectedCount: number;
152
- ambiguousRelationshipCount: number;
153
- envelopeStarted: boolean;
154
- finalized: boolean;
155
- completionGeneration: number;
156
- hasTerminalError: boolean;
157
- inMemoryEventCount: number;
158
- deferredPersistStartCount: number;
159
- capture: AdapterCaptureDiagnostics;
160
- };
161
- /**
162
- * Drain deferred completion work (microtask finalization).
163
- * Idempotent. Failures are isolated and never thrown to user code.
164
- *
165
- * @experimental Additive finalization API for serverless / unusual callback shapes.
166
- */
167
- flush(): Promise<void>;
168
- /**
169
- * Complete the standalone envelope when started. Fallback when automatic
170
- * completion cannot run (e.g. process shutdown). Idempotent.
171
- * Failures are isolated and never thrown to user code.
172
- *
173
- * @experimental Additive finalization API for serverless / unusual callback shapes.
174
- */
175
- finalize(options?: {
176
- status?: "success" | "error";
177
- errorMessage?: string;
178
- }): Promise<void>;
179
- /**
180
- * `flush()` then `finalize()`. Idempotent. Failures are isolated.
181
- *
182
- * @experimental Additive finalization API for serverless / unusual callback shapes.
183
- */
184
- close(): Promise<void>;
185
- /**
186
- * Match CallbackManager's runtime call order (parentRunId 4th), same as
187
- * handleLLMStart / handleToolStart — not the declared CallbackHandlerMethods
188
- * TypeScript order that puts runType 4th and parentRunId 8th.
189
- */
190
- handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string, _extra?: Record<string, unknown>): Promise<void>;
191
- handleChainEnd(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], _kwargs?: {
192
- inputs?: Record<string, unknown>;
193
- }): Promise<void>;
194
- handleChainError(err: unknown, runId: string, parentRunId?: string, tags?: string[], _kwargs?: {
195
- inputs?: Record<string, unknown>;
196
- }): Promise<void>;
197
- handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, _extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
198
- handleChatModelStart(llm: Serialized, messages: ChatModelMessages, runId: string, parentRunId?: string, _extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
199
- handleLLMNewToken(token: string, _idx: {
200
- prompt: number;
201
- completion: number;
202
- }, runId: string, _parentRunId?: string, _tags?: string[], _fields?: {
203
- chunk?: unknown;
204
- }): void | Promise<void>;
205
- handleLLMEnd(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], _extraParams?: Record<string, unknown>): Promise<void>;
206
- handleLLMError(err: unknown, runId: string, parentRunId?: string, tags?: string[], _extraParams?: Record<string, unknown>): Promise<void>;
207
- handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, toolCallId?: string): Promise<void>;
208
- handleToolEnd(output: unknown, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
209
- handleToolError(err: unknown, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
210
- handleRetrieverStart(retriever: Serialized, _query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
211
- handleRetrieverEnd(documents: RetrieverDocuments, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
212
- handleRetrieverError(err: unknown, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
213
- handleAgentAction(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
214
- handleAgentEnd(finish: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
215
- }
216
-
217
- /** Options for explicit envelope finalization (serverless / unusual callback shapes). */
218
- interface FinalizeOptions {
219
- status?: "success" | "error";
220
- errorMessage?: string;
221
- endTime?: number;
222
- }
223
- /** Bounded persistence diagnostics (no absolute paths / customer payloads). */
224
- interface AdapterPersistenceDiagnostics {
225
- readonly lateEventCount: number;
226
- readonly activeRunCount: number;
227
- readonly endedRunCount: number;
228
- readonly pendingRelationshipCount: number;
229
- readonly knownRelationshipCount: number;
230
- readonly syntheticGroupCount: number;
231
- readonly selfParentRejectedCount: number;
232
- readonly ambiguousRelationshipCount: number;
233
- readonly envelopeStarted: boolean;
234
- readonly finalized: boolean;
235
- readonly completionGeneration: number;
236
- readonly hasTerminalError: boolean;
237
- }
238
-
239
- interface TokenUsage {
240
- input?: number;
241
- output?: number;
242
- total?: number;
243
- cached?: number;
244
- cacheWrite?: number;
245
- reasoning?: number;
246
- }
247
- /** Extract token usage from LangChain / provider-shaped LLM outputs. Never throws. */
248
- declare function extractTokenUsage(output: unknown): TokenUsage | undefined;
249
- /** Best-effort model name from serialized LLM / chat model or provider metadata. */
250
- declare function extractModelName(serializedOrOutput: unknown): string | undefined;
251
- /**
252
- * Safe truncated string preview for logging-style fields.
253
- *
254
- * Delegates to the shared adapter preview serializer so every official adapter
255
- * bounds and escapes preview values identically.
256
- */
257
- declare function safePreview(value: unknown, maxChars: number): string | undefined;
258
- /** Shallow plain metadata: drops functions/symbols; avoids deep nesting. Never throws. */
259
- declare function toPlainMetadata(value: unknown): Record<string, unknown>;
260
-
261
- export { type AdapterPersistenceDiagnostics, AgentInspectCallback, type AgentInspectCallbackOptions, type CaptureMode, type FinalizeOptions, type LangChainRunMetadata, type LangChainStreamingOptions, type TokenUsage, extractModelName, extractTokenUsage, safePreview, toPlainMetadata };
package/dist/index.d.ts DELETED
@@ -1,261 +0,0 @@
1
- import { AgentAction, AgentFinish } from '@langchain/core/agents';
2
- import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
3
- import { Serialized } from '@langchain/core/load/serializable';
4
- import { LLMResult } from '@langchain/core/outputs';
5
- import { ChainValues } from '@langchain/core/utils/types';
6
-
7
- type AttributionConfidence = "explicit" | "correlated" | "heuristic" | "unknown";
8
- type InspectKind = "RUN" | "AGENT" | "LLM" | "TOOL" | "CHAIN" | "RETRIEVER" | "DECISION" | "RESULT" | "ERROR" | "LOGIC" | "LOG" | "OUTCOME";
9
- interface EventSource {
10
- type: "manual" | "json-log" | "log4js" | "pino" | "winston" | "adapter";
11
- file?: string;
12
- line?: number;
13
- }
14
- interface InspectEvent {
15
- eventId: string;
16
- runId: string;
17
- parentId?: string;
18
- name: string;
19
- kind: InspectKind;
20
- timestamp: number;
21
- status?: "running" | "ok" | "error";
22
- durationMs?: number;
23
- attributes?: Record<string, unknown>;
24
- confidence: AttributionConfidence;
25
- source: EventSource;
26
- }
27
-
28
- type RedactionStrategy = "full" | "prefix" | "hash";
29
- type RedactionRule = string | {
30
- key: string;
31
- strategy: RedactionStrategy;
32
- keep?: number;
33
- };
34
-
35
- /** Named redaction presets for trace writing and share-safe exports (v1.3.0+). */
36
- type RedactionProfile = "local" | "share" | "strict";
37
-
38
- /**
39
- * Capture policy shared by the official adapters.
40
- *
41
- * `metadata-only` is the default everywhere and never persists framework
42
- * payload content. `preview` opts into bounded, redacted previews.
43
- */
44
- type AdapterCaptureMode = "metadata-only" | "preview";
45
- /** Stable diagnostic codes emitted by shared preview capture. */
46
- declare const ADAPTER_CAPTURE_DIAGNOSTIC_CODES: readonly ["AI_CAPTURE_FIELD_UNAVAILABLE", "AI_CAPTURE_PREVIEW_TRUNCATED", "AI_CAPTURE_PREVIEW_REDACTED"];
47
- type AdapterCaptureDiagnosticCode = (typeof ADAPTER_CAPTURE_DIAGNOSTIC_CODES)[number];
48
- /** One bounded diagnostic. Never contains preview content or filesystem paths. */
49
- interface AdapterCaptureDiagnostic {
50
- readonly code: AdapterCaptureDiagnosticCode;
51
- readonly message: string;
52
- /** Persisted attribute name the diagnostic refers to (e.g. `inputPreview`). */
53
- readonly field: string;
54
- readonly capture: AdapterCaptureMode;
55
- }
56
- /** Optional consumer hook for adapter capture diagnostics. */
57
- type AdapterDiagnosticListener = (diagnostic: AdapterCaptureDiagnostic) => void;
58
- /** Bounded capture counters for adapter `getDiagnostics()` surfaces. */
59
- interface AdapterCaptureDiagnostics {
60
- readonly capture: AdapterCaptureMode;
61
- readonly redactionProfile: RedactionProfile;
62
- readonly maxPreviewChars: number;
63
- readonly previewFieldsCaptured: number;
64
- readonly previewFieldsUnavailable: number;
65
- readonly previewFieldsTruncated: number;
66
- readonly previewFieldsRedacted: number;
67
- readonly lastDiagnosticCode?: AdapterCaptureDiagnosticCode;
68
- readonly lastDiagnosticMessage?: string;
69
- }
70
-
71
- type CaptureMode = "none" | "metadata-only" | "preview";
72
- interface LangChainStreamingOptions {
73
- /**
74
- * Capture streaming lifecycle metadata (chunk counts, duration).
75
- * Does not capture full token text by default.
76
- */
77
- stream?: boolean;
78
- /**
79
- * Maximum streamed preview characters when `capture: "preview"`.
80
- * Defaults to `maxPreviewChars` when omitted.
81
- */
82
- maxStreamPreviewChars?: number;
83
- }
84
- interface AgentInspectCallbackOptions extends LangChainStreamingOptions {
85
- runName?: string;
86
- /** Trace directory for JSONL. When set and `persist` is omitted, persistence is enabled. */
87
- traceDir?: string;
88
- silent?: boolean;
89
- capture?: CaptureMode;
90
- redact?: RedactionRule[];
91
- maxPreviewChars?: number;
92
- /**
93
- * Redaction profile applied to preview attributes before persistence.
94
- * `share` and `strict` also cap `maxPreviewChars`.
95
- *
96
- * @experimental Effective only when `capture: "preview"`.
97
- */
98
- redactionProfile?: RedactionProfile;
99
- /**
100
- * Receives bounded capture diagnostics such as
101
- * `AI_CAPTURE_FIELD_UNAVAILABLE`. Listener failures are isolated.
102
- *
103
- * @experimental
104
- */
105
- onDiagnostic?: AdapterDiagnosticListener;
106
- /**
107
- * Persist callback lifecycle as schemaVersion "0.1" JSONL.
108
- * When omitted: enabled if `traceDir` is set, otherwise in-memory only.
109
- * Explicit `false` forces in-memory even when `traceDir` is set.
110
- */
111
- persist?: boolean;
112
- /** Optional run id for standalone persisted runs (defaults to generated id). */
113
- runId?: string;
114
- }
115
- interface LangChainRunMetadata {
116
- runId: string;
117
- parentRunId?: string;
118
- runName?: string;
119
- tags?: string[];
120
- metadata?: Record<string, unknown>;
121
- }
122
-
123
- /** Subpaths like `@langchain/core/messages/base` are not package exports; derive from the handler contract. */
124
- type ChatModelMessages = Parameters<NonNullable<BaseCallbackHandler["handleChatModelStart"]>>[1];
125
- type RetrieverDocuments = Parameters<NonNullable<BaseCallbackHandler["handleRetrieverEnd"]>>[0];
126
-
127
- declare class AgentInspectCallback extends BaseCallbackHandler {
128
- #private;
129
- name: string;
130
- /**
131
- * Ensure LangGraph/LangChain awaits async handler work (persistence) before
132
- * invoke/stream settles. Required for deterministic standalone envelopes.
133
- */
134
- awaitHandlers: boolean;
135
- constructor(options?: AgentInspectCallbackOptions);
136
- getEvents(): InspectEvent[];
137
- clear(): void;
138
- /**
139
- * Bounded adapter diagnostics for the current invocation (counts only).
140
- * Safe for CLI/MCP summaries — no absolute paths or payloads.
141
- *
142
- * @experimental
143
- */
144
- getDiagnostics(): {
145
- lateEventCount: number;
146
- activeRunCount: number;
147
- endedRunCount: number;
148
- pendingRelationshipCount: number;
149
- knownRelationshipCount: number;
150
- syntheticGroupCount: number;
151
- selfParentRejectedCount: number;
152
- ambiguousRelationshipCount: number;
153
- envelopeStarted: boolean;
154
- finalized: boolean;
155
- completionGeneration: number;
156
- hasTerminalError: boolean;
157
- inMemoryEventCount: number;
158
- deferredPersistStartCount: number;
159
- capture: AdapterCaptureDiagnostics;
160
- };
161
- /**
162
- * Drain deferred completion work (microtask finalization).
163
- * Idempotent. Failures are isolated and never thrown to user code.
164
- *
165
- * @experimental Additive finalization API for serverless / unusual callback shapes.
166
- */
167
- flush(): Promise<void>;
168
- /**
169
- * Complete the standalone envelope when started. Fallback when automatic
170
- * completion cannot run (e.g. process shutdown). Idempotent.
171
- * Failures are isolated and never thrown to user code.
172
- *
173
- * @experimental Additive finalization API for serverless / unusual callback shapes.
174
- */
175
- finalize(options?: {
176
- status?: "success" | "error";
177
- errorMessage?: string;
178
- }): Promise<void>;
179
- /**
180
- * `flush()` then `finalize()`. Idempotent. Failures are isolated.
181
- *
182
- * @experimental Additive finalization API for serverless / unusual callback shapes.
183
- */
184
- close(): Promise<void>;
185
- /**
186
- * Match CallbackManager's runtime call order (parentRunId 4th), same as
187
- * handleLLMStart / handleToolStart — not the declared CallbackHandlerMethods
188
- * TypeScript order that puts runType 4th and parentRunId 8th.
189
- */
190
- handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runType?: string, runName?: string, _extra?: Record<string, unknown>): Promise<void>;
191
- handleChainEnd(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], _kwargs?: {
192
- inputs?: Record<string, unknown>;
193
- }): Promise<void>;
194
- handleChainError(err: unknown, runId: string, parentRunId?: string, tags?: string[], _kwargs?: {
195
- inputs?: Record<string, unknown>;
196
- }): Promise<void>;
197
- handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, _extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
198
- handleChatModelStart(llm: Serialized, messages: ChatModelMessages, runId: string, parentRunId?: string, _extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>, runName?: string): Promise<void>;
199
- handleLLMNewToken(token: string, _idx: {
200
- prompt: number;
201
- completion: number;
202
- }, runId: string, _parentRunId?: string, _tags?: string[], _fields?: {
203
- chunk?: unknown;
204
- }): void | Promise<void>;
205
- handleLLMEnd(output: LLMResult, runId: string, parentRunId?: string, tags?: string[], _extraParams?: Record<string, unknown>): Promise<void>;
206
- handleLLMError(err: unknown, runId: string, parentRunId?: string, tags?: string[], _extraParams?: Record<string, unknown>): Promise<void>;
207
- handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, runName?: string, toolCallId?: string): Promise<void>;
208
- handleToolEnd(output: unknown, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
209
- handleToolError(err: unknown, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
210
- handleRetrieverStart(retriever: Serialized, _query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>, name?: string): Promise<void>;
211
- handleRetrieverEnd(documents: RetrieverDocuments, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
212
- handleRetrieverError(err: unknown, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
213
- handleAgentAction(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
214
- handleAgentEnd(finish: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void>;
215
- }
216
-
217
- /** Options for explicit envelope finalization (serverless / unusual callback shapes). */
218
- interface FinalizeOptions {
219
- status?: "success" | "error";
220
- errorMessage?: string;
221
- endTime?: number;
222
- }
223
- /** Bounded persistence diagnostics (no absolute paths / customer payloads). */
224
- interface AdapterPersistenceDiagnostics {
225
- readonly lateEventCount: number;
226
- readonly activeRunCount: number;
227
- readonly endedRunCount: number;
228
- readonly pendingRelationshipCount: number;
229
- readonly knownRelationshipCount: number;
230
- readonly syntheticGroupCount: number;
231
- readonly selfParentRejectedCount: number;
232
- readonly ambiguousRelationshipCount: number;
233
- readonly envelopeStarted: boolean;
234
- readonly finalized: boolean;
235
- readonly completionGeneration: number;
236
- readonly hasTerminalError: boolean;
237
- }
238
-
239
- interface TokenUsage {
240
- input?: number;
241
- output?: number;
242
- total?: number;
243
- cached?: number;
244
- cacheWrite?: number;
245
- reasoning?: number;
246
- }
247
- /** Extract token usage from LangChain / provider-shaped LLM outputs. Never throws. */
248
- declare function extractTokenUsage(output: unknown): TokenUsage | undefined;
249
- /** Best-effort model name from serialized LLM / chat model or provider metadata. */
250
- declare function extractModelName(serializedOrOutput: unknown): string | undefined;
251
- /**
252
- * Safe truncated string preview for logging-style fields.
253
- *
254
- * Delegates to the shared adapter preview serializer so every official adapter
255
- * bounds and escapes preview values identically.
256
- */
257
- declare function safePreview(value: unknown, maxChars: number): string | undefined;
258
- /** Shallow plain metadata: drops functions/symbols; avoids deep nesting. Never throws. */
259
- declare function toPlainMetadata(value: unknown): Record<string, unknown>;
260
-
261
- export { type AdapterPersistenceDiagnostics, AgentInspectCallback, type AgentInspectCallbackOptions, type CaptureMode, type FinalizeOptions, type LangChainRunMetadata, type LangChainStreamingOptions, type TokenUsage, extractModelName, extractTokenUsage, safePreview, toPlainMetadata };