docs(ocm): refresh env and CLI guides and redact internal settings secrets

This commit is contained in:
Chris Scott committed 2026-10-07 22:17:46 -04:00
1 parent 4553af41dc
commit 4b6df6cf5f
9 files changed
+178 -57

No files matched your search

+34 -4
View File
@@ -1,15 +1,45 @@
import { Hono } from 'hono'
import { AssistantSettingsPatchSchema } from '@opencode-manager/shared/schemas'
import type { SettingsService } from '../../services/settings'
import type { UserPreferences } from '@opencode-manager/shared/types'
import type { SettingsResponse, UserPreferences } from '@opencode-manager/shared/types'
import { OPENCODE_CONFIG_REDACTED_VALUE } from '../../services/opencode-config-file'
function redactSecret<T extends string | undefined>(value: T): T {
return (value ? OPENCODE_CONFIG_REDACTED_VALUE : value) as T
}
/**
* Replaces stored credentials in a settings response with `<redacted>` so token clients such as the
* agent-facing `ocm` tool can read preferences without receiving secrets. Empty values stay empty, so a
* caller can still tell whether a credential is configured.
*/
function redactInternalSettings(settings: SettingsResponse): SettingsResponse {
const { preferences } = settings
return {
...settings,
preferences: {
...preferences,
gitCredentials: preferences.gitCredentials?.map((credential) => ({
...credential,
token: redactSecret(credential.token),
sshPrivateKey: redactSecret(credential.sshPrivateKey),
sshPrivateKeyEncrypted: redactSecret(credential.sshPrivateKeyEncrypted),
passphrase: redactSecret(credential.passphrase),
})),
tts: preferences.tts && { ...preferences.tts, apiKey: redactSecret(preferences.tts.apiKey) },
stt: preferences.stt && { ...preferences.stt, apiKey: redactSecret(preferences.stt.apiKey) },
serverEnvVars: preferences.serverEnvVars?.map((envVar) => ({ ...envVar, value: redactSecret(envVar.value) })),
lastKnownGoodConfig: redactSecret(preferences.lastKnownGoodConfig),
},
}
}
export function createInternalSettingsRoutes(settingsService: SettingsService) {
const app = new Hono()
app.get('/', (c) => {
const userId = c.req.query('userId') ?? 'default'
const settings = settingsService.getSettings(userId)
return c.json(settings)
return c.json(redactInternalSettings(settingsService.getSettings(userId)))
})
app.patch('/', async (c) => {
@@ -49,7 +79,7 @@ export function createInternalSettingsRoutes(settingsService: SettingsService) {
}
const updated = settingsService.updateSettings(updates as Partial<UserPreferences>, userId)
return c.json(updated)
return c.json(redactInternalSettings(updated))
})
return app
+1 -1
View File
@@ -611,7 +611,7 @@ Use the \`${MANAGER_TOOL_NAME}\` tool with the \`request\` action. The tool runs
### GET /settings
Retrieve the user's full settings, including all preferences.
Retrieve the user's full settings, including all preferences. Stored credentials (git credential tokens, SSH keys and passphrases, TTS and STT API keys, server environment variable values, and the last known good config) are replaced with \`<redacted>\`; an empty value means none is set. PATCH responses are redacted the same way.
**Query Parameters:**
- \`userId\` (optional): User ID. Defaults to \`"default"\`.