@musnows/scriverse 0.9.6 → 0.9.7
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 +11 -9
- package/dist/ai.js.map +1 -1
- package/dist/app.js +5 -5
- package/dist/app.js.map +1 -1
- package/dist/public/ai-skill-menu.js +42 -0
- package/dist/public/ai-usage.d.ts +5 -2
- package/dist/public/ai-usage.js +50 -37
- package/dist/public/app.js +97 -25
- package/dist/public/index.html +3 -3
- package/dist/public/styles.css +28 -3
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/ai.js
CHANGED
|
@@ -24,7 +24,7 @@ import { composeRoleplayCurrentUserTurn, formatRoleplayScenePinText, roleplayUse
|
|
|
24
24
|
import { recallRoleplayMemoryArgumentsSchema, rememberRoleplayArgumentsSchema, renderRoleplayMemoriesForPrompt } from "./roleplay-memory.js";
|
|
25
25
|
import { canReadWorkModule } from "./work-permissions.js";
|
|
26
26
|
import { DEFAULT_SEMANTIC_CHUNK_MAXIMUM_CHARACTERS, SEMANTIC_CHUNK_RULE_VERSION, SEMANTIC_SOURCE_TYPES, fuseSemanticSearchResults, parseEmbeddingResponse, parseRerankCompletion, rankSemanticVectors, semanticConfigurationFingerprint, splitSemanticDocument } from "./semantic-search.js";
|
|
27
|
-
import { buildWritingCalendar, buildWritingMonthCalendar, formatServerLocalClock, resolveServerTimeZone } from "./writing-progress-time.js";
|
|
27
|
+
import { buildWritingCalendar, buildWritingMonthCalendar, formatServerLocalClock, resolveServerTimeZone, writingDateKey } from "./writing-progress-time.js";
|
|
28
28
|
import { RELATIONSHIP_SEARCH_POLICY_VERSION, RelationshipApproximateMatchLimitError, findApproximateNameMatchesChunked, ftsPhrase, isRelationshipPhoneticReference, normalizeRelationshipSearchText, relationshipCharacterTokenText, relationshipCharacterTokens, relationshipPinyinFtsQuery, relationshipPinyinSearchTokens, relationshipPinyinSequenceMatches, relationshipPinyinTokenText, relationshipPinyinTokens } from "./relationship-search.js";
|
|
29
29
|
import { clamp, id, json, maskSecret, now } from "./utils.js";
|
|
30
30
|
import { z } from "zod";
|
|
@@ -2398,13 +2398,13 @@ export class AiManager {
|
|
|
2398
2398
|
interactiveStreamIdleTimeoutMs: this.interactiveStreamIdleTimeoutMs
|
|
2399
2399
|
});
|
|
2400
2400
|
}
|
|
2401
|
-
getPlatformTokenUsage(
|
|
2402
|
-
return this.getTokenUsage(null,
|
|
2401
|
+
getPlatformTokenUsage() {
|
|
2402
|
+
return this.getTokenUsage(null, true);
|
|
2403
2403
|
}
|
|
2404
|
-
getWorkTokenUsage(workId
|
|
2404
|
+
getWorkTokenUsage(workId) {
|
|
2405
2405
|
this.store.getWork(workId);
|
|
2406
2406
|
return {
|
|
2407
|
-
...this.getTokenUsage(workId,
|
|
2407
|
+
...this.getTokenUsage(workId, false),
|
|
2408
2408
|
quota: this.getWorkTokenQuotaStatus(workId)
|
|
2409
2409
|
};
|
|
2410
2410
|
}
|
|
@@ -2910,10 +2910,11 @@ export class AiManager {
|
|
|
2910
2910
|
}
|
|
2911
2911
|
return details;
|
|
2912
2912
|
}
|
|
2913
|
-
getTokenUsage(workId,
|
|
2913
|
+
getTokenUsage(workId, includeWorks) {
|
|
2914
2914
|
const scopeSql = workId === null ? "" : " AND call.work_id = ?";
|
|
2915
2915
|
const scopeParams = workId === null ? [] : [workId];
|
|
2916
2916
|
const usageFilter = "(call.input_tokens > 0 OR call.output_tokens > 0)";
|
|
2917
|
+
const timezone = resolveServerTimeZone();
|
|
2917
2918
|
const summary = this.store.db.get(`SELECT
|
|
2918
2919
|
COALESCE(SUM(call.input_tokens), 0) AS input_tokens,
|
|
2919
2920
|
COALESCE(SUM(call.output_tokens), 0) AS output_tokens,
|
|
@@ -2928,7 +2929,7 @@ export class AiManager {
|
|
|
2928
2929
|
JOIN works work ON work.id = call.work_id
|
|
2929
2930
|
WHERE COALESCE(work.is_internal, 0) = 0 AND ${usageFilter}${scopeSql}`, ...scopeParams) ?? {};
|
|
2930
2931
|
const daily = this.store.db.all(`SELECT
|
|
2931
|
-
date(call.created_at,
|
|
2932
|
+
date(call.created_at, 'localtime') AS usage_date,
|
|
2932
2933
|
COALESCE(SUM(call.input_tokens), 0) AS input_tokens,
|
|
2933
2934
|
COALESCE(SUM(call.output_tokens), 0) AS output_tokens,
|
|
2934
2935
|
COALESCE(SUM(call.cached_input_tokens), 0) AS cached_input_tokens,
|
|
@@ -2940,7 +2941,7 @@ export class AiManager {
|
|
|
2940
2941
|
JOIN works work ON work.id = call.work_id
|
|
2941
2942
|
WHERE COALESCE(work.is_internal, 0) = 0 AND ${usageFilter}${scopeSql}
|
|
2942
2943
|
GROUP BY usage_date
|
|
2943
|
-
ORDER BY usage_date`,
|
|
2944
|
+
ORDER BY usage_date`, ...scopeParams).map((row) => this.mapTokenUsageRow(row, { date: stringValue(row, "usage_date") }));
|
|
2944
2945
|
const modelRows = this.store.db.all(`SELECT
|
|
2945
2946
|
COALESCE(model.model_id, call.model_id, '未指定模型') AS usage_model_id,
|
|
2946
2947
|
COALESCE(SUM(call.input_tokens), 0) AS input_tokens,
|
|
@@ -3020,7 +3021,8 @@ export class AiManager {
|
|
|
3020
3021
|
callTypes,
|
|
3021
3022
|
daily,
|
|
3022
3023
|
...(works ? { works } : {}),
|
|
3023
|
-
|
|
3024
|
+
timezone,
|
|
3025
|
+
serverDate: writingDateKey(new Date(), timezone)
|
|
3024
3026
|
};
|
|
3025
3027
|
}
|
|
3026
3028
|
mapTokenUsageRow(row, extra) {
|