Skip to content

Commit

Permalink
enhance: verify system tool is whitelisted when adding tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhopperlowe committed Sep 11, 2024
1 parent 8809ed1 commit c09d742
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion actions/gptscript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,38 @@ export const parseContent = async (toolContent: string): Promise<Tool[]> => {
) as Tool[];
};

const SystemToolWhitelist = [
'sys.abort',
'sys.append',
'sys.chat.current',
'sys.chat.finish',
'sys.chat.history',
'sys.context',
'sys.download',
'sys.exec',
'sys.find',
'sys.getenv',
'sys.http.get',
'sys.http.html2text',
'sys.http.post',
'sys.ls',
'sys.model.provider.credential',
'sys.prompt',
'sys.read',
'sys.remove',
'sys.stat',
'sys.time.now',
'sys.write',
];

/**
* Verifies that a tool exists by parsing it.
* @param toolRef The tool reference to verify.
* @returns A boolean indicating whether the tool exists.
*/
export const verifyToolExists = async (toolRef: string) => {
// skip verification if the tool is a system tool
if (toolRef.startsWith('sys.')) return true;
if (toolRef.startsWith('sys.')) return SystemToolWhitelist.includes(toolRef);

try {
await gpt().parse(toolRef);
Expand Down

0 comments on commit c09d742

Please sign in to comment.