Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
Merge branch 'dev' into feat/oss-desktop-deep-links
Josué668bf52b7bd8
diff --cc control-api/package-lock.jsonindex ff14bc2b4,ff14bc2b4..7237060ca--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@@ -1,12 -1,12 +1,12 @@@{"name": "clerum-control-api",-- "version": "0.1.367",++ "version": "0.1.368","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",-- "version": "0.1.367",++ "version": "0.1.368","dependencies": {"@clerum/image-policy": "file:../packages/image-policy","@clerum/llm-providers": "file:../packages/llm-providers",diff --cc control-api/package.jsonindex 2a655b11c,2a655b11c..96a068da6--- a/control-api/package.json+++ b/control-api/package.json@@@ -1,6 -1,6 +1,6 @@@{"name": "clerum-control-api",-- "version": "0.1.367",++ "version": "0.1.368","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --cc control-ui/package-lock.jsonindex aa10851df,aa10851df..3ae5053ab--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@@ -1,12 -1,12 +1,12 @@@{"name": "clerum-control-ui",-- "version": "0.1.352",++ "version": "0.1.353","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",-- "version": "0.1.352",++ "version": "0.1.353","dependencies": {"@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",diff --cc control-ui/package.jsonindex 2f7d71b2d,2f7d71b2d..836023b36--- a/control-ui/package.json+++ b/control-ui/package.json@@@ -1,6 -1,6 +1,6 @@@{"name": "clerum-control-ui",-- "version": "0.1.352",++ "version": "0.1.353","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --cc desktop-app/package-lock.jsonindex 19564485f,9597b8544..a382e0e4f--- a/desktop-app/package-lock.json+++ b/desktop-app/package-lock.json@@@ -1,15 -1,14 +1,15 @@@{"name": "evenfire",- "version": "0.1.328",- "version": "0.1.323",++ "version": "0.1.329","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "evenfire",- "version": "0.1.328",- "version": "0.1.323",++ "version": "0.1.329","license": "MPL-2.0","dependencies": {+ "@clerum/desktop-app-links": "file:../packages/desktop-app-links","@tanstack/react-query": "5.100.10","js-yaml": "^4.1.1","keytar": "^7.9.0",diff --cc desktop-app/package.jsonindex 217c398cc,f07aa132d..90d1a44bb--- a/desktop-app/package.json+++ b/desktop-app/package.json@@@ -1,7 -1,7 +1,7 @@@{"name": "evenfire","productName": "Evenfire",- "version": "0.1.328",- "version": "0.1.323",++ "version": "0.1.329","private": true,"license": "MPL-2.0","description": "Evenfire desktop client for secure agent and workflow access",diff --cc desktop-app/ui/src/hooks/__tests__/useWorkspaceController.test.tsxindex dbffaacbb,9df0a1a4b..33fccc055--- a/desktop-app/ui/src/hooks/__tests__/useWorkspaceController.test.tsx+++ b/desktop-app/ui/src/hooks/__tests__/useWorkspaceController.test.tsx@@@ -302,37 -105,9 +105,37 @@@ describe('useWorkspaceController', () =afterEach(() => {cleanup()vi.restoreAllMocks()- delete (window as { clerum?: unknown }).clerum+ uninstallMockClerum()})+ it('restores the session without waiting for a slow dependency-health probe', async () => {+ const clerum = installClerumHarness({ delayHealth: true })++ renderControllerHarness()++ await waitFor(() => expect(clerum.getSessionState).toHaveBeenCalledOnce())+ await waitFor(() => expect(screen.getByTestId('booting').textContent).toBe('false'))++ clerum.resolveHealth()+ })++ it('logs dependency-health probe failures without blocking session restoration', async () => {+ const healthError = new Error('health endpoint unavailable')+ const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)+ const clerum = installClerumHarness({ healthError })++ renderControllerHarness()++ await waitFor(() => expect(clerum.getSessionState).toHaveBeenCalledOnce())+ await waitFor(() => expect(screen.getByTestId('booting').textContent).toBe('false'))+ await waitFor(() =>+ expect(consoleWarn).toHaveBeenCalledWith(+ '[Desktop] Could not refresh dependency health:',+ healthError+ )+ )+ })+it('preserves a workflow nav selection while login session hydration finishes', async () => {const clerum = installClerumHarness({ delayAuthenticatedLoad: true })diff --cc desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/appControllerHarness.tsxindex 000000000,08568c095..af67f0992mode 000000,100644..100644--- a/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/appControllerHarness.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/__fixtures__/appControllerHarness.tsx@@@ -1,0 -1,288 +1,308 @@@+ import type { ReactNode } from 'react'+ import { vi } from 'vitest'+ import { AgentTaskTrackerProvider } from '@contexts/AgentTaskTrackerContext'+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'+ import { renderHook } from '@testing-library/react'+ import { useAppController } from '../../../useAppController'+ import { type MockClerum, installMockClerum } from './mockClerum'++ /**+ * The single `window.clerum` bridge for tests that boot the REAL coordinator+ * (`useAppController`), plus a `renderHook` mount for the ones that drive it+ * through its return value rather than through rendered UI.+ *+ * Two suites share it — `hooks/domain/__tests__/chatSelectionAcrossRouteChange`+ * and `hooks/__tests__/useWorkspaceController` (whose hook is a deprecated+ * re-export of `useAppController`, so both boot the same thing). It lives in this+ * folder because the repo keeps ONE `__fixtures__` directory for the hooks tests+ * and because it is built on top of `mockClerum` — splitting it away from its own+ * base would cost more than the cross-folder import it saves.+ *+ * `controllerHarness.renderController` stays the right tool when a test only+ * needs `useAgentChatController` — it drives `navItem` as a prop. The guards in+ * `useAppController` read `nav.navItem` from the navigation controller it owns,+ * which no prop can stand in for, hence this second harness.+ *+ * The bridge EXTENDS `installMockClerum()` (chat + rpc) with the namespaces the+ * coordinator touches on mount. Everything that differs between the two suites+ * is an option — never a duplicated bridge.+ */++ export const HARNESS_ME = {+ id: 'user-1',+ email: '[email protected]',+ name: 'Test User',+ teamId: 'team-1',+ teamName: 'Team 1',+ }++ type Fn = ReturnType<typeof vi.fn>++ interface Deferred<T> {+ promise: Promise<T>+ resolve: (value: T) => void+ }++ function createDeferred<T>(): Deferred<T> {+ let resolve!: (value: T) => void+ const promise = new Promise<T>(res => {+ resolve = res+ })+ return { promise, resolve }+ }++ function createSessionState(authenticated: boolean) {+ return authenticated+ ? { authenticated: true, me: HARNESS_ME }+ : { authenticated: false, me: null }+ }++ function createCatalog(agentNames: string[]) {+ return {+ userId: HARNESS_ME.id,+ teamId: HARNESS_ME.teamId,+ agentNames,+ userAgentNames: agentNames,+ teamAgentNames: [],+ mcpServersByAgent: {},+ agentContextByName: {},+ agentProviderByName: {},+ contextIds: [],+ userContextIds: [],+ teamContextIds: [],+ }+ }+++function createHealth() {++ return {++ externalRestApi: { ok: true },++ rpcProxy: { ok: true },++ }++}+++ const DEFAULT_DESKTOP_RELEASE_STATUS = {+ checked: true,+ currentVersion: '0.1.250',+ latestVersion: '0.1.250',+ minimumVersion: '0.1.250',+ updateRequired: false,+ releaseUrl: '',+ }++ export interface AppControllerClerumOptions {+ /** Access-catalog agents. Empty means "authenticated user with no agents". */+ agentNames?: string[]+ /** Boot already signed in (default). `false` boots at the login screen. */+ startAuthenticated?: boolean+ /**+ * Hold `team.directory`, `access.refreshCatalog` and `approvals.listPending`+ * open once authenticated, until `resolveAuthenticatedLoad()` runs — lets a+ * test observe the window between login and workspace hydration.+ */+ delayAuthenticatedLoad?: boolean++ /** Hold the dependency-health probe open until `resolveHealth()` runs. */++ delayHealth?: boolean++ /** Make the dependency-health probe reject with this value. */++ healthError?: unknown+ /** Make `auth.passwordLogin` reject with this instead of signing in. */+ passwordLoginError?: unknown+ /** Payload for `auth.getDesktopReleaseStatus`. */+ desktopReleaseStatus?: typeof DEFAULT_DESKTOP_RELEASE_STATUS+ /** Payload for `team.directory` / `team.initialDirectory` / `team.list`. */+ teamDirectory?: { items: unknown[]; currentTeamId: string }+ }++ export interface AppControllerClerumHandle {++ getDependenciesHealth: Fn+ getSessionState: Fn+ passwordLogin: Fn+ getDesktopReleaseStatus: Fn+ teamDirectory: Fn+ refreshCatalog: Fn+ listPending: Fn++ /** Settles a dependency-health probe held by `delayHealth`. */++ resolveHealth: () => void+ /** Settles whatever `delayAuthenticatedLoad` is holding open. */+ resolveAuthenticatedLoad: () => void+ }++ /**+ * Adds the auth/team/access/notifications/... namespaces the coordinator needs+ * on top of an installed `MockClerum`. Call it AFTER `installMockClerum()` and+ * BEFORE mounting. Use `installAppControllerClerum` when the suite has no+ * `installMockClerum()` of its own.+ */+ export function extendMockClerumForAppController(+ clerum: MockClerum,+ options: AppControllerClerumOptions = {}+ ): AppControllerClerumHandle {+ const agentNames = options.agentNames ?? ['agent-x']+ const bridge = clerum as unknown as Record<string, unknown>++ let authenticated = options.startAuthenticated ?? true+ const teamDirectoryPayload = options.teamDirectory ?? {+ items: [],+ currentTeamId: HARNESS_ME.teamId,+ }+ const teamDirectoryDeferred = createDeferred<typeof teamDirectoryPayload>()+ const catalogDeferred = createDeferred<ReturnType<typeof createCatalog>>()+ const approvalsDeferred = createDeferred<unknown[]>()++ const healthDeferred = createDeferred<ReturnType<typeof createHealth>>()+ const held = () => Boolean(options.delayAuthenticatedLoad) && authenticated+++ const getDependenciesHealth = vi.fn(async () => {++ if (options.healthError) throw options.healthError++ return options.delayHealth ? healthDeferred.promise : createHealth()++ })+ const getSessionState = vi.fn(async () => createSessionState(authenticated))+ const passwordLogin = vi.fn(async () => {+ if (options.passwordLoginError) throw options.passwordLoginError+ authenticated = true+ return createSessionState(true)+ })+ const getDesktopReleaseStatus = vi.fn(+ async () => options.desktopReleaseStatus ?? DEFAULT_DESKTOP_RELEASE_STATUS+ )+ const teamDirectory = vi.fn(async () =>+ held() ? teamDirectoryDeferred.promise : teamDirectoryPayload+ )+ const refreshCatalog = vi.fn(async () =>+ held() ? catalogDeferred.promise : createCatalog(agentNames)+ )+ const listPending = vi.fn(async () => (held() ? approvalsDeferred.promise : []))++ Object.assign(bridge.rpc as object, {+ listServers: vi.fn(async () => ({ servers: [] })),+ prewarmHost: vi.fn(async () => ({ status: 'ok' })),+ approveToolCall: vi.fn(async () => undefined),+ denyToolCall: vi.fn(async () => undefined),+ })++ Object.assign(bridge, {+ auth: {- getDependenciesHealth: vi.fn(async () => ({- externalRestApi: { ok: true },- rpcProxy: { ok: true },- })),++ getDependenciesHealth,+ getSessionState,+ getRuntimeConfigState: vi.fn(async () => ({+ activeProfileId: null,+ configured: true,+ isPackaged: false,+ options: [],+ })),+ getDesktopReleaseStatus,+ openDesktopRelease: vi.fn(async () => undefined),+ passwordLogin,+ logout: vi.fn(async () => undefined),+ onDesktopSetupToken: vi.fn(() => () => undefined),+ onDesktopEnvironmentSetup: vi.fn(() => () => undefined),+ onExternalLogout: vi.fn(() => () => undefined),+ },+ team: {+ list: vi.fn(async () => teamDirectoryPayload),+ members: vi.fn(async () => []),+ directory: teamDirectory,+ initialDirectory: teamDirectory,+ switch: vi.fn(async () => createSessionState(true)),+ },+ access: {+ refreshCatalog,+ },+ approvals: {+ listPending,+ decide: vi.fn(async () => ({ ok: true })),+ },+ notifications: {+ ack: vi.fn(async () => undefined),+ subscribe: vi.fn(async (onEvent: (event: unknown) => void) => {+ onEvent({+ type: 'notification.snapshot',+ items: [],+ cursor: null,+ observedAt: new Date().toISOString(),+ })+ return async () => undefined+ }),+ status: vi.fn(async () => ({+ active: 1,+ open: 1,+ connecting: 0,+ error: 0,+ approvalRequested: 0,+ snapshot: 1,+ updated: 0,+ })),+ isSupported: vi.fn(async () => false),+ show: vi.fn(async (payload: { id: string }) => ({ supported: false, id: payload.id })),+ onClick: vi.fn(() => () => undefined),+ onAction: vi.fn(() => () => undefined),+ onFailed: vi.fn(() => () => undefined),+ },+ notificationPreferences: {+ get: vi.fn(async () => ({+ preferredMedium: null,+ channelFallbackEnabled: true,+ verifiedMedia: [],+ })),+ update: vi.fn(async (next: unknown) => ({+ ...(next && typeof next === 'object' ? next : {}),+ verifiedMedia: [],+ })),+ },+ desktop: {+ getStatus: vi.fn(async () => ({ status: 'inactive' })),+ openWindow: vi.fn(async () => undefined),+ onWindowClosed: vi.fn(() => () => undefined),+ },+ workflows: {+ list: vi.fn(async () => ({ items: [], count: 0 })),+ read: vi.fn(async () => ({})),+ runs: vi.fn(async () => ({ items: [], count: 0 })),+ listRunArtifacts: vi.fn(async () => ({ artifacts: [] })),+ trigger: vi.fn(async () => undefined),+ },+ })++ return {++ getDependenciesHealth,+ getSessionState,+ passwordLogin,+ getDesktopReleaseStatus,+ teamDirectory,+ refreshCatalog,+ listPending,++ resolveHealth() {++ healthDeferred.resolve(createHealth())++ },+ resolveAuthenticatedLoad() {+ teamDirectoryDeferred.resolve(teamDirectoryPayload)+ catalogDeferred.resolve(createCatalog(agentNames))+ approvalsDeferred.resolve([])+ },+ }+ }++ /** `installMockClerum()` + `extendMockClerumForAppController()` in one call. */+ export function installAppControllerClerum(options: AppControllerClerumOptions = {}): {+ clerum: MockClerum+ handle: AppControllerClerumHandle+ } {+ const clerum = installMockClerum()+ return { clerum, handle: extendMockClerumForAppController(clerum, options) }+ }++ export interface RenderAppControllerResult {+ result: ReturnType<typeof renderHook<ReturnType<typeof useAppController>, unknown>>['result']+ unmount: () => void+ queryClient: QueryClient+ }++ export function renderAppController(): RenderAppControllerResult {+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })+ const utils = renderHook(() => useAppController(), {+ wrapper: ({ children }: { children: ReactNode }) => (+ <QueryClientProvider client={queryClient}>+ <AgentTaskTrackerProvider>{children}</AgentTaskTrackerProvider>+ </QueryClientProvider>+ ),+ })+ return { result: utils.result, unmount: utils.unmount, queryClient }+ }diff --cc desktop-app/ui/src/hooks/useAppController.tsindex 196ede463,af4b194e9..e58aca56f--- a/desktop-app/ui/src/hooks/useAppController.ts+++ b/desktop-app/ui/src/hooks/useAppController.ts@@@ -789,10 -791,24 +803,24 @@@ export function useAppController()try {if (requiresTeamSwitch) {- await ensureNotificationTeamContext({ teamId: targetTeamId })+ await ensureTeamContext({ teamId: targetTeamId })}- if (targetChatId && !requiresTeamSwitch && nav.selectedAgent === targetAgent) {+ // Same imperative-fast-path guard as handleSelectChatAgent: `switchToChat`+ // leaves no pending selection, so it only survives while the route (and+ // hence the agent-selection effect's deps) does not change. Opening a+ // notification from the Apps embed / a workspace / settings flips+ // `navItem` below, re-running that effect into its reset branch — the+ // conversation would blank to the "new chat" empty state and then land on+ // the most recent chat instead of the notification's. From another route+ // we fall through to the pending-selection path, which replays the+ // requested chat across the re-run.+ if (+ targetChatId &&+ !requiresTeamSwitch &&+ nav.selectedAgent === targetAgent &&+ nav.navItem === DESKTOP_ROUTES.chat+ ) {try {await chat.switchToChat(targetAgent, targetChatId)nav.setNavItem(DESKTOP_ROUTES.chat)@@@ -815,8 -831,9 +843,9 @@@[chat.setPendingChatSelection,chat.switchToChat,- ensureNotificationTeamContext,+ ensureTeamContext,fullSetStatus,+ nav.navItem,nav.selectedAgent,nav.setNavItem,nav.setSelectedAgent,