opencode-aicodewith-auth 0.1.26 → 0.1.27
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/index.js +0 -70
- package/dist/provider.js +1 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,63 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// provider.ts
|
|
3
|
-
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
4
|
-
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
5
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
6
|
-
var isClaude = (modelId) => modelId.startsWith("claude-");
|
|
7
|
-
var isGemini = (modelId) => modelId.startsWith("gemini-");
|
|
8
|
-
var isResponses = (modelId) => modelId.startsWith("gpt-") || modelId.startsWith("codex");
|
|
9
|
-
var normalizeModelId = (modelId) => String(modelId).trim();
|
|
10
|
-
function createAicodewith(options = {}) {
|
|
11
|
-
const openai = createOpenAI({
|
|
12
|
-
apiKey: options.apiKey,
|
|
13
|
-
baseURL: options.baseURL,
|
|
14
|
-
headers: options.headers,
|
|
15
|
-
fetch: options.fetch
|
|
16
|
-
});
|
|
17
|
-
const openaiLanguageModel = typeof openai.languageModel === "function" ? openai.languageModel : openai.chat;
|
|
18
|
-
const openaiChatModel = typeof openai.chat === "function" ? openai.chat : openaiLanguageModel;
|
|
19
|
-
const anthropic = createAnthropic({
|
|
20
|
-
apiKey: options.anthropic?.apiKey ?? options.apiKey,
|
|
21
|
-
baseURL: options.anthropic?.baseURL,
|
|
22
|
-
headers: options.anthropic?.headers ?? options.headers,
|
|
23
|
-
fetch: options.fetch
|
|
24
|
-
});
|
|
25
|
-
const google = createGoogleGenerativeAI({
|
|
26
|
-
apiKey: options.google?.apiKey ?? options.apiKey,
|
|
27
|
-
baseURL: options.google?.baseURL,
|
|
28
|
-
headers: options.google?.headers ?? options.headers,
|
|
29
|
-
fetch: options.fetch
|
|
30
|
-
});
|
|
31
|
-
const createModel = (modelId) => {
|
|
32
|
-
const id = normalizeModelId(modelId);
|
|
33
|
-
if (isClaude(id))
|
|
34
|
-
return anthropic.languageModel(id);
|
|
35
|
-
if (isGemini(id))
|
|
36
|
-
return google.languageModel(id);
|
|
37
|
-
if (isResponses(id) && typeof openai.responses === "function")
|
|
38
|
-
return openai.responses(id);
|
|
39
|
-
return openaiLanguageModel(id);
|
|
40
|
-
};
|
|
41
|
-
const provider = (modelId) => createModel(modelId);
|
|
42
|
-
provider.languageModel = createModel;
|
|
43
|
-
provider.chat = (modelId) => {
|
|
44
|
-
const id = normalizeModelId(modelId);
|
|
45
|
-
if (isClaude(id))
|
|
46
|
-
return anthropic.languageModel(id);
|
|
47
|
-
if (isGemini(id))
|
|
48
|
-
return google.languageModel(id);
|
|
49
|
-
return openaiChatModel(id);
|
|
50
|
-
};
|
|
51
|
-
provider.responses = (modelId) => {
|
|
52
|
-
const id = normalizeModelId(modelId);
|
|
53
|
-
if (isClaude(id) || isGemini(id))
|
|
54
|
-
return provider.chat(id);
|
|
55
|
-
return openai.responses(id);
|
|
56
|
-
};
|
|
57
|
-
return provider;
|
|
58
|
-
}
|
|
59
|
-
var aicodewith = createAicodewith();
|
|
60
|
-
|
|
61
2
|
// index.ts
|
|
62
3
|
import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile3, access as access2 } from "fs/promises";
|
|
63
4
|
import path5 from "path";
|
|
@@ -1870,16 +1811,6 @@ var ensureConfigFile = async () => {
|
|
|
1870
1811
|
})();
|
|
1871
1812
|
return ensureConfigPromise;
|
|
1872
1813
|
};
|
|
1873
|
-
var isPluginInput = (input) => {
|
|
1874
|
-
if (!input || typeof input !== "object")
|
|
1875
|
-
return false;
|
|
1876
|
-
return "client" in input && "project" in input && "directory" in input;
|
|
1877
|
-
};
|
|
1878
|
-
function createAicodewith2(input) {
|
|
1879
|
-
if (isPluginInput(input))
|
|
1880
|
-
return {};
|
|
1881
|
-
return createAicodewith(input);
|
|
1882
|
-
}
|
|
1883
1814
|
var parseRequestBody = (init) => {
|
|
1884
1815
|
if (!init?.body || typeof init.body !== "string") {
|
|
1885
1816
|
return { body: undefined, model: undefined, isStreaming: false };
|
|
@@ -2098,6 +2029,5 @@ var AicodewithCodexAuthPlugin = async (ctx) => {
|
|
|
2098
2029
|
var opencode_aicodewith_auth_default = AicodewithCodexAuthPlugin;
|
|
2099
2030
|
export {
|
|
2100
2031
|
opencode_aicodewith_auth_default as default,
|
|
2101
|
-
createAicodewith2 as createAicodewith,
|
|
2102
2032
|
AicodewithCodexAuthPlugin
|
|
2103
2033
|
};
|
package/dist/provider.js
CHANGED
package/package.json
CHANGED