@coda-console/codex 1.8.5 → 1.8.6

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.
@@ -0,0 +1,23 @@
1
+ // Compact labels belong to the adapter. Keep native IDs, full names, groups and all unrelated metadata intact.
2
+ const modes = { 'read-only': '审批', agent: '自动审批', 'agent-full-access': '完全访问' };
3
+ const label = (value, category, id = value.value ?? value.id) => {
4
+ const shortName = category === 'mode' ? (Object.hasOwn(modes, id) ? modes[id] : undefined)
5
+ : category === 'model' && /^GPT[- ]\d/i.test(value.name ?? '') ? value.name.replace(/^GPT[- ]/i, '') : undefined;
6
+ return shortName ? { ...value, _meta: { ...value._meta, coda: { ...value._meta?.coda, shortName } } } : value;
7
+ };
8
+ const options = list => list.map(option => ({ ...option, ...(Array.isArray(option.options) ? {
9
+ options: option.options.map(value => Array.isArray(value.options)
10
+ ? { ...value, options: value.options.map(each => label(each, option.category)) } : label(value, option.category)),
11
+ } : {}) }));
12
+ const display = value => ({ ...value,
13
+ ...(value.configOptions ? { configOptions: options(value.configOptions) } : {}),
14
+ ...(value.modes?.availableModes ? { modes: { ...value.modes, availableModes: value.modes.availableModes.map(mode => label(mode, 'mode')) } } : {}),
15
+ ...(value.models?.availableModels ? { models: { ...value.models, availableModels: value.models.availableModels.map(model => label(model, 'model')) } } : {}),
16
+ });
17
+ export function codexDisplayNames(message) {
18
+ if (message?.result && typeof message.result === 'object') return { ...message, result: display(message.result) };
19
+ if (message?.params?.update?.sessionUpdate === 'config_option_update') {
20
+ return { ...message, params: { ...message.params, update: display(message.params.update) } };
21
+ }
22
+ return message;
23
+ }
package/agent/entry.mjs CHANGED
@@ -25,6 +25,7 @@ import { CodexWaits } from './waits.mjs';
25
25
  import { CodexReviews } from './reviews.mjs';
26
26
  import { explainCodexError, reportedCodexFailures } from './errors.mjs';
27
27
  import { reportedCodexSleeps } from './sleep.mjs';
28
+ import { codexDisplayNames } from './display.mjs';
28
29
 
29
30
  const env = process.env;
30
31
  // A session starts read-only, unless its machine's configuration says otherwise.
@@ -50,7 +51,7 @@ if (!env.CODEX_PATH && accountSource(env) && env.CODA_PLUGIN_STATE) {
50
51
  const version = codexVersion();
51
52
  const waits = new CodexWaits({ agentInfo: version ? { name: 'codex', version } : null }), parse = line => { try { return JSON.parse(line); } catch { return null; } };
52
53
  const reviews = new CodexReviews(), say = message => process.stdout.write(`${JSON.stringify(message)}\n`);
53
- listen(line => { for (const message of waits.fromAgent(parse(line))) for (const each of reviews.fromAgent(message)) say(explainCodexError(each)); });
54
+ listen(line => { for (const message of waits.fromAgent(parse(line))) for (const each of reviews.fromAgent(message)) say(codexDisplayNames(explainCodexError(each))); });
54
55
  readLines(process.stdin).on('line', line => {
55
56
  const message = parse(line);
56
57
  if (!message || typeof message !== 'object') return;
package/package.json CHANGED
@@ -3,8 +3,10 @@
3
3
  "id": "codex",
4
4
  "displayName": "Codex",
5
5
  "description": "Codex Agent:Coda 自带的入口运行 codex-acp,报告子 Agent、后台命令与命令的自动审核。额度与登录由账号来源插件接管;未接入账号来源时使用 Codex 自己的登录面板。",
6
- "version": "1.8.5",
7
- "categories": ["Agent"],
6
+ "version": "1.8.6",
7
+ "categories": [
8
+ "Agent"
9
+ ],
8
10
  "dependencies": {
9
11
  "@agentclientprotocol/codex-acp": "1.12.0",
10
12
  "@openai/codex": "0.162.1"
@@ -46,7 +48,9 @@
46
48
  "items": {
47
49
  "type": "string",
48
50
  "format": "coda-model-provider",
49
- "modelApis": ["openai-responses"]
51
+ "modelApis": [
52
+ "openai-responses"
53
+ ]
50
54
  },
51
55
  "title": "模型服务",
52
56
  "order": 1,