cortico 0.1.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/LICENSE +21 -0
- package/README.md +47 -0
- package/package.json +43 -0
- package/src/boot.ts +46 -0
- package/src/bot.ts +1342 -0
- package/src/config-file.ts +41 -0
- package/src/core/README.md +92 -0
- package/src/core/billing.ts +26 -0
- package/src/core/blobs.ts +106 -0
- package/src/core/bus.ts +311 -0
- package/src/core/config-schema.ts +201 -0
- package/src/core/config.ts +262 -0
- package/src/core/core.ts +699 -0
- package/src/core/cost.ts +244 -0
- package/src/core/event-store.ts +304 -0
- package/src/core/fork.ts +113 -0
- package/src/core/generation.ts +118 -0
- package/src/core/instance-lock.ts +215 -0
- package/src/core/ipc-logger.ts +105 -0
- package/src/core/language.ts +62 -0
- package/src/core/log-context.ts +38 -0
- package/src/core/loop.ts +1858 -0
- package/src/core/markers.ts +48 -0
- package/src/core/prefix.ts +121 -0
- package/src/core/run.ts +95 -0
- package/src/core/secrets.ts +18 -0
- package/src/core/session.ts +56 -0
- package/src/core/sessions.ts +261 -0
- package/src/core/state.ts +104 -0
- package/src/core/template.ts +72 -0
- package/src/core/timers.ts +129 -0
- package/src/core/tool-log.ts +135 -0
- package/src/core/transcript.ts +92 -0
- package/src/core/truncate.ts +121 -0
- package/src/core/types.ts +1140 -0
- package/src/core/usage-log.ts +79 -0
- package/src/core/util.ts +386 -0
- package/src/deploy-listing.ts +160 -0
- package/src/deploy.ts +162 -0
- package/src/extensions/README.md +72 -0
- package/src/extensions/dry-mount.ts +390 -0
- package/src/extensions/manifest.ts +153 -0
- package/src/extensions/runtime.ts +42 -0
- package/src/extensions.ts +519 -0
- package/src/launcher.ts +285 -0
- package/src/paths.ts +155 -0
- package/src/protocol/open-responses/LICENSE +201 -0
- package/src/protocol/open-responses/README.md +14 -0
- package/src/protocol/open-responses/context-helpers.ts +27 -0
- package/src/protocol/open-responses/context-log.ts +59 -0
- package/src/protocol/open-responses/context.ts +89 -0
- package/src/protocol/open-responses/generated.ts +115 -0
- package/src/protocol/open-responses/index.ts +33 -0
- package/src/protocol/open-responses/openapi.json +4230 -0
- package/src/protocol/open-responses/stream.ts +146 -0
- package/src/protocol/open-responses/tokens.ts +31 -0
- package/src/providers/README.md +86 -0
- package/src/providers/base.ts +111 -0
- package/src/providers/configuration.ts +97 -0
- package/src/providers/console/config.ts +21 -0
- package/src/providers/console/settings.ts +443 -0
- package/src/providers/console/strings.ts +74 -0
- package/src/providers/console/types.ts +11 -0
- package/src/providers/llamacpp/archive.ts +148 -0
- package/src/providers/llamacpp/catalog.ts +247 -0
- package/src/providers/llamacpp/config.ts +36 -0
- package/src/providers/llamacpp/console/client.ts +6 -0
- package/src/providers/llamacpp/console/models-panel.ts +120 -0
- package/src/providers/llamacpp/console/runtime-panel.ts +173 -0
- package/src/providers/llamacpp/console/server.ts +153 -0
- package/src/providers/llamacpp/index.ts +95 -0
- package/src/providers/llamacpp/native.ts +51 -0
- package/src/providers/llamacpp/options.ts +117 -0
- package/src/providers/llamacpp/runtime-store.ts +139 -0
- package/src/providers/llamacpp/runtime.ts +214 -0
- package/src/providers/llamacpp/server.ts +286 -0
- package/src/providers/llamacpp/strings.ts +230 -0
- package/src/providers/openai-responses-compat/config.ts +20 -0
- package/src/providers/openai-responses-compat/index.ts +89 -0
- package/src/providers/openai-responses-compat/native.ts +127 -0
- package/src/providers/openai-responses-compat/strings.ts +19 -0
- package/src/providers/pricebook.ts +75 -0
- package/src/providers/registry.ts +137 -0
- package/src/providers/strings.ts +71 -0
- package/src/providers/transport/chat.ts +156 -0
- package/src/providers/transport/errors.ts +48 -0
- package/src/providers/transport/history.ts +68 -0
- package/src/providers/transport/native-input.ts +83 -0
- package/src/providers/transport/native-types.ts +13 -0
- package/src/providers/transport/response-assembly.ts +191 -0
- package/src/providers/transport/response-http.ts +196 -0
- package/src/providers/transport/response-meters.ts +27 -0
- package/src/providers/transport/responses-input.ts +56 -0
- package/src/web/README.md +84 -0
- package/src/web/client/console-pages/builtins/llm-settings/panel.ts +625 -0
- package/src/web/client/console-pages/builtins/llm-settings/pricing-panel.ts +168 -0
- package/src/web/client/console-pages/builtins/llm-settings/strings.ts +213 -0
- package/src/web/client/console-pages/builtins.ts +10 -0
- package/src/web/client/console-pages/context.ts +135 -0
- package/src/web/client/console-pages/host.ts +633 -0
- package/src/web/client/console-pages/loader.ts +132 -0
- package/src/web/client/console-pages/strings.ts +90 -0
- package/src/web/client/console-pages/tools/strings.ts +49 -0
- package/src/web/client/console-pages/tools/view.ts +215 -0
- package/src/web/client/core/api.ts +200 -0
- package/src/web/client/core/language.ts +56 -0
- package/src/web/client/core/lifecycle.ts +132 -0
- package/src/web/client/core/router.ts +199 -0
- package/src/web/client/core/stream.ts +157 -0
- package/src/web/client/core/websocket.ts +82 -0
- package/src/web/client/features/appearance/index.ts +333 -0
- package/src/web/client/features/appearance/strings.ts +87 -0
- package/src/web/client/features/config/index.ts +11 -0
- package/src/web/client/features/config/strings.ts +41 -0
- package/src/web/client/features/config/view.ts +428 -0
- package/src/web/client/features/core/events.ts +197 -0
- package/src/web/client/features/core/index.ts +254 -0
- package/src/web/client/features/core/run.ts +56 -0
- package/src/web/client/features/core/runlog.ts +214 -0
- package/src/web/client/features/core/sessions.ts +53 -0
- package/src/web/client/features/core/strings.ts +157 -0
- package/src/web/client/features/extensions/index.ts +422 -0
- package/src/web/client/features/extensions/strings.ts +164 -0
- package/src/web/client/features/feature.ts +93 -0
- package/src/web/client/features/live/context.ts +280 -0
- package/src/web/client/features/live/fork.ts +156 -0
- package/src/web/client/features/live/index.ts +392 -0
- package/src/web/client/features/live/onboarding.ts +113 -0
- package/src/web/client/features/live/protocol.ts +122 -0
- package/src/web/client/features/live/sessions.ts +71 -0
- package/src/web/client/features/live/status.ts +68 -0
- package/src/web/client/features/live/strings.ts +252 -0
- package/src/web/client/features/live/timeline.ts +590 -0
- package/src/web/client/features/prompts/editor.ts +292 -0
- package/src/web/client/features/prompts/index.ts +346 -0
- package/src/web/client/features/prompts/strings.ts +136 -0
- package/src/web/client/features/prompts/view.ts +256 -0
- package/src/web/client/features/providers/index.ts +100 -0
- package/src/web/client/features/providers/strings.ts +23 -0
- package/src/web/client/features/settings/general.ts +28 -0
- package/src/web/client/features/settings/index.ts +82 -0
- package/src/web/client/features/settings/strings.ts +33 -0
- package/src/web/client/features/storage/index.ts +1 -0
- package/src/web/client/features/storage/strings.ts +45 -0
- package/src/web/client/features/storage/view.ts +154 -0
- package/src/web/client/features/usage/chart.ts +486 -0
- package/src/web/client/features/usage/index.ts +407 -0
- package/src/web/client/features/usage/labels.ts +46 -0
- package/src/web/client/features/usage/range.ts +36 -0
- package/src/web/client/features/usage/state.ts +37 -0
- package/src/web/client/features/usage/strings.ts +191 -0
- package/src/web/client/features/usage/tooltip.ts +86 -0
- package/src/web/client/features/usage/types.ts +96 -0
- package/src/web/client/features/worlds/index.ts +424 -0
- package/src/web/client/features/worlds/strings.ts +121 -0
- package/src/web/client/main.ts +273 -0
- package/src/web/client/shell/avatar.ts +233 -0
- package/src/web/client/shell/index.ts +549 -0
- package/src/web/client/shell/strings.ts +89 -0
- package/src/web/client/theme/handoff.ts +43 -0
- package/src/web/client/theme/palette.ts +109 -0
- package/src/web/client/theme/registry.ts +130 -0
- package/src/web/client/theme/storage.ts +72 -0
- package/src/web/client/theme/strings.ts +123 -0
- package/src/web/client/theme/studio.ts +366 -0
- package/src/web/client/ui/actions.ts +109 -0
- package/src/web/client/ui/data.ts +185 -0
- package/src/web/client/ui/dom.ts +23 -0
- package/src/web/client/ui/fields.ts +191 -0
- package/src/web/client/ui/format.ts +75 -0
- package/src/web/client/ui/icons.ts +183 -0
- package/src/web/client/ui/images.ts +91 -0
- package/src/web/client/ui/index.ts +89 -0
- package/src/web/client/ui/lamp.ts +125 -0
- package/src/web/client/ui/log.ts +98 -0
- package/src/web/client/ui/overlay.ts +184 -0
- package/src/web/client/ui/page.ts +8 -0
- package/src/web/client/ui/prompt-input.tsx +311 -0
- package/src/web/client/ui/sheet.ts +131 -0
- package/src/web/client/ui/strings.ts +71 -0
- package/src/web/console-pages.ts +367 -0
- package/src/web/files.ts +107 -0
- package/src/web/path-picker.ts +296 -0
- package/src/web/public/index.html +17 -0
- package/src/web/public/styles.css +1715 -0
- package/src/web/server.ts +1883 -0
- package/src/web/shared/client-panel.ts +603 -0
- package/src/web/shared/console-protocol.ts +560 -0
- package/src/web/shared/css.d.ts +1 -0
- package/src/web/shared/path-picker.ts +23 -0
- package/src/web/shared/theme.ts +256 -0
- package/src/web/theme-store.ts +37 -0
- package/src/world.ts +449 -0
- package/src/worlds/bilibili/ENV_PROMPT.md +5 -0
- package/src/worlds/bilibili/README.md +176 -0
- package/src/worlds/bilibili/audience-admission.ts +995 -0
- package/src/worlds/bilibili/client.ts +528 -0
- package/src/worlds/bilibili/coalescing-buffer.ts +125 -0
- package/src/worlds/bilibili/config.ts +185 -0
- package/src/worlds/bilibili/console/client.ts +202 -0
- package/src/worlds/bilibili/definition.ts +35 -0
- package/src/worlds/bilibili/gift-frame.ts +131 -0
- package/src/worlds/bilibili/normalize.ts +452 -0
- package/src/worlds/bilibili/overlay/announcement.ts +76 -0
- package/src/worlds/bilibili/overlay/assets.ts +82 -0
- package/src/worlds/bilibili/overlay/model.ts +494 -0
- package/src/worlds/bilibili/overlay/project.ts +202 -0
- package/src/worlds/bilibili/overlay/server.ts +286 -0
- package/src/worlds/bilibili/overlay/types.ts +217 -0
- package/src/worlds/bilibili/overlay/web/app.js +690 -0
- package/src/worlds/bilibili/overlay/web/editor.css +297 -0
- package/src/worlds/bilibili/overlay/web/editor.html +102 -0
- package/src/worlds/bilibili/overlay/web/editor.js +2116 -0
- package/src/worlds/bilibili/overlay/web/overlay.html +13 -0
- package/src/worlds/bilibili/overlay/web/styles.css +258 -0
- package/src/worlds/bilibili/protobuf.ts +123 -0
- package/src/worlds/bilibili/wire.ts +94 -0
- package/src/worlds/bilibili/world.ts +1389 -0
- package/src/worlds/console-fixture/ENV_PROMPT.md +1 -0
- package/src/worlds/console-fixture/console/client.ts +72 -0
- package/src/worlds/console-fixture/world.ts +73 -0
- package/src/worlds/index.ts +15 -0
- package/src/worlds/minecraft/ENV_PROMPT.md +32 -0
- package/src/worlds/minecraft/ENV_PROMPT_CAMERA.md +2 -0
- package/src/worlds/minecraft/LICENSE-mineflayer-pathfinder.txt +21 -0
- package/src/worlds/minecraft/README.md +917 -0
- package/src/worlds/minecraft/blueprint-plan.ts +915 -0
- package/src/worlds/minecraft/blueprint-registry.ts +566 -0
- package/src/worlds/minecraft/blueprint-repair.ts +236 -0
- package/src/worlds/minecraft/blueprint-resource.ts +272 -0
- package/src/worlds/minecraft/blueprint.ts +492 -0
- package/src/worlds/minecraft/body-lease.ts +340 -0
- package/src/worlds/minecraft/bridge.ts +749 -0
- package/src/worlds/minecraft/check.ts +651 -0
- package/src/worlds/minecraft/chests.ts +292 -0
- package/src/worlds/minecraft/client-launch.ts +272 -0
- package/src/worlds/minecraft/client-options.ts +85 -0
- package/src/worlds/minecraft/client-skins.ts +164 -0
- package/src/worlds/minecraft/client-window.ps1 +91 -0
- package/src/worlds/minecraft/client.ts +423 -0
- package/src/worlds/minecraft/combat-context.ts +109 -0
- package/src/worlds/minecraft/combat.ts +1552 -0
- package/src/worlds/minecraft/config.ts +499 -0
- package/src/worlds/minecraft/console/access.ts +218 -0
- package/src/worlds/minecraft/console/client.ts +244 -0
- package/src/worlds/minecraft/console/log.ts +110 -0
- package/src/worlds/minecraft/console/mount.ts +420 -0
- package/src/worlds/minecraft/console/skin.ts +257 -0
- package/src/worlds/minecraft/console/style.css +154 -0
- package/src/worlds/minecraft/console/world.ts +449 -0
- package/src/worlds/minecraft/deaths.ts +135 -0
- package/src/worlds/minecraft/definition.ts +18 -0
- package/src/worlds/minecraft/engine-child.ts +274 -0
- package/src/worlds/minecraft/engine-ipc.ts +98 -0
- package/src/worlds/minecraft/entity-facts.ts +132 -0
- package/src/worlds/minecraft/escape.ts +407 -0
- package/src/worlds/minecraft/executor.ts +14494 -0
- package/src/worlds/minecraft/explored.ts +156 -0
- package/src/worlds/minecraft/geometry.ts +205 -0
- package/src/worlds/minecraft/goal-plan.ts +647 -0
- package/src/worlds/minecraft/item-break.ts +126 -0
- package/src/worlds/minecraft/item-facts.ts +146 -0
- package/src/worlds/minecraft/item-pick.ts +67 -0
- package/src/worlds/minecraft/level-dat.ts +176 -0
- package/src/worlds/minecraft/log.ts +132 -0
- package/src/worlds/minecraft/mineflayer-fixes.ts +1180 -0
- package/src/worlds/minecraft/names.ts +377 -0
- package/src/worlds/minecraft/pathfinder-lib.d.ts +13 -0
- package/src/worlds/minecraft/pathfinder-perf.ts +796 -0
- package/src/worlds/minecraft/piglin.ts +49 -0
- package/src/worlds/minecraft/policy.ts +547 -0
- package/src/worlds/minecraft/precheck.ts +655 -0
- package/src/worlds/minecraft/proxy.ts +445 -0
- package/src/worlds/minecraft/ranged.ts +635 -0
- package/src/worlds/minecraft/readouts.ts +102 -0
- package/src/worlds/minecraft/round.ts +26 -0
- package/src/worlds/minecraft/search-observation.ts +92 -0
- package/src/worlds/minecraft/server-config.ts +467 -0
- package/src/worlds/minecraft/server.ts +658 -0
- package/src/worlds/minecraft/show.ts +84 -0
- package/src/worlds/minecraft/skills.ts +1763 -0
- package/src/worlds/minecraft/terrain.ts +1735 -0
- package/src/worlds/minecraft/window.ts +96 -0
- package/src/worlds/minecraft/works.ts +179 -0
- package/src/worlds/minecraft/world.ts +6438 -0
- package/src/worlds/qq/ENV_PROMPT.md +5 -0
- package/src/worlds/qq/config.ts +108 -0
- package/src/worlds/qq/console/client.ts +126 -0
- package/src/worlds/qq/console/events.ts +155 -0
- package/src/worlds/qq/console/gate.ts +232 -0
- package/src/worlds/qq/console/roster.ts +203 -0
- package/src/worlds/qq/console/style.css +65 -0
- package/src/worlds/qq/conversation.ts +28 -0
- package/src/worlds/qq/definition.ts +62 -0
- package/src/worlds/qq/driver.ts +375 -0
- package/src/worlds/qq/history-tools.ts +209 -0
- package/src/worlds/qq/normalize.ts +323 -0
- package/src/worlds/qq/qface-map.ts +282 -0
- package/src/worlds/qq/vision-prompt.ts +27 -0
- package/src/worlds/qq/vision.ts +642 -0
- package/src/worlds/qq/vlm.ts +142 -0
- package/src/worlds/qq/world.ts +1503 -0
- package/src/worlds/terminal/ENV_PROMPT.md +11 -0
- package/src/worlds/terminal/config.ts +9 -0
- package/src/worlds/terminal/definition.ts +14 -0
- package/src/worlds/terminal/world.ts +700 -0
- package/src/worlds/websearch/ENV_PROMPT.md +1 -0
- package/src/worlds/websearch/brave-client.ts +261 -0
- package/src/worlds/websearch/config.ts +75 -0
- package/src/worlds/websearch/definition.ts +20 -0
- package/src/worlds/websearch/world.ts +171 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QQ群消息归一化:OneBot segment数组 ⇄ agent的纯文本世界。
|
|
3
|
+
* 全部纯函数,便于单测。
|
|
4
|
+
*
|
|
5
|
+
* 入站:segment数组渲染成一行可读文本(谁、几点、@了谁、回复了哪条)。
|
|
6
|
+
* 出站:agent的纯文本(+可选引用游标)编译回segment数组。
|
|
7
|
+
* 出站不编译“@某人”为 at 段;agent 写出的 @ 文本按普通文本发送。
|
|
8
|
+
*/
|
|
9
|
+
import { shortTime } from '../../core/util.ts';
|
|
10
|
+
import { QFACE_NAMES } from './qface-map.ts';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/** OneBot消息段:{type, data} */
|
|
14
|
+
export interface Segment {
|
|
15
|
+
type: string;
|
|
16
|
+
data: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** OneBot v11 群消息事件(只列归一化用到的字段) */
|
|
20
|
+
export interface OneBotGroupMessage {
|
|
21
|
+
post_type: string;
|
|
22
|
+
message_type?: string;
|
|
23
|
+
group_id?: number;
|
|
24
|
+
user_id: number;
|
|
25
|
+
message_id: number;
|
|
26
|
+
/** unix秒 */
|
|
27
|
+
time?: number;
|
|
28
|
+
sender?: { nickname?: string; card?: string };
|
|
29
|
+
message: Segment[];
|
|
30
|
+
raw_message?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/** JSON 卡片的通用字段;字段缺失时调用方渲染 `[json]`。 */
|
|
35
|
+
interface JsonCardInfo {
|
|
36
|
+
/** 腾讯协议提供的卡片回退文本,如 "[分享]标题"。 */
|
|
37
|
+
prompt?: string;
|
|
38
|
+
/** 封面图URL,取自meta.<动态key>.preview(key名随卡片类型而变,故只取meta下第一个) */
|
|
39
|
+
previewUrl?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 解析 JSON 卡片的通用 prompt 与 meta.*.preview 字段。
|
|
44
|
+
* 解析失败或字段缺失时返回空对象,调用方渲染 `[json]`。
|
|
45
|
+
*/
|
|
46
|
+
export function parseJsonCard(data: Record<string, unknown>): JsonCardInfo {
|
|
47
|
+
const raw = data.data;
|
|
48
|
+
if (typeof raw !== 'string' || !raw) return {};
|
|
49
|
+
let parsed: unknown;
|
|
50
|
+
try {
|
|
51
|
+
parsed = JSON.parse(raw);
|
|
52
|
+
} catch {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
if (!parsed || typeof parsed !== 'object') return {};
|
|
56
|
+
const obj = parsed as Record<string, unknown>;
|
|
57
|
+
const prompt = typeof obj.prompt === 'string' && obj.prompt ? obj.prompt : undefined;
|
|
58
|
+
|
|
59
|
+
let previewUrl: string | undefined;
|
|
60
|
+
const meta = obj.meta;
|
|
61
|
+
if (meta && typeof meta === 'object') {
|
|
62
|
+
for (const v of Object.values(meta as Record<string, unknown>)) {
|
|
63
|
+
if (v && typeof v === 'object') {
|
|
64
|
+
const preview = (v as Record<string, unknown>).preview;
|
|
65
|
+
if (typeof preview === 'string' && preview) {
|
|
66
|
+
previewUrl = preview.startsWith('//') ? `https:${preview}` : preview;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { prompt, previewUrl };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** json段的文本渲染策略:输入解析出的卡片信息,输出正文里的占位文本 */
|
|
76
|
+
export type JsonCardRenderPolicy = (info: JsonCardInfo) => string;
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/** 图片segment的渲染策略函数:输入segment.data,输出占位文本 */
|
|
80
|
+
export type ImageRenderPolicy = (data: Record<string, unknown>) => string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 生成图片渲染策略:
|
|
84
|
+
* - 取不到图 → 降级 `[图片]`
|
|
85
|
+
* - 主模型支持图像或 World 配置了视觉模型 → 带 URL 标记,供后续管线取图
|
|
86
|
+
* 主模型能力通过 host.modelFacts 查询; World 自带视觉不进入 core 契约。
|
|
87
|
+
*/
|
|
88
|
+
export function makeImagePolicy(canUseImages: boolean): ImageRenderPolicy {
|
|
89
|
+
if (canUseImages) {
|
|
90
|
+
return (data) => {
|
|
91
|
+
const url =
|
|
92
|
+
typeof data.url === 'string' && data.url
|
|
93
|
+
? data.url
|
|
94
|
+
: typeof data.file === 'string'
|
|
95
|
+
? data.file
|
|
96
|
+
: '';
|
|
97
|
+
return url ? `[图片 ${url}]` : '[图片]';
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return () => '[图片]';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
export interface RenderContext {
|
|
105
|
+
/** bot自己的QQ号 */
|
|
106
|
+
selfId: number;
|
|
107
|
+
/** bot 自己在本会话的显示名(群=该群 card;私聊=nickname),渲染 "@<名>(你)" 用 */
|
|
108
|
+
selfName: string;
|
|
109
|
+
timezone: string;
|
|
110
|
+
/**
|
|
111
|
+
* 会话标签,拼进 `[<label> HH:MM]` 前缀以标明消息来自哪个会话。
|
|
112
|
+
* 群 = `群「群名」`;私聊 = `私聊`(1:1,发言人由后面的显示名承载)。
|
|
113
|
+
*/
|
|
114
|
+
convLabel: string;
|
|
115
|
+
/**
|
|
116
|
+
* 这条平台 message_id 是否已被记录(QQ 消息身份即平台自身 message_id)。
|
|
117
|
+
* 查不到时,对应的引用回复走异步取原文。
|
|
118
|
+
*/
|
|
119
|
+
knowsMessage: (messageId: number | string) => boolean;
|
|
120
|
+
/** 已知称呼解析(可选):@别人时尝试用称呼替代QQ号 */
|
|
121
|
+
nameOf?: (qq: string) => string | undefined;
|
|
122
|
+
/** 图片渲染策略(能力协商产物);缺省=降级`[图片]` */
|
|
123
|
+
renderImage?: ImageRenderPolicy;
|
|
124
|
+
/** json卡片渲染策略(封面图接入外挂视觉用);缺省=只显示prompt文本,无封面图占位 */
|
|
125
|
+
renderJsonCard?: JsonCardRenderPolicy;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface RenderedIncoming {
|
|
129
|
+
/** 例: `#842485102 [群「茶话会」 21:32] 阿明(12345): 在吗` */
|
|
130
|
+
text: string;
|
|
131
|
+
/** 消息里@了bot自己(→urgent立即投递) */
|
|
132
|
+
mentionedSelf: boolean;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** 一个渲染片段:token(记号类,如@xx/[图片])与原样文本在拼接时空格规则不同 */
|
|
136
|
+
interface Part {
|
|
137
|
+
text: string;
|
|
138
|
+
isToken: boolean;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** 拼接片段:token与相邻片段之间保证有一个空格分隔;text-text直接相连 */
|
|
142
|
+
function joinParts(parts: Part[]): string {
|
|
143
|
+
let out = '';
|
|
144
|
+
let prevToken = false;
|
|
145
|
+
for (const p of parts) {
|
|
146
|
+
if (!p.text) continue;
|
|
147
|
+
if (
|
|
148
|
+
out.length > 0 &&
|
|
149
|
+
(prevToken || p.isToken) &&
|
|
150
|
+
!out.endsWith(' ') &&
|
|
151
|
+
!p.text.startsWith(' ')
|
|
152
|
+
) {
|
|
153
|
+
out += ' ';
|
|
154
|
+
}
|
|
155
|
+
out += p.text;
|
|
156
|
+
prevToken = p.isToken;
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 为缺少 RenderContext 的独立消息生成可读正文。
|
|
163
|
+
* 结果不带发言人或时间,不解析 @ 名称,也不输出图片 URL。
|
|
164
|
+
*/
|
|
165
|
+
export function renderSegmentsPlain(segments: Segment[]): string {
|
|
166
|
+
const parts: Part[] = [];
|
|
167
|
+
for (const seg of segments ?? []) {
|
|
168
|
+
const data = seg.data ?? {};
|
|
169
|
+
switch (seg.type) {
|
|
170
|
+
case 'text':
|
|
171
|
+
parts.push({ text: String(data.text ?? ''), isToken: false });
|
|
172
|
+
break;
|
|
173
|
+
case 'at': {
|
|
174
|
+
const qq = String(data.qq ?? '');
|
|
175
|
+
parts.push({ text: qq === 'all' ? '@全体成员' : `@${qq}`, isToken: true });
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case 'image':
|
|
179
|
+
parts.push({ text: '[图片]', isToken: true });
|
|
180
|
+
break;
|
|
181
|
+
case 'face': {
|
|
182
|
+
const name = QFACE_NAMES[String(data.id ?? '')];
|
|
183
|
+
parts.push({ text: name ? `[表情:${name}]` : '[QQ表情]', isToken: true });
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case 'reply':
|
|
187
|
+
parts.push({ text: '[回复某条消息]', isToken: true });
|
|
188
|
+
break;
|
|
189
|
+
case 'forward':
|
|
190
|
+
parts.push({ text: '[转发消息]', isToken: true });
|
|
191
|
+
break;
|
|
192
|
+
case 'node':
|
|
193
|
+
parts.push({ text: '[嵌套转发消息]', isToken: true });
|
|
194
|
+
break;
|
|
195
|
+
case 'json': {
|
|
196
|
+
const { prompt } = parseJsonCard(data);
|
|
197
|
+
parts.push({ text: prompt ? `[分享:${prompt}]` : '[json]', isToken: true });
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
default:
|
|
201
|
+
parts.push({ text: `[${seg.type}]`, isToken: true });
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return joinParts(parts);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 群消息 → `[HH:MM] 显示名(QQ号): 正文` + 是否@自己。
|
|
210
|
+
* 显示名 = sender.card || sender.nickname || QQ号。昵称和群昵称不能作为身份依据,
|
|
211
|
+
* 消息来源的QQ号(私聊来源/群消息发言人来源同理)始终随行以防身份混淆。
|
|
212
|
+
*/
|
|
213
|
+
export function renderIncoming(
|
|
214
|
+
msg: OneBotGroupMessage,
|
|
215
|
+
ctx: RenderContext,
|
|
216
|
+
): RenderedIncoming {
|
|
217
|
+
const renderImage = ctx.renderImage ?? (() => '[图片]');
|
|
218
|
+
let mentionedSelf = false;
|
|
219
|
+
const parts: Part[] = [];
|
|
220
|
+
|
|
221
|
+
for (const seg of msg.message ?? []) {
|
|
222
|
+
const data = seg.data ?? {};
|
|
223
|
+
switch (seg.type) {
|
|
224
|
+
case 'text': {
|
|
225
|
+
parts.push({ text: String(data.text ?? ''), isToken: false });
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'at': {
|
|
229
|
+
const qq = String(data.qq ?? '');
|
|
230
|
+
if (qq === String(ctx.selfId)) {
|
|
231
|
+
mentionedSelf = true;
|
|
232
|
+
parts.push({ text: `@${ctx.selfName}(你)`, isToken: true });
|
|
233
|
+
} else if (qq === 'all') {
|
|
234
|
+
// @全体成员不是对 bot 的定向提及,不触发 urgent。
|
|
235
|
+
parts.push({ text: '@全体成员', isToken: true });
|
|
236
|
+
} else {
|
|
237
|
+
const name = ctx.nameOf?.(qq);
|
|
238
|
+
parts.push({ text: `@${name ?? qq}`, isToken: true });
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
case 'reply': {
|
|
243
|
+
const mid = String(data.id ?? '');
|
|
244
|
+
parts.push({
|
|
245
|
+
text: ctx.knowsMessage(mid)
|
|
246
|
+
? `[回复#${mid}]`
|
|
247
|
+
: '[回复某条未被记录的消息,原文正在查询中...]',
|
|
248
|
+
isToken: true,
|
|
249
|
+
});
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
case 'image': {
|
|
253
|
+
parts.push({ text: renderImage(data), isToken: true });
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
case 'face': {
|
|
257
|
+
const name = QFACE_NAMES[String(data.id ?? '')];
|
|
258
|
+
parts.push({ text: name ? `[表情:${name}]` : '[QQ表情]', isToken: true });
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case 'forward': {
|
|
262
|
+
parts.push({ text: '[转发的聊天记录,正在展开中...]', isToken: true });
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case 'json': {
|
|
266
|
+
const info = parseJsonCard(data);
|
|
267
|
+
const rendered = ctx.renderJsonCard
|
|
268
|
+
? ctx.renderJsonCard(info)
|
|
269
|
+
: info.prompt
|
|
270
|
+
? `[分享:${info.prompt}]`
|
|
271
|
+
: '[json]';
|
|
272
|
+
parts.push({ text: rendered, isToken: true });
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
default: {
|
|
276
|
+
// 未知segment类型:保留类型名占位,不丢信息也不崩
|
|
277
|
+
parts.push({ text: `[${seg.type}]`, isToken: true });
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const displayName =
|
|
284
|
+
msg.sender?.card || msg.sender?.nickname || String(msg.user_id);
|
|
285
|
+
const when =
|
|
286
|
+
typeof msg.time === 'number' ? new Date(msg.time * 1000) : new Date();
|
|
287
|
+
const body = joinParts(parts);
|
|
288
|
+
// 行首的 `#<message_id>` 是这条消息在 QQ 上的真身份:引用回复哪条,就把这个
|
|
289
|
+
// 号回传给 draft(reply_to)。它由 World 渲染(平台自己的 ID),不是 core 的存储位置。
|
|
290
|
+
const idTag = msg.message_id !== undefined ? `#${msg.message_id} ` : '';
|
|
291
|
+
return {
|
|
292
|
+
text: `${idTag}[${ctx.convLabel} ${shortTime(ctx.timezone, when)}] ${displayName}(${msg.user_id}): ${body}`,
|
|
293
|
+
mentionedSelf,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
interface OutgoingArgs {
|
|
299
|
+
text: string;
|
|
300
|
+
/** 引用回复的平台 message_id(draft(reply_to) 收到的就是这个号) */
|
|
301
|
+
reply_to_message_id?: number | string;
|
|
302
|
+
/** 图片base64(不含data:前缀);有则编译成image段(OneBot base64://) */
|
|
303
|
+
image_base64?: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* 出站 → segment数组:reply段(如有)在前,然后image段(如有),最后text段
|
|
308
|
+
* (text非空才加——支持只发图不带字)。
|
|
309
|
+
* 不做 @ 编译:agent 写出的“@某人”作为纯文本原样发出。
|
|
310
|
+
*/
|
|
311
|
+
export function buildOutgoing(args: OutgoingArgs): Segment[] {
|
|
312
|
+
const segments: Segment[] = [];
|
|
313
|
+
if (args.reply_to_message_id !== undefined) {
|
|
314
|
+
segments.push({ type: 'reply', data: { id: String(args.reply_to_message_id) } });
|
|
315
|
+
}
|
|
316
|
+
if (args.image_base64) {
|
|
317
|
+
segments.push({ type: 'image', data: { file: `base64://${args.image_base64}` } });
|
|
318
|
+
}
|
|
319
|
+
if (args.text) {
|
|
320
|
+
segments.push({ type: 'text', data: { text: args.text } });
|
|
321
|
+
}
|
|
322
|
+
return segments;
|
|
323
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QQ face segment ID → 中文名称的协议兼容表。
|
|
3
|
+
* 编号与短名称对应 NapCat `face_config.json` 里的 `QSid`/`QDes`;不含图像或运行代码。
|
|
4
|
+
* 未覆盖的自定义或新增表情由调用方渲染为通用占位。
|
|
5
|
+
*/
|
|
6
|
+
export const QFACE_NAMES: Record<string, string> = {
|
|
7
|
+
"0": "惊讶",
|
|
8
|
+
"1": "撇嘴",
|
|
9
|
+
"2": "色",
|
|
10
|
+
"3": "发呆",
|
|
11
|
+
"4": "得意",
|
|
12
|
+
"5": "流泪",
|
|
13
|
+
"6": "害羞",
|
|
14
|
+
"7": "闭嘴",
|
|
15
|
+
"8": "睡",
|
|
16
|
+
"9": "大哭",
|
|
17
|
+
"10": "尴尬",
|
|
18
|
+
"11": "发怒",
|
|
19
|
+
"12": "调皮",
|
|
20
|
+
"13": "呲牙",
|
|
21
|
+
"14": "微笑",
|
|
22
|
+
"15": "难过",
|
|
23
|
+
"16": "酷",
|
|
24
|
+
"18": "抓狂",
|
|
25
|
+
"19": "吐",
|
|
26
|
+
"20": "偷笑",
|
|
27
|
+
"21": "可爱",
|
|
28
|
+
"22": "白眼",
|
|
29
|
+
"23": "傲慢",
|
|
30
|
+
"24": "饥饿",
|
|
31
|
+
"25": "困",
|
|
32
|
+
"26": "惊恐",
|
|
33
|
+
"27": "流汗",
|
|
34
|
+
"28": "憨笑",
|
|
35
|
+
"29": "悠闲",
|
|
36
|
+
"30": "奋斗",
|
|
37
|
+
"31": "咒骂",
|
|
38
|
+
"32": "疑问",
|
|
39
|
+
"33": "嘘",
|
|
40
|
+
"34": "晕",
|
|
41
|
+
"35": "折磨",
|
|
42
|
+
"36": "衰",
|
|
43
|
+
"37": "骷髅",
|
|
44
|
+
"38": "敲打",
|
|
45
|
+
"39": "再见",
|
|
46
|
+
"41": "发抖",
|
|
47
|
+
"42": "爱情",
|
|
48
|
+
"43": "跳跳",
|
|
49
|
+
"46": "猪头",
|
|
50
|
+
"49": "拥抱",
|
|
51
|
+
"53": "蛋糕",
|
|
52
|
+
"54": "闪电",
|
|
53
|
+
"55": "炸弹",
|
|
54
|
+
"56": "刀",
|
|
55
|
+
"57": "足球",
|
|
56
|
+
"59": "便便",
|
|
57
|
+
"60": "咖啡",
|
|
58
|
+
"61": "饭",
|
|
59
|
+
"63": "玫瑰",
|
|
60
|
+
"64": "凋谢",
|
|
61
|
+
"66": "爱心",
|
|
62
|
+
"67": "心碎",
|
|
63
|
+
"69": "礼物",
|
|
64
|
+
"74": "太阳",
|
|
65
|
+
"75": "月亮",
|
|
66
|
+
"76": "赞",
|
|
67
|
+
"77": "踩",
|
|
68
|
+
"78": "握手",
|
|
69
|
+
"79": "胜利",
|
|
70
|
+
"85": "飞吻",
|
|
71
|
+
"86": "怄火",
|
|
72
|
+
"89": "西瓜",
|
|
73
|
+
"96": "冷汗",
|
|
74
|
+
"97": "擦汗",
|
|
75
|
+
"98": "抠鼻",
|
|
76
|
+
"99": "鼓掌",
|
|
77
|
+
"100": "糗大了",
|
|
78
|
+
"101": "坏笑",
|
|
79
|
+
"102": "左哼哼",
|
|
80
|
+
"103": "右哼哼",
|
|
81
|
+
"104": "哈欠",
|
|
82
|
+
"105": "鄙视",
|
|
83
|
+
"106": "委屈",
|
|
84
|
+
"107": "快哭了",
|
|
85
|
+
"108": "阴险",
|
|
86
|
+
"109": "左亲亲",
|
|
87
|
+
"110": "吓",
|
|
88
|
+
"111": "可怜",
|
|
89
|
+
"112": "菜刀",
|
|
90
|
+
"113": "啤酒",
|
|
91
|
+
"114": "篮球",
|
|
92
|
+
"115": "乒乓",
|
|
93
|
+
"116": "示爱",
|
|
94
|
+
"117": "瓢虫",
|
|
95
|
+
"118": "抱拳",
|
|
96
|
+
"119": "勾引",
|
|
97
|
+
"120": "拳头",
|
|
98
|
+
"121": "差劲",
|
|
99
|
+
"122": "爱你",
|
|
100
|
+
"123": "NO",
|
|
101
|
+
"124": "OK",
|
|
102
|
+
"125": "转圈",
|
|
103
|
+
"126": "磕头",
|
|
104
|
+
"127": "回头",
|
|
105
|
+
"128": "跳绳",
|
|
106
|
+
"129": "挥手",
|
|
107
|
+
"130": "激动",
|
|
108
|
+
"131": "街舞",
|
|
109
|
+
"132": "献吻",
|
|
110
|
+
"133": "左太极",
|
|
111
|
+
"134": "右太极",
|
|
112
|
+
"136": "双喜",
|
|
113
|
+
"137": "鞭炮",
|
|
114
|
+
"138": "灯笼",
|
|
115
|
+
"140": "K歌",
|
|
116
|
+
"144": "喝彩",
|
|
117
|
+
"145": "祈祷",
|
|
118
|
+
"146": "爆筋",
|
|
119
|
+
"147": "棒棒糖",
|
|
120
|
+
"148": "喝奶",
|
|
121
|
+
"151": "飞机",
|
|
122
|
+
"158": "钞票",
|
|
123
|
+
"168": "药",
|
|
124
|
+
"169": "手枪",
|
|
125
|
+
"171": "茶",
|
|
126
|
+
"172": "眨眼睛",
|
|
127
|
+
"173": "泪奔",
|
|
128
|
+
"174": "无奈",
|
|
129
|
+
"175": "卖萌",
|
|
130
|
+
"176": "小纠结",
|
|
131
|
+
"177": "喷血",
|
|
132
|
+
"178": "斜眼笑",
|
|
133
|
+
"179": "doge",
|
|
134
|
+
"180": "惊喜",
|
|
135
|
+
"181": "骚扰",
|
|
136
|
+
"182": "笑哭",
|
|
137
|
+
"183": "我最美",
|
|
138
|
+
"184": "河蟹",
|
|
139
|
+
"185": "羊驼",
|
|
140
|
+
"187": "幽灵",
|
|
141
|
+
"188": "蛋",
|
|
142
|
+
"190": "菊花",
|
|
143
|
+
"192": "红包",
|
|
144
|
+
"193": "大笑",
|
|
145
|
+
"194": "不开心",
|
|
146
|
+
"197": "冷漠",
|
|
147
|
+
"198": "呃",
|
|
148
|
+
"199": "好棒",
|
|
149
|
+
"200": "拜托",
|
|
150
|
+
"201": "点赞",
|
|
151
|
+
"202": "无聊",
|
|
152
|
+
"203": "托脸",
|
|
153
|
+
"204": "吃",
|
|
154
|
+
"205": "送花",
|
|
155
|
+
"206": "害怕",
|
|
156
|
+
"207": "花痴",
|
|
157
|
+
"208": "小样儿",
|
|
158
|
+
"210": "飙泪",
|
|
159
|
+
"211": "我不看",
|
|
160
|
+
"212": "托腮",
|
|
161
|
+
"214": "啵啵",
|
|
162
|
+
"215": "糊脸",
|
|
163
|
+
"216": "拍头",
|
|
164
|
+
"217": "扯一扯",
|
|
165
|
+
"218": "舔一舔",
|
|
166
|
+
"219": "蹭一蹭",
|
|
167
|
+
"220": "拽炸天",
|
|
168
|
+
"221": "顶呱呱",
|
|
169
|
+
"222": "抱抱",
|
|
170
|
+
"223": "暴击",
|
|
171
|
+
"224": "开枪",
|
|
172
|
+
"225": "撩一撩",
|
|
173
|
+
"226": "拍桌",
|
|
174
|
+
"227": "拍手",
|
|
175
|
+
"228": "恭喜",
|
|
176
|
+
"229": "干杯",
|
|
177
|
+
"230": "嘲讽",
|
|
178
|
+
"231": "哼",
|
|
179
|
+
"232": "佛系",
|
|
180
|
+
"233": "掐一掐",
|
|
181
|
+
"234": "惊呆",
|
|
182
|
+
"235": "颤抖",
|
|
183
|
+
"236": "啃头",
|
|
184
|
+
"237": "偷看",
|
|
185
|
+
"238": "扇脸",
|
|
186
|
+
"239": "原谅",
|
|
187
|
+
"240": "喷脸",
|
|
188
|
+
"241": "生日快乐",
|
|
189
|
+
"242": "头撞击",
|
|
190
|
+
"243": "甩头",
|
|
191
|
+
"244": "扔狗",
|
|
192
|
+
"245": "加油必胜",
|
|
193
|
+
"246": "加油抱抱",
|
|
194
|
+
"247": "口罩护体",
|
|
195
|
+
"260": "搬砖中",
|
|
196
|
+
"261": "忙到飞起",
|
|
197
|
+
"262": "脑阔疼",
|
|
198
|
+
"263": "沧桑",
|
|
199
|
+
"264": "捂脸",
|
|
200
|
+
"265": "辣眼睛",
|
|
201
|
+
"266": "哦哟",
|
|
202
|
+
"267": "头秃",
|
|
203
|
+
"268": "问号脸",
|
|
204
|
+
"269": "暗中观察",
|
|
205
|
+
"270": "emm",
|
|
206
|
+
"271": "吃瓜",
|
|
207
|
+
"272": "呵呵哒",
|
|
208
|
+
"273": "我酸了",
|
|
209
|
+
"274": "太南了",
|
|
210
|
+
"276": "辣椒酱",
|
|
211
|
+
"277": "汪汪",
|
|
212
|
+
"278": "汗",
|
|
213
|
+
"279": "打脸",
|
|
214
|
+
"280": "击掌",
|
|
215
|
+
"281": "无眼笑",
|
|
216
|
+
"282": "敬礼",
|
|
217
|
+
"283": "狂笑",
|
|
218
|
+
"284": "面无表情",
|
|
219
|
+
"285": "摸鱼",
|
|
220
|
+
"286": "魔鬼笑",
|
|
221
|
+
"287": "哦",
|
|
222
|
+
"288": "请",
|
|
223
|
+
"289": "睁眼",
|
|
224
|
+
"290": "敲开心",
|
|
225
|
+
"291": "震惊",
|
|
226
|
+
"292": "让我康康",
|
|
227
|
+
"293": "摸锦鲤",
|
|
228
|
+
"294": "期待",
|
|
229
|
+
"295": "拿到红包",
|
|
230
|
+
"296": "真好",
|
|
231
|
+
"297": "拜谢",
|
|
232
|
+
"298": "元宝",
|
|
233
|
+
"299": "牛啊",
|
|
234
|
+
"300": "胖三斤",
|
|
235
|
+
"301": "好闪",
|
|
236
|
+
"302": "左拜年",
|
|
237
|
+
"303": "右拜年",
|
|
238
|
+
"304": "红包包",
|
|
239
|
+
"305": "右亲亲",
|
|
240
|
+
"306": "牛气冲天",
|
|
241
|
+
"307": "喵喵",
|
|
242
|
+
"308": "求红包",
|
|
243
|
+
"309": "谢红包",
|
|
244
|
+
"310": "新年烟花",
|
|
245
|
+
"311": "打call",
|
|
246
|
+
"312": "变形",
|
|
247
|
+
"313": "嗑到了",
|
|
248
|
+
"314": "仔细分析",
|
|
249
|
+
"315": "加油",
|
|
250
|
+
"316": "我没事",
|
|
251
|
+
"317": "菜狗",
|
|
252
|
+
"318": "崇拜",
|
|
253
|
+
"319": "比心",
|
|
254
|
+
"320": "庆祝",
|
|
255
|
+
"321": "老色痞",
|
|
256
|
+
"322": "拒绝",
|
|
257
|
+
"323": "嫌弃",
|
|
258
|
+
"324": "吃糖",
|
|
259
|
+
"325": "惊吓",
|
|
260
|
+
"326": "生气",
|
|
261
|
+
"327": "加一",
|
|
262
|
+
"328": "错号",
|
|
263
|
+
"329": "对号",
|
|
264
|
+
"330": "完成",
|
|
265
|
+
"331": "明白",
|
|
266
|
+
"332": "举牌牌",
|
|
267
|
+
"333": "烟花",
|
|
268
|
+
"334": "虎虎生威",
|
|
269
|
+
"336": "豹富",
|
|
270
|
+
"337": "花朵脸",
|
|
271
|
+
"338": "我想开了",
|
|
272
|
+
"339": "舔屏",
|
|
273
|
+
"340": "热化了",
|
|
274
|
+
"341": "打招呼",
|
|
275
|
+
"342": "酸Q",
|
|
276
|
+
"343": "我方了",
|
|
277
|
+
"344": "大怨种",
|
|
278
|
+
"345": "红包多多",
|
|
279
|
+
"346": "你真棒棒",
|
|
280
|
+
"347": "大展宏兔",
|
|
281
|
+
"348": "福萝卜",
|
|
282
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 被动识图的默认任务文本。它与配置加载逻辑分开维护,config.json 仍可覆盖。
|
|
3
|
+
*/
|
|
4
|
+
export const VISION_DEFAULT_PROMPT = `准确分析、精简描述图片内容,按以下结构输出:
|
|
5
|
+
|
|
6
|
+
## 分类
|
|
7
|
+
判断图片属于照片、表情包、屏幕截图或其他类型。
|
|
8
|
+
|
|
9
|
+
## 视觉事实
|
|
10
|
+
只描述画面中能够直接看见并确认的对象、文字、数量、位置、颜色、环境和动作。
|
|
11
|
+
不要加入原因、用途、身份、品牌背景或其他推断。
|
|
12
|
+
|
|
13
|
+
## 文字
|
|
14
|
+
提取画面中清晰可辨认的文字。
|
|
15
|
+
看不清的文字不要猜测,用“部分文字模糊无法辨认”说明。
|
|
16
|
+
|
|
17
|
+
## 视觉确定推测
|
|
18
|
+
仅允许根据清晰视觉线索作出高置信度判断,并明确标注为推测。
|
|
19
|
+
|
|
20
|
+
## 视觉延伸推测
|
|
21
|
+
描述由画面情境引出的合理但无法直接确认的推测,并明确标注依据。
|
|
22
|
+
|
|
23
|
+
## 视觉不可辨认项
|
|
24
|
+
只列出“画面中确实存在或疑似存在,但仅因视觉条件而无法看清、分辨或判断”的内容。
|
|
25
|
+
|
|
26
|
+
## 一句话描述
|
|
27
|
+
只包含确定性事实`;
|