codex-task 0.2.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/.codex-plugin/plugin.json +36 -0
- package/LICENSE +21 -0
- package/README.md +273 -0
- package/README.zh-CN.md +209 -0
- package/THIRD_PARTY_NOTICES.md +37 -0
- package/dist/api.d.ts +8 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +355 -0
- package/dist/api.js.map +1 -0
- package/dist/backends/direct/auth.d.ts +14 -0
- package/dist/backends/direct/auth.d.ts.map +1 -0
- package/dist/backends/direct/auth.js +152 -0
- package/dist/backends/direct/auth.js.map +1 -0
- package/dist/backends/direct/http.d.ts +12 -0
- package/dist/backends/direct/http.d.ts.map +1 -0
- package/dist/backends/direct/http.js +62 -0
- package/dist/backends/direct/http.js.map +1 -0
- package/dist/backends/direct/identity.d.ts +11 -0
- package/dist/backends/direct/identity.d.ts.map +1 -0
- package/dist/backends/direct/identity.js +89 -0
- package/dist/backends/direct/identity.js.map +1 -0
- package/dist/backends/direct/index.d.ts +15 -0
- package/dist/backends/direct/index.d.ts.map +1 -0
- package/dist/backends/direct/index.js +201 -0
- package/dist/backends/direct/index.js.map +1 -0
- package/dist/backends/direct/models.d.ts +14 -0
- package/dist/backends/direct/models.d.ts.map +1 -0
- package/dist/backends/direct/models.js +83 -0
- package/dist/backends/direct/models.js.map +1 -0
- package/dist/backends/direct/protocol.d.ts +24 -0
- package/dist/backends/direct/protocol.d.ts.map +1 -0
- package/dist/backends/direct/protocol.js +131 -0
- package/dist/backends/direct/protocol.js.map +1 -0
- package/dist/backends/direct/sse.d.ts +15 -0
- package/dist/backends/direct/sse.d.ts.map +1 -0
- package/dist/backends/direct/sse.js +93 -0
- package/dist/backends/direct/sse.js.map +1 -0
- package/dist/backends/sdk.d.ts +54 -0
- package/dist/backends/sdk.d.ts.map +1 -0
- package/dist/backends/sdk.js +173 -0
- package/dist/backends/sdk.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +224 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +77 -0
- package/dist/config.js.map +1 -0
- package/dist/doctor.d.ts +3 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +94 -0
- package/dist/doctor.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +30 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +10 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +30 -0
- package/dist/events.js.map +1 -0
- package/dist/fs-utils.d.ts +7 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +56 -0
- package/dist/fs-utils.js.map +1 -0
- package/dist/images.d.ts +18 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +102 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +14 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +61 -0
- package/dist/paths.js.map +1 -0
- package/dist/skill.d.ts +2 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +6 -0
- package/dist/skill.js.map +1 -0
- package/dist/state.d.ts +20 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +134 -0
- package/dist/state.js.map +1 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +89 -0
- package/skills/codex-task/SKILL.md +79 -0
- package/skills/codex-task/agents/openai.yaml +4 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-task",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Delegate focused text, image, and workspace tasks to CodexTask",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "wang121ye",
|
|
7
|
+
"url": "https://github.com/wangyendt"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/wangyendt/codex-task",
|
|
10
|
+
"repository": "https://github.com/wangyendt/codex-task",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"agent",
|
|
14
|
+
"codex",
|
|
15
|
+
"images",
|
|
16
|
+
"tasks"
|
|
17
|
+
],
|
|
18
|
+
"skills": "./skills/",
|
|
19
|
+
"interface": {
|
|
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.",
|
|
23
|
+
"developerName": "wang121ye",
|
|
24
|
+
"category": "Developer Tools",
|
|
25
|
+
"capabilities": [
|
|
26
|
+
"Interactive",
|
|
27
|
+
"Write"
|
|
28
|
+
],
|
|
29
|
+
"websiteURL": "https://github.com/wangyendt/codex-task",
|
|
30
|
+
"defaultPrompt": [
|
|
31
|
+
"Delegate this focused task with CodexTask.",
|
|
32
|
+
"Generate this image through CodexTask.",
|
|
33
|
+
"Send this workspace task to a Codex worker."
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ye.wang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# CodexTask
|
|
2
|
+
|
|
3
|
+
> Give another AI agent a focused errand—and get back text, images, or finished work. Powered by your existing Codex setup.
|
|
4
|
+
|
|
5
|
+
[中文文档](./README.zh-CN.md) · [PRD](./docs/PRD.md) · [Companion skill](./skills/codex-task/SKILL.md)
|
|
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:
|
|
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.
|
|
12
|
+
|
|
13
|
+
No daemon. No hosted service. No extra API key. Results are stable JSON that another agent can consume.
|
|
14
|
+
|
|
15
|
+
> [!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.
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
Requirements: Node.js 20+ and an existing Codex login (`codex login`).
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g codex-task
|
|
24
|
+
codex-task doctor
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Delegate a text result:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
codex-task text "Turn these notes into a crisp release announcement" \
|
|
31
|
+
--backend direct
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Generate an image that will not be removed by temporary-file cleanup:
|
|
35
|
+
|
|
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
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Edit an image:
|
|
45
|
+
|
|
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
|
+
```
|
|
52
|
+
|
|
53
|
+
Delegate repository work:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
codex-task task "Implement the requested feature and run focused tests" \
|
|
57
|
+
--backend sdk \
|
|
58
|
+
--cwd /absolute/path/to/repo
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Every command writes a machine-readable result:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
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": []
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Pick the backend
|
|
76
|
+
|
|
77
|
+
CodexTask never guesses. Direct is the CLI default, but workspace tasks require an explicit SDK backend.
|
|
78
|
+
|
|
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 |
|
|
88
|
+
|
|
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
|
+
The SDK backend defaults to:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
sandbox: danger-full-access
|
|
95
|
+
approval: never
|
|
96
|
+
network: true
|
|
97
|
+
```
|
|
98
|
+
|
|
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.
|
|
100
|
+
|
|
101
|
+
## Agent follow-ups
|
|
102
|
+
|
|
103
|
+
SDK tasks are single-turn first. If the worker needs clarification, the result is not an error:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"status": "needs_input",
|
|
108
|
+
"taskId": "...",
|
|
109
|
+
"threadId": "...",
|
|
110
|
+
"questions": ["Should the API preserve the legacy response shape?"],
|
|
111
|
+
"artifacts": []
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Ask the user, then resume the same Codex thread:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
printf '%s' "Yes, preserve it." | codex-task resume <task-id>
|
|
119
|
+
```
|
|
120
|
+
|
|
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
|
|
124
|
+
|
|
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.
|
|
126
|
+
|
|
127
|
+
Install it with [skillmanager](https://github.com/wangyendt/skillmanager):
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npm install -g @wang121ye/skillmanager
|
|
131
|
+
skillmanager install https://github.com/wangyendt/codex-task --global
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Or locate the copy included in the npm package:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
codex-task skill path
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The repository also includes `.codex-plugin/plugin.json` for plugin-compatible distribution.
|
|
141
|
+
|
|
142
|
+
## TypeScript API
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { generateImage, generateText, runTask } from "codex-task";
|
|
146
|
+
|
|
147
|
+
const copy = await generateText({
|
|
148
|
+
prompt: "Write a launch headline and three supporting bullets.",
|
|
149
|
+
backend: "direct",
|
|
150
|
+
});
|
|
151
|
+
|
|
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
|
+
});
|
|
158
|
+
|
|
159
|
+
const work = await runTask({
|
|
160
|
+
prompt: "Add the feature and run focused tests.",
|
|
161
|
+
backend: "sdk",
|
|
162
|
+
workingDirectory: "/absolute/path/to/repo",
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
For progress events:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import { streamTaskEvents } from "codex-task";
|
|
170
|
+
|
|
171
|
+
for await (const event of streamTaskEvents({
|
|
172
|
+
kind: "text",
|
|
173
|
+
options: { prompt: "Summarize this decision", backend: "direct" },
|
|
174
|
+
})) {
|
|
175
|
+
console.log(event);
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The event stream reports item and task progress; it is not guaranteed token streaming.
|
|
180
|
+
|
|
181
|
+
## Image controls
|
|
182
|
+
|
|
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
|
|
190
|
+
```
|
|
191
|
+
|
|
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.
|
|
193
|
+
|
|
194
|
+
## Inputs and output
|
|
195
|
+
|
|
196
|
+
Long prompts can come from a file or stdin:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
codex-task text --prompt-file task.md --backend direct
|
|
200
|
+
printf '%s' "$PROMPT" | codex-task task --backend sdk --cwd .
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The positional prompt, `--prompt-file`, and stdin are mutually exclusive.
|
|
204
|
+
|
|
205
|
+
Default stdout is one JSON result. `--stream` switches stdout to JSONL events. Diagnostics go to stderr. Exit codes are:
|
|
206
|
+
|
|
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 |
|
|
213
|
+
|
|
214
|
+
## Models and configuration
|
|
215
|
+
|
|
216
|
+
The SDK backend leaves model and reasoning unset unless you override them, allowing normal Codex configuration discovery.
|
|
217
|
+
|
|
218
|
+
Direct resolves its model in this order:
|
|
219
|
+
|
|
220
|
+
1. `--model` / API option;
|
|
221
|
+
2. Codex `config.toml`;
|
|
222
|
+
3. the preferred visible model in `models_cache.json`;
|
|
223
|
+
4. compatibility fallback.
|
|
224
|
+
|
|
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`.
|
|
226
|
+
|
|
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.
|
|
228
|
+
|
|
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.
|
|
230
|
+
|
|
231
|
+
Useful variables include:
|
|
232
|
+
|
|
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
|
+
```
|
|
243
|
+
|
|
244
|
+
## Temporary data
|
|
245
|
+
|
|
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.
|
|
251
|
+
|
|
252
|
+
## Development and releases
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install
|
|
256
|
+
npm run verify
|
|
257
|
+
```
|
|
258
|
+
|
|
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:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
RUN_DIRECT_E2E=1 npm run test:e2e
|
|
263
|
+
```
|
|
264
|
+
|
|
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
|
|
268
|
+
|
|
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).
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT © 2026 ye.wang
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# CodexTask
|
|
2
|
+
|
|
3
|
+
> 把一个明确的小任务交给另一个 AI Agent,拿回文本、图片或已经完成的工作。直接复用你现有的 Codex 环境。
|
|
4
|
+
|
|
5
|
+
[English](./README.md) · [产品需求文档](./docs/PRD.md) · [Companion skill](./skills/codex-task/SKILL.md)
|
|
6
|
+
|
|
7
|
+
CodexTask 把 Codex 封装成可供其他 Agent 调用的轻量 worker,统一提供三类能力:
|
|
8
|
+
|
|
9
|
+
- 文生文;
|
|
10
|
+
- 文生图和图生图;
|
|
11
|
+
- 通过官方 Codex SDK 执行边界明确的工作区任务。
|
|
12
|
+
|
|
13
|
+
没有 daemon,没有托管服务,也不需要额外 API key。所有结果都使用适合 Agent 解析的稳定 JSON。
|
|
14
|
+
|
|
15
|
+
> [!IMPORTANT]
|
|
16
|
+
> CodexTask 是独立的非官方开源项目,与 OpenAI 不存在隶属、认可或赞助关系。Codex 与 OpenAI 为 OpenAI 的商标。
|
|
17
|
+
|
|
18
|
+
## 30 秒上手
|
|
19
|
+
|
|
20
|
+
需要 Node.js 20+,并已执行过 `codex login`。
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g codex-task
|
|
24
|
+
codex-task doctor
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
生成文本:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
codex-task text "把这些笔记整理成简洁的发布公告" --backend direct
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
生成持久图片:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
codex-task image "精确、克制的机器人关节爆炸图" \
|
|
37
|
+
--backend direct \
|
|
38
|
+
--size 1536x1024 \
|
|
39
|
+
--quality high \
|
|
40
|
+
--output ./artifacts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
基于参考图编辑:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
codex-task image "保留主体,把背景换成整洁的工作室" \
|
|
47
|
+
--backend direct \
|
|
48
|
+
--image ./reference.png \
|
|
49
|
+
--output ./artifacts
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
委派仓库任务:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
codex-task task "实现这个功能并运行聚焦测试" \
|
|
56
|
+
--backend sdk \
|
|
57
|
+
--cwd /absolute/path/to/repo
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 两种后端
|
|
61
|
+
|
|
62
|
+
CodexTask 不猜测后端。CLI 默认是 Direct,但工作区任务必须显式写出 SDK。
|
|
63
|
+
|
|
64
|
+
| 能力 | `direct` | `sdk` |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| 独立文本结果 | 支持 | 支持 |
|
|
67
|
+
| 文生图 / 图生图 | 原生提取图片 | 通过已安装的 `$imagegen` skill |
|
|
68
|
+
| shell 和文件修改 | 不支持 | 支持 |
|
|
69
|
+
| 项目 rules 和本地工具 | 不支持 | 支持 |
|
|
70
|
+
| 本地 Codex skills | 不支持 | 按 Codex 正常发现 |
|
|
71
|
+
| 底层 | 非官方 ChatGPT Codex Responses | 官方 `@openai/codex-sdk` |
|
|
72
|
+
|
|
73
|
+
Direct 会复用 `$CODEX_HOME/auth.json`、Codex installation metadata、TLS impersonation 和 ChatGPT 私有 Codex Responses 接口。输入仍会发往 ChatGPT,接口也可能随时变化。
|
|
74
|
+
|
|
75
|
+
SDK task 默认权限为:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
sandbox: danger-full-access
|
|
79
|
+
approval: never
|
|
80
|
+
network: true
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
这意味着它可以访问工作区外路径、执行命令并联网,而且不会询问权限。只把可信 prompt 和可信仓库交给它。
|
|
84
|
+
|
|
85
|
+
## 追问与恢复
|
|
86
|
+
|
|
87
|
+
SDK 默认先执行一个 turn。确实需要澄清时返回:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"status": "needs_input",
|
|
92
|
+
"taskId": "...",
|
|
93
|
+
"threadId": "...",
|
|
94
|
+
"questions": ["是否必须保持旧响应格式?"],
|
|
95
|
+
"artifacts": []
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
向用户确认后恢复同一个 Codex thread:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
printf '%s' "是,必须保持。" | codex-task resume <task-id>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`--no-followup` 会要求 Codex 使用合理假设,只能完成或失败;它不保证模型一定成功。
|
|
106
|
+
|
|
107
|
+
## 安装给其他 Agent
|
|
108
|
+
|
|
109
|
+
仓库内置 `skills/codex-task/SKILL.md`。它教调用方 Agent 选择 `text`、`image`、`task` 或 `resume`,并不是注入底层 Codex worker 的 skill。
|
|
110
|
+
|
|
111
|
+
使用 [skillmanager](https://github.com/wangyendt/skillmanager) 安装:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm install -g @wang121ye/skillmanager
|
|
115
|
+
skillmanager install https://github.com/wangyendt/codex-task --global
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
也可以查看 npm 包内 skill 的位置:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
codex-task skill path
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## TypeScript API
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { generateImage, generateText, runTask } from "codex-task";
|
|
128
|
+
|
|
129
|
+
const text = await generateText({
|
|
130
|
+
prompt: "写一个标题和三个卖点。",
|
|
131
|
+
backend: "direct",
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const image = await generateImage({
|
|
135
|
+
prompt: "Agent 之间传递任务的克制等距插画。",
|
|
136
|
+
backend: "direct",
|
|
137
|
+
output: "./artifacts",
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const work = await runTask({
|
|
141
|
+
prompt: "实现功能并运行聚焦测试。",
|
|
142
|
+
backend: "sdk",
|
|
143
|
+
workingDirectory: "/absolute/path/to/repo",
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 图片参数
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
参考图 0–5 张本地 PNG/JPEG/WebP/GIF
|
|
151
|
+
size auto 或 WIDTHxHEIGHT,最长边 ≤3840
|
|
152
|
+
quality auto | low | medium | high
|
|
153
|
+
background auto | opaque | transparent
|
|
154
|
+
count 1–10
|
|
155
|
+
concurrency 1–3,默认 1
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
单张参考图不超过 20 MiB,总和不超过 50 MiB。默认拒绝覆盖已有文件,只有显式传 `--overwrite` 才会替换。每张图片完成后立即原子落盘,后续图片失败不会丢失已经生成的产物。
|
|
159
|
+
|
|
160
|
+
## Agent 友好的输出
|
|
161
|
+
|
|
162
|
+
- 默认 stdout 是一个最终 JSON。
|
|
163
|
+
- `--stream` 将 stdout 改为 JSONL 进度事件,不保证逐 token 输出。
|
|
164
|
+
- 诊断信息写 stderr。
|
|
165
|
+
- exit code:完成/追问为 `0`,运行失败为 `1`,参数错误为 `2`,取消或超时为 `130`。
|
|
166
|
+
|
|
167
|
+
长 prompt 推荐使用文件或 stdin:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
codex-task text --prompt-file task.md --backend direct
|
|
171
|
+
printf '%s' "$PROMPT" | codex-task task --backend sdk --cwd .
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 模型和配置
|
|
175
|
+
|
|
176
|
+
SDK 默认不覆写模型和 reasoning,继续按 Codex 正常配置读取。
|
|
177
|
+
|
|
178
|
+
Direct 按以下顺序选择模型:显式参数 → Codex `config.toml` → `models_cache.json` 首选模型 → 兼容 fallback。它同时实现 classic Responses 和 Responses Lite encoder;当前模型目录下文本默认是 `gpt-5.6-sol + medium`。私有 Responses Lite 路由会拒绝托管 `image_generation`,因此 Direct 图片会在发出请求前选择兼容的 classic `gpt-5.5`。最终 JSON 会返回真实的 `effectiveModel` 和 `reasoningEffort`。
|
|
179
|
+
|
|
180
|
+
配置优先级为 API/CLI → `CODEX_TASK_*` 环境变量 → 用户配置 → Codex 配置 → fallback。运行 `codex-task doctor` 可以查看真实路径和解析结果。迁移期间,仅当新的变量或路径不存在时才兼容读取旧的 `CODEXERRAND_*` 环境变量以及 CodexErrand 配置/待恢复任务;新状态始终写入 CodexTask 路径。
|
|
181
|
+
|
|
182
|
+
## 临时文件
|
|
183
|
+
|
|
184
|
+
- 不传 `--output` 的图片放系统临时目录,默认 24 小时过期。
|
|
185
|
+
- `needs_input` 的小型状态放平台 state 目录,默认保存 7 天。
|
|
186
|
+
- 临时产物总上限 1 GiB。
|
|
187
|
+
- 显式 `--output` 下的文件属于用户数据,`codex-task gc` 永远不会删除。
|
|
188
|
+
- 官方 SDK 的 session 仍由 Codex 自己保存在 `$CODEX_HOME`,CodexTask 不删除。
|
|
189
|
+
|
|
190
|
+
## 开发和发布
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npm install
|
|
194
|
+
npm run verify
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`verify` 会执行 lint、类型检查、单元测试、构建、npm 包内容检查和干净安装/import smoke test。真实 Direct endpoint 测试必须显式开启,CI 永远不会运行:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
RUN_DIRECT_E2E=1 npm run test:e2e
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
每次 push 到 `main` 自动发布 patch 版本。详细设置见 [发布说明](./docs/RELEASING.md)。
|
|
204
|
+
|
|
205
|
+
## 致谢与许可
|
|
206
|
+
|
|
207
|
+
Direct 后端部分技术和 MIT 代码源自 [`lawrencewzen/imgen`](https://github.com/lawrencewzen/imgen),详见 [第三方声明](./THIRD_PARTY_NOTICES.md)。
|
|
208
|
+
|
|
209
|
+
MIT © 2026 ye.wang
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## imgen
|
|
4
|
+
|
|
5
|
+
CodexTask's Direct backend is derived in part from ideas and MIT-licensed code in [`lawrencewzen/imgen`](https://github.com/lawrencewzen/imgen), including Codex OAuth handling, installation identity, TLS impersonation, Codex-like request metadata, image input encoding, and image SSE extraction.
|
|
6
|
+
|
|
7
|
+
The upstream license at the reviewed revision states:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 aisparkedu
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
CodexTask substantially restructures the implementation, adds text and SDK backends, structured task results, Responses Lite encoding, state management, validation, tests, and distribution assets.
|
|
34
|
+
|
|
35
|
+
## OpenAI Codex SDK
|
|
36
|
+
|
|
37
|
+
CodexTask depends on `@openai/codex-sdk` for its SDK backend. Codex and OpenAI are trademarks of OpenAI. Use of the dependency does not imply affiliation, endorsement, or sponsorship.
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ImageOptions, ResumeTaskOptions, TaskEvent, TaskRequest, TaskResult, TextOptions, WorkspaceTaskOptions } from "./types.js";
|
|
2
|
+
export declare function generateText(options: TextOptions): Promise<TaskResult>;
|
|
3
|
+
export declare function generateImage(options: ImageOptions): Promise<TaskResult>;
|
|
4
|
+
export declare function runTask(options: WorkspaceTaskOptions): Promise<TaskResult>;
|
|
5
|
+
export declare function resumeTask(options: ResumeTaskOptions): Promise<TaskResult>;
|
|
6
|
+
export declare function streamTaskEvents(request: TaskRequest): AsyncGenerator<TaskEvent>;
|
|
7
|
+
export declare function dispatch(request: TaskRequest): Promise<TaskResult>;
|
|
8
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAMV,YAAY,EAEZ,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,UAAU,EACV,WAAW,EACX,oBAAoB,EACrB,MAAM,YAAY,CAAC;AA0EpB,wBAAsB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA0C5E;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAwB9E;AAwDD,wBAAsB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CA0BhF;AA4CD,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAqChF;AAsBD,wBAAuB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC,SAAS,CAAC,CAavF;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAWlE"}
|