@ai-sdk/langchain 0.0.0-02dba89b-20251009204516 → 0.0.0-17394c74-20260122151521
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/CHANGELOG.md +1496 -498
- package/README.md +239 -1
- package/dist/index.d.mts +114 -32
- package/dist/index.d.ts +114 -32
- package/dist/index.js +1037 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1045 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -4
- package/src/adapter.ts +520 -0
- package/src/index.ts +12 -0
- package/src/stream-callbacks.ts +65 -0
- package/src/transport.ts +88 -0
- package/src/types.ts +75 -0
- package/src/utils.ts +1587 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type AIMessageChunk } from '@langchain/core/messages';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* State for LangGraph event processing
|
|
5
|
+
*/
|
|
6
|
+
export interface LangGraphEventState {
|
|
7
|
+
/** Tracks which message IDs have been seen */
|
|
8
|
+
messageSeen: Record<
|
|
9
|
+
string,
|
|
10
|
+
{ text?: boolean; reasoning?: boolean; tool?: Record<string, boolean> }
|
|
11
|
+
>;
|
|
12
|
+
/** Accumulates message chunks for later reference */
|
|
13
|
+
messageConcat: Record<string, AIMessageChunk>;
|
|
14
|
+
/** Maps tool call IDs to their message IDs (for chunks that don't include the ID) */
|
|
15
|
+
emittedToolCalls: Set<string>;
|
|
16
|
+
/** Maps image IDs to their message IDs (for chunks that don't include the ID) */
|
|
17
|
+
emittedImages: Set<string>;
|
|
18
|
+
/** Maps reasoning block IDs to their message IDs (for chunks that don't include the ID) */
|
|
19
|
+
emittedReasoningIds: Set<string>;
|
|
20
|
+
/** Maps message IDs to their reasoning block IDs (for chunks that don't include the ID) */
|
|
21
|
+
messageReasoningIds: Record<string, string>;
|
|
22
|
+
/** Maps message ID + tool call index to tool call info (for streaming chunks without ID) */
|
|
23
|
+
toolCallInfoByIndex: Record<
|
|
24
|
+
string,
|
|
25
|
+
Record<number, { id: string; name: string }>
|
|
26
|
+
>;
|
|
27
|
+
/** Tracks the current LangGraph step for start-step/finish-step events */
|
|
28
|
+
currentStep: number | null;
|
|
29
|
+
/** Maps tool call key (name:argsJson) to tool call ID for HITL interrupt handling */
|
|
30
|
+
emittedToolCallsByKey: Map<string, string>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Type for reasoning content block from LangChain
|
|
35
|
+
*/
|
|
36
|
+
export interface ReasoningContentBlock {
|
|
37
|
+
type: 'reasoning';
|
|
38
|
+
reasoning: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Type for thinking content block from LangChain (Anthropic-style)
|
|
43
|
+
*/
|
|
44
|
+
export interface ThinkingContentBlock {
|
|
45
|
+
type: 'thinking';
|
|
46
|
+
thinking: string;
|
|
47
|
+
signature?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Type for GPT-5 reasoning output block
|
|
52
|
+
*/
|
|
53
|
+
export interface GPT5ReasoningOutput {
|
|
54
|
+
id: string;
|
|
55
|
+
type: 'reasoning';
|
|
56
|
+
summary: {
|
|
57
|
+
type: 'summary_text';
|
|
58
|
+
text: string;
|
|
59
|
+
}[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Type for image generation tool outputs from LangChain/OpenAI
|
|
64
|
+
*/
|
|
65
|
+
export interface ImageGenerationOutput {
|
|
66
|
+
id: string;
|
|
67
|
+
type: 'image_generation_call';
|
|
68
|
+
status: string;
|
|
69
|
+
result?: string; // base64 image data
|
|
70
|
+
revised_prompt?: string;
|
|
71
|
+
size?: string;
|
|
72
|
+
output_format?: string;
|
|
73
|
+
quality?: string;
|
|
74
|
+
background?: string;
|
|
75
|
+
}
|