···11+# This file is auto-generated by @hey-api/openapi-python
22+33+from functools import cached_property
44+55+from .client import Client
66+77+88+class Global(Client):
99+ def health(self):
1010+ """
1111+ Get health
1212+1313+ Get health information about the OpenCode server.
1414+ """
1515+1616+ return self.client.get("/global/health")
1717+1818+ def event(self):
1919+ """
2020+ Get global events
2121+2222+ Subscribe to global events from the OpenCode system using server-sent events.
2323+ """
2424+2525+ return self.client.get("/global/event")
2626+2727+ def dispose(self):
2828+ """
2929+ Dispose instance
3030+3131+ Clean up and dispose all OpenCode instances, releasing all resources.
3232+ """
3333+3434+ return self.client.post("/global/dispose")
3535+3636+3737+class Project(Client):
3838+ def list_(self):
3939+ """
4040+ List all projects
4141+4242+ Get a list of projects that have been opened with OpenCode.
4343+ """
4444+4545+ return self.client.get("/project")
4646+4747+ def current(self):
4848+ """
4949+ Get current project
5050+5151+ Retrieve the currently active project that OpenCode is working with.
5252+ """
5353+5454+ return self.client.get("/project/current")
5555+5656+ def update(self):
5757+ """
5858+ Update project
5959+6060+ Update project properties such as name, icon and color.
6161+ """
6262+6363+ return self.client.patch("/project/{projectID}")
6464+6565+6666+class Pty(Client):
6767+ def list_(self):
6868+ """
6969+ List PTY sessions
7070+7171+ Get a list of all active pseudo-terminal (PTY) sessions managed by OpenCode.
7272+ """
7373+7474+ return self.client.get("/pty")
7575+7676+ def create(self):
7777+ """
7878+ Create PTY session
7979+8080+ Create a new pseudo-terminal (PTY) session for running shell commands and processes.
8181+ """
8282+8383+ return self.client.post("/pty")
8484+8585+ def remove(self):
8686+ """
8787+ Remove PTY session
8888+8989+ Remove and terminate a specific pseudo-terminal (PTY) session.
9090+ """
9191+9292+ return self.client.delete("/pty/{ptyID}")
9393+9494+ def get(self):
9595+ """
9696+ Get PTY session
9797+9898+ Retrieve detailed information about a specific pseudo-terminal (PTY) session.
9999+ """
100100+101101+ return self.client.get("/pty/{ptyID}")
102102+103103+ def update(self):
104104+ """
105105+ Update PTY session
106106+107107+ Update properties of an existing pseudo-terminal (PTY) session.
108108+ """
109109+110110+ return self.client.put("/pty/{ptyID}")
111111+112112+ def connect(self):
113113+ """
114114+ Connect to PTY session
115115+116116+ Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.
117117+ """
118118+119119+ return self.client.get("/pty/{ptyID}/connect")
120120+121121+122122+class Config(Client):
123123+ def get(self):
124124+ """
125125+ Get configuration
126126+127127+ Retrieve the current OpenCode configuration settings and preferences.
128128+ """
129129+130130+ return self.client.get("/config")
131131+132132+ def update(self):
133133+ """
134134+ Update configuration
135135+136136+ Update OpenCode configuration settings and preferences.
137137+ """
138138+139139+ return self.client.patch("/config")
140140+141141+ def providers(self):
142142+ """
143143+ List config providers
144144+145145+ Get a list of all configured AI providers and their default models.
146146+ """
147147+148148+ return self.client.get("/config/providers")
149149+150150+151151+class Tool(Client):
152152+ def ids(self):
153153+ """
154154+ List tool IDs
155155+156156+ Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.
157157+ """
158158+159159+ return self.client.get("/experimental/tool/ids")
160160+161161+ def list_(self):
162162+ """
163163+ List tools
164164+165165+ Get a list of available tools with their JSON schema parameters for a specific provider and model combination.
166166+ """
167167+168168+ return self.client.get("/experimental/tool")
169169+170170+171171+class Instance(Client):
172172+ def dispose(self):
173173+ """
174174+ Dispose instance
175175+176176+ Clean up and dispose the current OpenCode instance, releasing all resources.
177177+ """
178178+179179+ return self.client.post("/instance/dispose")
180180+181181+182182+class Path(Client):
183183+ def get(self):
184184+ """
185185+ Get paths
186186+187187+ Retrieve the current working directory and related path information for the OpenCode instance.
188188+ """
189189+190190+ return self.client.get("/path")
191191+192192+193193+class Vcs(Client):
194194+ def get(self):
195195+ """
196196+ Get VCS info
197197+198198+ Retrieve version control system (VCS) information for the current project, such as git branch.
199199+ """
200200+201201+ return self.client.get("/vcs")
202202+203203+204204+class Session(Client):
205205+ def list_(self):
206206+ """
207207+ List sessions
208208+209209+ Get a list of all OpenCode sessions, sorted by most recently updated.
210210+ """
211211+212212+ return self.client.get("/session")
213213+214214+ def create(self):
215215+ """
216216+ Create session
217217+218218+ Create a new OpenCode session for interacting with AI assistants and managing conversations.
219219+ """
220220+221221+ return self.client.post("/session")
222222+223223+ def status(self):
224224+ """
225225+ Get session status
226226+227227+ Retrieve the current status of all sessions, including active, idle, and completed states.
228228+ """
229229+230230+ return self.client.get("/session/status")
231231+232232+ def delete(self):
233233+ """
234234+ Delete session
235235+236236+ Delete a session and permanently remove all associated data, including messages and history.
237237+ """
238238+239239+ return self.client.delete("/session/{sessionID}")
240240+241241+ def get(self):
242242+ """
243243+ Get session
244244+245245+ Retrieve detailed information about a specific OpenCode session.
246246+ """
247247+248248+ return self.client.get("/session/{sessionID}")
249249+250250+ def update(self):
251251+ """
252252+ Update session
253253+254254+ Update properties of an existing session, such as title or other metadata.
255255+ """
256256+257257+ return self.client.patch("/session/{sessionID}")
258258+259259+ def children(self):
260260+ """
261261+ Get session children
262262+263263+ Retrieve all child sessions that were forked from the specified parent session.
264264+ """
265265+266266+ return self.client.get("/session/{sessionID}/children")
267267+268268+ def todo(self):
269269+ """
270270+ Get session todos
271271+272272+ Retrieve the todo list associated with a specific session, showing tasks and action items.
273273+ """
274274+275275+ return self.client.get("/session/{sessionID}/todo")
276276+277277+ def init(self):
278278+ """
279279+ Initialize session
280280+281281+ Analyze the current application and create an AGENTS.md file with project-specific agent configurations.
282282+ """
283283+284284+ return self.client.post("/session/{sessionID}/init")
285285+286286+ def fork(self):
287287+ """
288288+ Fork session
289289+290290+ Create a new session by forking an existing session at a specific message point.
291291+ """
292292+293293+ return self.client.post("/session/{sessionID}/fork")
294294+295295+ def abort(self):
296296+ """
297297+ Abort session
298298+299299+ Abort an active session and stop any ongoing AI processing or command execution.
300300+ """
301301+302302+ return self.client.post("/session/{sessionID}/abort")
303303+304304+ def unshare(self):
305305+ """
306306+ Unshare session
307307+308308+ Remove the shareable link for a session, making it private again.
309309+ """
310310+311311+ return self.client.delete("/session/{sessionID}/share")
312312+313313+ def share(self):
314314+ """
315315+ Share session
316316+317317+ Create a shareable link for a session, allowing others to view the conversation.
318318+ """
319319+320320+ return self.client.post("/session/{sessionID}/share")
321321+322322+ def diff(self):
323323+ """
324324+ Get session diff
325325+326326+ Get all file changes (diffs) made during this session.
327327+ """
328328+329329+ return self.client.get("/session/{sessionID}/diff")
330330+331331+ def summarize(self):
332332+ """
333333+ Summarize session
334334+335335+ Generate a concise summary of the session using AI compaction to preserve key information.
336336+ """
337337+338338+ return self.client.post("/session/{sessionID}/summarize")
339339+340340+ def messages(self):
341341+ """
342342+ Get session messages
343343+344344+ Retrieve all messages in a session, including user prompts and AI responses.
345345+ """
346346+347347+ return self.client.get("/session/{sessionID}/message")
348348+349349+ def prompt(self):
350350+ """
351351+ Send message
352352+353353+ Create and send a new message to a session, streaming the AI response.
354354+ """
355355+356356+ return self.client.post("/session/{sessionID}/message")
357357+358358+ def message(self):
359359+ """
360360+ Get message
361361+362362+ Retrieve a specific message from a session by its message ID.
363363+ """
364364+365365+ return self.client.get("/session/{sessionID}/message/{messageID}")
366366+367367+ def prompt_async(self):
368368+ """
369369+ Send async message
370370+371371+ Create and send a new message to a session asynchronously, starting the session if needed and returning immediately.
372372+ """
373373+374374+ return self.client.post("/session/{sessionID}/prompt_async")
375375+376376+ def command(self):
377377+ """
378378+ Send command
379379+380380+ Send a new command to a session for execution by the AI assistant.
381381+ """
382382+383383+ return self.client.post("/session/{sessionID}/command")
384384+385385+ def shell(self):
386386+ """
387387+ Run shell command
388388+389389+ Execute a shell command within the session context and return the AI's response.
390390+ """
391391+392392+ return self.client.post("/session/{sessionID}/shell")
393393+394394+ def revert(self):
395395+ """
396396+ Revert message
397397+398398+ Revert a specific message in a session, undoing its effects and restoring the previous state.
399399+ """
400400+401401+ return self.client.post("/session/{sessionID}/revert")
402402+403403+ def unrevert(self):
404404+ """
405405+ Restore reverted messages
406406+407407+ Restore all previously reverted messages in a session.
408408+ """
409409+410410+ return self.client.post("/session/{sessionID}/unrevert")
411411+412412+413413+class Part(Client):
414414+ def delete(self):
415415+ """Delete a part from a message"""
416416+417417+ return self.client.delete("/session/{sessionID}/message/{messageID}/part/{partID}")
418418+419419+ def update(self):
420420+ """Update a part in a message"""
421421+422422+ return self.client.patch("/session/{sessionID}/message/{messageID}/part/{partID}")
423423+424424+425425+class Permission(Client):
426426+ def respond(self):
427427+ """
428428+ Respond to permission
429429+430430+ Approve or deny a permission request from the AI assistant.
431431+432432+ Deprecated.
433433+ """
434434+435435+ return self.client.post("/session/{sessionID}/permissions/{permissionID}")
436436+437437+ def reply(self):
438438+ """
439439+ Respond to permission request
440440+441441+ Approve or deny a permission request from the AI assistant.
442442+ """
443443+444444+ return self.client.post("/permission/{requestID}/reply")
445445+446446+ def list_(self):
447447+ """
448448+ List pending permissions
449449+450450+ Get all pending permission requests across all sessions.
451451+ """
452452+453453+ return self.client.get("/permission")
454454+455455+456456+class Command(Client):
457457+ def list_(self):
458458+ """
459459+ List commands
460460+461461+ Get a list of all available commands in the OpenCode system.
462462+ """
463463+464464+ return self.client.get("/command")
465465+466466+467467+class Oauth(Client):
468468+ def authorize(self):
469469+ """
470470+ OAuth authorize
471471+472472+ Initiate OAuth authorization for a specific AI provider to get an authorization URL.
473473+ """
474474+475475+ return self.client.post("/provider/{providerID}/oauth/authorize")
476476+477477+ def callback(self):
478478+ """
479479+ OAuth callback
480480+481481+ Handle the OAuth callback from a provider after user authorization.
482482+ """
483483+484484+ return self.client.post("/provider/{providerID}/oauth/callback")
485485+486486+487487+class Provider(Client):
488488+ def list_(self):
489489+ """
490490+ List providers
491491+492492+ Get a list of all available AI providers, including both available and connected ones.
493493+ """
494494+495495+ return self.client.get("/provider")
496496+497497+ def auth(self):
498498+ """
499499+ Get provider auth methods
500500+501501+ Retrieve available authentication methods for all AI providers.
502502+ """
503503+504504+ return self.client.get("/provider/auth")
505505+506506+ @cached_property
507507+ def oauth(self) -> Oauth:
508508+ return Oauth(client=self.client)
509509+510510+511511+class Find(Client):
512512+ def text(self):
513513+ """
514514+ Find text
515515+516516+ Search for text patterns across files in the project using ripgrep.
517517+ """
518518+519519+ return self.client.get("/find")
520520+521521+ def files(self):
522522+ """
523523+ Find files
524524+525525+ Search for files or directories by name or pattern in the project directory.
526526+ """
527527+528528+ return self.client.get("/find/file")
529529+530530+ def symbols(self):
531531+ """
532532+ Find symbols
533533+534534+ Search for workspace symbols like functions, classes, and variables using LSP.
535535+ """
536536+537537+ return self.client.get("/find/symbol")
538538+539539+540540+class File(Client):
541541+ def list_(self):
542542+ """
543543+ List files
544544+545545+ List files and directories in a specified path.
546546+ """
547547+548548+ return self.client.get("/file")
549549+550550+ def read(self):
551551+ """
552552+ Read file
553553+554554+ Read the content of a specified file.
555555+ """
556556+557557+ return self.client.get("/file/content")
558558+559559+ def status(self):
560560+ """
561561+ Get file status
562562+563563+ Get the git status of all files in the project.
564564+ """
565565+566566+ return self.client.get("/file/status")
567567+568568+569569+class App(Client):
570570+ def log(self):
571571+ """
572572+ Write log
573573+574574+ Write a log entry to the server logs with specified level and metadata.
575575+ """
576576+577577+ return self.client.post("/log")
578578+579579+ def agents(self):
580580+ """
581581+ List agents
582582+583583+ Get a list of all available AI agents in the OpenCode system.
584584+ """
585585+586586+ return self.client.get("/agent")
587587+588588+589589+class Auth(Client):
590590+ def remove(self):
591591+ """
592592+ Remove MCP OAuth
593593+594594+ Remove OAuth credentials for an MCP server
595595+ """
596596+597597+ return self.client.delete("/mcp/{name}/auth")
598598+599599+ def start(self):
600600+ """
601601+ Start MCP OAuth
602602+603603+ Start OAuth authentication flow for a Model Context Protocol (MCP) server.
604604+ """
605605+606606+ return self.client.post("/mcp/{name}/auth")
607607+608608+ def callback(self):
609609+ """
610610+ Complete MCP OAuth
611611+612612+ Complete OAuth authentication for a Model Context Protocol (MCP) server using the authorization code.
613613+ """
614614+615615+ return self.client.post("/mcp/{name}/auth/callback")
616616+617617+ def authenticate(self):
618618+ """
619619+ Authenticate MCP OAuth
620620+621621+ Start OAuth flow and wait for callback (opens browser)
622622+ """
623623+624624+ return self.client.post("/mcp/{name}/auth/authenticate")
625625+626626+627627+class Mcp(Client):
628628+ def status(self):
629629+ """
630630+ Get MCP status
631631+632632+ Get the status of all Model Context Protocol (MCP) servers.
633633+ """
634634+635635+ return self.client.get("/mcp")
636636+637637+ def add(self):
638638+ """
639639+ Add MCP server
640640+641641+ Dynamically add a new Model Context Protocol (MCP) server to the system.
642642+ """
643643+644644+ return self.client.post("/mcp")
645645+646646+ def connect(self):
647647+ """Connect an MCP server"""
648648+649649+ return self.client.post("/mcp/{name}/connect")
650650+651651+ def disconnect(self):
652652+ """Disconnect an MCP server"""
653653+654654+ return self.client.post("/mcp/{name}/disconnect")
655655+656656+ @cached_property
657657+ def auth(self) -> Auth:
658658+ return Auth(client=self.client)
659659+660660+661661+class Lsp(Client):
662662+ def status(self):
663663+ """
664664+ Get LSP status
665665+666666+ Get LSP server status
667667+ """
668668+669669+ return self.client.get("/lsp")
670670+671671+672672+class Formatter(Client):
673673+ def status(self):
674674+ """
675675+ Get formatter status
676676+677677+ Get formatter status
678678+ """
679679+680680+ return self.client.get("/formatter")
681681+682682+683683+class Control(Client):
684684+ def next_(self):
685685+ """
686686+ Get next TUI request
687687+688688+ Retrieve the next TUI (Terminal User Interface) request from the queue for processing.
689689+ """
690690+691691+ return self.client.get("/tui/control/next")
692692+693693+ def response(self):
694694+ """
695695+ Submit TUI response
696696+697697+ Submit a response to the TUI request queue to complete a pending request.
698698+ """
699699+700700+ return self.client.post("/tui/control/response")
701701+702702+703703+class Tui(Client):
704704+ def append_prompt(self):
705705+ """
706706+ Append TUI prompt
707707+708708+ Append prompt to the TUI
709709+ """
710710+711711+ return self.client.post("/tui/append-prompt")
712712+713713+ def open_help(self):
714714+ """
715715+ Open help dialog
716716+717717+ Open the help dialog in the TUI to display user assistance information.
718718+ """
719719+720720+ return self.client.post("/tui/open-help")
721721+722722+ def open_sessions(self):
723723+ """
724724+ Open sessions dialog
725725+726726+ Open the session dialog
727727+ """
728728+729729+ return self.client.post("/tui/open-sessions")
730730+731731+ def open_themes(self):
732732+ """
733733+ Open themes dialog
734734+735735+ Open the theme dialog
736736+ """
737737+738738+ return self.client.post("/tui/open-themes")
739739+740740+ def open_models(self):
741741+ """
742742+ Open models dialog
743743+744744+ Open the model dialog
745745+ """
746746+747747+ return self.client.post("/tui/open-models")
748748+749749+ def submit_prompt(self):
750750+ """
751751+ Submit TUI prompt
752752+753753+ Submit the prompt
754754+ """
755755+756756+ return self.client.post("/tui/submit-prompt")
757757+758758+ def clear_prompt(self):
759759+ """
760760+ Clear TUI prompt
761761+762762+ Clear the prompt
763763+ """
764764+765765+ return self.client.post("/tui/clear-prompt")
766766+767767+ def execute_command(self):
768768+ """
769769+ Execute TUI command
770770+771771+ Execute a TUI command (e.g. agent_cycle)
772772+ """
773773+774774+ return self.client.post("/tui/execute-command")
775775+776776+ def show_toast(self):
777777+ """
778778+ Show TUI toast
779779+780780+ Show a toast notification in the TUI
781781+ """
782782+783783+ return self.client.post("/tui/show-toast")
784784+785785+ def publish(self):
786786+ """
787787+ Publish TUI event
788788+789789+ Publish a TUI event
790790+ """
791791+792792+ return self.client.post("/tui/publish")
793793+794794+ @cached_property
795795+ def control(self) -> Control:
796796+ return Control(client=self.client)
797797+798798+799799+class Auth_2(Client):
800800+ def set_(self):
801801+ """
802802+ Set auth credentials
803803+804804+ Set authentication credentials
805805+ """
806806+807807+ return self.client.put("/auth/{providerID}")
808808+809809+810810+class Event(Client):
811811+ def subscribe(self):
812812+ """
813813+ Subscribe to events
814814+815815+ Get events
816816+ """
817817+818818+ return self.client.get("/event")
819819+820820+821821+class Sdk(Client):
822822+ @cached_property
823823+ def global_(self) -> Global:
824824+ return Global(client=self.client)
825825+826826+ @cached_property
827827+ def project(self) -> Project:
828828+ return Project(client=self.client)
829829+830830+ @cached_property
831831+ def pty(self) -> Pty:
832832+ return Pty(client=self.client)
833833+834834+ @cached_property
835835+ def config(self) -> Config:
836836+ return Config(client=self.client)
837837+838838+ @cached_property
839839+ def tool(self) -> Tool:
840840+ return Tool(client=self.client)
841841+842842+ @cached_property
843843+ def instance(self) -> Instance:
844844+ return Instance(client=self.client)
845845+846846+ @cached_property
847847+ def path(self) -> Path:
848848+ return Path(client=self.client)
849849+850850+ @cached_property
851851+ def vcs(self) -> Vcs:
852852+ return Vcs(client=self.client)
853853+854854+ @cached_property
855855+ def session(self) -> Session:
856856+ return Session(client=self.client)
857857+858858+ @cached_property
859859+ def part(self) -> Part:
860860+ return Part(client=self.client)
861861+862862+ @cached_property
863863+ def permission(self) -> Permission:
864864+ return Permission(client=self.client)
865865+866866+ @cached_property
867867+ def command(self) -> Command:
868868+ return Command(client=self.client)
869869+870870+ @cached_property
871871+ def provider(self) -> Provider:
872872+ return Provider(client=self.client)
873873+874874+ @cached_property
875875+ def find(self) -> Find:
876876+ return Find(client=self.client)
877877+878878+ @cached_property
879879+ def file(self) -> File:
880880+ return File(client=self.client)
881881+882882+ @cached_property
883883+ def app(self) -> App:
884884+ return App(client=self.client)
885885+886886+ @cached_property
887887+ def mcp(self) -> Mcp:
888888+ return Mcp(client=self.client)
889889+890890+ @cached_property
891891+ def lsp(self) -> Lsp:
892892+ return Lsp(client=self.client)
893893+894894+ @cached_property
895895+ def formatter(self) -> Formatter:
896896+ return Formatter(client=self.client)
897897+898898+ @cached_property
899899+ def tui(self) -> Tui:
900900+ return Tui(client=self.client)
901901+902902+ @cached_property
903903+ def auth(self) -> Auth_2:
904904+ return Auth_2(client=self.client)
905905+906906+ @cached_property
907907+ def event(self) -> Event:
908908+ return Event(client=self.client)