@musnows/scriverse 0.6.6 → 0.6.8
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.md +3 -1
- package/dist/ai-protocol.js +5 -1
- package/dist/ai-protocol.js.map +1 -1
- package/dist/ai.js +390 -27
- package/dist/ai.js.map +1 -1
- package/dist/app.js +25 -5
- package/dist/app.js.map +1 -1
- package/dist/database.js +43 -2
- package/dist/database.js.map +1 -1
- package/dist/public/app.js +275 -78
- package/dist/public/index.html +5 -3
- package/dist/public/model-config.d.ts +3 -0
- package/dist/public/model-config.js +8 -0
- package/dist/public/styles.css +42 -1
- package/dist/release-update.js +170 -0
- package/dist/release-update.js.map +1 -0
- package/dist/security.js +4 -3
- package/dist/security.js.map +1 -1
- package/dist/server-runtime.js +5 -1
- package/dist/server-runtime.js.map +1 -1
- package/dist/store.js +32 -6
- package/dist/store.js.map +1 -1
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/store.js
CHANGED
|
@@ -16,7 +16,8 @@ export const WORK_AGENT_TOOL_IDS = [
|
|
|
16
16
|
"grep",
|
|
17
17
|
"search_story_entities",
|
|
18
18
|
"read_character_sections",
|
|
19
|
-
"search_drafts"
|
|
19
|
+
"search_drafts",
|
|
20
|
+
"image"
|
|
20
21
|
];
|
|
21
22
|
const DEFAULT_WORK_AGENT_TOOLS = [...WORK_AGENT_TOOL_IDS];
|
|
22
23
|
export function normalizeWorkAgentTools(value) {
|
|
@@ -681,13 +682,20 @@ export class Store {
|
|
|
681
682
|
const row = this.db.get("SELECT * FROM platform_ai_settings WHERE id = 1");
|
|
682
683
|
return {
|
|
683
684
|
systemPrompt: String(row?.system_prompt ?? ""),
|
|
685
|
+
imageToolModelId: row?.image_tool_model_id === null || row?.image_tool_model_id === undefined
|
|
686
|
+
? null
|
|
687
|
+
: String(row.image_tool_model_id),
|
|
684
688
|
updatedAt: String(row?.updated_at ?? "")
|
|
685
689
|
};
|
|
686
690
|
}
|
|
687
691
|
updatePlatformAiSettings(input) {
|
|
688
692
|
const timestamp = now();
|
|
689
|
-
|
|
690
|
-
|
|
693
|
+
const current = this.getPlatformAiSettings();
|
|
694
|
+
this.db.run(`INSERT INTO platform_ai_settings (id, system_prompt, image_tool_model_id, updated_at) VALUES (1, ?, ?, ?)
|
|
695
|
+
ON CONFLICT(id) DO UPDATE SET system_prompt = excluded.system_prompt,
|
|
696
|
+
image_tool_model_id = excluded.image_tool_model_id, updated_at = excluded.updated_at`, input.systemPrompt ?? String(current.systemPrompt), input.imageToolModelId === undefined
|
|
697
|
+
? (current.imageToolModelId === null ? null : String(current.imageToolModelId))
|
|
698
|
+
: input.imageToolModelId, timestamp);
|
|
691
699
|
return this.getPlatformAiSettings();
|
|
692
700
|
}
|
|
693
701
|
getPlatformUiSettings() {
|
|
@@ -754,6 +762,9 @@ export class Store {
|
|
|
754
762
|
agentToolCallLimit: Math.min(48, Math.max(5, Number(row?.agent_tool_call_limit ?? 12) || 12)),
|
|
755
763
|
agentToolCallGlobalMultiplier: Math.min(6, Math.max(1, Number(row?.agent_tool_call_global_multiplier ?? 3) || 3)),
|
|
756
764
|
agentTools: normalizeWorkAgentTools(row?.agent_tools_json),
|
|
765
|
+
imageToolModelId: row?.image_tool_model_id === null || row?.image_tool_model_id === undefined
|
|
766
|
+
? null
|
|
767
|
+
: String(row.image_tool_model_id),
|
|
757
768
|
alwaysIncludeSettingInfo: Number(row?.always_include_setting_info ?? 0) === 1,
|
|
758
769
|
titleGenerationModelId: row?.title_generation_model_id === null || row?.title_generation_model_id === undefined
|
|
759
770
|
? null
|
|
@@ -779,6 +790,9 @@ export class Store {
|
|
|
779
790
|
const nextAgentToolCallLimit = input.agentToolCallLimit ?? Number(current.agentToolCallLimit);
|
|
780
791
|
const nextAgentToolCallGlobalMultiplier = input.agentToolCallGlobalMultiplier ?? Number(current.agentToolCallGlobalMultiplier);
|
|
781
792
|
const nextAgentTools = normalizeWorkAgentTools(input.agentTools ?? current.agentTools);
|
|
793
|
+
const nextImageToolModelId = input.imageToolModelId === undefined
|
|
794
|
+
? (current.imageToolModelId ? String(current.imageToolModelId) : null)
|
|
795
|
+
: input.imageToolModelId?.trim() || null;
|
|
782
796
|
const nextAlwaysIncludeSettingInfo = input.alwaysIncludeSettingInfo ?? Boolean(current.alwaysIncludeSettingInfo);
|
|
783
797
|
const nextTitleGenerationModelId = input.titleGenerationModelId === undefined
|
|
784
798
|
? (current.titleGenerationModelId ? String(current.titleGenerationModelId) : null)
|
|
@@ -788,8 +802,8 @@ export class Store {
|
|
|
788
802
|
auto_run_daily_task_limit, auto_run_failure_threshold, auto_run_paused, auto_run_pause_reason,
|
|
789
803
|
auto_run_resume_at, auto_run_consecutive_failures, book_summary_context_percent,
|
|
790
804
|
context_compact_threshold, agent_tool_call_limit, agent_tool_call_global_multiplier,
|
|
791
|
-
agent_tools_json, title_generation_model_id, always_include_setting_info, updated_at
|
|
792
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
805
|
+
agent_tools_json, title_generation_model_id, image_tool_model_id, always_include_setting_info, updated_at
|
|
806
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
793
807
|
ON CONFLICT(work_id) DO UPDATE SET
|
|
794
808
|
system_prompt = excluded.system_prompt,
|
|
795
809
|
daily_token_quota = excluded.daily_token_quota,
|
|
@@ -808,8 +822,9 @@ export class Store {
|
|
|
808
822
|
agent_tool_call_global_multiplier = excluded.agent_tool_call_global_multiplier,
|
|
809
823
|
agent_tools_json = excluded.agent_tools_json,
|
|
810
824
|
title_generation_model_id = excluded.title_generation_model_id,
|
|
825
|
+
image_tool_model_id = excluded.image_tool_model_id,
|
|
811
826
|
always_include_setting_info = excluded.always_include_setting_info,
|
|
812
|
-
updated_at = excluded.updated_at`, workId, nextPrompt, nextDailyTokenQuota, nextEnabled ? 1 : 0, Math.min(8, Math.max(1, nextConcurrency)), Math.min(200, Math.max(1, nextBatchLimit)), Math.min(10_000, Math.max(0, nextDailyTaskLimit)), Math.min(10, Math.max(1, nextFailureThreshold)), current.autoRunPaused ? 1 : 0, String(current.autoRunPauseReason ?? ""), current.autoRunResumeAt === null ? null : String(current.autoRunResumeAt), Math.max(0, Number(current.autoRunConsecutiveFailures) || 0), Math.min(90, Math.max(1, nextBookSummaryContextPercent)), Math.min(90, Math.max(50, nextContextCompactThreshold)), Math.min(48, Math.max(5, nextAgentToolCallLimit)), Math.min(6, Math.max(1, nextAgentToolCallGlobalMultiplier)), JSON.stringify(nextAgentTools), nextTitleGenerationModelId, nextAlwaysIncludeSettingInfo ? 1 : 0, timestamp);
|
|
827
|
+
updated_at = excluded.updated_at`, workId, nextPrompt, nextDailyTokenQuota, nextEnabled ? 1 : 0, Math.min(8, Math.max(1, nextConcurrency)), Math.min(200, Math.max(1, nextBatchLimit)), Math.min(10_000, Math.max(0, nextDailyTaskLimit)), Math.min(10, Math.max(1, nextFailureThreshold)), current.autoRunPaused ? 1 : 0, String(current.autoRunPauseReason ?? ""), current.autoRunResumeAt === null ? null : String(current.autoRunResumeAt), Math.max(0, Number(current.autoRunConsecutiveFailures) || 0), Math.min(90, Math.max(1, nextBookSummaryContextPercent)), Math.min(90, Math.max(50, nextContextCompactThreshold)), Math.min(48, Math.max(5, nextAgentToolCallLimit)), Math.min(6, Math.max(1, nextAgentToolCallGlobalMultiplier)), JSON.stringify(nextAgentTools), nextTitleGenerationModelId, nextImageToolModelId, nextAlwaysIncludeSettingInfo ? 1 : 0, timestamp);
|
|
813
828
|
this.audit(workId, "work.ai-settings.updated", "work-ai-settings", workId, {
|
|
814
829
|
systemPromptChanged: input.systemPrompt !== undefined,
|
|
815
830
|
dailyTokenQuota: nextDailyTokenQuota,
|
|
@@ -823,6 +838,7 @@ export class Store {
|
|
|
823
838
|
agentToolCallLimit: Math.min(48, Math.max(5, nextAgentToolCallLimit)),
|
|
824
839
|
agentToolCallGlobalMultiplier: Math.min(6, Math.max(1, nextAgentToolCallGlobalMultiplier)),
|
|
825
840
|
agentTools: nextAgentTools,
|
|
841
|
+
imageToolModelId: nextImageToolModelId,
|
|
826
842
|
alwaysIncludeSettingInfo: nextAlwaysIncludeSettingInfo,
|
|
827
843
|
titleGenerationModelId: nextTitleGenerationModelId
|
|
828
844
|
});
|
|
@@ -3425,6 +3441,16 @@ export class Store {
|
|
|
3425
3441
|
throw notFound("附件");
|
|
3426
3442
|
return this.mapAttachment(row);
|
|
3427
3443
|
}
|
|
3444
|
+
getSettingAttachment(workId, attachmentId) {
|
|
3445
|
+
const row = this.db.get(`SELECT attachment.*
|
|
3446
|
+
FROM attachments attachment
|
|
3447
|
+
JOIN attachment_references reference ON reference.attachment_id = attachment.id
|
|
3448
|
+
WHERE attachment.id = ? AND attachment.work_id = ? AND reference.work_id = ? AND reference.entity_type = 'setting'
|
|
3449
|
+
LIMIT 1`, attachmentId, workId, workId);
|
|
3450
|
+
if (!row)
|
|
3451
|
+
throw new AppError(404, "SETTING_IMAGE_ATTACHMENT_NOT_FOUND", "图片附件不存在或未被设定正文引用");
|
|
3452
|
+
return this.mapAttachment(row);
|
|
3453
|
+
}
|
|
3428
3454
|
attachmentModules(attachmentId) {
|
|
3429
3455
|
this.getAttachment(attachmentId);
|
|
3430
3456
|
const modules = new Set();
|