feat(settings): Codex Bağlama, on by default
Settings → Codex Bağlama runs the bundled bridge for an OpenAI Codex install on the same computer: the IDE's models and combos appear in Codex and switching models keeps the conversation. The IDE points Codex's openai_base_url at the bridge only after the bridge answers, keeps it running across logins, and removes every trace when the setting is turned off. A Codex that already uses another base URL is left untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HRDGW1LiKcDUZYUdKBoWYW
This commit is contained in:
1 parent
1ce5ab82cf
commit
dea67fc153
16 files changed
+2317
-2
No files matched your search
@@ -36,6 +36,7 @@ import { WebSocket as RelayWebSocket } from 'ws'
|
||||
|
||||
import { classifyActiveRuntime, needsPackagedRuntimeUpgrade } from './active-runtime-state'
|
||||
import { createAiturkCliRunner, createAiturkLogin } from './aiturk-login'
|
||||
import { createCodexLink, createNodeCodexLinkDeps } from './codex-link'
|
||||
import { createMobileBackendResolver } from './mobile-backend'
|
||||
import {
|
||||
createMobileLink,
|
||||
@@ -13091,6 +13092,9 @@ async function startHermes() {
|
||||
// accumulated count of the resolved episode.
|
||||
bootstrapRepairAttempt = 0
|
||||
|
||||
// The local backend is up, so the venv the Codex bridge runs on exists.
|
||||
syncCodexLinkOnBoot()
|
||||
|
||||
return {
|
||||
baseUrl,
|
||||
mode: 'local',
|
||||
@@ -17182,6 +17186,72 @@ ipcMain.handle('hermes:quick-entry:settings:set', async (_event, patch) => {
|
||||
return applyQuickEntrySettings(next)
|
||||
})
|
||||
|
||||
// Codex Link ("Codex Bağlama"): lets the OpenAI Codex on this machine use the
|
||||
// IDE's models through a small local bridge. Main owns the preference file, the
|
||||
// bridge process, Codex's config line and the login item; Settings reads the
|
||||
// resulting state and asks for changes over IPC. Windows only (the login item is
|
||||
// a Run-key value). All decisions live in electron/codex-link.ts.
|
||||
const AITURK_IDE_DATA_ROOT = path.dirname(HERMES_HOME)
|
||||
|
||||
const codexLink = createCodexLink(
|
||||
createNodeCodexLinkDeps(
|
||||
{
|
||||
settingsFile: path.join(AITURK_IDE_DATA_ROOT, 'codex-baglama.json'),
|
||||
bridgeHome: path.join(AITURK_IDE_DATA_ROOT, 'codex-bridge'),
|
||||
hermesHome: HERMES_HOME,
|
||||
bridgeScript: IS_PACKAGED
|
||||
? path.join(process.resourcesPath, 'codex-bridge', 'bridge.py')
|
||||
: path.join(APP_ROOT, 'assets', 'codex-bridge', 'bridge.py'),
|
||||
pythonw: path.join(VENV_ROOT, 'Scripts', 'pythonw.exe'),
|
||||
python: getVenvPython(VENV_ROOT),
|
||||
codexConfig: path.join(process.env.CODEX_HOME || path.join(app.getPath('home'), '.codex'), 'config.toml')
|
||||
},
|
||||
rememberLog
|
||||
)
|
||||
)
|
||||
|
||||
let codexLinkBootSynced = false
|
||||
|
||||
// Once per launch, after the local backend is ready. Never allowed to affect
|
||||
// startup: it is not awaited and every failure ends in the log.
|
||||
function syncCodexLinkOnBoot() {
|
||||
if (!IS_WINDOWS || codexLinkBootSynced) {
|
||||
return
|
||||
}
|
||||
|
||||
codexLinkBootSynced = true
|
||||
void codexLink.apply().catch(error => rememberLog(`[codex-link] boot sync failed: ${error?.message ?? error}`))
|
||||
}
|
||||
|
||||
// Only the primary window's top-level frame may read or change the link.
|
||||
function assertCodexLinkSender(event) {
|
||||
const contents = mainWindow && !mainWindow.isDestroyed() ? mainWindow.webContents : null
|
||||
|
||||
if (
|
||||
!IS_WINDOWS ||
|
||||
!contents ||
|
||||
event.sender !== contents ||
|
||||
(event.senderFrame && event.senderFrame !== contents.mainFrame)
|
||||
) {
|
||||
throw new Error('codex-link:unavailable')
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.handle('aiturk:codex-link:get', async event => {
|
||||
assertCodexLinkSender(event)
|
||||
|
||||
return codexLink.getStatus()
|
||||
})
|
||||
|
||||
ipcMain.handle('aiturk:codex-link:set', async (event, patch) => {
|
||||
assertCodexLinkSender(event)
|
||||
|
||||
return codexLink.apply({
|
||||
enabled: typeof patch?.enabled === 'boolean' ? patch.enabled : undefined,
|
||||
sync: patch?.sync === true
|
||||
})
|
||||
})
|
||||
|
||||
// Quick window → main → PRIMARY renderer. We never submit here: the renderer
|
||||
// owns the one prompt-submit path, and forwarding keeps it that way. The
|
||||
// payload is `{ target, text }` — target routing (current chat / a picked
|
||||
|
||||
Reference in new issue
Block a user