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.
Files changed (92) hide show
  1. package/.codex-plugin/plugin.json +36 -0
  2. package/LICENSE +21 -0
  3. package/README.md +273 -0
  4. package/README.zh-CN.md +209 -0
  5. package/THIRD_PARTY_NOTICES.md +37 -0
  6. package/dist/api.d.ts +8 -0
  7. package/dist/api.d.ts.map +1 -0
  8. package/dist/api.js +355 -0
  9. package/dist/api.js.map +1 -0
  10. package/dist/backends/direct/auth.d.ts +14 -0
  11. package/dist/backends/direct/auth.d.ts.map +1 -0
  12. package/dist/backends/direct/auth.js +152 -0
  13. package/dist/backends/direct/auth.js.map +1 -0
  14. package/dist/backends/direct/http.d.ts +12 -0
  15. package/dist/backends/direct/http.d.ts.map +1 -0
  16. package/dist/backends/direct/http.js +62 -0
  17. package/dist/backends/direct/http.js.map +1 -0
  18. package/dist/backends/direct/identity.d.ts +11 -0
  19. package/dist/backends/direct/identity.d.ts.map +1 -0
  20. package/dist/backends/direct/identity.js +89 -0
  21. package/dist/backends/direct/identity.js.map +1 -0
  22. package/dist/backends/direct/index.d.ts +15 -0
  23. package/dist/backends/direct/index.d.ts.map +1 -0
  24. package/dist/backends/direct/index.js +201 -0
  25. package/dist/backends/direct/index.js.map +1 -0
  26. package/dist/backends/direct/models.d.ts +14 -0
  27. package/dist/backends/direct/models.d.ts.map +1 -0
  28. package/dist/backends/direct/models.js +83 -0
  29. package/dist/backends/direct/models.js.map +1 -0
  30. package/dist/backends/direct/protocol.d.ts +24 -0
  31. package/dist/backends/direct/protocol.d.ts.map +1 -0
  32. package/dist/backends/direct/protocol.js +131 -0
  33. package/dist/backends/direct/protocol.js.map +1 -0
  34. package/dist/backends/direct/sse.d.ts +15 -0
  35. package/dist/backends/direct/sse.d.ts.map +1 -0
  36. package/dist/backends/direct/sse.js +93 -0
  37. package/dist/backends/direct/sse.js.map +1 -0
  38. package/dist/backends/sdk.d.ts +54 -0
  39. package/dist/backends/sdk.d.ts.map +1 -0
  40. package/dist/backends/sdk.js +173 -0
  41. package/dist/backends/sdk.js.map +1 -0
  42. package/dist/cli.d.ts +3 -0
  43. package/dist/cli.d.ts.map +1 -0
  44. package/dist/cli.js +224 -0
  45. package/dist/cli.js.map +1 -0
  46. package/dist/config.d.ts +29 -0
  47. package/dist/config.d.ts.map +1 -0
  48. package/dist/config.js +77 -0
  49. package/dist/config.js.map +1 -0
  50. package/dist/doctor.d.ts +3 -0
  51. package/dist/doctor.d.ts.map +1 -0
  52. package/dist/doctor.js +94 -0
  53. package/dist/doctor.js.map +1 -0
  54. package/dist/errors.d.ts +16 -0
  55. package/dist/errors.d.ts.map +1 -0
  56. package/dist/errors.js +30 -0
  57. package/dist/errors.js.map +1 -0
  58. package/dist/events.d.ts +10 -0
  59. package/dist/events.d.ts.map +1 -0
  60. package/dist/events.js +30 -0
  61. package/dist/events.js.map +1 -0
  62. package/dist/fs-utils.d.ts +7 -0
  63. package/dist/fs-utils.d.ts.map +1 -0
  64. package/dist/fs-utils.js +56 -0
  65. package/dist/fs-utils.js.map +1 -0
  66. package/dist/images.d.ts +18 -0
  67. package/dist/images.d.ts.map +1 -0
  68. package/dist/images.js +102 -0
  69. package/dist/images.js.map +1 -0
  70. package/dist/index.d.ts +7 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +6 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/paths.d.ts +14 -0
  75. package/dist/paths.d.ts.map +1 -0
  76. package/dist/paths.js +61 -0
  77. package/dist/paths.js.map +1 -0
  78. package/dist/skill.d.ts +2 -0
  79. package/dist/skill.d.ts.map +1 -0
  80. package/dist/skill.js +6 -0
  81. package/dist/skill.js.map +1 -0
  82. package/dist/state.d.ts +20 -0
  83. package/dist/state.d.ts.map +1 -0
  84. package/dist/state.js +134 -0
  85. package/dist/state.js.map +1 -0
  86. package/dist/types.d.ts +167 -0
  87. package/dist/types.d.ts.map +1 -0
  88. package/dist/types.js +2 -0
  89. package/dist/types.js.map +1 -0
  90. package/package.json +89 -0
  91. package/skills/codex-task/SKILL.md +79 -0
  92. package/skills/codex-task/agents/openai.yaml +4 -0
package/dist/skill.js ADDED
@@ -0,0 +1,6 @@
1
+ import { dirname, resolve } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ export function companionSkillPath() {
4
+ return resolve(dirname(fileURLToPath(import.meta.url)), "..", "skills", "codex-task");
5
+ }
6
+ //# sourceMappingURL=skill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill.js","sourceRoot":"","sources":["../src/skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,kBAAkB;IAChC,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AACxF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { GcReport, ReasoningEffort, SandboxMode } from "./types.js";
2
+ export interface StoredTask {
3
+ version: 1;
4
+ taskId: string;
5
+ threadId: string;
6
+ workingDirectory: string;
7
+ createdAt: string;
8
+ updatedAt: string;
9
+ expiresAt: string;
10
+ sandboxMode: SandboxMode;
11
+ networkAccess: boolean;
12
+ model?: string | undefined;
13
+ reasoning?: ReasoningEffort | undefined;
14
+ noFollowup: boolean;
15
+ }
16
+ export declare function savePendingTask(task: Omit<StoredTask, "version" | "updatedAt" | "expiresAt">): Promise<void>;
17
+ export declare function loadPendingTask(taskId: string): StoredTask;
18
+ export declare function deletePendingTask(taskId: string): void;
19
+ export declare function runGarbageCollection(now?: number): GcReport;
20
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,OAAO,CAAC;CACrB;AASD,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAWlH;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CA4B1D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAGtD;AAiCD,wBAAgB,oBAAoB,CAAC,GAAG,SAAa,GAAG,QAAQ,CAmD/D"}
package/dist/state.js ADDED
@@ -0,0 +1,134 @@
1
+ import { existsSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
2
+ import { join, resolve, sep } from "node:path";
3
+ import { appPaths, legacyAppPaths } from "./paths.js";
4
+ import { atomicWrite, ensureDir, withFileLock } from "./fs-utils.js";
5
+ import { CodexTaskError } from "./errors.js";
6
+ import { loadConfig } from "./config.js";
7
+ function taskPath(taskId, paths = appPaths()) {
8
+ if (!/^[0-9a-f-]{36}$/i.test(taskId)) {
9
+ throw new CodexTaskError("INVALID_TASK_ID", `Invalid task id: ${taskId}`, { exitCode: 2 });
10
+ }
11
+ return join(paths.tasksDir, `${taskId}.json`);
12
+ }
13
+ export async function savePendingTask(task) {
14
+ const config = loadConfig();
15
+ const now = new Date();
16
+ const record = {
17
+ ...task,
18
+ version: 1,
19
+ updatedAt: now.toISOString(),
20
+ expiresAt: new Date(now.getTime() + config.pendingTaskTtlMs).toISOString(),
21
+ };
22
+ const path = taskPath(task.taskId);
23
+ await withFileLock(`${path}.lock`, async () => atomicWrite(path, JSON.stringify(record, null, 2)));
24
+ }
25
+ export function loadPendingTask(taskId) {
26
+ const currentPath = taskPath(taskId);
27
+ const legacyPath = taskPath(taskId, legacyAppPaths());
28
+ const path = existsSync(currentPath) ? currentPath : legacyPath;
29
+ if (!existsSync(path)) {
30
+ throw new CodexTaskError("TASK_NOT_FOUND", `No resumable task found for ${taskId}`, {
31
+ exitCode: 2,
32
+ });
33
+ }
34
+ let record;
35
+ try {
36
+ record = JSON.parse(readFileSync(path, "utf8"));
37
+ }
38
+ catch (error) {
39
+ throw new CodexTaskError("TASK_STATE_INVALID", `Could not parse task state for ${taskId}`, {
40
+ exitCode: 2,
41
+ cause: error,
42
+ });
43
+ }
44
+ if (record.version !== 1 || record.taskId !== taskId || !record.threadId) {
45
+ throw new CodexTaskError("TASK_STATE_INVALID", `Task state for ${taskId} is invalid`, {
46
+ exitCode: 2,
47
+ });
48
+ }
49
+ if (Date.parse(record.expiresAt) <= Date.now()) {
50
+ deletePendingTask(taskId);
51
+ throw new CodexTaskError("TASK_EXPIRED", `Task ${taskId} has expired`, { exitCode: 2 });
52
+ }
53
+ return record;
54
+ }
55
+ export function deletePendingTask(taskId) {
56
+ rmSync(taskPath(taskId), { force: true });
57
+ rmSync(taskPath(taskId, legacyAppPaths()), { force: true });
58
+ }
59
+ function directorySize(path) {
60
+ let total = 0;
61
+ for (const entry of readdirSync(path, { withFileTypes: true })) {
62
+ const child = join(path, entry.name);
63
+ if (entry.isDirectory())
64
+ total += directorySize(child);
65
+ else if (entry.isFile())
66
+ total += statSync(child).size;
67
+ }
68
+ return total;
69
+ }
70
+ function isInside(path, root) {
71
+ const absolute = resolve(path);
72
+ const absoluteRoot = resolve(root);
73
+ return absolute === absoluteRoot || absolute.startsWith(`${absoluteRoot}${sep}`);
74
+ }
75
+ function removeManagedPath(path, root) {
76
+ if (!isInside(path, root) || resolve(path) === resolve(root)) {
77
+ throw new CodexTaskError("GC_PATH_REJECTED", `Refusing to remove unmanaged path: ${path}`);
78
+ }
79
+ const bytes = existsSync(path) ? directorySize(path) : 0;
80
+ rmSync(path, { recursive: true, force: true });
81
+ return bytes;
82
+ }
83
+ export function runGarbageCollection(now = Date.now()) {
84
+ const config = loadConfig();
85
+ const paths = appPaths();
86
+ const report = { removedPaths: 0, reclaimedBytes: 0, warnings: [] };
87
+ ensureDir(paths.tempDir);
88
+ ensureDir(paths.tasksDir);
89
+ for (const entry of readdirSync(paths.tasksDir, { withFileTypes: true })) {
90
+ if (!entry.isFile() || !entry.name.endsWith(".json"))
91
+ continue;
92
+ const path = join(paths.tasksDir, entry.name);
93
+ try {
94
+ const record = JSON.parse(readFileSync(path, "utf8"));
95
+ if (!record.expiresAt || Date.parse(record.expiresAt) <= now) {
96
+ rmSync(path, { force: true });
97
+ report.removedPaths += 1;
98
+ }
99
+ }
100
+ catch (error) {
101
+ report.warnings.push(`Could not inspect ${path}: ${String(error)}`);
102
+ }
103
+ }
104
+ const tempEntries = [];
105
+ for (const entry of readdirSync(paths.tempDir, { withFileTypes: true })) {
106
+ if (!entry.isDirectory())
107
+ continue;
108
+ const path = join(paths.tempDir, entry.name);
109
+ try {
110
+ const stat = statSync(path);
111
+ tempEntries.push({ path, bytes: directorySize(path), mtimeMs: stat.mtimeMs });
112
+ }
113
+ catch (error) {
114
+ report.warnings.push(`Could not inspect ${path}: ${String(error)}`);
115
+ }
116
+ }
117
+ for (const entry of tempEntries.filter((item) => now - item.mtimeMs > config.tempTtlMs)) {
118
+ report.reclaimedBytes += removeManagedPath(entry.path, paths.tempDir);
119
+ report.removedPaths += 1;
120
+ }
121
+ const remaining = tempEntries
122
+ .filter((entry) => existsSync(entry.path))
123
+ .sort((left, right) => left.mtimeMs - right.mtimeMs);
124
+ let totalBytes = remaining.reduce((total, entry) => total + entry.bytes, 0);
125
+ for (const entry of remaining) {
126
+ if (totalBytes <= config.tempMaxBytes)
127
+ break;
128
+ report.reclaimedBytes += removeManagedPath(entry.path, paths.tempDir);
129
+ report.removedPaths += 1;
130
+ totalBytes -= entry.bytes;
131
+ }
132
+ return report;
133
+ }
134
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkBzC,SAAS,QAAQ,CAAC,MAAc,EAAE,QAAkB,QAAQ,EAAE;IAC5D,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,cAAc,CAAC,iBAAiB,EAAE,oBAAoB,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAA6D;IACjG,MAAM,MAAM,G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,CAAC;QACtE,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;QACzB,UAAU,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,167 @@
1
+ export type Backend = "direct" | "sdk";
2
+ export type ReasoningEffort = "none" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
3
+ export type TaskStatus = "completed" | "needs_input" | "failed" | "cancelled";
4
+ export type SandboxMode = "read-only" | "workspace-write" | "danger-full-access";
5
+ export interface UsageSummary {
6
+ inputTokens?: number | undefined;
7
+ cachedInputTokens?: number | undefined;
8
+ outputTokens?: number | undefined;
9
+ }
10
+ export interface Artifact {
11
+ path: string;
12
+ kind: "image" | "file";
13
+ mimeType?: string | undefined;
14
+ sizeBytes?: number | undefined;
15
+ expiresAt?: string | undefined;
16
+ }
17
+ export interface CommandSummary {
18
+ command: string;
19
+ exitCode?: number | undefined;
20
+ status?: string | undefined;
21
+ }
22
+ export interface ResultBase {
23
+ status: TaskStatus;
24
+ taskId: string;
25
+ backend: Backend;
26
+ threadId?: string | undefined;
27
+ text?: string | undefined;
28
+ effectiveModel?: string | undefined;
29
+ reasoningEffort?: ReasoningEffort | undefined;
30
+ artifacts: Artifact[];
31
+ changes?: string[] | undefined;
32
+ commands?: CommandSummary[] | undefined;
33
+ usage?: UsageSummary | undefined;
34
+ }
35
+ export interface CompletedResult extends ResultBase {
36
+ status: "completed";
37
+ }
38
+ export interface NeedsInputResult extends ResultBase {
39
+ status: "needs_input";
40
+ questions: string[];
41
+ }
42
+ export interface FailedResult extends ResultBase {
43
+ status: "failed";
44
+ error: {
45
+ code: string;
46
+ message: string;
47
+ retryable: boolean;
48
+ details?: unknown;
49
+ };
50
+ }
51
+ export interface CancelledResult extends ResultBase {
52
+ status: "cancelled";
53
+ error: {
54
+ code: "CANCELLED" | "TIMEOUT";
55
+ message: string;
56
+ retryable: boolean;
57
+ };
58
+ }
59
+ export type TaskResult = CompletedResult | NeedsInputResult | FailedResult | CancelledResult;
60
+ export type TaskEvent = {
61
+ type: "started";
62
+ taskId: string;
63
+ backend: Backend;
64
+ kind: TaskRequest["kind"];
65
+ } | {
66
+ type: "progress";
67
+ taskId: string;
68
+ message: string;
69
+ item?: unknown;
70
+ } | {
71
+ type: "retrying";
72
+ taskId: string;
73
+ attempt: number;
74
+ delayMs: number;
75
+ error: string;
76
+ } | {
77
+ type: "artifact";
78
+ taskId: string;
79
+ artifact: Artifact;
80
+ } | {
81
+ type: "needs_input";
82
+ taskId: string;
83
+ result: NeedsInputResult;
84
+ } | {
85
+ type: "completed";
86
+ taskId: string;
87
+ result: CompletedResult;
88
+ } | {
89
+ type: "failed";
90
+ taskId: string;
91
+ result: FailedResult | CancelledResult;
92
+ };
93
+ export interface CommonOptions {
94
+ backend?: Backend | undefined;
95
+ model?: string | undefined;
96
+ reasoning?: ReasoningEffort | undefined;
97
+ instructions?: string | undefined;
98
+ outputSchema?: Record<string, unknown> | undefined;
99
+ timeoutMs?: number | undefined;
100
+ retries?: number | undefined;
101
+ codexHome?: string | undefined;
102
+ signal?: AbortSignal | undefined;
103
+ onEvent?: ((event: TaskEvent) => void) | undefined;
104
+ }
105
+ export interface TextOptions extends CommonOptions {
106
+ prompt: string;
107
+ backend?: Backend | undefined;
108
+ workingDirectory?: string | undefined;
109
+ }
110
+ export interface ImageOptions extends CommonOptions {
111
+ prompt: string;
112
+ backend?: Backend | undefined;
113
+ imagePaths?: string[] | undefined;
114
+ output?: string | undefined;
115
+ count?: number | undefined;
116
+ concurrency?: number | undefined;
117
+ size?: string | undefined;
118
+ quality?: "auto" | "low" | "medium" | "high" | undefined;
119
+ background?: "auto" | "opaque" | "transparent" | undefined;
120
+ overwrite?: boolean | undefined;
121
+ workingDirectory?: string | undefined;
122
+ }
123
+ export interface WorkspaceTaskOptions extends CommonOptions {
124
+ prompt: string;
125
+ backend: "sdk";
126
+ workingDirectory?: string | undefined;
127
+ sandboxMode?: SandboxMode | undefined;
128
+ networkAccess?: boolean | undefined;
129
+ noFollowup?: boolean | undefined;
130
+ }
131
+ export interface ResumeTaskOptions extends Omit<CommonOptions, "backend"> {
132
+ taskId: string;
133
+ answer: string;
134
+ noFollowup?: boolean | undefined;
135
+ }
136
+ export type TaskRequest = {
137
+ kind: "text";
138
+ options: TextOptions;
139
+ } | {
140
+ kind: "image";
141
+ options: ImageOptions;
142
+ } | {
143
+ kind: "task";
144
+ options: WorkspaceTaskOptions;
145
+ } | {
146
+ kind: "resume";
147
+ options: ResumeTaskOptions;
148
+ };
149
+ export interface DoctorCheck {
150
+ name: string;
151
+ status: "ok" | "warning" | "error";
152
+ message: string;
153
+ details?: Record<string, unknown> | undefined;
154
+ }
155
+ export interface DoctorReport {
156
+ ok: boolean;
157
+ platform: string;
158
+ nodeVersion: string;
159
+ checks: DoctorCheck[];
160
+ paths: Record<string, string>;
161
+ }
162
+ export interface GcReport {
163
+ removedPaths: number;
164
+ reclaimedBytes: number;
165
+ warnings: string[];
166
+ }
167
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;AAE7F,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAEjF,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAA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,GAAG,SAAS,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "codex-task",
3
+ "version": "0.2.0",
4
+ "description": "Unofficial agent-to-agent text, image, and workspace task runner for Codex",
5
+ "type": "module",
6
+ "author": "wang121ye",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/wangyendt/codex-task#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/wangyendt/codex-task.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/wangyendt/codex-task/issues"
15
+ },
16
+ "keywords": [
17
+ "agent",
18
+ "codex",
19
+ "cli",
20
+ "image-generation",
21
+ "task-runner",
22
+ "typescript"
23
+ ],
24
+ "bin": {
25
+ "codex-task": "dist/cli.js"
26
+ },
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
34
+ "./types": {
35
+ "types": "./dist/types.d.ts",
36
+ "import": "./dist/types.js"
37
+ },
38
+ "./config": {
39
+ "types": "./dist/config.d.ts",
40
+ "import": "./dist/config.js"
41
+ },
42
+ "./package.json": "./package.json"
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "skills",
47
+ ".codex-plugin",
48
+ "README.md",
49
+ "README.zh-CN.md",
50
+ "LICENSE",
51
+ "THIRD_PARTY_NOTICES.md"
52
+ ],
53
+ "engines": {
54
+ "node": ">=20"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "scripts": {
60
+ "build": "tsc -p tsconfig.build.json",
61
+ "clean": "node scripts/clean.mjs",
62
+ "dev": "tsx src/cli.ts",
63
+ "lint": "eslint src test scripts",
64
+ "typecheck": "tsc -p tsconfig.json --noEmit",
65
+ "test": "node --import tsx --test test/*.test.ts",
66
+ "test:e2e": "node --import tsx --test test/e2e/*.e2e.test.ts",
67
+ "pack:check": "node scripts/pack-check.mjs",
68
+ "smoke:install": "node scripts/install-smoke.mjs",
69
+ "workflow:check": "node scripts/workflow-check.mjs",
70
+ "verify": "npm run lint && npm run workflow:check && npm run typecheck && npm test && npm run build && npm run pack:check && npm run smoke:install",
71
+ "prepublishOnly": "npm run verify"
72
+ },
73
+ "dependencies": {
74
+ "@openai/codex-sdk": "0.147.0",
75
+ "commander": "^14.0.2"
76
+ },
77
+ "optionalDependencies": {
78
+ "@ossiana/node-libcurl": "1.9.6"
79
+ },
80
+ "devDependencies": {
81
+ "@eslint/js": "^9.39.5",
82
+ "@types/node": "^20.19.43",
83
+ "eslint": "^9.39.5",
84
+ "tsx": "^4.23.12",
85
+ "typescript": "^5.9.3",
86
+ "typescript-eslint": "^8.66.0",
87
+ "yaml": "^2.9.0"
88
+ }
89
+ }
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: codex-task
3
+ description: Delegate a focused task to CodexTask and return structured text, generated or edited images, or completed workspace changes. Use when another Agent should call the codex-task CLI for text-to-text, text-to-image, image-to-image, or a bounded Codex workspace task, including resuming a task that needs user input.
4
+ ---
5
+
6
+ # CodexTask
7
+
8
+ Use the installed `codex-task` CLI as a companion tool. This skill teaches the calling Agent how to invoke the CLI; it is not injected into the Codex worker.
9
+
10
+ ## Resolve the CLI
11
+
12
+ The skill and the executable are separate. Installing this skill does not install the npm package.
13
+
14
+ 1. Prefer `codex-task` when `command -v codex-task` succeeds.
15
+ 2. Otherwise, when npm and network access are available, use `npx --yes codex-task@latest` in place of `codex-task` in every command below.
16
+ 3. If neither is available, tell the user to install the unscoped package with `npm install -g codex-task`.
17
+
18
+ Do not silently perform a global npm installation. The package name is `codex-task`, not `@wang121ye/codex-task`.
19
+
20
+ ## Choose the command
21
+
22
+ - Need only a text result: run `codex-task text --backend direct`.
23
+ - Need a new or edited image: run `codex-task image --backend direct`.
24
+ - Need shell commands, file edits, repository work, project rules, or local tools: run `codex-task task --backend sdk`.
25
+ - Have a prior `needs_input` result: ask the user the returned questions, then run `codex-task resume`.
26
+
27
+ Never send workspace work to Direct. Direct cannot run local tools, read a repository, use local MCP, or modify files.
28
+
29
+ ## Invoke safely
30
+
31
+ Prefer stdin for long or quote-heavy prompts:
32
+
33
+ ```bash
34
+ printf '%s' "$PROMPT" | codex-task text --backend direct
35
+ ```
36
+
37
+ For an image that must survive temporary cleanup, always pass an explicit output directory:
38
+
39
+ ```bash
40
+ codex-task image "A clean technical diagram" \
41
+ --backend direct \
42
+ --output ./artifacts
43
+ ```
44
+
45
+ For image-to-image, repeat `--image` up to five times:
46
+
47
+ ```bash
48
+ codex-task image "Keep the subject, change the lighting" \
49
+ --backend direct \
50
+ --image ./reference.png \
51
+ --output ./artifacts
52
+ ```
53
+
54
+ For repository work, pass the intended directory explicitly:
55
+
56
+ ```bash
57
+ codex-task task "Implement the requested change and run focused tests" \
58
+ --backend sdk \
59
+ --cwd /absolute/path/to/repo
60
+ ```
61
+
62
+ The SDK task default is `danger-full-access`, network enabled, and approval `never`. Invoke it only when the user's request authorizes the workspace task. Use `--no-followup` when the caller explicitly requires a single caller turn and accepts reasonable assumptions.
63
+
64
+ ## Handle the result
65
+
66
+ Parse stdout as JSON. Treat these statuses as follows:
67
+
68
+ - `completed`: return `text`, show or link `artifacts`, and summarize `changes` and `commands` when present.
69
+ - `needs_input`: relay every question to the user. Preserve `taskId`; after the user answers, run `codex-task resume <taskId>` with the answer through stdin or as the argument.
70
+ - `failed`: report `error.code` and `error.message`. Retry only when `error.retryable` is true.
71
+ - `cancelled`: report cancellation or timeout; do not claim the task completed.
72
+
73
+ Use `--stream` only when progress events are useful. It changes stdout from one JSON object to JSONL events; it is an item/progress stream, not guaranteed token streaming.
74
+
75
+ ## Diagnose
76
+
77
+ Run `codex-task doctor` when Direct authentication, native transport, model resolution, or SDK availability is uncertain. The command is read-only and does not send a model request.
78
+
79
+ Run `codex-task gc` only to clean CodexTask-managed temporary artifacts and expired pending-task metadata. Files created under an explicit `--output` path are never managed by this cleanup.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "CodexTask"
3
+ short_description: "Delegate text, image, and Codex workspace tasks"
4
+ default_prompt: "Use $codex-task to delegate this task to a focused Codex worker."