Files
openhuman/app/src/utils/config.ts
T
Mega MindandGitHub 5551e1e0aa Fix/365 enforce latest oauth gate from 351 (#421)
* feat: display app version in settings panel

* fix(onboarding): auto-refresh accessibility state after grant (#351)

* style(onboarding): apply formatter for issue #351 fix

* fix(onboarding): ESLint + typed mock for ScreenPermissionsStep; clear flag in handler

Consolidate tauriCommands imports and drop redundant mock cast.

Handle granted accessibility in focus/visibility callback instead of a follow-up effect.

Made-with: Cursor

* fix(release): gate OAuth deep links on minimum app version (#365)

- Add semver helpers and VITE_MINIMUM_SUPPORTED_APP_VERSION / download URL in app config
- Block openhuman://oauth/success when desktop build is below minimum; enqueue error,
  open latest-release URL, dispatch oauth:stale-app
- Pass new Vite env vars through release.yml and build-windows.yml Build frontend
- Document policy in docs/RELEASE_POLICY.md; note vars in app/.env.example

Closes #365

Made-with: Cursor

* fix: import React in SkillSetupWizard component

* fix: address CodeRabbit review (OAuth gate, semver, logging)

- Anchor semver regex to full string; arrow-style exports; tests for bad inputs
- Never throw from evaluateOAuthAppVersionGate; try/catch in deep link + omit raw URL from error logs
- Document build-time vs runtime policy in config JSDoc and RELEASE_POLICY
- Remove unused React import in SkillSetupWizard (tsc)

Made-with: Cursor

* fix: CodeRabbit — fail-closed OAuth gate, tauri-action Vite env, runbook

- Block OAuth when minimum is set but getVersion fails or version is unparseable
- Pass VITE_MINIMUM_* through tauri-action env (release + Windows) so bundles match yarn build
- Expand RELEASE_POLICY: artifact retirement, dual workflow env note
- Friendlier copy when current version is unknown

Made-with: Cursor
2026-04-08 04:26:19 +05:30

66 lines
3.0 KiB
TypeScript

import packageJson from '../../package.json';
export const CORE_RPC_URL =
import.meta.env.VITE_OPENHUMAN_CORE_RPC_URL || 'http://127.0.0.1:7788/rpc';
/** Matches core `OPENHUMAN_TOOL_TIMEOUT_SECS` (default 120s, max 3600s). */
const DEFAULT_TOOL_TIMEOUT_SECS = 120;
const MAX_TOOL_TIMEOUT_SECS = 3600;
function parseToolTimeoutSecs(): number {
const raw = import.meta.env.VITE_TOOL_TIMEOUT_SECS as string | undefined;
if (raw === undefined || raw === '') return DEFAULT_TOOL_TIMEOUT_SECS;
const n = Number(raw);
if (!Number.isFinite(n) || n <= 0 || n > MAX_TOOL_TIMEOUT_SECS) {
return DEFAULT_TOOL_TIMEOUT_SECS;
}
return Math.round(n);
}
export const TOOL_TIMEOUT_SECS = parseToolTimeoutSecs();
export const IS_DEV = import.meta.env.DEV;
/** Dev only: skip `.skip_onboarding` workspace check and ignore onboarded state so `/onboarding` always shows. Set `VITE_DEV_FORCE_ONBOARDING=true` in `.env.local`. */
export const DEV_FORCE_ONBOARDING =
import.meta.env.DEV && import.meta.env.VITE_DEV_FORCE_ONBOARDING === 'true';
export const SKILLS_GITHUB_REPO =
import.meta.env.VITE_SKILLS_GITHUB_REPO || 'tinyhumansai/openhuman-skills';
/** Sentry DSN for error reporting. Leave blank to disable. */
export const SENTRY_DSN = import.meta.env.VITE_SENTRY_DSN as string | undefined;
/** Backend API URL (web fallback when core RPC is unavailable). */
export const BACKEND_URL = import.meta.env.VITE_BACKEND_URL as string | undefined;
/** Telegram bot username used for managed DM linking when backend does not return a launch URL. */
export const TELEGRAM_BOT_USERNAME =
(import.meta.env.VITE_TELEGRAM_BOT_USERNAME as string | undefined) || 'openhuman_bot';
/** Dev only: auto-inject JWT token to skip login flow. */
export const DEV_JWT_TOKEN = import.meta.env.DEV
? (import.meta.env.VITE_DEV_JWT_TOKEN as string | undefined)
: undefined;
export const APP_VERSION = packageJson.version;
/**
* Minimum **desktop app** semver required for OAuth deep-link completion (`openhuman://oauth/success`).
*
* **Build-time embedding:** This value is baked into each shipped installer. Raising the floor for
* users already on an older build requires them to install a **new** release (or use in-app update
* when available)—changing CI vars alone does not retrofit existing binaries. For a fleet-wide
* minimum that can move without a new app build, add a runtime policy endpoint later and consult it
* here with this constant as fallback only.
*
* Set in production builds (e.g. GitHub Actions `vars`). Empty = no gate (default for local dev).
*/
export const MINIMUM_SUPPORTED_APP_VERSION =
(import.meta.env.VITE_MINIMUM_SUPPORTED_APP_VERSION as string | undefined)?.trim() ?? '';
/** Recovery link opened when OAuth is blocked due to an outdated app build (build-time default; override via CI). */
export const LATEST_APP_DOWNLOAD_URL =
(import.meta.env.VITE_LATEST_APP_DOWNLOAD_URL as string | undefined)?.trim() ||
'https://github.com/tinyhumansai/openhuman/releases/latest';