@@ -9,6 +9,7 @@ import { assertSafeTruthFileName, createInteractionToolsFromDeps } from "../inte
99import { writeExportArtifact } from "../interaction/export-artifact.js" ;
1010import { assertSafeBookId , deriveBookIdFromTitle } from "../utils/book-id.js" ;
1111import { safeChildPath } from "../utils/path-safety.js" ;
12+ import { normalizePlatformId , normalizePlatformOrOther } from "../models/book.js" ;
1213
1314// ---------------------------------------------------------------------------
1415// Helpers
@@ -105,36 +106,6 @@ const SubAgentParams = Type.Object({
105106} ) ;
106107
107108type SubAgentParamsType = Static < typeof SubAgentParams > ;
108- type ArchitectPlatform = NonNullable < SubAgentParamsType [ "platform" ] > ;
109-
110- function normalizeArchitectPlatform ( platform : unknown ) : ArchitectPlatform | undefined {
111- if ( typeof platform !== "string" ) {
112- return undefined ;
113- }
114-
115- const raw = platform . trim ( ) ;
116- if ( ! raw ) {
117- return undefined ;
118- }
119-
120- const lowered = raw . toLowerCase ( ) ;
121- const compact = lowered . replace ( / [ \s _ - ] + / g, "" ) ;
122-
123- if ( compact === "tomato" || compact === "fanqie" || compact === "fanqienovel" || raw . includes ( "番茄" ) ) {
124- return "tomato" ;
125- }
126- if ( compact === "qidian" || compact === "qidianzhongwenwang" || raw . includes ( "起点" ) ) {
127- return "qidian" ;
128- }
129- if ( compact === "feilu" || raw . includes ( "飞卢" ) ) {
130- return "feilu" ;
131- }
132- if ( compact === "other" || compact === "others" || raw . includes ( "其他" ) || raw . includes ( "其它" ) ) {
133- return "other" ;
134- }
135-
136- return "other" ;
137- }
138109
139110function prepareSubAgentArguments ( args : unknown ) : SubAgentParamsType {
140111 if ( ! args || typeof args !== "object" || Array . isArray ( args ) ) {
@@ -143,7 +114,7 @@ function prepareSubAgentArguments(args: unknown): SubAgentParamsType {
143114
144115 const prepared = { ...( args as Record < string , unknown > ) } ;
145116 if ( "platform" in prepared ) {
146- const platform = normalizeArchitectPlatform ( prepared . platform ) ;
117+ const platform = normalizePlatformId ( prepared . platform ) ;
147118 if ( platform ) {
148119 prepared . platform = platform ;
149120 } else {
@@ -215,7 +186,7 @@ export function createSubAgentTool(
215186 id,
216187 title : resolvedTitle ,
217188 genre : genre ?? "general" ,
218- platform : normalizeArchitectPlatform ( platform ) ?? "other" ,
189+ platform : normalizePlatformOrOther ( platform ) ,
219190 language : ( language ?? "zh" ) as any ,
220191 status : "outlining" as any ,
221192 targetChapters : targetChapters ?? 200 ,
0 commit comments