@langchain/angular 0.0.1 → 0.1.2
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/README.md +68 -7
- package/dist/index.cjs +81 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -26
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +63 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -29
- package/dist/index.js.map +1 -1
- package/dist/stream.custom.cjs +36 -13
- package/dist/stream.custom.cjs.map +1 -1
- package/dist/stream.custom.js +37 -14
- package/dist/stream.custom.js.map +1 -1
- package/package.json +32 -27
package/dist/index.d.cts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import * as _langchain_langgraph_sdk0 from "@langchain/langgraph-sdk";
|
|
2
2
|
import { BagTemplate, Client, DefaultToolCall, DefaultToolCall as DefaultToolCall$1, Interrupt, Message, StreamEvent, StreamMode, ThreadState, ToolCallFromTool, ToolCallState, ToolCallWithResult as ToolCallWithResult$1, ToolCallsFromTools } from "@langchain/langgraph-sdk";
|
|
3
|
-
import * as
|
|
4
|
-
import * as _langchain_langgraph_sdk_ui0 from "@langchain/langgraph-sdk/ui";
|
|
5
|
-
import { AgentTypeConfigLike, AnyStreamOptions, BaseStream, BaseSubagentState, CompiledSubAgentLike, DeepAgentTypeConfigLike, DefaultSubagentStates, ExtractAgentConfig, ExtractDeepAgentConfig, ExtractSubAgentMiddleware, FetchStreamTransport, GetConfigurableType, GetInterruptType, GetToolCallsType, InferAgentToolCalls, InferBag, InferBag as InferBag$1, InferDeepAgentSubagents, InferNodeNames, InferStateType, InferStateType as InferStateType$1, InferSubagentByName, InferSubagentNames, InferSubagentState, InferSubagentStates, InferToolCalls, IsAgentLike, IsDeepAgentLike, MessageMetadata, MessageMetadata as MessageMetadata$1, QueueEntry, QueueInterface, ResolveStreamInterface, ResolveStreamInterface as ResolveStreamInterface$1, ResolveStreamOptions, ResolveStreamOptions as ResolveStreamOptions$1, SubAgentLike, SubagentManager, SubagentStateMap, SubagentStatus, SubagentToolCall, SubmitOptions, UseAgentStream, UseAgentStreamOptions, UseDeepAgentStream, UseDeepAgentStreamOptions, UseStreamCustomOptions, UseStreamCustomOptions as UseStreamCustomOptions$1, UseStreamOptions, UseStreamThread, UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace } from "@langchain/langgraph-sdk/ui";
|
|
3
|
+
import * as _langchain_core_messages0 from "@langchain/core/messages";
|
|
6
4
|
import { AIMessage, BaseMessage, ToolMessage } from "@langchain/core/messages";
|
|
5
|
+
import * as _langchain_langgraph_sdk_ui0 from "@langchain/langgraph-sdk/ui";
|
|
6
|
+
import { AcceptBaseMessages, AgentTypeConfigLike, AnyStreamOptions, BaseStream, BaseSubagentState, CompiledSubAgentLike, DeepAgentTypeConfigLike, DefaultSubagentStates, ExtractAgentConfig, ExtractDeepAgentConfig, ExtractSubAgentMiddleware, FetchStreamTransport, GetConfigurableType, GetInterruptType, GetToolCallsType, InferAgentToolCalls, InferBag, InferBag as InferBag$1, InferDeepAgentSubagents, InferNodeNames, InferStateType, InferStateType as InferStateType$1, InferSubagentByName, InferSubagentNames, InferSubagentState, InferSubagentStates, InferToolCalls, IsAgentLike, IsDeepAgentLike, MessageMetadata, MessageMetadata as MessageMetadata$1, QueueEntry, QueueInterface, ResolveStreamInterface, ResolveStreamInterface as ResolveStreamInterface$1, ResolveStreamOptions, ResolveStreamOptions as ResolveStreamOptions$1, SubAgentLike, SubagentApi, SubagentManager, SubagentStateMap, SubagentStatus, SubagentStream, SubagentStreamInterface, SubagentStreamInterface as SubagentStreamInterface$1, SubagentToolCall, SubmitOptions, UseAgentStream, UseAgentStreamOptions, UseDeepAgentStream, UseDeepAgentStreamOptions, UseStreamCustomOptions, UseStreamCustomOptions as UseStreamCustomOptions$1, UseStreamOptions, UseStreamThread, UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace } from "@langchain/langgraph-sdk/ui";
|
|
7
|
+
import { Signal, WritableSignal } from "@angular/core";
|
|
7
8
|
|
|
8
9
|
//#region src/index.d.ts
|
|
9
10
|
type ClassToolCallWithResult<T> = T extends ToolCallWithResult$1<infer TC, unknown, unknown> ? ToolCallWithResult$1<TC, ToolMessage, AIMessage> : T;
|
|
10
|
-
type
|
|
11
|
+
type ClassSubagentStreamInterface<StateType = Record<string, unknown>, ToolCall = DefaultToolCall$1, SubagentName extends string = string> = Omit<SubagentStreamInterface$1<StateType, ToolCall, SubagentName>, "messages"> & {
|
|
12
|
+
messages: BaseMessage[];
|
|
13
|
+
};
|
|
14
|
+
type WithClassMessages<T> = Omit<T, "messages" | "getMessagesMetadata" | "toolCalls" | "getToolCalls" | "submit" | "subagents" | "activeSubagents" | "getSubagent" | "getSubagentsByType" | "getSubagentsByMessage"> & {
|
|
11
15
|
messages: BaseMessage[];
|
|
12
16
|
getMessagesMetadata: (message: BaseMessage, index?: number) => MessageMetadata$1<Record<string, unknown>> | undefined;
|
|
13
|
-
} & ("
|
|
17
|
+
} & ("submit" extends keyof T ? {
|
|
18
|
+
submit: T extends {
|
|
19
|
+
submit: (values: infer V, options?: infer O) => infer Ret;
|
|
20
|
+
} ? (values: AcceptBaseMessages<Exclude<V, null | undefined>> | null | undefined, options?: O) => Ret : never;
|
|
21
|
+
} : unknown) & ("toolCalls" extends keyof T ? {
|
|
14
22
|
toolCalls: T extends {
|
|
15
23
|
toolCalls: (infer TC)[];
|
|
16
24
|
} ? ClassToolCallWithResult<TC>[] : never;
|
|
@@ -18,9 +26,39 @@ type WithClassMessages<T> = Omit<T, "messages" | "getMessagesMetadata" | "toolCa
|
|
|
18
26
|
getToolCalls: T extends {
|
|
19
27
|
getToolCalls: (message: infer _M) => (infer TC)[];
|
|
20
28
|
} ? (message: AIMessage) => ClassToolCallWithResult<TC>[] : never;
|
|
29
|
+
} : unknown) & ("subagents" extends keyof T ? {
|
|
30
|
+
subagents: T extends {
|
|
31
|
+
subagents: Map<string, SubagentStreamInterface$1<infer S, infer TC, infer N>>;
|
|
32
|
+
} ? Map<string, ClassSubagentStreamInterface<S, TC, N>> : never;
|
|
33
|
+
activeSubagents: T extends {
|
|
34
|
+
activeSubagents: SubagentStreamInterface$1<infer S, infer TC, infer N>[];
|
|
35
|
+
} ? ClassSubagentStreamInterface<S, TC, N>[] : never;
|
|
36
|
+
getSubagent: T extends {
|
|
37
|
+
getSubagent: (id: string) => SubagentStreamInterface$1<infer S, infer TC, infer N> | undefined;
|
|
38
|
+
} ? (toolCallId: string) => ClassSubagentStreamInterface<S, TC, N> | undefined : never;
|
|
39
|
+
getSubagentsByType: T extends {
|
|
40
|
+
getSubagentsByType: (type: string) => SubagentStreamInterface$1<infer S, infer TC, infer N>[];
|
|
41
|
+
} ? (type: string) => ClassSubagentStreamInterface<S, TC, N>[] : never;
|
|
42
|
+
getSubagentsByMessage: T extends {
|
|
43
|
+
getSubagentsByMessage: (id: string) => SubagentStreamInterface$1<infer S, infer TC, infer N>[];
|
|
44
|
+
} ? (messageId: string) => ClassSubagentStreamInterface<S, TC, N>[] : never;
|
|
21
45
|
} : unknown);
|
|
22
|
-
|
|
23
|
-
|
|
46
|
+
type AngularWritableKeys = "isLoading" | "branch";
|
|
47
|
+
type AngularPlainKeys = "submit" | "stop" | "joinStream" | "switchThread" | "setBranch" | "getMessagesMetadata" | "getToolCalls" | "getSubagent" | "getSubagentsByType" | "getSubagentsByMessage" | "subagents" | "activeSubagents" | "client" | "assistantId";
|
|
48
|
+
type AngularQueueInterface<T> = T extends {
|
|
49
|
+
entries: infer E;
|
|
50
|
+
size: infer S;
|
|
51
|
+
cancel: infer C;
|
|
52
|
+
clear: infer Cl;
|
|
53
|
+
} ? {
|
|
54
|
+
entries: WritableSignal<E>;
|
|
55
|
+
size: WritableSignal<S>;
|
|
56
|
+
cancel: C;
|
|
57
|
+
clear: Cl;
|
|
58
|
+
} : T;
|
|
59
|
+
type AngularSignalWrap<T> = { [K in keyof T]: K extends AngularPlainKeys ? T[K] : K extends AngularWritableKeys ? WritableSignal<T[K]> : K extends "queue" ? AngularQueueInterface<T[K]> : Signal<T[K]> };
|
|
60
|
+
declare function useStream<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(options: ResolveStreamOptions$1<T, InferBag$1<T, Bag>>): AngularSignalWrap<WithClassMessages<ResolveStreamInterface$1<T, InferBag$1<T, Bag>>>>;
|
|
61
|
+
declare function useStream<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(options: UseStreamCustomOptions$1<InferStateType$1<T>, InferBag$1<T, Bag>>): AngularSignalWrap<WithClassMessages<ResolveStreamInterface$1<T, InferBag$1<T, Bag>>>>;
|
|
24
62
|
declare function useStreamLGP<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends {
|
|
25
63
|
ConfigurableType?: Record<string, unknown>;
|
|
26
64
|
InterruptType?: unknown;
|
|
@@ -29,19 +67,19 @@ declare function useStreamLGP<StateType extends Record<string, unknown> = Record
|
|
|
29
67
|
} = BagTemplate>(options: AnyStreamOptions<StateType, Bag>): {
|
|
30
68
|
assistantId: string;
|
|
31
69
|
client: Client<_langchain_langgraph_sdk0.DefaultValues, _langchain_langgraph_sdk0.DefaultValues, unknown>;
|
|
32
|
-
values:
|
|
33
|
-
error:
|
|
34
|
-
isLoading:
|
|
35
|
-
branch:
|
|
70
|
+
values: Signal<any>;
|
|
71
|
+
error: Signal<unknown>;
|
|
72
|
+
isLoading: WritableSignal<boolean>;
|
|
73
|
+
branch: WritableSignal<string>;
|
|
36
74
|
setBranch: (value: string) => void;
|
|
37
|
-
messages:
|
|
38
|
-
toolCalls:
|
|
75
|
+
messages: Signal<(BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType> | _langchain_core_messages0.BaseMessageChunk<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>)[]>;
|
|
76
|
+
toolCalls: Signal<ToolCallWithResult$1<DefaultToolCall$1>[]>;
|
|
39
77
|
getToolCalls: (message: Message) => ToolCallWithResult$1<DefaultToolCall$1>[];
|
|
40
|
-
interrupt:
|
|
41
|
-
interrupts:
|
|
42
|
-
history:
|
|
43
|
-
isThreadLoading:
|
|
44
|
-
experimental_branchTree:
|
|
78
|
+
interrupt: Signal<Interrupt<GetInterruptType<Bag>> | undefined>;
|
|
79
|
+
interrupts: Signal<Interrupt<GetInterruptType<Bag>>[]>;
|
|
80
|
+
history: Signal<ThreadState<any>[]>;
|
|
81
|
+
isThreadLoading: Signal<boolean>;
|
|
82
|
+
experimental_branchTree: Signal<_langchain_langgraph_sdk_ui0.Sequence<any>>;
|
|
45
83
|
getMessagesMetadata: (message: Message, index?: number | undefined) => MessageMetadata$1<StateType> | undefined;
|
|
46
84
|
submit: (values: StateType, submitOptions?: SubmitOptions<StateType, GetConfigurableType<Bag>> | undefined) => Promise<void>;
|
|
47
85
|
stop: () => Promise<void>;
|
|
@@ -54,19 +92,19 @@ declare function useStreamLGP<StateType extends Record<string, unknown> = Record
|
|
|
54
92
|
}) => boolean) | undefined;
|
|
55
93
|
} | undefined) => Promise<void>;
|
|
56
94
|
queue: {
|
|
57
|
-
entries:
|
|
58
|
-
size:
|
|
95
|
+
entries: WritableSignal<readonly _langchain_langgraph_sdk_ui0.QueueEntry<StateType, SubmitOptions<StateType, GetConfigurableType<Bag>>>[]>;
|
|
96
|
+
size: WritableSignal<number>;
|
|
59
97
|
cancel(id: string): Promise<boolean>;
|
|
60
98
|
clear(): Promise<void>;
|
|
61
99
|
};
|
|
62
100
|
switchThread(newThreadId: string | null): void;
|
|
63
|
-
readonly subagents: Map<string,
|
|
64
|
-
readonly activeSubagents:
|
|
65
|
-
getSubagent(toolCallId: string):
|
|
66
|
-
getSubagentsByType(type: string):
|
|
67
|
-
getSubagentsByMessage(messageId: string):
|
|
101
|
+
readonly subagents: Map<string, SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string>>;
|
|
102
|
+
readonly activeSubagents: SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string>[];
|
|
103
|
+
getSubagent(toolCallId: string): SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string> | undefined;
|
|
104
|
+
getSubagentsByType(type: string): SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string>[];
|
|
105
|
+
getSubagentsByMessage(messageId: string): SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string>[];
|
|
68
106
|
};
|
|
69
107
|
type ToolCallWithResult<ToolCall = DefaultToolCall$1> = ToolCallWithResult$1<ToolCall, ToolMessage, AIMessage>;
|
|
70
108
|
//#endregion
|
|
71
|
-
export { type AgentTypeConfigLike, type BaseStream, type BaseSubagentState, type CompiledSubAgentLike, type DeepAgentTypeConfigLike, type DefaultSubagentStates, type DefaultToolCall, type ExtractAgentConfig, type ExtractDeepAgentConfig, type ExtractSubAgentMiddleware, FetchStreamTransport, type GetToolCallsType, type InferAgentToolCalls, type InferBag, type InferDeepAgentSubagents, type InferNodeNames, type InferStateType, type InferSubagentByName, type InferSubagentNames, type InferSubagentState, type InferSubagentStates, type InferToolCalls, type IsAgentLike, type IsDeepAgentLike, type MessageMetadata, type QueueEntry, type QueueInterface, type ResolveStreamInterface, type ResolveStreamOptions, type SubAgentLike, SubagentManager, type SubagentStateMap, type SubagentStatus, type SubagentToolCall, type ToolCallFromTool, type ToolCallState, ToolCallWithResult, type ToolCallsFromTools, type UseAgentStream, type UseAgentStreamOptions, type UseDeepAgentStream, type UseDeepAgentStreamOptions, type UseStreamCustomOptions, type UseStreamOptions, type UseStreamThread, type UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace, useStream, useStreamLGP };
|
|
109
|
+
export { type AgentTypeConfigLike, type BaseStream, type BaseSubagentState, ClassSubagentStreamInterface, type CompiledSubAgentLike, type DeepAgentTypeConfigLike, type DefaultSubagentStates, type DefaultToolCall, type ExtractAgentConfig, type ExtractDeepAgentConfig, type ExtractSubAgentMiddleware, FetchStreamTransport, type GetToolCallsType, type InferAgentToolCalls, type InferBag, type InferDeepAgentSubagents, type InferNodeNames, type InferStateType, type InferSubagentByName, type InferSubagentNames, type InferSubagentState, type InferSubagentStates, type InferToolCalls, type IsAgentLike, type IsDeepAgentLike, type MessageMetadata, type QueueEntry, type QueueInterface, type ResolveStreamInterface, type ResolveStreamOptions, type SubAgentLike, type SubagentApi, SubagentManager, type SubagentStateMap, type SubagentStatus, type SubagentStream, type SubagentStreamInterface, type SubagentToolCall, type ToolCallFromTool, type ToolCallState, ToolCallWithResult, type ToolCallsFromTools, type UseAgentStream, type UseAgentStreamOptions, type UseDeepAgentStream, type UseDeepAgentStreamOptions, type UseStreamCustomOptions, type UseStreamOptions, type UseStreamThread, type UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace, useStream, useStreamLGP };
|
|
72
110
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;KAqDK,uBAAA,MACH,CAAA,SAAU,oBAAA,+BACN,oBAAA,CAAoB,EAAA,EAAI,WAAA,EAAiB,SAAA,IACzC,CAAA;AAAA,KAEM,4BAAA,aACE,MAAA,8BACD,iBAAA,0CAET,IAAA,CACF,yBAAA,CAAwB,SAAA,EAAW,QAAA,EAAU,YAAA;EAG7C,QAAA,EAAU,WAAA;AAAA;AAAA,KAGP,iBAAA,MAAuB,IAAA,CAC1B,CAAA;EAYA,QAAA,EAAU,WAAA;EACV,mBAAA,GACE,OAAA,EAAS,WAAA,EACT,KAAA,cACG,iBAAA,CAAgB,MAAA;AA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langgraph_sdk_ui0 from "@langchain/langgraph-sdk/ui";
|
|
3
|
-
import { AgentTypeConfigLike, AnyStreamOptions, BaseStream, BaseSubagentState, CompiledSubAgentLike, DeepAgentTypeConfigLike, DefaultSubagentStates, ExtractAgentConfig, ExtractDeepAgentConfig, ExtractSubAgentMiddleware, FetchStreamTransport, GetConfigurableType, GetInterruptType, GetToolCallsType, InferAgentToolCalls, InferBag, InferBag as InferBag$1, InferDeepAgentSubagents, InferNodeNames, InferStateType, InferStateType as InferStateType$1, InferSubagentByName, InferSubagentNames, InferSubagentState, InferSubagentStates, InferToolCalls, IsAgentLike, IsDeepAgentLike, MessageMetadata, MessageMetadata as MessageMetadata$1, QueueEntry, QueueInterface, ResolveStreamInterface, ResolveStreamInterface as ResolveStreamInterface$1, ResolveStreamOptions, ResolveStreamOptions as ResolveStreamOptions$1, SubAgentLike, SubagentManager, SubagentStateMap, SubagentStatus, SubagentToolCall, SubmitOptions, UseAgentStream, UseAgentStreamOptions, UseDeepAgentStream, UseDeepAgentStreamOptions, UseStreamCustomOptions, UseStreamCustomOptions as UseStreamCustomOptions$1, UseStreamOptions, UseStreamThread, UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace } from "@langchain/langgraph-sdk/ui";
|
|
3
|
+
import { AcceptBaseMessages, AgentTypeConfigLike, AnyStreamOptions, BaseStream, BaseSubagentState, CompiledSubAgentLike, DeepAgentTypeConfigLike, DefaultSubagentStates, ExtractAgentConfig, ExtractDeepAgentConfig, ExtractSubAgentMiddleware, FetchStreamTransport, GetConfigurableType, GetInterruptType, GetToolCallsType, InferAgentToolCalls, InferBag, InferBag as InferBag$1, InferDeepAgentSubagents, InferNodeNames, InferStateType, InferStateType as InferStateType$1, InferSubagentByName, InferSubagentNames, InferSubagentState, InferSubagentStates, InferToolCalls, IsAgentLike, IsDeepAgentLike, MessageMetadata, MessageMetadata as MessageMetadata$1, QueueEntry, QueueInterface, ResolveStreamInterface, ResolveStreamInterface as ResolveStreamInterface$1, ResolveStreamOptions, ResolveStreamOptions as ResolveStreamOptions$1, SubAgentLike, SubagentApi, SubagentManager, SubagentStateMap, SubagentStatus, SubagentStream, SubagentStreamInterface, SubagentStreamInterface as SubagentStreamInterface$1, SubagentToolCall, SubmitOptions, UseAgentStream, UseAgentStreamOptions, UseDeepAgentStream, UseDeepAgentStreamOptions, UseStreamCustomOptions, UseStreamCustomOptions as UseStreamCustomOptions$1, UseStreamOptions, UseStreamThread, UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace } from "@langchain/langgraph-sdk/ui";
|
|
4
4
|
import * as _langchain_langgraph_sdk0 from "@langchain/langgraph-sdk";
|
|
5
5
|
import { BagTemplate, Client, DefaultToolCall, DefaultToolCall as DefaultToolCall$1, Interrupt, Message, StreamEvent, StreamMode, ThreadState, ToolCallFromTool, ToolCallState, ToolCallWithResult as ToolCallWithResult$1, ToolCallsFromTools } from "@langchain/langgraph-sdk";
|
|
6
|
+
import * as _langchain_core_messages0 from "@langchain/core/messages";
|
|
6
7
|
import { AIMessage, BaseMessage, ToolMessage } from "@langchain/core/messages";
|
|
7
8
|
|
|
8
9
|
//#region src/index.d.ts
|
|
9
10
|
type ClassToolCallWithResult<T> = T extends ToolCallWithResult$1<infer TC, unknown, unknown> ? ToolCallWithResult$1<TC, ToolMessage, AIMessage> : T;
|
|
10
|
-
type
|
|
11
|
+
type ClassSubagentStreamInterface<StateType = Record<string, unknown>, ToolCall = DefaultToolCall$1, SubagentName extends string = string> = Omit<SubagentStreamInterface$1<StateType, ToolCall, SubagentName>, "messages"> & {
|
|
12
|
+
messages: BaseMessage[];
|
|
13
|
+
};
|
|
14
|
+
type WithClassMessages<T> = Omit<T, "messages" | "getMessagesMetadata" | "toolCalls" | "getToolCalls" | "submit" | "subagents" | "activeSubagents" | "getSubagent" | "getSubagentsByType" | "getSubagentsByMessage"> & {
|
|
11
15
|
messages: BaseMessage[];
|
|
12
16
|
getMessagesMetadata: (message: BaseMessage, index?: number) => MessageMetadata$1<Record<string, unknown>> | undefined;
|
|
13
|
-
} & ("
|
|
17
|
+
} & ("submit" extends keyof T ? {
|
|
18
|
+
submit: T extends {
|
|
19
|
+
submit: (values: infer V, options?: infer O) => infer Ret;
|
|
20
|
+
} ? (values: AcceptBaseMessages<Exclude<V, null | undefined>> | null | undefined, options?: O) => Ret : never;
|
|
21
|
+
} : unknown) & ("toolCalls" extends keyof T ? {
|
|
14
22
|
toolCalls: T extends {
|
|
15
23
|
toolCalls: (infer TC)[];
|
|
16
24
|
} ? ClassToolCallWithResult<TC>[] : never;
|
|
@@ -18,9 +26,39 @@ type WithClassMessages<T> = Omit<T, "messages" | "getMessagesMetadata" | "toolCa
|
|
|
18
26
|
getToolCalls: T extends {
|
|
19
27
|
getToolCalls: (message: infer _M) => (infer TC)[];
|
|
20
28
|
} ? (message: AIMessage) => ClassToolCallWithResult<TC>[] : never;
|
|
29
|
+
} : unknown) & ("subagents" extends keyof T ? {
|
|
30
|
+
subagents: T extends {
|
|
31
|
+
subagents: Map<string, SubagentStreamInterface$1<infer S, infer TC, infer N>>;
|
|
32
|
+
} ? Map<string, ClassSubagentStreamInterface<S, TC, N>> : never;
|
|
33
|
+
activeSubagents: T extends {
|
|
34
|
+
activeSubagents: SubagentStreamInterface$1<infer S, infer TC, infer N>[];
|
|
35
|
+
} ? ClassSubagentStreamInterface<S, TC, N>[] : never;
|
|
36
|
+
getSubagent: T extends {
|
|
37
|
+
getSubagent: (id: string) => SubagentStreamInterface$1<infer S, infer TC, infer N> | undefined;
|
|
38
|
+
} ? (toolCallId: string) => ClassSubagentStreamInterface<S, TC, N> | undefined : never;
|
|
39
|
+
getSubagentsByType: T extends {
|
|
40
|
+
getSubagentsByType: (type: string) => SubagentStreamInterface$1<infer S, infer TC, infer N>[];
|
|
41
|
+
} ? (type: string) => ClassSubagentStreamInterface<S, TC, N>[] : never;
|
|
42
|
+
getSubagentsByMessage: T extends {
|
|
43
|
+
getSubagentsByMessage: (id: string) => SubagentStreamInterface$1<infer S, infer TC, infer N>[];
|
|
44
|
+
} ? (messageId: string) => ClassSubagentStreamInterface<S, TC, N>[] : never;
|
|
21
45
|
} : unknown);
|
|
22
|
-
|
|
23
|
-
|
|
46
|
+
type AngularWritableKeys = "isLoading" | "branch";
|
|
47
|
+
type AngularPlainKeys = "submit" | "stop" | "joinStream" | "switchThread" | "setBranch" | "getMessagesMetadata" | "getToolCalls" | "getSubagent" | "getSubagentsByType" | "getSubagentsByMessage" | "subagents" | "activeSubagents" | "client" | "assistantId";
|
|
48
|
+
type AngularQueueInterface<T> = T extends {
|
|
49
|
+
entries: infer E;
|
|
50
|
+
size: infer S;
|
|
51
|
+
cancel: infer C;
|
|
52
|
+
clear: infer Cl;
|
|
53
|
+
} ? {
|
|
54
|
+
entries: WritableSignal<E>;
|
|
55
|
+
size: WritableSignal<S>;
|
|
56
|
+
cancel: C;
|
|
57
|
+
clear: Cl;
|
|
58
|
+
} : T;
|
|
59
|
+
type AngularSignalWrap<T> = { [K in keyof T]: K extends AngularPlainKeys ? T[K] : K extends AngularWritableKeys ? WritableSignal<T[K]> : K extends "queue" ? AngularQueueInterface<T[K]> : Signal<T[K]> };
|
|
60
|
+
declare function useStream<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(options: ResolveStreamOptions$1<T, InferBag$1<T, Bag>>): AngularSignalWrap<WithClassMessages<ResolveStreamInterface$1<T, InferBag$1<T, Bag>>>>;
|
|
61
|
+
declare function useStream<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(options: UseStreamCustomOptions$1<InferStateType$1<T>, InferBag$1<T, Bag>>): AngularSignalWrap<WithClassMessages<ResolveStreamInterface$1<T, InferBag$1<T, Bag>>>>;
|
|
24
62
|
declare function useStreamLGP<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends {
|
|
25
63
|
ConfigurableType?: Record<string, unknown>;
|
|
26
64
|
InterruptType?: unknown;
|
|
@@ -29,19 +67,19 @@ declare function useStreamLGP<StateType extends Record<string, unknown> = Record
|
|
|
29
67
|
} = BagTemplate>(options: AnyStreamOptions<StateType, Bag>): {
|
|
30
68
|
assistantId: string;
|
|
31
69
|
client: Client<_langchain_langgraph_sdk0.DefaultValues, _langchain_langgraph_sdk0.DefaultValues, unknown>;
|
|
32
|
-
values:
|
|
33
|
-
error:
|
|
34
|
-
isLoading:
|
|
35
|
-
branch:
|
|
70
|
+
values: Signal<any>;
|
|
71
|
+
error: Signal<unknown>;
|
|
72
|
+
isLoading: WritableSignal<boolean>;
|
|
73
|
+
branch: WritableSignal<string>;
|
|
36
74
|
setBranch: (value: string) => void;
|
|
37
|
-
messages:
|
|
38
|
-
toolCalls:
|
|
75
|
+
messages: Signal<(BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType> | _langchain_core_messages0.BaseMessageChunk<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>)[]>;
|
|
76
|
+
toolCalls: Signal<ToolCallWithResult$1<DefaultToolCall$1>[]>;
|
|
39
77
|
getToolCalls: (message: Message) => ToolCallWithResult$1<DefaultToolCall$1>[];
|
|
40
|
-
interrupt:
|
|
41
|
-
interrupts:
|
|
42
|
-
history:
|
|
43
|
-
isThreadLoading:
|
|
44
|
-
experimental_branchTree:
|
|
78
|
+
interrupt: Signal<Interrupt<GetInterruptType<Bag>> | undefined>;
|
|
79
|
+
interrupts: Signal<Interrupt<GetInterruptType<Bag>>[]>;
|
|
80
|
+
history: Signal<ThreadState<any>[]>;
|
|
81
|
+
isThreadLoading: Signal<boolean>;
|
|
82
|
+
experimental_branchTree: Signal<_langchain_langgraph_sdk_ui0.Sequence<any>>;
|
|
45
83
|
getMessagesMetadata: (message: Message, index?: number | undefined) => MessageMetadata$1<StateType> | undefined;
|
|
46
84
|
submit: (values: StateType, submitOptions?: SubmitOptions<StateType, GetConfigurableType<Bag>> | undefined) => Promise<void>;
|
|
47
85
|
stop: () => Promise<void>;
|
|
@@ -54,19 +92,19 @@ declare function useStreamLGP<StateType extends Record<string, unknown> = Record
|
|
|
54
92
|
}) => boolean) | undefined;
|
|
55
93
|
} | undefined) => Promise<void>;
|
|
56
94
|
queue: {
|
|
57
|
-
entries:
|
|
58
|
-
size:
|
|
95
|
+
entries: WritableSignal<readonly _langchain_langgraph_sdk_ui0.QueueEntry<StateType, SubmitOptions<StateType, GetConfigurableType<Bag>>>[]>;
|
|
96
|
+
size: WritableSignal<number>;
|
|
59
97
|
cancel(id: string): Promise<boolean>;
|
|
60
98
|
clear(): Promise<void>;
|
|
61
99
|
};
|
|
62
100
|
switchThread(newThreadId: string | null): void;
|
|
63
|
-
readonly subagents: Map<string,
|
|
64
|
-
readonly activeSubagents:
|
|
65
|
-
getSubagent(toolCallId: string):
|
|
66
|
-
getSubagentsByType(type: string):
|
|
67
|
-
getSubagentsByMessage(messageId: string):
|
|
101
|
+
readonly subagents: Map<string, SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string>>;
|
|
102
|
+
readonly activeSubagents: SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string>[];
|
|
103
|
+
getSubagent(toolCallId: string): SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string> | undefined;
|
|
104
|
+
getSubagentsByType(type: string): SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string>[];
|
|
105
|
+
getSubagentsByMessage(messageId: string): SubagentStreamInterface$1<Record<string, unknown>, DefaultToolCall$1, string>[];
|
|
68
106
|
};
|
|
69
107
|
type ToolCallWithResult<ToolCall = DefaultToolCall$1> = ToolCallWithResult$1<ToolCall, ToolMessage, AIMessage>;
|
|
70
108
|
//#endregion
|
|
71
|
-
export { type AgentTypeConfigLike, type BaseStream, type BaseSubagentState, type CompiledSubAgentLike, type DeepAgentTypeConfigLike, type DefaultSubagentStates, type DefaultToolCall, type ExtractAgentConfig, type ExtractDeepAgentConfig, type ExtractSubAgentMiddleware, FetchStreamTransport, type GetToolCallsType, type InferAgentToolCalls, type InferBag, type InferDeepAgentSubagents, type InferNodeNames, type InferStateType, type InferSubagentByName, type InferSubagentNames, type InferSubagentState, type InferSubagentStates, type InferToolCalls, type IsAgentLike, type IsDeepAgentLike, type MessageMetadata, type QueueEntry, type QueueInterface, type ResolveStreamInterface, type ResolveStreamOptions, type SubAgentLike, SubagentManager, type SubagentStateMap, type SubagentStatus, type SubagentToolCall, type ToolCallFromTool, type ToolCallState, ToolCallWithResult, type ToolCallsFromTools, type UseAgentStream, type UseAgentStreamOptions, type UseDeepAgentStream, type UseDeepAgentStreamOptions, type UseStreamCustomOptions, type UseStreamOptions, type UseStreamThread, type UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace, useStream, useStreamLGP };
|
|
109
|
+
export { type AgentTypeConfigLike, type BaseStream, type BaseSubagentState, ClassSubagentStreamInterface, type CompiledSubAgentLike, type DeepAgentTypeConfigLike, type DefaultSubagentStates, type DefaultToolCall, type ExtractAgentConfig, type ExtractDeepAgentConfig, type ExtractSubAgentMiddleware, FetchStreamTransport, type GetToolCallsType, type InferAgentToolCalls, type InferBag, type InferDeepAgentSubagents, type InferNodeNames, type InferStateType, type InferSubagentByName, type InferSubagentNames, type InferSubagentState, type InferSubagentStates, type InferToolCalls, type IsAgentLike, type IsDeepAgentLike, type MessageMetadata, type QueueEntry, type QueueInterface, type ResolveStreamInterface, type ResolveStreamOptions, type SubAgentLike, type SubagentApi, SubagentManager, type SubagentStateMap, type SubagentStatus, type SubagentStream, type SubagentStreamInterface, type SubagentToolCall, type ToolCallFromTool, type ToolCallState, ToolCallWithResult, type ToolCallsFromTools, type UseAgentStream, type UseAgentStreamOptions, type UseDeepAgentStream, type UseDeepAgentStreamOptions, type UseStreamCustomOptions, type UseStreamOptions, type UseStreamThread, type UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace, useStream, useStreamLGP };
|
|
72
110
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;KAqDK,uBAAA,MACH,CAAA,SAAU,oBAAA,+BACN,oBAAA,CAAoB,EAAA,EAAI,WAAA,EAAiB,SAAA,IACzC,CAAA;AAAA,KAEM,4BAAA,aACE,MAAA,8BACD,iBAAA,0CAET,IAAA,CACF,yBAAA,CAAwB,SAAA,EAAW,QAAA,EAAU,YAAA;EAG7C,QAAA,EAAU,WAAA;AAAA;AAAA,KAGP,iBAAA,MAAuB,IAAA,CAC1B,CAAA;EAYA,QAAA,EAAU,WAAA;EACV,mBAAA,GACE,OAAA,EAAS,WAAA,EACT,KAAA,cACG,iBAAA,CAAgB,MAAA;AAAA,4BACK,CAAA;EAEpB,MAAA,EAAQ,CAAA;IACN,MAAA,GAAS,MAAA,WAAiB,OAAA;EAAA,KAGtB,MAAA,EACI,kBAAA,CAAmB,OAAA,CAAQ,CAAA,yCAG/B,OAAA,GAAU,CAAA,KACP,GAAA;AAAA,0CAIY,CAAA;EAErB,SAAA,EAAW,CAAA;IAAY,SAAA;EAAA,IACnB,uBAAA,CAAwB,EAAA;AAAA,6CAIJ,CAAA;EAExB,YAAA,EAAc,CAAA;IACZ,YAAA,GAAe,OAAA;EAAA,KAEZ,OAAA,EAAS,SAAA,KAAkB,uBAAA,CAAwB,EAAA;AAAA,0CAInC,CAAA;EAErB,SAAA,EAAW,CAAA;IACT,SAAA,EAAW,GAAA,SAET,yBAAA;EAAA,IAGA,GAAA,SAAY,4BAAA,CAA6B,CAAA,EAAG,EAAA,EAAI,CAAA;EAEpD,eAAA,EAAiB,CAAA;IACf,eAAA,EAAiB,yBAAA;EAAA,IAM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OAAA,EAAS,wBAAA,CAAuB,gBAAA,CAAe,CAAA,GAAI,UAAA,CAAS,CAAA,EAAG,GAAA,KAC9D,iBAAA,CACD,iBAAA,CAAkB,wBAAA,CAAuB,CAAA,EAAG,UAAA,CAAS,CAAA,EAAG,GAAA;AAAA,iBAoB1C,YAAA,mBACI,MAAA,oBAA0B,MAAA;EAE1C,gBAAA,GAAmB,MAAA;EACnB,aAAA;EACA,eAAA;EACA,UAAA;AAAA,IACE,WAAA,CAAA,CACJ,OAAA,EAAS,gBAAA,CAAiB,SAAA,EAAW,GAAA;;iBAAZ,yBAAA,CAAA,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqsBf,kBAAA,YAA8B,iBAAA,IACxC,oBAAA,CAAoB,QAAA,EAAU,WAAA,EAAiB,SAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useStreamCustom } from "./stream.custom.js";
|
|
2
2
|
import { computed, effect, signal } from "@angular/core";
|
|
3
|
-
import { FetchStreamTransport, MessageTupleManager, PendingRunsTracker, StreamError, StreamManager, SubagentManager, calculateDepthFromNamespace, extractInterrupts, extractParentIdFromNamespace, extractToolCallIdFromNamespace, filterStream, getBranchContext, getMessagesMetadataMap, isSubagentNamespace, toMessageClass } from "@langchain/langgraph-sdk/ui";
|
|
3
|
+
import { FetchStreamTransport, MessageTupleManager, PendingRunsTracker, StreamError, StreamManager, SubagentManager, calculateDepthFromNamespace, ensureMessageInstances, extractInterrupts, extractParentIdFromNamespace, extractToolCallIdFromNamespace, filterStream, getBranchContext, getMessagesMetadataMap, isSubagentNamespace, toMessageClass } from "@langchain/langgraph-sdk/ui";
|
|
4
4
|
import { Client } from "@langchain/langgraph-sdk";
|
|
5
5
|
import { getToolCallsWithResults } from "@langchain/langgraph-sdk/utils";
|
|
6
|
-
|
|
7
6
|
//#region src/index.ts
|
|
8
7
|
function fetchHistory(client, threadId, options) {
|
|
9
8
|
if (options?.limit === false) return client.threads.getState(threadId).then((state) => {
|
|
@@ -38,6 +37,7 @@ function useStreamLGP(options) {
|
|
|
38
37
|
};
|
|
39
38
|
const historyLimit = typeof options.fetchStateHistory === "object" && options.fetchStateHistory != null ? options.fetchStateHistory.limit ?? false : options.fetchStateHistory ?? false;
|
|
40
39
|
const threadId = signal(void 0);
|
|
40
|
+
let threadIdPromise = null;
|
|
41
41
|
const client = options.client ?? new Client({ apiUrl: options.apiUrl });
|
|
42
42
|
const history = signal({
|
|
43
43
|
data: void 0,
|
|
@@ -105,11 +105,13 @@ function useStreamLGP(options) {
|
|
|
105
105
|
getMessages,
|
|
106
106
|
branchContext: branchContext()
|
|
107
107
|
}));
|
|
108
|
+
const subagentVersion = signal(0);
|
|
108
109
|
effect((onCleanup) => {
|
|
109
110
|
const unsubscribe = stream.subscribe(() => {
|
|
110
111
|
streamValues.set(stream.values);
|
|
111
112
|
streamError.set(stream.error);
|
|
112
113
|
isLoading.set(stream.isLoading);
|
|
114
|
+
subagentVersion.update((v) => v + 1);
|
|
113
115
|
});
|
|
114
116
|
onCleanup(() => unsubscribe());
|
|
115
117
|
});
|
|
@@ -151,17 +153,20 @@ function useStreamLGP(options) {
|
|
|
151
153
|
return stream.start(async (signal) => {
|
|
152
154
|
usableThreadId = threadId();
|
|
153
155
|
if (!usableThreadId) {
|
|
154
|
-
|
|
156
|
+
const threadPromise = client.threads.create({
|
|
155
157
|
threadId: submitOptions?.threadId,
|
|
156
158
|
metadata: submitOptions?.metadata
|
|
157
|
-
})
|
|
159
|
+
});
|
|
160
|
+
threadIdPromise = threadPromise.then((t) => t.thread_id);
|
|
161
|
+
usableThreadId = (await threadPromise).thread_id;
|
|
158
162
|
threadId.set(usableThreadId);
|
|
159
163
|
options.onThreadId?.(usableThreadId);
|
|
160
164
|
}
|
|
161
165
|
const streamMode = new Set([
|
|
162
166
|
...submitOptions?.streamMode ?? [],
|
|
163
167
|
"values",
|
|
164
|
-
"messages-tuple"
|
|
168
|
+
"messages-tuple",
|
|
169
|
+
"updates"
|
|
165
170
|
]);
|
|
166
171
|
if (options.onUpdateEvent) streamMode.add("updates");
|
|
167
172
|
if (options.onCustomEvent) streamMode.add("custom");
|
|
@@ -224,21 +229,28 @@ function useStreamLGP(options) {
|
|
|
224
229
|
}
|
|
225
230
|
}
|
|
226
231
|
},
|
|
227
|
-
onError: (error) =>
|
|
232
|
+
onError: (error) => {
|
|
233
|
+
options.onError?.(error, callbackMeta);
|
|
234
|
+
submitOptions?.onError?.(error, callbackMeta);
|
|
235
|
+
},
|
|
228
236
|
onFinish: () => {}
|
|
229
237
|
});
|
|
230
238
|
}
|
|
231
239
|
let submitting = false;
|
|
232
|
-
|
|
240
|
+
function drainQueue() {
|
|
233
241
|
if (!isLoading() && !submitting && pendingRuns.size > 0) {
|
|
234
242
|
const next = pendingRuns.shift();
|
|
235
243
|
if (next) {
|
|
236
244
|
submitting = true;
|
|
237
245
|
joinStream(next.id).finally(() => {
|
|
238
246
|
submitting = false;
|
|
247
|
+
drainQueue();
|
|
239
248
|
});
|
|
240
249
|
}
|
|
241
250
|
}
|
|
251
|
+
}
|
|
252
|
+
effect(() => {
|
|
253
|
+
drainQueue();
|
|
242
254
|
});
|
|
243
255
|
async function submit(values, submitOptions) {
|
|
244
256
|
if (stream.isLoading || submitting) {
|
|
@@ -251,27 +263,33 @@ function useStreamLGP(options) {
|
|
|
251
263
|
}
|
|
252
264
|
return;
|
|
253
265
|
}
|
|
254
|
-
|
|
266
|
+
let usableThreadId = threadId();
|
|
267
|
+
if (!usableThreadId && threadIdPromise) usableThreadId = await threadIdPromise;
|
|
255
268
|
if (usableThreadId) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
269
|
+
try {
|
|
270
|
+
const run = await client.runs.create(usableThreadId, options.assistantId, {
|
|
271
|
+
input: values,
|
|
272
|
+
config: submitOptions?.config,
|
|
273
|
+
context: submitOptions?.context,
|
|
274
|
+
command: submitOptions?.command,
|
|
275
|
+
interruptBefore: submitOptions?.interruptBefore,
|
|
276
|
+
interruptAfter: submitOptions?.interruptAfter,
|
|
277
|
+
metadata: submitOptions?.metadata,
|
|
278
|
+
multitaskStrategy: "enqueue",
|
|
279
|
+
streamResumable: true,
|
|
280
|
+
streamSubgraphs: submitOptions?.streamSubgraphs,
|
|
281
|
+
durability: submitOptions?.durability
|
|
282
|
+
});
|
|
283
|
+
pendingRuns.add({
|
|
284
|
+
id: run.run_id,
|
|
285
|
+
values,
|
|
286
|
+
options: submitOptions,
|
|
287
|
+
createdAt: new Date(run.created_at)
|
|
288
|
+
});
|
|
289
|
+
} catch (error) {
|
|
290
|
+
options.onError?.(error, void 0);
|
|
291
|
+
submitOptions?.onError?.(error, void 0);
|
|
292
|
+
}
|
|
275
293
|
return;
|
|
276
294
|
}
|
|
277
295
|
}
|
|
@@ -279,6 +297,7 @@ function useStreamLGP(options) {
|
|
|
279
297
|
const result = submitDirect(values, submitOptions);
|
|
280
298
|
Promise.resolve(result).finally(() => {
|
|
281
299
|
submitting = false;
|
|
300
|
+
drainQueue();
|
|
282
301
|
});
|
|
283
302
|
return result;
|
|
284
303
|
}
|
|
@@ -325,7 +344,7 @@ function useStreamLGP(options) {
|
|
|
325
344
|
}
|
|
326
345
|
}
|
|
327
346
|
});
|
|
328
|
-
const messages = computed(() => getMessages(values()));
|
|
347
|
+
const messages = computed(() => ensureMessageInstances(getMessages(values())));
|
|
329
348
|
const toolCalls = computed(() => getToolCallsWithResults(getMessages(values())));
|
|
330
349
|
function getToolCalls(message) {
|
|
331
350
|
return getToolCallsWithResults(getMessages(values())).filter((tc) => tc.aiMessage.id === message.id);
|
|
@@ -411,9 +430,11 @@ function useStreamLGP(options) {
|
|
|
411
430
|
}
|
|
412
431
|
},
|
|
413
432
|
get subagents() {
|
|
433
|
+
subagentVersion();
|
|
414
434
|
return stream.getSubagents();
|
|
415
435
|
},
|
|
416
436
|
get activeSubagents() {
|
|
437
|
+
subagentVersion();
|
|
417
438
|
return stream.getActiveSubagents();
|
|
418
439
|
},
|
|
419
440
|
getSubagent(toolCallId) {
|
|
@@ -427,7 +448,7 @@ function useStreamLGP(options) {
|
|
|
427
448
|
}
|
|
428
449
|
};
|
|
429
450
|
}
|
|
430
|
-
|
|
431
451
|
//#endregion
|
|
432
452
|
export { FetchStreamTransport, SubagentManager, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace, useStream, useStreamLGP };
|
|
453
|
+
|
|
433
454
|
//# sourceMappingURL=index.js.map
|