@musnows/scriverse 0.5.10 → 0.5.12
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/ai.js +80 -5
- package/dist/ai.js.map +1 -1
- package/dist/app.js +61 -4
- package/dist/app.js.map +1 -1
- package/dist/cli-contract.js +25 -0
- package/dist/cli-contract.js.map +1 -1
- package/dist/cli-core.js +3 -0
- package/dist/cli-core.js.map +1 -1
- package/dist/database.js +66 -1
- package/dist/database.js.map +1 -1
- package/dist/public/app.js +666 -110
- package/dist/public/entity-version.js +2 -0
- package/dist/public/index.html +10 -2
- package/dist/public/markdown.js +6 -1
- package/dist/public/module-request-cache.d.ts +17 -0
- package/dist/public/module-request-cache.js +35 -0
- package/dist/public/page-route.d.ts +1 -1
- package/dist/public/page-route.js +1 -0
- package/dist/public/stream-typewriter.d.ts +19 -0
- package/dist/public/stream-typewriter.js +83 -0
- package/dist/public/styles.css +70 -6
- package/dist/public/work-permissions.d.ts +2 -2
- package/dist/public/work-permissions.js +8 -0
- package/dist/store.js +164 -18
- package/dist/store.js.map +1 -1
- package/dist/user-auth.js +12 -5
- package/dist/user-auth.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/work-permissions.js +9 -0
- package/dist/work-permissions.js.map +1 -1
- package/dist/writing-progress-time.js +71 -0
- package/dist/writing-progress-time.js.map +1 -0
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -65,6 +65,7 @@ const memberRoleValueSchema = z.enum(["editor", "settings-editor", "viewer"]);
|
|
|
65
65
|
const moduleAccessSchema = z.enum(["none", "read", "write"]);
|
|
66
66
|
const modulePermissionsSchema = z.object({
|
|
67
67
|
prose: moduleAccessSchema,
|
|
68
|
+
drafts: moduleAccessSchema.optional(),
|
|
68
69
|
settings: moduleAccessSchema,
|
|
69
70
|
characters: moduleAccessSchema,
|
|
70
71
|
races: moduleAccessSchema,
|
|
@@ -76,7 +77,12 @@ const modulePermissionsSchema = z.object({
|
|
|
76
77
|
"ai-chat": moduleAccessSchema,
|
|
77
78
|
"ai-analysis": moduleAccessSchema,
|
|
78
79
|
"ai-settings": moduleAccessSchema
|
|
79
|
-
}).strict()
|
|
80
|
+
}).strict().transform((permissions) => ({
|
|
81
|
+
...permissions,
|
|
82
|
+
drafts: permissions.drafts ?? (permissions.prose === "write" && permissions.settings === "write"
|
|
83
|
+
? "write"
|
|
84
|
+
: permissions.prose === "none" || permissions.settings === "none" ? "none" : "read")
|
|
85
|
+
}));
|
|
80
86
|
const memberSchema = z.union([
|
|
81
87
|
z.object({ userId: identifier, permissions: modulePermissionsSchema }).strict(),
|
|
82
88
|
z.object({ userId: identifier, role: memberRoleValueSchema }).strict()
|
|
@@ -97,7 +103,7 @@ const presenceHeartbeatSchema = z.object({
|
|
|
97
103
|
page: z.discriminatedUnion("kind", [
|
|
98
104
|
z.object({ kind: z.literal(presencePageKinds[0]) }).strict(),
|
|
99
105
|
z.object({ kind: z.literal(presencePageKinds[1]), resourceId: identifier }).strict(),
|
|
100
|
-
z.object({ kind: z.literal(presencePageKinds[2]), module: z.enum(["settings", "characters", "races", "organizations", "timeline", "relationships", "outlines", "reviews", "tasks", "ai-settings"]) }).strict(),
|
|
106
|
+
z.object({ kind: z.literal(presencePageKinds[2]), module: z.enum(["drafts", "settings", "characters", "races", "organizations", "timeline", "relationships", "outlines", "reviews", "tasks", "ai-settings"]) }).strict(),
|
|
101
107
|
z.object({ kind: z.literal(presencePageKinds[3]), module: z.enum(["setting", "character", "race", "organization", "relationship"]), resourceId: identifier.optional() }).strict(),
|
|
102
108
|
z.object({ kind: z.literal(presencePageKinds[4]) }).strict()
|
|
103
109
|
])
|
|
@@ -136,6 +142,11 @@ const settingSchema = z.object({
|
|
|
136
142
|
scope: jsonObject.optional(),
|
|
137
143
|
authorNote: z.string().max(20_000).optional()
|
|
138
144
|
});
|
|
145
|
+
const draftSchema = z.object({
|
|
146
|
+
draftType: z.enum(["prose", "setting"]),
|
|
147
|
+
title: nonEmpty.max(200),
|
|
148
|
+
content: z.string().max(200_000)
|
|
149
|
+
}).strict();
|
|
139
150
|
const characterSchema = z.object({
|
|
140
151
|
name: nonEmpty.max(200),
|
|
141
152
|
code: z.string().trim().max(200).optional(),
|
|
@@ -304,6 +315,7 @@ const aiUsageQuerySchema = z.object({
|
|
|
304
315
|
timezoneOffset: z.coerce.number().int().min(-840).max(840).default(0)
|
|
305
316
|
}).strict();
|
|
306
317
|
const platformPageSizesSchema = z.object({
|
|
318
|
+
drafts: z.number().int().min(10).max(100).optional(),
|
|
307
319
|
settings: z.number().int().min(10).max(100).optional(),
|
|
308
320
|
characters: z.number().int().min(10).max(100).optional(),
|
|
309
321
|
races: z.number().int().min(10).max(100).optional(),
|
|
@@ -361,7 +373,7 @@ const workAiSettingsSchema = z.object({
|
|
|
361
373
|
autoRunFailureThreshold: z.number().int().min(1).max(10).optional(),
|
|
362
374
|
bookSummaryContextPercent: z.number().int().min(1).max(90).optional(),
|
|
363
375
|
contextCompactThreshold: z.number().int().min(50).max(90).optional(),
|
|
364
|
-
agentTools: z.array(z.enum(["story_index", "read_chapters", "grep", "search_story_entities", "read_character_sections"])).max(
|
|
376
|
+
agentTools: z.array(z.enum(["story_index", "read_chapters", "grep", "search_story_entities", "read_character_sections", "search_drafts"])).max(6).optional()
|
|
365
377
|
}).strict();
|
|
366
378
|
const contextSchema = z.object({
|
|
367
379
|
type: z.enum(["none", "selection", "chapter", "volume", "book", "entities"]),
|
|
@@ -861,6 +873,10 @@ export function createRuntime(options) {
|
|
|
861
873
|
data(response, store.createImportedWork(input, originalFileName, extension.slice(1), parsedNovel), 201);
|
|
862
874
|
});
|
|
863
875
|
app.get("/api/works/:workId", (request, response) => {
|
|
876
|
+
if (request.query.directory === "volumes") {
|
|
877
|
+
data(response, store.getWorkVolumeDirectory(request.params.workId));
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
864
880
|
const pagination = parsePagination(request.query);
|
|
865
881
|
data(response, pagination ? store.getWorkDirectoryPage(request.params.workId, pagination) : store.getWorkDirectory(request.params.workId));
|
|
866
882
|
});
|
|
@@ -986,6 +1002,12 @@ export function createRuntime(options) {
|
|
|
986
1002
|
data(response, store.updateVolume(request.params.volumeId, volumeInput, expectedVersionNo, "manual", null, changeNote));
|
|
987
1003
|
});
|
|
988
1004
|
app.get("/api/volumes/:volumeId", (request, response) => data(response, store.getVolume(request.params.volumeId)));
|
|
1005
|
+
app.get("/api/volumes/:volumeId/chapters", (request, response) => {
|
|
1006
|
+
const pagination = parsePagination(request.query);
|
|
1007
|
+
data(response, pagination
|
|
1008
|
+
? store.listVolumeChaptersPage(request.params.volumeId, pagination)
|
|
1009
|
+
: store.listVolumeChapters(request.params.volumeId));
|
|
1010
|
+
});
|
|
989
1011
|
app.delete("/api/volumes/:volumeId", (request, response) => {
|
|
990
1012
|
const input = parse(z.object({ expectedVersionNo: expectedVersionNoSchema }).strict(), request.body ?? {});
|
|
991
1013
|
store.deleteVolume(request.params.volumeId, input.expectedVersionNo);
|
|
@@ -1124,6 +1146,33 @@ export function createRuntime(options) {
|
|
|
1124
1146
|
store.deleteForeshadowOccurrence(request.params.occurrenceId, input.expectedVersionNo);
|
|
1125
1147
|
noContent(response);
|
|
1126
1148
|
});
|
|
1149
|
+
app.get("/api/works/:workId/drafts", (request, response) => {
|
|
1150
|
+
const query = parse(z.object({
|
|
1151
|
+
draftType: z.enum(["prose", "setting"]).optional(),
|
|
1152
|
+
includeContent: z.enum(["true", "false"]).default("false")
|
|
1153
|
+
}), request.query);
|
|
1154
|
+
const pagination = parsePagination(request.query);
|
|
1155
|
+
const includeContent = query.includeContent === "true";
|
|
1156
|
+
data(response, pagination
|
|
1157
|
+
? store.listDraftsPage(request.params.workId, pagination, query.draftType, includeContent)
|
|
1158
|
+
: store.listDrafts(request.params.workId, query.draftType, includeContent));
|
|
1159
|
+
});
|
|
1160
|
+
app.post("/api/works/:workId/drafts", (request, response) => {
|
|
1161
|
+
data(response, store.createDraft(request.params.workId, parse(draftSchema, request.body)), 201);
|
|
1162
|
+
});
|
|
1163
|
+
app.get("/api/drafts/:draftId", (request, response) => data(response, store.getDraft(request.params.draftId)));
|
|
1164
|
+
app.patch("/api/drafts/:draftId", (request, response) => {
|
|
1165
|
+
const { changeNote, expectedVersionNo, ...input } = parse(draftSchema.partial().extend({
|
|
1166
|
+
changeNote: changeNoteSchema,
|
|
1167
|
+
expectedVersionNo: expectedVersionNoSchema
|
|
1168
|
+
}).strict(), request.body);
|
|
1169
|
+
data(response, store.updateDraft(request.params.draftId, input, "manual", null, changeNote, expectedVersionNo));
|
|
1170
|
+
});
|
|
1171
|
+
app.delete("/api/drafts/:draftId", (request, response) => {
|
|
1172
|
+
const input = parse(z.object({ expectedVersionNo: expectedVersionNoSchema }).strict(), request.body ?? {});
|
|
1173
|
+
store.deleteDraft(request.params.draftId, input.expectedVersionNo);
|
|
1174
|
+
noContent(response);
|
|
1175
|
+
});
|
|
1127
1176
|
app.get("/api/works/:workId/settings", (request, response) => {
|
|
1128
1177
|
const pagination = parsePagination(request.query);
|
|
1129
1178
|
const includeContent = request.query.includeContent === "true";
|
|
@@ -1652,6 +1701,7 @@ export function createRuntime(options) {
|
|
|
1652
1701
|
role: z.enum(["user", "assistant"]),
|
|
1653
1702
|
content: nonEmpty.max(200_000),
|
|
1654
1703
|
citations: z.array(z.unknown()).max(100).optional(),
|
|
1704
|
+
requestId: identifier.optional(),
|
|
1655
1705
|
metadata: z.object({
|
|
1656
1706
|
modelDisplayName: z.string().max(200).optional(),
|
|
1657
1707
|
outputTokens: z.number().int().min(0).max(10_000_000).optional(),
|
|
@@ -1817,6 +1867,7 @@ export function createRuntime(options) {
|
|
|
1817
1867
|
onProcessStep: (step) => sendEvent("process_step", step),
|
|
1818
1868
|
conversationId: input.conversationId,
|
|
1819
1869
|
excludeConversationMessageId: input.currentMessageId,
|
|
1870
|
+
...(input.currentMessageId ? { assistantMessageRequestId: `assistant:${input.currentMessageId}` } : {}),
|
|
1820
1871
|
...(input.modelId ? { modelId: input.modelId } : {}),
|
|
1821
1872
|
...(input.parameters ? { parameters: input.parameters } : {})
|
|
1822
1873
|
}, (delta) => sendEvent("delta", { delta }));
|
|
@@ -1829,7 +1880,13 @@ export function createRuntime(options) {
|
|
|
1829
1880
|
cacheHitPercent: suggestion.cacheHitPercent,
|
|
1830
1881
|
chapterVersion: suggestion.chapterVersion,
|
|
1831
1882
|
toolCalls: suggestion.toolCalls,
|
|
1832
|
-
processSteps: suggestion.processSteps
|
|
1883
|
+
processSteps: suggestion.processSteps,
|
|
1884
|
+
messageId: typeof suggestion.conversationMessage === "object" && suggestion.conversationMessage !== null
|
|
1885
|
+
? suggestion.conversationMessage.id
|
|
1886
|
+
: undefined,
|
|
1887
|
+
messageCreatedAt: typeof suggestion.conversationMessage === "object" && suggestion.conversationMessage !== null
|
|
1888
|
+
? suggestion.conversationMessage.createdAt
|
|
1889
|
+
: undefined
|
|
1833
1890
|
});
|
|
1834
1891
|
}
|
|
1835
1892
|
catch (error) {
|