opencode-aicodewith-auth 0.1.25 → 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 +17 -75
- 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";
|
|
@@ -1637,6 +1578,11 @@ var CATEGORY_MODEL_MAP = {
|
|
|
1637
1578
|
"data-analysis": `${PROVIDER_ID}/claude-sonnet-4-5-20250929`
|
|
1638
1579
|
};
|
|
1639
1580
|
var DEFAULT_MODEL = `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
|
|
1581
|
+
var DEFAULT_CONFIG = {
|
|
1582
|
+
$schema: "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json",
|
|
1583
|
+
agents: Object.fromEntries(Object.entries(AGENT_MODEL_MAP).map(([name, model]) => [name, { model }])),
|
|
1584
|
+
categories: Object.fromEntries(Object.entries(CATEGORY_MODEL_MAP).map(([name, model]) => [name, { model }]))
|
|
1585
|
+
};
|
|
1640
1586
|
var OMO_CONFIG_FILENAME = "oh-my-opencode.json";
|
|
1641
1587
|
|
|
1642
1588
|
// lib/hooks/omo-config-sync/index.ts
|
|
@@ -1662,10 +1608,17 @@ var getDefaultModelForCategory = (categoryName) => {
|
|
|
1662
1608
|
};
|
|
1663
1609
|
var syncOmoConfig = async () => {
|
|
1664
1610
|
const configPath = getOmoConfigPath();
|
|
1611
|
+
let config;
|
|
1665
1612
|
if (!await fileExists(configPath)) {
|
|
1613
|
+
config = DEFAULT_CONFIG;
|
|
1614
|
+
try {
|
|
1615
|
+
await writeFile2(configPath, `${JSON.stringify(config, null, 2)}
|
|
1616
|
+
`, "utf-8");
|
|
1617
|
+
} catch (error) {
|
|
1618
|
+
console.warn(`[${PACKAGE_NAME2}] Failed to create OMO config: ${error instanceof Error ? error.message : error}`);
|
|
1619
|
+
}
|
|
1666
1620
|
return;
|
|
1667
1621
|
}
|
|
1668
|
-
let config;
|
|
1669
1622
|
try {
|
|
1670
1623
|
const content = await readFile2(configPath, "utf-8");
|
|
1671
1624
|
config = JSON.parse(content);
|
|
@@ -1858,16 +1811,6 @@ var ensureConfigFile = async () => {
|
|
|
1858
1811
|
})();
|
|
1859
1812
|
return ensureConfigPromise;
|
|
1860
1813
|
};
|
|
1861
|
-
var isPluginInput = (input) => {
|
|
1862
|
-
if (!input || typeof input !== "object")
|
|
1863
|
-
return false;
|
|
1864
|
-
return "client" in input && "project" in input && "directory" in input;
|
|
1865
|
-
};
|
|
1866
|
-
function createAicodewith2(input) {
|
|
1867
|
-
if (isPluginInput(input))
|
|
1868
|
-
return {};
|
|
1869
|
-
return createAicodewith(input);
|
|
1870
|
-
}
|
|
1871
1814
|
var parseRequestBody = (init) => {
|
|
1872
1815
|
if (!init?.body || typeof init.body !== "string") {
|
|
1873
1816
|
return { body: undefined, model: undefined, isStreaming: false };
|
|
@@ -1966,12 +1909,12 @@ var getOutputTokenLimit = (input, output) => {
|
|
|
1966
1909
|
return DEFAULT_OUTPUT_TOKEN_MAX;
|
|
1967
1910
|
};
|
|
1968
1911
|
var AicodewithCodexAuthPlugin = async (ctx) => {
|
|
1969
|
-
await
|
|
1970
|
-
ensureConfigFile(),
|
|
1971
|
-
syncOmoConfig()
|
|
1972
|
-
]).catch((error) => {
|
|
1912
|
+
await ensureConfigFile().catch((error) => {
|
|
1973
1913
|
console.warn(`[${PACKAGE_NAME3}] Failed to update config: ${error instanceof Error ? error.message : error}`);
|
|
1974
1914
|
});
|
|
1915
|
+
syncOmoConfig().catch((error) => {
|
|
1916
|
+
console.warn(`[${PACKAGE_NAME3}] Failed to sync OMO config: ${error instanceof Error ? error.message : error}`);
|
|
1917
|
+
});
|
|
1975
1918
|
const autoUpdateHook = createAutoUpdateHook(ctx, { autoUpdate: true });
|
|
1976
1919
|
const authHook = {
|
|
1977
1920
|
provider: PROVIDER_ID,
|
|
@@ -2086,6 +2029,5 @@ var AicodewithCodexAuthPlugin = async (ctx) => {
|
|
|
2086
2029
|
var opencode_aicodewith_auth_default = AicodewithCodexAuthPlugin;
|
|
2087
2030
|
export {
|
|
2088
2031
|
opencode_aicodewith_auth_default as default,
|
|
2089
|
-
createAicodewith2 as createAicodewith,
|
|
2090
2032
|
AicodewithCodexAuthPlugin
|
|
2091
2033
|
};
|
package/dist/provider.js
CHANGED
package/package.json
CHANGED