File tree Expand file tree Collapse file tree
packages/opencode/specs/v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // @ts -nocheck
2+
3+ import { OpenCode } from "@opencode-ai/core"
4+ import { ReadTool } from "@opencode-ai/core/tools"
5+
6+ const opencode = OpenCode . make ( { } )
7+
8+ opencode . tool . add ( ReadTool )
9+
10+ opencode . tool . add ( {
11+ name : "bash" ,
12+ schema : {
13+ type : "object" ,
14+ properties : {
15+ command : {
16+ type : "string" ,
17+ description : "The command to run." ,
18+ } ,
19+ } ,
20+ required : [ "command" ] ,
21+ } ,
22+ execute ( input , ctx ) { } ,
23+ } )
24+
25+ opencode . auth . add ( {
26+ provider : "openai" ,
27+ type : "api" ,
28+ value : process . env . OPENAI_API_KEY ,
29+ } )
30+
31+ opencode . agent . add ( {
32+ name : "build" ,
33+ permissions : [ ] ,
34+ model : {
35+ id : "gpt-5-5" ,
36+ provider : "openai" ,
37+ variant : "xhigh" ,
38+ } ,
39+ } )
40+
41+ import { anthropic } from "@opencode-ai/core/models"
42+
43+ const sessionID = await opencode . session . create ( {
44+ agent : "build" ,
45+ } )
46+
47+ opencode . subscribe ( ( event ) => {
48+ console . log ( event )
49+ } )
50+
51+ await opencode . session . prompt ( {
52+ sessionID,
53+ text : "hey what is up" ,
54+ } )
55+
56+ await opencode . session . prompt ( {
57+ sessionID,
58+ text : "hey what is up" ,
59+ role : "assistant" ,
60+ } )
61+
62+ await opencode . session . wait ( )
63+
64+ console . log ( await opencode . session . messages ( sessionID ) )
You can’t perform that action at this time.
0 commit comments