feat: ActionRequired (#5897)
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
getToolConfirmationContent,
|
||||
NotificationEvent,
|
||||
} from '../types/message';
|
||||
import { Message, confirmPermission } from '../api';
|
||||
import { Message, confirmToolAction } from '../api';
|
||||
import ToolCallConfirmation from './ToolCallConfirmation';
|
||||
import MessageCopyLink from './MessageCopyLink';
|
||||
import { cn } from '../utils';
|
||||
@@ -100,22 +100,22 @@ export default function GooseMessage({
|
||||
messageIndex === messageHistoryIndex - 1 &&
|
||||
hasToolConfirmation &&
|
||||
toolConfirmationContent &&
|
||||
!handledToolConfirmations.current.has(toolConfirmationContent.id)
|
||||
!handledToolConfirmations.current.has(toolConfirmationContent.data.id)
|
||||
) {
|
||||
const hasExistingResponse = messages.some((msg) =>
|
||||
getToolResponses(msg).some((response) => response.id === toolConfirmationContent.id)
|
||||
getToolResponses(msg).some((response) => response.id === toolConfirmationContent.data.id)
|
||||
);
|
||||
|
||||
if (!hasExistingResponse) {
|
||||
handledToolConfirmations.current.add(toolConfirmationContent.id);
|
||||
handledToolConfirmations.current.add(toolConfirmationContent.data.id);
|
||||
|
||||
void (async () => {
|
||||
try {
|
||||
await confirmPermission({
|
||||
await confirmToolAction({
|
||||
body: {
|
||||
session_id: sessionId,
|
||||
id: toolConfirmationContent.id,
|
||||
sessionId,
|
||||
action: 'deny',
|
||||
id: toolConfirmationContent.data.id,
|
||||
},
|
||||
throwOnError: true,
|
||||
});
|
||||
@@ -216,7 +216,7 @@ export default function GooseMessage({
|
||||
sessionId={sessionId}
|
||||
isCancelledMessage={messageIndex == messageHistoryIndex - 1}
|
||||
isClicked={messageIndex < messageHistoryIndex}
|
||||
toolConfirmationContent={toolConfirmationContent}
|
||||
actionRequiredContent={toolConfirmationContent}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
|
||||
import { snakeToTitleCase } from '../utils';
|
||||
import PermissionModal from './settings/permission/PermissionModal';
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
import { confirmPermission, ToolConfirmationRequest } from '../api';
|
||||
import { confirmToolAction, ActionRequired } from '../api';
|
||||
import { Button } from './ui/button';
|
||||
|
||||
const ALLOW_ONCE = 'allow_once';
|
||||
@@ -24,16 +24,16 @@ interface ToolConfirmationProps {
|
||||
sessionId: string;
|
||||
isCancelledMessage: boolean;
|
||||
isClicked: boolean;
|
||||
toolConfirmationContent: ToolConfirmationRequest & { type: 'toolConfirmationRequest' };
|
||||
actionRequiredContent: ActionRequired & { type: 'actionRequired' };
|
||||
}
|
||||
|
||||
export default function ToolConfirmation({
|
||||
sessionId,
|
||||
isCancelledMessage,
|
||||
isClicked,
|
||||
toolConfirmationContent,
|
||||
actionRequiredContent,
|
||||
}: ToolConfirmationProps) {
|
||||
const { id: toolConfirmationId, toolName, prompt } = toolConfirmationContent;
|
||||
const { id: toolConfirmationId, toolName, prompt } = actionRequiredContent.data;
|
||||
|
||||
// Check if we have a stored state for this tool confirmation
|
||||
const storedState = toolConfirmationState.get(toolConfirmationId);
|
||||
@@ -96,19 +96,19 @@ export default function ToolConfirmation({
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await confirmPermission({
|
||||
const response = await confirmToolAction({
|
||||
body: {
|
||||
session_id: sessionId,
|
||||
sessionId: sessionId,
|
||||
id: toolConfirmationId,
|
||||
action: newStatus,
|
||||
principal_type: 'Tool',
|
||||
principalType: 'Tool',
|
||||
},
|
||||
});
|
||||
if (response.error) {
|
||||
console.error('Failed to confirm permission:', response.error);
|
||||
console.error('Failed to confirm tool action:', response.error);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error confirming permission:', err);
|
||||
console.error('Error confirming tool action:', err);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user