mirror of
https://github.com/stablyai/orca.git
synced 2026-11-03 10:37:35 +00:00
* feat(accounts): link standalone GLM Coding Plans Adapt the reviewed GLM accounts contribution to current main, retain Antigravity behavior, guard late credential results, expose storage protection, and redact quota errors. Co-authored-by: Luchong <lu740528977@gmail.com> * fix(accounts): retain GLM credential results during quota refresh * fix(accounts): make GLM credential editing desktop-only * fix(accounts): mirror the host GLM site in paired clients * fix(accounts): report unknown GLM host details and split web settings tests Apply the independently reviewed Accounts correction from697284a without the v2 adapter commits. Preserve the saved-key store and serialized write behavior. * fix(zcode): ship required GLM account translation entries * chore: record GLM reconciliation hook validation * chore: validate installed GLM commit hooks * test: complete GLM account fixtures and web API inventory --------- Co-authored-by: Luchong <lu740528977@gmail.com>
50 lines
2.0 KiB
TypeScript
50 lines
2.0 KiB
TypeScript
import { ipcMain } from 'electron'
|
|
import {
|
|
clearZcodePlanApiKey,
|
|
getZcodePlanApiKeyProtection,
|
|
hasZcodePlanApiKey,
|
|
saveZcodePlanApiKey
|
|
} from '../zcode/zcode-plan-api-key-store'
|
|
import { hasZcodeCliPlanCredentials } from '../rate-limits/zcode-usage-fetcher'
|
|
import type { RateLimitService } from '../rate-limits/service'
|
|
import type { ZcodePlanCredentialsStatus } from '../../shared/zcode-plan-sites'
|
|
|
|
function getZcodePlanCredentialsStatus(): ZcodePlanCredentialsStatus {
|
|
return {
|
|
apiKeyConfigured: hasZcodePlanApiKey(),
|
|
zcodeCliConfigured: hasZcodeCliPlanCredentials(),
|
|
apiKeyProtection: getZcodePlanApiKeyProtection()
|
|
}
|
|
}
|
|
|
|
// Why: fire-and-forget — callers get the persisted credential status immediately;
|
|
// the rate-limit refresh runs in the background and only logs on failure.
|
|
function refreshAfterZcodePlanCredentialChange(
|
|
rateLimits: RateLimitService | null,
|
|
action: 'save' | 'clear'
|
|
): void {
|
|
rateLimits?.invalidateZcodeCredentialState()
|
|
void rateLimits?.refresh().catch((error: unknown) => {
|
|
console.error(`[zcode] failed to trigger rate-limit refresh after ${action}:`, error)
|
|
})
|
|
}
|
|
|
|
export function registerZcodePlanCredentialsHandlers(rateLimits: RateLimitService | null): void {
|
|
ipcMain.handle('zcodePlanCredentials:getStatus', () => getZcodePlanCredentialsStatus())
|
|
ipcMain.handle('zcodePlanCredentials:saveApiKey', (_event, key: string) => {
|
|
// Validate the IPC argument in the main process; the renderer-declared type
|
|
// is compile-time only and the value arrives as unknown over IPC.
|
|
if (typeof key !== 'string') {
|
|
throw new Error('GLM Coding Plan API key must be a string')
|
|
}
|
|
saveZcodePlanApiKey(key)
|
|
refreshAfterZcodePlanCredentialChange(rateLimits, 'save')
|
|
return getZcodePlanCredentialsStatus()
|
|
})
|
|
ipcMain.handle('zcodePlanCredentials:clearApiKey', () => {
|
|
clearZcodePlanApiKey()
|
|
refreshAfterZcodePlanCredentialChange(rateLimits, 'clear')
|
|
return getZcodePlanCredentialsStatus()
|
|
})
|
|
}
|