remcodex 0.1.0-beta.1
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/LICENSE +21 -0
- package/README.md +331 -0
- package/dist/server/src/app.js +186 -0
- package/dist/server/src/cli.js +270 -0
- package/dist/server/src/controllers/codex-options.controller.js +199 -0
- package/dist/server/src/controllers/message.controller.js +21 -0
- package/dist/server/src/controllers/project.controller.js +44 -0
- package/dist/server/src/controllers/session.controller.js +175 -0
- package/dist/server/src/db/client.js +10 -0
- package/dist/server/src/db/migrations.js +32 -0
- package/dist/server/src/gateways/ws.gateway.js +60 -0
- package/dist/server/src/services/codex-app-server-runner.js +363 -0
- package/dist/server/src/services/codex-exec-runner.js +147 -0
- package/dist/server/src/services/codex-rollout-sync.js +977 -0
- package/dist/server/src/services/codex-runner.js +11 -0
- package/dist/server/src/services/codex-stream-events.js +478 -0
- package/dist/server/src/services/event-store.js +328 -0
- package/dist/server/src/services/project-manager.js +130 -0
- package/dist/server/src/services/pty-runner.js +72 -0
- package/dist/server/src/services/session-manager.js +1586 -0
- package/dist/server/src/services/session-timeline-service.js +181 -0
- package/dist/server/src/types/codex-launch.js +2 -0
- package/dist/server/src/types/models.js +37 -0
- package/dist/server/src/utils/ansi.js +143 -0
- package/dist/server/src/utils/codex-launch.js +102 -0
- package/dist/server/src/utils/codex-quota.js +179 -0
- package/dist/server/src/utils/codex-status.js +163 -0
- package/dist/server/src/utils/codex-ui-options.js +114 -0
- package/dist/server/src/utils/command.js +46 -0
- package/dist/server/src/utils/errors.js +16 -0
- package/dist/server/src/utils/ids.js +7 -0
- package/dist/server/src/utils/node-pty.js +29 -0
- package/package.json +36 -0
- package/scripts/fix-node-pty-helper.js +36 -0
- package/web/api.js +175 -0
- package/web/app.js +8082 -0
- package/web/components/composer.js +627 -0
- package/web/components/session-workbench.js +173 -0
- package/web/i18n/index.js +171 -0
- package/web/i18n/locales/de.js +50 -0
- package/web/i18n/locales/en.js +320 -0
- package/web/i18n/locales/es.js +50 -0
- package/web/i18n/locales/fr.js +50 -0
- package/web/i18n/locales/ja.js +50 -0
- package/web/i18n/locales/ko.js +50 -0
- package/web/i18n/locales/pt-BR.js +50 -0
- package/web/i18n/locales/ru.js +50 -0
- package/web/i18n/locales/zh-CN.js +320 -0
- package/web/i18n/locales/zh-Hant.js +53 -0
- package/web/index.html +23 -0
- package/web/message-rich-text.js +218 -0
- package/web/session-command-activity.js +980 -0
- package/web/session-event-adapter.js +826 -0
- package/web/session-timeline-reducer.js +728 -0
- package/web/session-timeline-renderer.js +656 -0
- package/web/session-ws.js +31 -0
- package/web/styles.css +5665 -0
- package/web/vendor/markdown-it.js +6969 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodexExecRunner = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
class CodexExecRunner {
|
|
6
|
+
command;
|
|
7
|
+
cwd;
|
|
8
|
+
process = null;
|
|
9
|
+
jsonListeners = new Set();
|
|
10
|
+
textListeners = new Set();
|
|
11
|
+
exitListeners = new Set();
|
|
12
|
+
stdoutBuffer = "";
|
|
13
|
+
stopTimer = null;
|
|
14
|
+
constructor(command, cwd) {
|
|
15
|
+
this.command = command;
|
|
16
|
+
this.cwd = cwd;
|
|
17
|
+
}
|
|
18
|
+
start(prompt, threadId, launch) {
|
|
19
|
+
const args = this.buildExecArgs(prompt, threadId, launch);
|
|
20
|
+
this.process = (0, node_child_process_1.spawn)(this.command, args, {
|
|
21
|
+
cwd: this.cwd,
|
|
22
|
+
env: process.env,
|
|
23
|
+
stdio: "pipe",
|
|
24
|
+
});
|
|
25
|
+
if (!this.process.pid) {
|
|
26
|
+
throw new Error("Failed to start codex exec process.");
|
|
27
|
+
}
|
|
28
|
+
this.process.stdout.on("data", (chunk) => {
|
|
29
|
+
this.handleStdout(chunk.toString("utf8"));
|
|
30
|
+
});
|
|
31
|
+
this.process.stderr.on("data", (chunk) => {
|
|
32
|
+
this.emitText("stderr", chunk.toString("utf8"));
|
|
33
|
+
});
|
|
34
|
+
this.process.on("close", (exitCode) => {
|
|
35
|
+
if (this.stopTimer) {
|
|
36
|
+
clearTimeout(this.stopTimer);
|
|
37
|
+
this.stopTimer = null;
|
|
38
|
+
}
|
|
39
|
+
this.flushStdoutRemainder();
|
|
40
|
+
this.process = null;
|
|
41
|
+
this.exitListeners.forEach((listener) => listener(exitCode));
|
|
42
|
+
});
|
|
43
|
+
this.process.on("error", (error) => {
|
|
44
|
+
this.emitText("stderr", `Failed to spawn Codex exec: ${error.message}`);
|
|
45
|
+
});
|
|
46
|
+
return this.process.pid;
|
|
47
|
+
}
|
|
48
|
+
stop() {
|
|
49
|
+
if (!this.process) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.process.kill("SIGINT");
|
|
53
|
+
this.stopTimer = setTimeout(() => {
|
|
54
|
+
this.process?.kill("SIGTERM");
|
|
55
|
+
}, 1500);
|
|
56
|
+
this.stopTimer.unref();
|
|
57
|
+
}
|
|
58
|
+
respond() {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
onJsonEvent(listener) {
|
|
62
|
+
this.jsonListeners.add(listener);
|
|
63
|
+
return () => {
|
|
64
|
+
this.jsonListeners.delete(listener);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
onText(listener) {
|
|
68
|
+
this.textListeners.add(listener);
|
|
69
|
+
return () => {
|
|
70
|
+
this.textListeners.delete(listener);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
onExit(listener) {
|
|
74
|
+
this.exitListeners.add(listener);
|
|
75
|
+
return () => {
|
|
76
|
+
this.exitListeners.delete(listener);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
isAlive() {
|
|
80
|
+
return this.process !== null;
|
|
81
|
+
}
|
|
82
|
+
buildExecArgs(prompt, threadId, launch) {
|
|
83
|
+
const mid = [];
|
|
84
|
+
if (launch?.model) {
|
|
85
|
+
mid.push("-m", launch.model);
|
|
86
|
+
}
|
|
87
|
+
if (launch?.profile) {
|
|
88
|
+
mid.push("-p", launch.profile);
|
|
89
|
+
}
|
|
90
|
+
if (launch?.sandbox) {
|
|
91
|
+
mid.push("-s", launch.sandbox);
|
|
92
|
+
}
|
|
93
|
+
if (launch?.reasoningEffort) {
|
|
94
|
+
mid.push("-c", `model_reasoning_effort=${launch.reasoningEffort}`);
|
|
95
|
+
}
|
|
96
|
+
if (launch?.speed === "fast") {
|
|
97
|
+
mid.push("--enable", "fast_mode");
|
|
98
|
+
}
|
|
99
|
+
else if (launch?.speed === "deep") {
|
|
100
|
+
mid.push("--disable", "fast_mode");
|
|
101
|
+
}
|
|
102
|
+
for (const name of launch?.enableFeatures ?? []) {
|
|
103
|
+
mid.push("--enable", name);
|
|
104
|
+
}
|
|
105
|
+
for (const name of launch?.disableFeatures ?? []) {
|
|
106
|
+
mid.push("--disable", name);
|
|
107
|
+
}
|
|
108
|
+
if (threadId) {
|
|
109
|
+
return ["exec", "resume", "--json", ...mid, "--skip-git-repo-check", threadId, prompt];
|
|
110
|
+
}
|
|
111
|
+
return ["exec", "--json", ...mid, "--skip-git-repo-check", "--color", "never", prompt];
|
|
112
|
+
}
|
|
113
|
+
handleStdout(chunk) {
|
|
114
|
+
this.stdoutBuffer += chunk;
|
|
115
|
+
const lines = this.stdoutBuffer.split(/\r?\n/);
|
|
116
|
+
this.stdoutBuffer = lines.pop() ?? "";
|
|
117
|
+
lines.forEach((line) => this.handleJsonLine(line));
|
|
118
|
+
}
|
|
119
|
+
flushStdoutRemainder() {
|
|
120
|
+
if (!this.stdoutBuffer.trim()) {
|
|
121
|
+
this.stdoutBuffer = "";
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.handleJsonLine(this.stdoutBuffer);
|
|
125
|
+
this.stdoutBuffer = "";
|
|
126
|
+
}
|
|
127
|
+
handleJsonLine(line) {
|
|
128
|
+
const trimmed = line.trim();
|
|
129
|
+
if (!trimmed) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const event = JSON.parse(trimmed);
|
|
134
|
+
this.jsonListeners.forEach((listener) => listener(event));
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
this.emitText("stdout", trimmed);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
emitText(stream, text) {
|
|
141
|
+
if (!text) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this.textListeners.forEach((listener) => listener(stream, text.trimEnd()));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.CodexExecRunner = CodexExecRunner;
|