|
| 1 | +/* |
| 2 | + * Copyright (c) 2018-present, easy-4-java (https://github.com/easy-4-java). |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
1 | 16 | package io.github.easy4j.codex; |
2 | 17 |
|
3 | 18 | import lombok.Data; |
4 | 19 |
|
5 | 20 | /** |
6 | | - * Codex CLI 客户端配置(纯 POJO,可与 Spring {@code @ConfigurationProperties} 映射)。 |
| 21 | + * Configuration POJO for {@link CodexClient}. |
| 22 | + * |
| 23 | + * <p>This plain Java object captures every runtime knob the {@code codex} CLI |
| 24 | + * exposes, and is intentionally framework-free so it can be wired in three |
| 25 | + * common ways:</p> |
| 26 | + * <ul> |
| 27 | + * <li>Constructed programmatically (e.g. {@code new CodexClientConfig()}).</li> |
| 28 | + * <li>Mapped from external configuration sources such as YAML/JSON.</li> |
| 29 | + * <li>Bound by Spring's {@code @ConfigurationProperties} mechanism.</li> |
| 30 | + * </ul> |
| 31 | + * |
| 32 | + * <p>Default values are tuned for safe, non-destructive use: the JSON output |
| 33 | + * mode is enabled by default so callers can rely on structured responses, |
| 34 | + * while the bypass flags default to {@code false} so that operations always |
| 35 | + * require approvals unless explicitly opted-in.</p> |
| 36 | + * |
| 37 | + * @author [@Loong Wan](https://github.com/loong10k) |
| 38 | + * @since 3.0.0 |
| 39 | + * @see CodexClient |
7 | 40 | */ |
8 | 41 | @Data |
9 | 42 | public class CodexClientConfig { |
10 | 43 |
|
11 | | - /** 本地 CLI 可执行文件名或绝对路径 */ |
| 44 | + /** Name or absolute path of the local {@code codex} CLI executable. */ |
12 | 45 | private String localExecutable = "codex"; |
13 | 46 |
|
14 | | - /** 命令执行超时(秒) */ |
| 47 | + /** Command execution timeout in seconds (passed to the OS-level watchdog). */ |
15 | 48 | private int localTimeoutSeconds = 600; |
16 | 49 |
|
17 | | - /** 探测 CLI 是否可用的超时(秒) */ |
| 50 | + /** Timeout in seconds used by {@link CodexClientConfig#probe()} when verifying CLI availability. */ |
18 | 51 | private int localProbeTimeoutSeconds = 5; |
19 | 52 |
|
20 | | - /** 默认模型 */ |
| 53 | + /** Default model name (e.g. {@code gpt-5-codex}); propagated to every {@code exec} call when set. */ |
21 | 54 | private String defaultModel; |
22 | 55 |
|
23 | | - /** 默认 sandbox 模式(read-only, workspace-write, danger-full-access) */ |
| 56 | + /** Default sandbox mode (one of {@code read-only}, {@code workspace-write}, {@code danger-full-access}). */ |
24 | 57 | private String defaultSandbox; |
25 | 58 |
|
26 | | - /** 默认审批策略(untrusted, on-request, never) */ |
| 59 | + /** Default approval policy (one of {@code untrusted}, {@code on-request}, {@code never}). */ |
27 | 60 | private String defaultApprovalPolicy; |
28 | 61 |
|
29 | | - /** 默认配置 profile */ |
| 62 | + /** Default configuration profile name. */ |
30 | 63 | private String defaultProfile; |
31 | 64 |
|
32 | | - /** 是否使用 OSS provider */ |
| 65 | + /** Whether to use the OSS provider instead of OpenAI-hosted models. */ |
33 | 66 | private boolean ossProvider; |
34 | 67 |
|
35 | | - /** OSS provider 名称(lmstudio / ollama) */ |
| 68 | + /** OSS provider name (e.g. {@code lmstudio}, {@code ollama}). */ |
36 | 69 | private String localProvider; |
37 | 70 |
|
38 | | - /** 是否跳过 git repo 检查 */ |
| 71 | + /** Skip the precondition check that the current directory is a git repository. */ |
39 | 72 | private boolean skipGitRepoCheck; |
40 | 73 |
|
41 | | - /** 是否为临时会话(不持久化) */ |
| 74 | + /** If {@code true}, sessions are not persisted to disk after the call completes. */ |
42 | 75 | private boolean ephemeral; |
43 | 76 |
|
44 | | - /** 是否输出 JSONL 格式 */ |
| 77 | + /** Emit {@code codex} output as JSON Lines (the SDK parses these into {@link io.github.easy4j.codex.model.CodexEvent} instances). */ |
45 | 78 | private boolean jsonOutput = true; |
46 | 79 |
|
47 | | - /** 输出 Schema 文件路径(结构化输出) */ |
| 80 | + /** Path to a JSON Schema file describing the structured output expected from the agent. */ |
48 | 81 | private String outputSchema; |
49 | 82 |
|
50 | | - /** 是否启用 web search */ |
| 83 | + /** Enable web-search tool during execution. */ |
51 | 84 | private boolean search; |
52 | 85 |
|
53 | | - /** 图片文件路径 */ |
| 86 | + /** Path to an image attachment forwarded to the agent. */ |
54 | 87 | private String image; |
55 | 88 |
|
56 | | - /** 配置覆盖(-c key=value) */ |
| 89 | + /** Inline {@code -c key=value} configuration overrides; each element becomes a separate {@code -c} flag. */ |
57 | 90 | private String[] configOverrides; |
58 | 91 |
|
59 | | - /** 输出文件路径(output-last-message) */ |
| 92 | + /** Output file path used by {@code codex exec --output-last-message}. */ |
60 | 93 | private String outputFile; |
61 | 94 |
|
62 | | - /** 额外目录 */ |
| 95 | + /** Additional directory granted to the agent at runtime. */ |
63 | 96 | private String addDir; |
64 | 97 |
|
65 | | - /** 工作目录 */ |
| 98 | + /** Working directory in which the {@code codex} process is launched. */ |
66 | 99 | private String workingDir; |
67 | 100 |
|
68 | | - /** 是否跳过所有审批和沙箱(极度危险) */ |
| 101 | + /** |
| 102 | + * Bypass ALL approval prompts and the OS sandbox. <strong>Use with extreme |
| 103 | + * caution</strong> — the agent will run without any human gating. |
| 104 | + */ |
69 | 105 | private boolean dangerouslyBypassApprovalsAndSandbox; |
70 | 106 |
|
71 | | - /** 是否跳过 hook 信任检查 */ |
| 107 | + /** |
| 108 | + * Skip the trust verification step for plugin hooks. Enable only when you |
| 109 | + * fully control the hooks that will run. |
| 110 | + */ |
72 | 111 | private boolean dangerouslyBypassHookTrust; |
73 | 112 |
|
74 | | - /** 严格配置模式(报错而非忽略未知字段) */ |
| 113 | + /** Fail fast on unknown configuration keys instead of silently ignoring them. */ |
75 | 114 | private boolean strictConfig; |
76 | 115 |
|
77 | | - /** 启用的 feature(可重复) */ |
| 116 | + /** Feature flags to enable (passed as repeated {@code --enable <name>}). */ |
78 | 117 | private String[] enable; |
79 | 118 |
|
80 | | - /** 禁用的 feature(可重复) */ |
| 119 | + /** Feature flags to disable (passed as repeated {@code --disable <name>}). */ |
81 | 120 | private String[] disable; |
82 | 121 |
|
83 | | - /** 禁用 alternate screen 模式(TUI) */ |
| 122 | + /** Disable the alternate-screen mode in the interactive TUI. */ |
84 | 123 | private boolean noAltScreen; |
85 | 124 | } |
0 commit comments