narraeon 0.7.6 → 0.7.9

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.
Files changed (29) hide show
  1. package/dist/node/runtime/authoring/AuthoringRequestSnapshot.js +14 -1
  2. package/dist/node/runtime/history/HistoryRendering.js +25 -6
  3. package/dist/node/runtime/history/HistoryTools.js +31 -0
  4. package/dist/node/runtime/play/FileNativeContinuityCorrection.js +12 -4
  5. package/dist/node/runtime/play/PlayCallChain.js +10 -21
  6. package/dist/node/runtime/play/PlayDocumentTools.js +72 -43
  7. package/dist/node/runtime/prompt/FileNativePromptCompiler.js +35 -19
  8. package/dist/node/runtime/prompt/FileNativeToolRegistry.js +15 -12
  9. package/dist/node/runtime/prompt/WorldMaterialCoverage.js +0 -67
  10. package/dist/node/runtime/setting/SettingAuthoringTransaction.js +326 -62
  11. package/dist/node/runtime/setting/SettingImprovementSession.js +40 -3
  12. package/dist/node/runtime/world/FileNativeWorldStore.js +13 -3
  13. package/dist/node/runtime/world/WorldDocumentMaintenance.js +9 -2
  14. package/dist/node/runtime/world/WorldDocumentStore.js +441 -389
  15. package/dist/node/runtime/world/WorldLedgerAuthority.js +18 -2
  16. package/dist/node/runtime/world/WorldStateRevision.js +6 -3
  17. package/dist/node/runtime/world-revision/FileNativeWorldRevisionStore.js +61 -17
  18. package/dist/node/runtime/world-revision/LegacyWorldRevisionEpochUpgrade.js +46 -0
  19. package/dist/node/runtime/world-revision/WorldRevisionAuthoringTransaction.js +83 -30
  20. package/dist/node/runtime/world-revision/WorldRevisionSession.js +64 -4
  21. package/dist/node/runtime/world-revision/WorldRevisionWorkspace.js +32 -11
  22. package/dist/node/shared/default-setting-improvement-prompt.js +23 -8
  23. package/dist/node/shared/ordered-author-prompts.js +9 -7
  24. package/dist/node/shared/ordered-play-prompts.js +2 -2
  25. package/dist/web/assets/index-B2kbaOGe.js +1408 -0
  26. package/dist/web/assets/{index-BjxBYYQi.css → index-DH2BVsYd.css} +1 -1
  27. package/dist/web/index.html +2 -2
  28. package/package.json +1 -1
  29. package/dist/web/assets/index-Cj2JYCia.js +0 -1408
@@ -7,17 +7,22 @@
7
7
  * mechanical setting-improvement boundary.
8
8
  */
9
9
  export const defaultSettingImprovementPromptPath = "prompts/setting-improvement.md";
10
+ /** Content-package-only paragraphs; a running-world revision omits them. */
11
+ const contentPackageWorldStartZhCN = "内容包设定完善定义开场结束处的世界起点,可以包含已有历史、当前状态、持续过程和各人的认知。简单起点足以开玩,普通未定义内容可在游玩中生长;不预写未来必然发生的经历或强制剧情阶段。";
12
+ const contentPackageOpeningZhCN = "仅在内容包分支检查 opening.md:写玩家当时可感知的具体局面,保留尚待回答的请求与必要原话,不替玩家决定行动、台词或内心。独处、安静和等待也可形成开场。开场与文档停在同一时点,将约束首次行动的结果写给自然所有者,无需复制整篇叙事。";
13
+ const contentPackageWorldStartEn = "Content-package setting improvement defines the world where the opening ends, including established history, current state, ongoing processes and individual knowledge. A simple starting point can be playable and ordinary undefined content can grow during play. Do not prewrite inevitable future experiences or mandatory plot stages.";
14
+ const contentPackageOpeningEn = "Inspect opening.md only in the content-package branch. Show a concrete situation the player can perceive, retaining unanswered requests and consequential wording without choosing player action, speech or inner thoughts. Solitude, quiet and waiting can also open a story. Documents and opening stop at the same moment; give outcomes constraining the first action to natural owners without copying the whole narrative.";
10
15
  export const defaultSettingImprovementPromptZhCN = `# 系统推荐的创作方法
11
16
 
12
17
  以当前编辑目标、已有内容和用户目标为起点。讨论时说明必要判断,落实时定向修改;用户要求审查或重组时,相关结构与重复表达也在范围内。不为填满结构制造内容,无需修改也是合法结果。
13
18
 
14
19
  ## 编辑目标与世界起点
15
20
 
16
- 内容包设定完善定义开场结束处的世界起点,可以包含已有历史、当前状态、持续过程和各人的认知。简单起点足以开玩,普通未定义内容可在游玩中生长;不预写未来必然发生的经历或强制剧情阶段。
21
+ ${contentPackageWorldStartZhCN}
17
22
 
18
- 运行中世界修订维护当前已经演变的世界,按用户要求调整并保留未受影响的事实、经历与认知,不退回初始取值。此分支不读取或修改 opening.md。明确修订不是世界内事件,不需虚构行动解释它。
23
+ 运行中世界修订维护当前已经演变的世界,按用户要求调整并保留未受影响的事实、经历与认知,不退回初始取值。明确修订不是世界内事件,不需虚构行动解释它。
19
24
 
20
- 涉及结构、材料发现或更新位置时,先列出编辑目标根目录,完整读取 control/frame.yaml、启用的世界提示块、绑定的当前情境及受影响文档。实际操作遵守本轮工具边界。
25
+ 涉及结构、材料发现或更新位置时,以本请求 bootstrap 已提供的目录、控制文档与注入文档为起点;未提供而受影响的文档再用工具读取。实际操作遵守本轮工具边界。
21
26
 
22
27
  ## 世界信息怎样组织
23
28
 
@@ -41,7 +46,7 @@ world/ 或 state/ 承载虚构事实,control/ 安排本世界的取材、规
41
46
 
42
47
  ## 开场与整理
43
48
 
44
- 仅在内容包分支检查 opening.md:写玩家当时可感知的具体局面,保留尚待回答的请求与必要原话,不替玩家决定行动、台词或内心。独处、安静和等待也可形成开场。开场与文档停在同一时点,将约束首次行动的结果写给自然所有者,无需复制整篇叙事。
49
+ ${contentPackageOpeningZhCN}
45
50
 
46
51
  整理结束已完成或失效的进程、约定和限制,保留仍有意义的成果、后遗影响、经历与引用。补录、去重和归档不让事情再发生。长材料按需发现,软体积提示不授权截断;暂时离场不等于退役,退役也不会移除显式全文槽。
47
52
 
@@ -53,11 +58,11 @@ Start with the editing target, existing content and the user's goal. Discuss nec
53
58
 
54
59
  ## Editing target and world starting point
55
60
 
56
- Content-package setting improvement defines the world where the opening ends, including established history, current state, ongoing processes and individual knowledge. A simple starting point can be playable and ordinary undefined content can grow during play. Do not prewrite inevitable future experiences or mandatory plot stages.
61
+ ${contentPackageWorldStartEn}
57
62
 
58
- Running-world revision maintains the world as it has evolved: apply requested changes while preserving unaffected facts, events and knowledge instead of resetting initial values. This branch does not read or modify opening.md. Explicit revision is not an in-world event and needs no invented action to explain it.
63
+ Running-world revision maintains the world as it has evolved: apply requested changes while preserving unaffected facts, events and knowledge instead of resetting initial values. Explicit revision is not an in-world event and needs no invented action to explain it.
59
64
 
60
- When structure, discovery or update locations are affected, list the editing target's root and completely read control/frame.yaml, enabled world instructions, the bound current situation and affected documents. Follow this request's actual tool boundary.
65
+ When structure, discovery or update locations are affected, start from the directory, control documents and injected documents this request's bootstrap already provides; read affected documents with tools only when they were not provided. Follow this request's actual tool boundary.
61
66
 
62
67
  ## Organizing world information
63
68
 
@@ -81,7 +86,7 @@ world/ or state/ carries fictional facts. control/ arranges world-specific mater
81
86
 
82
87
  ## Opening and consolidation
83
88
 
84
- Inspect opening.md only in the content-package branch. Show a concrete situation the player can perceive, retaining unanswered requests and consequential wording without choosing player action, speech or inner thoughts. Solitude, quiet and waiting can also open a story. Documents and opening stop at the same moment; give outcomes constraining the first action to natural owners without copying the whole narrative.
89
+ ${contentPackageOpeningEn}
85
90
 
86
91
  Consolidation closes completed or expired processes, commitments and restrictions while retaining meaningful results, lasting effects, events and references. Recording, deduplication and archiving do not perform events again. Keep long material discoverable on demand; advisory size limits do not authorize truncation. Temporary absence is not retirement, and retirement does not remove explicit full-document slots.
87
92
 
@@ -93,3 +98,13 @@ export function defaultSettingImprovementPromptForLocale(locale) {
93
98
  ? defaultSettingImprovementPromptZhCN
94
99
  : defaultSettingImprovementPromptEn;
95
100
  }
101
+ /**
102
+ * The same guidance for a running-world revision: the content-package-only
103
+ * paragraphs are omitted, and everything else stays byte-identical.
104
+ */
105
+ export function revisionSettingImprovementPromptForLocale(locale) {
106
+ const paragraphs = locale === "zh-CN"
107
+ ? [contentPackageWorldStartZhCN, contentPackageOpeningZhCN]
108
+ : [contentPackageWorldStartEn, contentPackageOpeningEn];
109
+ return paragraphs.reduce((text, paragraph) => text.replace(`${paragraph}\n\n`, ""), defaultSettingImprovementPromptForLocale(locale));
110
+ }
@@ -1,7 +1,7 @@
1
- import { defaultSettingImprovementPromptForLocale } from "./default-setting-improvement-prompt.js";
1
+ import { defaultSettingImprovementPromptForLocale, revisionSettingImprovementPromptForLocale, } from "./default-setting-improvement-prompt.js";
2
2
  import { tabletopAuthorBody } from "./tabletop-guidance.js";
3
3
  /** Authoring uses the same permissions as play, with target-specific dynamic references. */
4
- export function builtinAuthorPrompts(locale) {
4
+ export function builtinAuthorPrompts(locale, target = "setting") {
5
5
  const zh = locale === "zh-CN";
6
6
  return [
7
7
  {
@@ -18,7 +18,9 @@ export function builtinAuthorPrompts(locale) {
18
18
  name: zh ? "创作建议" : "Authoring guidance",
19
19
  required: false,
20
20
  category: "policy",
21
- body: defaultSettingImprovementPromptForLocale(locale),
21
+ body: target === "world-revision"
22
+ ? revisionSettingImprovementPromptForLocale(locale)
23
+ : defaultSettingImprovementPromptForLocale(locale),
22
24
  },
23
25
  {
24
26
  id: "author.tabletop",
@@ -53,15 +55,15 @@ export function builtinAuthorPrompts(locale) {
53
55
  export function authoringMechanics(locale, target) {
54
56
  const zh = locale === "zh-CN";
55
57
  const common = zh
56
- ? `只使用请求随附的工具及其参数契约。含工具调用的响应是中间步;收到全部工具结果后继续,非空且无工具调用的响应结束本次发送。完整工具响应按调用顺序结算,失败调用不撤销成功同级调用。修改既有文件前必须完整读取;cursor 只属于产生它的树 revision;本事务自身成功修改后的完整读取授权由 Runtime 承接。外部树变化或跨 epoch 后旧授权失效,需要重新读取。工具返回逻辑路径,不能访问宿主文件。文档引用使用返回的 @ref;YAML 整文档引用为单键 {$ref: "@ref"},locator 使用 map key 或从零开始的数组下标。成功回执决定当前值,模型文字不构成提交。`
57
- : `Use only the attached tools and their parameter contracts. Responses with tool calls are intermediate steps; continue after all results. A nonempty tool-free response ends this send. Complete tool responses settle calls in order; a failed call does not undo successful siblings. Completely read existing files before writing. Cursors belong to their producing tree revision. Runtime carries complete-read authorization through this transaction’s own successful changes. External tree changes or an epoch transition invalidate old authorization and require new reads. Tools expose logical paths, never host files. Use returned @refs for documents; YAML whole-document references are single-key {$ref: "@ref"} maps, and locators use map keys or zero-based array indexes. Actual receipts determine current values; model prose cannot commit changes.`;
58
+ ? `只使用请求随附的工具及其参数契约。含工具调用的响应是中间步;收到全部工具结果后继续,非空且无工具调用的响应结束本次发送。完整工具响应按调用顺序结算,失败调用不撤销成功同级调用。修改既有文件前必须完整读取;cursor 只属于产生它的树 revision;本事务自身成功修改后的完整读取授权由 Runtime 承接。外部树变化或跨 epoch 后旧授权失效,需要重新读取。bootstrap 中 Runtime 预载的完整文档视为已在该 revision 完整读取,可直接修改;目录不算读取。工具返回逻辑路径,不能访问宿主文件。文档引用使用返回的 @ref;YAML 整文档引用为单键 {$ref: "@ref"},locator 使用 map key 或从零开始的数组下标。成功回执决定当前值,模型文字不构成提交。`
59
+ : `Use only the attached tools and their parameter contracts. Responses with tool calls are intermediate steps; continue after all results. A nonempty tool-free response ends this send. Complete tool responses settle calls in order; a failed call does not undo successful siblings. Completely read existing files before writing. Cursors belong to their producing tree revision. Runtime carries complete-read authorization through this transaction’s own successful changes. External tree changes or an epoch transition invalidate old authorization and require new reads. Runtime-preloaded complete documents in the bootstrap count as completely read at that revision; the directory does not. Tools expose logical paths, never host files. Use returned @refs for documents; YAML whole-document references are single-key {$ref: "@ref"} maps, and locators use map keys or zero-based array indexes. Actual receipts determine current values; model prose cannot commit changes.`;
58
60
  const boundary = target === "setting"
59
61
  ? zh
60
62
  ? "内容包工具的成功变化在完整响应结算时原子发布到当前树,无需应用。setting_create 建立新文档身份;删除仅在无绑定与引用阻挡时接受。"
61
63
  : "Successful content-package changes publish atomically to the current tree when the complete response settles, with no Apply step. setting_create establishes new document identities; deletion is accepted only without binding or reference blockers."
62
64
  : zh
63
- ? "世界修订工具只修改持久独占 epoch 的 state/* 与 control/* 工作树。opening.md 不可读取或修改,既有状态文档不可删除或移动。只有玩家应用或放弃才结束 epoch;应用提交世界,放弃不改变世界。跨 epoch 全部旧读取授权失效。"
64
- : "World-revision tools modify only state/* and control/* in the durably locked exclusive epoch. opening.md cannot be read or changed; existing state documents cannot be deleted or moved. Only player Apply or Discard ends the epoch; Apply commits the world, Discard leaves it unchanged. Every old read authorization expires across epochs.";
65
+ ? "世界修订工具只修改持久独占 epoch 的 state/* 与 control/* 工作树。opening.md 不可读取或修改;既有状态文档可以删除或移动,删除须无绑定与引用阻挡。只有玩家应用或放弃才结束 epoch;应用提交世界,放弃不改变世界。跨 epoch 全部旧读取授权失效。世界修订可用 history_list、history_search、history_read 只读导航已提交历史,历史不能被改写。"
66
+ : "World-revision tools modify only state/* and control/* in the durably locked exclusive epoch. opening.md cannot be read or changed; existing state documents can be deleted or moved, and deletion requires no binding or reference blockers. Only player Apply or Discard ends the epoch; Apply commits the world, Discard leaves it unchanged. Every old read authorization expires across epochs. World revision may read committed history with history_list, history_search and history_read; history cannot be rewritten.";
65
67
  const views = zh
66
68
  ? 'control/player-views.yaml 的 format 为 narraeon.player-views/v1;views 中每项有 id、title 和 items,items 中每项有 id、label、select。精确选择一个 YAML 字段使用 select: {document: "@ref", locator: {yaml: [字段名]}};Markdown 小节使用 locator: {markdown: [标题]}。document 必须来自实际返回的引用,locator 必须对应已读正文;省略 locator 会展示整份文档,选择容器会递归展示子树。'
67
69
  : 'control/player-views.yaml uses format: narraeon.player-views/v1. Each views entry has id, title and items; each item has id, label and select. Select one YAML field with select: {document: "@ref", locator: {yaml: [field]}}; select a Markdown section with locator: {markdown: [heading]}. Use a returned document reference and a locator from the actual read body. Omitting locator displays the whole document; selecting a container recursively displays its subtree.';
@@ -100,7 +100,7 @@ export function builtinPlayPrompts(locale) {
100
100
 
101
101
  只可调用请求随附的工具。目录使用预加载索引或工具返回的 @dir-*,无需重复列目录确认;文档和历史使用返回的 @句柄。工具结果标明读取范围、完整性及 cursor;目录摘要不等于正文。材料覆盖中完整正文与精确读取取得对应范围的写入资格,界面绑定标注不扩大写入资格。初始世界材料只在全新上下文加载一次;后续成功工具调用与回执更新当前值和读取资格,不必重读自己刚成功写入的内容。全新上下文不继承旧对话的读取与写入资格。
102
102
 
103
- world_patch 的 YAML locator 可以包含 map key 和从零开始的数组下标;remove 删除一个精确位置。未提供的元数据保持原值。world_retire 从目录注入中退役文档,文档仍可读取、引用和恢复。工具响应的成功状态变化与后续最终叙事分别提交,后续失败不回滚已提交变化。成功写入回执表示当前值已改变;以真实回执的结算状态为准,模型文字不能提交世界。
103
+ world_patch 的 YAML locator 可以包含 map key 和从零开始的数组下标;add 与 replace 是 upsert,无论目标是否存在都写入,下标达到或超过长度时追加;remove 删除一个精确位置,目标不存在时为无操作。每条 edit 独立结算:失败的 edit 被跳过,其余照常生效;回执列出失败项时,已生效的 edit 不要重发,只补发列出的 edit。未提供的元数据保持原值。world_retire 从目录注入中退役文档,文档仍可读取、引用和恢复。工具响应的成功状态变化与后续最终叙事分别提交,后续失败不回滚已提交变化。成功写入回执表示当前值已改变;以真实回执的结算状态为准,模型文字不能提交世界。
104
104
 
105
105
  包含工具调用的响应属于中间步,其中的文字尚未展示或提交为最终叙事。收到全部工具结果后,根据回执在最终正文中呈现本轮尚未展示的内容,并与已提交状态一致;没有工具调用的非空正文结束本次循环并由 Runtime 提交。world_checkpoint 登记历史重放边界并向玩家建议从此开始全新上下文;在随后非空且无工具调用的最终正文成功提交后生效,边界包含该正文;登记后仍可继续工具调用。登记不结束世界内事件,也不自动切换上下文,玩家自行选择。全新上下文补入边界后的已提交玩家原文与最终叙事,排除开场白、工具和推理。何时登记由检查点政策块规定。
106
106
 
@@ -109,7 +109,7 @@ ${historyUseGuidance(locale)}`
109
109
 
110
110
  Use only attached tools. Directories use @dir-* handles from the preload or tool results; do not list them again just to confirm a handle; documents and history use returned @handles. Results identify read scope, completeness and cursor; directory summaries are not document bodies. Complete injected bodies and exact reads obtain write authorization within their corresponding scopes; player-view annotations do not widen it. Initial world materials load once per fresh context. Later successful tool calls and receipts update current values and read scopes; do not re-read merely to confirm your own successful writes. A fresh context does not inherit an old conversation's read or write authorization.
111
111
 
112
- YAML world_patch locators accept map keys and zero-based array indexes; remove deletes one exact location. Omitted metadata remains unchanged. world_retire removes a document from catalog injection while keeping it readable, referenceable and restorable. Successful tool-response state changes and later final narrative commit separately; later failure does not roll back committed changes. Successful write receipts change current values; the actual receipt determines settlement, not model prose.
112
+ YAML world_patch locators accept map keys and zero-based array indexes; add and replace are upserts that write whether or not the target exists, and an index past the end appends; remove deletes one exact location and is a no-op when it is absent. Each edit settles on its own: a failed edit is skipped and the others still apply, so when a receipt lists failed edits, send again only those. Omitted metadata remains unchanged. world_retire removes a document from catalog injection while keeping it readable, referenceable and restorable. Successful tool-response state changes and later final narrative commit separately; later failure does not roll back committed changes. Successful write receipts change current values; the actual receipt determines settlement, not model prose.
113
113
 
114
114
  Responses containing tool calls are intermediate steps; their text has not yet been displayed or committed as final narrative. After all tool results, use the receipts to present this turn's still-unshown content in final prose consistent with committed state. A nonempty tool-free response ends this loop and Runtime commits it. world_checkpoint registers the history-replay boundary and suggests a fresh context from that point to the player; it takes effect after the subsequent nonempty tool-free final prose successfully commits, including that prose, and further tool calls may follow registration. Registration neither ends an in-world event nor switches context, which the player chooses. Fresh-context replay contains committed player originals and final narratives after the boundary, excluding the opening, tools and reasoning. The checkpoint policy block decides when to register.
115
115