@coda-console/codex 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/agent/display.mjs +1 -1
- package/agent/entry.mjs +2 -1
- package/agent/manual-mode.mjs +33 -0
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ Codex Agent:Codex 插件提供的入口运行 codex-acp,报告子 Agent、
|
|
|
8
8
|
|
|
9
9
|
**会话临时目录可写**:Coda 给会话一个临时目录时(环境变量 `CODA_SESSION_TMP`,绝对路径,`<状态根>/session-tmp/<会话ID>`),它加进 Codex workspace-write 沙箱的可写根,和 Coda 经 ACP 交来的附加目录同样处理(每一轮的沙箱策略与会话配置的 `sandbox_workspace_write.writable_roots`),从别的机器拉下来的文件可以原地改再推回去。只加这个会话自己的目录,不加 `session-tmp/`(别的会话的目录在它下面);完全放开模式本来就能写,只读的沙箱策略不加;没有这个变量(旧的后端)或不是绝对路径时和以前一样。Codex 的 `TMPDIR` 不改。
|
|
10
10
|
|
|
11
|
+
**审批模式**:除 codex-acp 自带的 `read-only`(短名「按需审批」)、`agent`(「自动审批」)、`agent-full-access`(「完全访问」)外,入口给它的唯一一张模式表加了第四个 `manual`(「人工审批」):`approvalPolicy: untrusted`、审批人是用户、workspace-write 沙箱且不开网络(`agent/manual-mode.mjs`,锚点对不上就启动失败)。Codex 要运行不在它可信命令里的命令时,经 ACP 的 `session/request_permission` 交给 Coda 由人答复;会话临时目录同样在它的可写根里。`read-only` 保留给已有会话,它是 `on-request`(由模型自己决定问不问)且允许写工作区,所以不归入 `safe`。清单的 `modes` 因此是 `manual: "manual"`、`auto: "agent"`、`full: "agent-full-access"`、`safe: []`、`default: "full"`,与未指定模式时的启动默认(完全访问)一致。
|
|
12
|
+
|
|
11
13
|
## 资源页:Codex 的登录与额度
|
|
12
14
|
|
|
13
15
|
资源页上的资源类型「Codex」:这台机器上 Codex 自己的登录(本机登录)和它的额度。打开「多账号」时它输出为空,「Codex」里是多账号管理的账号(类型 `accounts`,见下)。
|
package/agent/display.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Compact labels belong to the adapter. Keep native IDs, full names, groups and all unrelated metadata intact.
|
|
2
|
-
const modes = { 'read-only': '
|
|
2
|
+
const modes = { manual: '人工审批', 'read-only': '按需审批', agent: '自动审批', 'agent-full-access': '完全访问' };
|
|
3
3
|
const label = (value, category, id = value.value ?? value.id) => {
|
|
4
4
|
const shortName = category === 'mode' ? (Object.hasOwn(modes, id) ? modes[id] : undefined)
|
|
5
5
|
: category === 'model' && /^GPT[- ]\d/i.test(value.name ?? '') ? value.name.replace(/^GPT[- ]/i, '') : undefined;
|
package/agent/entry.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { orderedCodexTitles } from './titles.mjs';
|
|
|
18
18
|
import { continuedCodexSubagents } from './subagents.mjs';
|
|
19
19
|
import { describeExit, followCodexProcessExit, listenExit } from './process-exit.mjs';
|
|
20
20
|
import { networkedCodexDevelopment } from './network.mjs';
|
|
21
|
+
import { manualCodexApproval } from './manual-mode.mjs';
|
|
21
22
|
import { codexOptionsAsShown } from './options.mjs';
|
|
22
23
|
import { instructedCodexThreads } from './instructions.mjs';
|
|
23
24
|
import { promptRequiredCodexSteering } from './steering.mjs';
|
|
@@ -92,6 +93,6 @@ registerHooks({ load(url, context, nextLoad) {
|
|
|
92
93
|
const loaded = nextLoad(url, context);
|
|
93
94
|
if (url !== adapter.href) return loaded;
|
|
94
95
|
return { ...loaded, source: reportedCodexUnrecognized(shownCodexAsyncMessages(reportedCodexCompactions(reportedCodexSleeps(reportedCodexFailures(codexOptionsAsShown(relayedCodexStreams(orderedCodexTitles(followCodexProcessExit(continuedCodexSubagents(
|
|
95
|
-
promptRequiredCodexSteering(instructedCodexThreads(countedCodexUsage(servedCodexModels(networkedCodexDevelopment(writableCodexSessionTmp(trustedCodaMcpRequests(Buffer.from(loaded.source).toString('utf8')))))))))))))))))) };
|
|
96
|
+
promptRequiredCodexSteering(instructedCodexThreads(countedCodexUsage(servedCodexModels(networkedCodexDevelopment(manualCodexApproval(writableCodexSessionTmp(trustedCodaMcpRequests(Buffer.from(loaded.source).toString('utf8'))))))))))))))))))) };
|
|
96
97
|
} });
|
|
97
98
|
await import(adapter.href);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// codex-acp 1.12.0 has no mode in which Codex asks the user before everything but its trusted commands: its "read-only" is
|
|
2
|
+
// `on-request`, where the model itself decides what to ask about. Coda's manual approval tier needs the real thing, so this adds the
|
|
3
|
+
// mode `manual` to the adapter's one AgentMode table (the mode list, `session/set_mode`, `session/set_config_option` and the
|
|
4
|
+
// config options all read it): `untrusted` approval, the user as reviewer, a workspace-write sandbox without network. Fail loudly
|
|
5
|
+
// on an adapter upgrade.
|
|
6
|
+
const patches = [
|
|
7
|
+
[` static DEFAULT_AGENT_MODE = _AgentMode.Agent;`, ` static Manual = new _AgentMode(
|
|
8
|
+
"manual",
|
|
9
|
+
"Manual approval",
|
|
10
|
+
"Ask before running anything outside Codex's trusted commands",
|
|
11
|
+
"standard",
|
|
12
|
+
"untrusted",
|
|
13
|
+
"user",
|
|
14
|
+
{
|
|
15
|
+
type: "workspaceWrite",
|
|
16
|
+
writableRoots: [],
|
|
17
|
+
networkAccess: false,
|
|
18
|
+
excludeTmpdirEnvVar: false,
|
|
19
|
+
excludeSlashTmp: false
|
|
20
|
+
},
|
|
21
|
+
"workspace-write"
|
|
22
|
+
);
|
|
23
|
+
static DEFAULT_AGENT_MODE = _AgentMode.Agent;`],
|
|
24
|
+
[' return [_AgentMode.ReadOnly, _AgentMode.Agent, _AgentMode.AgentFullAccess];',
|
|
25
|
+
' return [_AgentMode.Manual, _AgentMode.ReadOnly, _AgentMode.Agent, _AgentMode.AgentFullAccess];'],
|
|
26
|
+
];
|
|
27
|
+
export function manualCodexApproval(source) {
|
|
28
|
+
for (const [before, after] of patches) {
|
|
29
|
+
if (source.split(before).length !== 2) throw new Error('codex-acp manual approval mode patch no longer matches the locked adapter');
|
|
30
|
+
source = source.replace(before, () => after);
|
|
31
|
+
}
|
|
32
|
+
return source;
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"id": "codex",
|
|
4
4
|
"displayName": "Codex",
|
|
5
5
|
"description": "用 OpenAI Codex 跑会话",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.4.0",
|
|
7
7
|
"engines": {
|
|
8
|
-
"coda":
|
|
8
|
+
"coda": 21
|
|
9
9
|
},
|
|
10
10
|
"categories": [
|
|
11
11
|
"Agent"
|
|
@@ -32,10 +32,13 @@
|
|
|
32
32
|
"command": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/agent/entry.mjs\"",
|
|
33
33
|
"modes": {
|
|
34
34
|
"title": "审批模式",
|
|
35
|
-
"unset": "
|
|
35
|
+
"unset": "默认(完全放开)",
|
|
36
36
|
"note": "未选择时为完全访问。",
|
|
37
|
+
"manual": "manual",
|
|
37
38
|
"auto": "agent",
|
|
38
|
-
"full": "agent-full-access"
|
|
39
|
+
"full": "agent-full-access",
|
|
40
|
+
"safe": [],
|
|
41
|
+
"default": "full"
|
|
39
42
|
},
|
|
40
43
|
"skillsDir": ".agents/skills",
|
|
41
44
|
"configFiles": [
|