Skip to content

The agent that grows with you

Merge remote-tracking branch 'origin/main' into merge/main-3

emozilla479d19500a85
diff --cc apps/desktop/src/api/local-models.ts
index 00000000000,00000000000..4d449e1b9c2
new file mode 100644
--- /dev/null
+++ b/apps/desktop/src/api/local-models.ts
@@@ -1,0 -1,0 +1,99 @@@
++import type {
++ LocalCatalogModel,
++ LocalHardware,
++ LocalModelsStatus,
++ LocalRuntimeJob
++} from '@/types/hermes'
++
++import { hermesApi, profileScoped } from './client'
++
++// The desktop surface of the managed llama.cpp runtime: status/catalog
++// reads, download/install/activate jobs, and server control.
++
++export function getLocalModelsStatus(): Promise<LocalModelsStatus> {
++ return hermesApi<LocalModelsStatus>({
++ ...profileScoped(),
++ path: '/api/local-models/status'
++ })
++}
++
++export function getLocalHardware(): Promise<LocalHardware> {
++ return hermesApi<LocalHardware>({
++ ...profileScoped(),
++ path: '/api/local-models/hardware'
++ })
++}
++
++export function getLocalCatalog(): Promise<{ models: LocalCatalogModel[] }> {
++ return hermesApi<{ models: LocalCatalogModel[] }>({
++ ...profileScoped(),
++ path: '/api/local-models/catalog'
++ })
++}
++
++export function installLocalRuntime(backend?: string): Promise<{ backend: string; job_id: string; tag: string }> {
++ return hermesApi<{ backend: string; job_id: string; tag: string }>({
++ ...profileScoped(),
++ body: { backend: backend ?? null },
++ method: 'POST',
++ path: '/api/local-models/runtime/install'
++ })
++}
++
++export function downloadLocalModel(modelId: string): Promise<{ already_downloaded?: boolean; job_id: null | string }> {
++ return hermesApi<{ already_downloaded?: boolean; job_id: null | string }>({
++ ...profileScoped(),
++ body: { model_id: modelId },
++ method: 'POST',
++ path: '/api/local-models/download'
++ })
++}
++
++export function deleteLocalModel(modelId: string): Promise<{ ok: boolean }> {
++ return hermesApi<{ ok: boolean }>({
++ ...profileScoped(),
++ method: 'DELETE',
++ path: `/api/local-models/models/${encodeURIComponent(modelId)}`
++ })
++}
++
++export function getLocalRuntimeJob(jobId: string): Promise<LocalRuntimeJob> {
++ return hermesApi<LocalRuntimeJob>({
++ ...profileScoped(),
++ path: `/api/local-models/jobs/${encodeURIComponent(jobId)}`
++ })
++}
++
++export function getLocalModelsJobs(): Promise<{ jobs: LocalRuntimeJob[] }> {
++ return hermesApi<{ jobs: LocalRuntimeJob[] }>({
++ ...profileScoped(),
++ path: '/api/local-models/jobs'
++ })
++}
++
++export function activateLocalModel(modelId: string): Promise<{ job_id: string }> {
++ return hermesApi<{ job_id: string }>({
++ ...profileScoped(),
++ body: { model_id: modelId },
++ method: 'POST',
++ path: '/api/local-models/activate'
++ })
++}
++
++export function ejectLocalModel(modelId: string): Promise<{ ok: boolean }> {
++ return hermesApi<{ ok: boolean }>({
++ ...profileScoped(),
++ body: { model_id: modelId },
++ method: 'POST',
++ path: '/api/local-models/eject'
++ })
++}
++
++export function setLocalServer(action: 'start' | 'stop'): Promise<{ ok: boolean }> {
++ return hermesApi<{ ok: boolean }>({
++ ...profileScoped(),
++ body: { action },
++ method: 'POST',
++ path: '/api/local-models/server'
++ })
++}
diff --cc apps/desktop/src/hermes.ts
index 02116416e86,6242ef5998b..7bb69bc0854
--- a/apps/desktop/src/hermes.ts
+++ b/apps/desktop/src/hermes.ts
@@@ -1,141 -1,32 +1,33 @@@
- import { JsonRpcGatewayClient } from '@hermes/shared'
-
- import type { HermesApiRequest, HermesConnection } from '@/global'
- import { reconnectBackoffDelayMs } from '@/lib/reconnect-backoff'
- import { recordTranscriptTail } from '@/store/transcript-tail'
- import type {
- ActionResponse,
- ActionStatusResponse,
- AnalyticsResponse,
- AudioSpeakResponse,
- AudioTranscriptionResponse,
- AutomationBlueprint,
- AuxiliaryModelsResponse,
- BackendUpdateCheckResponse,
- ComputerUseStatus,
- ConfigSchemaResponse,
- CronDeliveryTarget,
- CronJob,
- CronJobCreatePayload,
- CronJobUpdates,
- CuratorStatusResponse,
- CustomEndpointsResponse,
- CustomEndpointUpdate,
- CustomEndpointValidationResponse,
- DebugShareResponse,
- ElevenLabsVoicesResponse,
- EnvVarInfo,
- HermesConfig,
- HermesConfigRecord,
- LocalCatalogModel,
- LocalHardware,
- LocalModelsStatus,
- LocalRuntimeJob,
- LogsResponse,
- McpCatalogResponse,
- McpServerSummary,
- MemoryProviderConfig,
- MemoryProviderOAuthStatus,
- MemoryStatusResponse,
- MessagingPlatformsResponse,
- MessagingPlatformTestResponse,
- MessagingPlatformUpdate,
- MoaConfigResponse,
- ModelAssignmentRequest,
- ModelAssignmentResponse,
- ModelInfoResponse,
- ModelOptionsResponse,
- OAuthPollResponse,
- OAuthProvidersResponse,
- OAuthStartResponse,
- OAuthSubmitResponse,
- PaginatedSessions,
- PairingResponse,
- PairingUser,
- ProfileCreatePayload,
- ProfileDesktopOverlay,
- ProfileSetupCommand,
- ProfileSoul,
- ProfilesResponse,
- SessionInfo,
- SessionMessage,
- SessionMessagesResponse,
- SessionSearchResponse,
- SkillHubPreview,
- SkillHubScanResult,
- SkillHubSearchResponse,
- SkillHubSourcesResponse,
- SkillInfo,
- StarmapGraph,
- StatusResponse,
- TerminalBackendsResponse,
- ToolsetConfig,
- ToolsetInfo,
- ToolsetModelsResponse,
- WebhookCreatePayload,
- WebhookCreateResponse,
- WebhookEnableResponse,
- WebhooksResponse
- } from '@/types/hermes'
-
- // Desktop startup fires a burst of read-only data calls (config, profiles,
- // model info/options, cron) the moment the backend passes readiness. On a
- // profile-heavy or remote install these can each take tens of seconds — e.g.
- // /api/profiles runs list_profiles(), which does a recursive skill-tree walk
- // per profile — so the 15s default (DEFAULT_FETCH_TIMEOUT_MS in hardening.ts)
- // times out a backend that is alive-but-busy, surfacing as a spurious
- // "Timed out connecting to Hermes backend" that hangs the UI (#48504).
- //
- // Give the boot burst a generous per-call timeout instead of raising the
- // global default: interactive/runtime calls and the liveness poll (/api/status)
- // keep the short default so a genuinely-dead backend is still detected fast.
- export const STARTUP_REQUEST_TIMEOUT_MS = 60_000
- const DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS = 30_000
- const SESSION_LIST_REQUEST_TIMEOUT_MS = 60_000
- // The cron trigger endpoint intentionally waits for the whole job so its
- // response reflects the persisted execution result. Agent jobs can run far
- // longer than the Electron fetch default; keep this override local to the one
- // synchronous long-operation endpoint rather than weakening all API timeouts.
- export const CRON_TRIGGER_REQUEST_TIMEOUT_MS = 24 * 60 * 60 * 1000
- // prompt.submit is effectively fire-and-forget: turn completion is signaled by
- // stream / message.complete events, NOT by the RPC return. A long turn (MoA
- // presets running references + aggregator in series, deep reasoning, large tool
- // chains) can legitimately take minutes to ACK, so bounding the ack by the
- // generic 30s default surfaces a false "request timed out" toast while the turn
- // is still running and will succeed (issue #55024). Match the backend's
- // agent-turn ceiling (agent.gateway_timeout = 1800s) so the ack timeout only
- // ever fires when the turn itself would have been abandoned server-side.
- export const PROMPT_SUBMIT_REQUEST_TIMEOUT_MS = 1_800_000
- export const AUDIO_SPEAK_MIN_REQUEST_TIMEOUT_MS = 180_000
- export const AUDIO_SPEAK_MAX_REQUEST_TIMEOUT_MS = 600_000
- const AUDIO_SPEAK_TIMEOUT_MS_PER_CHAR = 35
-
- export function audioSpeakRequestTimeoutMs(text: string): number {
- const estimated = Math.max(
- AUDIO_SPEAK_MIN_REQUEST_TIMEOUT_MS,
- Math.ceil(String(text || '').length * AUDIO_SPEAK_TIMEOUT_MS_PER_CHAR)
- )
-
- return Math.min(AUDIO_SPEAK_MAX_REQUEST_TIMEOUT_MS, estimated)
- }
-
- export const AUDIO_TRANSCRIBE_MIN_REQUEST_TIMEOUT_MS = 180_000
- export const AUDIO_TRANSCRIBE_MAX_REQUEST_TIMEOUT_MS = 600_000
- // The transcribe payload is the base64 audio data URL itself, so its string
- // length tracks clip size. ~0.1ms/char keeps short clips at the floor while
- // letting multi-minute recordings scale toward the cap (a base64 char is
- // ~0.75 bytes, so at 128kbps ≈ 21k chars/s of audio this budgets ~2s of
- // timeout per 1s of audio before the cap clamps it).
- const AUDIO_TRANSCRIBE_TIMEOUT_MS_PER_CHAR = 0.1
-
- export function audioTranscribeRequestTimeoutMs(dataUrl: string): number {
- const estimated = Math.max(
- AUDIO_TRANSCRIBE_MIN_REQUEST_TIMEOUT_MS,
- Math.ceil(String(dataUrl || '').length * AUDIO_TRANSCRIBE_TIMEOUT_MS_PER_CHAR)
- )
-
- return Math.min(AUDIO_TRANSCRIBE_MAX_REQUEST_TIMEOUT_MS, estimated)
- }
+ // The desktop REST/WS client, split by domain under src/api/. This module is
+ // the compatibility barrel: every helper keeps its historical `@/hermes`
+ // import path while the implementations live in focused files.
+ // client is the one module with internals: profileScoped / connectionScoped /
+ // capabilityScoped are shared across api/ but must not reach call sites, or
+ // request scoping stops having a single owner.
+ export {
+ getApiRequestConnection,
+ getApiRequestProfile,
+ hermesApi,
+ HermesGateway,
+ profileScopeKey,
+ PROMPT_SUBMIT_REQUEST_TIMEOUT_MS,
+ setApiRequestConnection,
+ setApiRequestProfile,
+ STARTUP_REQUEST_TIMEOUT_MS
+ } from './api/client'
+ export type { ProfileScope } from './api/client'
+ export * from './api/config'
+ export * from './api/cron'
++export * from './api/local-models'
+ export * from './api/mcp'
+ export * from './api/messaging'
+ export * from './api/models'
+ export * from './api/plugins'
+ export * from './api/profiles'
+ export * from './api/sessions'
+ export * from './api/skills'
+ export * from './api/system'
+ export * from './api/toolsets'
export type {
ActionResponse,