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,171 @@
|
|
|
1
|
+
# Codex Runtime Host
|
|
2
|
+
|
|
3
|
+
本机个人 Codex 功能的统一运行宿主。它是唯一的 Injector / Adapter,负责:
|
|
4
|
+
|
|
5
|
+
- 连接或启动支持 loopback CDP 的隔离 Codex 桌面实例;
|
|
6
|
+
- 从同级项目的 `codex-feature.json` 注册 Sidebar 或 Conversation toolbar 入口;
|
|
7
|
+
- 挂载 full-page、Pinned Summary,并把 Detail iframe Surface 优先注册为 Codex 原生右侧 Task Tab;
|
|
8
|
+
- 把 Codex 当前 resolved Theme Tokens 同步给每个 Surface;
|
|
9
|
+
- 执行经过 manifest allowlist、Surface 身份和 renderer token 校验的 Host actions;
|
|
10
|
+
- 把所有易变的 Codex DOM / CDP 细节留在一个 Adapter 中。
|
|
11
|
+
|
|
12
|
+
各功能项目继续拥有自己的数据、HTTP API 与页面。宿主不读取业务数据库;单个
|
|
13
|
+
功能服务失效不会阻止 Codex 或其他功能运行。
|
|
14
|
+
|
|
15
|
+
## 启动与验证
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm start
|
|
19
|
+
npm test
|
|
20
|
+
npm run check:runtime
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
宿主默认扫描上层目录中的同级项目。只有当 manifest 的 `healthUrl` 返回的 JSON 同时满足
|
|
24
|
+
`ok === true`、`service === feature.id`、`protocolVersion === 1`,且 `instanceId` 等于本次 RuntimeHost
|
|
25
|
+
生成并传给功能进程的 `MINECODEX_FEATURE_INSTANCE_ID` 时,宿主才会复用现有服务。仅仅可达或
|
|
26
|
+
返回 2xx 的 foreign / stale 服务不会被信任;身份不匹配时,宿主会在项目目录执行其
|
|
27
|
+
`command`。可用以下环境变量启动隔离实例:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
CODEX_FEATURES_ROOT=/path/to/features \
|
|
31
|
+
CODEX_RUNTIME_PROFILE_DIR=/tmp/codex-profile \
|
|
32
|
+
CODEX_RUNTIME_CDP_PORT=9232 \
|
|
33
|
+
MINECODEX_CODEX_EXECUTABLE=/path/to/Codex \
|
|
34
|
+
npm start
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Sidebar / page manifest
|
|
38
|
+
|
|
39
|
+
旧 manifest 保持兼容;没有 `entry` 时默认仍是 Sidebar:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"schemaVersion": 1,
|
|
44
|
+
"id": "images",
|
|
45
|
+
"label": "Images",
|
|
46
|
+
"surfaceUrl": "http://127.0.0.1:47831/",
|
|
47
|
+
"placement": { "after": "sites", "order": 10 },
|
|
48
|
+
"command": ["node", "src/main.mjs"],
|
|
49
|
+
"icon": {
|
|
50
|
+
"viewBox": "0 0 24 24",
|
|
51
|
+
"markup": "<rect ...></rect>"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Conversation toolbar / responsive summary manifest
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"schemaVersion": 1,
|
|
61
|
+
"id": "notes",
|
|
62
|
+
"label": { "en": "Notes", "zh-CN": "笔记" },
|
|
63
|
+
"surfaceUrl": "http://127.0.0.1:47832/?surface=summary",
|
|
64
|
+
"healthUrl": "http://127.0.0.1:47832/api/health",
|
|
65
|
+
"entry": {
|
|
66
|
+
"kind": "conversation-toolbar",
|
|
67
|
+
"ariaLabel": { "en": "Toggle pinned notes", "zh-CN": "切换固定笔记" }
|
|
68
|
+
},
|
|
69
|
+
"pinnedSummary": {
|
|
70
|
+
"label": { "en": "Pinned Notes", "zh-CN": "固定笔记" },
|
|
71
|
+
"surfaceUrl": "http://127.0.0.1:47832/?surface=summary",
|
|
72
|
+
"presentation": "responsive-summary",
|
|
73
|
+
"overlayLabel": { "en": "Toggle notes", "zh-CN": "切换笔记" },
|
|
74
|
+
"pinnedLabel": { "en": "Toggle pinned notes", "zh-CN": "切换固定笔记" }
|
|
75
|
+
},
|
|
76
|
+
"detailTabs": [
|
|
77
|
+
{ "id": "todo", "label": { "en": "Todo", "zh-CN": "待办" }, "surfaceUrl": "http://127.0.0.1:47832/?surface=todo" },
|
|
78
|
+
{ "id": "prompts", "label": { "en": "Prompts", "zh-CN": "提示词" }, "surfaceUrl": "http://127.0.0.1:47832/?surface=prompts" }
|
|
79
|
+
],
|
|
80
|
+
"hostActions": ["insert-text", "attach-file", "open-detail-tab", "open-editor-modal", "resolve-file-paths"],
|
|
81
|
+
"command": ["node", "src/main.mjs"],
|
|
82
|
+
"icon": { "resource": "node_modules/lucide-static/icons/notebook-tabs.svg" }
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`icon.resource` 必须留在功能项目目录内。宿主读取真实 SVG 的 `viewBox` 与内部
|
|
87
|
+
markup;功能不需要把第三方 SVG 复制进 manifest。
|
|
88
|
+
|
|
89
|
+
`label`、`entry.ariaLabel`、Pinned Summary 的三个 label 与 Detail Tab label 均可使用
|
|
90
|
+
单个字符串或 `{ "en": "…", "zh-CN": "…" }` locale map。字符串 manifest 保持
|
|
91
|
+
向后兼容;locale map 以 English 为 fallback,并按 Codex 文档语言选择显示文本。
|
|
92
|
+
Host action、feature id 与 detail id 是协议标识,必须保持语言无关。
|
|
93
|
+
|
|
94
|
+
Conversation toolbar 入口复制原生按钮结构后会规范化交互类:关闭态保持透明并使用
|
|
95
|
+
tertiary icon color,只有真实 hover 或 `data-state=open` 时才使用 Codex 原生
|
|
96
|
+
`list-hover-background`,避免把创建瞬间的原生激活样式固化到功能按钮上。
|
|
97
|
+
Conversation toolbar 的结构遵循原生分组,而不只追求图标顺序:有原生 Summary 时,
|
|
98
|
+
Feature 入口直接加入 Summary 所在的中间功能组并紧跟在 Summary 后;New Chat 尚无
|
|
99
|
+
Summary 时,宿主在中间 toolbar 的右端建立同构的 Summary feature group。可见的
|
|
100
|
+
`Toggle bottom panel` 仅作为 New Chat 状态下定位中间 toolbar 的稳定锚点,Feature 不会
|
|
101
|
+
进入也不会扩宽最右侧的 Bottom Panel / Side Panel 原生组。
|
|
102
|
+
|
|
103
|
+
## Surface 协议
|
|
104
|
+
|
|
105
|
+
Surface 发给 Host:
|
|
106
|
+
|
|
107
|
+
- `codex-personal:ready`
|
|
108
|
+
- `codex-personal:close`
|
|
109
|
+
- `codex-personal:open-thread`
|
|
110
|
+
- `codex-personal:host-action`
|
|
111
|
+
- `codex-personal:surface-metrics`
|
|
112
|
+
|
|
113
|
+
Host 发给 Surface:
|
|
114
|
+
|
|
115
|
+
- `codex-personal:theme`
|
|
116
|
+
- `codex-personal:host-result`
|
|
117
|
+
- `codex-personal:surface-active`(`active: true | false`)
|
|
118
|
+
|
|
119
|
+
`codex-personal:theme` 同时携带标准化后的 `locale`(当前为 `en` 或 `zh-CN`),
|
|
120
|
+
Surface 可用它同步自身可见文案与辅助功能标签。
|
|
121
|
+
Page Surface 每次显示或隐藏时都会收到 `codex-personal:surface-active`;iframe 重新加载后,
|
|
122
|
+
Host 会再次发送当前状态。功能页面可据此暂停隐藏状态下的轮询或其他后台工作。
|
|
123
|
+
|
|
124
|
+
每个 iframe 消息同时校验 `event.origin` 与准确的 `contentWindow`。Host action
|
|
125
|
+
还必须在对应 feature 的 allowlist 中;需要 Node/CDP 的原生动作使用每个 Renderer
|
|
126
|
+
独立的随机 binding token,并按 target 串行执行。功能页面只有收到明确成功结果后
|
|
127
|
+
才能更新“最近调用”等产品状态。
|
|
128
|
+
|
|
129
|
+
当前 Host actions:
|
|
130
|
+
|
|
131
|
+
- `insert-text`:替换已保存的 Composer selection/caret;无法恢复时另起一行追加。
|
|
132
|
+
- `attach-file`:用 CDP 填充临时 file input,再把真实 `File` drop 给 Composer;只有
|
|
133
|
+
观察到原生附件 chip/preview 才报告 `attach`,否则明确返回 `insert-path`。
|
|
134
|
+
- `open-detail-tab`:动态发现当前 Codex React right-panel controller 与当前 Task scope,
|
|
135
|
+
用稳定的 `featureId-detailId` 聚焦或创建唯一原生 Tab;capability 不可用时才回退到
|
|
136
|
+
RuntimeHost 自建的兼容 Tab host。
|
|
137
|
+
- `resolve-file-paths`:通过 Codex preload 暴露的 Electron file bridge 解析 Finder
|
|
138
|
+
drop 的真实 `File` 对象。
|
|
139
|
+
|
|
140
|
+
## Adapter 生命周期与故障边界
|
|
141
|
+
|
|
142
|
+
- 只在 top frame 安装 Runtime,绝不向业务 iframe 注入 binding token。
|
|
143
|
+
- Watch / refresh 串行;已连接 Renderer 不重复连接,关闭 target 会清理状态。
|
|
144
|
+
- 入口由 Renderer 内的 MutationObserver 幂等挂载,React 重绘不会产生重复入口。
|
|
145
|
+
- Summary 根据对话主区域宽度连续派生 `overlay / shift / gutter`:小于 1096px
|
|
146
|
+
使用临时 Popover;1096–1535px 预留 316px 并把对话内容左移 158px;更宽时
|
|
147
|
+
放入右侧 gutter 而不移动对话。
|
|
148
|
+
- Popover 与 inline Summary 只占可见矩形,不使用透明全屏 overlay;原生 Portal
|
|
149
|
+
可以保持更高层级。Surface 上报自然高度,Host 再按窗口可用高度截断,内容组件
|
|
150
|
+
自己拥有唯一的纵向 scroller。
|
|
151
|
+
- Host 把当前 Codex Summary 的 section title、row type、icon color/size、radius、
|
|
152
|
+
border、dropdown background 和 elevation tokens 发送给 Surface。
|
|
153
|
+
- 新客户端会话默认关闭;Thread 切换关闭 Pinned Summary 并清除旧 Composer Range。
|
|
154
|
+
- Detail Tab 使用 Codex 当前 `local-thread` scope,因此标签状态跟随 Task;React panel
|
|
155
|
+
中的 iframe 继续注册同一套 Surface origin、`contentWindow`、Theme 与 Host-action bridge。
|
|
156
|
+
- Surface 以 `ready` handshake 标记可用。若第一次加载发生在服务离线期间,下一次
|
|
157
|
+
打开只重载这个未 ready 的 iframe;已经 ready 的 Surface 不重载、不打断草稿。
|
|
158
|
+
|
|
159
|
+
## 当前接口分类
|
|
160
|
+
|
|
161
|
+
| 路径 | 分类 | 说明 |
|
|
162
|
+
| --- | --- | --- |
|
|
163
|
+
| loopback HTTP、manifest、Surface message schema | 项目自有稳定接口 | 可由测试直接覆盖 |
|
|
164
|
+
| `window.electronBridge.getPathForFile` | 当前稳定 internal/preload | 仅用于 Finder `File` 路径解析 |
|
|
165
|
+
| React right-panel `openTab`、Task scope、JSX runtime | private internal capability | 动态发现 bundle 并做能力检测;失败时回退自建 Tab host |
|
|
166
|
+
| toolbar、summary、tabs、Composer selectors | DOM inference | 统一留在本 Adapter |
|
|
167
|
+
| `Runtime.addBinding`、`DOM.setFileInputFiles`、注入脚本 | high-risk CDP | 必须使用隔离 profile 验收 |
|
|
168
|
+
| `togglePinnedSummary`、`composer.addFiles` 字符串 | 探索证据 | 当前实现不把它们当契约 |
|
|
169
|
+
|
|
170
|
+
这是非官方 CDP / DOM Adapter,不是公开的 Codex Contribution API。Codex 更新后应只
|
|
171
|
+
在这个宿主中修复;各功能的数据和 Web UI不需要跟随重写。
|