feat: organize project conversations and add coding teacher side chat
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { accessSync, constants } from 'node:fs';
|
||||
import { CodingTeacherService } from '../coding-teacher/service';
|
||||
import { readCodingConversationHistory } from '../coding-projects/conversation-history';
|
||||
import path from 'node:path';
|
||||
import type { AgentBrowserModule } from '../agent-browser';
|
||||
import type { AgentBrowserSnapshot } from '../../shared/agent-browser';
|
||||
@@ -290,6 +292,16 @@ export function createCodingComposition(
|
||||
let plugins: CodingProjectPluginService | undefined;
|
||||
let previewDataSession: PreviewDataSessionManager | undefined;
|
||||
const projects = new CodingProjectService(projectStore, {
|
||||
getDefaultModel: async () => {
|
||||
const provider = getProviderService();
|
||||
const accountId = await provider.getDefaultAccountId();
|
||||
const accounts = await provider.listAccounts();
|
||||
const account = accounts.find((item) => item.id === accountId && item.enabled);
|
||||
if (!account?.model) return null;
|
||||
const model = { accountId: account.id, modelId: account.model, thinkingLevel: 'off' as const, reasoningChoice: { mode: 'default' as const } };
|
||||
selectPiProviderModel(buildPiProviderCatalog({ accounts }), model);
|
||||
return model;
|
||||
},
|
||||
createConversationStore: conversationStoreForProject,
|
||||
onResourcesChanged: async (project) => {
|
||||
runtime?.markResourcesStale();
|
||||
@@ -501,6 +513,8 @@ export function createCodingComposition(
|
||||
: {}),
|
||||
});
|
||||
const conversations = new CodingConversationService(projects, runtime, {
|
||||
readHistory: (projectId, conversation) => readCodingConversationHistory(options.paths.userDataDir, projectId, conversation),
|
||||
onDelete: (projectId, conversationId) => teacher.removeSource(projectId, conversationId),
|
||||
archiveSession: async ({ projectId, sessionKey }) => {
|
||||
await archivePiConversationSession({
|
||||
userDataDir: options.paths.userDataDir,
|
||||
@@ -552,7 +566,12 @@ export function createCodingComposition(
|
||||
previewDataSession?.handleAgentBrowserLifecycle(event);
|
||||
})
|
||||
: () => undefined;
|
||||
const teacher = new CodingTeacherService({
|
||||
projects, runtime, userDataDir: options.paths.userDataDir,
|
||||
acquireLease: (id) => options.acquireBackgroundLease?.({ id, kind: 'coding-run' }) ?? (() => undefined),
|
||||
});
|
||||
return {
|
||||
teacher,
|
||||
gameAudio: gameAudioDelivery,
|
||||
attachments,
|
||||
dataService,
|
||||
@@ -583,6 +602,7 @@ export function createCodingComposition(
|
||||
await agentServer.stop();
|
||||
},
|
||||
async shutdown() {
|
||||
await teacher.dispose();
|
||||
conversations.dispose();
|
||||
gameResourceDelivery.dispose();
|
||||
gameAudioDelivery.dispose();
|
||||
|
||||
Reference in New Issue
Block a user