@openclaw-china/shared 0.1.25 → 0.1.26

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.
@@ -1,51 +1,51 @@
1
- /**
2
- * 通用日志工具
3
- *
4
- * 提供分级日志功能:
5
- * - info: 关键业务日志(默认显示)
6
- * - debug: 调试日志(带 [DEBUG] 标记)
7
- * - error: 错误日志
8
- * - warn: 警告日志
9
- */
10
-
11
- export type LogLevel = "debug" | "info" | "warn" | "error";
12
-
13
- export interface Logger {
14
- debug: (msg: string) => void;
15
- info: (msg: string) => void;
16
- warn: (msg: string) => void;
17
- error: (msg: string) => void;
18
- }
19
-
20
- export interface LoggerOptions {
21
- log?: (msg: string) => void;
22
- error?: (msg: string) => void;
23
- }
24
-
25
- /**
26
- * 创建带前缀的日志器
27
- *
28
- * @param prefix 日志前缀(如 "dingtalk", "feishu")
29
- * @param opts 可选的日志输出函数
30
- * @returns Logger 实例
31
- *
32
- * @example
33
- * ```ts
34
- * const logger = createLogger("dingtalk");
35
- * logger.debug("connecting..."); // [dingtalk] [DEBUG] connecting...
36
- * logger.info("connected"); // [dingtalk] connected
37
- * logger.warn("slow response"); // [dingtalk] [WARN] slow response
38
- * logger.error("failed"); // [dingtalk] [ERROR] failed
39
- * ```
40
- */
41
- export function createLogger(prefix: string, opts?: LoggerOptions): Logger {
42
- const logFn = opts?.log ?? console.log;
43
- const errorFn = opts?.error ?? console.error;
44
-
45
- return {
46
- debug: (msg: string) => logFn(`[${prefix}] [DEBUG] ${msg}`),
47
- info: (msg: string) => logFn(`[${prefix}] ${msg}`),
48
- warn: (msg: string) => logFn(`[${prefix}] [WARN] ${msg}`),
49
- error: (msg: string) => errorFn(`[${prefix}] [ERROR] ${msg}`),
50
- };
51
- }
1
+ /**
2
+ * 通用日志工具
3
+ *
4
+ * 提供分级日志功能:
5
+ * - info: 关键业务日志(默认显示)
6
+ * - debug: 调试日志(带 [DEBUG] 标记)
7
+ * - error: 错误日志
8
+ * - warn: 警告日志
9
+ */
10
+
11
+ export type LogLevel = "debug" | "info" | "warn" | "error";
12
+
13
+ export interface Logger {
14
+ debug: (msg: string) => void;
15
+ info: (msg: string) => void;
16
+ warn: (msg: string) => void;
17
+ error: (msg: string) => void;
18
+ }
19
+
20
+ export interface LoggerOptions {
21
+ log?: (msg: string) => void;
22
+ error?: (msg: string) => void;
23
+ }
24
+
25
+ /**
26
+ * 创建带前缀的日志器
27
+ *
28
+ * @param prefix 日志前缀(如 "dingtalk", "feishu")
29
+ * @param opts 可选的日志输出函数
30
+ * @returns Logger 实例
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const logger = createLogger("dingtalk");
35
+ * logger.debug("connecting..."); // [dingtalk] [DEBUG] connecting...
36
+ * logger.info("connected"); // [dingtalk] connected
37
+ * logger.warn("slow response"); // [dingtalk] [WARN] slow response
38
+ * logger.error("failed"); // [dingtalk] [ERROR] failed
39
+ * ```
40
+ */
41
+ export function createLogger(prefix: string, opts?: LoggerOptions): Logger {
42
+ const logFn = opts?.log ?? console.log;
43
+ const errorFn = opts?.error ?? console.error;
44
+
45
+ return {
46
+ debug: (msg: string) => logFn(`[${prefix}] [DEBUG] ${msg}`),
47
+ info: (msg: string) => logFn(`[${prefix}] ${msg}`),
48
+ warn: (msg: string) => logFn(`[${prefix}] [WARN] ${msg}`),
49
+ error: (msg: string) => errorFn(`[${prefix}] [ERROR] ${msg}`),
50
+ };
51
+ }
@@ -1,57 +1,57 @@
1
- /**
2
- * 媒体处理模块
3
- *
4
- * 提供统一的媒体解析、路径处理和文件读取功能
5
- *
6
- * @module @openclaw-china/shared/media
7
- */
8
-
9
- // 媒体解析
10
- export {
11
- // 类型
12
- type MediaType,
13
- type ExtractedMedia,
14
- type MediaParseResult,
15
- type MediaParseOptions,
16
- // 常量
17
- IMAGE_EXTENSIONS,
18
- AUDIO_EXTENSIONS,
19
- VIDEO_EXTENSIONS,
20
- NON_IMAGE_EXTENSIONS,
21
- // 路径处理函数
22
- isHttpUrl,
23
- isFileUrl,
24
- isLocalReference,
25
- normalizeLocalPath,
26
- stripTitleFromUrl,
27
- getExtension,
28
- isImagePath,
29
- isNonImageFilePath,
30
- detectMediaType,
31
- // 媒体提取函数
32
- extractMediaFromText,
33
- extractImagesFromText,
34
- extractFilesFromText,
35
- } from "./media-parser.js";
36
-
37
- // 媒体 IO
38
- export {
39
- // 类型
40
- type MediaReadResult,
41
- type MediaReadOptions,
42
- type PathSecurityOptions,
43
- // 错误类
44
- FileSizeLimitError,
45
- MediaTimeoutError,
46
- PathSecurityError,
47
- // 路径安全
48
- validatePathSecurity,
49
- getDefaultAllowedPrefixes,
50
- // MIME 类型
51
- getMimeType,
52
- // 媒体读取函数
53
- fetchMediaFromUrl,
54
- readMediaFromLocal,
55
- readMedia,
56
- readMediaBatch,
57
- } from "./media-io.js";
1
+ /**
2
+ * 媒体处理模块
3
+ *
4
+ * 提供统一的媒体解析、路径处理和文件读取功能
5
+ *
6
+ * @module @openclaw-china/shared/media
7
+ */
8
+
9
+ // 媒体解析
10
+ export {
11
+ // 类型
12
+ type MediaType,
13
+ type ExtractedMedia,
14
+ type MediaParseResult,
15
+ type MediaParseOptions,
16
+ // 常量
17
+ IMAGE_EXTENSIONS,
18
+ AUDIO_EXTENSIONS,
19
+ VIDEO_EXTENSIONS,
20
+ NON_IMAGE_EXTENSIONS,
21
+ // 路径处理函数
22
+ isHttpUrl,
23
+ isFileUrl,
24
+ isLocalReference,
25
+ normalizeLocalPath,
26
+ stripTitleFromUrl,
27
+ getExtension,
28
+ isImagePath,
29
+ isNonImageFilePath,
30
+ detectMediaType,
31
+ // 媒体提取函数
32
+ extractMediaFromText,
33
+ extractImagesFromText,
34
+ extractFilesFromText,
35
+ } from "./media-parser.js";
36
+
37
+ // 媒体 IO
38
+ export {
39
+ // 类型
40
+ type MediaReadResult,
41
+ type MediaReadOptions,
42
+ type PathSecurityOptions,
43
+ // 错误类
44
+ FileSizeLimitError,
45
+ MediaTimeoutError,
46
+ PathSecurityError,
47
+ // 路径安全
48
+ validatePathSecurity,
49
+ getDefaultAllowedPrefixes,
50
+ // MIME 类型
51
+ getMimeType,
52
+ // 媒体读取函数
53
+ fetchMediaFromUrl,
54
+ readMediaFromLocal,
55
+ readMedia,
56
+ readMediaBatch,
57
+ } from "./media-io.js";