@musnows/scriverse 1.1.1 → 1.1.3
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/README.en.md +3 -0
- package/README.md +3 -0
- package/dist/ai-response-limit.js +12 -0
- package/dist/ai-response-limit.js.map +1 -0
- package/dist/ai.js +41 -17
- package/dist/ai.js.map +1 -1
- package/dist/app.js +24 -1
- package/dist/app.js.map +1 -1
- package/dist/public/app.js +40 -4
- package/dist/public/index.html +2 -1
- package/dist/public/mobile-app-runtime.js +662 -0
- package/dist/public/mobile-app.css +19 -0
- package/dist/public/mobile-offline-api.js +196 -0
- package/dist/public/mobile-service-worker.js +82 -0
- package/dist/public/mobile-sync-client.js +292 -0
- package/dist/public/mobile-sync-store.js +1004 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -14,6 +14,7 @@ import { AI_PROVIDER_PROTOCOL_OPTIONS, AI_PROVIDER_PROTOCOLS, AI_THINKING_TYPES,
|
|
|
14
14
|
import { MAX_AI_ANALYSIS_TIMEOUT_SECONDS, MIN_AI_ANALYSIS_TIMEOUT_SECONDS } from "./ai-analysis-timeout.js";
|
|
15
15
|
import { aiConversationExportContentDisposition, exportAiConversationMarkdown } from "./ai-conversation-export.js";
|
|
16
16
|
import { DEFAULT_AI_CHAT_TAB_LIMIT } from "./ai-chat-tab-limit.js";
|
|
17
|
+
import { resolveAiResponseMaxBytes } from "./ai-response-limit.js";
|
|
17
18
|
import { DEFAULT_CHAPTER_ANNOTATION_NOTE_MAX_LENGTH } from "./chapter-annotation-note.js";
|
|
18
19
|
import { MAX_AI_STREAM_IDLE_TIMEOUT_SECONDS, MIN_AI_STREAM_IDLE_TIMEOUT_SECONDS, normalizeAiStreamIdleTimeoutSeconds } from "./ai-stream-timeout.js";
|
|
19
20
|
import { AttachmentStorage } from "./attachment-storage.js";
|
|
@@ -760,7 +761,7 @@ const desktopLocalAiRunSchema = z.object({
|
|
|
760
761
|
const desktopLocalAiCompletionResponseSchema = z.object({
|
|
761
762
|
requestId: identifier,
|
|
762
763
|
status: z.number().int().min(100).max(599),
|
|
763
|
-
body: z.string()
|
|
764
|
+
body: z.string(),
|
|
764
765
|
retryAfter: z.string().max(500).optional()
|
|
765
766
|
}).strict();
|
|
766
767
|
/** 创建任务 API 的分析类型校验:仅允许可新建类型,历史类型在运行层保留防御性拒绝。 */
|
|
@@ -1520,6 +1521,14 @@ export function createRuntime(options) {
|
|
|
1520
1521
|
if (options.security?.enforceSameOrigin ?? true)
|
|
1521
1522
|
app.use(createSameOriginMiddleware());
|
|
1522
1523
|
app.use("/api/sync/works", express.json({ limit: "3mb" }));
|
|
1524
|
+
app.use("/api/works/:workId/desktop-local-ai/runs/:runId/responses", (request, response, next) => {
|
|
1525
|
+
const maximumResponseBytes = resolveAiResponseMaxBytes();
|
|
1526
|
+
// 外层 JSON 会转义响应文本;最终仍按响应字符串的 UTF-8 字节数校验。
|
|
1527
|
+
const requestBodyLimit = maximumResponseBytes === null
|
|
1528
|
+
? Number.MAX_SAFE_INTEGER
|
|
1529
|
+
: Math.min(Number.MAX_SAFE_INTEGER, maximumResponseBytes * 6 + 4_096);
|
|
1530
|
+
express.json({ limit: requestBodyLimit })(request, response, next);
|
|
1531
|
+
});
|
|
1523
1532
|
app.use(express.json({ limit: "2mb" }));
|
|
1524
1533
|
const registrationMode = resolveRegistrationMode(options.security);
|
|
1525
1534
|
const registrationEnabled = isRegistrationEnabled(registrationMode);
|
|
@@ -3475,6 +3484,19 @@ export function createRuntime(options) {
|
|
|
3475
3484
|
const permissions = requestPermissions(request, String(conversation.workId));
|
|
3476
3485
|
data(response, redactAiConversation(conversation, permissions));
|
|
3477
3486
|
});
|
|
3487
|
+
app.get("/api/ai-conversations/:conversationId/title", async (request, response) => {
|
|
3488
|
+
const conversationId = request.params.conversationId;
|
|
3489
|
+
const current = store.getAiConversationSummary(conversationId);
|
|
3490
|
+
requestPermissions(request, String(current.workId));
|
|
3491
|
+
await ai.waitForConversationTitle(conversationId);
|
|
3492
|
+
const updated = store.getAiConversationSummary(conversationId);
|
|
3493
|
+
requestPermissions(request, String(updated.workId));
|
|
3494
|
+
data(response, {
|
|
3495
|
+
id: updated.id,
|
|
3496
|
+
title: updated.title,
|
|
3497
|
+
updatedAt: updated.updatedAt
|
|
3498
|
+
});
|
|
3499
|
+
});
|
|
3478
3500
|
app.get("/api/ai-conversations/:conversationId/export", (request, response) => {
|
|
3479
3501
|
const conversation = store.getAiConversation(request.params.conversationId);
|
|
3480
3502
|
const permissions = requestPermissions(request, String(conversation.workId));
|
|
@@ -4248,6 +4270,7 @@ export function createRuntime(options) {
|
|
|
4248
4270
|
contextUsage: result.contextUsage,
|
|
4249
4271
|
conversationId,
|
|
4250
4272
|
conversationTitle: result.conversationTitle,
|
|
4273
|
+
conversationTitleGenerationStarted: result.conversationTitleGenerationStarted,
|
|
4251
4274
|
messageId: typeof result.conversationMessage === "object" && result.conversationMessage !== null
|
|
4252
4275
|
? result.conversationMessage.id
|
|
4253
4276
|
: undefined,
|