opencode-aicodewith-auth 0.1.17 → 0.1.18
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.md +2 -2
- package/dist/index.js +34 -3
- package/dist/lib/request/claude-tools-transform.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,8 +63,8 @@ User Request → OpenCode → Plugin Auth Hook → Route by Model:
|
|
|
63
63
|
|---------|---------|:-------:|---------|
|
|
64
64
|
| `aicodewith/gpt-5.2-codex` | GPT-5.2 Codex | ✅ | 日常编程、代码生成 |
|
|
65
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 | ✅ | 复杂任务、深度思考 |
|
|
66
|
+
| `aicodewith/claude-sonnet-4-5-20250929` | Claude Sonnet 4.5 | ✅ | 代码审查、文档查询 |
|
|
67
|
+
| `aicodewith/claude-opus-4-5-20251101` | Claude Opus 4.5 | ✅ | 复杂任务、深度思考 |
|
|
68
68
|
| `aicodewith/gemini-3-pro` | Gemini 3 Pro | ✅ | 前端 UI、多模态任务 |
|
|
69
69
|
|
|
70
70
|
---
|
package/dist/index.js
CHANGED
|
@@ -1026,6 +1026,7 @@ async function handleSuccessResponse(response, isStreaming) {
|
|
|
1026
1026
|
|
|
1027
1027
|
// lib/request/claude-tools-transform.ts
|
|
1028
1028
|
var TOOL_PREFIX = "mcp_";
|
|
1029
|
+
var CLAUDE_USER_ID = "user_7b18c0b8358639d7ff4cdbf78a1552a7d5ca63ba83aee236c4b22ae2be77ba5f_account_3bb3dcbe-4efe-4795-b248-b73603575290_session_4a72737c-93d6-4c45-aebe-6e2d47281338";
|
|
1029
1030
|
function transformClaudeRequest(init) {
|
|
1030
1031
|
if (!init?.body || typeof init.body !== "string") {
|
|
1031
1032
|
return init;
|
|
@@ -1033,6 +1034,13 @@ function transformClaudeRequest(init) {
|
|
|
1033
1034
|
try {
|
|
1034
1035
|
const parsed = JSON.parse(init.body);
|
|
1035
1036
|
let modified = false;
|
|
1037
|
+
if (!parsed.metadata) {
|
|
1038
|
+
parsed.metadata = {};
|
|
1039
|
+
}
|
|
1040
|
+
if (!parsed.metadata.user_id) {
|
|
1041
|
+
parsed.metadata.user_id = CLAUDE_USER_ID;
|
|
1042
|
+
modified = true;
|
|
1043
|
+
}
|
|
1036
1044
|
if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
1037
1045
|
parsed.tools = parsed.tools.map((tool) => {
|
|
1038
1046
|
if (tool.name) {
|
|
@@ -1351,6 +1359,26 @@ async function getLatestVersion() {
|
|
|
1351
1359
|
clearTimeout(timeoutId);
|
|
1352
1360
|
}
|
|
1353
1361
|
}
|
|
1362
|
+
var OH_MY_OPENCODE = "oh-my-opencode";
|
|
1363
|
+
function hasOhMyOpencode(directory) {
|
|
1364
|
+
for (const configPath of getConfigPaths(directory)) {
|
|
1365
|
+
try {
|
|
1366
|
+
if (!fs2.existsSync(configPath))
|
|
1367
|
+
continue;
|
|
1368
|
+
const content = fs2.readFileSync(configPath, "utf-8");
|
|
1369
|
+
const config = JSON.parse(stripJsonComments(content));
|
|
1370
|
+
const plugins = config.plugin ?? [];
|
|
1371
|
+
for (const entry of plugins) {
|
|
1372
|
+
if (entry === OH_MY_OPENCODE || entry.startsWith(`${OH_MY_OPENCODE}@`) || entry.includes(OH_MY_OPENCODE)) {
|
|
1373
|
+
return true;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
} catch {
|
|
1377
|
+
continue;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return false;
|
|
1381
|
+
}
|
|
1354
1382
|
|
|
1355
1383
|
// lib/hooks/auto-update/cache.ts
|
|
1356
1384
|
import * as fs3 from "fs";
|
|
@@ -1420,7 +1448,8 @@ function invalidatePackage(packageName = PACKAGE_NAME) {
|
|
|
1420
1448
|
// lib/hooks/auto-update/index.ts
|
|
1421
1449
|
var DISPLAY_NAME = "AICodewith";
|
|
1422
1450
|
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1423
|
-
var
|
|
1451
|
+
var STARTUP_TOAST_DELAY_WITH_OMO = 6000;
|
|
1452
|
+
var STARTUP_TOAST_DELAY_WITHOUT_OMO = 0;
|
|
1424
1453
|
function createAutoUpdateHook(ctx, options = {}) {
|
|
1425
1454
|
const { autoUpdate = true, showStartupToast = true } = options;
|
|
1426
1455
|
let hasChecked = false;
|
|
@@ -1437,11 +1466,13 @@ function createAutoUpdateHook(ctx, options = {}) {
|
|
|
1437
1466
|
const cachedVersion = getCachedVersion();
|
|
1438
1467
|
const localDevVersion = getLocalDevVersion(ctx.directory);
|
|
1439
1468
|
const displayVersion = localDevVersion ?? cachedVersion ?? "unknown";
|
|
1469
|
+
const hasOmo = hasOhMyOpencode(ctx.directory);
|
|
1470
|
+
const startupDelay = hasOmo ? STARTUP_TOAST_DELAY_WITH_OMO : STARTUP_TOAST_DELAY_WITHOUT_OMO;
|
|
1440
1471
|
if (localDevVersion) {
|
|
1441
1472
|
if (showStartupToast) {
|
|
1442
1473
|
setTimeout(() => {
|
|
1443
1474
|
showStartupToastWithSpinner(ctx, `${displayVersion} (dev)`, "Local development mode").catch(() => {});
|
|
1444
|
-
},
|
|
1475
|
+
}, startupDelay);
|
|
1445
1476
|
}
|
|
1446
1477
|
log("Local development mode, skipping update check");
|
|
1447
1478
|
return;
|
|
@@ -1449,7 +1480,7 @@ function createAutoUpdateHook(ctx, options = {}) {
|
|
|
1449
1480
|
if (showStartupToast) {
|
|
1450
1481
|
setTimeout(() => {
|
|
1451
1482
|
showStartupToastWithSpinner(ctx, displayVersion, "GPT-5.2 \xB7 Claude \xB7 Gemini").catch(() => {});
|
|
1452
|
-
},
|
|
1483
|
+
}, startupDelay);
|
|
1453
1484
|
}
|
|
1454
1485
|
runBackgroundUpdateCheck(ctx, autoUpdate).catch((err) => {
|
|
1455
1486
|
log("Background update check failed:", err);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file claude-tools-transform.ts
|
|
3
3
|
* @input Claude API request body and response
|
|
4
|
-
* @output Transformed request/response with mcp_ prefix handling
|
|
4
|
+
* @output Transformed request/response with mcp_ prefix handling and metadata
|
|
5
5
|
* @pos Handles tool name transformation to bypass Claude Code OAuth restrictions
|
|
6
6
|
*
|
|
7
7
|
* 📌 On change: Update this header + lib/request/ARCHITECTURE.md
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* Transform Claude API request to add mcp_ prefix to tool names
|
|
10
|
+
* Transform Claude API request to add mcp_ prefix to tool names and inject user_id metadata
|
|
11
11
|
* This bypasses the "This credential is only authorized for use with Claude Code" error
|
|
12
12
|
*/
|
|
13
13
|
export declare function transformClaudeRequest(init?: RequestInit): RequestInit | undefined;
|
package/package.json
CHANGED