Files
recap/startos/actions/setOpenAICompatible.ts
Keysat 0ae59f3550 Add multi-tenant cloud mode: self-serve purchase, credit metering, core-decoupling
Introduces RECAP_MODE=multi alongside single-mode self-host:
- Tenant auth + accounts (magic-link via System SMTP), per-tenant credit pool,
  anonymous trial minting with per-IP/-64 caps
- Self-serve Pro/Max purchase: inline Lightning (BTCPay) + card (Zaprite),
  prepaid 30-day periods, expiry-reminder emails
- Core-decoupling: relay owns cloud tier/expiry keyed by Recaps user-id
- SQLite (better-sqlite3) schema for multi-mode; filesystem unchanged for single
- StartOS actions/versions through 0.2.155
2026-06-13 14:25:05 -05:00

65 lines
1.9 KiB
TypeScript

import { sdk } from '../sdk'
import { configFile } from '../file-models/config.json'
const { InputSpec, Value } = sdk
const inputSpec = InputSpec.of({
openai_compatible_base_url: Value.text({
name: 'Base URL',
description:
'OpenAI-compatible API endpoint. Examples: https://api.deepseek.com/v1, https://api.together.xyz/v1, https://api.groq.com/openai/v1. Must include the /v1 (or equivalent) path segment.',
required: true,
default: null,
minLength: 1,
maxLength: 512,
patterns: [
{
regex: '^https?://.+',
description: 'Must start with http:// or https://',
},
],
}),
openai_compatible_api_key: Value.text({
name: 'API Key',
description:
'API key for the OpenAI-compatible backend. Some self-hosted backends accept any non-empty value — leave blank for those.',
required: false,
default: null,
masked: true,
minLength: 0,
maxLength: 256,
}),
})
export const setOpenAICompatible = sdk.Action.withInput(
'set-openai-compatible',
async ({ effects }) => ({
name: 'Set OpenAI-Compatible Backend',
description:
'Point Recaps at any OpenAI-compatible chat-completions API: DeepSeek, Together, Groq, Fireworks, self-hosted vLLM, etc. Used for topic analysis only — does not transcribe audio.',
warning: null,
allowedStatuses: 'any',
group: 'AI Providers',
visibility: 'enabled',
}),
inputSpec,
async ({ effects }) => {
const config = await configFile.read().once()
return {
openai_compatible_base_url: config?.openai_compatible_base_url || undefined,
openai_compatible_api_key: config?.openai_compatible_api_key || undefined,
}
},
async ({ effects, input }) => {
await configFile.merge(effects, {
openai_compatible_base_url: (input.openai_compatible_base_url || '').trim(),
openai_compatible_api_key: (input.openai_compatible_api_key || '').trim(),
})
return null
},
)