xling 0.9.1 → 0.9.2

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.
Files changed (46) hide show
  1. package/dist/{base-CbaByk6Y.d.ts → base-B7_Wl7Tj.d.ts} +2 -2
  2. package/dist/{base-C2-JqowN.d.ts → base-BzTpaH-G.d.ts} +2 -2
  3. package/dist/codex-oiTfloLj.js +1 -0
  4. package/dist/commands/proxy/index.js +1 -1
  5. package/dist/commands/settings/auth.js +3 -3
  6. package/dist/commands/settings/get.js +1 -1
  7. package/dist/commands/settings/inspect.js +1 -1
  8. package/dist/commands/settings/list.js +1 -1
  9. package/dist/commands/settings/set.d.ts +1 -1
  10. package/dist/commands/settings/set.js +6 -3
  11. package/dist/commands/settings/switch.js +1 -1
  12. package/dist/commands/settings/sync.js +6 -5
  13. package/dist/commands/version/index.js +1 -1
  14. package/dist/{dispatcher-Ck97HDr8.js → dispatcher-GQ0DcyYr.js} +1 -1
  15. package/dist/domain/interfaces.d.ts +2 -2
  16. package/dist/domain/types.d.ts +2 -2
  17. package/dist/domain/validators.d.ts +1 -1
  18. package/dist/{interfaces-CtOhRZzC.d.ts → interfaces-BlM-_HAC.d.ts} +1 -1
  19. package/dist/server-tc_ROnwq.js +1 -0
  20. package/dist/services/launch/adapters/base.d.ts +3 -3
  21. package/dist/services/launch/adapters/claude.d.ts +3 -3
  22. package/dist/services/launch/adapters/codex.d.ts +3 -3
  23. package/dist/services/launch/adapters/gemini.d.ts +3 -3
  24. package/dist/services/launch/dispatcher.d.ts +2 -2
  25. package/dist/services/proxy/index.js +1 -1
  26. package/dist/services/proxy/server.js +1 -1
  27. package/dist/services/settings/adapters/base.d.ts +3 -3
  28. package/dist/services/settings/adapters/claude.d.ts +3 -3
  29. package/dist/services/settings/adapters/codex.d.ts +4 -3
  30. package/dist/services/settings/adapters/codex.js +1 -1
  31. package/dist/services/settings/adapters/gemini.d.ts +3 -3
  32. package/dist/services/settings/adapters/xling.d.ts +3 -3
  33. package/dist/services/settings/dispatcher.d.ts +2 -2
  34. package/dist/services/settings/dispatcher.js +1 -1
  35. package/dist/services/settings/fsStore.d.ts +1 -1
  36. package/dist/services/settings/sync.d.ts +5 -2
  37. package/dist/services/settings/sync.js +1 -1
  38. package/dist/services/settings/templates/claudeDefault.d.ts +1 -1
  39. package/dist/sync-F4vZCogY.js +1 -0
  40. package/dist/{types-vDRpkfsj.d.ts → types-QfiJTz-B.d.ts} +9 -1
  41. package/dist/utils/format.d.ts +1 -1
  42. package/dist/utils/runner.d.ts +1 -1
  43. package/package.json +1 -1
  44. package/dist/codex-B7IedjUS.js +0 -1
  45. package/dist/server-Cymednu2.js +0 -1
  46. package/dist/sync-C39sJRnz.js +0 -1
@@ -1,5 +1,5 @@
1
- import { f as SettingsListData, g as ToolId, h as SwitchOptions, i as InspectResult, l as Scope, m as SettingsResult, r as EditOptions, t as ConfigObject } from "./types-vDRpkfsj.js";
2
- import { n as SettingsAdapter } from "./interfaces-CtOhRZzC.js";
1
+ import { _ as ToolId, a as InspectResult, g as SwitchOptions, h as SettingsResult, i as EditOptions, n as ConfigObject, p as SettingsListData, u as Scope } from "./types-QfiJTz-B.js";
2
+ import { n as SettingsAdapter } from "./interfaces-BlM-_HAC.js";
3
3
 
4
4
  //#region src/services/settings/adapters/base.d.ts
5
5
 
@@ -1,5 +1,5 @@
1
- import { a as LaunchCommandSpec, g as ToolId } from "./types-vDRpkfsj.js";
2
- import { t as LaunchAdapter } from "./interfaces-CtOhRZzC.js";
1
+ import { _ as ToolId, o as LaunchCommandSpec } from "./types-QfiJTz-B.js";
2
+ import { t as LaunchAdapter } from "./interfaces-BlM-_HAC.js";
3
3
 
4
4
  //#region src/services/launch/adapters/base.d.ts
5
5
 
@@ -0,0 +1 @@
1
+ import{c as e,t}from"./errors-DMQ0N3V2.js";import{n,t as r}from"./editor-DkpC97xg.js";import{a as i,c as a,f as o,h as s,o as c,p as l,r as u,t as d}from"./fsStore-iYRoM63Y.js";import{t as f}from"./base-CojCfrYM.js";import*as p from"node:path";const m=`~/.codex/auth-profiles`,h=`~/.codex/auth.json`;var g=class extends f{toolId=`codex`;async list(t){if(!this.validateScope(t))throw new e(t);let n=this.resolvePath(t),r=this.readConfig(n);return{type:`entries`,entries:this.#r(r),filePath:n}}resolvePath(e){switch(e){case`user`:return`~/.codex/config.toml`;default:throw Error(`Unsupported scope for Codex: ${e}`)}}validateScope(e){return e===`user`}async switchProfile(t,n,r){if(!this.validateScope(t))throw new e(t);return this.isAuthProfile(n)?this.#e(n):this.#t(t,n)}async edit(t,a){if(!this.validateScope(t))throw new e(t);let o=this.resolvePath(t);if(!a.provider){let e=l(o);i(p.dirname(e)),c(o)||this.writeConfig(o,{});let t=n(a.ide);return await r(t,e),{success:!0,message:`Opened Codex config in ${t}`,filePath:e}}let s=a.provider.id?.trim()||a.provider.name?.trim();if(!s)throw Error(`Provider name cannot be empty`);let u=a.provider.base_url?.trim();if(!u)throw Error(`Base URL is required for Codex providers`);let d=a.provider.name?.trim()||s,f=a.provider.experimental_bearer_token?.trim();if(!f)throw Error(`Experimental bearer token is required for Codex providers`);let m=this.#n(o),h=_(m.model_providers)?{...m.model_providers}:{};h[s]={name:d,base_url:u,wire_api:`responses`,experimental_bearer_token:f};let g={...m,model_providers:h};return this.writeConfig(o,g),{success:!0,message:`Added model_providers.${s}`,filePath:l(o),data:h[s]}}listAuthProfiles(){return a(m).filter(e=>e.endsWith(`.json`)).map(e=>e.replace(`.json`,``))}isAuthProfile(e){return c(`${m}/${e}.json`)}saveAuthProfile(e,t=!1){let n=`${m}/${e}.json`;return c(h)?!t&&c(n)?{success:!1,message:`Profile "${e}" already exists. Use --force to overwrite.`}:(i(m),d(h,n),u(h),{success:!0,message:`Saved current auth as profile: ${e}\nauth.json has been removed. You can now login with another account.`,filePath:l(n)}):{success:!1,message:`No auth.json found. Please run 'codex login' first.`}}deleteAuthProfile(e){let t=`${m}/${e}.json`;return c(t)?(u(t),{success:!0,message:`Deleted auth profile: ${e}`}):{success:!1,message:`Auth profile "${e}" not found.`}}getAllSwitchableProfiles(e){let t=this.resolvePath(e),n=[];try{let e=this.readConfig(t),r=e.model_providers;_(r)&&(n=Object.keys(r));let i=e.profiles;_(i)&&(n=[...new Set([...n,...Object.keys(i)])])}catch{}let r=this.listAuthProfiles();return{providers:n,authProfiles:r}}#e(e){let t=`${m}/${e}.json`,n=`~/.codex/config.toml`;if(!c(t))return{success:!1,message:`Auth profile "${e}" not found.`};d(t,h);try{let e=this.readConfig(n);e.model_provider&&(delete e.model_provider,this.writeConfig(n,e))}catch{}return{success:!0,message:`Switched to auth profile: ${e}`,filePath:l(h)}}#t(e,t){let n=this.resolvePath(e);c(h)&&u(h);let r=this.readConfig(n),i=r.profiles,a=(_(i)?i:void 0)?.[t];if(_(a)){let e={...r};for(let[t,n]of Object.entries(a))e[t]=n;return e.current_profile=t,this.writeConfig(n,e),{success:!0,message:`Switched to profile: ${t}`,filePath:l(n)}}let o={...r,model_provider:t};return this.writeConfig(n,o),{success:!0,message:`Switched to provider: ${t}`,filePath:l(n)}}readConfig(e){return o(e)}writeConfig(e,t){s(e,t,!1)}#n(e){try{return this.readConfig(e)}catch(e){if(e instanceof t)return{};throw e}}#r(e){let t=e.model_providers;return _(t)?t:{}}};const _=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date);export{_ as n,g as t};
@@ -1,4 +1,4 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../errorClassifier-BtDItoIE.js";import"../../loadBalancer-B-jkwy15.js";import"../../transformer-B_JzskvR.js";import{n as e,t}from"../../server-Cymednu2.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Start an OpenAI-compatible proxy server with load balancing and key rotation`;static description=`Boot a local proxy server that forwards requests to configured upstream AI providers.
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../errorClassifier-BtDItoIE.js";import"../../loadBalancer-B-jkwy15.js";import"../../transformer-B_JzskvR.js";import{n as e,t}from"../../server-tc_ROnwq.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Start an OpenAI-compatible proxy server with load balancing and key rotation`;static description=`Boot a local proxy server that forwards requests to configured upstream AI providers.
2
2
 
3
3
  Features:
4
4
  - OpenAI-compatible API endpoints (/v1/chat/completions, /v1/messages, etc.)
@@ -1,8 +1,8 @@
1
- import"../../errors-DMQ0N3V2.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import{t}from"../../codex-B7IedjUS.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Manage auth profiles for Codex`;static description=`
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import{t}from"../../codex-oiTfloLj.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Manage auth profiles for Codex`;static description=`
2
2
  Save, list, and delete auth profiles for Codex.
3
3
  Use settings:switch to switch between auth profiles and providers.
4
4
 
5
5
  Auth profiles allow you to save multiple Codex login credentials
6
6
  and switch between them without having to logout and login again.
7
- `;static examples=[{description:`List all saved auth profiles`,command:`<%= config.bin %> <%= command.id %> --tool codex`},{description:`Save current auth as a named profile`,command:`<%= config.bin %> <%= command.id %> --save personal --tool codex`},{description:`Overwrite an existing profile`,command:`<%= config.bin %> <%= command.id %> --save personal --tool codex --force`},{description:`Delete an auth profile`,command:`<%= config.bin %> <%= command.id %> --delete old-account --tool codex`}];static flags={tool:r.string({char:`t`,description:`AI CLI tool (currently only codex is supported)`,options:[`codex`],default:`codex`}),save:r.string({char:`s`,description:`Save current auth as a named profile`}),delete:r.string({char:`d`,description:`Delete an auth profile`}),force:r.boolean({char:`f`,description:`Overwrite existing profile without confirmation`,default:!1}),json:r.boolean({description:`Output JSON instead of text`,default:!1})};async run(){let{flags:e}=await this.parse(i);e.tool!==`codex`&&this.error(`Auth profile management is currently only supported for Codex.`,{exit:1});let n=new t,r=!!e.force,a=!!e.json,o=e.save,s=e.delete;o?await this.#t(n,o,{force:r,json:a}):s?await this.#n(n,s,{json:a}):await this.#e(n,{json:a})}async#e(t,n){let r=t.listAuthProfiles();if(n.json){this.log(e({profiles:r}));return}if(r.length===0){this.log(`No auth profiles found.`),this.log(`
8
- To save your current auth, run:`),this.log(` xling settings:auth --save <name> --tool codex`);return}this.log(`Auth profiles:`);for(let e of r)this.log(` - ${e}`);this.log(`\nTotal: ${r.length} profile(s)`)}async#t(e,t,n){let r=e.saveAuthProfile(t,n.force);this.#r(r,n.json),r.success||this.exit(1)}async#n(e,t,n){let r=e.deleteAuthProfile(t);this.#r(r,n.json),r.success||this.exit(1)}#r(t,n){if(n){this.log(e(t));return}t.success?(this.log(t.message??`Operation completed successfully.`),t.filePath&&this.log(` File: ${t.filePath}`)):this.error(t.message??`Operation failed.`,{exit:1})}};export{i as default};
7
+ `;static examples=[{description:`List all saved auth profiles`,command:`<%= config.bin %> <%= command.id %> --tool codex`},{description:`Save current auth as a named profile`,command:`<%= config.bin %> <%= command.id %> --save personal --tool codex`},{description:`Overwrite an existing profile`,command:`<%= config.bin %> <%= command.id %> --save personal --tool codex --force`},{description:`Delete an auth profile`,command:`<%= config.bin %> <%= command.id %> --delete old-account --tool codex`},{description:`Restore a saved auth profile back to auth.json`,command:`<%= config.bin %> <%= command.id %> --restore personal --tool codex`}];static flags={tool:r.string({char:`t`,description:`AI CLI tool (currently only codex is supported)`,options:[`codex`],default:`codex`}),save:r.string({char:`s`,description:`Save current auth as a named profile`}),delete:r.string({char:`d`,description:`Delete an auth profile`}),restore:r.string({char:`r`,description:`Restore a saved auth profile back to auth.json`}),force:r.boolean({char:`f`,description:`Overwrite existing profile without confirmation`,default:!1}),json:r.boolean({description:`Output JSON instead of text`,default:!1})};async run(){let{flags:e}=await this.parse(i);e.tool!==`codex`&&this.error(`Auth profile management is currently only supported for Codex.`,{exit:1});let n=new t,r=!!e.force,a=!!e.json,o=e.save,s=e.delete,c=e.restore;[o,s,c].filter(Boolean).length>1&&this.error(`Please specify only one of --save, --delete, or --restore.`,{exit:1}),o?await this.#t(n,o,{force:r,json:a}):s?await this.#n(n,s,{json:a}):c?await this.#r(n,c,{json:a}):await this.#e(n,{json:a})}async#e(t,n){let r=t.listAuthProfiles();if(n.json){this.log(e({profiles:r}));return}if(r.length===0){this.log(`No auth profiles found.`),this.log(`
8
+ To save your current auth, run:`),this.log(` xling settings:auth --save <name> --tool codex`);return}this.log(`Auth profiles:`);for(let e of r)this.log(` - ${e}`);this.log(`\nTotal: ${r.length} profile(s)`)}async#t(e,t,n){let r=e.saveAuthProfile(t,n.force);this.#i(r,n.json),r.success||this.exit(1)}async#n(e,t,n){let r=e.deleteAuthProfile(t);this.#i(r,n.json),r.success||this.exit(1)}async#r(e,t,n){let r=await e.switchProfile(`user`,t);this.#i(r,n.json),r.success||this.exit(1)}#i(t,n){if(n){this.log(e(t));return}t.success?(this.log(t.message??`Operation completed successfully.`),t.filePath&&this.log(` File: ${t.filePath}`)):this.error(t.message??`Operation failed.`,{exit:1})}};export{i as default};
@@ -1,4 +1,4 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import{p as t}from"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-B7IedjUS.js";import"../../claudeDefault-CAA3qlD0.js";import{t as n}from"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t as r}from"../../dispatcher-Ck97HDr8.js";import{Args as i,Command as a,Flags as o}from"@oclif/core";import s from"node:fs";import c from"node:path";var l=class l extends a{static summary=`View the full configuration file`;static description=`
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import{p as t}from"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-oiTfloLj.js";import"../../claudeDefault-CAA3qlD0.js";import{t as n}from"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t as r}from"../../dispatcher-GQ0DcyYr.js";import{Args as i,Command as a,Flags as o}from"@oclif/core";import s from"node:fs";import c from"node:path";var l=class l extends a{static summary=`View the full configuration file`;static description=`
2
2
  Print the entire configuration file for the selected tool/scope.
3
3
  Use --json for structured output or --no-json for plain text.
4
4
  `;static examples=[{description:`Print Claude user settings (raw file)`,command:`<%= config.bin %> <%= command.id %> --tool claude --scope user`},{description:`Inspect a Claude variant by name`,command:`<%= config.bin %> <%= command.id %> hxi --tool claude --scope user`},{description:`Dump Codex config as JSON for scripting`,command:`<%= config.bin %> <%= command.id %> --tool codex --json`},{description:`View xling prompt router config (if present)`,command:`<%= config.bin %> <%= command.id %> --tool xling --scope user`}];static args={name:i.string({description:`Claude variant name (optional). Example: settings:get hxi`,required:!1})};static flags={tool:o.string({char:`t`,description:`AI CLI tool to manage`,options:[`claude`,`codex`,`gemini`,`xling`],default:`claude`}),scope:o.string({char:`s`,description:`Configuration scope`,options:[`user`,`project`,`local`,`system`],default:`user`})};async run(){let{args:t,flags:n}=await this.parse(l);try{let r=n.tool,i=n.scope,a=r===`claude`&&t.name?await this.#t(i,t.name):await this.#e(r,i);if(n.json){this.log(e({success:!0,data:a}));return}if(!a.exists){this.warn(`Config file not found: ${a.path}`);return}a.content?this.log(a.content):this.log(`File is empty.`)}catch(e){this.error(e.message,{exit:1})}}async#e(e,t){return(await new r().execute({tool:e,scope:t,action:`inspect`})).data}async#t(e,r){let i=new n;if(!i.validateScope(e))throw Error(`Invalid scope for Claude: ${e}`);let a=r.trim();if(!a||a===`default`)return this.#e(`claude`,e);let o=t(i.resolvePath(e)),l=c.dirname(o),u=this.#n(l,a)??c.join(l,`settings.${a}.json`);if(!s.existsSync(u))return{path:u,exists:!1};let d=s.statSync(u);return{path:u,exists:!0,content:s.readFileSync(u,`utf-8`),size:d.size,lastModified:d.mtime}}#n(e,t){let n=[`settings.${t}.json`,`settings-${t}.json`];for(let t of n){let n=c.join(e,t);if(s.existsSync(n))return n}return null}};export{l as default};
@@ -1,4 +1,4 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-B7IedjUS.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t}from"../../dispatcher-Ck97HDr8.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Inspect configuration file status`;static description=`
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-oiTfloLj.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t}from"../../dispatcher-GQ0DcyYr.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Inspect configuration file status`;static description=`
2
2
  Display information about the configuration file, including:
3
3
  - File path
4
4
  - Existence status
@@ -1,4 +1,4 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{i as e,n as t,r as n}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-B7IedjUS.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t as r}from"../../dispatcher-Ck97HDr8.js";import{Command as i,Flags as a}from"@oclif/core";var o=class o extends i{static summary=`List all settings for a tool`;static description=`
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{i as e,n as t,r as n}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-oiTfloLj.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t as r}from"../../dispatcher-GQ0DcyYr.js";import{Command as i,Flags as a}from"@oclif/core";var o=class o extends i{static summary=`List all settings for a tool`;static description=`
2
2
  Display all configuration settings for the specified AI CLI tool.
3
3
  Supports multiple scopes (user, project, local, system).
4
4
  `;static examples=[{description:`List Claude user settings (YAML-style summary)`,command:`<%= config.bin %> <%= command.id %> --tool claude --scope user`},{description:`Show Codex providers in a table`,command:`<%= config.bin %> <%= command.id %> --tool codex --scope user --table`},{description:`Inspect Gemini project settings as JSON`,command:`<%= config.bin %> <%= command.id %> -t gemini -s project --json`},{description:`Check xling shortcut config location`,command:`<%= config.bin %> <%= command.id %> --tool xling --scope user`}];static flags={tool:a.string({char:`t`,description:`AI CLI tool to manage`,options:[`claude`,`codex`,`gemini`,`xling`],default:`claude`}),scope:a.string({char:`s`,description:`Configuration scope`,options:[`user`,`project`,`local`,`system`],default:`user`}),json:a.boolean({description:`Output JSON instead of text summary`,default:!1}),table:a.boolean({description:`Render table output instead of JSON`,default:!1})};async run(){let{flags:e}=await this.parse(o);try{let t=await new r().execute({tool:e.tool,scope:e.scope,action:`list`});if(e.table){this.#t(t.data);return}if(e.json){this.log(n(t));return}this.#e(t.data)}catch(e){this.error(e.message,{exit:1})}}#e(e){if(!e){this.log(`No settings found.`);return}if(e.type===`files`){if(e.files.length===0){this.log(`No settings files found.`);return}this.log(this.#n(e.files));return}if(Object.keys(e.entries).length===0){this.log(`No settings found.`);return}this.log(this.#r(e.entries,e.filePath))}#t(n){if(!n){this.log(`No settings found.`);return}if(n.type===`files`){if(n.files.length===0){this.log(`No settings files found.`);return}this.log(t(n.files));return}if(Object.keys(n.entries).length===0){this.log(`No settings found.`);return}this.log(e(n.entries)),this.log(`File: ${n.filePath}`)}#n(e){let t=e.map(e=>`${e.active?`* `:`- `}${e.variant} -> ${e.path}`+(e.exists?``:` (missing)`));return[`files:`].concat(t).join(`
@@ -1,8 +1,8 @@
1
1
  import { Command, Interfaces } from "@oclif/core";
2
2
 
3
3
  //#region src/commands/settings/set.d.ts
4
-
5
4
  declare class SettingsSet extends Command {
5
+ #private;
6
6
  static summary: string;
7
7
  static description: string;
8
8
  static examples: Command.Example[];
@@ -1,5 +1,8 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-B7IedjUS.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t}from"../../dispatcher-Ck97HDr8.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Open settings files in your IDE`;static description=`
2
- Create or open settings files for AI CLI tools in your preferred editor.
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-oiTfloLj.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t}from"../../dispatcher-GQ0DcyYr.js";import{Command as n,Flags as r}from"@oclif/core";import i from"node:readline/promises";import{stdin as a,stdout as o}from"node:process";var s=class s extends n{static summary=`Open settings files or add Codex providers`;static description=`
2
+ Create or open settings files for AI CLI tools in your preferred editor,
3
+ or interactively add Codex model providers.
4
+
3
5
  For Claude: provide --name to edit settings.<name>.json (default: settings.json).
6
+ For Codex: answer prompts to create a [model_providers.<name>] entry.
4
7
  For Xling: edits ~/.claude/xling.json configuration.
5
- `;static examples=[{description:`Create or edit a Claude variant in VS Code`,command:`<%= config.bin %> <%= command.id %> --tool claude --scope user --name hxi`},{description:`Open Claude project settings in Cursor without JSON output`,command:`<%= config.bin %> <%= command.id %> --tool claude --scope project --name default --ide cursor --no-json`},{description:`Edit Codex user config`,command:`<%= config.bin %> <%= command.id %> --tool codex --scope user`},{description:`Edit xling shortcut config in Cursor`,command:`<%= config.bin %> <%= command.id %> --tool xling --ide cursor`}];static args={};static flags={tool:r.string({char:`t`,description:`AI CLI tool to manage`,options:[`claude`,`codex`,`gemini`,`xling`],default:`claude`}),scope:r.string({char:`s`,description:`Configuration scope`,options:[`user`,`project`,`local`,`system`],default:`user`}),name:r.string({description:`Claude variant name (e.g., hxi). Creates settings.<name>.json if missing and opens it in the IDE.`}),ide:r.string({description:`Editor command or alias (default: code for VS Code)`,default:`code`}),json:r.boolean({description:`Output JSON (default)`,default:!0,allowNo:!0})};async run(){let{flags:n}=await this.parse(i);try{let r=await new t().execute({tool:n.tool,scope:n.scope,action:`edit`,name:n.name,ide:n.ide});n.json?this.log(e(r)):(this.log(r.message??`Opened settings file`),r.filePath&&this.log(`File: ${r.filePath}`))}catch(e){this.error(e.message,{exit:1})}}};export{i as default};
8
+ `;static examples=[{description:`Create or edit a Claude variant in VS Code`,command:`<%= config.bin %> <%= command.id %> --tool claude --scope user --name hxi`},{description:`Open Claude project settings in Cursor without JSON output`,command:`<%= config.bin %> <%= command.id %> --tool claude --scope project --name default --ide cursor --no-json`},{description:`Add a Codex provider interactively`,command:`<%= config.bin %> <%= command.id %> --tool codex --scope user`},{description:`Edit xling shortcut config in Cursor`,command:`<%= config.bin %> <%= command.id %> --tool xling --ide cursor`}];static args={};static flags={tool:r.string({char:`t`,description:`AI CLI tool to manage`,options:[`claude`,`codex`,`gemini`,`xling`],default:`claude`}),scope:r.string({char:`s`,description:`Configuration scope`,options:[`user`,`project`,`local`,`system`],default:`user`}),name:r.string({description:`Claude variant name or Codex provider key. Defaults to prompt input if omitted.`}),ide:r.string({description:`Editor command or alias (default: code for VS Code)`,default:`code`}),json:r.boolean({description:`Output JSON (default)`,default:!0,allowNo:!0})};async run(){let{flags:e}=await this.parse(s),n=new t;try{let t=e.tool===`codex`?await this.#e(n,e):await n.execute({tool:e.tool,scope:e.scope,action:`edit`,name:e.name,ide:e.ide});this.#n(t,e)}catch(e){this.error(e.message,{exit:1})}}async#e(e,t){let n=await this.#t(t.name);return e.execute({tool:`codex`,scope:t.scope,action:`edit`,provider:n,ide:t.ide})}async#t(e){let t=i.createInterface({input:a,output:o});try{let n=e?`Provider name [${e}]: `:`Provider name: `,r=(await t.question(n)).trim()||e?.trim()||``;r||this.error(`Provider name cannot be empty.`,{exit:1});let i=(await t.question(`Base URL (e.g., https://api.example.com/v1): `)).trim();i||this.error(`Base URL is required.`,{exit:1});let a=(await t.question(`Experimental bearer token (required): `)).trim();return a||this.error(`Experimental bearer token 不能为空。`,{exit:1}),{id:r,name:r,base_url:i,experimental_bearer_token:a}}finally{t.close()}}#n(t,n){if(n.json){this.log(e(t));return}this.log(t.message??`Opened settings file`),t.filePath&&this.log(`File: ${t.filePath}`)}};export{s as default};
@@ -1,4 +1,4 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import{t}from"../../codex-B7IedjUS.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t as n}from"../../dispatcher-Ck97HDr8.js";import{Args as r,Command as i,Flags as a}from"@oclif/core";import o from"node:readline/promises";import{stdin as s,stdout as c}from"node:process";var l=class l extends i{static summary=`Switch Codex profiles or Claude settings variants`;static description=`
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import{t}from"../../codex-oiTfloLj.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t as n}from"../../dispatcher-GQ0DcyYr.js";import{Args as r,Command as i,Flags as a}from"@oclif/core";import o from"node:readline/promises";import{stdin as s,stdout as c}from"node:process";var l=class l extends i{static summary=`Switch Codex profiles or Claude settings variants`;static description=`
2
2
  Switch to a different profile configuration for Codex
3
3
  or activate a specific settings.<variant>.json for Claude.
4
4
 
@@ -1,5 +1,6 @@
1
- import"../../errors-DMQ0N3V2.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import{n as t,r as n,t as r}from"../../sync-C39sJRnz.js";import{Command as i,Flags as a}from"@oclif/core";import o from"node:readline/promises";import{stdin as s,stdout as c}from"node:process";var l=class l extends i{static summary=`Sync Claude Code config.toml into Codex config.toml`;static description=`
2
- Copy the Claude Code config.toml into Codex's configuration directory.
3
- Shows a diff first, then lets you choose overwrite, backup+overwrite,
4
- or cancel (similar to settings:switch). Use --force to skip prompts.
5
- `;static examples=[{description:`Sync default paths with a backup`,command:`<%= config.bin %> <%= command.id %>`},{description:`Dry-run and emit JSON (no writes)`,command:`<%= config.bin %> <%= command.id %> --dry-run --json`},{description:`Explicitly set source/target paths`,command:`<%= config.bin %> <%= command.id %> --source ~/.claude/config.toml --target ~/.codex/config.toml`}];static flags={source:a.string({description:`Path to Claude Code config.toml`,default:r}),target:a.string({description:`Path to Codex config.toml`,default:t}),backup:a.boolean({description:`Create a .bak of the target before overwriting`,default:!1,allowNo:!0}),dryRun:a.boolean({description:`Show what would change without writing files`,default:!1}),force:a.boolean({description:`Apply without prompts (overwrites unless --backup is set)`,default:!1}),json:a.boolean({description:`Output JSON instead of human-readable text`,default:!1})};async run(){let{flags:t}=await this.parse(l);t.json&&!t.force&&!t.dryRun&&this.error(`--json requires --force or --dry-run (no prompts allowed).`,{exit:1});try{let r=n({sourcePath:t.source,targetPath:t.target,backup:!1,dryRun:!0});if(!r.data?.changed){t.json?this.log(e(r)):this.log(r.message??`Already in sync.`);return}if(t.dryRun){t.json?this.log(e(r)):(this.#e(r.diff),this.log(`Dry-run only; no files were written.`));return}this.#e(r.diff);let i=!!t.backup;if(!t.force){let n=await this.#t();if(n===`cancel`){t.json?this.log(e({...r,message:`Sync cancelled.`})):this.log(`Sync cancelled.`);return}i=n===`backup`}let a=n({sourcePath:t.source,targetPath:t.target,backup:i,dryRun:!1});if(t.json){this.log(e(a));return}this.log(a.message??`Sync completed.`),a.data&&(this.log(`Source: ${a.data.source}`),this.log(`Target: ${a.data.target}`),a.data.backupPath&&this.log(`Backup: ${a.data.backupPath}`))}catch(e){this.error(e.message,{exit:1})}}#e(e){if(!e){this.log(`No diff available; files may already match.`);return}this.log(`Proposed changes:`),this.log(e)}async#t(){let e=o.createInterface({input:s,output:c});try{for(;;){let t=(await e.question(`Choose action ([o]verwrite/[b]ackup+overwrite/[c]ancel): `)).trim().toLowerCase();if([`overwrite`,`backup`,`cancel`].includes(t))return t;if([`o`,`b`,`c`].includes(t))return{o:`overwrite`,b:`backup`,c:`cancel`}[t];this.log(`Invalid selection. Please try again.`)}}finally{e.close()}}};export{l as default};
1
+ import"../../errors-DMQ0N3V2.js";import{r as e}from"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import{i as t,n,r,t as i}from"../../sync-F4vZCogY.js";import{Command as a,Flags as o}from"@oclif/core";import s from"node:readline/promises";import{stdin as c,stdout as l}from"node:process";var u=class u extends a{static summary=`Sync config.toml between Claude Code and Codex`;static description=`
2
+ Copy Claude Code config.toml into Codex (default) or reverse the direction
3
+ with --reverse. Shows a diff first, then lets you choose overwrite,
4
+ backup+overwrite, or cancel (similar to settings:switch).
5
+ Use --force to skip prompts.
6
+ `;static examples=[{description:`Sync Claude -> Codex with optional backup`,command:`<%= config.bin %> <%= command.id %>`},{description:`Dry-run and emit JSON (no writes)`,command:`<%= config.bin %> <%= command.id %> --dry-run --json`},{description:`Explicitly set source/target paths`,command:`<%= config.bin %> <%= command.id %> --source ~/.claude/config.toml --target ~/.codex/config.toml`},{description:`Reverse sync (Codex -> Claude)`,command:`<%= config.bin %> <%= command.id %> --reverse`}];static flags={source:o.string({description:`Path to Claude Code config.toml`}),target:o.string({description:`Path to Codex config.toml`}),backup:o.boolean({description:`Create a .bak of the target before overwriting`,default:!1,allowNo:!0}),dryRun:o.boolean({description:`Show what would change without writing files`,default:!1}),force:o.boolean({description:`Apply without prompts (overwrites unless --backup is set)`,default:!1}),json:o.boolean({description:`Output JSON instead of human-readable text`,default:!1}),reverse:o.boolean({description:`Reverse sync: copy Codex config.toml into Claude Code config.toml`,default:!1})};async run(){let{flags:a}=await this.parse(u);a.json&&!a.force&&!a.dryRun&&this.error(`--json requires --force or --dry-run (no prompts allowed).`,{exit:1});let o=!!a.reverse,s=o?n:i,c=o?i:n,l=o?t:r;try{let t=l({sourcePath:a.source??s,targetPath:a.target??c,backup:!1,dryRun:!0});if(!t.data?.changed){a.json?this.log(e(t)):this.log(t.message??`Already in sync.`);return}if(a.dryRun){a.json?this.log(e(t)):(this.#e(t.diff),this.log(`Dry-run only; no files were written.`));return}this.#e(t.diff);let n=!!a.backup;if(!a.force){let r=await this.#t();if(r===`cancel`){a.json?this.log(e({...t,message:`Sync cancelled.`})):this.log(`Sync cancelled.`);return}n=r===`backup`}let r=l({sourcePath:a.source??s,targetPath:a.target??c,backup:n,dryRun:!1});if(a.json){this.log(e(r));return}this.log(r.message??`Sync completed.`),r.data&&(this.log(`Source: ${r.data.source}`),this.log(`Target: ${r.data.target}`),r.data.backupPath&&this.log(`Backup: ${r.data.backupPath}`))}catch(e){this.error(e.message,{exit:1})}}#e(e){if(!e){this.log(`No diff available; files may already match.`);return}this.log(`Proposed changes:`),this.log(e)}async#t(){let e=s.createInterface({input:c,output:l});try{for(;;){let t=(await e.question(`Choose action ([o]verwrite/[b]ackup+overwrite/[c]ancel): `)).trim().toLowerCase();if([`overwrite`,`backup`,`cancel`].includes(t))return t;if([`o`,`b`,`c`].includes(t))return{o:`overwrite`,b:`backup`,c:`cancel`}[t];this.log(`Invalid selection. Please try again.`)}}finally{e.close()}}};export{u as default};
@@ -1 +1 @@
1
- import{Command as e}from"@oclif/core";var t=`0.9.1`,n=class extends e{static summary=`Show the current xling version`;static description=`Displays the version from package.json.`;static examples=[{description:`Print the installed CLI version`,command:`<%= config.bin %> <%= command.id %>`},{description:`Shortcut using the built-in flag`,command:`<%= config.bin %> --version`}];async run(){this.log(t??`unknown`)}};export{n as default};
1
+ import{Command as e}from"@oclif/core";var t=`0.9.2`,n=class extends e{static summary=`Show the current xling version`;static description=`Displays the version from package.json.`;static examples=[{description:`Print the installed CLI version`,command:`<%= config.bin %> <%= command.id %>`},{description:`Shortcut using the built-in flag`,command:`<%= config.bin %> --version`}];async run(){this.log(t??`unknown`)}};export{n as default};
@@ -1 +1 @@
1
- import{d as e}from"./errors-DMQ0N3V2.js";import{t}from"./xling-DqZuT8CZ.js";import{t as n}from"./codex-B7IedjUS.js";import{t as r}from"./claude-FRKIDAFa.js";import{t as i}from"./gemini-CuAIjTLO.js";var a=class{#e;constructor(){this.#e=new Map,this.#e.set(`claude`,new r),this.#e.set(`codex`,new n),this.#e.set(`gemini`,new i),this.#e.set(`xling`,new t)}async execute(e){let t=this.#t(e.tool);switch(e.action){case`list`:return{success:!0,data:await t.list(e.scope)};case`switch-profile`:if(!e.profile)throw Error(`Profile is required for switch-profile action`);if(!t.switchProfile)throw Error(`Tool ${e.tool} does not support profile switching`);return await t.switchProfile(e.scope,e.profile,e.switchOptions);case`edit`:if(!t.edit)throw Error(`Tool ${e.tool} does not support editing via CLI`);return await t.edit(e.scope,{name:e.name,ide:e.ide});case`inspect`:if(!t.inspect)throw Error(`Tool ${e.tool} does not support inspect action`);return{success:!0,data:await t.inspect(e.scope)};default:throw Error(`Unsupported action`)}}#t(t){let n=this.#e.get(t);if(!n)throw new e(t);return n}registerAdapter(e){this.#e.set(e.toolId,e)}getSupportedTools(){return Array.from(this.#e.keys())}};export{a as t};
1
+ import{d as e}from"./errors-DMQ0N3V2.js";import{t}from"./xling-DqZuT8CZ.js";import{t as n}from"./codex-oiTfloLj.js";import{t as r}from"./claude-FRKIDAFa.js";import{t as i}from"./gemini-CuAIjTLO.js";var a=class{#e;constructor(){this.#e=new Map,this.#e.set(`claude`,new r),this.#e.set(`codex`,new n),this.#e.set(`gemini`,new i),this.#e.set(`xling`,new t)}async execute(e){let t=this.#t(e.tool);switch(e.action){case`list`:return{success:!0,data:await t.list(e.scope)};case`switch-profile`:if(!e.profile)throw Error(`Profile is required for switch-profile action`);if(!t.switchProfile)throw Error(`Tool ${e.tool} does not support profile switching`);return await t.switchProfile(e.scope,e.profile,e.switchOptions);case`edit`:if(!t.edit)throw Error(`Tool ${e.tool} does not support editing via CLI`);return await t.edit(e.scope,{name:e.name,ide:e.ide,provider:e.provider});case`inspect`:if(!t.inspect)throw Error(`Tool ${e.tool} does not support inspect action`);return{success:!0,data:await t.inspect(e.scope)};default:throw Error(`Unsupported action`)}}#t(t){let n=this.#e.get(t);if(!n)throw new e(t);return n}registerAdapter(e){this.#e.set(e.toolId,e)}getSupportedTools(){return Array.from(this.#e.keys())}};export{a as t};
@@ -1,3 +1,3 @@
1
- import "../types-vDRpkfsj.js";
2
- import { n as SettingsAdapter, t as LaunchAdapter } from "../interfaces-CtOhRZzC.js";
1
+ import "../types-QfiJTz-B.js";
2
+ import { n as SettingsAdapter, t as LaunchAdapter } from "../interfaces-BlM-_HAC.js";
3
3
  export { LaunchAdapter, SettingsAdapter };
@@ -1,2 +1,2 @@
1
- import { a as LaunchCommandSpec, c as OutputFormat, d as SettingsFileEntry, f as SettingsListData, g as ToolId, h as SwitchOptions, i as InspectResult, l as Scope, m as SettingsResult, n as ConfigValue, o as LaunchPayload, p as SettingsPayload, r as EditOptions, s as LaunchResult, t as ConfigObject, u as SettingAction } from "../types-vDRpkfsj.js";
2
- export { ConfigObject, ConfigValue, EditOptions, InspectResult, LaunchCommandSpec, LaunchPayload, LaunchResult, OutputFormat, Scope, SettingAction, SettingsFileEntry, SettingsListData, SettingsPayload, SettingsResult, SwitchOptions, ToolId };
1
+ import { _ as ToolId, a as InspectResult, c as LaunchResult, d as SettingAction, f as SettingsFileEntry, g as SwitchOptions, h as SettingsResult, i as EditOptions, l as OutputFormat, m as SettingsPayload, n as ConfigObject, o as LaunchCommandSpec, p as SettingsListData, r as ConfigValue, s as LaunchPayload, t as CodexProviderInput, u as Scope } from "../types-QfiJTz-B.js";
2
+ export { CodexProviderInput, ConfigObject, ConfigValue, EditOptions, InspectResult, LaunchCommandSpec, LaunchPayload, LaunchResult, OutputFormat, Scope, SettingAction, SettingsFileEntry, SettingsListData, SettingsPayload, SettingsResult, SwitchOptions, ToolId };
@@ -1,4 +1,4 @@
1
- import { g as ToolId, l as Scope, n as ConfigValue, p as SettingsPayload, u as SettingAction } from "../types-vDRpkfsj.js";
1
+ import { _ as ToolId, d as SettingAction, m as SettingsPayload, r as ConfigValue, u as Scope } from "../types-QfiJTz-B.js";
2
2
  import { ZodType, z } from "zod";
3
3
 
4
4
  //#region src/domain/validators.d.ts
@@ -1,4 +1,4 @@
1
- import { a as LaunchCommandSpec, f as SettingsListData, g as ToolId, h as SwitchOptions, i as InspectResult, l as Scope, m as SettingsResult, r as EditOptions } from "./types-vDRpkfsj.js";
1
+ import { _ as ToolId, a as InspectResult, g as SwitchOptions, h as SettingsResult, i as EditOptions, o as LaunchCommandSpec, p as SettingsListData, u as Scope } from "./types-QfiJTz-B.js";
2
2
 
3
3
  //#region src/domain/interfaces.d.ts
4
4
 
@@ -0,0 +1 @@
1
+ import{p as e}from"./fsStore-iYRoM63Y.js";import{p as t}from"./config-CGH3WLbz.js";import{t as n}from"./xling-DqZuT8CZ.js";import{t as r}from"./errorClassifier-BtDItoIE.js";import{t as i}from"./loadBalancer-B-jkwy15.js";import{c as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f}from"./transformer-B_JzskvR.js";import{watch as p}from"node:fs";const m=4320;function h(){return`req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function g(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e==null)return``;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return`[object Object]`}return typeof e==`symbol`?e.toString():typeof e==`function`?e.name||`[function]`:``}async function _(t={}){let r=new n,a=r.resolvePath(`user`),o=r.readConfig(a);if(!o.providers?.length)throw Error(`No providers configured in ~/.claude/xling.json. Add a 'providers' array.`);let s=()=>o,c=o.proxy??{},l=t.host??c.host??`127.0.0.1`,u=t.port??c.port??m,d=t.accessKey??c.accessKey,f=new i(c.loadBalance??`failover`,c.keyRotation?.cooldownMs??6e4),h=Bun.serve({hostname:l,port:u,async fetch(e){let n=new URL(e.url).pathname;if(e.method===`OPTIONS`)return new Response(null,{status:204,headers:T()});if(n===`/health`||n===`/`){let e=s();return Response.json({status:`ok`,providers:e.providers.map(e=>e.name),loadBalance:e.proxy?.loadBalance??`failover`},{headers:T()})}if(n===`/stats`)return Response.json({stats:f.getStats()},{headers:T()});if(n===`/v1/models`||n===`/models`){let e=D(s().providers);return Response.json(e,{headers:T()})}if(d){let r=e.headers.get(`authorization`)?.replace(/^Bearer\s+/i,``);if(r!==d)return t.logger&&(console.log(`[auth] Access key validation failed for path: ${n}`),console.log(`[auth] Expected: ${d.slice(0,4)}...`),console.log(`[auth] Received: ${r?r.slice(0,4)+`...`:`(none)`}`)),Response.json({error:{message:`Invalid access key`,type:`auth_error`}},{status:401,headers:T()})}if(n.startsWith(`/v1/`)||n.startsWith(`/claude/`)||n.startsWith(`/openai/`)||n===`/responses`||n===`/messages`||n===`/chat/completions`){t.logger&&console.log(`[proxy] Handling request: ${e.method} ${n}`);let r=s();return v(e,n,{providers:r.providers,modelMapping:r.proxy?.modelMapping,defaultModel:r.defaultModel,passthroughResponsesAPI:r.proxy?.passthroughResponsesAPI,keyRotation:r.proxy?.keyRotation},f,t.logger??!0)}return t.logger&&console.log(`[proxy] 404 Not Found: ${e.method} ${n}`),Response.json({error:{message:`Not found`,type:`not_found`}},{status:404,headers:T()})}}),g=e(a),_=null;try{_=p(g,e=>{if(e===`change`)try{let e=r.readConfig(a);e.providers?.length&&(o=e,t.logger&&console.log(`[proxy] Config reloaded`))}catch(e){t.logger&&console.error(`[proxy] Failed to reload config:`,e)}})}catch(e){t.logger&&console.warn(`[proxy] Failed to watch config file:`,e)}return{baseUrl:`http://${l}:${u}`,providers:o.providers.map(e=>e.name),models:o.providers.flatMap(e=>e.models.map(t=>`${e.name},${t}`)),server:h,shutdown:async()=>{_?.close(),await h.stop()}}}async function v(e,n,i,a,c){let u={requestId:h(),startTime:Date.now(),retryCount:0},d=n;n.startsWith(`/claude/`)?d=n.replace(`/claude`,``):n.startsWith(`/openai/`)&&(d=n.replace(`/openai`,``)),d.startsWith(`/v1/v1/`)&&(d=d.replace(`/v1/v1/`,`/v1/`));let p;if(e.headers.get(`content-type`)?.includes(`application/json`))try{p=await e.json()}catch{return Response.json({error:{message:`Invalid JSON body`,type:`invalid_request`}},{status:400,headers:T()})}let m=o(p),_=l(p),v=p,D=!1,O=`openai`,k=b(p),A=x(k,i.modelMapping,i.defaultModel,i.providers);if(m&&p&&typeof p==`object`){let e=p;e.model=A||k,D=e.stream===!0,O=`anthropic`,v=f(e),(d===`/v1/messages`||d===`/messages`)&&(d=`/v1/chat/completions`),c&&console.log(`[${u.requestId}] Converting Anthropic -> OpenAI format (path: ${d})`)}else if(_&&p&&typeof p==`object`){let e=p;if(e.model=A||k,D=e.stream===!0,(i.passthroughResponsesAPI??[]).some(t=>t.endsWith(`*`)?String(e.model).startsWith(t.slice(0,-1)):e.model===t))O=`openai`,v=e,c&&console.log(`[${u.requestId}] Responses API passthrough (native support): model=${g(e.model)}`);else{if(O=`responses`,c){let t=g(e.model);if(console.log(`[${u.requestId}] Responses API request: stream=${D}, model=${t}`),e.tools){let t=e.tools;console.log(`[${u.requestId}] Tools count: ${t.length}`),t.slice(0,5).forEach((e,t)=>{let n=e,r=g(n.type),i=g(n.function?.name??n.name??`N/A`);console.log(`[${u.requestId}] Tool[${t}]: type=${r}, name=${i}, keys=${Object.keys(n).join(`,`)}`)})}else console.log(`[${u.requestId}] No tools in request`)}if(v=s(e),(d===`/v1/responses`||d===`/responses`)&&(d=`/v1/chat/completions`),c){console.log(`[${u.requestId}] Converting Responses API -> OpenAI format (path: ${d})`);let e=v?.tools;e?console.log(`[${u.requestId}] Converted tools count: ${e.length}`):console.log(`[${u.requestId}] No tools after conversion`)}}}else p&&typeof p==`object`&&A&&A!==k&&(p.model=A,v=p,D=p.stream===!0);c&&A&&A!==k&&console.log(`[${u.requestId}] Model mapped: ${k} -> ${A}`);let j=A,M=i.keyRotation?.enabled===!1?1:i.providers.length*2,N=null;for(;u.retryCount<M;){let n=w(i.providers,a,j);if(!n)return Response.json({error:{message:`No available providers`,type:`service_unavailable`}},{status:503,headers:T()});u.provider=n.name;let o=t(n),s=a.getProviderState(n.name),l=s?a.selectKey({...n,apiKeys:o},s):o[0];if(!l){u.retryCount++;continue}let f=o.indexOf(l);u.keyIndex=f,c&&console.log(`[${u.requestId}] -> ${n.name} (key ${f+1}/${o.length})`);try{let t=await y(e,n,l,d,v);if(t.ok){if(a.reportSuccess(n.name,f),c){let e=Date.now()-u.startTime;console.log(`[${u.requestId}] <- ${t.status} (${e}ms)`)}return O===`anthropic`?await S(t,k||`unknown`,D,c,u.requestId):O===`responses`?await C(t,k||`unknown`,D,c,u.requestId):E(t)}let o=await t.clone().json().catch(()=>null),s=r(t.status,o);if(a.reportError(n.name,f,s),c&&console.log(`[${u.requestId}] Error: ${s.type} - ${s.message}`),s.retryable&&i.keyRotation?.onError!==!1){u.retryCount++,N=t;continue}return E(t)}catch(e){let t=r(0,void 0,e);if(a.reportError(n.name,f,t),c&&console.log(`[${u.requestId}] Network error: ${t.message}`),t.retryable){u.retryCount++;continue}return Response.json({error:{message:t.message,type:t.type}},{status:502,headers:T()})}}return N?E(N):Response.json({error:{message:`All providers failed after retries`,type:`service_unavailable`}},{status:503,headers:T()})}async function y(e,t,n,r,i){let a=t.baseUrl.replace(/\/+$/,``),o=r;a.endsWith(`/v1`)&&r.startsWith(`/v1/`)&&(o=r.slice(3));let s=`${a}${o}`,c={"Content-Type":`application/json`,Authorization:`Bearer ${n}`};t.headers&&Object.assign(c,t.headers);for(let t of[`accept`,`accept-encoding`,`x-request-id`]){let n=e.headers.get(t);n&&(c[t]=n)}let l={method:e.method,headers:c};if(i&&e.method!==`GET`&&e.method!==`HEAD`&&(l.body=JSON.stringify(i)),t.timeout){let e=new AbortController,n=setTimeout(()=>e.abort(),t.timeout);l.signal=e.signal;try{let e=await fetch(s,l);return clearTimeout(n),e}catch(e){throw clearTimeout(n),e}}return fetch(s,l)}function b(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.model==`string`)return t.model}function x(e,t,n,r){if(!e)return n;if(!t||Object.keys(t).length===0)return e;if(t[e])return t[e];if(r?.some(t=>t.models.some(t=>t===e||e.startsWith(t))))return e;for(let[n,r]of Object.entries(t))if(n.endsWith(`*`)){let t=n.slice(0,-1);if(e.startsWith(t))return r}return t[`*`]?t[`*`]:n??e}async function S(e,t,n,r,i){if(n){r&&console.log(`[${i}] Converting streaming response OpenAI -> Anthropic`);let n=u(t),a=e.body?.pipeThrough(n);return new Response(a,{status:200,headers:{...T(),"Content-Type":`text/event-stream`,"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"X-Accel-Buffering":`no`}})}try{let n=await e.text(),a;try{a=JSON.parse(n)}catch{r&&console.log(`[${i}] Response is not JSON, wrapping as text`),a={content:n}}r&&console.log(`[${i}] Response type: ${typeof a}, keys: ${Object.keys(a).join(`, `)}`);let o=d(a,t);return r&&console.log(`[${i}] Converted response OpenAI -> Anthropic`),Response.json(o,{status:200,headers:T()})}catch(e){return console.error(`[${i}] Response conversion failed:`,e),Response.json({type:`error`,error:{type:`api_error`,message:`Response conversion failed: ${e.message}`}},{status:500,headers:T()})}}async function C(e,t,n,r,i){if(n){r&&console.log(`[${i}] Converting streaming response OpenAI -> Responses API`);let n=c(t),a=e.body?.pipeThrough(n);return new Response(a,{status:200,headers:{...T(),"Content-Type":`text/event-stream`,"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"X-Accel-Buffering":`no`}})}try{let n=await e.text(),o;try{o=JSON.parse(n)}catch{r&&console.log(`[${i}] Response is not JSON, wrapping as text`),o={content:n}}r&&console.log(`[${i}] Response type: ${typeof o}, keys: ${Object.keys(o).join(`, `)}`);let s=a(o,t);return r&&console.log(`[${i}] Converted response OpenAI -> Responses API`),Response.json(s,{status:200,headers:T()})}catch(e){return console.error(`[${i}] Response conversion failed:`,e),Response.json({id:`resp_${Date.now()}`,object:`response`,created_at:Math.floor(Date.now()/1e3),model:t,output:[],status:`failed`,error:{code:`api_error`,message:`Response conversion failed: ${e.message}`}},{status:500,headers:T()})}}function w(e,n,r){let i=e.map(e=>({...e,apiKeys:t(e)}));if(r?.includes(`,`)){let[e]=r.split(`,`),t=i.find(t=>t.name===e);if(t)return t}if(r){let e=i.filter(e=>e.models.some(e=>e===r||r.startsWith(e)));if(e.length>0)return n.selectProvider(e)}return n.selectProvider(i)}function T(){return{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, DELETE, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type, Authorization, X-Request-ID`,"Access-Control-Max-Age":`86400`}}function E(e){let t=new Headers(e.headers);for(let[e,n]of Object.entries(T()))t.set(e,n);return new Response(e.body,{status:e.status,statusText:e.statusText,headers:t})}function D(e){let t=Math.floor(Date.now()/1e3),n=[],r=new Set;for(let i of e)for(let e of i.models){let a=`${i.name},${e}`;r.has(a)||(r.add(a),n.push({id:a,object:`model`,created:t,owned_by:i.name})),r.has(e)||(r.add(e),n.push({id:e,object:`model`,created:t,owned_by:i.name}))}return{object:`list`,data:n}}export{_ as n,m as t};
@@ -1,4 +1,4 @@
1
- import "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
3
- import { t as BaseLaunchAdapter } from "../../../base-C2-JqowN.js";
1
+ import "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
+ import { t as BaseLaunchAdapter } from "../../../base-BzTpaH-G.js";
4
4
  export { BaseLaunchAdapter };
@@ -1,6 +1,6 @@
1
- import { a as LaunchCommandSpec } from "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
3
- import { t as BaseLaunchAdapter } from "../../../base-C2-JqowN.js";
1
+ import { o as LaunchCommandSpec } from "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
+ import { t as BaseLaunchAdapter } from "../../../base-BzTpaH-G.js";
4
4
 
5
5
  //#region src/services/launch/adapters/claude.d.ts
6
6
 
@@ -1,6 +1,6 @@
1
- import { a as LaunchCommandSpec } from "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
3
- import { t as BaseLaunchAdapter } from "../../../base-C2-JqowN.js";
1
+ import { o as LaunchCommandSpec } from "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
+ import { t as BaseLaunchAdapter } from "../../../base-BzTpaH-G.js";
4
4
 
5
5
  //#region src/services/launch/adapters/codex.d.ts
6
6
 
@@ -1,6 +1,6 @@
1
- import { a as LaunchCommandSpec } from "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
3
- import { t as BaseLaunchAdapter } from "../../../base-C2-JqowN.js";
1
+ import { o as LaunchCommandSpec } from "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
+ import { t as BaseLaunchAdapter } from "../../../base-BzTpaH-G.js";
4
4
 
5
5
  //#region src/services/launch/adapters/gemini.d.ts
6
6
 
@@ -1,5 +1,5 @@
1
- import { g as ToolId, o as LaunchPayload, s as LaunchResult } from "../../types-vDRpkfsj.js";
2
- import { t as LaunchAdapter } from "../../interfaces-CtOhRZzC.js";
1
+ import { _ as ToolId, c as LaunchResult, s as LaunchPayload } from "../../types-QfiJTz-B.js";
2
+ import { t as LaunchAdapter } from "../../interfaces-BlM-_HAC.js";
3
3
 
4
4
  //#region src/services/launch/dispatcher.d.ts
5
5
 
@@ -1 +1 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import{i as e,r as t,t as n}from"../../errorClassifier-BtDItoIE.js";import{t as r}from"../../loadBalancer-B-jkwy15.js";import"../../transformer-B_JzskvR.js";import{n as i,t as a}from"../../server-Cymednu2.js";export{a as DEFAULT_PROXY_PORT,r as ProxyLoadBalancer,n as classifyError,t as isRetryable,e as shouldRotateKey,i as startProxyServer};
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import{i as e,r as t,t as n}from"../../errorClassifier-BtDItoIE.js";import{t as r}from"../../loadBalancer-B-jkwy15.js";import"../../transformer-B_JzskvR.js";import{n as i,t as a}from"../../server-tc_ROnwq.js";export{a as DEFAULT_PROXY_PORT,r as ProxyLoadBalancer,n as classifyError,t as isRetryable,e as shouldRotateKey,i as startProxyServer};
@@ -1 +1 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../errorClassifier-BtDItoIE.js";import"../../loadBalancer-B-jkwy15.js";import"../../transformer-B_JzskvR.js";import{n as e,t}from"../../server-Cymednu2.js";export{t as DEFAULT_PROXY_PORT,e as startProxyServer};
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../errorClassifier-BtDItoIE.js";import"../../loadBalancer-B-jkwy15.js";import"../../transformer-B_JzskvR.js";import{n as e,t}from"../../server-tc_ROnwq.js";export{t as DEFAULT_PROXY_PORT,e as startProxyServer};
@@ -1,4 +1,4 @@
1
- import "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
3
- import { t as BaseAdapter } from "../../../base-CbaByk6Y.js";
1
+ import "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
+ import { t as BaseAdapter } from "../../../base-B7_Wl7Tj.js";
4
4
  export { BaseAdapter };
@@ -1,6 +1,6 @@
1
- import { f as SettingsListData, h as SwitchOptions, l as Scope, m as SettingsResult, r as EditOptions } from "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
3
- import { t as BaseAdapter } from "../../../base-CbaByk6Y.js";
1
+ import { g as SwitchOptions, h as SettingsResult, i as EditOptions, p as SettingsListData, u as Scope } from "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
+ import { t as BaseAdapter } from "../../../base-B7_Wl7Tj.js";
4
4
 
5
5
  //#region src/services/settings/adapters/claude.d.ts
6
6
 
@@ -1,6 +1,6 @@
1
- import { f as SettingsListData, h as SwitchOptions, l as Scope, m as SettingsResult, n as ConfigValue, t as ConfigObject } from "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
3
- import { t as BaseAdapter } from "../../../base-CbaByk6Y.js";
1
+ import { g as SwitchOptions, h as SettingsResult, i as EditOptions, n as ConfigObject, p as SettingsListData, r as ConfigValue, u as Scope } from "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
+ import { t as BaseAdapter } from "../../../base-B7_Wl7Tj.js";
4
4
 
5
5
  //#region src/services/settings/adapters/codex.d.ts
6
6
 
@@ -26,6 +26,7 @@ declare class CodexAdapter extends BaseAdapter {
26
26
  * Switch to a different Codex profile (provider or auth profile)
27
27
  */
28
28
  switchProfile(scope: Scope, profile: string, _options?: SwitchOptions): Promise<SettingsResult>;
29
+ edit(scope: Scope, options: EditOptions): Promise<SettingsResult>;
29
30
  /**
30
31
  * List all auth profiles
31
32
  */
@@ -1 +1 @@
1
- import"../../../errors-DMQ0N3V2.js";import"../../../fsStore-iYRoM63Y.js";import"../../../base-CojCfrYM.js";import{n as e,t}from"../../../codex-B7IedjUS.js";export{t as CodexAdapter,e as isConfigObject};
1
+ import"../../../errors-DMQ0N3V2.js";import"../../../editor-DkpC97xg.js";import"../../../fsStore-iYRoM63Y.js";import"../../../base-CojCfrYM.js";import{n as e,t}from"../../../codex-oiTfloLj.js";export{t as CodexAdapter,e as isConfigObject};
@@ -1,6 +1,6 @@
1
- import { l as Scope } from "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
3
- import { t as BaseAdapter } from "../../../base-CbaByk6Y.js";
1
+ import { u as Scope } from "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
+ import { t as BaseAdapter } from "../../../base-B7_Wl7Tj.js";
4
4
 
5
5
  //#region src/services/settings/adapters/gemini.d.ts
6
6
 
@@ -1,7 +1,7 @@
1
- import { f as SettingsListData, l as Scope, m as SettingsResult, r as EditOptions } from "../../../types-vDRpkfsj.js";
2
- import "../../../interfaces-CtOhRZzC.js";
1
+ import { h as SettingsResult, i as EditOptions, p as SettingsListData, u as Scope } from "../../../types-QfiJTz-B.js";
2
+ import "../../../interfaces-BlM-_HAC.js";
3
3
  import { C as XlingConfig, m as ProviderConfig, x as ShortcutConfig } from "../../../config-CaLWAetR.js";
4
- import { t as BaseAdapter } from "../../../base-CbaByk6Y.js";
4
+ import { t as BaseAdapter } from "../../../base-B7_Wl7Tj.js";
5
5
 
6
6
  //#region src/services/settings/adapters/xling.d.ts
7
7
  /**
@@ -1,5 +1,5 @@
1
- import { g as ToolId, m as SettingsResult, p as SettingsPayload } from "../../types-vDRpkfsj.js";
2
- import { n as SettingsAdapter } from "../../interfaces-CtOhRZzC.js";
1
+ import { _ as ToolId, h as SettingsResult, m as SettingsPayload } from "../../types-QfiJTz-B.js";
2
+ import { n as SettingsAdapter } from "../../interfaces-BlM-_HAC.js";
3
3
 
4
4
  //#region src/services/settings/dispatcher.d.ts
5
5
 
@@ -1 +1 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-B7IedjUS.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t as e}from"../../dispatcher-Ck97HDr8.js";export{e as SettingsDispatcher};
1
+ import"../../errors-DMQ0N3V2.js";import"../../editor-DkpC97xg.js";import"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import"../../base-CojCfrYM.js";import"../../config-CGH3WLbz.js";import"../../template-nmCA0YjS.js";import"../../xling-DqZuT8CZ.js";import"../../codex-oiTfloLj.js";import"../../claudeDefault-CAA3qlD0.js";import"../../claude-FRKIDAFa.js";import"../../gemini-CuAIjTLO.js";import{t as e}from"../../dispatcher-GQ0DcyYr.js";export{e as SettingsDispatcher};
@@ -1,4 +1,4 @@
1
- import { t as ConfigObject } from "../../types-vDRpkfsj.js";
1
+ import { n as ConfigObject } from "../../types-QfiJTz-B.js";
2
2
 
3
3
  //#region src/services/settings/fsStore.d.ts
4
4
  interface FileInfo {
@@ -1,4 +1,4 @@
1
- import { m as SettingsResult } from "../../types-vDRpkfsj.js";
1
+ import { h as SettingsResult } from "../../types-QfiJTz-B.js";
2
2
 
3
3
  //#region src/services/settings/sync.d.ts
4
4
 
@@ -9,6 +9,8 @@ interface SyncOptions {
9
9
  targetPath?: string;
10
10
  backup?: boolean;
11
11
  dryRun?: boolean;
12
+ currentLabel?: string;
13
+ nextLabel?: string;
12
14
  }
13
15
  interface SyncResultData {
14
16
  source: string;
@@ -25,5 +27,6 @@ interface SyncResultData {
25
27
  * - Skips work when files are already identical
26
28
  */
27
29
  declare function syncClaudeTomlToCodex(options?: SyncOptions): SettingsResult<SyncResultData>;
30
+ declare function syncCodexTomlToClaude(options?: SyncOptions): SettingsResult<SyncResultData>;
28
31
  //#endregion
29
- export { DEFAULT_CLAUDE_CODE_TOML_PATH, DEFAULT_CODEX_CONFIG_PATH, SyncOptions, SyncResultData, syncClaudeTomlToCodex };
32
+ export { DEFAULT_CLAUDE_CODE_TOML_PATH, DEFAULT_CODEX_CONFIG_PATH, SyncOptions, SyncResultData, syncClaudeTomlToCodex, syncCodexTomlToClaude };
@@ -1 +1 @@
1
- import"../../errors-DMQ0N3V2.js";import"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import{n as e,r as t,t as n}from"../../sync-C39sJRnz.js";export{n as DEFAULT_CLAUDE_CODE_TOML_PATH,e as DEFAULT_CODEX_CONFIG_PATH,t as syncClaudeTomlToCodex};
1
+ import"../../errors-DMQ0N3V2.js";import"../../format-CYV2tIph.js";import"../../fsStore-iYRoM63Y.js";import{i as e,n as t,r as n,t as r}from"../../sync-F4vZCogY.js";export{r as DEFAULT_CLAUDE_CODE_TOML_PATH,t as DEFAULT_CODEX_CONFIG_PATH,n as syncClaudeTomlToCodex,e as syncCodexTomlToClaude};
@@ -1,4 +1,4 @@
1
- import { t as ConfigObject } from "../../../types-vDRpkfsj.js";
1
+ import { n as ConfigObject } from "../../../types-QfiJTz-B.js";
2
2
 
3
3
  //#region src/services/settings/templates/claudeDefault.d.ts
4
4
  declare const CLAUDE_SETTINGS_TEMPLATE: ConfigObject;
@@ -0,0 +1 @@
1
+ import{t as e}from"./errors-DMQ0N3V2.js";import{a as t}from"./format-CYV2tIph.js";import{f as n,o as r,p as i,t as a,u as o}from"./fsStore-iYRoM63Y.js";const s=`~/.claude/config.toml`,c=`~/.codex/config.toml`;function l(e={}){return d({...e,defaultSource:s,defaultTarget:c,currentLabel:e.currentLabel??`codex`,nextLabel:e.nextLabel??`claude`})}function u(e={}){return d({...e,defaultSource:c,defaultTarget:s,currentLabel:e.currentLabel??`claude`,nextLabel:e.nextLabel??`codex`})}function d(n){let s=n.sourcePath??n.defaultSource,c=n.targetPath??n.defaultTarget,l=n.backup??!0,u=n.dryRun??!1,d=i(s),p=i(c);if(d===p)throw Error(`Source and target config paths are identical.`);if(!r(d))throw new e(d);let m=r(p),h=o(d),g=m?o(p):``;f(d),m&&f(p);let _=t(g,h,{current:n.currentLabel,next:n.nextLabel}),v=!!_,y=l&&m?`${p}.bak`:void 0,b={source:d,target:p,backupPath:v?y:void 0,changed:v,dryRun:u,diff:_};return u?{success:!0,message:v?`Changes detected. Run without --dry-run to apply.`:`Already in sync. No changes needed.`,filePath:p,data:b,diff:_??void 0}:v?(l&&m&&(b.backupPath=y,a(p,y)),a(d,p),{success:!0,message:l&&m?`Synced config.toml (backup created).`:`Synced config.toml.`,filePath:p,data:b,diff:_??void 0}):{success:!0,message:`Already in sync. No changes applied.`,filePath:p,data:b}}function f(e){return n(e)}export{u as i,c as n,l as r,s as t};
@@ -10,9 +10,16 @@ type ConfigValue = string | number | boolean | null | Date | ConfigValue[] | Con
10
10
  interface ConfigObject {
11
11
  [key: string]: ConfigValue;
12
12
  }
13
+ interface CodexProviderInput {
14
+ id: string;
15
+ name: string;
16
+ base_url: string;
17
+ experimental_bearer_token: string;
18
+ }
13
19
  interface EditOptions {
14
20
  name?: string;
15
21
  ide?: string;
22
+ provider?: CodexProviderInput;
16
23
  }
17
24
  interface SwitchOptions {
18
25
  preview?: boolean;
@@ -46,6 +53,7 @@ interface SettingsPayload {
46
53
  profile?: string;
47
54
  name?: string;
48
55
  ide?: string;
56
+ provider?: CodexProviderInput;
49
57
  format?: OutputFormat;
50
58
  switchOptions?: SwitchOptions;
51
59
  }
@@ -105,4 +113,4 @@ interface LaunchCommandSpec {
105
113
  envVars?: Record<string, string>;
106
114
  }
107
115
  //#endregion
108
- export { LaunchCommandSpec as a, OutputFormat as c, SettingsFileEntry as d, SettingsListData as f, ToolId as g, SwitchOptions as h, InspectResult as i, Scope as l, SettingsResult as m, ConfigValue as n, LaunchPayload as o, SettingsPayload as p, EditOptions as r, LaunchResult as s, ConfigObject as t, SettingAction as u };
116
+ export { ToolId as _, InspectResult as a, LaunchResult as c, SettingAction as d, SettingsFileEntry as f, SwitchOptions as g, SettingsResult as h, EditOptions as i, OutputFormat as l, SettingsPayload as m, ConfigObject as n, LaunchCommandSpec as o, SettingsListData as p, ConfigValue as r, LaunchPayload as s, CodexProviderInput as t, Scope as u };
@@ -1,4 +1,4 @@
1
- import { d as SettingsFileEntry, n as ConfigValue, t as ConfigObject } from "../types-vDRpkfsj.js";
1
+ import { f as SettingsFileEntry, n as ConfigObject, r as ConfigValue } from "../types-QfiJTz-B.js";
2
2
 
3
3
  //#region src/utils/format.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { a as LaunchCommandSpec } from "../types-vDRpkfsj.js";
1
+ import { o as LaunchCommandSpec } from "../types-QfiJTz-B.js";
2
2
 
3
3
  //#region src/utils/runner.d.ts
4
4
  interface SpawnOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xling",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Unified CLI for managing AI tool settings",
5
5
  "homepage": "https://github.com/kingsword09/xling/tree/main#readme",
6
6
  "bugs": {
@@ -1 +0,0 @@
1
- import{c as e}from"./errors-DMQ0N3V2.js";import{a as t,c as n,f as r,h as i,o as a,p as o,r as s,t as c}from"./fsStore-iYRoM63Y.js";import{t as l}from"./base-CojCfrYM.js";const u=`~/.codex/auth-profiles`,d=`~/.codex/auth.json`;var f=class extends l{toolId=`codex`;async list(t){if(!this.validateScope(t))throw new e(t);let n=this.resolvePath(t),r=this.readConfig(n);return{type:`entries`,entries:this.#n(r),filePath:n}}resolvePath(e){switch(e){case`user`:return`~/.codex/config.toml`;default:throw Error(`Unsupported scope for Codex: ${e}`)}}validateScope(e){return e===`user`}async switchProfile(t,n,r){if(!this.validateScope(t))throw new e(t);return this.isAuthProfile(n)?this.#e(n):this.#t(t,n)}listAuthProfiles(){return n(u).filter(e=>e.endsWith(`.json`)).map(e=>e.replace(`.json`,``))}isAuthProfile(e){return a(`${u}/${e}.json`)}saveAuthProfile(e,n=!1){let r=`${u}/${e}.json`;return a(d)?!n&&a(r)?{success:!1,message:`Profile "${e}" already exists. Use --force to overwrite.`}:(t(u),c(d,r),s(d),{success:!0,message:`Saved current auth as profile: ${e}\nauth.json has been removed. You can now login with another account.`,filePath:o(r)}):{success:!1,message:`No auth.json found. Please run 'codex login' first.`}}deleteAuthProfile(e){let t=`${u}/${e}.json`;return a(t)?(s(t),{success:!0,message:`Deleted auth profile: ${e}`}):{success:!1,message:`Auth profile "${e}" not found.`}}getAllSwitchableProfiles(e){let t=this.resolvePath(e),n=[];try{let e=this.readConfig(t),r=e.model_providers;p(r)&&(n=Object.keys(r));let i=e.profiles;p(i)&&(n=[...new Set([...n,...Object.keys(i)])])}catch{}let r=this.listAuthProfiles();return{providers:n,authProfiles:r}}#e(e){let t=`${u}/${e}.json`,n=`~/.codex/config.toml`;if(!a(t))return{success:!1,message:`Auth profile "${e}" not found.`};c(t,d);try{let e=this.readConfig(n);e.model_provider&&(delete e.model_provider,this.writeConfig(n,e))}catch{}return{success:!0,message:`Switched to auth profile: ${e}`,filePath:o(d)}}#t(e,t){let n=this.resolvePath(e);a(d)&&s(d);let r=this.readConfig(n),i=r.profiles,c=(p(i)?i:void 0)?.[t];if(p(c)){let e={...r};for(let[t,n]of Object.entries(c))e[t]=n;return e.current_profile=t,this.writeConfig(n,e),{success:!0,message:`Switched to profile: ${t}`,filePath:o(n)}}let l={...r,model_provider:t};return this.writeConfig(n,l),{success:!0,message:`Switched to provider: ${t}`,filePath:o(n)}}readConfig(e){return r(e)}writeConfig(e,t){i(e,t,!1)}#n(e){let t=e.model_providers;return p(t)?t:{}}};const p=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date);export{p as n,f as t};
@@ -1 +0,0 @@
1
- import{p as e}from"./config-CGH3WLbz.js";import{t}from"./xling-DqZuT8CZ.js";import{t as n}from"./errorClassifier-BtDItoIE.js";import{t as r}from"./loadBalancer-B-jkwy15.js";import{c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./transformer-B_JzskvR.js";const f=4320;function p(){return`req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function m(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e==null)return``;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return`[object Object]`}return typeof e==`symbol`?e.toString():typeof e==`function`?e.name||`[function]`:``}async function h(e={}){let n=new t,i=n.readConfig(n.resolvePath(`user`));if(!i.providers?.length)throw Error(`No providers configured in ~/.claude/xling.json. Add a 'providers' array.`);let a=i.proxy??{},o=e.host??a.host??`127.0.0.1`,s=e.port??a.port??f,c=e.accessKey??a.accessKey,l=new r(a.loadBalance??`failover`,a.keyRotation?.cooldownMs??6e4),u=Bun.serve({hostname:o,port:s,async fetch(t){let n=new URL(t.url).pathname;if(t.method===`OPTIONS`)return new Response(null,{status:204,headers:C()});if(n===`/health`||n===`/`)return Response.json({status:`ok`,providers:i.providers.map(e=>e.name),loadBalance:a.loadBalance??`failover`},{headers:C()});if(n===`/stats`)return Response.json({stats:l.getStats()},{headers:C()});if(n===`/v1/models`||n===`/models`){let e=T(i.providers);return Response.json(e,{headers:C()})}if(c){let r=t.headers.get(`authorization`)?.replace(/^Bearer\s+/i,``);if(r!==c)return e.logger&&(console.log(`[auth] Access key validation failed for path: ${n}`),console.log(`[auth] Expected: ${c.slice(0,4)}...`),console.log(`[auth] Received: ${r?r.slice(0,4)+`...`:`(none)`}`)),Response.json({error:{message:`Invalid access key`,type:`auth_error`}},{status:401,headers:C()})}return n.startsWith(`/v1/`)||n.startsWith(`/claude/`)||n.startsWith(`/openai/`)||n===`/responses`||n===`/messages`||n===`/chat/completions`?(e.logger&&console.log(`[proxy] Handling request: ${t.method} ${n}`),g(t,n,{providers:i.providers,modelMapping:a.modelMapping,defaultModel:i.defaultModel,passthroughResponsesAPI:a.passthroughResponsesAPI,keyRotation:a.keyRotation},l,e.logger??!0)):(e.logger&&console.log(`[proxy] 404 Not Found: ${t.method} ${n}`),Response.json({error:{message:`Not found`,type:`not_found`}},{status:404,headers:C()}))}});return{baseUrl:`http://${o}:${s}`,providers:i.providers.map(e=>e.name),models:i.providers.flatMap(e=>e.models.map(t=>`${e.name},${t}`)),server:u,shutdown:async()=>{await u.stop()}}}async function g(t,r,i,s,l){let u={requestId:p(),startTime:Date.now(),retryCount:0},f=r;r.startsWith(`/claude/`)?f=r.replace(`/claude`,``):r.startsWith(`/openai/`)&&(f=r.replace(`/openai`,``)),f.startsWith(`/v1/v1/`)&&(f=f.replace(`/v1/v1/`,`/v1/`));let h;if(t.headers.get(`content-type`)?.includes(`application/json`))try{h=await t.json()}catch{return Response.json({error:{message:`Invalid JSON body`,type:`invalid_request`}},{status:400,headers:C()})}let g=a(h),T=c(h),E=h,D=!1,O=`openai`,k=v(h),A=y(k,i.modelMapping,i.defaultModel);if(g&&h&&typeof h==`object`){let e=h;e.model=A||k,D=e.stream===!0,O=`anthropic`,E=d(e),(f===`/v1/messages`||f===`/messages`)&&(f=`/v1/chat/completions`),l&&console.log(`[${u.requestId}] Converting Anthropic -> OpenAI format (path: ${f})`)}else if(T&&h&&typeof h==`object`){let e=h;if(e.model=A||k,D=e.stream===!0,(i.passthroughResponsesAPI??[]).some(t=>t.endsWith(`*`)?String(e.model).startsWith(t.slice(0,-1)):e.model===t))O=`openai`,E=e,l&&console.log(`[${u.requestId}] Responses API passthrough (native support): model=${m(e.model)}`);else{if(O=`responses`,l){let t=m(e.model);if(console.log(`[${u.requestId}] Responses API request: stream=${D}, model=${t}`),e.tools){let t=e.tools;console.log(`[${u.requestId}] Tools count: ${t.length}`),t.slice(0,5).forEach((e,t)=>{let n=e,r=m(n.type),i=m(n.function?.name??n.name??`N/A`);console.log(`[${u.requestId}] Tool[${t}]: type=${r}, name=${i}, keys=${Object.keys(n).join(`,`)}`)})}else console.log(`[${u.requestId}] No tools in request`)}if(E=o(e),(f===`/v1/responses`||f===`/responses`)&&(f=`/v1/chat/completions`),l){console.log(`[${u.requestId}] Converting Responses API -> OpenAI format (path: ${f})`);let e=E?.tools;e?console.log(`[${u.requestId}] Converted tools count: ${e.length}`):console.log(`[${u.requestId}] No tools after conversion`)}}}else h&&typeof h==`object`&&A&&A!==k&&(h.model=A,E=h,D=h.stream===!0);l&&A&&A!==k&&console.log(`[${u.requestId}] Model mapped: ${k} -> ${A}`);let j=A,M=i.keyRotation?.enabled===!1?1:i.providers.length*2,N=null;for(;u.retryCount<M;){let r=S(i.providers,s,j);if(!r)return Response.json({error:{message:`No available providers`,type:`service_unavailable`}},{status:503,headers:C()});u.provider=r.name;let a=e(r),o=s.getProviderState(r.name),c=o?s.selectKey({...r,apiKeys:a},o):a[0];if(!c){u.retryCount++;continue}let d=a.indexOf(c);u.keyIndex=d,l&&console.log(`[${u.requestId}] -> ${r.name} (key ${d+1}/${a.length})`);try{let e=await _(t,r,c,f,E);if(e.ok){if(s.reportSuccess(r.name,d),l){let t=Date.now()-u.startTime;console.log(`[${u.requestId}] <- ${e.status} (${t}ms)`)}return O===`anthropic`?await b(e,k||`unknown`,D,l,u.requestId):O===`responses`?await x(e,k||`unknown`,D,l,u.requestId):w(e)}let a=await e.clone().json().catch(()=>null),o=n(e.status,a);if(s.reportError(r.name,d,o),l&&console.log(`[${u.requestId}] Error: ${o.type} - ${o.message}`),o.retryable&&i.keyRotation?.onError!==!1){u.retryCount++,N=e;continue}return w(e)}catch(e){let t=n(0,void 0,e);if(s.reportError(r.name,d,t),l&&console.log(`[${u.requestId}] Network error: ${t.message}`),t.retryable){u.retryCount++;continue}return Response.json({error:{message:t.message,type:t.type}},{status:502,headers:C()})}}return N?w(N):Response.json({error:{message:`All providers failed after retries`,type:`service_unavailable`}},{status:503,headers:C()})}async function _(e,t,n,r,i){let a=t.baseUrl.replace(/\/+$/,``),o=r;a.endsWith(`/v1`)&&r.startsWith(`/v1/`)&&(o=r.slice(3));let s=`${a}${o}`,c={"Content-Type":`application/json`,Authorization:`Bearer ${n}`};t.headers&&Object.assign(c,t.headers);for(let t of[`accept`,`accept-encoding`,`x-request-id`]){let n=e.headers.get(t);n&&(c[t]=n)}let l={method:e.method,headers:c};if(i&&e.method!==`GET`&&e.method!==`HEAD`&&(l.body=JSON.stringify(i)),t.timeout){let e=new AbortController,n=setTimeout(()=>e.abort(),t.timeout);l.signal=e.signal;try{let e=await fetch(s,l);return clearTimeout(n),e}catch(e){throw clearTimeout(n),e}}return fetch(s,l)}function v(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.model==`string`)return t.model}function y(e,t,n){if(!e)return n;if(!t||Object.keys(t).length===0)return e;if(t[e])return t[e];for(let[n,r]of Object.entries(t))if(n.endsWith(`*`)){let t=n.slice(0,-1);if(e.startsWith(t))return r}return t[`*`]?t[`*`]:n??e}async function b(e,t,n,r,i){if(n){r&&console.log(`[${i}] Converting streaming response OpenAI -> Anthropic`);let n=l(t),a=e.body?.pipeThrough(n);return new Response(a,{status:200,headers:{...C(),"Content-Type":`text/event-stream`,"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"X-Accel-Buffering":`no`}})}try{let n=await e.text(),a;try{a=JSON.parse(n)}catch{r&&console.log(`[${i}] Response is not JSON, wrapping as text`),a={content:n}}r&&console.log(`[${i}] Response type: ${typeof a}, keys: ${Object.keys(a).join(`, `)}`);let o=u(a,t);return r&&console.log(`[${i}] Converted response OpenAI -> Anthropic`),Response.json(o,{status:200,headers:C()})}catch(e){return console.error(`[${i}] Response conversion failed:`,e),Response.json({type:`error`,error:{type:`api_error`,message:`Response conversion failed: ${e.message}`}},{status:500,headers:C()})}}async function x(e,t,n,r,a){if(n){r&&console.log(`[${a}] Converting streaming response OpenAI -> Responses API`);let n=s(t),i=e.body?.pipeThrough(n);return new Response(i,{status:200,headers:{...C(),"Content-Type":`text/event-stream`,"Cache-Control":`no-cache, no-transform`,Connection:`keep-alive`,"X-Accel-Buffering":`no`}})}try{let n=await e.text(),o;try{o=JSON.parse(n)}catch{r&&console.log(`[${a}] Response is not JSON, wrapping as text`),o={content:n}}r&&console.log(`[${a}] Response type: ${typeof o}, keys: ${Object.keys(o).join(`, `)}`);let s=i(o,t);return r&&console.log(`[${a}] Converted response OpenAI -> Responses API`),Response.json(s,{status:200,headers:C()})}catch(e){return console.error(`[${a}] Response conversion failed:`,e),Response.json({id:`resp_${Date.now()}`,object:`response`,created_at:Math.floor(Date.now()/1e3),model:t,output:[],status:`failed`,error:{code:`api_error`,message:`Response conversion failed: ${e.message}`}},{status:500,headers:C()})}}function S(t,n,r){let i=t.map(t=>({...t,apiKeys:e(t)}));if(r?.includes(`,`)){let[e]=r.split(`,`),t=i.find(t=>t.name===e);if(t)return t}if(r){let e=i.filter(e=>e.models.some(e=>e===r||r.startsWith(e)));if(e.length>0)return n.selectProvider(e)}return n.selectProvider(i)}function C(){return{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, DELETE, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type, Authorization, X-Request-ID`,"Access-Control-Max-Age":`86400`}}function w(e){let t=new Headers(e.headers);for(let[e,n]of Object.entries(C()))t.set(e,n);return new Response(e.body,{status:e.status,statusText:e.statusText,headers:t})}function T(e){let t=Math.floor(Date.now()/1e3),n=[],r=new Set;for(let i of e)for(let e of i.models){let a=`${i.name},${e}`;r.has(a)||(r.add(a),n.push({id:a,object:`model`,created:t,owned_by:i.name})),r.has(e)||(r.add(e),n.push({id:e,object:`model`,created:t,owned_by:i.name}))}return{object:`list`,data:n}}export{h as n,f as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./errors-DMQ0N3V2.js";import{a as t}from"./format-CYV2tIph.js";import{f as n,o as r,p as i,t as a,u as o}from"./fsStore-iYRoM63Y.js";const s=`~/.claude/config.toml`,c=`~/.codex/config.toml`;function l(n={}){let l=n.sourcePath??s,d=n.targetPath??c,f=n.backup??!0,p=n.dryRun??!1,m=i(l),h=i(d);if(m===h)throw Error(`Source and target config paths are identical.`);if(!r(m))throw new e(m);let g=r(h),_=o(m),v=g?o(h):``;u(m),g&&u(h);let y=t(v,_,{current:`codex`,next:`claude`}),b=!!y,x=f&&g?`${h}.bak`:void 0,S={source:m,target:h,backupPath:b?x:void 0,changed:b,dryRun:p,diff:y};return p?{success:!0,message:b?`Changes detected. Run without --dry-run to apply.`:`Already in sync. No changes needed.`,filePath:h,data:S,diff:y??void 0}:b?(f&&g&&(S.backupPath=x,a(h,x)),a(m,h),{success:!0,message:f&&g?`Synced config.toml (backup created).`:`Synced config.toml.`,filePath:h,data:S,diff:y??void 0}):{success:!0,message:`Already in sync. No changes applied.`,filePath:h,data:S}}function u(e){return n(e)}export{c as n,l as r,s as t};