补齐story与world能力注入链路
This commit is contained in:
@@ -89,6 +89,7 @@
|
|||||||
本轮只做一件事:
|
本轮只做一件事:
|
||||||
|
|
||||||
1. 把 `story/custom world` 的 service 依赖从大仓储接口改成最小 capability
|
1. 把 `story/custom world` 的 service 依赖从大仓储接口改成最小 capability
|
||||||
|
2. 把 `AppContext -> route -> service` 的注入链路同步改成 capability wiring
|
||||||
|
|
||||||
本轮不做:
|
本轮不做:
|
||||||
|
|
||||||
@@ -100,4 +101,5 @@
|
|||||||
|
|
||||||
1. `server-node` 编译通过
|
1. `server-node` 编译通过
|
||||||
2. 相关测试 stub 不再依赖完整 `RuntimeRepositoryPort`
|
2. 相关测试 stub 不再依赖完整 `RuntimeRepositoryPort`
|
||||||
3. 文档明确固定“能力先迁、逻辑后搬”的顺序
|
3. `storyActionRoutes` / `runtimeRoutes` 不再默认把整块 `runtimeRepository` 传进对应 service
|
||||||
|
4. 文档明确固定“能力先迁、逻辑后搬”的顺序
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ import { CustomWorldAgentOrchestrator } from './services/customWorldAgentOrchest
|
|||||||
import { CustomWorldAgentSessionStore } from './services/customWorldAgentSessionStore.js';
|
import { CustomWorldAgentSessionStore } from './services/customWorldAgentSessionStore.js';
|
||||||
import { CustomWorldSessionStore } from './services/customWorldSessionStore.js';
|
import { CustomWorldSessionStore } from './services/customWorldSessionStore.js';
|
||||||
import { UpstreamLlmClient } from './services/llmClient.js';
|
import { UpstreamLlmClient } from './services/llmClient.js';
|
||||||
|
import type {
|
||||||
|
CustomWorldProfileCapability,
|
||||||
|
CustomWorldSessionCapability,
|
||||||
|
RuntimeStoryCapability,
|
||||||
|
} from './services/runtimeCapabilities.js';
|
||||||
import type { SmsVerificationService } from './services/smsVerificationService.js';
|
import type { SmsVerificationService } from './services/smsVerificationService.js';
|
||||||
import type { WechatAuthService } from './services/wechatAuthService.js';
|
import type { WechatAuthService } from './services/wechatAuthService.js';
|
||||||
import { WechatAuthStateStore } from './services/wechatAuthStateStore.js';
|
import { WechatAuthStateStore } from './services/wechatAuthStateStore.js';
|
||||||
@@ -29,6 +34,9 @@ export type AppContext = {
|
|||||||
smsAuthEventRepository: SmsAuthEventRepository;
|
smsAuthEventRepository: SmsAuthEventRepository;
|
||||||
userSessionRepository: UserSessionRepository;
|
userSessionRepository: UserSessionRepository;
|
||||||
runtimeRepository: RuntimeRepository;
|
runtimeRepository: RuntimeRepository;
|
||||||
|
runtimeStoryCapability: RuntimeStoryCapability;
|
||||||
|
customWorldSessionCapability: CustomWorldSessionCapability;
|
||||||
|
customWorldProfileCapability: CustomWorldProfileCapability;
|
||||||
llmClient: UpstreamLlmClient;
|
llmClient: UpstreamLlmClient;
|
||||||
customWorldSessions: CustomWorldSessionStore;
|
customWorldSessions: CustomWorldSessionStore;
|
||||||
customWorldAgentSessions: CustomWorldAgentSessionStore;
|
customWorldAgentSessions: CustomWorldAgentSessionStore;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export function createStoryActionRoutes(context: AppContext) {
|
|||||||
await resolveRuntimeStoryAction({
|
await resolveRuntimeStoryAction({
|
||||||
runtimeRepository: createRuntimeStorySnapshotRepository({
|
runtimeRepository: createRuntimeStorySnapshotRepository({
|
||||||
request,
|
request,
|
||||||
runtimeRepository: context.runtimeRepository,
|
runtimeRepository: context.runtimeStoryCapability,
|
||||||
config: context.config,
|
config: context.config,
|
||||||
}),
|
}),
|
||||||
llmClient: context.llmClient,
|
llmClient: context.llmClient,
|
||||||
@@ -83,7 +83,7 @@ export function createStoryActionRoutes(context: AppContext) {
|
|||||||
await getRuntimeStoryState({
|
await getRuntimeStoryState({
|
||||||
runtimeRepository: createRuntimeStorySnapshotRepository({
|
runtimeRepository: createRuntimeStorySnapshotRepository({
|
||||||
request,
|
request,
|
||||||
runtimeRepository: context.runtimeRepository,
|
runtimeRepository: context.runtimeStoryCapability,
|
||||||
config: context.config,
|
config: context.config,
|
||||||
}),
|
}),
|
||||||
userId: request.userId!,
|
userId: request.userId!,
|
||||||
|
|||||||
@@ -555,7 +555,7 @@ export function createRuntimeRoutes(context: AppContext) {
|
|||||||
asyncHandler(async (request, response) => {
|
asyncHandler(async (request, response) => {
|
||||||
sendApiResponse<ListCustomWorldWorksResponse>(response, {
|
sendApiResponse<ListCustomWorldWorksResponse>(response, {
|
||||||
items: await listCustomWorldWorkSummaries(request.userId!, {
|
items: await listCustomWorldWorkSummaries(request.userId!, {
|
||||||
runtimeRepository: context.runtimeRepository,
|
runtimeRepository: context.customWorldProfileCapability,
|
||||||
customWorldAgentSessions: context.customWorldAgentSessions,
|
customWorldAgentSessions: context.customWorldAgentSessions,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ import { CustomWorldAgentOrchestrator } from './services/customWorldAgentOrchest
|
|||||||
import { CustomWorldAgentSessionStore } from './services/customWorldAgentSessionStore.js';
|
import { CustomWorldAgentSessionStore } from './services/customWorldAgentSessionStore.js';
|
||||||
import { CustomWorldSessionStore } from './services/customWorldSessionStore.js';
|
import { CustomWorldSessionStore } from './services/customWorldSessionStore.js';
|
||||||
import { UpstreamLlmClient } from './services/llmClient.js';
|
import { UpstreamLlmClient } from './services/llmClient.js';
|
||||||
|
import {
|
||||||
|
createCustomWorldProfileCapability,
|
||||||
|
createCustomWorldSessionCapability,
|
||||||
|
createRuntimeSnapshotCapability,
|
||||||
|
} from './services/runtimeCapabilities.js';
|
||||||
import { createSmsVerificationService } from './services/smsVerificationService.js';
|
import { createSmsVerificationService } from './services/smsVerificationService.js';
|
||||||
import { createWechatAuthService } from './services/wechatAuthService.js';
|
import { createWechatAuthService } from './services/wechatAuthService.js';
|
||||||
import { WechatAuthStateStore } from './services/wechatAuthStateStore.js';
|
import { WechatAuthStateStore } from './services/wechatAuthStateStore.js';
|
||||||
@@ -80,9 +85,18 @@ export async function createAppContext(config: AppConfig = loadConfig()) {
|
|||||||
const logger = createLogger(config);
|
const logger = createLogger(config);
|
||||||
const db = await createDatabase(config);
|
const db = await createDatabase(config);
|
||||||
const runtimeRepository = new RuntimeRepository(db);
|
const runtimeRepository = new RuntimeRepository(db);
|
||||||
const customWorldAgentSessions = new CustomWorldAgentSessionStore(
|
const runtimeStoryCapability = createRuntimeSnapshotCapability(
|
||||||
runtimeRepository,
|
runtimeRepository,
|
||||||
);
|
);
|
||||||
|
const customWorldSessionCapability = createCustomWorldSessionCapability(
|
||||||
|
runtimeRepository,
|
||||||
|
);
|
||||||
|
const customWorldProfileCapability = createCustomWorldProfileCapability(
|
||||||
|
runtimeRepository,
|
||||||
|
);
|
||||||
|
const customWorldAgentSessions = new CustomWorldAgentSessionStore(
|
||||||
|
customWorldSessionCapability,
|
||||||
|
);
|
||||||
const context: AppContext = {
|
const context: AppContext = {
|
||||||
config,
|
config,
|
||||||
logger,
|
logger,
|
||||||
@@ -94,8 +108,11 @@ export async function createAppContext(config: AppConfig = loadConfig()) {
|
|||||||
smsAuthEventRepository: new SmsAuthEventRepository(db),
|
smsAuthEventRepository: new SmsAuthEventRepository(db),
|
||||||
userSessionRepository: new UserSessionRepository(db),
|
userSessionRepository: new UserSessionRepository(db),
|
||||||
runtimeRepository,
|
runtimeRepository,
|
||||||
|
runtimeStoryCapability,
|
||||||
|
customWorldSessionCapability,
|
||||||
|
customWorldProfileCapability,
|
||||||
llmClient: new UpstreamLlmClient(config, logger),
|
llmClient: new UpstreamLlmClient(config, logger),
|
||||||
customWorldSessions: new CustomWorldSessionStore(runtimeRepository),
|
customWorldSessions: new CustomWorldSessionStore(customWorldSessionCapability),
|
||||||
customWorldAgentSessions,
|
customWorldAgentSessions,
|
||||||
customWorldAgentOrchestrator: new CustomWorldAgentOrchestrator(
|
customWorldAgentOrchestrator: new CustomWorldAgentOrchestrator(
|
||||||
customWorldAgentSessions,
|
customWorldAgentSessions,
|
||||||
|
|||||||
Reference in New Issue
Block a user