opencode-aicodewith-auth 0.1.1 → 0.1.2
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.ai.md +39 -7
- package/README.md +59 -106
- package/dist/index.d.ts +8 -0
- package/dist/index.js +11 -8
- package/dist/lib/constants.d.ts +8 -0
- package/dist/lib/logger.d.ts +8 -0
- package/dist/lib/prompts/codex-opencode-bridge.d.ts +8 -0
- package/dist/lib/prompts/codex.d.ts +8 -0
- package/dist/lib/prompts/opencode-codex.d.ts +5 -3
- package/dist/lib/request/fetch-helpers.d.ts +8 -0
- package/dist/lib/request/helpers/input-utils.d.ts +8 -0
- package/dist/lib/request/helpers/model-map.d.ts +8 -0
- package/dist/lib/request/request-transformer.d.ts +8 -0
- package/dist/lib/request/response-handler.d.ts +8 -0
- package/dist/lib/types.d.ts +8 -0
- package/dist/provider.d.ts +8 -0
- package/package.json +1 -1
package/README.ai.md
CHANGED
|
@@ -165,21 +165,33 @@ Ensure the `plugin` array includes `opencode-aicodewith-auth`:
|
|
|
165
165
|
|
|
166
166
|
---
|
|
167
167
|
|
|
168
|
-
## Step 4 — Verify installation
|
|
168
|
+
## Step 4 — Verify installation and check npm registry
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
### 4.1 Check if user is using a non-official npm registry
|
|
171
|
+
|
|
172
|
+
Run this command to detect the npm registry:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm config get registry
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
If the output is NOT `https://registry.npmjs.org/` (e.g., shows taobao, cnpm, or other mirrors), **remember to include a warning in your final message**.
|
|
179
|
+
|
|
180
|
+
### 4.2 Tell the user installation is complete
|
|
181
|
+
|
|
182
|
+
**If using official npm registry** (https://registry.npmjs.org/):
|
|
171
183
|
|
|
172
|
-
> "
|
|
173
|
-
>
|
|
184
|
+
> "安装完成!请重启 OpenCode 以加载插件。
|
|
185
|
+
> 你现在可以使用以下模型:
|
|
174
186
|
> - `gpt-5.2-codex`
|
|
175
187
|
> - `gpt-5.2`
|
|
176
188
|
> - `claude-sonnet-4-5-20250929`
|
|
177
189
|
> - `claude-opus-4-5-20251101`
|
|
178
190
|
> - `gemini-3-pro-high`
|
|
179
191
|
>
|
|
180
|
-
>
|
|
192
|
+
> 测试命令: `opencode --model gpt-5.2-codex`"
|
|
181
193
|
|
|
182
|
-
|
|
194
|
+
**If using a mirror registry** (taobao, cnpm, etc.), add this warning:
|
|
183
195
|
|
|
184
196
|
> "安装完成!请重启 OpenCode 以加载插件。
|
|
185
197
|
> 你现在可以使用以下模型:
|
|
@@ -189,7 +201,14 @@ Or in Chinese:
|
|
|
189
201
|
> - `claude-opus-4-5-20251101`
|
|
190
202
|
> - `gemini-3-pro-high`
|
|
191
203
|
>
|
|
192
|
-
> 测试命令: `opencode --model gpt-5.2-codex`
|
|
204
|
+
> 测试命令: `opencode --model gpt-5.2-codex`
|
|
205
|
+
>
|
|
206
|
+
> ⚠️ **注意**: 检测到你使用的是非官方 npm 源。如果启动 OpenCode 时遇到插件加载失败(如 `BunInstallFailedError`),可能是镜像源尚未同步最新版本。解决方法:
|
|
207
|
+
> ```bash
|
|
208
|
+
> # 临时使用官方源重新安装
|
|
209
|
+
> npm config set registry https://registry.npmjs.org/
|
|
210
|
+
> # 重启 OpenCode 后,可以改回原来的源
|
|
211
|
+
> ```"
|
|
193
212
|
|
|
194
213
|
---
|
|
195
214
|
|
|
@@ -206,6 +225,18 @@ Or in Chinese:
|
|
|
206
225
|
|
|
207
226
|
If the user reports issues:
|
|
208
227
|
|
|
228
|
+
### "BunInstallFailedError" or plugin fails to load
|
|
229
|
+
This is usually caused by npm mirror sync delays. The user's npm registry may not have synced the latest version yet.
|
|
230
|
+
|
|
231
|
+
Tell the user:
|
|
232
|
+
> "这个问题通常是因为你的 npm 镜像源还没有同步最新版本。解决方法:
|
|
233
|
+
> ```bash
|
|
234
|
+
> # 临时切换到官方源
|
|
235
|
+
> npm config set registry https://registry.npmjs.org/
|
|
236
|
+
> # 重启 OpenCode
|
|
237
|
+
> # 之后可以改回原来的源
|
|
238
|
+
> ```"
|
|
239
|
+
|
|
209
240
|
### "Provider not found: aicodewith"
|
|
210
241
|
- Verify `opencode.json` contains `"plugin": ["opencode-aicodewith-auth"]`
|
|
211
242
|
- Ask user to restart OpenCode
|
|
@@ -228,3 +259,4 @@ If the user reports issues:
|
|
|
228
259
|
4. **NEVER run interactive commands** — Do NOT run `opencode auth login`, it will block. Edit files directly instead.
|
|
229
260
|
5. **ALWAYS verify file writes** — Re-read after writing to confirm valid JSON
|
|
230
261
|
6. **ALWAYS wait for user confirmation** — Don't assume, ask when unclear
|
|
262
|
+
7. **ALWAYS check npm registry and warn if using mirrors** — Run `npm config get registry` and warn user about potential sync issues if not using official registry
|
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
opencode-aicodewith-auth
|
|
3
3
|
An OpenCode auth plugin for AICodewith
|
|
4
|
+
|
|
5
|
+
📌 MAINTAINER NOTICE:
|
|
6
|
+
Any architecture, feature, or convention changes MUST update:
|
|
7
|
+
1. This file (if affecting overall structure)
|
|
8
|
+
2. Relevant subdirectory's ARCHITECTURE.md
|
|
9
|
+
3. Affected file headers (input/output/pos comments)
|
|
4
10
|
-->
|
|
5
11
|
|
|
6
12
|
<div align="center">
|
|
@@ -8,7 +14,8 @@ An OpenCode auth plugin for AICodewith
|
|
|
8
14
|
# opencode-aicodewith-auth
|
|
9
15
|
|
|
10
16
|
**OpenCode 的 AICodewith 认证插件**
|
|
11
|
-
|
|
17
|
+
|
|
18
|
+
一次登录 → 多模型可用(GPT-5.2、Claude、Gemini)
|
|
12
19
|
|
|
13
20
|
[](https://www.npmjs.com/package/opencode-aicodewith-auth)
|
|
14
21
|
[](https://www.npmjs.com/package/opencode-aicodewith-auth)
|
|
@@ -18,59 +25,68 @@ An OpenCode auth plugin for AICodewith
|
|
|
18
25
|
|
|
19
26
|
---
|
|
20
27
|
|
|
21
|
-
##
|
|
28
|
+
## Architecture Overview
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
```
|
|
31
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
32
|
+
│ opencode-aicodewith-auth │
|
|
33
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
34
|
+
│ index.ts Plugin entry, auth hook, config injection │
|
|
35
|
+
│ provider.ts Multi-provider factory (OpenAI/Claude/Gemini)│
|
|
36
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
37
|
+
│ lib/ Core library modules │
|
|
38
|
+
│ ├── constants.ts Global constants & header names │
|
|
39
|
+
│ ├── types.ts Shared TypeScript interfaces │
|
|
40
|
+
│ ├── logger.ts Debug/request logging utilities │
|
|
41
|
+
│ ├── prompts/ Codex prompt fetching & bridging │
|
|
42
|
+
│ └── request/ Request transformation & response handling│
|
|
43
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
44
|
+
│ scripts/ Installation automation │
|
|
45
|
+
│ └── install-opencode-aicodewith.js postinstall config writer │
|
|
46
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
47
|
+
```
|
|
24
48
|
|
|
25
|
-
|
|
26
|
-
- 只认证 **一次**
|
|
27
|
-
- 在 OpenCode 里自由切换多个模型
|
|
49
|
+
### Data Flow
|
|
28
50
|
|
|
29
|
-
|
|
51
|
+
```
|
|
52
|
+
User Request → OpenCode → Plugin Auth Hook → Route by Model:
|
|
53
|
+
├── gpt-*/codex-* → Codex API (transform + headers)
|
|
54
|
+
├── claude-* → Anthropic API (URL rewrite)
|
|
55
|
+
└── gemini-* → Gemini API (headers + URL build)
|
|
56
|
+
```
|
|
30
57
|
|
|
31
58
|
---
|
|
32
59
|
|
|
33
60
|
## 支持的模型
|
|
34
61
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
> AICodewith 后续支持更多模型时,插件也会同步更新。
|
|
62
|
+
| 模型 ID | 显示名称 | 适合场景 |
|
|
63
|
+
|---------|---------|---------|
|
|
64
|
+
| `aicodewith/gpt-5.2-codex` | GPT-5.2 Codex | 日常编程、代码生成 |
|
|
65
|
+
| `aicodewith/gpt-5.2` | GPT-5.2 | 架构设计、逻辑推理 |
|
|
66
|
+
| `aicodewith/claude-sonnet-4-5-20250929` | Claude Sonnet 4.5 | 代码审查、文档查询 |
|
|
67
|
+
| `aicodewith/claude-opus-4-5-20251101` | Claude Opus 4.5 | 复杂任务、深度思考 |
|
|
68
|
+
| `aicodewith/gemini-3-pro-high` | Gemini 3 Pro | 前端 UI、多模态任务 |
|
|
44
69
|
|
|
45
70
|
---
|
|
46
71
|
|
|
47
|
-
##
|
|
48
|
-
|
|
49
|
-
### 第一步:获取 API Key
|
|
72
|
+
## 快速开始
|
|
50
73
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
---
|
|
74
|
+
### 🔥 方案一:完整安装(推荐 - 包含 oh-my-opencode)
|
|
54
75
|
|
|
55
|
-
|
|
76
|
+
```
|
|
77
|
+
帮我安装配置 opencode-aicodewith-auth 和 oh-my-opencode,按照这个说明操作:https://raw.githubusercontent.com/DaneelOlivaw1/opencode-aicodewith-auth/main/INSTALL-WITH-OMO.md
|
|
78
|
+
```
|
|
56
79
|
|
|
57
|
-
|
|
80
|
+
### 📦 方案二:单独安装
|
|
58
81
|
|
|
59
82
|
```
|
|
60
83
|
帮我安装配置 opencode-aicodewith-auth,按照这个说明操作:https://raw.githubusercontent.com/DaneelOlivaw1/opencode-aicodewith-auth/main/README.ai.md
|
|
61
84
|
```
|
|
62
85
|
|
|
63
|
-
AI 会引导你完成整个安装流程。
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
86
|
<details>
|
|
68
87
|
<summary><strong>手动安装</strong></summary>
|
|
69
88
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
在你的 OpenCode 配置文件中添加插件:
|
|
73
|
-
|
|
89
|
+
1. 编辑 `~/.config/opencode/opencode.json`:
|
|
74
90
|
```json
|
|
75
91
|
{
|
|
76
92
|
"$schema": "https://opencode.ai/config.json",
|
|
@@ -78,103 +94,40 @@ AI 会引导你完成整个安装流程。
|
|
|
78
94
|
}
|
|
79
95
|
```
|
|
80
96
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
关闭并重新打开 OpenCode,让插件生效。
|
|
84
|
-
|
|
85
|
-
#### 3. 运行认证
|
|
86
|
-
|
|
87
|
-
在终端运行:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
opencode auth login
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
按提示操作:
|
|
94
|
-
|
|
95
|
-
1. 选择 **Other**
|
|
96
|
-
2. 供应商名称填:`aicodewith`
|
|
97
|
-
3. 输入你的 API Key(在 AICodewith 平台创建的 key)
|
|
98
|
-
4. 回车完成
|
|
99
|
-
|
|
100
|
-

|
|
97
|
+
2. 运行 `opencode auth login` → 选择 Other → 输入 `aicodewith` → 输入 API Key
|
|
101
98
|
|
|
102
99
|
</details>
|
|
103
100
|
|
|
104
101
|
---
|
|
105
102
|
|
|
106
|
-
## Provider 配置
|
|
107
|
-
|
|
108
|
-
### 自动注入(默认)
|
|
109
|
-
|
|
110
|
-
安装后,插件会自动在你的 OpenCode 配置中注入 `aicodewith` provider。
|
|
111
|
-
|
|
112
|
-
如果你想手动管理,可以用这个模板:
|
|
113
|
-
|
|
114
|
-
```json
|
|
115
|
-
{
|
|
116
|
-
"provider": {
|
|
117
|
-
"aicodewith": {
|
|
118
|
-
"name": "AICodewith",
|
|
119
|
-
"api": "https://api.openai.com/v1",
|
|
120
|
-
"env": ["AICODEWITH_API_KEY"],
|
|
121
|
-
"models": {
|
|
122
|
-
"gpt-5.2-codex": {},
|
|
123
|
-
"gpt-5.2": {},
|
|
124
|
-
"claude-sonnet-4-5-20250929": {},
|
|
125
|
-
"claude-opus-4-5-20251101": {},
|
|
126
|
-
"gemini-3-pro-high": {}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
103
|
## 使用
|
|
136
104
|
|
|
137
|
-
启动时指定模型:
|
|
138
|
-
|
|
139
105
|
```bash
|
|
140
|
-
opencode --model gpt-5.2-codex
|
|
106
|
+
opencode --model aicodewith/gpt-5.2-codex
|
|
141
107
|
```
|
|
142
108
|
|
|
143
|
-
或者在 OpenCode 界面里切换模型。
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## 常见问题
|
|
148
|
-
|
|
149
|
-
### "Provider not found: aicodewith"
|
|
150
|
-
|
|
151
|
-
* 确认 `opencode.json` 中有 `"plugin": ["opencode-aicodewith-auth"]`
|
|
152
|
-
* 修改配置后记得重启 OpenCode
|
|
153
|
-
|
|
154
109
|
---
|
|
155
110
|
|
|
156
111
|
## 开发
|
|
157
112
|
|
|
158
|
-
克隆并构建:
|
|
159
|
-
|
|
160
113
|
```bash
|
|
161
114
|
git clone https://github.com/DaneelOlivaw1/opencode-aicodewith-auth.git
|
|
162
115
|
cd opencode-aicodewith-auth
|
|
163
116
|
bun install
|
|
164
117
|
bun run build
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
类型检查:
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
118
|
bun run typecheck
|
|
171
119
|
```
|
|
172
120
|
|
|
173
|
-
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## File Index
|
|
174
124
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
125
|
+
| File | Role | Description |
|
|
126
|
+
|------|------|-------------|
|
|
127
|
+
| `index.ts` | **Entry** | Plugin main, auth hook, config auto-injection |
|
|
128
|
+
| `provider.ts` | **Core** | Multi-provider language model factory |
|
|
129
|
+
| `lib/` | **Library** | See [lib/ARCHITECTURE.md](lib/ARCHITECTURE.md) |
|
|
130
|
+
| `scripts/` | **Tooling** | See [scripts/ARCHITECTURE.md](scripts/ARCHITECTURE.md) |
|
|
178
131
|
|
|
179
132
|
---
|
|
180
133
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* @input OpenCode plugin context, auth credentials
|
|
4
|
+
* @output Auth hook, config injection, fetch interceptor
|
|
5
|
+
* @pos Plugin entry point - orchestrates auth and request routing
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + README.md file index
|
|
8
|
+
*/
|
|
1
9
|
import type { Plugin, PluginInput, Hooks } from "@opencode-ai/plugin";
|
|
2
10
|
import { type AicodewithProviderSettings } from "./provider";
|
|
3
11
|
export declare function createAicodewith(input: AicodewithProviderSettings | PluginInput): import("./provider").AicodewithProvider | Hooks;
|
package/dist/index.js
CHANGED
|
@@ -1003,13 +1003,14 @@ var PROVIDER_NPM = new URL(`./provider${PROVIDER_EXT}`, import.meta.url).href;
|
|
|
1003
1003
|
var DEFAULT_API = "https://api.openai.com/v1";
|
|
1004
1004
|
var DEFAULT_ENV = ["AICODEWITH_API_KEY"];
|
|
1005
1005
|
var DEFAULT_OUTPUT_TOKEN_MAX = 32000;
|
|
1006
|
-
var
|
|
1007
|
-
"gpt-5.2-codex",
|
|
1008
|
-
"gpt-5.2",
|
|
1009
|
-
"claude-sonnet-4-5-20250929",
|
|
1010
|
-
"claude-opus-4-5-20251101",
|
|
1011
|
-
"gemini-3-pro-high"
|
|
1012
|
-
|
|
1006
|
+
var MODEL_CONFIGS = {
|
|
1007
|
+
"gpt-5.2-codex": { name: "GPT-5.2 Codex" },
|
|
1008
|
+
"gpt-5.2": { name: "GPT-5.2" },
|
|
1009
|
+
"claude-sonnet-4-5-20250929": { name: "Claude Sonnet 4.5" },
|
|
1010
|
+
"claude-opus-4-5-20251101": { name: "Claude Opus 4.5" },
|
|
1011
|
+
"gemini-3-pro-high": { name: "Gemini 3 Pro" }
|
|
1012
|
+
};
|
|
1013
|
+
var ALLOWED_MODEL_IDS = Object.keys(MODEL_CONFIGS);
|
|
1013
1014
|
var ALLOWED_MODEL_SET = new Set(ALLOWED_MODEL_IDS);
|
|
1014
1015
|
var homeDir = process.env.OPENCODE_TEST_HOME || os.homedir();
|
|
1015
1016
|
var configRoot = process.env.XDG_CONFIG_HOME || path.join(homeDir, ".config");
|
|
@@ -1017,7 +1018,9 @@ var configDir = path.join(configRoot, "opencode");
|
|
|
1017
1018
|
var configPath = path.join(configDir, "opencode.json");
|
|
1018
1019
|
var ensureConfigPromise;
|
|
1019
1020
|
var toModelMap = (ids, existing = {}) => ids.reduce((acc, id) => {
|
|
1020
|
-
|
|
1021
|
+
const existingConfig = Object.prototype.hasOwnProperty.call(existing, id) ? existing[id] : {};
|
|
1022
|
+
const defaultConfig = MODEL_CONFIGS[id] ?? {};
|
|
1023
|
+
acc[id] = { ...defaultConfig, ...typeof existingConfig === "object" ? existingConfig : {} };
|
|
1021
1024
|
return acc;
|
|
1022
1025
|
}, {});
|
|
1023
1026
|
var readJson = async (filePath) => {
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file constants.ts
|
|
3
|
+
* @input -
|
|
4
|
+
* @output Global constants (URLs, header names, provider IDs)
|
|
5
|
+
* @pos Foundation - imported by most other modules
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
export declare const PLUGIN_NAME = "opencode-aicodewith-auth";
|
|
2
10
|
export declare const PROVIDER_ID = "aicodewith";
|
|
3
11
|
export declare const AUTH_METHOD_LABEL = "AICodewith API Key";
|
package/dist/lib/logger.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file logger.ts
|
|
3
|
+
* @input Log stage, data objects
|
|
4
|
+
* @output File logs (~/.opencode/logs/), console debug output
|
|
5
|
+
* @pos Utility - debug/request logging for development
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
export declare const LOGGING_ENABLED: boolean;
|
|
2
10
|
export declare const DEBUG_ENABLED: boolean;
|
|
3
11
|
export declare function logRequest(stage: string, data: Record<string, unknown>): void;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file codex-opencode-bridge.ts
|
|
3
|
+
* @input -
|
|
4
|
+
* @output CODEX_OPENCODE_BRIDGE constant (tool remapping rules)
|
|
5
|
+
* @pos Bridge layer - maps Codex tools to OpenCode equivalents
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/prompts/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
/**
|
|
2
10
|
* Codex-OpenCode Bridge Prompt
|
|
3
11
|
*
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file codex.ts
|
|
3
|
+
* @input Normalized model name
|
|
4
|
+
* @output Codex system prompt (fetched from GitHub, cached)
|
|
5
|
+
* @pos Prompt provider - fetches model-specific instructions from openai/codex repo
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/prompts/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
export type ModelFamily = "gpt-5.2-codex" | "codex-max" | "codex" | "gpt-5.2" | "gpt-5.1";
|
|
2
10
|
export declare function getModelFamily(normalizedModel: string): ModelFamily;
|
|
3
11
|
export declare function getCodexInstructions(normalizedModel?: string): Promise<string>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @file opencode-codex.ts
|
|
3
|
+
* @input -
|
|
4
|
+
* @output OpenCode's codex.txt prompt (for filtering duplicate system prompts)
|
|
5
|
+
* @pos Prompt fetcher - caches OpenCode's system prompt for comparison
|
|
3
6
|
*
|
|
4
|
-
*
|
|
5
|
-
* Uses ETag-based caching to efficiently track updates.
|
|
7
|
+
* 📌 On change: Update this header + lib/prompts/ARCHITECTURE.md
|
|
6
8
|
*/
|
|
7
9
|
/**
|
|
8
10
|
* Fetch OpenCode's codex.txt prompt with ETag-based caching
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file fetch-helpers.ts
|
|
3
|
+
* @input Raw request, API key, RequestInit
|
|
4
|
+
* @output Transformed headers, URL extraction, response handlers
|
|
5
|
+
* @pos Request layer entry - coordinates transformation and response handling
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/request/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
import type { RequestBody } from "../types";
|
|
2
10
|
export declare function extractRequestUrl(input: Request | string | URL): string;
|
|
3
11
|
export declare function transformRequestForCodex(init?: RequestInit): Promise<{
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file input-utils.ts
|
|
3
|
+
* @input InputItem[], cached OpenCode prompt
|
|
4
|
+
* @output Filtered InputItem[] (OpenCode prompts removed, orphaned outputs fixed)
|
|
5
|
+
* @pos Helper - message filtering and tool output normalization
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/request/helpers/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
import type { InputItem } from "../../types";
|
|
2
10
|
export declare const getContentText: (item: InputItem) => string;
|
|
3
11
|
export declare function isOpenCodeSystemPrompt(item: InputItem, cachedPrompt: string | null): boolean;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file model-map.ts
|
|
3
|
+
* @input Config model ID (e.g., "gpt-5.2-codex-high")
|
|
4
|
+
* @output Normalized API model name (e.g., "gpt-5.2-codex")
|
|
5
|
+
* @pos Helper - static model ID mapping for all supported variants
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/request/helpers/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
/**
|
|
2
10
|
* Model Configuration Map
|
|
3
11
|
*
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file request-transformer.ts
|
|
3
|
+
* @input RequestBody from OpenCode
|
|
4
|
+
* @output Transformed RequestBody for Codex API
|
|
5
|
+
* @pos Core transformation - model normalization, reasoning config, input filtering
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/request/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
import type { ConfigOptions, InputItem, ReasoningConfig, RequestBody } from "../types";
|
|
2
10
|
export declare function normalizeModel(model: string | undefined): string;
|
|
3
11
|
export declare function filterInput(input: InputItem[] | undefined): InputItem[] | undefined;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file response-handler.ts
|
|
3
|
+
* @input SSE Response stream
|
|
4
|
+
* @output JSON Response (for non-streaming) or passthrough (for streaming)
|
|
5
|
+
* @pos Response layer - SSE parsing and content-type handling
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/request/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
/**
|
|
2
10
|
* Convert SSE stream response to JSON for generateText()
|
|
3
11
|
* @param response - Fetch response with SSE stream
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file types.ts
|
|
3
|
+
* @input -
|
|
4
|
+
* @output TypeScript interfaces (RequestBody, InputItem, etc.)
|
|
5
|
+
* @pos Foundation - shared type definitions across lib/
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + lib/ARCHITECTURE.md
|
|
8
|
+
*/
|
|
1
9
|
export interface ConfigOptions {
|
|
2
10
|
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
3
11
|
reasoningSummary?: "auto" | "concise" | "detailed" | "off" | "on";
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file provider.ts
|
|
3
|
+
* @input Provider settings (apiKey, baseURL, headers)
|
|
4
|
+
* @output Multi-provider language model factory (OpenAI/Anthropic/Google)
|
|
5
|
+
* @pos Core provider - routes model requests to appropriate SDK
|
|
6
|
+
*
|
|
7
|
+
* 📌 On change: Update this header + README.md file index
|
|
8
|
+
*/
|
|
1
9
|
import type { LanguageModelV2 } from "@ai-sdk/provider";
|
|
2
10
|
import type { FetchFunction } from "@ai-sdk/provider-utils";
|
|
3
11
|
export type AicodewithProviderSettings = {
|
package/package.json
CHANGED