@musnows/scriverse 0.5.12 → 0.6.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/ai-protocol.js +6 -1
- package/dist/ai-protocol.js.map +1 -1
- package/dist/ai.js +336 -21
- package/dist/ai.js.map +1 -1
- package/dist/app.js +14 -4
- package/dist/app.js.map +1 -1
- package/dist/database.js +17 -0
- package/dist/database.js.map +1 -1
- package/dist/public/ai-context-meter.js +32 -0
- package/dist/public/app.js +180 -38
- package/dist/public/index.html +7 -3
- package/dist/public/styles.css +45 -6
- package/dist/store.js +40 -7
- package/dist/store.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -293,8 +293,7 @@ const providerSchema = z.object({
|
|
|
293
293
|
status: z.enum(["enabled", "disabled"]).optional(),
|
|
294
294
|
note: z.string().max(10_000).optional(),
|
|
295
295
|
concurrencyLimit: z.number().int().min(1).max(100).optional(),
|
|
296
|
-
rpmLimit: z.number().int().min(1).max(10_000).optional()
|
|
297
|
-
maxTokens: z.number().int().min(1).max(32_768).optional()
|
|
296
|
+
rpmLimit: z.number().int().min(1).max(10_000).optional()
|
|
298
297
|
});
|
|
299
298
|
const modelSchema = z.object({
|
|
300
299
|
displayName: nonEmpty.max(200),
|
|
@@ -373,7 +372,8 @@ const workAiSettingsSchema = z.object({
|
|
|
373
372
|
autoRunFailureThreshold: z.number().int().min(1).max(10).optional(),
|
|
374
373
|
bookSummaryContextPercent: z.number().int().min(1).max(90).optional(),
|
|
375
374
|
contextCompactThreshold: z.number().int().min(50).max(90).optional(),
|
|
376
|
-
agentTools: z.array(z.enum(["story_index", "read_chapters", "grep", "search_story_entities", "read_character_sections", "search_drafts"])).max(6).optional()
|
|
375
|
+
agentTools: z.array(z.enum(["story_index", "read_chapters", "grep", "search_story_entities", "read_character_sections", "search_drafts"])).max(6).optional(),
|
|
376
|
+
titleGenerationModelId: z.string().trim().max(200).optional()
|
|
377
377
|
}).strict();
|
|
378
378
|
const contextSchema = z.object({
|
|
379
379
|
type: z.enum(["none", "selection", "chapter", "volume", "book", "entities"]),
|
|
@@ -1670,6 +1670,8 @@ export function createRuntime(options) {
|
|
|
1670
1670
|
app.patch("/api/works/:workId/ai-settings", (request, response) => {
|
|
1671
1671
|
const workId = request.params.workId;
|
|
1672
1672
|
const input = parse(workAiSettingsSchema, request.body);
|
|
1673
|
+
if (input.titleGenerationModelId)
|
|
1674
|
+
ai.assertModelAvailable(input.titleGenerationModelId);
|
|
1673
1675
|
const before = store.getWorkAiSettings(workId);
|
|
1674
1676
|
let updated = store.updateWorkAiSettings(workId, input);
|
|
1675
1677
|
if (updated.autoRunEnabled) {
|
|
@@ -1779,6 +1781,7 @@ export function createRuntime(options) {
|
|
|
1779
1781
|
data(response, pagination ? ai.listModelsPage(request.params.providerId, pagination) : ai.listModels(request.params.providerId));
|
|
1780
1782
|
});
|
|
1781
1783
|
app.post("/api/providers/:providerId/models", (request, response) => data(response, ai.createModel(request.params.providerId, parse(modelSchema, request.body)), 201));
|
|
1784
|
+
app.post("/api/models/:modelId/test", async (request, response) => data(response, await ai.testModel(request.params.modelId)));
|
|
1782
1785
|
app.get("/api/models/:modelId", (request, response) => data(response, ai.getModel(request.params.modelId)));
|
|
1783
1786
|
app.patch("/api/models/:modelId", (request, response) => data(response, ai.updateModel(request.params.modelId, parse(modelSchema.partial(), request.body))));
|
|
1784
1787
|
app.delete("/api/models/:modelId", (request, response) => {
|
|
@@ -1881,6 +1884,7 @@ export function createRuntime(options) {
|
|
|
1881
1884
|
chapterVersion: suggestion.chapterVersion,
|
|
1882
1885
|
toolCalls: suggestion.toolCalls,
|
|
1883
1886
|
processSteps: suggestion.processSteps,
|
|
1887
|
+
conversationTitle: suggestion.conversationTitle,
|
|
1884
1888
|
messageId: typeof suggestion.conversationMessage === "object" && suggestion.conversationMessage !== null
|
|
1885
1889
|
? suggestion.conversationMessage.id
|
|
1886
1890
|
: undefined,
|
|
@@ -1891,9 +1895,15 @@ export function createRuntime(options) {
|
|
|
1891
1895
|
}
|
|
1892
1896
|
catch (error) {
|
|
1893
1897
|
if (!controller.signal.aborted) {
|
|
1898
|
+
const details = error instanceof AppError && error.details && typeof error.details === "object" && !Array.isArray(error.details)
|
|
1899
|
+
? error.details
|
|
1900
|
+
: null;
|
|
1894
1901
|
sendEvent("error", {
|
|
1895
1902
|
code: error instanceof AppError ? error.code : "AI_STREAM_FAILED",
|
|
1896
|
-
message: error instanceof Error ? error.message : "AI 流式调用失败"
|
|
1903
|
+
message: error instanceof Error ? error.message : "AI 流式调用失败",
|
|
1904
|
+
...(error instanceof AppError ? { status: error.status } : {}),
|
|
1905
|
+
...(typeof details?.failure === "string" ? { failure: details.failure } : {}),
|
|
1906
|
+
...(typeof details?.callId === "string" ? { callId: details.callId } : {})
|
|
1897
1907
|
});
|
|
1898
1908
|
}
|
|
1899
1909
|
}
|