opencode-catpaw-auth 1.3.0 → 1.3.1
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/dist/src/constants.d.ts +0 -8
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +0 -8
- package/dist/src/plugin.d.ts +3 -4
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +20 -38
- package/dist/src/request.d.ts +2 -2
- package/dist/src/request.d.ts.map +1 -1
- package/dist/src/request.js +4 -13
- package/package.json +1 -1
package/dist/src/constants.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Constants for Catpaw Auth plugin
|
|
3
3
|
*/
|
|
4
|
-
/**
|
|
5
|
-
* Provider identifier for Catpaw/Quotio
|
|
6
|
-
*/
|
|
7
|
-
export declare const CATPAW_PROVIDER_ID = "quotio";
|
|
8
|
-
/**
|
|
9
|
-
* Default base URL for Quotio API
|
|
10
|
-
*/
|
|
11
|
-
export declare const QUOTIO_DEFAULT_BASE_URL = "http://127.0.0.1:8317/v1";
|
|
12
4
|
/**
|
|
13
5
|
* Anthropic API version header
|
|
14
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC"}
|
package/dist/src/constants.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Constants for Catpaw Auth plugin
|
|
3
3
|
*/
|
|
4
|
-
/**
|
|
5
|
-
* Provider identifier for Catpaw/Quotio
|
|
6
|
-
*/
|
|
7
|
-
export const CATPAW_PROVIDER_ID = "quotio";
|
|
8
|
-
/**
|
|
9
|
-
* Default base URL for Quotio API
|
|
10
|
-
*/
|
|
11
|
-
export const QUOTIO_DEFAULT_BASE_URL = "http://127.0.0.1:8317/v1";
|
|
12
4
|
/**
|
|
13
5
|
* Anthropic API version header
|
|
14
6
|
*/
|
package/dist/src/plugin.d.ts
CHANGED
|
@@ -3,11 +3,10 @@ export declare const CATPAW_PROVIDER_ID = "anthropic";
|
|
|
3
3
|
/**
|
|
4
4
|
* CatPaw Anthropic Proxy Plugin for OpenCode
|
|
5
5
|
*
|
|
6
|
-
* This plugin
|
|
6
|
+
* This plugin provides automatic authentication for mcli.sankuai.com:
|
|
7
7
|
* 1. Loads API key from ~/.config/mcopilot-cli/.config.yaml
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
* 4. Supports streaming responses
|
|
8
|
+
* 2. Injects auth headers to requests to https://mcli.sankuai.com
|
|
9
|
+
* 3. Supports streaming responses
|
|
11
10
|
*/
|
|
12
11
|
declare const plugin: Plugin;
|
|
13
12
|
export default plugin;
|
package/dist/src/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAgC,MAAM,qBAAqB,CAAC;AAKhF,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAgC,MAAM,qBAAqB,CAAC;AAKhF,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C;;;;;;;GAOG;AACH,QAAA,MAAM,MAAM,EAAE,MAoFb,CAAC;AAEF,eAAe,MAAM,CAAC;AACtB,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,CAAC"}
|
package/dist/src/plugin.js
CHANGED
|
@@ -4,62 +4,47 @@ export const CATPAW_PROVIDER_ID = "anthropic";
|
|
|
4
4
|
/**
|
|
5
5
|
* CatPaw Anthropic Proxy Plugin for OpenCode
|
|
6
6
|
*
|
|
7
|
-
* This plugin
|
|
7
|
+
* This plugin provides automatic authentication for mcli.sankuai.com:
|
|
8
8
|
* 1. Loads API key from ~/.config/mcopilot-cli/.config.yaml
|
|
9
|
-
* 2.
|
|
10
|
-
* 3.
|
|
11
|
-
* 4. Supports streaming responses
|
|
9
|
+
* 2. Injects auth headers to requests to https://mcli.sankuai.com
|
|
10
|
+
* 3. Supports streaming responses
|
|
12
11
|
*/
|
|
13
|
-
const plugin = async ({ client
|
|
14
|
-
// 预加载配置
|
|
12
|
+
const plugin = async ({ client }) => {
|
|
15
13
|
const apiKey = await loadApiKeyFromConfig();
|
|
16
14
|
const workingDir = getWorkingDir();
|
|
17
|
-
if (!apiKey) {
|
|
18
|
-
client.app.log({
|
|
19
|
-
body: {
|
|
20
|
-
service: "catpaw-auth",
|
|
21
|
-
level: "error",
|
|
22
|
-
message: "Failed to load API key from ~/.config/mcopilot-cli/.config.yaml",
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
client.app.log({
|
|
28
|
-
body: {
|
|
29
|
-
service: "catpaw-auth",
|
|
30
|
-
level: "info",
|
|
31
|
-
message: "CatPaw proxy loaded successfully",
|
|
32
|
-
extra: { workingDir, apiKeyPrefix: apiKey.slice(0, 8) + "..." },
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
15
|
return {
|
|
37
16
|
config: async (config) => {
|
|
38
|
-
// 配置 anthropic provider,指向本地代理
|
|
39
17
|
config.provider = config.provider || {};
|
|
40
18
|
config.provider[CATPAW_PROVIDER_ID] = {
|
|
41
19
|
npm: "@ai-sdk/anthropic",
|
|
42
20
|
name: "CatPaw Anthropic Proxy",
|
|
43
21
|
options: {
|
|
44
|
-
baseURL: "
|
|
22
|
+
baseURL: "https://mcli.sankuai.com/v1",
|
|
45
23
|
},
|
|
46
24
|
models: {
|
|
47
|
-
"
|
|
48
|
-
name: "
|
|
25
|
+
"kimi-k2.5": {
|
|
26
|
+
name: "Kimi K2.5",
|
|
27
|
+
limit: {
|
|
28
|
+
context: 200000,
|
|
29
|
+
output: 64000,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
"glm-5": {
|
|
33
|
+
name: "GLM-5",
|
|
49
34
|
limit: {
|
|
50
35
|
context: 200000,
|
|
51
|
-
output:
|
|
36
|
+
output: 64000,
|
|
52
37
|
},
|
|
53
38
|
},
|
|
54
|
-
"
|
|
55
|
-
name: "
|
|
39
|
+
"MiniMax-M2.5": {
|
|
40
|
+
name: "MiniMax M2.5",
|
|
56
41
|
limit: {
|
|
57
42
|
context: 200000,
|
|
58
43
|
output: 64000,
|
|
59
44
|
},
|
|
60
45
|
},
|
|
61
|
-
"claude-
|
|
62
|
-
name: "Claude
|
|
46
|
+
"claude-sonnet-4.5": {
|
|
47
|
+
name: "Claude Sonnet 4.5",
|
|
63
48
|
limit: {
|
|
64
49
|
context: 200000,
|
|
65
50
|
output: 64000,
|
|
@@ -72,18 +57,15 @@ const plugin = async ({ client, }) => {
|
|
|
72
57
|
provider: CATPAW_PROVIDER_ID,
|
|
73
58
|
loader: async (getAuth, provider) => {
|
|
74
59
|
return {
|
|
75
|
-
apiKey: "dummy-key",
|
|
60
|
+
apiKey: "dummy-key",
|
|
76
61
|
async fetch(input, init) {
|
|
77
|
-
// 检查是否是目标请求(发送到 localhost:2819)
|
|
78
62
|
if (!isTargetRequest(input)) {
|
|
79
63
|
return fetch(input, init);
|
|
80
64
|
}
|
|
81
65
|
if (!apiKey) {
|
|
82
66
|
throw new Error("CatPaw API key not loaded. Check ~/.config/mcopilot-cli/.config.yaml");
|
|
83
67
|
}
|
|
84
|
-
// 准备代理请求,转发到目标服务器
|
|
85
68
|
const { request, init: requestInit } = prepareProxyRequest(input, init, apiKey, workingDir);
|
|
86
|
-
// 发送请求
|
|
87
69
|
return fetch(request, requestInit);
|
|
88
70
|
},
|
|
89
71
|
};
|
package/dist/src/request.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 检查请求是否是发送到目标服务器的请求
|
|
3
3
|
*/
|
|
4
4
|
export declare function isTargetRequest(input: RequestInfo | URL | string): boolean;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* 准备代理请求,注入认证 headers
|
|
7
7
|
*/
|
|
8
8
|
export declare function prepareProxyRequest(input: RequestInfo | URL | string, init: RequestInit | undefined, apiKey: string, workingDir: string): {
|
|
9
9
|
request: RequestInfo | URL | string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,GAAG,MAAM,GAAG,OAAO,CAQ1E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,GAAG,GAAG,GAAG,MAAM,EACjC,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB;IAAE,OAAO,EAAE,WAAW,GAAG,GAAG,GAAG,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CA2B5D"}
|
package/dist/src/request.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const TARGET_BASE_URL = "https://mcli.sankuai.com";
|
|
2
|
-
const PROXY_HOST = "127.0.0.1:2819";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* 检查请求是否是发送到目标服务器的请求
|
|
5
4
|
*/
|
|
6
5
|
export function isTargetRequest(input) {
|
|
7
6
|
const url = typeof input === "string"
|
|
@@ -9,20 +8,12 @@ export function isTargetRequest(input) {
|
|
|
9
8
|
: input instanceof URL
|
|
10
9
|
? input.toString()
|
|
11
10
|
: input.url;
|
|
12
|
-
return url.includes(
|
|
11
|
+
return url.includes(TARGET_BASE_URL);
|
|
13
12
|
}
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* 准备代理请求,注入认证 headers
|
|
16
15
|
*/
|
|
17
16
|
export function prepareProxyRequest(input, init, apiKey, workingDir) {
|
|
18
|
-
// 解析原始 URL
|
|
19
|
-
const originalUrl = typeof input === "string"
|
|
20
|
-
? input
|
|
21
|
-
: input instanceof URL
|
|
22
|
-
? input.toString()
|
|
23
|
-
: input.url;
|
|
24
|
-
// 将 localhost:2819 替换为目标服务器
|
|
25
|
-
const targetUrl = originalUrl.replace(/http:\/\/127\.0\.0\.1:2819/, TARGET_BASE_URL);
|
|
26
17
|
// 准备 headers
|
|
27
18
|
const headers = new Headers(init?.headers);
|
|
28
19
|
// 移除可能冲突的 headers
|
|
@@ -41,7 +32,7 @@ export function prepareProxyRequest(input, init, apiKey, workingDir) {
|
|
|
41
32
|
headers,
|
|
42
33
|
};
|
|
43
34
|
return {
|
|
44
|
-
request:
|
|
35
|
+
request: input,
|
|
45
36
|
init: requestInit,
|
|
46
37
|
};
|
|
47
38
|
}
|