feat(chat): 添加权限批准模式切换
This commit is contained in:
@@ -9,7 +9,12 @@ import {
|
||||
resumeAgentChatStream,
|
||||
streamAgentChat,
|
||||
} from "@/lib/chatStream";
|
||||
import type { AgentModel, PermissionReply, StreamEvent } from "@/lib/chatStream";
|
||||
import type {
|
||||
AgentApprovalMode,
|
||||
AgentModel,
|
||||
PermissionReply,
|
||||
StreamEvent,
|
||||
} from "@/lib/chatStream";
|
||||
import type {
|
||||
AgentArtifact,
|
||||
AgentPermissionRequest,
|
||||
@@ -45,6 +50,7 @@ type UseAgentChatSessionOptions = {
|
||||
) => void;
|
||||
onBeforeSend?: () => void;
|
||||
getModel?: () => AgentModel;
|
||||
getApprovalMode?: () => AgentApprovalMode;
|
||||
};
|
||||
|
||||
type PromptRunOptions = {
|
||||
@@ -210,6 +216,7 @@ export const useAgentChatSession = ({
|
||||
onToolCall,
|
||||
onBeforeSend,
|
||||
getModel,
|
||||
getApprovalMode,
|
||||
}: UseAgentChatSessionOptions) => {
|
||||
const hydrationCompletedRef = useRef(false);
|
||||
const hydrationNonceRef = useRef(0);
|
||||
@@ -636,6 +643,7 @@ export const useAgentChatSession = ({
|
||||
message: prompt,
|
||||
sessionId: sessionIdOverride ?? sessionIdRef.current,
|
||||
model: getModel?.(),
|
||||
approvalMode: getApprovalMode?.(),
|
||||
signal: controller.signal,
|
||||
onEvent: (event) =>
|
||||
applyStreamEvent(event, {
|
||||
@@ -686,7 +694,15 @@ export const useAgentChatSession = ({
|
||||
setIsStreaming(false);
|
||||
}
|
||||
},
|
||||
[applyStreamEvent, getModel, isHydrating, isStreaming, messages, onBeforeSend],
|
||||
[
|
||||
applyStreamEvent,
|
||||
getApprovalMode,
|
||||
getModel,
|
||||
isHydrating,
|
||||
isStreaming,
|
||||
messages,
|
||||
onBeforeSend,
|
||||
],
|
||||
);
|
||||
|
||||
const abort = useCallback(() => {
|
||||
|
||||
Reference in New Issue
Block a user