Files
infiplot-web/lib/engine/prompts/segments/writer/guardrails.ts
T
Zonghao Yuan 0e4c2ebef4 feat(engine): merge cloudflare-migration — paradigm D engine, BYOK proxy, story persistence (#95)
Squash-merge the cloudflare-migration branch (7 commits by Kai ki) into
staging with conflict resolution, feature integration, and bug fixes.

Engine:
- Paradigm D: single-stream Writer replacing dual-phase Plan/Beats
- Delete Architect agent; story bible generated via Writer <plan> tag
- Modular prompt architecture (segments/registry/builder)
- StreamRouter for tagged stream splitting (<plan>/<story>/<choices>)

Infrastructure:
- Cloudflare Workers deployment (wrangler.jsonc, OpenNext adapter)
- D1 database schema + Drizzle ORM (scaffolded, not yet active)
- R2 storage helpers (scaffolded, not yet active)
- Story persistence API routes + client-side persistence

BYOK (Bring Your Own Key):
- /api/llm/user-proxy with SSRF-protected LLM proxy (+ requireUser auth)
- CORS-aware fetch in ai-client: auto-detect CORS failure, fallback to
  server proxy transparently via OpenAI SDK custom fetch
- BYO config support added to classify-freeform and vision routes
- SettingsModal CORS privacy notice (keys never logged/stored)

SSE streaming:
- engineClient.ts: fetchSSE helper for progressive scene events
- startSession/requestScene accept optional emit callback
- Fix SSE error event field name (error → message) in scene/start routes

i18n integration:
- Wire buildLanguageDirective into paradigm D's prompt builder
- Update corsNotice i18n keys (zh-CN/en/ja) with CORS proxy privacy text
- Preserve Session.language + LanguageSwitcher from i18n commit

Co-authored-by: Kai ki <155355644+zbf1009@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-18 18:05:38 +08:00

38 lines
1.8 KiB
TypeScript

import type { PromptSegment } from "../../types";
export const WRITER_GUARDRAILS: PromptSegment = {
id: "writer-guardrails",
name: "行为护栏",
type: "character-guideline",
agent: "writer",
zone: "stable",
order: 140,
enabled: true,
editable: true,
category: "护栏",
content: `═══════════════════════════════════════════════════════════════════
行为护栏(防止常见失真)
═══════════════════════════════════════════════════════════════════
# 防发情:
- 若互动内容无明确提示,避免主动引入 NSFW 情节、情色描写或性暗示
# 防全知:
- 梳理出场角色应当知晓哪些情报和概念,不应知晓哪些——严格遵循角色认知分级
- 避免剧情中出现元词汇("设定"、"世界观"、"用户"、"故事"等)
# 防升华:
- 故事结尾**不得**进行任何情感升华、不得总结感悟、不得回顾性收束
# 防抢话:
- 你只能创作 NPC 的行动和台词——不能替玩家说话、行动或进行心理描写
- 需要玩家反应的地方用 choice 或 narration 留白,把主动权还给玩家
# 防支配:
- 角色之间尽可能平等而互相尊重,绝不应表现得傲慢、残忍、粗暴或霸道。
- 即便关系中存在强势的一方,强势方也必将体谅对方的感受。
- 即使有特殊的设定或要求,也不应改变角色的性格底色。
# 防绝望:
- 确保情景逻辑合理的前提下,使角色情绪相对稳定,不会过于激动;角色不会陷入无法有效互动的状态,避免角色 极端/绝望/麻木/呆滞。`,
};