@opentiny/genui-sdk-server 0.0.1-alpha.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 OpenTiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { }
package/dist/cli.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ import C from "dotenv";
3
+ import l from "node:path";
4
+ import { Command as w } from "commander";
5
+ import { s as B } from "./start-server-CvMT9YSe.js";
6
+ const e = r;
7
+ (function(t, x) {
8
+ const n = r, o = t();
9
+ for (; ; )
10
+ try {
11
+ if (parseInt(n(383)) / 1 + -parseInt(n(363)) / 2 + parseInt(n(359)) / 3 + parseInt(n(371)) / 4 + -parseInt(n(362)) / 5 + parseInt(n(382)) / 6 + parseInt(n(387)) / 7 * (parseInt(n(355)) / 8) === x) break;
12
+ o.push(o.shift());
13
+ } catch {
14
+ o.push(o.shift());
15
+ }
16
+ })(y, 190885);
17
+ const b = new w();
18
+ function y() {
19
+ const t = ["u3rHCNqGysbJAa", "y29UzMLN", "zxHPDa", "qKftrv9vuKW", "6iEQ5A6A5lMj546V5Akd5y+y6yEp5PAh5lU26lEV", "mti2otmWognTCu1wtW", "lxaGls1WB3j0ia", "zw52", "5Akd5y+y6yEpifbpuLtVViK", "yxbPs2v5", "5lIl55Qeic5LBNBVViK", "Cgf0Aa", "zxjYB3i", "Cg9YDa", "yxqGy29TCgXLDa", "ue9sva", "mZuYndK0CLDsveTU", "nZeYnJvoC0LIA2m", "BMfTzq", "Bwf4qxr0zw1WDa", "y3DK", "mJf3we9nsMi", "lMvUDG", "ic5LBNyG5OIw57o757UF546V", "5B6e77Yi6BUy6k6K6k+75y+w5B2t5yMn55UU5B2v", "AwXLidXWyxrOpG", "yMfZzvvsta", "5P+L55Yl5zg95lUK5BIU5yQP5l+H5OgV", "ieDLBLvj", "zxj2AwnLigzVCG", "5PYn5yQH5zcV5yQO56UV5y+J77Yi6BUy6k6Kia", "Aw9UieHuvfaGCW", "lwGSic0TAgvSCa", "ndCYmda4wfjjugH1", "B3b0Aw9U", "C2vYDMvY", "mZeWmo+8JoAiLUIaHEs9V+EuQoEoRW", "mJu2mtCZBMXUyw50", "vvjm", "zgvZy3jPChrPBW", "mtCZotCXmfbrsgDsAq", "mZqXode2zuLwswDz", "CMvZB2X2zq", "546V5Akd5y+y6yEp5PYQ6ywn572U77YA6k+35zYO"];
20
+ return y = function() {
21
+ return t;
22
+ }, y();
23
+ }
24
+ function r(t, x) {
25
+ t = t - 349;
26
+ const n = y();
27
+ let o = n[t];
28
+ if (r.SzPLtr === void 0) {
29
+ var f = function(s) {
30
+ const m = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";
31
+ let a = "", u = "";
32
+ for (let c = 0, d, i, A = 0; i = s.charAt(A++); ~i && (d = c % 4 ? d * 64 + i : i, c++ % 4) ? a += String.fromCharCode(255 & d >> (-2 * c & 6)) : 0)
33
+ i = m.indexOf(i);
34
+ for (let c = 0, d = a.length; c < d; c++)
35
+ u += "%" + ("00" + a.charCodeAt(c).toString(16)).slice(-2);
36
+ return decodeURIComponent(u);
37
+ };
38
+ r.OvCJtf = f, r.LCSnKQ = {}, r.SzPLtr = !0;
39
+ }
40
+ const p = n[0], _ = t + p, v = r.LCSnKQ[_];
41
+ return v ? o = v : (o = r.OvCJtf(o), r.LCSnKQ[_] = o), o;
42
+ }
43
+ b[e(384)]("genui-sdk-" + e(357))[e(361) + "n"](e(366) + e(380) + e(353) + e(351) + e(350))[e(356)]("-e, --envF" + e(391), e(370) + e(390) + e(376))[e(356)](e(372) + "<port>", e(352) + e(358) + e(374)).helpOption(e(354), e(349)).action((t) => {
44
+ const x = e, { envFile: n, port: o } = t;
45
+ if (n) {
46
+ const m = l.resolve(process[x(386)](), n), a = {};
47
+ a[x(377)] = m, C[x(367)](a);
48
+ } else C[x(367)]({ path: l[x(364)](process[x(386)](), x(388)) });
49
+ const f = process[x(373)][x(369)], p = process.env.API_KEY;
50
+ !f && (console[x(378)]("环境变量未配置:请在" + x(389) + "境中设置 BASE_" + x(360)), process[x(368)](1)), !p && (console.error(x(365) + x(389) + "境中设置 API_KEY"), process.exit(1));
51
+ const _ = process[x(373)][x(381)] ? Number(process.env[x(381)]) : void 0, v = (o ? Number(o) : void 0) ?? _ ?? 3100, s = {};
52
+ s[x(379)] = v, s[x(392)] = f, s[x(375)] = p, s[x(385) + "s"] = 10, B(s);
53
+ }), b.parse(process.argv);
@@ -0,0 +1,43 @@
1
+ import { ChatCompletionCreateParamsBase } from '@opentiny/genui-sdk-chat-completions';
2
+ import { Express as Express_2 } from 'express';
3
+ import { IncomingMessage } from 'node:http';
4
+ import { IRequestOptions } from '@opentiny/genui-sdk-chat-completions';
5
+ import { ServerResponse } from 'node:http';
6
+
7
+ export declare function createChatCompletionHandler(config: IChatCompletionHandlerConfig): {
8
+ handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
9
+ };
10
+
11
+ export declare function equipChatCompletions(app: Express_2, options: IEquipChatCompletionsOptions): void;
12
+
13
+ export declare class GenUIChatAPIError extends Error {
14
+ name: string;
15
+ status: number;
16
+ statusText: string;
17
+ code: string;
18
+ constructor(message: string, status: number, statusText: string, code: string);
19
+ }
20
+
21
+ export declare interface IChatCompletionHandlerConfig {
22
+ chatCompletions: (params: ChatCompletionCreateParamsBase, options?: IRequestOptions) => Promise<Response>;
23
+ }
24
+
25
+ export declare interface IEquipChatCompletionsOptions {
26
+ route: string;
27
+ apiKey: string;
28
+ baseURL: string;
29
+ }
30
+
31
+ export declare interface IStartServerOptions extends Omit<IEquipChatCompletionsOptions, 'route'> {
32
+ port?: number;
33
+ maxAttempts?: number;
34
+ }
35
+
36
+ /**
37
+ * 尝试在指定端口启动服务器,如果端口被占用则尝试下一个端口
38
+ * @param port 起始端口号
39
+ * @param maxAttempts 最大尝试次数,默认10次
40
+ */
41
+ export declare function startServer(options: IStartServerOptions): void;
42
+
43
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ import { G as b, c as A, e as B, s as d } from "./start-server-CvMT9YSe.js";
2
+ function x() {
3
+ var n = ["mtu2DMrNA21A", "mJmZnZu1ExzmwgDv", "mJqZr0PABKvJ", "mJmXmZeWmJzzEev1vee", "ndi3nZaWmfLREwnoqW", "mZa2nde1mNPJCMnvsG", "mZG5nZbeqMndy0y", "mtCYnZKZmuv4EKzZzG", "mtK1mduXnMrODeLluq"];
4
+ return x = function() {
5
+ return n;
6
+ }, x();
7
+ }
8
+ (function(n, u) {
9
+ for (var r = t, e = n(); ; )
10
+ try {
11
+ var f = parseInt(r(246)) / 1 + -parseInt(r(245)) / 2 * (parseInt(r(250)) / 3) + -parseInt(r(248)) / 4 * (parseInt(r(249)) / 5) + parseInt(r(247)) / 6 + -parseInt(r(243)) / 7 + parseInt(r(244)) / 8 + parseInt(r(242)) / 9;
12
+ if (f === u) break;
13
+ e.push(e.shift());
14
+ } catch {
15
+ e.push(e.shift());
16
+ }
17
+ })(x, 993576);
18
+ function t(n, u) {
19
+ n = n - 242;
20
+ var r = x(), e = r[n];
21
+ if (t.GprlBx === void 0) {
22
+ var f = function(l) {
23
+ for (var c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=", i = "", h = "", s = 0, m, a, I = 0; a = l.charAt(I++); ~a && (m = s % 4 ? m * 64 + a : a, s++ % 4) ? i += String.fromCharCode(255 & m >> (-2 * s & 6)) : 0)
24
+ a = c.indexOf(a);
25
+ for (var o = 0, J = i.length; o < J; o++)
26
+ h += "%" + ("00" + i.charCodeAt(o).toString(16)).slice(-2);
27
+ return decodeURIComponent(h);
28
+ };
29
+ t.uHCiiJ = f, t.YlJCBC = {}, t.GprlBx = !0;
30
+ }
31
+ var C = r[0], p = n + C, v = t.YlJCBC[p];
32
+ return v ? e = v : (e = t.uHCiiJ(e), t.YlJCBC[p] = e), e;
33
+ }
34
+ export {
35
+ b as GenUIChatAPIError,
36
+ A as createChatCompletionHandler,
37
+ B as equipChatCompletions,
38
+ d as startServer
39
+ };