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.
- package/dist/node/runtime/authoring/AuthoringRequestSnapshot.js +14 -1
- package/dist/node/runtime/history/HistoryRendering.js +25 -6
- package/dist/node/runtime/history/HistoryTools.js +31 -0
- package/dist/node/runtime/play/FileNativeContinuityCorrection.js +12 -4
- package/dist/node/runtime/play/PlayCallChain.js +10 -21
- package/dist/node/runtime/play/PlayDocumentTools.js +72 -43
- package/dist/node/runtime/prompt/FileNativePromptCompiler.js +35 -19
- package/dist/node/runtime/prompt/FileNativeToolRegistry.js +15 -12
- package/dist/node/runtime/prompt/WorldMaterialCoverage.js +0 -67
- package/dist/node/runtime/setting/SettingAuthoringTransaction.js +326 -62
- package/dist/node/runtime/setting/SettingImprovementSession.js +40 -3
- package/dist/node/runtime/world/FileNativeWorldStore.js +13 -3
- package/dist/node/runtime/world/WorldDocumentMaintenance.js +9 -2
- package/dist/node/runtime/world/WorldDocumentStore.js +441 -389
- package/dist/node/runtime/world/WorldLedgerAuthority.js +18 -2
- package/dist/node/runtime/world/WorldStateRevision.js +6 -3
- package/dist/node/runtime/world-revision/FileNativeWorldRevisionStore.js +61 -17
- package/dist/node/runtime/world-revision/LegacyWorldRevisionEpochUpgrade.js +46 -0
- package/dist/node/runtime/world-revision/WorldRevisionAuthoringTransaction.js +83 -30
- package/dist/node/runtime/world-revision/WorldRevisionSession.js +64 -4
- package/dist/node/runtime/world-revision/WorldRevisionWorkspace.js +32 -11
- package/dist/node/shared/default-setting-improvement-prompt.js +23 -8
- package/dist/node/shared/ordered-author-prompts.js +9 -7
- package/dist/node/shared/ordered-play-prompts.js +2 -2
- package/dist/web/assets/index-B2kbaOGe.js +1408 -0
- package/dist/web/assets/{index-BjxBYYQi.css → index-DH2BVsYd.css} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-Cj2JYCia.js +0 -1408
|
@@ -4,9 +4,10 @@ import { InvalidContentTreeError, } from "../content/ContentWorkspace.js";
|
|
|
4
4
|
import { contentTreeFingerprint } from "../content/ContentTreeFingerprint.js";
|
|
5
5
|
import { equalModelHostBinding } from "../model/ModelHost.js";
|
|
6
6
|
import { settingImprovementPromptForBinding, } from "../play/FileNativePlayPresetStore.js";
|
|
7
|
+
import { WorldDocumentStore } from "../world/WorldDocumentStore.js";
|
|
7
8
|
import { appendAuthoringUserMessage, ModelToolConversation, rememberAuthoringRequest, resumePausedAuthoringConversation, } from "../authoring/ModelToolConversation.js";
|
|
8
9
|
import { summarizeStoredSettingImprovementSession, } from "./FileNativeSettingImprovementStore.js";
|
|
9
|
-
import { SettingAuthoringTransaction, settingImprovementRuntimeContract, settingImprovementToolDefinitions, } from "./SettingAuthoringTransaction.js";
|
|
10
|
+
import { SettingAuthoringTransaction, settingImprovementRuntimeContract, settingImprovementToolDefinitions, authoringPreloadAuthorization, buildAuthoringPreload, contentPackageAuthoringSurface, } from "./SettingAuthoringTransaction.js";
|
|
10
11
|
class RecoveryWriteConflictError extends Error {
|
|
11
12
|
}
|
|
12
13
|
export class SettingImprovementRollbackError extends Error {
|
|
@@ -186,7 +187,7 @@ export class SettingImprovementSession {
|
|
|
186
187
|
assertPackage(session, input.packageId);
|
|
187
188
|
}
|
|
188
189
|
return this.#startRequest(session, requestId, async (next) => {
|
|
189
|
-
const { playPreset, bootstrap } = await this.#compileCurrent(input.packageId, next.modelBinding);
|
|
190
|
+
const { playPreset, bootstrap, preload } = await this.#compileCurrent(input.packageId, next.modelBinding);
|
|
190
191
|
next.schemaVersion = 3;
|
|
191
192
|
next.requests ??= [];
|
|
192
193
|
next.requests.push({
|
|
@@ -194,7 +195,9 @@ export class SettingImprovementSession {
|
|
|
194
195
|
modelItemStart: next.modelItems.length,
|
|
195
196
|
bootstrap,
|
|
196
197
|
playPreset: structuredClone(playPreset),
|
|
198
|
+
preload: structuredClone(preload.record),
|
|
197
199
|
});
|
|
200
|
+
next.authorization = authoringPreloadAuthorization(next.authorization, preload.record);
|
|
198
201
|
appendAuthoringUserMessage(next, message, requestId);
|
|
199
202
|
});
|
|
200
203
|
});
|
|
@@ -244,6 +247,7 @@ export class SettingImprovementSession {
|
|
|
244
247
|
const playPreset = await this.#bindPlayPreset();
|
|
245
248
|
const locale = this.#locale();
|
|
246
249
|
const package_ = await this.#content.readCurrentTreeContentPackage(packageId);
|
|
250
|
+
const preload = this.#preload(package_.files, modelBinding, playPreset, locale);
|
|
247
251
|
const bootstrap = this.#compiler.compileSettingImprovement({
|
|
248
252
|
contentPackageTitle: package_.title,
|
|
249
253
|
gameplay: package_.gameplay,
|
|
@@ -252,8 +256,41 @@ export class SettingImprovementSession {
|
|
|
252
256
|
playPreset,
|
|
253
257
|
modelBinding: modelBinding,
|
|
254
258
|
tools: settingImprovementToolDefinitions(locale, package_.gameplay),
|
|
259
|
+
preload: preload.blocks,
|
|
260
|
+
});
|
|
261
|
+
return { bootstrap, playPreset, preload };
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Preloads the control documents and the documents the package frame injects.
|
|
265
|
+
* A preview that cannot be built degrades to the directory and control files.
|
|
266
|
+
*/
|
|
267
|
+
#preload(files, modelBinding, playPreset, locale) {
|
|
268
|
+
const revision = contentTreeFingerprint(files);
|
|
269
|
+
const snapshot = WorldDocumentStore.open({
|
|
270
|
+
layout: "content_package",
|
|
271
|
+
files: [...files],
|
|
272
|
+
});
|
|
273
|
+
let injected = [];
|
|
274
|
+
let injectedUnavailable;
|
|
275
|
+
try {
|
|
276
|
+
const preview = this.#preview(snapshot, modelBinding, playPreset);
|
|
277
|
+
injected = preview.compilation.coverage.flatMap(({ slot, status, readAuthorization }) => status === "resolved" && readAuthorization !== undefined
|
|
278
|
+
? [{ shortRef: readAuthorization.shortRef, slot }]
|
|
279
|
+
: []);
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
injectedUnavailable =
|
|
283
|
+
error instanceof Error ? error.message : "unknown preview failure";
|
|
284
|
+
}
|
|
285
|
+
return buildAuthoringPreload({
|
|
286
|
+
snapshot,
|
|
287
|
+
surface: contentPackageAuthoringSurface,
|
|
288
|
+
locale,
|
|
289
|
+
revision,
|
|
290
|
+
sourcePrefix: "content-package:preload",
|
|
291
|
+
injected,
|
|
292
|
+
...(injectedUnavailable === undefined ? {} : { injectedUnavailable }),
|
|
255
293
|
});
|
|
256
|
-
return { bootstrap, playPreset };
|
|
257
294
|
}
|
|
258
295
|
async cancel(sessionId) {
|
|
259
296
|
const running = this.#conversation.cancel(sessionId);
|
|
@@ -1114,10 +1114,20 @@ export class FileNativeWorldStore {
|
|
|
1114
1114
|
assertRelativePath(change.relativePath);
|
|
1115
1115
|
const previous = candidateState.get(change.relativePath);
|
|
1116
1116
|
const previousHash = previous === undefined ? null : sha256(previous);
|
|
1117
|
-
|
|
1118
|
-
|
|
1117
|
+
const nextBytes = change.canonicalNextBytes;
|
|
1118
|
+
const consistent = change.kind === "delete"
|
|
1119
|
+
? previous !== undefined &&
|
|
1120
|
+
nextBytes === null &&
|
|
1121
|
+
change.nextHash === null
|
|
1122
|
+
: nextBytes !== null &&
|
|
1123
|
+
change.nextHash !== null &&
|
|
1124
|
+
sha256(nextBytes) === change.nextHash;
|
|
1125
|
+
if (previousHash !== change.expectedPreviousHash || !consistent)
|
|
1119
1126
|
throw new FileNativeWorldCreationError("operation_conflict", `State-change hash conflicts: ${change.relativePath}`);
|
|
1120
|
-
|
|
1127
|
+
if (nextBytes === null)
|
|
1128
|
+
candidateState.delete(change.relativePath);
|
|
1129
|
+
else
|
|
1130
|
+
candidateState.set(change.relativePath, nextBytes);
|
|
1121
1131
|
}
|
|
1122
1132
|
const inspection = inspectContentPackageCurrentTree([
|
|
1123
1133
|
...[...candidateState].map(([path, contents]) => ({
|
|
@@ -87,10 +87,15 @@ export async function readDocumentMaintenanceFacts(authority, head, cache) {
|
|
|
87
87
|
continue;
|
|
88
88
|
const changed = await Promise.all(commit.stateChanges.map(async (change) => ({
|
|
89
89
|
change,
|
|
90
|
-
contents:
|
|
90
|
+
contents: change.kind === "delete"
|
|
91
|
+
? null
|
|
92
|
+
: await authority.readStateChangeContents(commit, change),
|
|
91
93
|
})));
|
|
92
94
|
for (const { change, contents } of changed)
|
|
93
|
-
|
|
95
|
+
if (contents === null)
|
|
96
|
+
files.delete(change.relativePath);
|
|
97
|
+
else
|
|
98
|
+
files.set(change.relativePath, contents);
|
|
94
99
|
const next = snapshot();
|
|
95
100
|
const position = {
|
|
96
101
|
kind: isCorrectionCommit(commit.mode)
|
|
@@ -103,6 +108,8 @@ export async function readDocumentMaintenanceFacts(authority, head, cache) {
|
|
|
103
108
|
worldTime: commit.worldClock ?? null,
|
|
104
109
|
};
|
|
105
110
|
for (const { change } of changed) {
|
|
111
|
+
if (change.kind === "delete")
|
|
112
|
+
continue;
|
|
106
113
|
const ref = change.stableShortRef;
|
|
107
114
|
const before = previous.query({
|
|
108
115
|
kind: "read_document",
|