Skip to main content

opencode_ctl/tools/
mod.rs

1//! Tool argument structs (all twenty, final schemas) and tool bodies.
2
3use schemars::JsonSchema;
4use serde::Deserialize;
5use serde_json::Value;
6
7pub mod changes;
8pub mod hatch;
9pub mod messages;
10pub mod pair;
11pub mod permissions;
12pub mod service;
13pub mod session;
14pub mod wait;
15
16#[derive(Debug, Deserialize, JsonSchema)]
17pub struct ServiceStatusArgs {}
18
19#[derive(Debug, Deserialize, JsonSchema)]
20pub struct ServiceStartArgs {}
21
22#[derive(Debug, Deserialize, JsonSchema)]
23pub struct ConfirmArgs {
24    /// Must be true; the flag is friction, not a guard.
25    #[serde(default)]
26    pub confirm: bool,
27}
28
29#[derive(Debug, Deserialize, JsonSchema)]
30pub struct SessionListArgs {
31    /// Workspace directory filter (default: the paired directory, else the host working directory).
32    pub directory: Option<String>,
33    /// Drop the directory filter.
34    pub all: Option<bool>,
35    pub search: Option<String>,
36    /// 1..200, default 20.
37    pub limit: Option<u32>,
38    pub cursor: Option<String>,
39}
40
41#[derive(Debug, Deserialize, JsonSchema)]
42pub struct SessionCreateArgs {
43    pub title: Option<String>,
44    pub directory: Option<String>,
45    /// Refused with PERMISSIONS_LOCKED when permissions are locked.
46    pub agent: Option<String>,
47    /// `provider/model[#variant]`.
48    pub model: Option<String>,
49    /// Permission rules `{action, resource, effect}`; refused with PERMISSIONS_LOCKED when locked.
50    pub permissions: Option<Vec<Value>>,
51    pub parent_id: Option<String>,
52}
53
54#[derive(Debug, Deserialize, JsonSchema)]
55pub struct SessionGetArgs {
56    pub session_id: Option<String>,
57}
58
59#[derive(Debug, Deserialize, JsonSchema)]
60pub struct SessionPromptArgs {
61    pub session_id: Option<String>,
62    pub text: String,
63    /// `steer` (default) or `queue`.
64    pub delivery: Option<String>,
65}
66
67#[derive(Debug, Deserialize, JsonSchema)]
68pub struct SessionWaitArgs {
69    pub session_id: Option<String>,
70    /// The message id returned by session_prompt.
71    pub after: Option<String>,
72    pub timeout_s: Option<u64>,
73    pub poll_s: Option<u64>,
74    pub hard: Option<bool>,
75}
76
77#[derive(Debug, Deserialize, JsonSchema)]
78pub struct SessionMessagesArgs {
79    pub session_id: Option<String>,
80    pub limit: Option<u32>,
81    pub cursor: Option<String>,
82    /// `asc` or `desc` (default `desc`); ignored when `cursor` is given.
83    pub order: Option<String>,
84    pub r#type: Option<String>,
85    pub reasoning: Option<bool>,
86    /// `none`, `summary` (default) or `full`.
87    pub tools: Option<String>,
88}
89
90#[derive(Debug, Deserialize, JsonSchema)]
91pub struct SessionChangesArgs {
92    pub session_id: Option<String>,
93    pub from: Option<String>,
94    pub to: Option<String>,
95    /// Workspace-relative exact paths.
96    pub paths: Option<Vec<String>>,
97    pub patches: Option<bool>,
98    pub context: Option<u32>,
99}
100
101#[derive(Debug, Deserialize, JsonSchema)]
102pub struct WorkspaceStatusArgs {
103    pub directory: Option<String>,
104}
105
106#[derive(Debug, Deserialize, JsonSchema)]
107pub struct SessionInterruptArgs {
108    pub session_id: Option<String>,
109    /// Let pending steering input continue (default false).
110    pub resume: Option<bool>,
111}
112
113#[derive(Debug, Deserialize, JsonSchema)]
114pub struct SessionDeleteArgs {
115    /// Required: never defaults to the paired session.
116    pub session_id: String,
117    #[serde(default)]
118    pub confirm: bool,
119}
120
121#[derive(Debug, Deserialize, JsonSchema)]
122pub struct PermissionReplyArgs {
123    pub session_id: Option<String>,
124    pub request_id: String,
125    /// `once`, `always` or `reject`.
126    pub decision: String,
127    pub message: Option<String>,
128    pub confirm: Option<bool>,
129}
130
131#[derive(Debug, Deserialize, JsonSchema)]
132pub struct FormReplyArgs {
133    pub session_id: Option<String>,
134    pub form_id: String,
135    pub answer: Value,
136}
137
138#[derive(Debug, Deserialize, JsonSchema)]
139pub struct SavedPermissionsArgs {
140    pub project_id: Option<String>,
141    pub remove_id: Option<String>,
142    pub confirm: Option<bool>,
143}
144
145#[derive(Debug, Deserialize, JsonSchema)]
146pub struct OpencodeOperationsArgs {
147    pub filter: Option<String>,
148}
149
150#[derive(Debug, Deserialize, JsonSchema)]
151pub struct OpencodeApiArgs {
152    /// An operationId such as `session.get`.
153    pub operation: String,
154    pub params: Option<Value>,
155    pub body: Option<Value>,
156    pub allow_mutation: Option<bool>,
157}
158
159#[derive(Debug, Deserialize, JsonSchema)]
160pub struct PairStatusArgs {}