codex-task 0.2.2 → 0.2.4

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.
Files changed (49) hide show
  1. package/.codex-plugin/plugin.json +4 -4
  2. package/README.md +201 -160
  3. package/README_EN.md +196 -0
  4. package/dist/api.d.ts.map +1 -1
  5. package/dist/api.js +36 -18
  6. package/dist/api.js.map +1 -1
  7. package/dist/backends/direct/index.d.ts +6 -2
  8. package/dist/backends/direct/index.d.ts.map +1 -1
  9. package/dist/backends/direct/index.js +2 -1
  10. package/dist/backends/direct/index.js.map +1 -1
  11. package/dist/backends/direct/protocol.d.ts +1 -0
  12. package/dist/backends/direct/protocol.d.ts.map +1 -1
  13. package/dist/backends/direct/protocol.js +1 -1
  14. package/dist/backends/direct/protocol.js.map +1 -1
  15. package/dist/cli.js +98 -35
  16. package/dist/cli.js.map +1 -1
  17. package/dist/images.d.ts +4 -2
  18. package/dist/images.d.ts.map +1 -1
  19. package/dist/images.js +35 -26
  20. package/dist/images.js.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/inputs.d.ts +14 -0
  26. package/dist/inputs.d.ts.map +1 -0
  27. package/dist/inputs.js +40 -0
  28. package/dist/inputs.js.map +1 -0
  29. package/dist/server.d.ts +19 -0
  30. package/dist/server.d.ts.map +1 -0
  31. package/dist/server.js +503 -0
  32. package/dist/server.js.map +1 -0
  33. package/dist/types.d.ts +8 -6
  34. package/dist/types.d.ts.map +1 -1
  35. package/examples/mobile/README.md +69 -0
  36. package/examples/mobile/android/CodexTaskClient.kt +126 -0
  37. package/examples/mobile/android/MealWorkflow.kt +51 -0
  38. package/examples/mobile/ios/CodexTaskClient.swift +163 -0
  39. package/examples/mobile/ios/MealWorkflow.swift +55 -0
  40. package/package.json +4 -2
  41. package/scripts/service/Install-Windows.ps1 +47 -0
  42. package/scripts/service/Uninstall-Windows.ps1 +9 -0
  43. package/scripts/service/install-macos.sh +66 -0
  44. package/scripts/service/install-ubuntu.sh +63 -0
  45. package/scripts/service/uninstall-macos.sh +12 -0
  46. package/scripts/service/uninstall-ubuntu.sh +12 -0
  47. package/skills/codex-task/SKILL.md +74 -38
  48. package/skills/codex-task/agents/openai.yaml +1 -1
  49. package/README.zh-CN.md +0 -209
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "codex-task",
3
- "version": "0.2.2",
4
- "description": "Delegate focused text, image, and workspace tasks to CodexTask",
3
+ "version": "0.2.4",
4
+ "description": "Delegate multimodal text, image, and workspace tasks to CodexTask",
5
5
  "author": {
6
6
  "name": "wang121ye",
7
7
  "url": "https://github.com/wangyendt"
@@ -18,8 +18,8 @@
18
18
  "skills": "./skills/",
19
19
  "interface": {
20
20
  "displayName": "CodexTask",
21
- "shortDescription": "Delegate text, image, and workspace tasks",
22
- "longDescription": "A companion skill for routing focused text, image, and workspace tasks through the CodexTask CLI.",
21
+ "shortDescription": "Delegate multimodal text, image, and workspace tasks",
22
+ "longDescription": "A companion skill for routing composable text, image, and workspace inputs through the CodexTask CLI.",
23
23
  "developerName": "wang121ye",
24
24
  "category": "Developer Tools",
25
25
  "capabilities": [
package/README.md CHANGED
@@ -1,273 +1,314 @@
1
1
  # CodexTask
2
2
 
3
- > Give another AI agent a focused errand—and get back text, images, or finished work. Powered by your existing Codex setup.
3
+ > 把文本、图片和项目任务交给另一个 Codex worker,拿回结构化文本、生成图片或已经完成的工作区变更。
4
4
 
5
- [中文文档](./README.zh-CN.md) · [PRD](./docs/PRD.md) · [Common commands](./docs/常用命令.txt) · [Companion skill](./skills/codex-task/SKILL.md)
5
+ [English](./README_EN.md) · [产品需求文档](./docs/PRD.md) · [远程部署与手机调用](./docs/knowhow/20260811_远程服务部署与移动端调用.md) · [常用命令](./docs/常用命令.txt) · [Companion Skill](./skills/codex-task/SKILL.md)
6
6
 
7
- CodexTask turns Codex into a small, composable worker for other agents. It ships one CLI, one TypeScript API, and one installable skill for three jobs:
7
+ CodexTask 是一个轻量、可组合的跨 Agent 多模态任务运行器。它提供 CLITypeScript API、可安装给其他 Agent Skill,以及可选的自托管 HTTP 服务;没有中心化托管平台,也不需要额外 API key。
8
8
 
9
- - focused text-to-text tasks;
10
- - text-to-image and image-to-image generation;
11
- - bounded workspace tasks through the official Codex SDK.
9
+ 你只需要按“想拿回什么”选择命令:
12
10
 
13
- No daemon. No hosted service. No extra API key. Results are stable JSON that another agent can consume.
11
+ | 期望结果 | 命令 | 可组合输入 | 典型任务 |
12
+ | --- | --- | --- | --- |
13
+ | 文本 | `codex-task text` | 文本、多个 prompt 文件、最多 5 张图片、stdin | 文生文、图生文、图文生文 |
14
+ | 图片 | `codex-task image` | 文本、多个 prompt 文件、最多 5 张参考图、stdin | 文生图、图生图、图文生图 |
15
+ | 工作区变更 | `codex-task task` | 文本、多个 prompt 文件、最多 5 张图片、当前项目 | 写代码、改文件、运行命令 |
16
+ | 恢复任务 | `codex-task resume` | task ID、补充文本/文件/图片 | 回答追问后继续同一个 Codex task |
14
17
 
15
18
  > [!IMPORTANT]
16
- > CodexTask is an independent, unofficial open-source project. It is not affiliated with, endorsed by, or sponsored by OpenAI. Codex and OpenAI are trademarks of OpenAI.
19
+ > CodexTask 是独立的非官方开源项目,与 OpenAI 不存在隶属、认可或赞助关系。Codex OpenAI OpenAI 的商标。
17
20
 
18
- ## Quick start
21
+ ## 30 秒上手
19
22
 
20
- Requirements: Node.js 20+ and an existing Codex login (`codex login`).
23
+ 需要 Node.js 20+,并已执行过 `codex login`。
21
24
 
22
25
  ```bash
23
26
  npm install -g codex-task
24
27
  codex-task doctor
25
28
  ```
26
29
 
27
- Delegate a text result:
30
+ 下面用同一份“健身营养餐”串起文生图、图生文、图生图、工作区任务和恢复。图片与 JSON 都来自真实模型请求,不是占位图或手写示意;由于生成模型具有随机性,重新执行会得到不同但同类的结果。
31
+
32
+ ### 1. 生成图片:一份健身营养餐
28
33
 
29
34
  ```bash
30
- codex-task text "Turn these notes into a crisp release announcement" \
31
- --backend direct
35
+ codex-task image "生成一份写实、干净的健身营养餐:香煎鸡胸肉、糙米、西兰花、牛油果;四种食物分区摆放,俯拍,完整餐盘,食材边界清晰;浅灰桌面,柔和自然光;不要文字、水印、餐具和其他食物。" -o ./docs/assets/fitness-meal.png --size 1024x1024 --quality high
32
36
  ```
33
37
 
34
- Generate an image that will not be removed by temporary-file cleanup:
38
+ 这个示例用 `--output` 保存到 README 资产目录;省略它时,最终图片默认保存在当前目录,而不是临时目录:
35
39
 
36
- ```bash
37
- codex-task image "A precise exploded-view diagram of a compact robot joint" \
38
- --backend direct \
39
- --size 1536x1024 \
40
- --quality high \
41
- --output ./artifacts
40
+ ```json
41
+ {
42
+ "status": "completed",
43
+ "taskId": "78cda394-e16f-4cac-9d0f-9b8a010e3879",
44
+ "backend": "direct",
45
+ "text": "Generated 1 image(s).",
46
+ "effectiveModel": "gpt-5.5",
47
+ "artifacts": [
48
+ { "path": "/your/project/docs/assets/fitness-meal.png", "kind": "image", "mimeType": "image/png" }
49
+ ]
50
+ }
42
51
  ```
43
52
 
44
- Edit an image:
53
+ 真实生成结果:
45
54
 
46
- ```bash
47
- codex-task image "Keep the object; replace the background with a clean workshop" \
48
- --backend direct \
49
- --image ./reference.png \
50
- --output ./artifacts
51
- ```
55
+ ![CodexTask 文生图生成的健身营养餐](./docs/assets/fitness-meal.png)
52
56
 
53
- Delegate repository work:
57
+ ### 2. 图片 + prompt → JSON 营养分析
54
58
 
55
59
  ```bash
56
- codex-task task "Implement the requested feature and run focused tests" \
57
- --backend sdk \
58
- --cwd /absolute/path/to/repo
60
+ codex-task text "识别图片中的全部食物,估算每项可食部分重量和热量。重量和热量必须是数字;热量为基于视觉份量的近似值;note 用中文说明估算存在误差。" -i ./docs/assets/fitness-meal.png --schema ./docs/examples/nutrition.schema.json --model gpt-5.6-sol --reasoning medium
59
61
  ```
60
62
 
61
- Every command writes a machine-readable result:
63
+ 图生文输入就是上一步的真实图片:
64
+
65
+ <img src="./docs/assets/fitness-meal.png" alt="CodexTask 图生文输入图片" width="520">
66
+
67
+ `text` 不只是文生文,也支持图生文和图文生文。下面是该命令真实返回的结构化内容,完整文件见 [`fitness-meal-analysis.json`](./docs/examples/fitness-meal-analysis.json):
62
68
 
63
69
  ```json
64
70
  {
65
- "status": "completed",
66
- "taskId": "e6fe7ed7-72de-4b27-8b6e-08152192d6cb",
67
- "backend": "direct",
68
- "text": "...",
69
- "effectiveModel": "gpt-5.6-sol",
70
- "reasoningEffort": "medium",
71
- "artifacts": []
71
+ "foods": [
72
+ { "name": "煎烤鸡胸肉", "estimatedGrams": 220, "calories": 380 },
73
+ { "name": "熟糙米饭", "estimatedGrams": 250, "calories": 280 },
74
+ { "name": "西兰花", "estimatedGrams": 170, "calories": 60 },
75
+ { "name": "牛油果", "estimatedGrams": 100, "calories": 160 }
76
+ ],
77
+ "totalCalories": 880,
78
+ "note": "以上重量和热量根据图片中的视觉份量估算,实际数值会因食材品种、烹饪用油及熟制程度而存在误差。"
72
79
  }
73
80
  ```
74
81
 
75
- ## Pick the backend
82
+ 这只是视觉估算,不应替代称重或专业营养建议。
76
83
 
77
- CodexTask never guesses. Direct is the CLI default, but workspace tasks require an explicit SDK backend.
84
+ ### 3. 图片 + prompt 高蛋白版本图片
78
85
 
79
- | Capability | `direct` | `sdk` |
80
- | --- | --- | --- |
81
- | Focused text result | Yes | Yes |
82
- | Text-to-image / image-to-image | Yes, native result extraction | Yes, via the installed `$imagegen` skill |
83
- | Shell and file edits | No | Yes |
84
- | Project rules and local tools | No | Yes |
85
- | Local Codex skills | No | Normal Codex discovery |
86
- | Transport | Unofficial ChatGPT Codex Responses | Official `@openai/codex-sdk` |
87
- | Stability | Experimental | Supported SDK surface |
86
+ ```bash
87
+ codex-task image "把这份餐食调整成高蛋白低碳版本:增加约 50% 的鸡胸肉,糙米减少约一半;只改变鸡胸肉和糙米的份量,保持餐盘、俯拍机位、光线、牛油果、西兰花和写实摄影风格不变;不要增加其他食物、文字或水印。" -i ./docs/assets/fitness-meal.png -o ./docs/assets/fitness-meal-high-protein.png --size 1024x1024 --quality high
88
+ ```
88
89
 
89
- Direct reuses `$CODEX_HOME/auth.json`, Codex installation metadata, TLS impersonation, and the private ChatGPT Codex Responses endpoint. Inputs are still sent to ChatGPT. The interface may change without notice.
90
+ | 图生图输入 | 真实图生图输出 |
91
+ | --- | --- |
92
+ | <img src="./docs/assets/fitness-meal.png" alt="原始健身营养餐" width="420"> | <img src="./docs/assets/fitness-meal-high-protein.png" alt="高蛋白低碳版本健身营养餐" width="420"> |
93
+ | 原始份量 | 增加鸡胸肉、减少糙米 |
90
94
 
91
- The SDK backend defaults to:
95
+ ### 4. 多份要求 + 参考图 → 完成项目
92
96
 
93
- ```text
94
- sandbox: danger-full-access
95
- approval: never
96
- network: true
97
+ ```bash
98
+ codex-task task "实现一个健身营养餐详情页,并运行相关测试" -f ./requirements.md -f ./api-contract.md -i ./docs/assets/fitness-meal.png --cwd ./meal-app
97
99
  ```
98
100
 
99
- That combination is intentionally powerful: it can read and write outside the workspace, execute commands, and use the network without asking for approval. Only delegate trusted prompts and repositories.
101
+ `task` 固定使用官方 Codex SDK,不需要再写 `--backend sdk`。`--cwd ./meal-app` 表示:把该目录作为 worker 的当前项目;Codex 会从这里读取代码、项目规则与 skills,并在授权范围内修改文件、执行命令。
100
102
 
101
- ## Agent follow-ups
103
+ ```json
104
+ {
105
+ "status": "completed",
106
+ "taskId": "7dd7a7d7-...",
107
+ "backend": "sdk",
108
+ "threadId": "019...",
109
+ "text": "已实现营养餐详情页并通过相关测试。",
110
+ "changes": ["src/pages/MealDetail.tsx", "test/MealDetail.test.tsx"],
111
+ "commands": [{ "command": "npm test -- MealDetail", "exitCode": 0 }],
112
+ "artifacts": []
113
+ }
114
+ ```
115
+
116
+ ### 5. 回答追问并继续
102
117
 
103
- SDK tasks are single-turn first. If the worker needs clarification, the result is not an error:
118
+ 如果任务存在关键歧义,`task` 可能返回:
104
119
 
105
120
  ```json
106
121
  {
107
122
  "status": "needs_input",
108
- "taskId": "...",
109
- "threadId": "...",
110
- "questions": ["Should the API preserve the legacy response shape?"],
123
+ "taskId": "7dd7a7d7-...",
124
+ "questions": ["页面按单人份还是双人份展示热量?"],
111
125
  "artifacts": []
112
126
  }
113
127
  ```
114
128
 
115
- Ask the user, then resume the same Codex thread:
129
+ 取得答案后,用同一个 task ID 恢复;补充回答也可以同时带多个文件和图片:
116
130
 
117
131
  ```bash
118
- printf '%s' "Yes, preserve it." | codex-task resume <task-id>
132
+ codex-task resume 7dd7a7d7-... "按单人份展示" -f ./copy-guidelines.md -i ./expected-layout.png
119
133
  ```
120
134
 
121
- Pass `--no-followup` to require reasonable assumptions and a completed/failed result in one caller turn. It does not guarantee the model succeeds.
122
-
123
- ## Use from another agent
135
+ ```json
136
+ {
137
+ "status": "completed",
138
+ "taskId": "7dd7a7d7-...",
139
+ "backend": "sdk",
140
+ "text": "已按单人份完成页面和测试。",
141
+ "changes": ["src/pages/MealDetail.tsx"],
142
+ "artifacts": []
143
+ }
144
+ ```
124
145
 
125
- This repository ships `skills/codex-task/SKILL.md`. It teaches a calling agent when to choose text, image, task, or resume. It is a companion skill, not a skill injected into the Codex worker.
146
+ ## 组合输入,而不是四选一
126
147
 
127
- Install it with [SkillTruck](https://github.com/wangyendt/skilltruck):
148
+ 位置 prompt、重复的 `-f/--prompt-file`、非空 stdin 和重复的 `-i/--image` 可以同时出现:
128
149
 
129
150
  ```bash
130
- npm install -g skilltruck
131
- skilltruck install https://github.com/wangyendt/codex-task --global
151
+ printf '%s' "总热量控制在 700 kcal 内" | codex-task text "制定调整建议" -f ./training-goal.md -f ./allergies.md -i ./meal-front.png -i ./meal-side.png
132
152
  ```
133
153
 
134
- Or locate the copy included in the npm package:
154
+ CodexTask 按固定顺序组合输入:位置 prompt prompt 文件(按命令行顺序)→ stdin;图片保持 `-i` 的顺序。文件内容会带绝对路径边界标记,避免多份长 prompt 混在一起。每张图片不超过 20 MiB,总和不超过 50 MiB。
135
155
 
136
- ```bash
137
- codex-task skill path
138
- ```
156
+ ## 两种后端
139
157
 
140
- The repository also includes `.codex-plugin/plugin.json` for plugin-compatible distribution.
158
+ `text` `image` 默认使用 Direct,可手动传 `--backend sdk`。`task` `resume` 固定使用 SDK,不做自动猜测。
141
159
 
142
- ## TypeScript API
143
-
144
- ```ts
145
- import { generateImage, generateText, runTask } from "codex-task";
160
+ | 能力 | `direct` | `sdk` |
161
+ | --- | --- | --- |
162
+ | 文本结果 | 支持文本与图片输入 | 支持文本与图片输入 |
163
+ | 图片结果 | 原生提取生成图片 | Codex 调用已安装的 `$imagegen` skill |
164
+ | shell、文件修改、项目规则 | 不支持 | 支持 |
165
+ | 本地 Codex skills | 不支持 | 按 Codex 正常发现 |
166
+ | 底层 | 非官方 ChatGPT Codex Responses | 官方 `@openai/codex-sdk` |
146
167
 
147
- const copy = await generateText({
148
- prompt: "Write a launch headline and three supporting bullets.",
149
- backend: "direct",
150
- });
168
+ Direct 复用 `$CODEX_HOME/auth.json`、Codex installation metadata、TLS impersonation 和 ChatGPT 私有 Codex Responses 接口。输入仍会发往 ChatGPT,接口可能随时变化。Direct 只返回生成结果,不能读项目、运行 shell、调用本地 MCP 或使用 worker skills。
151
169
 
152
- const image = await generateImage({
153
- prompt: "A restrained isometric illustration of agent-to-agent delegation.",
154
- backend: "direct",
155
- output: "./artifacts",
156
- quality: "high",
157
- });
170
+ SDK task 默认权限为:
158
171
 
159
- const work = await runTask({
160
- prompt: "Add the feature and run focused tests.",
161
- backend: "sdk",
162
- workingDirectory: "/absolute/path/to/repo",
163
- });
172
+ ```text
173
+ sandbox: danger-full-access
174
+ approval: never
175
+ network: true
164
176
  ```
165
177
 
166
- For progress events:
178
+ 这意味着 worker 可以访问工作区外路径、执行命令并联网,而且不会等待权限确认。只委派可信 prompt 和可信项目;需要收窄时显式传 `--sandbox workspace-write` 或 `--no-network`。
167
179
 
168
- ```ts
169
- import { streamTaskEvents } from "codex-task";
180
+ ## 图片输出与临时文件
170
181
 
171
- for await (const event of streamTaskEvents({
172
- kind: "text",
173
- options: { prompt: "Summarize this decision", backend: "direct" },
174
- })) {
175
- console.log(event);
176
- }
182
+ - 默认:在当前目录生成唯一文件名,例如 `./image-a1b2c3d4.png`;这是持久用户文件,`gc` 不会删除。
183
+ - 指定位置:传 `-o ./artifacts` 或 `-o ./meal.png`。
184
+ - 临时产物:显式传 `--temp`,写入 `os.tmpdir()/codex-task/<task-id>`,24 小时后可被清理。
185
+ - `--temp` 与 `--output` 互斥;已有目标默认拒绝覆盖,只有 `--overwrite` 才允许替换。
186
+
187
+ ```bash
188
+ codex-task image "生成三个便当配色方案" -n 3 -o ./artifacts
189
+ codex-task image "仅供本轮分析的草图" --temp
190
+ codex-task gc
177
191
  ```
178
192
 
179
- The event stream reports item and task progress; it is not guaranteed token streaming.
193
+ 图片参数:`size=auto|WIDTHxHEIGHT`(最长边 3840)、`quality=auto|low|medium|high`、`background=auto|opaque|transparent`、`count=1–10`、`concurrency=1–3`。
180
194
 
181
- ## Image controls
195
+ ## 安装给其他 Agent
182
196
 
183
- ```text
184
- references 0–5 local PNG/JPEG/WebP/GIF files
185
- size auto or WIDTHxHEIGHT; longest edge 3840
186
- quality auto | low | medium | high
187
- background auto | opaque | transparent
188
- count 1–10
189
- concurrency 1–3, default 1
197
+ 仓库内置 [`skills/codex-task/SKILL.md`](./skills/codex-task/SKILL.md)。它教调用方 Agent 何时运行 `text`、`image`、`task` 或 `resume`;它不是注入底层 Codex worker 的 skill。
198
+
199
+ Skill CLI 是两件事:SkillTruck 负责安装 Skill,npm 负责安装可执行命令。安装 Skill 不会自动全局安装 npm 包。
200
+
201
+ ```bash
202
+ npm install -g skilltruck codex-task
203
+ skilltruck install https://github.com/wangyendt/codex-task --global
190
204
  ```
191
205
 
192
- Each reference may be at most 20 MiB, with a 50 MiB combined limit. Existing outputs are rejected unless `--overwrite` is supplied. Completed images are atomically saved immediately, so a later batch failure does not discard earlier artifacts.
206
+ 如果不想全局安装 CLI,Agent 可回退到 `npx --yes codex-task@latest`。也可以运行 `codex-task skill path` 查看 npm 包内 Skill 的位置。
207
+
208
+ ## 手机远程调用与开机自启
193
209
 
194
- ## Inputs and output
210
+ `codex-task serve` 把四类任务开放为带 Bearer Token 的异步 HTTP API。手机提交后先拿到 `jobId`,再轮询状态;这样不会因为一次图片或工作区任务耗时几分钟而一直占住移动端请求。
211
+
212
+ | 目标 | 接口 |
213
+ | --- | --- |
214
+ | 文本结果 | `POST /v1/text` |
215
+ | 图片结果 | `POST /v1/image` |
216
+ | 工作区变更 | `POST /v1/task` |
217
+ | 回答追问 | `POST /v1/tasks/:taskId/resume` |
218
+ | 查询进度 | `GET /v1/jobs/:jobId` |
219
+ | 下载产物 | `GET /v1/jobs/:jobId/artifacts/:index` |
195
220
 
196
- Long prompts can come from a file or stdin:
221
+ 持久服务选择 `npm install -g codex-task@latest`,不使用 `npx`:开机启动不应依赖 npm 网络,启动程序路径也应稳定。三平台脚本会安装或升级全局包、生成随机 token、创建用户级自启动项并立即启动服务。
197
222
 
198
223
  ```bash
199
- codex-task text --prompt-file task.md --backend direct
200
- printf '%s' "$PROMPT" | codex-task task --backend sdk --cwd .
224
+ # Ubuntu:systemd user service
225
+ bash ./scripts/service/install-ubuntu.sh
226
+
227
+ # macOS:LaunchAgent
228
+ bash ./scripts/service/install-macos.sh
229
+
230
+ # Windows PowerShell:Scheduled Task
231
+ powershell -ExecutionPolicy Bypass -File .\scripts\service\Install-Windows.ps1
201
232
  ```
202
233
 
203
- The positional prompt, `--prompt-file`, and stdin are mutually exclusive.
234
+ 默认监听 `0.0.0.0:7777` 以便手机访问,安装完成会打印 token。手机地址应填写电脑的局域网/VPN 地址,例如 `http://192.168.1.50:7777`,不能填写 `0.0.0.0`。
204
235
 
205
- Default stdout is one JSON result. `--stream` switches stdout to JSONL events. Diagnostics go to stderr. Exit codes are:
236
+ ```bash
237
+ curl -sS http://127.0.0.1:7777/healthz
238
+ curl -sS -X POST http://127.0.0.1:7777/v1/text -H "Authorization: Bearer $CODEX_TASK_TOKEN" -H 'Content-Type: application/json' -d '{"prompt":"把这段需求整理成三条要点"}'
239
+ curl -sS http://127.0.0.1:7777/v1/jobs/替换为jobId -H "Authorization: Bearer $CODEX_TASK_TOKEN"
240
+ ```
206
241
 
207
- | Code | Meaning |
208
- | --- | --- |
209
- | `0` | `completed` or `needs_input` |
210
- | `1` | execution failure |
211
- | `2` | invalid arguments or configuration |
212
- | `130` | cancellation or timeout |
242
+ > [!CAUTION]
243
+ > 服务不内置 TLS,不能直接暴露到公网。建议只在可信局域网、Tailscale/WireGuard HTTPS 反向代理后使用。Token 持有者实际上拥有该电脑上 CodexTask 的执行权;远程 `task` 默认仍是 `danger-full-access`、可联网、`approval: never`。服务重启会丢失内存中的远程 job 查询记录,终态 job 和下载链接默认保留 24 小时;已返回的 SDK `taskId` 仍可按 CodexTask 自身状态恢复。
213
244
 
214
- ## Models and configuration
245
+ Android Kotlin iOS Swift 的完整示例在 [`examples/mobile`](./examples/mobile/README.md):流程会先调用 `image` 生成营养餐,下载图片后调用 `text` 做图生文,再调用 `task` 修改服务器上的项目,必要时通过 `resume` 回答追问。更完整的部署、升级、卸载、JSON 字段和安全说明见[远程服务部署与移动端调用](./docs/knowhow/20260811_远程服务部署与移动端调用.md)。
215
246
 
216
- The SDK backend leaves model and reasoning unset unless you override them, allowing normal Codex configuration discovery.
247
+ ## TypeScript API
217
248
 
218
- Direct resolves its model in this order:
249
+ ```ts
250
+ import { generateImage, generateText, runTask } from "codex-task";
219
251
 
220
- 1. `--model` / API option;
221
- 2. Codex `config.toml`;
222
- 3. the preferred visible model in `models_cache.json`;
223
- 4. compatibility fallback.
252
+ const meal = await generateImage({
253
+ prompt: "生成一份高蛋白健身营养餐",
254
+ output: ".",
255
+ });
224
256
 
225
- It supports classic Responses and Responses Lite encoders. With a current Codex model catalog, text defaults to `gpt-5.6-sol` with `medium` reasoning. The private Responses Lite route rejects hosted `image_generation`, so Direct image requests are preflighted to the compatible classic `gpt-5.5` model before any request is sent. The final JSON always reports `effectiveModel` and `reasoningEffort`.
257
+ const analysis = await generateText({
258
+ prompt: "识别食物并估算热量,只返回 JSON",
259
+ promptFiles: ["./nutrition-rules.md", "./allergies.md"],
260
+ imagePaths: [meal.artifacts[0]!.path],
261
+ });
226
262
 
227
- Configuration precedence is API/CLI → `CODEX_TASK_*` environment variables → user config → Codex config → fallback. The user config is `config.json` under the standard platform config directory; run `codex-task doctor` to see the exact path.
263
+ const work = await runTask({
264
+ prompt: "根据要求实现营养餐详情页并测试",
265
+ promptFiles: ["./requirements.md", "./api-contract.md"],
266
+ imagePaths: [meal.artifacts[0]!.path],
267
+ workingDirectory: "./meal-app",
268
+ });
269
+ ```
228
270
 
229
- For migration, `CODEXERRAND_*` variables and the former CodexErrand config/task paths are recognized only when their `CODEX_TASK_*` or CodexTask equivalents are absent. New state is always written under CodexTask paths.
271
+ `streamTaskEvents()` 可输出 JSONL 级别的 item/task 进度,但不保证逐 token 流式输出。
230
272
 
231
- Useful variables include:
273
+ ## 输出、状态与退出码
232
274
 
233
- ```text
234
- CODEX_TASK_MODEL
235
- CODEX_TASK_REASONING
236
- CODEX_TASK_PROXY
237
- CODEX_TASK_CODEX_HOME
238
- CODEX_TASK_TEXT_TIMEOUT_MS
239
- CODEX_TASK_IMAGE_TIMEOUT_MS
240
- CODEX_TASK_SDK_TIMEOUT_MS
241
- CODEX_TASK_RETRIES
242
- ```
275
+ stdout 默认只有一个 JSON 结果;`--stream` 时为 JSONL。诊断写 stderr。
276
+
277
+ | 状态/退出码 | 含义 |
278
+ | --- | --- |
279
+ | `completed` / `0` | 完成 |
280
+ | `needs_input` / `0` | 等待调用方补充输入,可 `resume` |
281
+ | `failed` / `1` | 执行失败 |
282
+ | 参数错误 / `2` | 输入或配置无效 |
283
+ | `cancelled` / `130` | 取消或超时 |
284
+
285
+ `--no-followup` 会要求 SDK worker 采用合理假设并在当前 caller turn 内完成或失败,但不能保证模型一定成功。
286
+
287
+ ## 模型与配置
243
288
 
244
- ## Temporary data
289
+ SDK 默认不覆写 model/reasoning,继续读取正常的 Codex 用户与项目配置。
245
290
 
246
- - Images without `--output` live under the platform temporary directory and expire after 24 hours.
247
- - Pending `needs_input` metadata lives under the platform state directory and expires after 7 days.
248
- - Managed temporary artifacts are capped at 1 GiB.
249
- - Explicit output paths are user data and are never removed by `codex-task gc`.
250
- - Official SDK sessions remain managed by Codex under `$CODEX_HOME`; CodexTask does not delete them.
291
+ Direct 按显式参数 → Codex `config.toml` → `models_cache.json` 首选模型 → 兼容 fallback 的顺序选择模型。当前文本可使用 `gpt-5.6-sol + medium/high`;私有 Responses Lite 路由不暴露托管 `image_generation`,所以 Direct 图片会在请求前选择兼容的 classic `gpt-5.5`。这不代表 `gpt-5.6-sol` 没有视觉能力,只是这条非官方 Direct 生图协议不兼容。最终 JSON 始终返回真实的 `effectiveModel` 和 `reasoningEffort`。
251
292
 
252
- ## Development and releases
293
+ 运行 `codex-task doctor` 可查看本机 Direct transport、OAuth、模型解析、Codex CLI/SDK 与真实数据路径,不会发送模型请求。
294
+
295
+ ## 开发与发布
253
296
 
254
297
  ```bash
255
298
  npm install
256
299
  npm run verify
257
300
  ```
258
301
 
259
- `npm run verify` runs lint, type checking, unit tests, build, package inspection, and a clean install/import smoke test. Live Direct endpoint tests are opt-in and never run in CI:
302
+ `verify` 会执行 lint、workflow 检查、类型检查、单元测试、构建、npm 包内容检查和干净安装/import smoke test。真实 Direct endpoint 测试只允许手动执行:
260
303
 
261
304
  ```bash
262
305
  RUN_DIRECT_E2E=1 npm run test:e2e
263
306
  ```
264
307
 
265
- Every push to `main` triggers an automatic patch bump. A second workflow verifies the package, publishes through npm Trusted Publishing, and creates a `vX.Y.Z` tag. Repository setup is documented in [Release setup](./docs/RELEASING.md).
266
-
267
- ## Acknowledgements
308
+ 每次 push `main` 都会自动发布 patch 版本,详见[发布配置](./docs/RELEASING.md)
268
309
 
269
- The Direct backend is derived in part from the MIT-licensed [`lawrencewzen/imgen`](https://github.com/lawrencewzen/imgen). See [third-party notices](./THIRD_PARTY_NOTICES.md).
310
+ ## 致谢与许可
270
311
 
271
- ## License
312
+ Direct 后端部分技术与 MIT 代码源自 [`lawrencewzen/imgen`](https://github.com/lawrencewzen/imgen),详见[第三方声明](./THIRD_PARTY_NOTICES.md)。
272
313
 
273
314
  MIT © 2026 ye.wang