@musnows/scriverse 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ai.js CHANGED
@@ -1006,10 +1006,8 @@ export class ContextBuilder {
1006
1006
  const includeAutomaticContext = scope.type !== "none" && scope.suppressAutomaticContext !== true;
1007
1007
  const settingsOnly = scope.type === "settings";
1008
1008
  const isProseScope = PROSE_CONTEXT_SCOPE_TYPES.has(scope.type);
1009
- const includeSettingInfo = includeAutomaticContext
1010
- && isProseScope
1011
- && !settingsOnly
1012
- && scope.includeSettingInfo !== false;
1009
+ const includeSettingInfo = !settingsOnly && scope.suppressAutomaticContext !== true && (scope.includeSettingInfo === true
1010
+ || (includeAutomaticContext && isProseScope && scope.includeSettingInfo !== false));
1013
1011
  const constraints = includeAutomaticContext
1014
1012
  ? [wrapAiContextRegion("work", `作品:${String(work.title)}\n作者:${String(work.author) || "未填写"}`)]
1015
1013
  : [];
@@ -3233,9 +3231,14 @@ export class AiManager {
3233
3231
  buildContextPlan(input, model, existingBudget, persistKeywordInjections = false) {
3234
3232
  const budget = existingBudget ?? this.contextBudget(input, model);
3235
3233
  const roleplayCharacterId = this.roleplayCharacterId(input.workId, input.conversationId);
3234
+ const settings = this.store.getWorkAiSettings(input.workId);
3235
+ const configuredScope = {
3236
+ ...input.scope,
3237
+ includeSettingInfo: settings.alwaysIncludeSettingInfo === true ? true : input.scope.includeSettingInfo
3238
+ };
3236
3239
  const baseScope = roleplayCharacterId
3237
3240
  ? {
3238
- ...input.scope,
3241
+ ...configuredScope,
3239
3242
  type: "none",
3240
3243
  suppressAutomaticContext: true,
3241
3244
  includeBookSummary: false,
@@ -3243,9 +3246,8 @@ export class AiManager {
3243
3246
  volumeId: undefined,
3244
3247
  selection: undefined
3245
3248
  }
3246
- : input.scope;
3249
+ : configuredScope;
3247
3250
  const contextWindow = numberValue(model, "context_window") || DEFAULT_CONTEXT_WINDOW;
3248
- const settings = this.store.getWorkAiSettings(input.workId);
3249
3251
  const percentage = Math.min(90, Math.max(1, Number(settings.bookSummaryContextPercent) || 50));
3250
3252
  const workContextBudgetTokens = Number(budget.workContextBudgetTokens) || 256;
3251
3253
  const bookSummaryMaximumTokens = baseScope.includeBookSummary || baseScope.type === "book" || baseScope.type === "volume"
@@ -3260,9 +3262,8 @@ export class AiManager {
3260
3262
  const injected = conversationId
3261
3263
  ? this.store.getAiConversationInjectedEntities(conversationId, workId)
3262
3264
  : { characters: [], races: [], organizations: [] };
3263
- const proseSettingInfoOn = PROSE_CONTEXT_SCOPE_TYPES.has(scope.type)
3264
- && scope.suppressAutomaticContext !== true
3265
- && scope.includeSettingInfo !== false;
3265
+ const proseSettingInfoOn = scope.suppressAutomaticContext !== true && (scope.includeSettingInfo === true || (PROSE_CONTEXT_SCOPE_TYPES.has(scope.type)
3266
+ && scope.includeSettingInfo !== false));
3266
3267
  const matches = matchKeywordEntities(this.store, workId, instruction, {
3267
3268
  excludeCharacterIds: [
3268
3269
  ...(scope.characterIds ?? []),