@minniexcode/codex-switch 0.1.1 → 0.1.3
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/README.CN.md +6 -4
- package/README.md +15 -4
- package/dist/app/add-provider.js +1 -0
- package/dist/app/bridge.js +2 -1
- package/dist/app/switch-provider.js +2 -1
- package/dist/commands/handlers.js +1 -0
- package/dist/domain/config.js +45 -1
- package/dist/domain/providers.js +1 -0
- package/dist/runtime/copilot-adapter.js +346 -70
- package/dist/runtime/copilot-bridge-worker.js +27 -2
- package/dist/runtime/copilot-bridge.js +192 -10
- package/dist/runtime/copilot-cli.js +22 -0
- package/dist/runtime/copilot-installer.js +59 -1
- package/dist/runtime/copilot-sdk-loader.js +4 -1
- package/docs/Design/codex-switch-v0.1.0-design.md +32 -152
- package/docs/Design/codex-switch-v0.1.1-design.md +15 -26
- package/docs/Design/codex-switch-v0.1.2-design.md +65 -0
- package/docs/Design/codex-switch-v0.1.3-design.md +10 -0
- package/docs/PRD/codex-switch-prd-v0.1.0.md +65 -217
- package/docs/PRD/codex-switch-prd-v0.1.1.md +26 -0
- package/docs/PRD/codex-switch-prd-v0.1.2.md +41 -0
- package/docs/PRD/codex-switch-prd-v0.1.3.md +22 -0
- package/docs/Tests/testing.md +1 -1
- package/docs/cli-usage.md +14 -4
- package/docs/codex-switch-command-design.md +1 -1
- package/docs/codex-switch-product-overview.md +7 -3
- package/docs/codex-switch-product-research.md +2 -2
- package/docs/codex-switch-technical-architecture.md +86 -1115
- package/package.json +1 -1
- package/docs/Design/codex-switch-copilot-integration-design.md +0 -517
- package/docs/Design/codex-switch-v0.0.10-design.md +0 -669
- package/docs/Design/codex-switch-v0.0.11-design.md +0 -824
- package/docs/Design/codex-switch-v0.0.12-design.md +0 -343
- package/docs/Design/codex-switch-v0.0.4-design.md +0 -874
- package/docs/Design/codex-switch-v0.0.5-design.md +0 -932
- package/docs/Design/codex-switch-v0.0.6-design.md +0 -708
- package/docs/Design/codex-switch-v0.0.7-design.md +0 -862
- package/docs/Design/codex-switch-v0.0.8-design.md +0 -132
- package/docs/Design/codex-switch-v0.0.9-design.md +0 -182
- package/docs/Design/codex-switch-v0.0.9-to-v0.0.12-roadmap.md +0 -413
- package/docs/PRD/codex-switch-prd-v0.0.10.md +0 -406
- package/docs/PRD/codex-switch-prd-v0.0.11.md +0 -577
- package/docs/PRD/codex-switch-prd-v0.0.12.md +0 -279
- package/docs/PRD/codex-switch-prd-v0.0.5-to-v0.1.0.md +0 -446
- package/docs/PRD/codex-switch-prd-v0.0.8.md +0 -62
- package/docs/PRD/codex-switch-prd-v0.0.9.md +0 -166
- package/docs/PRD/codex-switch-prd.md +0 -650
- package/docs/Tests/test-report-0.0.5.md +0 -163
- package/docs/Tests/test-report-0.0.7.md +0 -118
- package/docs/Tests/testing-bridge-v0.0.9.md +0 -367
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# codex-switch v0.1.2 Design
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
`0.1.2` repairs the Copilot runtime integration while keeping direct-provider support unchanged.
|
|
6
|
+
|
|
7
|
+
## SDK Runtime
|
|
8
|
+
|
|
9
|
+
- The managed installer installs `@github/copilot-sdk@1.0.2`.
|
|
10
|
+
- `loadCopilotSdk()` resolves `@github/copilot-sdk` from the managed runtime package using `createRequire()`.
|
|
11
|
+
- Copilot-specific paths call a Node gate before mutation or bridge startup. Node.js `<20` fails with `COPILOT_RUNTIME_NODE_UNSUPPORTED`.
|
|
12
|
+
- `probeCopilotSdkRuntime()` classifies missing installs, unsupported versions, and prerelease installs before runtime use.
|
|
13
|
+
- SDK API-shape validation happens later when creating the client or session.
|
|
14
|
+
|
|
15
|
+
## SDK API Contract
|
|
16
|
+
|
|
17
|
+
The supported runtime/session shape is:
|
|
18
|
+
|
|
19
|
+
- `CopilotClient`
|
|
20
|
+
- `CopilotClient.getAuthStatus()`
|
|
21
|
+
- `CopilotClient.createSession()`
|
|
22
|
+
- `CopilotSession.sendAndWait()` when present, otherwise `CopilotSession.send()`
|
|
23
|
+
- `CopilotSession.abort()`
|
|
24
|
+
- `CopilotSession.disconnect()` only as best-effort cleanup
|
|
25
|
+
- SDK `approveAll` or compatible permission handler
|
|
26
|
+
|
|
27
|
+
Auth readiness uses `getAuthStatus()` and does not create a session just to test login state. `abort()` is a required compatibility surface; `disconnect()` is not a required compatibility gate.
|
|
28
|
+
|
|
29
|
+
## Bridge Worker
|
|
30
|
+
|
|
31
|
+
The parent process passes both runtime state and SDK runtime directories into the worker. The worker creates one long-lived `CopilotClient`, starts it once, and serializes incoming requests through a promise queue. Each request gets its own session, uses `abort()` for timeout and cancellation control, and attempts `disconnect()` after completion as best-effort cleanup.
|
|
32
|
+
|
|
33
|
+
## Request Mapping
|
|
34
|
+
|
|
35
|
+
The bridge remains a minimal OpenAI-compatible adapter:
|
|
36
|
+
|
|
37
|
+
- `/v1/chat/completions` maps messages to a text prompt.
|
|
38
|
+
- `/v1/responses` accepts string input, message arrays, or typed top-level content-item arrays and maps those text-oriented shapes to the same prompt path.
|
|
39
|
+
- `model` is passed to `createSession({ model })`.
|
|
40
|
+
- Mixed top-level arrays are rejected as unsupported input.
|
|
41
|
+
- `sendAndWait()` receives `{ prompt }` and the request timeout when available; otherwise the bridge falls back to `send()`.
|
|
42
|
+
|
|
43
|
+
Non-text Responses content is represented as readable placeholders. Complex tool-call round trips are outside the `0.1.2` guarantee.
|
|
44
|
+
|
|
45
|
+
## Streaming
|
|
46
|
+
|
|
47
|
+
Streaming Responses requests emit `response.created`, `response.in_progress`, output item/content part setup events, text deltas, done events, and `response.completed`. The bridge writes initial SSE bytes before the upstream response completes and emits comment heartbeats every 15 seconds while waiting.
|
|
48
|
+
|
|
49
|
+
## Error Mapping
|
|
50
|
+
|
|
51
|
+
- Unsupported request shapes return `400`.
|
|
52
|
+
- Auth-required failures return `401`.
|
|
53
|
+
- Upstream timeouts return `504`.
|
|
54
|
+
- Other bridge runtime failures return `500`.
|
|
55
|
+
|
|
56
|
+
## Config Projection
|
|
57
|
+
|
|
58
|
+
Copilot provider projection includes:
|
|
59
|
+
|
|
60
|
+
```toml
|
|
61
|
+
wire_api = "responses"
|
|
62
|
+
stream_idle_timeout_ms = 300000
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Direct provider projection does not add `stream_idle_timeout_ms`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# codex-switch v0.1.3 Design
|
|
2
|
+
|
|
3
|
+
`0.1.3` is a targeted Copilot login compatibility repair release.
|
|
4
|
+
|
|
5
|
+
## Design Notes
|
|
6
|
+
|
|
7
|
+
- The SDK adapter constructs `CopilotClient` through `RuntimeConnection.forStdio({ path })`.
|
|
8
|
+
- The runtime path passed to the SDK resolves to the managed `@github/copilot/npm-loader.js` entrypoint.
|
|
9
|
+
- Human terminal commands such as `copilot --help` and `copilot login` continue to use the bundled `.bin` shim so interactive onboarding behavior remains unchanged.
|
|
10
|
+
- The release adds regression coverage for the constructor compatibility path and runtime loader resolution.
|
|
@@ -1,217 +1,65 @@
|
|
|
1
|
-
# codex-switch
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
- CLI
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
##
|
|
33
|
-
|
|
34
|
-
`
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
### 3.2 `--json` envelope
|
|
67
|
-
|
|
68
|
-
`--json` 的顶层 envelope 必须保持不变:
|
|
69
|
-
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"ok": true,
|
|
73
|
-
"command": "list",
|
|
74
|
-
"data": {},
|
|
75
|
-
"warnings": [],
|
|
76
|
-
"error": null
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
约束如下:
|
|
81
|
-
|
|
82
|
-
- 顶层字段名不变。
|
|
83
|
-
- 顶层字段顺序和 shape 不变。
|
|
84
|
-
- 新信息只能继续追加到 `data`、`warnings` 或 `error.details`。
|
|
85
|
-
|
|
86
|
-
### 3.3 dual-path model
|
|
87
|
-
|
|
88
|
-
`0.1.0` 必须把以下分层固定为正式合同:
|
|
89
|
-
|
|
90
|
-
- tool home:
|
|
91
|
-
- `codex-switch.json`
|
|
92
|
-
- `providers.json`
|
|
93
|
-
- `backups/`
|
|
94
|
-
- `runtime/`
|
|
95
|
-
- `runtimes/`
|
|
96
|
-
- target Codex runtime:
|
|
97
|
-
- `config.toml`
|
|
98
|
-
- `auth.json`
|
|
99
|
-
|
|
100
|
-
含义必须稳定:
|
|
101
|
-
|
|
102
|
-
- `providers.json` 是管理态 SSOT。
|
|
103
|
-
- `config.toml` 是受管 runtime routing 文件。
|
|
104
|
-
- `auth.json` 是受管 auth projection 文件。
|
|
105
|
-
|
|
106
|
-
### 3.4 主工作流
|
|
107
|
-
|
|
108
|
-
Direct provider 主路径:
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
codexs init
|
|
112
|
-
codexs add <provider> --profile <name> --api-key <key>
|
|
113
|
-
codexs switch <provider>
|
|
114
|
-
codexs status
|
|
115
|
-
codexs doctor
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Copilot provider 主路径:
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
codexs init
|
|
122
|
-
codexs login copilot
|
|
123
|
-
codexs add <provider> --copilot --profile <name>
|
|
124
|
-
codexs switch <provider>
|
|
125
|
-
codexs status
|
|
126
|
-
codexs doctor
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
`migrate` 的定位必须明确为:
|
|
130
|
-
|
|
131
|
-
- 面向已有 runtime state 的高级 adopt helper。
|
|
132
|
-
- 不应与 fresh install 主路径混淆。
|
|
133
|
-
- 不应被写成所有新用户都应先执行的默认步骤。
|
|
134
|
-
|
|
135
|
-
## 4. Release Gate
|
|
136
|
-
|
|
137
|
-
只有以下条件全部满足,才允许发布 `0.1.0`。
|
|
138
|
-
|
|
139
|
-
### 4.1 工作流
|
|
140
|
-
|
|
141
|
-
- fresh tool home 下 direct provider 主路径可稳定走通。
|
|
142
|
-
- fresh tool home 下 Copilot 主路径可稳定走通。
|
|
143
|
-
- `switch` 的成功语义仍然等于 config 和 auth projection 都正确。
|
|
144
|
-
- `rollback` 对受管写操作仍然可信。
|
|
145
|
-
|
|
146
|
-
### 4.2 输出与语义
|
|
147
|
-
|
|
148
|
-
- `--json` 读命令输出稳定。
|
|
149
|
-
- 非交互模式不会意外触发 prompt。
|
|
150
|
-
- 错误码和 issue code 对常见失败场景足够稳定。
|
|
151
|
-
- `status` 与 `doctor` 能清楚说明下一步修复动作。
|
|
152
|
-
- `list`、`status`、`doctor` 的人类可读输出和交互提示一致。
|
|
153
|
-
|
|
154
|
-
### 4.3 文档
|
|
155
|
-
|
|
156
|
-
- README、README.CN、README.AI、CLI usage、product overview、PRD、design 和 changelog 与实际行为一致。
|
|
157
|
-
- `docs/Tests/testing.md` 不能继续停留在忽略状态,测试回归必须落仓库并可版本化。
|
|
158
|
-
- 主路径在所有面向用户的文档中必须一致。
|
|
159
|
-
- `0.1.0` 的定位必须压过旧的 `0.0.12` 叙事。
|
|
160
|
-
|
|
161
|
-
### 4.4 包内容
|
|
162
|
-
|
|
163
|
-
- `npm pack --dry-run` 结果合理。
|
|
164
|
-
- tarball 中包含正确的 README、LICENSE、docs、dist。
|
|
165
|
-
- `codexs --help`、`codexs --version`、安装指引与 npm 包元数据一致。
|
|
166
|
-
|
|
167
|
-
### 4.5 结构
|
|
168
|
-
|
|
169
|
-
- 不再保留明显误导性的历史目录语义。
|
|
170
|
-
- 稳定模块的边界说明足够清楚。
|
|
171
|
-
- 新问题不再需要反复回到超大入口文件修补。
|
|
172
|
-
|
|
173
|
-
## 5. 可执行验证清单
|
|
174
|
-
|
|
175
|
-
`0.1.0` 的发布前验证必须至少覆盖以下项目:
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
npm run build
|
|
179
|
-
npm test
|
|
180
|
-
npx tsc --noEmit
|
|
181
|
-
npm pack --dry-run
|
|
182
|
-
node dist/cli.js --help
|
|
183
|
-
node dist/cli.js --version
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
同时必须做以下行为验证:
|
|
187
|
-
|
|
188
|
-
- fresh direct provider flow。
|
|
189
|
-
- fresh Copilot provider flow。
|
|
190
|
-
- `list/status/doctor` 语义检查。
|
|
191
|
-
- `--json` 输出检查。
|
|
192
|
-
- `migrate` 作为高级 adopt helper 的检查。
|
|
193
|
-
- `setup` 作为 deprecated entry 的检查。
|
|
194
|
-
|
|
195
|
-
## 6. 明确不在范围内
|
|
196
|
-
|
|
197
|
-
`0.1.0` 不要求完成以下内容:
|
|
198
|
-
|
|
199
|
-
- 新 upstream。
|
|
200
|
-
- GUI / TUI。
|
|
201
|
-
- daemon。
|
|
202
|
-
- plugin system。
|
|
203
|
-
- auto migration。
|
|
204
|
-
- 兼容层。
|
|
205
|
-
- dual-read / dual-write。
|
|
206
|
-
- `migrate` 的完整非交互产品化。
|
|
207
|
-
- 旧状态的自动升级保留逻辑。
|
|
208
|
-
|
|
209
|
-
## 7. 若 Gate 未通过
|
|
210
|
-
|
|
211
|
-
如果任何阻塞项仍然存在,就不要强行发布 `0.1.0`。
|
|
212
|
-
|
|
213
|
-
此时应继续发布 beta 或 rc 版本,而不是为了版本号好看提前进入稳定线。
|
|
214
|
-
|
|
215
|
-
## 8. 结论
|
|
216
|
-
|
|
217
|
-
`0.1.0` 的本质不是“功能更多”,而是“承诺更稳”。当命令面、输出契约、主工作流、诊断语义、包内容和文档事实完全一致时,这个版本号才成立。
|
|
1
|
+
# codex-switch v0.1.0 PRD
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
- Version line: `0.1.0`
|
|
6
|
+
- Role: first stable documentation baseline
|
|
7
|
+
- Scope: summarize the stable public contract already reached by the CLI
|
|
8
|
+
|
|
9
|
+
## Product Contract
|
|
10
|
+
|
|
11
|
+
`codex-switch` is a local-first CLI named `codexs` for managing Codex model-provider routes. It keeps tool-owned provider state separate from the target Codex runtime while projecting the selected provider into Codex-compatible `config.toml` and `auth.json` files.
|
|
12
|
+
|
|
13
|
+
Stable user workflows:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
codexs init
|
|
17
|
+
codexs add <provider> --profile <model-provider-id> --api-key <key> --base-url <url> --model <model>
|
|
18
|
+
codexs switch <provider>
|
|
19
|
+
codexs status
|
|
20
|
+
codexs doctor
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
codexs init
|
|
25
|
+
codexs login copilot
|
|
26
|
+
codexs add <provider> --copilot --profile <model-provider-id> --model <model>
|
|
27
|
+
codexs switch <provider>
|
|
28
|
+
codexs status
|
|
29
|
+
codexs doctor
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Stable Boundaries
|
|
33
|
+
|
|
34
|
+
- Tool home owns `codex-switch.json`, `providers.json`, `backups/`, `runtime/`, and `runtimes/`.
|
|
35
|
+
- Target Codex home owns the active `config.toml` and `auth.json` projection.
|
|
36
|
+
- `providers.json` is the provider registry source of truth.
|
|
37
|
+
- `config.toml` uses top-level `model` / `model_provider` plus `[model_providers.*]` sections.
|
|
38
|
+
- `auth.json` receives the active Codex-facing bearer value as `OPENAI_API_KEY`.
|
|
39
|
+
- Copilot upstream GitHub credentials are not stored in `providers.json` or target `auth.json`.
|
|
40
|
+
|
|
41
|
+
## Stable Commands
|
|
42
|
+
|
|
43
|
+
Stable command families include `init`, `login copilot`, `add`, `edit`, `switch`, `remove`, `list`, `show`, `current`, `status`, `doctor`, `config show`, `config list-profiles`, `import`, `export`, `bridge start`, `bridge status`, `bridge stop`, `backups list`, and `rollback`.
|
|
44
|
+
|
|
45
|
+
`migrate` remains an advanced adopt helper for existing Codex state. `setup` is a deprecated compatibility entry that points users to `init` and `migrate`.
|
|
46
|
+
|
|
47
|
+
## Output Contract
|
|
48
|
+
|
|
49
|
+
JSON output keeps the top-level envelope:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"ok": true,
|
|
54
|
+
"command": "status",
|
|
55
|
+
"data": {},
|
|
56
|
+
"warnings": [],
|
|
57
|
+
"error": null
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
New information should be added under `data`, `warnings`, or `error.details` without changing the envelope.
|
|
62
|
+
|
|
63
|
+
## Non-Goals
|
|
64
|
+
|
|
65
|
+
`0.1.0` does not introduce automatic migration shims, a daemon, GUI/TUI, plugin system, new upstream families, or backward-compatibility dual-read paths for old development state.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# codex-switch v0.1.1 PRD
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
- Version line: `0.1.1`
|
|
6
|
+
- Role: documentation and fact-source completion release
|
|
7
|
+
- Current package version: `0.1.1`
|
|
8
|
+
|
|
9
|
+
## Goal
|
|
10
|
+
|
|
11
|
+
`0.1.1` closes documentation gaps after the first stable line. It does not change the primary command surface. Its purpose is to make README, CLI usage, product overview, technical architecture, PRD, design, and changelog agree on the same current facts.
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Keep `0.1.0` as the stable product contract summary.
|
|
16
|
+
- Add explicit `0.1.1` PRD and design fact sources so links from overview and architecture resolve.
|
|
17
|
+
- Remove obsolete `0.0.x` transition docs from the active docs tree.
|
|
18
|
+
- Keep Copilot described as a managed local bridge backed by the official GitHub Copilot runtime.
|
|
19
|
+
- Clarify that direct providers remain the stable, generic path and that Copilot has additional runtime prerequisites.
|
|
20
|
+
- Keep the development-version policy: no automatic migration or backward-compatibility shims unless a later task explicitly asks for them.
|
|
21
|
+
|
|
22
|
+
## Acceptance
|
|
23
|
+
|
|
24
|
+
- Public docs link only to current `0.1.0`, `0.1.1`, or planned `0.1.2` fact sources.
|
|
25
|
+
- No public page points to removed `0.0.x` transition documents.
|
|
26
|
+
- `npm test` and `npx tsc --noEmit` continue to pass.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# codex-switch v0.1.2 PRD
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
- Version line: `0.1.2`
|
|
6
|
+
- Status: release candidate
|
|
7
|
+
- Current repository package version: `0.1.2`
|
|
8
|
+
- Role: next Copilot runtime repair line
|
|
9
|
+
- Scope: make the experimental Copilot bridge diagnosable and usable for simple text-oriented turns against the currently verified Codex runtime boundary, with `0.140.x` treated as a planning and verification target rather than a blanket compatibility guarantee
|
|
10
|
+
|
|
11
|
+
## Problem
|
|
12
|
+
|
|
13
|
+
The existing Copilot path treated `@github/copilot-sdk` as a simple chat/session SDK. The package is an official JSON-RPC control surface for GitHub Copilot CLI and has a stricter runtime contract than the previous integration assumed. It also requires Node.js `>=20`, while direct providers should continue to support Node.js `>=18`.
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Default the managed installer to `@github/copilot-sdk@1.0.2` instead of `latest`.
|
|
18
|
+
- Keep package-level `engines.node >=18`, but fail Copilot-only paths early under Node.js `<20` with `COPILOT_RUNTIME_NODE_UNSUPPORTED`.
|
|
19
|
+
- Load the SDK from the managed runtime install directory using `createRequire()`.
|
|
20
|
+
- Probe auth through `CopilotClient.getAuthStatus()` rather than by creating a session.
|
|
21
|
+
- Treat unsupported SDK versions and prerelease installs as explicit runtime failures before bridge use, with API-shape validation reported separately as `COPILOT_SDK_API_UNSUPPORTED` when the client or session is actually used.
|
|
22
|
+
- Start the bridge worker with the same `runtimesDir` that passed parent readiness checks.
|
|
23
|
+
- Keep one long-lived `CopilotClient` in the worker, create one session per request, require `abort()`, and attempt `disconnect()` as best-effort cleanup after the request.
|
|
24
|
+
- Serialize bridge requests to avoid session event interleaving.
|
|
25
|
+
- Normalize `/v1/chat/completions` and `/v1/responses` text-oriented turns to SDK `prompt` messages and pass the model through `createSession({ model })`.
|
|
26
|
+
- Stream Responses API events before upstream completion and emit heartbeat comments while waiting.
|
|
27
|
+
- Return explicit bridge errors for unsupported requests, auth-required failures, SDK/runtime failures, and upstream timeouts.
|
|
28
|
+
- Project Copilot model providers with `wire_api = "responses"` and `stream_idle_timeout_ms = 300000`.
|
|
29
|
+
|
|
30
|
+
## Non-Goals
|
|
31
|
+
|
|
32
|
+
`0.1.2` does not claim the Copilot bridge is a complete OpenAI Responses API backend. Complex tool-call round trips remain experimental unless verified separately.
|
|
33
|
+
|
|
34
|
+
## Acceptance
|
|
35
|
+
|
|
36
|
+
- `/v1/responses` request normalization accepts string input, message arrays, or typed top-level content-item arrays; mixed arrays are rejected; non-text items become readable placeholders.
|
|
37
|
+
- Unsupported requests map to `400`, auth-required failures map to `401`, upstream timeouts map to `504`, and other bridge runtime failures map to `500`.
|
|
38
|
+
- Streaming Responses requests emit the expected event shape, including initial lifecycle events before upstream completion, text deltas, and final completion events.
|
|
39
|
+
- Copilot config projection writes `wire_api = "responses"` and `stream_idle_timeout_ms = 300000`.
|
|
40
|
+
- Simple non-stream and stream bridge requests work against the fake SDK contract.
|
|
41
|
+
- Node `<20` Copilot commands fail before mutating provider or Codex state.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# codex-switch v0.1.3 PRD
|
|
2
|
+
|
|
3
|
+
## Version
|
|
4
|
+
|
|
5
|
+
- Version line: `0.1.3`
|
|
6
|
+
- Current repository package version: `0.1.3`
|
|
7
|
+
|
|
8
|
+
## Summary
|
|
9
|
+
|
|
10
|
+
`0.1.3` is a narrow hotfix release for the broken `login copilot` path. The goal is to restore compatibility with the currently supported official Copilot SDK/runtime pairing without expanding the command surface or the experimental Copilot bridge scope.
|
|
11
|
+
|
|
12
|
+
## Required Outcome
|
|
13
|
+
|
|
14
|
+
- `codexs login copilot` must no longer fail during `CopilotClient` construction when the managed SDK/runtime is installed.
|
|
15
|
+
- The SDK integration must explicitly point at the managed Copilot runtime loader instead of relying on implicit package discovery.
|
|
16
|
+
- Existing direct-provider behavior and Copilot bridge behavior remain unchanged outside the constructor compatibility fix.
|
|
17
|
+
|
|
18
|
+
## Non-Goals
|
|
19
|
+
|
|
20
|
+
- No new Copilot features or new upstream families.
|
|
21
|
+
- No migration shims or backward-compatibility preservation for older local experimental runtime state.
|
|
22
|
+
- No changes to the managed SDK pin or Node version requirements.
|
package/docs/Tests/testing.md
CHANGED
package/docs/cli-usage.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# codex-switch CLI Usage
|
|
2
2
|
|
|
3
|
-
This document describes the current CLI contract for `@minniexcode/codex-switch
|
|
3
|
+
This document describes the current `0.1.3` CLI contract for `@minniexcode/codex-switch`, including the Copilot login hotfix boundary.
|
|
4
4
|
|
|
5
5
|
Executable command name:
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ codexs
|
|
|
10
10
|
|
|
11
11
|
## 1. Version Context
|
|
12
12
|
|
|
13
|
-
The current package version in this repository is `0.1.
|
|
13
|
+
The current package version in this repository is `0.1.3`.
|
|
14
14
|
|
|
15
15
|
This release line targets Codex `0.134.0+`. The public contract assumes runtime routing is selected by top-level `model` plus `model_provider`, while legacy `profile` and `[profiles.*]` remain inspect-and-adopt inputs instead of the recommended runtime path.
|
|
16
16
|
|
|
@@ -51,6 +51,8 @@ Important notes:
|
|
|
51
51
|
- The current implementation prefers the bundled Copilot CLI from the managed runtime and falls back to `PATH` when needed.
|
|
52
52
|
- `login copilot` succeeds only after auth readiness is rechecked.
|
|
53
53
|
- `add --copilot` does not install or log in to Copilot for you.
|
|
54
|
+
- Copilot runtime paths require Node.js `>=20`; direct providers remain supported on Node.js `>=18`.
|
|
55
|
+
- The Copilot bridge is experimental and targets simple text-oriented turns through the local OpenAI-compatible bridge.
|
|
54
56
|
|
|
55
57
|
## 3. Runtime Route Contract
|
|
56
58
|
|
|
@@ -73,6 +75,10 @@ Managed provider projection fixes these fields for OpenAI-compatible direct rout
|
|
|
73
75
|
- `wire_api = "responses"`
|
|
74
76
|
- `requires_openai_auth = true`
|
|
75
77
|
|
|
78
|
+
Copilot bridge projection also writes:
|
|
79
|
+
|
|
80
|
+
- `stream_idle_timeout_ms = 300000`
|
|
81
|
+
|
|
76
82
|
Compatibility notes:
|
|
77
83
|
|
|
78
84
|
- `--profile` is accepted as an alias for the managed `model_provider` id.
|
|
@@ -278,5 +284,9 @@ codexs rollback [backup-id]
|
|
|
278
284
|
- [Chinese README](../README.CN.md)
|
|
279
285
|
- [AI README](../README.AI.md)
|
|
280
286
|
- [Product Overview](./codex-switch-product-overview.md)
|
|
281
|
-
- [
|
|
282
|
-
- [
|
|
287
|
+
- [PRD 0.1.0](./PRD/codex-switch-prd-v0.1.0.md)
|
|
288
|
+
- [PRD 0.1.1](./PRD/codex-switch-prd-v0.1.1.md)
|
|
289
|
+
- [PRD 0.1.2](./PRD/codex-switch-prd-v0.1.2.md)
|
|
290
|
+
- [PRD 0.1.3](./PRD/codex-switch-prd-v0.1.3.md)
|
|
291
|
+
- [Design 0.1.2](./Design/codex-switch-v0.1.2-design.md)
|
|
292
|
+
- [Design 0.1.3](./Design/codex-switch-v0.1.3-design.md)
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
- 文档类型:命令设计文档
|
|
9
9
|
- 适用范围:`codex-switch` MVP
|
|
10
10
|
- 关联文档:
|
|
11
|
-
- [`PRD/codex-switch-prd.md`](./PRD/codex-switch-prd.md)
|
|
11
|
+
- [`PRD/codex-switch-prd-v0.1.0.md`](./PRD/codex-switch-prd-v0.1.0.md)
|
|
12
12
|
- [`codex-switch-technical-architecture.md`](./codex-switch-technical-architecture.md)
|
|
13
13
|
|
|
14
14
|
## 1. 文档目标
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
这份文档介绍当前活跃产品事实源下的 `codex-switch` 产品定位。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
当前稳定 release contract 以这些文档为准:
|
|
8
8
|
|
|
9
|
-
- [`cli-usage.md`](./cli-usage.md)
|
|
9
|
+
- [`cli-usage.md`](./cli-usage.md)
|
|
10
|
+
- [`PRD/codex-switch-prd-v0.1.0.md`](./PRD/codex-switch-prd-v0.1.0.md)
|
|
10
11
|
- [`PRD/codex-switch-prd-v0.1.1.md`](./PRD/codex-switch-prd-v0.1.1.md)
|
|
11
|
-
- [`
|
|
12
|
+
- [`PRD/codex-switch-prd-v0.1.2.md`](./PRD/codex-switch-prd-v0.1.2.md)(规划中)
|
|
13
|
+
- [`Design/codex-switch-v0.1.2-design.md`](./Design/codex-switch-v0.1.2-design.md)(规划中)
|
|
12
14
|
|
|
13
15
|
## 产品概述
|
|
14
16
|
|
|
@@ -85,3 +87,5 @@ codexs migrate
|
|
|
85
87
|
- `migrate` 何时才该使用
|
|
86
88
|
- `status` / `doctor` 如何帮助定位下一步
|
|
87
89
|
- 当前运行态是用顶层 `model` 与 `model_provider` 选择活动路由
|
|
90
|
+
|
|
91
|
+
`0.1.3` 是当前已发布的 Copilot login hotfix 线。当前实现边界是:Copilot 路径要求 Node.js `>=20`,受管安装默认固定到 `@github/copilot-sdk@1.0.2`,运行时会额外拒绝过旧版本和 prerelease 版本,并通过显式 `RuntimeConnection.forStdio({ path })` 把官方 SDK 连接到受管安装中的 Copilot runtime loader;本地 bridge 仍然只是面向 simple text-oriented turns 的 experimental bridge。Direct provider 路径继续支持 Node.js `>=18`。
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 背景与当前结论
|
|
4
4
|
|
|
5
|
-
这份文档的定位不是正式 PRD,而是 `codex-switch` 的前置分析稿。它用于整合当前对参考项目、产品边界和技术方向的判断,并为后续单独编写 `PRD/codex-switch-prd.md` 提供输入。
|
|
5
|
+
这份文档的定位不是正式 PRD,而是 `codex-switch` 的前置分析稿。它用于整合当前对参考项目、产品边界和技术方向的判断,并为后续单独编写 `PRD/codex-switch-prd-v0.1.0.md` 提供输入。
|
|
6
6
|
|
|
7
7
|
当前已经相对明确、可以先锁定的基础结论如下:
|
|
8
8
|
|
|
@@ -317,7 +317,7 @@ Rust / Zig 不是不能做,而是当前收益不足。只有在下面这些诉
|
|
|
317
317
|
|
|
318
318
|
## 后续 PRD 输入项
|
|
319
319
|
|
|
320
|
-
以下内容应留给后续单独的 `PRD/codex-switch-prd.md` 详细展开,这次只列为输入清单,不在本稿中定死:
|
|
320
|
+
以下内容应留给后续单独的 `PRD/codex-switch-prd-v0.1.0.md` 详细展开,这次只列为输入清单,不在本稿中定死:
|
|
321
321
|
|
|
322
322
|
- 目标用户和典型场景
|
|
323
323
|
- 例如个人多 provider 用户、需要让 AI 执行切换命令的开发者、需要本地安全回滚的用户
|