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
|
@@ -146,6 +146,17 @@ export class FileNativeAuthorityV3 {
|
|
|
146
146
|
history,
|
|
147
147
|
historyLength: basis.historyLength + historyAppend.length,
|
|
148
148
|
materials,
|
|
149
|
+
...(input.narrativeCheckpoint === undefined
|
|
150
|
+
? basis.narrativeCheckpoint === undefined
|
|
151
|
+
? {}
|
|
152
|
+
: { narrativeCheckpoint: basis.narrativeCheckpoint }
|
|
153
|
+
: {
|
|
154
|
+
narrativeCheckpoint: {
|
|
155
|
+
...input.narrativeCheckpoint,
|
|
156
|
+
head,
|
|
157
|
+
historyMessageId: historyAppend.at(-1)?.messageId ?? "",
|
|
158
|
+
},
|
|
159
|
+
}),
|
|
149
160
|
};
|
|
150
161
|
assertEndpoint(endpointValue);
|
|
151
162
|
const endpoint = await this.#writeObject(sequence, "endpoint.json", endpointValue);
|
|
@@ -169,6 +180,12 @@ export class FileNativeAuthorityV3 {
|
|
|
169
180
|
};
|
|
170
181
|
const timelineParent = await this.#authorityRefAt(basisHead);
|
|
171
182
|
const commit = {
|
|
183
|
+
...(input.playContext === undefined
|
|
184
|
+
? {}
|
|
185
|
+
: { playContext: input.playContext }),
|
|
186
|
+
...(input.worldClock === undefined
|
|
187
|
+
? {}
|
|
188
|
+
: { worldClock: input.worldClock }),
|
|
172
189
|
schemaVersion: 3,
|
|
173
190
|
type: "file_native_authority_commit",
|
|
174
191
|
sequence,
|
|
@@ -180,6 +197,9 @@ export class FileNativeAuthorityV3 {
|
|
|
180
197
|
stateChanges: storedChanges,
|
|
181
198
|
nextAdditionalMaterials: structuredClone(input.nextMaterials),
|
|
182
199
|
result: endpoint,
|
|
200
|
+
...(input.narrativeCheckpoint === undefined
|
|
201
|
+
? {}
|
|
202
|
+
: { narrativeCheckpoint: structuredClone(input.narrativeCheckpoint) }),
|
|
183
203
|
...(input.correctionTargets === undefined
|
|
184
204
|
? {}
|
|
185
205
|
: { correctionTargets: structuredClone(input.correctionTargets) }),
|
|
@@ -241,8 +261,20 @@ export class FileNativeAuthorityV3 {
|
|
|
241
261
|
history,
|
|
242
262
|
additionalMaterials: structuredClone([...materials.items]),
|
|
243
263
|
result,
|
|
264
|
+
...(endpoint.narrativeCheckpoint === undefined
|
|
265
|
+
? {}
|
|
266
|
+
: {
|
|
267
|
+
narrativeCheckpoint: structuredClone(endpoint.narrativeCheckpoint),
|
|
268
|
+
}),
|
|
244
269
|
};
|
|
245
270
|
}
|
|
271
|
+
async readNarrativeCheckpoint(head) {
|
|
272
|
+
const current = await this.readHead();
|
|
273
|
+
const endpoint = await this.#readEndpoint(head === undefined || head === current.head
|
|
274
|
+
? current.result
|
|
275
|
+
: await this.#resultRefAt(head));
|
|
276
|
+
return structuredClone(endpoint.narrativeCheckpoint);
|
|
277
|
+
}
|
|
246
278
|
async recoverState(head) {
|
|
247
279
|
const current = await this.readHead();
|
|
248
280
|
const selected = head ?? current.head;
|
|
@@ -283,6 +315,18 @@ export class FileNativeAuthorityV3 {
|
|
|
283
315
|
throw new FileNativeAuthorityV3Error("corrupt", "Continuity head does not match the immutable Authority chain");
|
|
284
316
|
return { head: head.head, commits };
|
|
285
317
|
}
|
|
318
|
+
/** Exact bytes of an accepted state change, with the same digest check as recovery. */
|
|
319
|
+
async readStateChangeContents(change) {
|
|
320
|
+
const blob = change.nextBlob;
|
|
321
|
+
if (!isBlobRef(blob))
|
|
322
|
+
throw corruptShape("State-change blob");
|
|
323
|
+
const contents = await readFile(join(this.#epochRoot(blob.epoch), "blobs", `${blob.digest}.txt`), "utf8");
|
|
324
|
+
if (hashHex(contents) !== blob.digest ||
|
|
325
|
+
hashWithPrefix(contents) !== change.nextHash ||
|
|
326
|
+
blob.sha256 !== change.nextHash)
|
|
327
|
+
throw corruptShape("State-change blob digest");
|
|
328
|
+
return contents;
|
|
329
|
+
}
|
|
286
330
|
async commitAt(head) {
|
|
287
331
|
if (head === "genesis")
|
|
288
332
|
return null;
|
|
@@ -572,6 +616,9 @@ function assertEndpoint(value) {
|
|
|
572
616
|
"history",
|
|
573
617
|
"historyLength",
|
|
574
618
|
"materials",
|
|
619
|
+
...(value.narrativeCheckpoint === undefined
|
|
620
|
+
? []
|
|
621
|
+
: ["narrativeCheckpoint"]),
|
|
575
622
|
]) ||
|
|
576
623
|
value.schemaVersion !== 3 ||
|
|
577
624
|
value.type !== "file_native_authority_endpoint" ||
|
|
@@ -579,7 +626,9 @@ function assertEndpoint(value) {
|
|
|
579
626
|
(value.history !== null && !isObjectRef(value.history)) ||
|
|
580
627
|
!Number.isSafeInteger(value.historyLength) ||
|
|
581
628
|
Number(value.historyLength) < 0 ||
|
|
582
|
-
!isObjectRef(value.materials)
|
|
629
|
+
!isObjectRef(value.materials) ||
|
|
630
|
+
(value.narrativeCheckpoint !== undefined &&
|
|
631
|
+
!isNarrativeCheckpoint(value.narrativeCheckpoint, true)))
|
|
583
632
|
throw corruptShape("Authority endpoint");
|
|
584
633
|
}
|
|
585
634
|
function assertStateManifest(value) {
|
|
@@ -640,6 +689,16 @@ function assertCommit(value) {
|
|
|
640
689
|
throw corruptShape("Authority commit");
|
|
641
690
|
const correction = value.mode === "correction";
|
|
642
691
|
const revision = value.mode === "timeline_revision";
|
|
692
|
+
const lastHistory = Array.isArray(value.historyAppend)
|
|
693
|
+
? value.historyAppend.at(-1)
|
|
694
|
+
: undefined;
|
|
695
|
+
if (value.narrativeCheckpoint !== undefined &&
|
|
696
|
+
(!isNarrativeCheckpoint(value.narrativeCheckpoint, false) ||
|
|
697
|
+
value.mode !== "play" ||
|
|
698
|
+
!Array.isArray(value.historyAppend) ||
|
|
699
|
+
!isRecord(lastHistory) ||
|
|
700
|
+
lastHistory.role !== "narrator"))
|
|
701
|
+
throw corruptShape("Narrative checkpoint declaration");
|
|
643
702
|
if (!hasExactKeys(value, [
|
|
644
703
|
"schemaVersion",
|
|
645
704
|
"type",
|
|
@@ -647,6 +706,11 @@ function assertCommit(value) {
|
|
|
647
706
|
"head",
|
|
648
707
|
"auditParent",
|
|
649
708
|
"timelineParent",
|
|
709
|
+
...(value.playContext === undefined ? [] : ["playContext"]),
|
|
710
|
+
...(value.worldClock === undefined ? [] : ["worldClock"]),
|
|
711
|
+
...(value.narrativeCheckpoint === undefined
|
|
712
|
+
? []
|
|
713
|
+
: ["narrativeCheckpoint"]),
|
|
650
714
|
"mode",
|
|
651
715
|
"historyAppend",
|
|
652
716
|
"stateChanges",
|
|
@@ -657,6 +721,10 @@ function assertCommit(value) {
|
|
|
657
721
|
]) ||
|
|
658
722
|
value.schemaVersion !== 3 ||
|
|
659
723
|
value.type !== "file_native_authority_commit" ||
|
|
724
|
+
(value.playContext !== undefined &&
|
|
725
|
+
(typeof value.playContext !== "string" ||
|
|
726
|
+
value.playContext.length === 0)) ||
|
|
727
|
+
(value.worldClock !== undefined && typeof value.worldClock !== "string") ||
|
|
660
728
|
!Number.isSafeInteger(value.sequence) ||
|
|
661
729
|
Number(value.sequence) < 1 ||
|
|
662
730
|
value.head !== `commit:${String(value.sequence)}` ||
|
|
@@ -848,6 +916,25 @@ function hasExactKeys(value, keys) {
|
|
|
848
916
|
return (Object.keys(value).length === keys.length &&
|
|
849
917
|
keys.every((key) => Object.hasOwn(value, key)));
|
|
850
918
|
}
|
|
919
|
+
function isNarrativeCheckpoint(value, effective) {
|
|
920
|
+
if (!isRecord(value) ||
|
|
921
|
+
!hasExactKeys(value, [
|
|
922
|
+
"contextId",
|
|
923
|
+
"completedPlayerRounds",
|
|
924
|
+
...(effective ? ["head", "historyMessageId"] : []),
|
|
925
|
+
]) ||
|
|
926
|
+
typeof value.contextId !== "string" ||
|
|
927
|
+
value.contextId.length === 0 ||
|
|
928
|
+
!Number.isSafeInteger(value.completedPlayerRounds) ||
|
|
929
|
+
Number(value.completedPlayerRounds) < 0)
|
|
930
|
+
return false;
|
|
931
|
+
return (!effective ||
|
|
932
|
+
(typeof value.head === "string" &&
|
|
933
|
+
/^commit:[1-9][0-9]*$/u.test(value.head) &&
|
|
934
|
+
typeof value.historyMessageId === "string" &&
|
|
935
|
+
value.historyMessageId.startsWith(`message.${value.head.slice("commit:".length)}.`) &&
|
|
936
|
+
/^message\.[1-9][0-9]*\.[1-9][0-9]*\.narrator$/u.test(value.historyMessageId)));
|
|
937
|
+
}
|
|
851
938
|
function corruptShape(label) {
|
|
852
939
|
return new FileNativeAuthorityV3Error("corrupt", `${label} has an invalid shape`);
|
|
853
940
|
}
|