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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +331 -0
  3. package/dist/server/src/app.js +186 -0
  4. package/dist/server/src/cli.js +270 -0
  5. package/dist/server/src/controllers/codex-options.controller.js +199 -0
  6. package/dist/server/src/controllers/message.controller.js +21 -0
  7. package/dist/server/src/controllers/project.controller.js +44 -0
  8. package/dist/server/src/controllers/session.controller.js +175 -0
  9. package/dist/server/src/db/client.js +10 -0
  10. package/dist/server/src/db/migrations.js +32 -0
  11. package/dist/server/src/gateways/ws.gateway.js +60 -0
  12. package/dist/server/src/services/codex-app-server-runner.js +363 -0
  13. package/dist/server/src/services/codex-exec-runner.js +147 -0
  14. package/dist/server/src/services/codex-rollout-sync.js +977 -0
  15. package/dist/server/src/services/codex-runner.js +11 -0
  16. package/dist/server/src/services/codex-stream-events.js +478 -0
  17. package/dist/server/src/services/event-store.js +328 -0
  18. package/dist/server/src/services/project-manager.js +130 -0
  19. package/dist/server/src/services/pty-runner.js +72 -0
  20. package/dist/server/src/services/session-manager.js +1586 -0
  21. package/dist/server/src/services/session-timeline-service.js +181 -0
  22. package/dist/server/src/types/codex-launch.js +2 -0
  23. package/dist/server/src/types/models.js +37 -0
  24. package/dist/server/src/utils/ansi.js +143 -0
  25. package/dist/server/src/utils/codex-launch.js +102 -0
  26. package/dist/server/src/utils/codex-quota.js +179 -0
  27. package/dist/server/src/utils/codex-status.js +163 -0
  28. package/dist/server/src/utils/codex-ui-options.js +114 -0
  29. package/dist/server/src/utils/command.js +46 -0
  30. package/dist/server/src/utils/errors.js +16 -0
  31. package/dist/server/src/utils/ids.js +7 -0
  32. package/dist/server/src/utils/node-pty.js +29 -0
  33. package/package.json +36 -0
  34. package/scripts/fix-node-pty-helper.js +36 -0
  35. package/web/api.js +175 -0
  36. package/web/app.js +8082 -0
  37. package/web/components/composer.js +627 -0
  38. package/web/components/session-workbench.js +173 -0
  39. package/web/i18n/index.js +171 -0
  40. package/web/i18n/locales/de.js +50 -0
  41. package/web/i18n/locales/en.js +320 -0
  42. package/web/i18n/locales/es.js +50 -0
  43. package/web/i18n/locales/fr.js +50 -0
  44. package/web/i18n/locales/ja.js +50 -0
  45. package/web/i18n/locales/ko.js +50 -0
  46. package/web/i18n/locales/pt-BR.js +50 -0
  47. package/web/i18n/locales/ru.js +50 -0
  48. package/web/i18n/locales/zh-CN.js +320 -0
  49. package/web/i18n/locales/zh-Hant.js +53 -0
  50. package/web/index.html +23 -0
  51. package/web/message-rich-text.js +218 -0
  52. package/web/session-command-activity.js +980 -0
  53. package/web/session-event-adapter.js +826 -0
  54. package/web/session-timeline-reducer.js +728 -0
  55. package/web/session-timeline-renderer.js +656 -0
  56. package/web/session-ws.js +31 -0
  57. package/web/styles.css +5665 -0
  58. 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;