opencode-aicodewith-auth 0.1.26 → 0.1.29

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 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";
@@ -1604,48 +1545,37 @@ Restart OpenCode to apply.`,
1604
1545
  import { readFile as readFile2, writeFile as writeFile2, access } from "fs/promises";
1605
1546
  import path4 from "path";
1606
1547
  import os3 from "os";
1607
-
1608
- // lib/hooks/omo-config-sync/constants.ts
1609
- var AGENT_MODEL_MAP = {
1610
- sisyphus: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1611
- prometheus: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1612
- metis: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1613
- "OpenCode-Builder": `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1614
- build: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1615
- plan: `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1616
- oracle: `${PROVIDER_ID}/gpt-5.2`,
1617
- momus: `${PROVIDER_ID}/gpt-5.2`,
1618
- librarian: `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1619
- atlas: `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1620
- "sisyphus-junior": `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1621
- general: `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1622
- explore: `${PROVIDER_ID}/gemini-3-pro`,
1623
- "multimodal-looker": `${PROVIDER_ID}/gemini-3-pro`,
1624
- "frontend-ui-ux-engineer": `${PROVIDER_ID}/gemini-3-pro`,
1625
- "document-writer": `${PROVIDER_ID}/gemini-3-pro`
1626
- };
1627
- var CATEGORY_MODEL_MAP = {
1628
- "visual-engineering": `${PROVIDER_ID}/gemini-3-pro`,
1629
- visual: `${PROVIDER_ID}/gemini-3-pro`,
1630
- ultrabrain: `${PROVIDER_ID}/gpt-5.2`,
1631
- artistry: `${PROVIDER_ID}/gemini-3-pro`,
1632
- quick: `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1633
- "unspecified-low": `${PROVIDER_ID}/claude-sonnet-4-5-20250929`,
1634
- "unspecified-high": `${PROVIDER_ID}/claude-opus-4-5-20251101`,
1635
- writing: `${PROVIDER_ID}/gemini-3-pro`,
1636
- "business-logic": `${PROVIDER_ID}/gpt-5.2`,
1637
- "data-analysis": `${PROVIDER_ID}/claude-sonnet-4-5-20250929`
1638
- };
1548
+ var PACKAGE_NAME2 = "opencode-aicodewith-auth";
1549
+ var OMO_CONFIG_FILENAME = "oh-my-opencode.json";
1639
1550
  var DEFAULT_MODEL = `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1640
- var DEFAULT_CONFIG = {
1641
- $schema: "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json",
1642
- agents: Object.fromEntries(Object.entries(AGENT_MODEL_MAP).map(([name, model]) => [name, { model }])),
1643
- categories: Object.fromEntries(Object.entries(CATEGORY_MODEL_MAP).map(([name, model]) => [name, { model }]))
1551
+ var mapModelToAicodewith = (model) => {
1552
+ if (model.startsWith(`${PROVIDER_ID}/`)) {
1553
+ return model;
1554
+ }
1555
+ const lowerModel = model.toLowerCase();
1556
+ if (lowerModel.includes("codex")) {
1557
+ return `${PROVIDER_ID}/gpt-5.2-codex`;
1558
+ }
1559
+ if (lowerModel.includes("claude-opus") || lowerModel.includes("claude_opus")) {
1560
+ return `${PROVIDER_ID}/claude-opus-4-5-20251101`;
1561
+ }
1562
+ if (lowerModel.includes("claude-sonnet") || lowerModel.includes("claude_sonnet")) {
1563
+ return `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1564
+ }
1565
+ if (lowerModel.includes("claude-haiku") || lowerModel.includes("claude_haiku")) {
1566
+ return `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1567
+ }
1568
+ if (lowerModel.includes("claude")) {
1569
+ return `${PROVIDER_ID}/claude-sonnet-4-5-20250929`;
1570
+ }
1571
+ if (lowerModel.includes("gpt-") || lowerModel.includes("gpt_") || lowerModel.startsWith("openai/")) {
1572
+ return `${PROVIDER_ID}/gpt-5.2`;
1573
+ }
1574
+ if (lowerModel.includes("gemini") || lowerModel.startsWith("google/")) {
1575
+ return `${PROVIDER_ID}/gemini-3-pro`;
1576
+ }
1577
+ return DEFAULT_MODEL;
1644
1578
  };
1645
- var OMO_CONFIG_FILENAME = "oh-my-opencode.json";
1646
-
1647
- // lib/hooks/omo-config-sync/index.ts
1648
- var PACKAGE_NAME2 = "opencode-aicodewith-auth";
1649
1579
  var fileExists = async (filePath) => {
1650
1580
  try {
1651
1581
  await access(filePath);
@@ -1659,25 +1589,12 @@ var getOmoConfigPath = () => {
1659
1589
  const configRoot = process.env.XDG_CONFIG_HOME || path4.join(homeDir, ".config");
1660
1590
  return path4.join(configRoot, "opencode", OMO_CONFIG_FILENAME);
1661
1591
  };
1662
- var getDefaultModelForAgent = (agentName) => {
1663
- return AGENT_MODEL_MAP[agentName] || DEFAULT_MODEL;
1664
- };
1665
- var getDefaultModelForCategory = (categoryName) => {
1666
- return CATEGORY_MODEL_MAP[categoryName] || DEFAULT_MODEL;
1667
- };
1668
1592
  var syncOmoConfig = async () => {
1669
1593
  const configPath = getOmoConfigPath();
1670
- let config;
1671
1594
  if (!await fileExists(configPath)) {
1672
- config = DEFAULT_CONFIG;
1673
- try {
1674
- await writeFile2(configPath, `${JSON.stringify(config, null, 2)}
1675
- `, "utf-8");
1676
- } catch (error) {
1677
- console.warn(`[${PACKAGE_NAME2}] Failed to create OMO config: ${error instanceof Error ? error.message : error}`);
1678
- }
1679
1595
  return;
1680
1596
  }
1597
+ let config;
1681
1598
  try {
1682
1599
  const content = await readFile2(configPath, "utf-8");
1683
1600
  config = JSON.parse(content);
@@ -1689,18 +1606,24 @@ var syncOmoConfig = async () => {
1689
1606
  }
1690
1607
  let changed = false;
1691
1608
  if (config.agents && typeof config.agents === "object") {
1692
- for (const [agentName, agentConfig] of Object.entries(config.agents)) {
1693
- if (!agentConfig.model) {
1694
- agentConfig.model = getDefaultModelForAgent(agentName);
1695
- changed = true;
1609
+ for (const [_agentName, agentConfig] of Object.entries(config.agents)) {
1610
+ if (agentConfig.model && !agentConfig.model.startsWith(`${PROVIDER_ID}/`)) {
1611
+ const mappedModel = mapModelToAicodewith(agentConfig.model);
1612
+ if (mappedModel !== agentConfig.model) {
1613
+ agentConfig.model = mappedModel;
1614
+ changed = true;
1615
+ }
1696
1616
  }
1697
1617
  }
1698
1618
  }
1699
1619
  if (config.categories && typeof config.categories === "object") {
1700
- for (const [categoryName, categoryConfig] of Object.entries(config.categories)) {
1701
- if (!categoryConfig.model) {
1702
- categoryConfig.model = getDefaultModelForCategory(categoryName);
1703
- changed = true;
1620
+ for (const [_categoryName, categoryConfig] of Object.entries(config.categories)) {
1621
+ if (categoryConfig.model && !categoryConfig.model.startsWith(`${PROVIDER_ID}/`)) {
1622
+ const mappedModel = mapModelToAicodewith(categoryConfig.model);
1623
+ if (mappedModel !== categoryConfig.model) {
1624
+ categoryConfig.model = mappedModel;
1625
+ changed = true;
1626
+ }
1704
1627
  }
1705
1628
  }
1706
1629
  }
@@ -1870,16 +1793,6 @@ var ensureConfigFile = async () => {
1870
1793
  })();
1871
1794
  return ensureConfigPromise;
1872
1795
  };
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
1796
  var parseRequestBody = (init) => {
1884
1797
  if (!init?.body || typeof init.body !== "string") {
1885
1798
  return { body: undefined, model: undefined, isStreaming: false };
@@ -2098,6 +2011,5 @@ var AicodewithCodexAuthPlugin = async (ctx) => {
2098
2011
  var opencode_aicodewith_auth_default = AicodewithCodexAuthPlugin;
2099
2012
  export {
2100
2013
  opencode_aicodewith_auth_default as default,
2101
- createAicodewith2 as createAicodewith,
2102
2014
  AicodewithCodexAuthPlugin
2103
2015
  };
package/dist/provider.js CHANGED
@@ -56,8 +56,6 @@ function createAicodewith(options = {}) {
56
56
  };
57
57
  return provider;
58
58
  }
59
- var aicodewith = createAicodewith();
60
59
  export {
61
- createAicodewith,
62
- aicodewith
60
+ createAicodewith
63
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-aicodewith-auth",
3
- "version": "0.1.26",
3
+ "version": "0.1.29",
4
4
  "description": "OpenCode plugin for AICodewith authentication - Access GPT-5.2, Claude, and Gemini models through AICodewith API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",