The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge remote-tracking branch 'origin/main' into ethie/pm-clean
ethernet4b803147d3a2
diff --cc apps/desktop/src/app/contrib/onboarding-kickoff.test.tsindex b23c523e270,00000000000..a60276176d6mode 100644,000000..100644--- a/apps/desktop/src/app/contrib/onboarding-kickoff.test.ts+++ b/apps/desktop/src/app/contrib/onboarding-kickoff.test.ts@@@ -1,103 -1,0 +1,106 @@@+import { afterEach, expect, it, vi } from 'vitest'++import type { ClientSessionState } from '@/app/types'- import { $setupSession, SETUP_PROFILE } from '@/components/onboarding-chat/setup-profile'++import { $setupSession } from '@/components/onboarding-chat/setup-profile'+import { assistantTextPart } from '@/lib/chat-messages'+import { $activeGatewayProfile } from '@/store/profile'+import { $activeSessionId, $messages, $selectedStoredSessionId } from '@/store/session'+import { $sessionStates } from '@/store/session-states'++import { adoptGuideSession } from './onboarding-kickoff'++const messages = [{ id: 'greeting', role: 'assistant' as const, parts: [assistantTextPart('Welcome back')] }]++const setupProfile = 'setup-provisioned'++function publishGuide(storedSessionId: string, visible = true) {+ const state: ClientSessionState = {+ storedSessionId,+ messages,+ branch: '',+ cwd: '',+ model: '',+ provider: '',+ reasoningEffort: '',+ serviceTier: '',+ fast: false,+ yolo: false,+ personality: '',+ busy: false,+ awaitingResponse: false,+ streamId: null,+ sawAssistantPayload: false,+ adoptedRunningTurn: false,+ pendingBranchGroup: null,+ interrupted: false,+ interimBoundaryPending: false,+ needsInput: false,+ turnStartedAt: null,+ turnLive: false,+ usage: null+ }++ $sessionStates.set({ 'runtime-guide': state })+ $activeSessionId.set('runtime-guide')+ $selectedStoredSessionId.set(storedSessionId)- $activeGatewayProfile.set(SETUP_PROFILE)++ $activeGatewayProfile.set(setupProfile)+ $messages.set(visible ? messages : [])+}++afterEach(() => {+ $sessionStates.set({})+ $activeSessionId.set(null)+ $selectedStoredSessionId.set(null)+ $activeGatewayProfile.set('default')+ $messages.set([])+ $setupSession.set(null)+})++it('adopts the resumed runtime only after the correct saved transcript is visible', async () => {+ const request = vi.fn(async () => {+ throw new Error('Unexpected configuration request')+ })++ await adoptGuideSession(++ setupProfile,+ { id: 'guide', resolved_id: 'guide-tip' },+ false,+ async () => {+ publishGuide('guide-tip')+ },+ request+ )- expect($setupSession.get()).toMatchObject({ storedId: 'guide', runtimeId: 'runtime-guide', profile: SETUP_PROFILE })++ expect($setupSession.get()).toMatchObject({ storedId: 'guide', runtimeId: 'runtime-guide', profile: setupProfile })+ expect(request).not.toHaveBeenCalled()+ expect($messages.get()).toEqual(messages)+})++it.each(['empty', 'wrong-session', 'wrong-profile', 'no-runtime'])(+ 'rejects a settled resume with %s instead of releasing startup',+ async failure => {+ const request = vi.fn(async () => {+ throw new Error('Unexpected configuration request')+ })++ await expect(+ adoptGuideSession(++ setupProfile,+ { id: 'guide' },+ false,+ async () => {+ publishGuide(failure === 'wrong-session' ? 'other' : 'guide', failure !== 'empty')++ if (failure === 'wrong-profile') {+ $activeGatewayProfile.set('default')+ }++ if (failure === 'no-runtime') {+ $activeSessionId.set(null)+ }+ },+ request+ )+ ).rejects.toThrow('could not be loaded')+ expect($setupSession.get()).toBeNull()+ expect(request).not.toHaveBeenCalled()+ }+)diff --cc apps/desktop/src/app/contrib/onboarding-kickoff.tsindex 31eef00d2c0,249acb7e912..d6e27ab1e98--- a/apps/desktop/src/app/contrib/onboarding-kickoff.ts+++ b/apps/desktop/src/app/contrib/onboarding-kickoff.ts@@@ -8,14 -9,7 +9,8 @@@ importpickOnboardingGreeting,takeGuideShape} from '@/components/onboarding-chat/assembly'- import {- $setupSession,- ensureSetupProfile,- guideSourceConnectionId,- SETUP_CHAT_TITLE,- SETUP_PROFILE- } from '@/components/onboarding-chat/setup-profile'+ import { $setupSession, guideSourceConnectionId, SETUP_CHAT_TITLE } from '@/components/onboarding-chat/setup-profile'+import { chatMessageText } from '@/lib/chat-messages'import { isOnboardingEnabled } from '@/lib/onboarding-enabled'import { activeGatewayConnectionId, requestGatewayForProfile } from '@/store/gateway'import { loadMachineProfile } from '@/store/machine'@@@ -55,7 -48,8 +50,8 @@@ interface GuideSessionresolved_id?: string}-async function adoptGuideSession(+export async function adoptGuideSession(+ setupProfile: string,canonical: GuideSession,freeTier: SetupStatus['free_tier'],resumeSession: OnboardingKickoffOptions['resumeSession'],@@@ -63,26 -57,11 +59,26 @@@): Promise<void> {await resumeSession(canonical.resolved_id ?? canonical.id, true)const adoptedRuntimeId = $activeSessionId.get()- $chatOnboardingThreadIds.set(adoptedRuntimeId ? [canonical.id, adoptedRuntimeId] : [canonical.id])+ const state = adoptedRuntimeId ? $sessionStates.get()[adoptedRuntimeId] : undefined++ // resumeSession can settle without adopting (failed or superseded resume).+ // Only release the splash for the guide's actual binding and visible transcript.+ if (+ !adoptedRuntimeId ||+ !state?.storedSessionId ||+ ![canonical.id, canonical.resolved_id].includes(state.storedSessionId) ||+ $selectedStoredSessionId.get() !== state.storedSessionId ||- $activeGatewayProfile.get() !== SETUP_PROFILE ||++ $activeGatewayProfile.get() !== setupProfile ||+ !$messages.get().some(message => message.role === 'assistant' && !message.hidden && chatMessageText(message).trim())+ ) {+ throw new Error('The welcome conversation could not be loaded. Please try again.')+ }++ $chatOnboardingThreadIds.set([canonical.id, adoptedRuntimeId])$setupSession.set({connectionId: guideSourceConnectionId(canonical.id),- profile: SETUP_PROFILE,+ profile: setupProfile,- runtimeId: adoptedRuntimeId ?? canonical.id,+ runtimeId: adoptedRuntimeId,storedId: canonical.id})@@@ -186,8 -175,7 +185,8 @@@ export function useOnboardingKickoff(// Set the title explicitly so the backend does not name the session after the hidden runbook message.await guideRequest('session.title', { session_id: runtimeId, title: SETUP_CHAT_TITLE }).catch(() => undefined)- await adoptGuideSession({ id: storedId ?? runtimeId }, record.free_tier, resumeSession, guideRequest)- // session.create has already persisted both seed rows, so the caller may advance the phase.++ await adoptGuideSession(setupProfile, { id: storedId ?? runtimeId }, record.free_tier, resumeSession, guideRequest)+return true} catch (error) {$newChatProfile.set(previousNewChatProfile)diff --cc apps/desktop/src/store/onboarding-gate.tsindex c4cf71f914b,a3eae271227..9ab4566dc1d--- a/apps/desktop/src/store/onboarding-gate.ts+++ b/apps/desktop/src/store/onboarding-gate.ts@@@ -3,7 -3,8 +3,8 @@@ import { atom, computed } from 'nanostoimport { isOnboardingEnabled } from '@/lib/onboarding-enabled'import { readKey, writeKey } from '@/lib/storage'+ import { $gateway } from './gateway'-import { hasSeenIntroReveal, markIntroRevealSeen } from './intro-reveal'+import { $introReveal, hasSeenIntroReveal, markIntroRevealSeen } from './intro-reveal'import { DEFAULT_ANSWERS, setOnboardingAnswers } from './onboarding-answers'const PHASE_KEY = 'hermes-onboarding-phase-v1'@@@ -182,7 -166,8 +184,8 @@@ export async function devResetOnboardinreturn}+ await $gateway.get()?.request('onboarding.reset_setup_profile', {})- guideKickoff = { status: 'idle' }+ setGuideKickoff({ status: 'idle' })setPhase('idle')setOnboardingAnswers({ ...DEFAULT_ANSWERS, connectors: [...DEFAULT_ANSWERS.connectors] })}diff --cc hermes_cli/profiles.pyindex cea1ca296e3,39458d3c0bc..f1f2203d3ba--- a/hermes_cli/profiles.py+++ b/hermes_cli/profiles.py@@@ -2033,14 -2008,7 +2059,15 @@@ def import_profile(archive_path: str, nif archive_root != canon:final_source = staging_root / canonextracted.rename(final_source)+ # Remove foreign runtime state before publishing, including file-shaped roots.+ # A failed removal must abort import rather than install a stale PM selection.+ for child in final_source.iterdir():+ if child.name in PM_RUNTIME_ROOT_DIRS:+ if child.is_dir():+ shutil.rmtree(child)+ else:+ child.unlink()+ drop_profile_role(final_source)shutil.move(str(final_source), str(profile_dir))return profile_dir