-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCopilotClientOptions.java.html
More file actions
702 lines (652 loc) · 28.7 KB
/
Copy pathCopilotClientOptions.java.html
File metadata and controls
702 lines (652 loc) · 28.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang=""><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CopilotClientOptions.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub Copilot SDK :: Java</a> > <a href="index.source.html" class="el_package">com.github.copilot.rpc</a> > <span class="el_source">CopilotClientOptions.java</span></div><h1>CopilotClientOptions.java</h1><pre class="source lang-java linenums">/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.rpc;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Supplier;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Optional;
import java.util.OptionalInt;
/**
* Configuration options for creating a
* {@link com.github.copilot.CopilotClient}.
* <p>
* This class provides a fluent API for configuring how the client connects to
* and manages the Copilot CLI server. All setter methods return {@code this}
* for method chaining.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* var options = new CopilotClientOptions().setCliPath("/usr/local/bin/copilot").setLogLevel("debug")
* .setAutoStart(true);
*
* var client = new CopilotClient(options);
* }</pre>
*
* @see com.github.copilot.CopilotClient
* @since 1.0.0
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
<span class="nc" id="L42">public class CopilotClientOptions {</span>
@Deprecated
private boolean autoRestart;
<span class="nc" id="L46"> private boolean autoStart = true;</span>
private String[] cliArgs;
private String cliPath;
private String cliUrl;
private String copilotHome;
private String cwd;
private Map<String, String> environment;
private Executor executor;
private String gitHubToken;
<span class="nc" id="L55"> private String logLevel = "info";</span>
<span class="nc" id="L56"> private CopilotClientMode mode = CopilotClientMode.COPILOT_CLI;</span>
private Supplier<CompletableFuture<List<ModelInfo>>> onListModels;
private int port;
private TelemetryConfig telemetry;
private Integer sessionIdleTimeoutSeconds;
private boolean remote;
private String tcpConnectionToken;
private Boolean useLoggedInUser;
<span class="nc" id="L64"> private boolean useStdio = true;</span>
/**
* Returns whether the client should automatically restart the server on crash.
*
* @return the auto-restart flag value (no longer has any effect)
* @deprecated This option has no effect and will be removed in a future
* release.
*/
@Deprecated
public boolean isAutoRestart() {
<span class="nc" id="L75"> return autoRestart;</span>
}
/**
* Sets whether the client should automatically restart the CLI server if it
* crashes unexpectedly.
*
* @param autoRestart
* ignored — this option no longer has any effect
* @return this options instance for method chaining
* @deprecated This option has no effect and will be removed in a future
* release.
*/
@Deprecated
public CopilotClientOptions setAutoRestart(boolean autoRestart) {
<span class="nc" id="L90"> this.autoRestart = autoRestart;</span>
<span class="nc" id="L91"> return this;</span>
}
/**
* Returns whether the client should automatically start the server.
*
* @return {@code true} to auto-start (default), {@code false} for manual start
*/
public boolean isAutoStart() {
<span class="nc" id="L100"> return autoStart;</span>
}
/**
* Sets whether the client should automatically start the CLI server when the
* first request is made.
*
* @param autoStart
* {@code true} to auto-start, {@code false} for manual start
* @return this options instance for method chaining
*/
public CopilotClientOptions setAutoStart(boolean autoStart) {
<span class="nc" id="L112"> this.autoStart = autoStart;</span>
<span class="nc" id="L113"> return this;</span>
}
/**
* Gets the extra CLI arguments.
* <p>
* Returns a shallow copy of the internal array, or {@code null} if no arguments
* have been set.
*
* @return a copy of the extra arguments, or {@code null}
*/
public String[] getCliArgs() {
<span class="nc bnc" id="L125" title="All 2 branches missed."> return cliArgs != null ? Arrays.copyOf(cliArgs, cliArgs.length) : null;</span>
}
/**
* Sets extra arguments to pass to the CLI process.
* <p>
* These arguments are prepended before SDK-managed flags. A shallow copy of the
* provided array is stored. If {@code null} or empty, the existing arguments
* are cleared.
*
* @param cliArgs
* the extra arguments to pass, or {@code null}/empty to clear
* @return this options instance for method chaining
*/
public CopilotClientOptions setCliArgs(String[] cliArgs) {
<span class="nc bnc" id="L140" title="All 4 branches missed."> if (cliArgs == null || cliArgs.length == 0) {</span>
<span class="nc bnc" id="L141" title="All 2 branches missed."> if (this.cliArgs != null) {</span>
<span class="nc" id="L142"> this.cliArgs = new String[0];</span>
}
} else {
<span class="nc" id="L145"> this.cliArgs = Arrays.copyOf(cliArgs, cliArgs.length);</span>
}
<span class="nc" id="L147"> return this;</span>
}
/**
* Gets the path to the Copilot CLI executable.
*
* @return the CLI path, or {@code null} to use "copilot" from PATH
*/
public String getCliPath() {
<span class="nc" id="L156"> return cliPath;</span>
}
/**
* Sets the path to the Copilot CLI executable.
*
* @param cliPath
* the path to the CLI executable
* @return this options instance for method chaining
*/
public CopilotClientOptions setCliPath(String cliPath) {
<span class="nc" id="L167"> this.cliPath = Objects.requireNonNull(cliPath, "cliPath must not be null");</span>
<span class="nc" id="L168"> return this;</span>
}
/**
* Gets the URL of an existing CLI server to connect to.
*
* @return the CLI server URL, or {@code null} to spawn a new process
*/
public String getCliUrl() {
<span class="nc" id="L177"> return cliUrl;</span>
}
/**
* Sets the URL of an existing CLI server to connect to.
* <p>
* When provided, the client will not spawn a CLI process but will connect to
* the specified URL instead. Format: "host:port" or "http://host:port".
* <p>
* <strong>Note:</strong> This is mutually exclusive with
* {@link #setUseStdio(boolean)} and {@link #setCliPath(String)}.
*
* @param cliUrl
* the CLI server URL to connect to (must not be {@code null} or
* empty)
* @return this options instance for method chaining
* @throws IllegalArgumentException
* if {@code cliUrl} is {@code null} or empty
*/
public CopilotClientOptions setCliUrl(String cliUrl) {
<span class="nc" id="L197"> this.cliUrl = Objects.requireNonNull(cliUrl, "cliUrl must not be null");</span>
<span class="nc" id="L198"> return this;</span>
}
/**
* Gets the base directory for Copilot data (session state, config, etc.).
*
* @return the Copilot home directory path, or {@code null} to use the CLI
* default ({@code ~/.copilot})
*/
public String getCopilotHome() {
<span class="nc" id="L208"> return copilotHome;</span>
}
/**
* Sets the base directory for Copilot data (session state, config, etc.).
* <p>
* Sets the {@code COPILOT_HOME} environment variable on the spawned CLI
* process. When {@code null}, the {@code COPILOT_HOME} env var is not set on
* the spawned process, so the CLI falls back to its default
* ({@code ~/.copilot}).
* <p>
* This option is only used when the SDK spawns the CLI process; it is ignored
* when connecting to an external server via {@link #setCliUrl(String)}.
*
* @param copilotHome
* the Copilot home directory path, or {@code null} to use the CLI
* default
* @return this options instance for method chaining
*/
public CopilotClientOptions setCopilotHome(String copilotHome) {
<span class="nc" id="L228"> this.copilotHome = copilotHome;</span>
<span class="nc" id="L229"> return this;</span>
}
/**
* Gets the working directory for the CLI process.
*
* @return the working directory path
*/
public String getCwd() {
<span class="nc" id="L238"> return cwd;</span>
}
/**
* Sets the working directory for the CLI process.
*
* @param cwd
* the working directory path (must not be {@code null} or empty)
* @return this options instance for method chaining
* @throws IllegalArgumentException
* if {@code cwd} is {@code null} or empty
*/
public CopilotClientOptions setCwd(String cwd) {
<span class="nc" id="L251"> this.cwd = Objects.requireNonNull(cwd, "cwd must not be null");</span>
<span class="nc" id="L252"> return this;</span>
}
/**
* Gets the environment variables for the CLI process.
* <p>
* Returns a shallow copy of the internal map, or {@code null} if no environment
* has been set.
*
* @return a copy of the environment variables map, or {@code null}
*/
public Map<String, String> getEnvironment() {
<span class="nc bnc" id="L264" title="All 2 branches missed."> return environment != null ? new HashMap<>(environment) : null;</span>
}
/**
* Sets environment variables to pass to the CLI process.
* <p>
* When set, these environment variables replace the inherited environment. A
* shallow copy of the provided map is stored. If {@code null} or empty, the
* existing environment is cleared.
*
* @param environment
* the environment variables map, or {@code null}/empty to clear
* @return this options instance for method chaining
*/
public CopilotClientOptions setEnvironment(Map<String, String> environment) {
<span class="nc bnc" id="L279" title="All 4 branches missed."> if (environment == null || environment.isEmpty()) {</span>
<span class="nc bnc" id="L280" title="All 2 branches missed."> if (this.environment != null) {</span>
<span class="nc" id="L281"> this.environment.clear();</span>
}
} else {
<span class="nc" id="L284"> this.environment = new HashMap<>(environment);</span>
}
<span class="nc" id="L286"> return this;</span>
}
/**
* Gets the executor used for internal asynchronous operations.
* <p>
* Returns {@code null} if no executor has been explicitly set, indicating that
* the SDK should use its default executor strategy.
*
* @return the executor, or {@code null} if using SDK defaults
*/
public Executor getExecutor() {
<span class="nc" id="L298"> return executor;</span>
}
/**
* Sets the executor used for internal asynchronous operations.
* <p>
* When provided, the SDK uses this executor for all internal
* {@code CompletableFuture} combinators. This allows callers to isolate SDK
* work onto a dedicated thread pool or integrate with container-managed
* threading.
* <p>
* The SDK will not shut down a user-provided executor. If you pass a custom
* {@code ExecutorService}, you remain responsible for shutting it down.
* <p>
* If not set (or set to {@code null}), the SDK uses its default executor:
* virtual threads on JDK 25+, {@code ForkJoinPool.commonPool()} on older JDKs.
*
* @param executor
* the executor to use, or {@code null} for SDK defaults
* @return this options instance for fluent chaining
*/
public CopilotClientOptions setExecutor(Executor executor) {
<span class="nc" id="L320"> this.executor = executor;</span>
<span class="nc" id="L321"> return this;</span>
}
/**
* Gets the GitHub token for authentication.
*
* @return the GitHub token, or {@code null} to use other authentication methods
*/
public String getGitHubToken() {
<span class="nc" id="L330"> return gitHubToken;</span>
}
/**
* Sets the GitHub token to use for authentication.
* <p>
* When provided, the token is passed to the CLI server via environment
* variable. This takes priority over other authentication methods.
*
* @param gitHubToken
* the GitHub token (must not be {@code null} or empty)
* @return this options instance for method chaining
* @throws IllegalArgumentException
* if {@code gitHubToken} is {@code null} or empty
*/
public CopilotClientOptions setGitHubToken(String gitHubToken) {
<span class="nc" id="L346"> this.gitHubToken = Objects.requireNonNull(gitHubToken, "gitHubToken must not be null");</span>
<span class="nc" id="L347"> return this;</span>
}
/**
* Gets the GitHub token for authentication.
*
* @return the GitHub token, or {@code null} to use other authentication methods
* @deprecated Use {@link #getGitHubToken()} instead.
*/
@Deprecated
public String getGithubToken() {
<span class="nc" id="L358"> return gitHubToken;</span>
}
/**
* Sets the GitHub token to use for authentication.
*
* @param githubToken
* the GitHub token
* @return this options instance for method chaining
* @deprecated Use {@link #setGitHubToken(String)} instead.
*/
@Deprecated
public CopilotClientOptions setGithubToken(String githubToken) {
<span class="nc" id="L371"> this.gitHubToken = Objects.requireNonNull(githubToken, "githubToken must not be null");</span>
<span class="nc" id="L372"> return this;</span>
}
/**
* Gets the log level for the CLI process.
*
* @return the log level (default: "info")
*/
public String getLogLevel() {
<span class="nc" id="L381"> return logLevel;</span>
}
/**
* Sets the log level for the CLI process.
* <p>
* Valid levels include: "error", "warn", "info", "debug", "trace".
*
* @param logLevel
* the log level (must not be {@code null} or empty)
* @return this options instance for method chaining
* @throws IllegalArgumentException
* if {@code logLevel} is {@code null} or empty
*/
public CopilotClientOptions setLogLevel(String logLevel) {
<span class="nc" id="L396"> this.logLevel = Objects.requireNonNull(logLevel, "logLevel must not be null");</span>
<span class="nc" id="L397"> return this;</span>
}
/**
* Gets the SDK defaulting strategy.
*
* @return the client mode (never {@code null})
* @since 1.3.0
*/
public CopilotClientMode getMode() {
<span class="nc" id="L407"> return mode;</span>
}
/**
* Sets the SDK defaulting strategy.
* <p>
* When set to {@link CopilotClientMode#EMPTY}, the SDK validates that the app
* has supplied the required configuration (e.g.
* {@link #setCopilotHome(String)}) and translates session creation requests
* into runtime options that flip tool filter precedence to
* {@code excluded}-wins so exclusions are expressible.
*
* @param mode
* the client mode
* @return this options instance for method chaining
* @since 1.3.0
*/
public CopilotClientOptions setMode(CopilotClientMode mode) {
<span class="nc" id="L425"> this.mode = Objects.requireNonNull(mode, "mode must not be null");</span>
<span class="nc" id="L426"> return this;</span>
}
/**
* Gets the custom handler for listing available models.
*
* @return the handler, or {@code null} if not set
*/
public Supplier<CompletableFuture<List<ModelInfo>>> getOnListModels() {
<span class="nc" id="L435"> return onListModels;</span>
}
/**
* Sets a custom handler for listing available models.
* <p>
* When provided, {@code listModels()} calls this handler instead of querying
* the CLI server. Useful in BYOK (Bring Your Own Key) mode to return models
* available from your custom provider.
*
* @param onListModels
* the handler that returns the list of available models (must not be
* {@code null})
* @return this options instance for method chaining
* @throws IllegalArgumentException
* if {@code onListModels} is {@code null}
*/
public CopilotClientOptions setOnListModels(Supplier<CompletableFuture<List<ModelInfo>>> onListModels) {
<span class="nc" id="L453"> this.onListModels = Objects.requireNonNull(onListModels, "onListModels must not be null");</span>
<span class="nc" id="L454"> return this;</span>
}
/**
* Gets the TCP port for the CLI server.
*
* @return the port number, or 0 for a random port
*/
public int getPort() {
<span class="nc" id="L463"> return port;</span>
}
/**
* Sets the TCP port for the CLI server to listen on.
* <p>
* This is only used when {@link #isUseStdio()} is {@code false}.
*
* @param port
* the port number, or 0 for a random port
* @return this options instance for method chaining
*/
public CopilotClientOptions setPort(int port) {
<span class="nc" id="L476"> this.port = port;</span>
<span class="nc" id="L477"> return this;</span>
}
/**
* Returns whether remote session support (Mission Control integration) is
* enabled.
* <p>
* When {@code true}, sessions in a GitHub repository working directory are
* accessible from GitHub web and mobile.
*
* @return {@code true} if remote sessions are enabled
*/
public boolean isRemote() {
<span class="nc" id="L490"> return remote;</span>
}
/**
* Enables remote session support (Mission Control integration).
* <p>
* When {@code true}, sessions in a GitHub repository working directory are
* accessible from GitHub web and mobile.
* <p>
* This option is only used when the SDK spawns the CLI process; it is ignored
* when connecting to an external server via {@link #setCliUrl(String)}.
*
* @param remote
* {@code true} to enable remote sessions
* @return this options instance for method chaining
*/
public CopilotClientOptions setRemote(boolean remote) {
<span class="nc" id="L507"> this.remote = remote;</span>
<span class="nc" id="L508"> return this;</span>
}
/**
* Gets the OpenTelemetry configuration for the CLI server.
*
* @return the telemetry config, or {@code null}
* @since 1.2.0
*/
public TelemetryConfig getTelemetry() {
<span class="nc" id="L518"> return telemetry;</span>
}
/**
* Sets the OpenTelemetry configuration for the CLI server.
* <p>
* When set, the CLI server is started with OpenTelemetry instrumentation
* enabled using the provided settings.
*
* @param telemetry
* the telemetry configuration
* @return this options instance for method chaining
* @since 1.2.0
*/
public CopilotClientOptions setTelemetry(TelemetryConfig telemetry) {
<span class="nc" id="L533"> this.telemetry = Objects.requireNonNull(telemetry, "telemetry must not be null");</span>
<span class="nc" id="L534"> return this;</span>
}
/**
* Gets the server-wide idle timeout for sessions in seconds.
*
* @return an {@link OptionalInt} containing the session idle timeout in
* seconds, or {@link java.util.OptionalInt#empty()} if not set. Use
* {@link #clearSessionIdleTimeoutSeconds()} to revert to the default.
* @since 1.3.0
*/
@JsonIgnore
public OptionalInt getSessionIdleTimeoutSeconds() {
<span class="nc bnc" id="L547" title="All 2 branches missed."> return sessionIdleTimeoutSeconds == null ? OptionalInt.empty() : OptionalInt.of(sessionIdleTimeoutSeconds);</span>
}
/**
* Sets the server-wide idle timeout for sessions in seconds.
* <p>
* Sessions without activity for this duration are automatically cleaned up. Set
* to {@code 0} to disable (sessions live indefinitely). Use
* {@link #clearSessionIdleTimeoutSeconds()} to revert to the default.
* <p>
* This option is only used when the SDK spawns the CLI process; it is ignored
* when connecting to an external server via {@link #setCliUrl(String)}.
*
* @param sessionIdleTimeoutSeconds
* the idle timeout in seconds
* @return this options instance for method chaining
* @since 1.3.0
*/
public CopilotClientOptions setSessionIdleTimeoutSeconds(int sessionIdleTimeoutSeconds) {
<span class="nc" id="L566"> this.sessionIdleTimeoutSeconds = sessionIdleTimeoutSeconds;</span>
<span class="nc" id="L567"> return this;</span>
}
/**
* Clears the sessionIdleTimeoutSeconds setting, reverting to the default
* behavior.
*
* @return this instance for method chaining
*/
public CopilotClientOptions clearSessionIdleTimeoutSeconds() {
<span class="nc" id="L577"> this.sessionIdleTimeoutSeconds = null;</span>
<span class="nc" id="L578"> return this;</span>
}
/**
* Gets the connection token for the headless CLI server (TCP only).
*
* @return the connection token, or {@code null} if not set
*/
public String getTcpConnectionToken() {
<span class="nc" id="L587"> return tcpConnectionToken;</span>
}
/**
* Sets the connection token for the headless CLI server (TCP only).
* <p>
* When the SDK spawns its own CLI in TCP mode and this is omitted, a UUID is
* generated automatically so the loopback listener is safe by default. Cannot
* be combined with {@link #setUseStdio(boolean)} = {@code true}.
*
* @param tcpConnectionToken
* the connection token (must not be {@code null} or empty)
* @return this options instance for method chaining
*/
public CopilotClientOptions setTcpConnectionToken(String tcpConnectionToken) {
<span class="nc" id="L602"> this.tcpConnectionToken = Objects.requireNonNull(tcpConnectionToken, "tcpConnectionToken must not be null");</span>
<span class="nc" id="L603"> return this;</span>
}
/**
* Returns whether to use the logged-in user for authentication.
*
* @return an {@link Optional} containing the boolean value, or empty if not set
*/
@JsonIgnore
public Optional<Boolean> getUseLoggedInUser() {
<span class="nc" id="L613"> return Optional.ofNullable(useLoggedInUser);</span>
}
/**
* Sets whether to use the logged-in user for authentication.
* <p>
* When true, the CLI server will attempt to use stored OAuth tokens or gh CLI
* auth. When false, only explicit tokens (gitHubToken or environment variables)
* are used. Default: true (but defaults to false when gitHubToken is provided).
* <p>
*
* @param useLoggedInUser
* {@code true} to use logged-in user auth, {@code false} otherwise
* @return this options instance for method chaining
*/
public CopilotClientOptions setUseLoggedInUser(boolean useLoggedInUser) {
<span class="nc" id="L629"> this.useLoggedInUser = useLoggedInUser;</span>
<span class="nc" id="L630"> return this;</span>
}
/**
* Clears the useLoggedInUser setting, reverting to the default behavior.
*
* @return this instance for method chaining
*/
public CopilotClientOptions clearUseLoggedInUser() {
<span class="nc" id="L639"> this.useLoggedInUser = null;</span>
<span class="nc" id="L640"> return this;</span>
}
/**
* Returns whether to use stdio transport instead of TCP.
*
* @return {@code true} to use stdio (default), {@code false} to use TCP
*/
public boolean isUseStdio() {
<span class="nc" id="L649"> return useStdio;</span>
}
/**
* Sets whether to use stdio transport instead of TCP.
* <p>
* Stdio transport is more efficient and is the default. TCP transport can be
* useful for debugging or connecting to remote servers.
*
* @param useStdio
* {@code true} to use stdio, {@code false} to use TCP
* @return this options instance for method chaining
*/
public CopilotClientOptions setUseStdio(boolean useStdio) {
<span class="nc" id="L663"> this.useStdio = useStdio;</span>
<span class="nc" id="L664"> return this;</span>
}
/**
* Creates a shallow clone of this {@code CopilotClientOptions} instance.
* <p>
* Array properties (like {@code cliArgs}) are copied into new arrays so that
* modifications to the clone do not affect the original. The
* {@code environment} map is also copied to a new map instance. Other
* reference-type properties are shared between the original and clone.
*
* @return a clone of this options instance
*/
@Override
public CopilotClientOptions clone() {
<span class="nc" id="L679"> CopilotClientOptions copy = new CopilotClientOptions();</span>
<span class="nc" id="L680"> copy.autoRestart = this.autoRestart;</span>
<span class="nc" id="L681"> copy.autoStart = this.autoStart;</span>
<span class="nc bnc" id="L682" title="All 2 branches missed."> copy.cliArgs = this.cliArgs != null ? this.cliArgs.clone() : null;</span>
<span class="nc" id="L683"> copy.cliPath = this.cliPath;</span>
<span class="nc" id="L684"> copy.cliUrl = this.cliUrl;</span>
<span class="nc" id="L685"> copy.copilotHome = this.copilotHome;</span>
<span class="nc" id="L686"> copy.cwd = this.cwd;</span>
<span class="nc bnc" id="L687" title="All 2 branches missed."> copy.environment = this.environment != null ? new java.util.HashMap<>(this.environment) : null;</span>
<span class="nc" id="L688"> copy.executor = this.executor;</span>
<span class="nc" id="L689"> copy.gitHubToken = this.gitHubToken;</span>
<span class="nc" id="L690"> copy.logLevel = this.logLevel;</span>
<span class="nc" id="L691"> copy.onListModels = this.onListModels;</span>
<span class="nc" id="L692"> copy.port = this.port;</span>
<span class="nc" id="L693"> copy.remote = this.remote;</span>
<span class="nc" id="L694"> copy.sessionIdleTimeoutSeconds = this.sessionIdleTimeoutSeconds;</span>
<span class="nc" id="L695"> copy.tcpConnectionToken = this.tcpConnectionToken;</span>
<span class="nc" id="L696"> copy.telemetry = this.telemetry;</span>
<span class="nc" id="L697"> copy.useLoggedInUser = this.useLoggedInUser;</span>
<span class="nc" id="L698"> copy.useStdio = this.useStdio;</span>
<span class="nc" id="L699"> return copy;</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.14.202510111229</span></div></body></html>