11import { join } from "jsr:@std/path"
22import Anthropic from "npm:@anthropic-ai/sdk"
33import { homedir } from "node:os"
4- import { loadUserSettings } from "./settings.ts"
4+ import { isJinaAvailable , loadUserSettings } from "./settings.ts"
55
66export const EDITOR_DIR = join ( homedir ( ) , ".ComputerUseAgent" , "editor_dir" )
77export const SESSIONS_DIR = join ( homedir ( ) , ".ComputerUseAgent" , "sessions" )
@@ -63,6 +63,15 @@ You have access to following tools and capabilities:
6363- CLIPBOARD_TOOLS:
6464 - Name: "read_clipboard"
6565 - Arguments: none
66+ ${ isJinaAvailable ( ) ? `
67+ - JINA_TOOLS:
68+ - Name: "readPage"
69+ - Arguments: {url: string}
70+ - Name: "search"
71+ - Arguments: {searchTerm: string}
72+ - Name: "searchGrounding"
73+ - Arguments: {searchTerm: string}
74+ ` : '' }
6675
6776Before taking any action, follow these steps:
6877
@@ -93,6 +102,15 @@ Your capabilities include:
93102 - Can add, retrieve, and clear memories
94103 - Use memory for context persistence
95104
105+ 4. Clipboard Access:
106+ - Can read content from the system clipboard
107+ ${ isJinaAvailable ( ) ? `
108+ 5. Jina API Integration:
109+ - Can read and parse content from a URL
110+ - Can search content using Jina Search API
111+ - Can search with grounding using Jina Grounding API
112+ ` : '' }
113+
96114Always present your solution in this order:
971151. Understanding of the request
981162. Step-by-step plan
@@ -101,7 +119,7 @@ Always present your solution in this order:
101119export const API_CONFIG = {
102120 MODEL : "claude-3-5-sonnet-20241022" ,
103121 INTENT_MODEL : "claude-3-5-haiku-20241022" ,
104- MAX_TOKENS : 4096 ,
122+ MAX_TOKENS : 8192 ,
105123 MAX_INTENT_TOKENS : 20 ,
106124}
107125
@@ -150,12 +168,66 @@ export const CLIPBOARD_TOOLS: Anthropic.Beta.BetaTool[] = [
150168 }
151169]
152170
171+ export const JINA_TOOLS : Anthropic . Beta . BetaTool [ ] = [
172+ {
173+ type : "custom" ,
174+ name : "readPage" ,
175+ description : "Read and parse content from a URL using Jina Reader API" ,
176+ input_schema : {
177+ type : "object" ,
178+ properties : {
179+ url : {
180+ type : "string" ,
181+ description : "The URL to read and parse" ,
182+ } ,
183+ } ,
184+ required : [ "url" ] ,
185+ } ,
186+ } ,
187+ {
188+ type : "custom" ,
189+ name : "search" ,
190+ description : "Search content using Jina Search API" ,
191+ input_schema : {
192+ type : "object" ,
193+ properties : {
194+ searchTerm : {
195+ type : "string" ,
196+ description : "The term to search for" ,
197+ } ,
198+ } ,
199+ required : [ "searchTerm" ] ,
200+ } ,
201+ } ,
202+ {
203+ type : "custom" ,
204+ name : "searchGrounding" ,
205+ description : "Search with grounding using Jina Grounding API" ,
206+ input_schema : {
207+ type : "object" ,
208+ properties : {
209+ searchTerm : {
210+ type : "string" ,
211+ description : "The term to search for with grounding" ,
212+ } ,
213+ } ,
214+ required : [ "searchTerm" ] ,
215+ } ,
216+ } ,
217+ ]
218+
219+ export const ALL_TOOLS = [
220+ ...MEMORY_TOOLS ,
221+ ...CLIPBOARD_TOOLS ,
222+ ...( isJinaAvailable ( ) ? JINA_TOOLS : [ ] ) ,
223+ ]
224+
153225export function getSystemContext ( basePrompt : string ) : string {
154226 const settings = loadUserSettings ( )
155227 const customCommandsContext = settings . customCommands . length > 0
156- ? "\nCustom Commands:\n" + settings . customCommands
228+ ? "\nAvailable Commands:\n" + settings . customCommands
157229 . map ( cmd => `- ${ cmd . name } : ${ cmd . description } ${ cmd . helpCommand ? `\n Help: ${ cmd . helpCommand } ` : ''
158- } ${ cmd . helpFlags ? `\n Flags: ${ cmd . helpFlags . join ( ', ' ) } ` : ''
230+ } ${ cmd . helpText ? `\n Flags: ${ cmd . helpText } ` : ''
159231 } `) . join ( '\n' )
160232 : ''
161233
0 commit comments