-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathToolPermissionPrompt.tsx
More file actions
72 lines (60 loc) · 1.78 KB
/
ToolPermissionPrompt.tsx
File metadata and controls
72 lines (60 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { BlinkCaret } from "components/BlinkCaret"
import { Box, Text, useInput } from "ink"
import TextInput from "ink-text-input"
import { AgentStore } from "store"
import { getToolInfo } from "utils/getToolInfo"
export const ToolPermissionPrompt: React.FC = () => {
const store = AgentStore.useStoreState((state) => state)
const actions = AgentStore.useStoreActions((actions) => actions)
if (!store.pendingToolPermission) {
return null
}
const { serverName, toolName } = getToolInfo(
store.pendingToolPermission.toolName
)
const handleSubmit = (value: string) => {
const response = value.trim() || "yes"
// Send the permission response to the waiting canUseTool call
store.messageQueue.sendPermissionResponse(response)
actions.setPendingToolPermission(undefined)
actions.setInput("")
}
useInput((_input, key) => {
if (key.escape) {
handleSubmit("no")
}
})
return (
<Box flexDirection="column" marginBottom={1}>
<Text bold color="yellow">
[Tool Permission Request]
</Text>
<Box marginLeft={2} flexDirection="column">
<Box>
<Text bold>Tool: </Text>
{serverName ? (
<>
<Text color="cyan">[{serverName}]</Text>
<Text> {toolName}</Text>
</>
) : (
<Text>{toolName}</Text>
)}
</Box>
<Box marginTop={1}>
<Text dimColor>
Allow? (Enter=yes, ESC=no, or ask another question):{" "}
</Text>
</Box>
<Box>
<BlinkCaret interval={100} color="green" enabled />
<TextInput
value={store.input}
onChange={actions.setInput}
onSubmit={handleSubmit}
/>
</Box>
</Box>
</Box>
)
}