@ynhcj/xiaoyi 2.5.6 → 2.5.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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Calculate SHA256 hash of a buffer.
3
+ */
4
+ export declare function calculateSHA256(buffer: Buffer): string;
5
+ /**
6
+ * Calculate SHA256 hash of a string.
7
+ */
8
+ export declare function calculateSHA256String(text: string): string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.calculateSHA256 = calculateSHA256;
7
+ exports.calculateSHA256String = calculateSHA256String;
8
+ // Cryptographic utilities
9
+ const crypto_1 = __importDefault(require("crypto"));
10
+ /**
11
+ * Calculate SHA256 hash of a buffer.
12
+ */
13
+ function calculateSHA256(buffer) {
14
+ return crypto_1.default.createHash("sha256").update(buffer).digest("hex");
15
+ }
16
+ /**
17
+ * Calculate SHA256 hash of a string.
18
+ */
19
+ function calculateSHA256String(text) {
20
+ return crypto_1.default.createHash("sha256").update(text, "utf8").digest("hex");
21
+ }
@@ -0,0 +1,6 @@
1
+ export declare const logger: {
2
+ log(message: string, ...args: any[]): void;
3
+ warn(message: string, ...args: any[]): void;
4
+ error(message: string, ...args: any[]): void;
5
+ debug(message: string, ...args: any[]): void;
6
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
4
+ // Logging utilities for XY channel
5
+ const runtime_js_1 = require("../runtime.js");
6
+ /**
7
+ * Log a message using the OpenClaw runtime logger.
8
+ */
9
+ function logMessage(level, message, ...args) {
10
+ try {
11
+ const runtime = (0, runtime_js_1.getXiaoYiRuntime)();
12
+ const logFn = runtime[level];
13
+ if (logFn) {
14
+ const formattedMessage = `[XY] ${message}`;
15
+ logFn(formattedMessage, ...args);
16
+ }
17
+ }
18
+ catch (error) {
19
+ // Fallback to console if runtime not available
20
+ console[level](`[XY] ${message}`, ...args);
21
+ }
22
+ }
23
+ exports.logger = {
24
+ log(message, ...args) {
25
+ logMessage("log", message, ...args);
26
+ },
27
+ warn(message, ...args) {
28
+ logMessage("warn", message, ...args);
29
+ },
30
+ error(message, ...args) {
31
+ logMessage("error", message, ...args);
32
+ },
33
+ debug(message, ...args) {
34
+ // Debug messages go to log level
35
+ logMessage("log", `[DEBUG] ${message}`, ...args);
36
+ },
37
+ };
@@ -0,0 +1,34 @@
1
+ import type { SessionBinding, ServerIdentifier } from "../types.js";
2
+ /**
3
+ * Session-to-server binding cache.
4
+ * Tracks which WebSocket server each session is bound to.
5
+ */
6
+ declare class SessionManager {
7
+ private bindings;
8
+ /**
9
+ * Bind a session to a specific server.
10
+ */
11
+ bind(sessionId: string, server: ServerIdentifier): void;
12
+ /**
13
+ * Get the server binding for a session.
14
+ */
15
+ getBinding(sessionId: string): ServerIdentifier | null;
16
+ /**
17
+ * Check if a session is bound to a server.
18
+ */
19
+ isBound(sessionId: string): boolean;
20
+ /**
21
+ * Unbind a session.
22
+ */
23
+ unbind(sessionId: string): void;
24
+ /**
25
+ * Clear all bindings.
26
+ */
27
+ clear(): void;
28
+ /**
29
+ * Get all bindings.
30
+ */
31
+ getAll(): SessionBinding[];
32
+ }
33
+ export declare const sessionManager: SessionManager;
34
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sessionManager = void 0;
4
+ /**
5
+ * Session-to-server binding cache.
6
+ * Tracks which WebSocket server each session is bound to.
7
+ */
8
+ class SessionManager {
9
+ constructor() {
10
+ this.bindings = new Map();
11
+ }
12
+ /**
13
+ * Bind a session to a specific server.
14
+ */
15
+ bind(sessionId, server) {
16
+ this.bindings.set(sessionId, {
17
+ sessionId,
18
+ server,
19
+ boundAt: Date.now(),
20
+ });
21
+ }
22
+ /**
23
+ * Get the server binding for a session.
24
+ */
25
+ getBinding(sessionId) {
26
+ const binding = this.bindings.get(sessionId);
27
+ return binding ? binding.server : null;
28
+ }
29
+ /**
30
+ * Check if a session is bound to a server.
31
+ */
32
+ isBound(sessionId) {
33
+ return this.bindings.has(sessionId);
34
+ }
35
+ /**
36
+ * Unbind a session.
37
+ */
38
+ unbind(sessionId) {
39
+ this.bindings.delete(sessionId);
40
+ }
41
+ /**
42
+ * Clear all bindings.
43
+ */
44
+ clear() {
45
+ this.bindings.clear();
46
+ }
47
+ /**
48
+ * Get all bindings.
49
+ */
50
+ getAll() {
51
+ return Array.from(this.bindings.values());
52
+ }
53
+ }
54
+ // Singleton instance
55
+ exports.sessionManager = new SessionManager();
package/package.json CHANGED
@@ -1,12 +1,24 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi",
3
- "version": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "description": "XiaoYi channel plugin for OpenClaw",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "xiaoyi.js",
17
+ "openclaw.plugin.json",
18
+ "README.md"
19
+ ],
7
20
  "scripts": {
8
- "build": "tsc",
9
- "prepublishOnly": "npm run build"
21
+ "build": "tsc"
10
22
  },
11
23
  "keywords": [
12
24
  "openclaw",
@@ -17,8 +29,12 @@
17
29
  "author": "ynhcj",
18
30
  "license": "MIT",
19
31
  "openclaw": {
20
- "extensions": ["xiaoyi.js"],
21
- "channels": ["xiaoyi"],
32
+ "extensions": [
33
+ "xiaoyi.js"
34
+ ],
35
+ "channels": [
36
+ "xiaoyi"
37
+ ],
22
38
  "installDependencies": true,
23
39
  "install": {
24
40
  "npmSpec": "@ynhcj/xiaoyi@latest",
@@ -33,11 +49,13 @@
33
49
  "docsLabel": "xiaoyi",
34
50
  "blurb": "小艺 A2A 协议支持,通过 WebSocket 连接。",
35
51
  "order": 80,
36
- "aliases": ["xy"]
52
+ "aliases": [
53
+ "xy"
54
+ ]
37
55
  }
38
56
  },
39
57
  "peerDependencies": {
40
- "openclaw": "*"
58
+ "openclaw": ">=2026.3.1"
41
59
  },
42
60
  "peerDependenciesMeta": {
43
61
  "openclaw": {
@@ -45,19 +63,16 @@
45
63
  }
46
64
  },
47
65
  "dependencies": {
66
+ "node-fetch": "^3.3.2",
67
+ "uuid": "^13.0.0",
48
68
  "ws": "^8.16.0",
49
69
  "zod": "^3.22.4"
50
70
  },
51
71
  "devDependencies": {
52
72
  "@types/node": "^20.11.0",
73
+ "@types/node-fetch": "^2.6.13",
74
+ "@types/uuid": "^10.0.0",
53
75
  "@types/ws": "^8.5.10",
54
- "openclaw": "^2026.2.24",
55
76
  "typescript": "^5.3.3"
56
- },
57
- "files": [
58
- "dist",
59
- "xiaoyi.js",
60
- "openclaw.plugin.json",
61
- "README.md"
62
- ]
77
+ }
63
78
  }