minecodex 0.1.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/LICENSE +21 -0
- package/README.md +56 -0
- package/apps/dashboard/app.js +387 -0
- package/apps/dashboard/favicon.svg +18 -0
- package/apps/dashboard/index.html +70 -0
- package/apps/dashboard/styles.css +297 -0
- package/features/images/README.md +106 -0
- package/features/images/codex-feature.json +24 -0
- package/features/images/src/http-server.mjs +302 -0
- package/features/images/src/image-library.mjs +582 -0
- package/features/images/src/main.mjs +52 -0
- package/features/images/src/prompt-index.mjs +182 -0
- package/features/images/src/save-as.mjs +40 -0
- package/features/images/src/thread-metadata.mjs +93 -0
- package/features/images/web/app.js +1045 -0
- package/features/images/web/index.html +162 -0
- package/features/images/web/styles.css +994 -0
- package/features/model-slider/README.md +30 -0
- package/features/model-slider/THIRD_PARTY_NOTICES.md +24 -0
- package/features/model-slider/assets/providers/anthropic.svg +1 -0
- package/features/model-slider/assets/providers/deepseek.svg +1 -0
- package/features/model-slider/assets/providers/gemini.svg +1 -0
- package/features/model-slider/assets/providers/grok.svg +1 -0
- package/features/model-slider/assets/providers/hunyuan.svg +1 -0
- package/features/model-slider/assets/providers/kimi.svg +1 -0
- package/features/model-slider/assets/providers/minimax.svg +1 -0
- package/features/model-slider/assets/providers/openai.svg +1 -0
- package/features/model-slider/assets/providers/qwen.svg +1 -0
- package/features/model-slider/assets/providers/xiaomimimo.svg +1 -0
- package/features/model-slider/assets/providers/zhipu.svg +1 -0
- package/features/model-slider/assets/ui/sparkles.svg +18 -0
- package/features/model-slider/assets/ui/star-off.svg +17 -0
- package/features/model-slider/assets/ui/star.svg +15 -0
- package/features/model-slider/codex-feature.json +56 -0
- package/features/model-slider/vendor/cc-switch-LICENSE +21 -0
- package/features/model-slider/vendor/lucide-LICENSE +35 -0
- package/features/notes/README.md +106 -0
- package/features/notes/assets/icons/circle.svg +15 -0
- package/features/notes/assets/icons/ellipsis.svg +17 -0
- package/features/notes/assets/icons/external-link.svg +17 -0
- package/features/notes/assets/icons/list-todo.svg +19 -0
- package/features/notes/assets/icons/message-square-quote.svg +17 -0
- package/features/notes/assets/icons/paperclip.svg +15 -0
- package/features/notes/assets/icons/star-off.svg +17 -0
- package/features/notes/assets/icons/star.svg +15 -0
- package/features/notes/assets/icons/sticky-note.svg +16 -0
- package/features/notes/assets/icons/trash-2.svg +19 -0
- package/features/notes/codex-feature.json +90 -0
- package/features/notes/src/http-server.mjs +541 -0
- package/features/notes/src/main.mjs +54 -0
- package/features/notes/src/product.mjs +771 -0
- package/features/notes/web/app.js +1495 -0
- package/features/notes/web/codex-artifact-document.svg +1 -0
- package/features/notes/web/codex-attachment.svg +1 -0
- package/features/notes/web/codex-build.svg +1 -0
- package/features/notes/web/codex-code.svg +1 -0
- package/features/notes/web/codex-cplusplus.svg +1 -0
- package/features/notes/web/codex-css.svg +1 -0
- package/features/notes/web/codex-document.svg +1 -0
- package/features/notes/web/codex-file.svg +1 -0
- package/features/notes/web/codex-folder.svg +1 -0
- package/features/notes/web/codex-hashes.svg +1 -0
- package/features/notes/web/codex-html.svg +1 -0
- package/features/notes/web/codex-image.svg +1 -0
- package/features/notes/web/codex-java.svg +1 -0
- package/features/notes/web/codex-javascript.svg +1 -0
- package/features/notes/web/codex-json.svg +1 -0
- package/features/notes/web/codex-notebook.svg +1 -0
- package/features/notes/web/codex-pdf.svg +1 -0
- package/features/notes/web/codex-pencil.svg +3 -0
- package/features/notes/web/codex-php.svg +1 -0
- package/features/notes/web/codex-plus.svg +3 -0
- package/features/notes/web/codex-presentation.svg +1 -0
- package/features/notes/web/codex-python.svg +1 -0
- package/features/notes/web/codex-react.svg +1 -0
- package/features/notes/web/codex-rust.svg +1 -0
- package/features/notes/web/codex-shell.svg +1 -0
- package/features/notes/web/codex-skill.svg +1 -0
- package/features/notes/web/codex-spreadsheet.svg +1 -0
- package/features/notes/web/codex-task.svg +3 -0
- package/features/notes/web/codex-terminal.svg +1 -0
- package/features/notes/web/codex-toml.svg +1 -0
- package/features/notes/web/codex-typescript.svg +1 -0
- package/features/notes/web/codex-view-all.svg +3 -0
- package/features/notes/web/index.html +15 -0
- package/features/notes/web/styles.css +1155 -0
- package/package.json +67 -0
- package/packages/cli/bin/mcx.mjs +7 -0
- package/packages/cli/src/browser-exchange.mjs +31 -0
- package/packages/cli/src/commands.mjs +389 -0
- package/packages/cli/src/config.mjs +101 -0
- package/packages/cli/src/control-server.mjs +371 -0
- package/packages/cli/src/npm-adapter.mjs +40 -0
- package/packages/cli/src/paths.mjs +33 -0
- package/packages/cli/src/platform.mjs +368 -0
- package/packages/cli/src/runtime-manager.mjs +338 -0
- package/packages/runtime-host/README.md +171 -0
- package/packages/runtime-host/src/codex-runtime.mjs +4311 -0
- package/packages/runtime-host/src/feature-registry.mjs +827 -0
- package/packages/runtime-host/src/main.mjs +98 -0
- package/packages/runtime-host/src/pid-file.mjs +23 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import { writeFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { CodexRuntime, createRuntimeReadyContract } from "./codex-runtime.mjs";
|
|
7
|
+
import { createManagedPidFileWriter } from "./pid-file.mjs";
|
|
8
|
+
import {
|
|
9
|
+
discoverFeatures,
|
|
10
|
+
loadConfiguredModelCatalog,
|
|
11
|
+
selectEnabledFeatures,
|
|
12
|
+
startFeatureProcesses,
|
|
13
|
+
} from "./feature-registry.mjs";
|
|
14
|
+
|
|
15
|
+
const runtimeRoot = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
16
|
+
const featuresRoot = process.env.CODEX_FEATURES_ROOT ?? path.dirname(runtimeRoot);
|
|
17
|
+
const legacyDataDir = process.env.CODEX_IMAGE_HOST_DATA_DIR ?? path.join(os.homedir(), ".codex-image-host");
|
|
18
|
+
const profileDir = process.env.CODEX_RUNTIME_PROFILE_DIR ?? path.join(legacyDataDir, "codex-profile");
|
|
19
|
+
const cdpPort = Number(process.env.CODEX_RUNTIME_CDP_PORT ?? 9231);
|
|
20
|
+
|
|
21
|
+
const discoveredFeatures = await discoverFeatures(featuresRoot);
|
|
22
|
+
if (!discoveredFeatures.length) throw new Error(`No codex-feature.json files found under ${featuresRoot}`);
|
|
23
|
+
const features = selectEnabledFeatures(discoveredFeatures, process.env.MINECODEX_ENABLED_FEATURES);
|
|
24
|
+
const modelCatalog = await loadConfiguredModelCatalog();
|
|
25
|
+
for (const feature of features) {
|
|
26
|
+
if (feature.modelSelector) feature.modelSelector.models = modelCatalog;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let readyWritePromise = Promise.resolve();
|
|
30
|
+
let runtime;
|
|
31
|
+
let featureProcesses;
|
|
32
|
+
let runtimeReady = false;
|
|
33
|
+
const updateCodexPidFile = createManagedPidFileWriter(process.env.MINECODEX_CODEX_PID_FILE);
|
|
34
|
+
|
|
35
|
+
function writeReadyFile() {
|
|
36
|
+
if (!process.env.MINECODEX_RUNTIME_READY_FILE) return Promise.resolve();
|
|
37
|
+
const filePath = process.env.MINECODEX_RUNTIME_READY_FILE;
|
|
38
|
+
readyWritePromise = readyWritePromise.catch(() => {}).then(() => writeFile(filePath, `${JSON.stringify(
|
|
39
|
+
createRuntimeReadyContract({
|
|
40
|
+
pid: process.pid,
|
|
41
|
+
features,
|
|
42
|
+
plugins: featureProcesses.getStatuses({ rendererActive: runtime?.getRendererStatus().active }),
|
|
43
|
+
failures: featureProcesses.getFailures(),
|
|
44
|
+
renderer: runtime?.getRendererStatus(),
|
|
45
|
+
runtimeSessionId: runtime?.runtimeSessionId,
|
|
46
|
+
}),
|
|
47
|
+
)}\n`, { mode: 0o600 }));
|
|
48
|
+
return readyWritePromise;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function requestReadyFileRefresh() {
|
|
52
|
+
if (!runtimeReady || !runtime || !featureProcesses) return;
|
|
53
|
+
writeReadyFile().catch((error) => console.warn("Runtime ready-file update failed", error.message));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const featureInstanceId = randomUUID();
|
|
57
|
+
featureProcesses = await startFeatureProcesses(features, {
|
|
58
|
+
instanceId: featureInstanceId,
|
|
59
|
+
deferredStart: true,
|
|
60
|
+
onStatusChange: requestReadyFileRefresh,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
runtime = new CodexRuntime({
|
|
64
|
+
features,
|
|
65
|
+
profileDir,
|
|
66
|
+
cdpPort,
|
|
67
|
+
appPath: process.env.MINECODEX_CODEX_EXECUTABLE || undefined,
|
|
68
|
+
onManagedCodexPidChange: updateCodexPidFile,
|
|
69
|
+
onStatusChange: requestReadyFileRefresh,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
await runtime.start();
|
|
74
|
+
runtimeReady = true;
|
|
75
|
+
await writeReadyFile();
|
|
76
|
+
} catch (error) {
|
|
77
|
+
await featureProcesses.stop();
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.log(`Codex Runtime: ${features.map((feature) => feature.label).join(", ") || "no plugins enabled"}`);
|
|
82
|
+
|
|
83
|
+
async function shutdown() {
|
|
84
|
+
await runtime.stop();
|
|
85
|
+
await featureProcesses.stop();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
89
|
+
process.once(signal, async () => {
|
|
90
|
+
try {
|
|
91
|
+
await shutdown();
|
|
92
|
+
process.exit(0);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error(`Runtime shutdown failed: ${error.message}`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { rename, unlink, writeFile } from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
export function createManagedPidFileWriter(
|
|
4
|
+
filePath,
|
|
5
|
+
{
|
|
6
|
+
writeFileImpl = writeFile,
|
|
7
|
+
renameImpl = rename,
|
|
8
|
+
unlinkImpl = unlink,
|
|
9
|
+
temporaryPath = `${filePath}.${process.pid}.tmp`,
|
|
10
|
+
} = {},
|
|
11
|
+
) {
|
|
12
|
+
return async (pid) => {
|
|
13
|
+
if (!filePath) return;
|
|
14
|
+
if (pid == null) {
|
|
15
|
+
await unlinkImpl(filePath).catch((error) => {
|
|
16
|
+
if (error.code !== "ENOENT") throw error;
|
|
17
|
+
});
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
await writeFileImpl(temporaryPath, `${pid}\n`, { mode: 0o600 });
|
|
21
|
+
await renameImpl(temporaryPath, filePath);
|
|
22
|
+
};
|
|
23
|
+
}
|