Skip to content

Commit 0a4ff8d

Browse files
committed
sync: cherry-pick changes from feature/3.0.x
1 parent 6da07df commit 0a4ff8d

16 files changed

Lines changed: 3554 additions & 157 deletions

src/main/java/io/github/easy4j/codex/CodexClient.java

Lines changed: 560 additions & 64 deletions
Large diffs are not rendered by default.
Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,124 @@
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+
*/
116
package io.github.easy4j.codex;
217

318
import lombok.Data;
419

520
/**
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
740
*/
841
@Data
942
public class CodexClientConfig {
1043

11-
/** 本地 CLI 可执行文件名或绝对路径 */
44+
/** Name or absolute path of the local {@code codex} CLI executable. */
1245
private String localExecutable = "codex";
1346

14-
/** 命令执行超时(秒) */
47+
/** Command execution timeout in seconds (passed to the OS-level watchdog). */
1548
private int localTimeoutSeconds = 600;
1649

17-
/** 探测 CLI 是否可用的超时(秒) */
50+
/** Timeout in seconds used by {@link CodexClientConfig#probe()} when verifying CLI availability. */
1851
private int localProbeTimeoutSeconds = 5;
1952

20-
/** 默认模型 */
53+
/** Default model name (e.g. {@code gpt-5-codex}); propagated to every {@code exec} call when set. */
2154
private String defaultModel;
2255

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}). */
2457
private String defaultSandbox;
2558

26-
/** 默认审批策略(untrusted, on-request, never */
59+
/** Default approval policy (one of {@code untrusted}, {@code on-request}, {@code never}). */
2760
private String defaultApprovalPolicy;
2861

29-
/** 默认配置 profile */
62+
/** Default configuration profile name. */
3063
private String defaultProfile;
3164

32-
/** 是否使用 OSS provider */
65+
/** Whether to use the OSS provider instead of OpenAI-hosted models. */
3366
private boolean ossProvider;
3467

35-
/** OSS provider 名称(lmstudio / ollama */
68+
/** OSS provider name (e.g. {@code lmstudio}, {@code ollama}). */
3669
private String localProvider;
3770

38-
/** 是否跳过 git repo 检查 */
71+
/** Skip the precondition check that the current directory is a git repository. */
3972
private boolean skipGitRepoCheck;
4073

41-
/** 是否为临时会话(不持久化) */
74+
/** If {@code true}, sessions are not persisted to disk after the call completes. */
4275
private boolean ephemeral;
4376

44-
/** 是否输出 JSONL 格式 */
77+
/** Emit {@code codex} output as JSON Lines (the SDK parses these into {@link io.github.easy4j.codex.model.CodexEvent} instances). */
4578
private boolean jsonOutput = true;
4679

47-
/** 输出 Schema 文件路径(结构化输出) */
80+
/** Path to a JSON Schema file describing the structured output expected from the agent. */
4881
private String outputSchema;
4982

50-
/** 是否启用 web search */
83+
/** Enable web-search tool during execution. */
5184
private boolean search;
5285

53-
/** 图片文件路径 */
86+
/** Path to an image attachment forwarded to the agent. */
5487
private String image;
5588

56-
/** 配置覆盖(-c key=value */
89+
/** Inline {@code -c key=value} configuration overrides; each element becomes a separate {@code -c} flag. */
5790
private String[] configOverrides;
5891

59-
/** 输出文件路径(output-last-message */
92+
/** Output file path used by {@code codex exec --output-last-message}. */
6093
private String outputFile;
6194

62-
/** 额外目录 */
95+
/** Additional directory granted to the agent at runtime. */
6396
private String addDir;
6497

65-
/** 工作目录 */
98+
/** Working directory in which the {@code codex} process is launched. */
6699
private String workingDir;
67100

68-
/** 是否跳过所有审批和沙箱(极度危险) */
101+
/**
102+
* Bypass ALL approval prompts and the OS sandbox. <strong>Use with extreme
103+
* caution</strong> &mdash; the agent will run without any human gating.
104+
*/
69105
private boolean dangerouslyBypassApprovalsAndSandbox;
70106

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+
*/
72111
private boolean dangerouslyBypassHookTrust;
73112

74-
/** 严格配置模式(报错而非忽略未知字段) */
113+
/** Fail fast on unknown configuration keys instead of silently ignoring them. */
75114
private boolean strictConfig;
76115

77-
/** 启用的 feature(可重复) */
116+
/** Feature flags to enable (passed as repeated {@code --enable <name>}). */
78117
private String[] enable;
79118

80-
/** 禁用的 feature(可重复) */
119+
/** Feature flags to disable (passed as repeated {@code --disable <name>}). */
81120
private String[] disable;
82121

83-
/** 禁用 alternate screen 模式(TUI */
122+
/** Disable the alternate-screen mode in the interactive TUI. */
84123
private boolean noAltScreen;
85124
}

0 commit comments

Comments
 (0)