@sns-parse/core 0.6.0-alpha.1 → 0.6.0-alpha.2
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/lib/engine/config.js +9 -0
- package/lib/engine/generic.d.ts +31 -0
- package/lib/engine/generic.js +13 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/workflow/default.js +3 -0
- package/lib/workflow/hooks.d.ts +6 -1
- package/package.json +1 -1
package/lib/engine/config.js
CHANGED
|
@@ -261,5 +261,14 @@ function engineConfigContributions() {
|
|
|
261
261
|
{ key: 'deduplicationTipText', type: 'string', default: '链接 ${url} 在最近 ${interval} 秒内已解析过,已跳过。', description: '重复解析提示,支持变量 ${url} ${interval}' },
|
|
262
262
|
],
|
|
263
263
|
}),
|
|
264
|
+
(0, config_1.defineConfig)({
|
|
265
|
+
group: '通用链接解析(预留)',
|
|
266
|
+
fields: [
|
|
267
|
+
{ key: 'genericParseEnabled', type: 'boolean', default: false, description: '对未命中平台声明的链接启用通用解析(预留:暂无实现,开启不生效)' },
|
|
268
|
+
{ key: 'genericLlmBaseUrl', type: 'string', default: '', description: 'LLM 接口 Base URL(OpenAI 兼容格式;预留字段,暂不消费)' },
|
|
269
|
+
{ key: 'genericLlmModel', type: 'string', default: '', description: 'LLM 模型名(预留字段,暂不消费)' },
|
|
270
|
+
{ key: 'genericLlmApiKey', type: 'string', default: '', role: 'secret', description: 'LLM API Key(预留字段,暂不消费)' },
|
|
271
|
+
],
|
|
272
|
+
}),
|
|
264
273
|
];
|
|
265
274
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用链接解析(预留,暂不实现):对未命中任何平台声明的链接的基础解析能力。
|
|
3
|
+
*
|
|
4
|
+
* 设计:
|
|
5
|
+
* - 经 'parse.generic' 工作流阶段调度(见 workflow/hooks.ts);
|
|
6
|
+
* - 基线实现 = 未实现(返回 null)——链路保持现状:非平台链接不进入解析流程;
|
|
7
|
+
* - 后续实现可由宿主或扩展 replace('parse.generic') 注入
|
|
8
|
+
* (OG 元信息抽取 / 页面结构化 / LLM 归纳,source 字段标注来源);
|
|
9
|
+
* - LLM 接口仅预留契约:engineConfigContributions() 的「通用链接解析(预留)」组
|
|
10
|
+
* 提供 baseUrl/model/apiKey 配置位,暂无消费方,开关默认关闭。
|
|
11
|
+
*/
|
|
12
|
+
export interface GenericLinkInput {
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
15
|
+
export interface GenericLinkResult {
|
|
16
|
+
title?: string;
|
|
17
|
+
desc?: string;
|
|
18
|
+
images: string[];
|
|
19
|
+
/** 解析来源:og=OG 元信息 / html=页面结构化 / llm=模型归纳 */
|
|
20
|
+
source?: 'og' | 'html' | 'llm';
|
|
21
|
+
}
|
|
22
|
+
/** LLM 增强预留接口(字段与「通用链接解析(预留)」配置组一一对应) */
|
|
23
|
+
export interface LlmOptions {
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
apiKey?: string;
|
|
26
|
+
model?: string;
|
|
27
|
+
}
|
|
28
|
+
/** 通用解析器实现契约(replace('parse.generic') 的注入形态) */
|
|
29
|
+
export interface GenericLinkParser {
|
|
30
|
+
parse(input: GenericLinkInput, rt: any): Promise<GenericLinkResult | null>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 通用链接解析(预留,暂不实现):对未命中任何平台声明的链接的基础解析能力。
|
|
4
|
+
*
|
|
5
|
+
* 设计:
|
|
6
|
+
* - 经 'parse.generic' 工作流阶段调度(见 workflow/hooks.ts);
|
|
7
|
+
* - 基线实现 = 未实现(返回 null)——链路保持现状:非平台链接不进入解析流程;
|
|
8
|
+
* - 后续实现可由宿主或扩展 replace('parse.generic') 注入
|
|
9
|
+
* (OG 元信息抽取 / 页面结构化 / LLM 归纳,source 字段标注来源);
|
|
10
|
+
* - LLM 接口仅预留契约:engineConfigContributions() 的「通用链接解析(预留)」组
|
|
11
|
+
* 提供 baseUrl/model/apiKey 配置位,暂无消费方,开关默认关闭。
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './engine/config';
|
|
|
21
21
|
export * from './engine/platform-config';
|
|
22
22
|
export * from './engine/translate';
|
|
23
23
|
export * from './engine/parser';
|
|
24
|
+
export * from './engine/generic';
|
|
24
25
|
export * from './engine/fetcher';
|
|
25
26
|
export * from './engine/compose';
|
|
26
27
|
export * from './engine/forward';
|
package/lib/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __exportStar(require("./engine/config"), exports);
|
|
|
37
37
|
__exportStar(require("./engine/platform-config"), exports);
|
|
38
38
|
__exportStar(require("./engine/translate"), exports);
|
|
39
39
|
__exportStar(require("./engine/parser"), exports);
|
|
40
|
+
__exportStar(require("./engine/generic"), exports);
|
|
40
41
|
__exportStar(require("./engine/fetcher"), exports);
|
|
41
42
|
__exportStar(require("./engine/compose"), exports);
|
|
42
43
|
__exportStar(require("./engine/forward"), exports);
|
package/lib/workflow/default.js
CHANGED
|
@@ -59,6 +59,9 @@ async function sendDispatch(rt, input) {
|
|
|
59
59
|
function createDefaultPipeline(rt) {
|
|
60
60
|
const p = new hooks_1.Pipeline(rt);
|
|
61
61
|
p.replace('parse', (input, r) => fetcher.fetchApi(r, input.url, input.type, input.fieldMapping, input.platformConf));
|
|
62
|
+
// 通用链接解析(预留):基线=未实现(null)——非平台链接不进入解析流程;
|
|
63
|
+
// 后续由宿主/扩展 replace 注入(OG/HTML/LLM,契约见 engine/generic.ts)
|
|
64
|
+
p.replace('parse.generic', async () => null);
|
|
62
65
|
p.replace('translate', async () => null);
|
|
63
66
|
p.replace('media.image', async (input) => ({ kind: 'raw', url: input.url }));
|
|
64
67
|
p.replace('media.video', async (input) => ({ kind: 'raw', url: input.videoUrl }));
|
package/lib/workflow/hooks.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ import type { ParsedData } from '../types';
|
|
|
13
13
|
import type { ImageOutcome, VideoOutcome, TranslateResult, GifOptions, MediaKind, VideoMeta } from '../extensions';
|
|
14
14
|
import type { ProcessedItem, MessageUnit } from '../engine/compose';
|
|
15
15
|
import type { OutboundSender, SessionLike } from '../sender';
|
|
16
|
-
|
|
16
|
+
import type { GenericLinkInput, GenericLinkResult } from '../engine/generic';
|
|
17
|
+
export type StageName = 'parse' | 'parse.generic' | 'translate' | 'media.image' | 'media.video' | 'media.merged' | 'merge' | 'transcode' | 'compose' | 'send';
|
|
17
18
|
export interface ParseInput {
|
|
18
19
|
url: string;
|
|
19
20
|
type: string;
|
|
@@ -67,6 +68,10 @@ export interface StageIO {
|
|
|
67
68
|
input: ParseInput;
|
|
68
69
|
output: ParsedData;
|
|
69
70
|
};
|
|
71
|
+
'parse.generic': {
|
|
72
|
+
input: GenericLinkInput;
|
|
73
|
+
output: GenericLinkResult | null;
|
|
74
|
+
};
|
|
70
75
|
translate: {
|
|
71
76
|
input: TranslateInput;
|
|
72
77
|
output: TranslateResult | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sns-parse/core",
|
|
3
|
-
"version": "0.6.0-alpha.
|
|
3
|
+
"version": "0.6.0-alpha.2+upstream.1.6.7",
|
|
4
4
|
"description": "sns-parse 核心:契约、宿主抽象、配置 DSL 与解析引擎(fetcher/parser/翻译/X 原生解析/合并/GIF/TLS 指纹客户端)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|