1818/**
1919 * OpenCLI {@code chatgpt}(ChatGPT Web)浏览器适配器。
2020 */
21- @ RequiredArgsConstructor
21+ @ RequiredArgsConstructor /**
22+
23+ * OpenCLI {@code chatgpt} (ChatGPT Web) browser adapter client.
24+ *
25+ * <p>Provides typed methods for ChatGPT Web interactions such as {@code ask}, {@code send},
26+ * {@code history}, {@code image}, and session management.</p>
27+
28+ *
29+
30+ * @author [@Loong Wan](https://github.com/loong10k)
31+
32+ * @since 3.0.0
33+
34+ */
35+
2236public final class ChatgptOpenCliClient {
2337
2438 private final OpenCliExecutor executor ;
@@ -35,11 +49,22 @@ public static class ChatgptCommonOptions {
3549
3650 private Integer historyLimit ;
3751
52+ private Integer stableSeconds ;
53+
3854 private Boolean readAsMarkdown ;
3955
40- /** 文档:{@code --new} 开启新会话。 */
4156 private Boolean newConversation ;
4257
58+ private String conversation ;
59+
60+ private String project ;
61+
62+ private Boolean waitForResponse ;
63+
64+ private Boolean deepResearch ;
65+
66+ private Boolean webSearch ;
67+
4368 private Boolean jsonOutput ;
4469
4570 public void appendTo (List <String > target ) {
@@ -52,9 +77,27 @@ public void appendTo(List<String> target) {
5277 if (historyLimit != null ) {
5378 OpenCliArgSupport .addOptionPair (target , "--limit" , String .valueOf (historyLimit ));
5479 }
80+ if (stableSeconds != null ) {
81+ OpenCliArgSupport .addOptionPair (target , "--stable" , String .valueOf (stableSeconds ));
82+ }
5583 if (readAsMarkdown != null ) {
5684 OpenCliArgSupport .addOptionPair (target , "--markdown" , String .valueOf (readAsMarkdown ));
5785 }
86+ if (conversation != null ) {
87+ OpenCliArgSupport .addOptionPair (target , "--conversation" , conversation );
88+ }
89+ if (project != null ) {
90+ OpenCliArgSupport .addOptionPair (target , "--project" , project );
91+ }
92+ if (waitForResponse != null ) {
93+ OpenCliArgSupport .addOptionPair (target , "--wait" , String .valueOf (waitForResponse ));
94+ }
95+ if (Boolean .TRUE .equals (deepResearch )) {
96+ target .add ("--deep-research" );
97+ }
98+ if (Boolean .TRUE .equals (webSearch )) {
99+ target .add ("--web-search" );
100+ }
58101 if (Boolean .TRUE .equals (jsonOutput )) {
59102 target .add ("-f" );
60103 target .add ("json" );
@@ -118,6 +161,63 @@ public OpenCliResult status(List<String> more) {
118161 return ch ().invoke (OpenCliArgSupport .merge (OpenCliLists .of ("status" ), more ));
119162 }
120163
164+ public OpenCliResult deepResearchResult (String id , Boolean wait , Integer timeoutSeconds ,
165+ Integer stableSeconds , List <String > more ) {
166+ List <String > args = new ArrayList <>();
167+ args .add ("deep-research-result" );
168+ args .add (id );
169+ if (wait != null ) {
170+ OpenCliArgSupport .addOptionPair (args , "--wait" , String .valueOf (wait ));
171+ }
172+ if (timeoutSeconds != null ) {
173+ OpenCliArgSupport .addOptionPair (args , "--timeout" , String .valueOf (timeoutSeconds ));
174+ }
175+ if (stableSeconds != null ) {
176+ OpenCliArgSupport .addOptionPair (args , "--stable" , String .valueOf (stableSeconds ));
177+ }
178+ return ch ().invoke (OpenCliArgSupport .merge (args , more ));
179+ }
180+
181+ public OpenCliResult login (Integer timeoutSeconds , List <String > more ) {
182+ List <String > args = new ArrayList <>();
183+ args .add ("login" );
184+ if (timeoutSeconds != null ) {
185+ OpenCliArgSupport .addOptionPair (args , "--timeout" , String .valueOf (timeoutSeconds ));
186+ }
187+ return ch ().invoke (OpenCliArgSupport .merge (args , more ));
188+ }
189+
190+ public OpenCliResult model (String model , String project , List <String > more ) {
191+ List <String > args = new ArrayList <>();
192+ args .add ("model" );
193+ args .add (model );
194+ if (project != null ) {
195+ OpenCliArgSupport .addOptionPair (args , "--project" , project );
196+ }
197+ return ch ().invoke (OpenCliArgSupport .merge (args , more ));
198+ }
199+
200+ public OpenCliResult projectFileAdd (String file , String id , List <String > more ) {
201+ List <String > args = new ArrayList <>();
202+ args .add ("project-file-add" );
203+ args .add (file );
204+ OpenCliArgSupport .addOptionPair (args , "--id" , id );
205+ return ch ().invoke (OpenCliArgSupport .merge (args , more ));
206+ }
207+
208+ public OpenCliResult projectList (Integer limit , List <String > more ) {
209+ List <String > args = new ArrayList <>();
210+ args .add ("project-list" );
211+ if (limit != null ) {
212+ OpenCliArgSupport .addOptionPair (args , "--limit" , String .valueOf (limit ));
213+ }
214+ return ch ().invoke (OpenCliArgSupport .merge (args , more ));
215+ }
216+
217+ public OpenCliResult whoami (List <String > more ) {
218+ return ch ().invoke (OpenCliArgSupport .merge (OpenCliLists .of ("whoami" ), more ));
219+ }
220+
121221 /**
122222 * {@code chatgpt image} 文生图参数。
123223 */
@@ -144,7 +244,7 @@ public void appendTo(List<String> target) {
144244 OpenCliArgSupport .addOptionPair (target , "--op" , outputDir );
145245 }
146246 if (Boolean .TRUE .equals (skipDownload )) {
147- OpenCliArgSupport . addOptionPair ( target , "--sd" , "true " );
247+ target . add ( "--sd" );
148248 }
149249 if (timeoutSeconds != null ) {
150250 OpenCliArgSupport .addOptionPair (target , "--timeout" , String .valueOf (timeoutSeconds ));
0 commit comments