narraeon 0.4.0 → 0.5.0
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/node/protocol/appPreferences.js +25 -0
- package/dist/node/protocol/conversationObservation.js +67 -0
- package/dist/node/protocol/v1.js +186 -34
- package/dist/node/protocol/worldExtensions.js +16 -0
- package/dist/node/protocol/worldMaintenance.js +77 -0
- package/dist/node/protocol/worldPromptDiagnostics.js +1 -0
- package/dist/node/runtime/ConversationChanges.js +24 -0
- package/dist/node/runtime/V1Runtime.js +445 -121
- package/dist/node/runtime/artifact/FileNativeArtifactStore.js +326 -12
- package/dist/node/runtime/authoring/AuthoringRequestSnapshot.js +63 -0
- package/dist/node/runtime/authoring/ModelToolConversation.js +218 -0
- package/dist/node/runtime/config/AppPreferencesStore.js +46 -17
- package/dist/node/runtime/content/ContentTreeFingerprint.js +13 -0
- package/dist/node/runtime/content/ContentWorkspace.js +43 -13
- package/dist/node/runtime/content/CurrentTreeContentLibrary.js +128 -46
- package/dist/node/runtime/content/FileNativeContentTree.js +28 -10
- package/dist/node/runtime/content/PackageFollowups.js +80 -0
- package/dist/node/runtime/extension/FrontendExtensionBundle.js +19 -14
- package/dist/node/runtime/extension/PackageScriptPermissions.js +70 -0
- package/dist/node/runtime/extension/WorldExtensionControls.js +205 -0
- package/dist/node/runtime/extension/WorldExtensionRequests.js +64 -0
- package/dist/node/runtime/model/FileNativeModelAdapters.js +21 -466
- package/dist/node/runtime/model/ModelConnectionStore.js +13 -0
- package/dist/node/runtime/model/ModelHost.js +31 -1
- package/dist/node/runtime/model/ModelHostStream.js +51 -5
- package/dist/node/runtime/play/FileNativeContinuityCorrection.js +55 -45
- package/dist/node/runtime/play/FileNativePlayPresetStore.js +256 -238
- package/dist/node/runtime/play/FileNativePlayTimelineStore.js +118 -9
- package/dist/node/runtime/play/OrderedFollowups.js +71 -0
- package/dist/node/runtime/play/OrderedPlayPrompts.js +180 -0
- package/dist/node/runtime/play/PlayCallChain.js +814 -61
- package/dist/node/runtime/play/PlayContinuity.js +88 -0
- package/dist/node/runtime/play/PlayDocumentTools.js +205 -287
- package/dist/node/runtime/play/PlayFollowupRequests.js +34 -3
- package/dist/node/runtime/play/PlayPresetWorkbench.js +45 -54
- package/dist/node/runtime/play/PlayPromptRun.js +86 -0
- package/dist/node/runtime/prompt/FileNativePromptCompiler.js +670 -93
- package/dist/node/runtime/prompt/FileNativeToolRegistry.js +37 -21
- package/dist/node/runtime/prompt/PromptCompilationCodec.js +322 -0
- package/dist/node/runtime/prompt/WorldMaintenanceReport.js +251 -0
- package/dist/node/runtime/prompt/WorldMaterialCoverage.js +83 -0
- package/dist/node/runtime/prompt/WorldPromptDiagnostics.js +185 -0
- package/dist/node/runtime/setting/FileNativeSettingImprovementStore.js +1027 -0
- package/dist/node/runtime/setting/SettingAuthoringTransaction.js +1339 -0
- package/dist/node/runtime/setting/SettingImprovementSession.js +714 -0
- package/dist/node/runtime/world/FileNativeAuthorityV3.js +88 -1
- package/dist/node/runtime/world/FileNativeWorldStore.js +292 -27
- package/dist/node/runtime/world/PlayerViewBindings.js +30 -0
- package/dist/node/runtime/world/PlayerViewRenderer.js +27 -34
- package/dist/node/runtime/world/WorldDocumentMaintenance.js +174 -0
- package/dist/node/runtime/world/WorldDocumentStore.js +166 -96
- package/dist/node/runtime/world/WorldOperationCoordinator.js +103 -2
- package/dist/node/runtime/world-revision/FileNativeWorldRevisionStore.js +696 -0
- package/dist/node/runtime/world-revision/WorldRevisionAuthoringTransaction.js +380 -0
- package/dist/node/runtime/world-revision/WorldRevisionSession.js +709 -0
- package/dist/node/runtime/world-revision/WorldRevisionWorkspace.js +494 -0
- package/dist/node/server/ConversationStream.js +109 -0
- package/dist/node/server/createServer.js +5 -1
- package/dist/node/shared/artifact-payload-contract.js +123 -0
- package/dist/node/shared/default-play-prompts.js +25 -45
- package/dist/node/shared/default-preset-host.js +114 -138
- package/dist/node/shared/default-setting-improvement-prompt.js +52 -38
- package/dist/node/shared/display-regex.js +114 -0
- package/dist/node/shared/first-party-action-choices.js +1 -6
- package/dist/node/shared/first-party-player-view.js +1 -6
- package/dist/node/shared/ordered-author-prompts.js +64 -0
- package/dist/node/shared/ordered-followups.js +42 -0
- package/dist/node/shared/ordered-play-prompts.js +73 -0
- package/dist/web/assets/index-BXfelCi9.js +1207 -0
- package/dist/web/assets/index-BYnhUxlk.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/node/runtime/model/SettingAuthorStream.js +0 -21
- package/dist/node/runtime/setting/DocumentCandidateSettingImprovement.js +0 -1731
- package/dist/web/assets/index-D8YKfmNG.js +0 -1192
- package/dist/web/assets/index-Xa0s35CJ.css +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** Narrative history contains only committed original inputs and final prose. */
|
|
2
|
+
export function completedPlayerRounds(history) {
|
|
3
|
+
let pending = false;
|
|
4
|
+
let completed = 0;
|
|
5
|
+
for (const [id, text] of Object.entries(history)) {
|
|
6
|
+
if (id.includes("message.genesis"))
|
|
7
|
+
continue;
|
|
8
|
+
if (id.endsWith(".player"))
|
|
9
|
+
pending = text.trim().length > 0;
|
|
10
|
+
else if (id.endsWith(".narrator") && pending) {
|
|
11
|
+
completed += 1;
|
|
12
|
+
pending = false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return completed;
|
|
16
|
+
}
|
|
17
|
+
export function checkpointHistory(history, checkpoint) {
|
|
18
|
+
const entries = Object.entries(history);
|
|
19
|
+
const cutoff = checkpoint === undefined
|
|
20
|
+
? -1
|
|
21
|
+
: entries.findIndex(([id]) => id === checkpoint.historyMessageId ||
|
|
22
|
+
id.endsWith(`.${checkpoint.historyMessageId}`));
|
|
23
|
+
if (checkpoint !== undefined && cutoff < 0)
|
|
24
|
+
throw new Error("The narrative checkpoint is not reachable in this history.");
|
|
25
|
+
return entries
|
|
26
|
+
.slice(cutoff + 1)
|
|
27
|
+
.filter(([id]) => !id.includes("message.genesis"));
|
|
28
|
+
}
|
|
29
|
+
export function playerRoundMarker(rounds, hasCheckpoint, locale) {
|
|
30
|
+
const markdown = locale === "zh-CN"
|
|
31
|
+
? `距上次检查点已完成 ${rounds} 回合。${hasCheckpoint ? "" : "当前尚无检查点,以世界起点计数。"}必要状态整理完成时,可调用 world_checkpoint 建议在此开启全新上下文。`
|
|
32
|
+
: `Completed player rounds since the last checkpoint: ${rounds}. ${hasCheckpoint ? "" : "No checkpoint yet; counting from the world origin. "}When necessary state maintenance is complete, world_checkpoint can suggest starting a fresh context here.`;
|
|
33
|
+
return {
|
|
34
|
+
kind: "runtime_notice",
|
|
35
|
+
notice: "checkpoint_rounds",
|
|
36
|
+
text: `${locale === "zh-CN" ? "[Runtime 回合提示]" : "[Runtime round marker]"}\n${markdown}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function isPlayerRoundMarker(item) {
|
|
40
|
+
return item?.kind === "runtime_notice" && item.notice === "checkpoint_rounds";
|
|
41
|
+
}
|
|
42
|
+
export function continuationNotice(locale) {
|
|
43
|
+
return {
|
|
44
|
+
kind: "runtime_notice",
|
|
45
|
+
notice: "continuation",
|
|
46
|
+
text: locale === "zh-CN"
|
|
47
|
+
? "[Runtime 续写提示]\n本次发送没有追加新的玩家原文。请从当前对话继续生成;已有的最终主持正文是已经完成的历史。"
|
|
48
|
+
: "[Runtime continuation]\nThis send adds no new player input. Continue generation from the current conversation; existing final narrator messages are already completed history.",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function toolStepNotice(locale) {
|
|
52
|
+
return {
|
|
53
|
+
kind: "runtime_notice",
|
|
54
|
+
notice: "tool_step",
|
|
55
|
+
text: locale === "zh-CN"
|
|
56
|
+
? "[Runtime 结算提示]\n上一响应同时调用了工具,其中的文字没有作为最终故事展示或提交。工具已按回执结算;请从已提交结果继续,最终用无工具调用的非空叙事完成本次发送。"
|
|
57
|
+
: "[Runtime settlement]\nThe previous response called tools, so its text was not displayed or committed as final story. The tools have settled as their receipts state. Continue from committed results, then finish this send with nonempty narrative and no tool calls.",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function playerInputAppend(input) {
|
|
61
|
+
return [
|
|
62
|
+
...(input.text.trim().length > 0 && input.checkpointAvailable
|
|
63
|
+
? [
|
|
64
|
+
playerRoundMarker(completedPlayerRounds(input.history) -
|
|
65
|
+
(input.checkpoint?.completedPlayerRounds ?? 0), input.checkpoint !== undefined, input.locale),
|
|
66
|
+
]
|
|
67
|
+
: []),
|
|
68
|
+
{ kind: "player", text: input.text },
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
export function checkpointReplayBlocks(history, checkpoint, locale) {
|
|
72
|
+
const entries = checkpointHistory(history, checkpoint);
|
|
73
|
+
if (entries.length === 0)
|
|
74
|
+
return [];
|
|
75
|
+
const zh = locale === "zh-CN";
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
source: "runtime:checkpoint-history:notice",
|
|
79
|
+
markdown: zh
|
|
80
|
+
? "# 检查点后的已提交原文\n\n以下是当前时间线上最近一次已生效检查点之后的玩家原文与最终主持叙事;尚无检查点时从世界起点选取,开场白除外。部分结果可能已写入当前文档;这些记录用于核对连续性,不代表需要再次执行其中的事件。当前明确的世界修订优先,不能用旧叙事推翻修订。"
|
|
81
|
+
: "# Committed history after the checkpoint\n\nThese are the current timeline’s original player inputs and final narratives after its last effective checkpoint (or the world origin if none, excluding the opening). Some results may already be in current documents. These records support continuity, not repeated execution. Explicit current world corrections take precedence over old narrative.",
|
|
82
|
+
},
|
|
83
|
+
...entries.map(([id, text]) => ({
|
|
84
|
+
source: `runtime:checkpoint-history:${id}`,
|
|
85
|
+
markdown: `## ${id.endsWith(".player") ? (zh ? "玩家原文" : "Player input") : zh ? "主持叙事" : "Host narrative"}\n\n${text}`,
|
|
86
|
+
})),
|
|
87
|
+
];
|
|
88
|
+
}
|