@eaera-com/cms-sdk 0.1.99 → 0.1.100
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/dist/chunks/{chats-D9FmKJNH.js → chats-BjSS83OW.js} +1 -1
- package/dist/chunks/{client-DxMxkttF.js → client-Ac6qgpZ8.js} +1 -1
- package/dist/chunks/{connection-DW52jKW-.js → connection--KUpmDbP.js} +31 -2
- package/dist/chunks/{qwenpaw.constant-BSzwf_Ut.js → qwenpaw.constant-DHSj9A-0.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/server/ai/qwenpaw/chat/stop.post.js +4 -4
- package/dist/server/ai/qwenpaw/chat.post.js +4 -4
- package/dist/server/ai/qwenpaw/chats-id.delete.js +3 -3
- package/dist/server/ai/qwenpaw/chats.get.js +4 -4
- package/dist/server/ai/qwenpaw/history.get.js +3 -3
- package/dist/server/ai/qwenpaw/session.get.js +1 -1
- package/dist/server/ai/qwenpaw/session.post.js +3 -20
- package/dist/server/ai/qwenpaw/upload.post.js +4 -4
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createError } from 'h3';
|
|
2
2
|
import { ofetch } from 'ofetch';
|
|
3
|
-
import { e as QWENPAW_LIST_TIMEOUT_MS, d as QWENPAW_DEFAULT_AGENT_ID, f as QWENPAW_MAX_HISTORY_TURNS } from './qwenpaw.constant-
|
|
3
|
+
import { e as QWENPAW_LIST_TIMEOUT_MS, d as QWENPAW_DEFAULT_AGENT_ID, f as QWENPAW_MAX_HISTORY_TURNS } from './qwenpaw.constant-DHSj9A-0.js';
|
|
4
4
|
|
|
5
5
|
const chatsHeaders = (extra = {}) => ({
|
|
6
6
|
accept: "application/json",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as QWENPAW_CHANNEL, d as QWENPAW_DEFAULT_AGENT_ID, i as QWENPAW_CHAT_TIMEOUT_MS, j as QWENPAW_STOP_TIMEOUT_MS, k as QWENPAW_UPLOAD_TIMEOUT_MS } from './qwenpaw.constant-
|
|
1
|
+
import { h as QWENPAW_CHANNEL, d as QWENPAW_DEFAULT_AGENT_ID, i as QWENPAW_CHAT_TIMEOUT_MS, j as QWENPAW_STOP_TIMEOUT_MS, k as QWENPAW_UPLOAD_TIMEOUT_MS } from './qwenpaw.constant-DHSj9A-0.js';
|
|
2
2
|
import { createError } from 'h3';
|
|
3
3
|
|
|
4
4
|
const buildConsoleChatBody = (target, text, files = []) => ({
|
|
@@ -2,7 +2,7 @@ import { getCookie, createError, setCookie } from 'h3';
|
|
|
2
2
|
import { ofetch } from 'ofetch';
|
|
3
3
|
import { useRuntimeConfig } from '#imports';
|
|
4
4
|
import { T as TOKEN_STORAGE_KEY } from './storage.constant-CVWam5ls.js';
|
|
5
|
-
import {
|
|
5
|
+
import { l as QWENPAW_RUNTIME_CONFIG_KEY, d as QWENPAW_DEFAULT_AGENT_ID, m as QWENPAW_EXCHANGE_ACTION_PATH, n as QWENPAW_EXCHANGE_TIMEOUT_MS, o as QWENPAW_CONFIGURATION_ERROR_CODES, p as QWENPAW_COOKIE_BASE_URL, q as QWENPAW_COOKIE_MAX_AGE } from './qwenpaw.constant-DHSj9A-0.js';
|
|
6
6
|
|
|
7
7
|
class QwenpawExchangeError extends Error {
|
|
8
8
|
constructor(code, configurationError, message) {
|
|
@@ -52,6 +52,35 @@ const resolveQwenpawConnection = (event, overrides = {}) => {
|
|
|
52
52
|
return resolved;
|
|
53
53
|
};
|
|
54
54
|
const hasQwenpawConnection = (event) => Boolean(resolveQwenpawConnection(event).baseUrl);
|
|
55
|
+
const resolveFreshQwenpawConnection = async (event) => {
|
|
56
|
+
let connection = resolveQwenpawConnection(event);
|
|
57
|
+
if (!connection.baseUrl) {
|
|
58
|
+
try {
|
|
59
|
+
await exchangeQwenpawSession(event);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
handleExchangeError(error);
|
|
62
|
+
}
|
|
63
|
+
connection = resolveQwenpawConnection(event);
|
|
64
|
+
}
|
|
65
|
+
return connection;
|
|
66
|
+
};
|
|
67
|
+
const exchangeErrorStatus = (error) => {
|
|
68
|
+
if (error.code === "AI_NOT_AUTHENTICATED") return 401;
|
|
69
|
+
if (error.configurationError) return 403;
|
|
70
|
+
if (error.code === "AI_SESSION_EXCHANGE_FAILED") return 423;
|
|
71
|
+
return 502;
|
|
72
|
+
};
|
|
73
|
+
const handleExchangeError = (error) => {
|
|
74
|
+
if (error instanceof QwenpawExchangeError) {
|
|
75
|
+
throw createError({
|
|
76
|
+
statusCode: exchangeErrorStatus(error),
|
|
77
|
+
message: error.message,
|
|
78
|
+
data: { code: error.code }
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
console.error("qwenpaw-session", error);
|
|
82
|
+
throw createError({ statusCode: 502, message: "The AI agent is unreachable." });
|
|
83
|
+
};
|
|
55
84
|
const cmsBackendUrl = (event) => {
|
|
56
85
|
const pub = useRuntimeConfig(event).public ?? {};
|
|
57
86
|
const opts = pub.cmsSdkOptions ?? {};
|
|
@@ -118,4 +147,4 @@ const exchangeQwenpawSession = async (event) => {
|
|
|
118
147
|
return connection;
|
|
119
148
|
};
|
|
120
149
|
|
|
121
|
-
export {
|
|
150
|
+
export { resolveFreshQwenpawConnection as a, resolveQwenpawServerConfig as b, resolveQwenpawConnection as c, handleExchangeError as d, exchangeQwenpawSession as e, hasQwenpawConnection as h, requireCmsSession as r };
|
|
@@ -20,4 +20,4 @@ const QWENPAW_CONFIGURATION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
20
20
|
"AI_CREDENTIAL_NOT_CONFIGURED"
|
|
21
21
|
]);
|
|
22
22
|
|
|
23
|
-
export { QWENPAW_MAX_MESSAGE_LENGTH as Q, QWENPAW_MAX_FILES as a, QWENPAW_MAX_FILE_NAME_LENGTH as b, QWENPAW_MAX_SESSION_ID_LENGTH as c, QWENPAW_DEFAULT_AGENT_ID as d, QWENPAW_LIST_TIMEOUT_MS as e, QWENPAW_MAX_HISTORY_TURNS as f, QWENPAW_MAX_UPLOAD_BYTES as g, QWENPAW_CHANNEL as h, QWENPAW_CHAT_TIMEOUT_MS as i, QWENPAW_STOP_TIMEOUT_MS as j, QWENPAW_UPLOAD_TIMEOUT_MS as k, QWENPAW_RUNTIME_CONFIG_KEY as l,
|
|
23
|
+
export { QWENPAW_MAX_MESSAGE_LENGTH as Q, QWENPAW_MAX_FILES as a, QWENPAW_MAX_FILE_NAME_LENGTH as b, QWENPAW_MAX_SESSION_ID_LENGTH as c, QWENPAW_DEFAULT_AGENT_ID as d, QWENPAW_LIST_TIMEOUT_MS as e, QWENPAW_MAX_HISTORY_TURNS as f, QWENPAW_MAX_UPLOAD_BYTES as g, QWENPAW_CHANNEL as h, QWENPAW_CHAT_TIMEOUT_MS as i, QWENPAW_STOP_TIMEOUT_MS as j, QWENPAW_UPLOAD_TIMEOUT_MS as k, QWENPAW_RUNTIME_CONFIG_KEY as l, QWENPAW_EXCHANGE_ACTION_PATH as m, QWENPAW_EXCHANGE_TIMEOUT_MS as n, QWENPAW_CONFIGURATION_ERROR_CODES as o, QWENPAW_COOKIE_BASE_URL as p, QWENPAW_COOKIE_MAX_AGE as q };
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ import { ref, shallowRef, watch, computed, toRaw } from 'vue';
|
|
|
9
9
|
import { W as WS_RECONNECT_INITIAL_MS, a as WS_RECONNECT_MAX_MS, b as WS_CONNECTION_STATE, c as WS_PING_INTERVAL_MS, d as WS_MESSAGE_TYPE, e as WS_CLOSE_CODE, f as WS_MAX_RECONNECT_ATTEMPTS, g as WS_AUTH_TIMEOUT_MS, h as WS_RECONNECT_JITTER_MS, i as WS_PING_WATCHDOG_CHECK_MS, j as WS_MAX_SUBSCRIPTIONS, k as WS_PING_WATCHDOG_FACTOR } from './chunks/mt5Retcode-DK9C-4Dv.js';
|
|
10
10
|
export { M as MT5_RETCODE, l as WS_ACTION_ACCEPTED_ERROR_CODE, m as WS_ACTION_ERROR_CODE, n as WS_ACTION_RESULT_ERROR_CODE, o as WS_ACTION_RESULT_TTL_MS, p as WS_AUTH_ERROR_CODE, q as WS_CLOSE_REASON, r as WS_MT5_EVENT_TYPE, s as WS_TOPIC, t as WS_TOPIC_NAMESPACE, u as accountTopic, v as adminTopic, w as mt5Topic, x as streamTopic, y as symbolTopic, z as userTopic, A as viewMt5Retcode } from './chunks/mt5Retcode-DK9C-4Dv.js';
|
|
11
11
|
import { defineStore, storeToRefs } from 'pinia';
|
|
12
|
-
export { Q as QwenpawConfigError, a as QwenpawUpstreamError, b as buildConsoleChatBody, p as postConsoleChatError } from './chunks/client-
|
|
13
|
-
export { d as deleteQwenpawChat, e as extractChatModel, f as fetchChatHistory, g as getQwenpawChatMessages, l as listQwenpawChats, a as listQwenpawGroups, m as messagesToTurns } from './chunks/chats-
|
|
12
|
+
export { Q as QwenpawConfigError, a as QwenpawUpstreamError, b as buildConsoleChatBody, p as postConsoleChatError } from './chunks/client-Ac6qgpZ8.js';
|
|
13
|
+
export { d as deleteQwenpawChat, e as extractChatModel, f as fetchChatHistory, g as getQwenpawChatMessages, l as listQwenpawChats, a as listQwenpawGroups, m as messagesToTurns } from './chunks/chats-BjSS83OW.js';
|
|
14
14
|
export { categoryLabel, computeSpread, formatPrice } from './common/helpers/format.js';
|
|
15
15
|
|
|
16
16
|
const MT5_SERVER_NAME = "EAERA MT5 - Live";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler, readBody, createError } from 'h3';
|
|
2
|
-
import { c as qwenpawStop, p as postConsoleChatError } from '../../../../chunks/client-
|
|
3
|
-
import { c as QWENPAW_MAX_SESSION_ID_LENGTH } from '../../../../chunks/qwenpaw.constant-
|
|
4
|
-
import { r as requireCmsSession, a as
|
|
2
|
+
import { c as qwenpawStop, p as postConsoleChatError } from '../../../../chunks/client-Ac6qgpZ8.js';
|
|
3
|
+
import { c as QWENPAW_MAX_SESSION_ID_LENGTH } from '../../../../chunks/qwenpaw.constant-DHSj9A-0.js';
|
|
4
|
+
import { r as requireCmsSession, a as resolveFreshQwenpawConnection, b as resolveQwenpawServerConfig } from '../../../../chunks/connection--KUpmDbP.js';
|
|
5
5
|
|
|
6
6
|
const stop_post = defineEventHandler(async (event) => {
|
|
7
7
|
requireCmsSession(event);
|
|
@@ -10,7 +10,7 @@ const stop_post = defineEventHandler(async (event) => {
|
|
|
10
10
|
if (!sessionId || sessionId.length > QWENPAW_MAX_SESSION_ID_LENGTH) {
|
|
11
11
|
throw createError({ statusCode: 400, message: "Conversation session is required." });
|
|
12
12
|
}
|
|
13
|
-
const connection =
|
|
13
|
+
const connection = await resolveFreshQwenpawConnection(event);
|
|
14
14
|
try {
|
|
15
15
|
return await qwenpawStop({
|
|
16
16
|
config: resolveQwenpawServerConfig(event),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { defineEventHandler, readBody, createError, setResponseStatus, setResponseHeader, sendStream } from 'h3';
|
|
3
|
-
import { q as qwenpawChat, p as postConsoleChatError } from '../../../chunks/client-
|
|
4
|
-
import { Q as QWENPAW_MAX_MESSAGE_LENGTH, a as QWENPAW_MAX_FILES, b as QWENPAW_MAX_FILE_NAME_LENGTH, c as QWENPAW_MAX_SESSION_ID_LENGTH } from '../../../chunks/qwenpaw.constant-
|
|
5
|
-
import { r as requireCmsSession, a as
|
|
3
|
+
import { q as qwenpawChat, p as postConsoleChatError } from '../../../chunks/client-Ac6qgpZ8.js';
|
|
4
|
+
import { Q as QWENPAW_MAX_MESSAGE_LENGTH, a as QWENPAW_MAX_FILES, b as QWENPAW_MAX_FILE_NAME_LENGTH, c as QWENPAW_MAX_SESSION_ID_LENGTH } from '../../../chunks/qwenpaw.constant-DHSj9A-0.js';
|
|
5
|
+
import { r as requireCmsSession, a as resolveFreshQwenpawConnection, b as resolveQwenpawServerConfig } from '../../../chunks/connection--KUpmDbP.js';
|
|
6
6
|
|
|
7
7
|
const chat_post = defineEventHandler(async (event) => {
|
|
8
8
|
requireCmsSession(event);
|
|
@@ -27,7 +27,7 @@ const chat_post = defineEventHandler(async (event) => {
|
|
|
27
27
|
if (!sessionId || sessionId.length > QWENPAW_MAX_SESSION_ID_LENGTH) {
|
|
28
28
|
throw createError({ statusCode: 400, message: "Conversation session is required." });
|
|
29
29
|
}
|
|
30
|
-
const connection =
|
|
30
|
+
const connection = await resolveFreshQwenpawConnection(event);
|
|
31
31
|
const upstreamAbort = new AbortController();
|
|
32
32
|
event.node.req.once("close", () => upstreamAbort.abort());
|
|
33
33
|
let upstream;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineEventHandler, getRouterParam, createError } from 'h3';
|
|
2
|
-
import { d as deleteQwenpawChat } from '../../../chunks/chats-
|
|
3
|
-
import { r as requireCmsSession, a as
|
|
2
|
+
import { d as deleteQwenpawChat } from '../../../chunks/chats-BjSS83OW.js';
|
|
3
|
+
import { r as requireCmsSession, a as resolveFreshQwenpawConnection } from '../../../chunks/connection--KUpmDbP.js';
|
|
4
4
|
|
|
5
5
|
const chatsId_delete = defineEventHandler(async (event) => {
|
|
6
6
|
requireCmsSession(event);
|
|
@@ -8,7 +8,7 @@ const chatsId_delete = defineEventHandler(async (event) => {
|
|
|
8
8
|
if (!chatId) {
|
|
9
9
|
throw createError({ statusCode: 400, message: "Missing chat id." });
|
|
10
10
|
}
|
|
11
|
-
const ok = await deleteQwenpawChat(
|
|
11
|
+
const ok = await deleteQwenpawChat(await resolveFreshQwenpawConnection(event), chatId);
|
|
12
12
|
if (!ok) {
|
|
13
13
|
throw createError({ statusCode: 502, message: "Delete failed." });
|
|
14
14
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { defineEventHandler } from 'h3';
|
|
2
|
-
import { l as listQwenpawChats, a as listQwenpawGroups } from '../../../chunks/chats-
|
|
3
|
-
import { d as QWENPAW_DEFAULT_AGENT_ID } from '../../../chunks/qwenpaw.constant-
|
|
4
|
-
import { r as requireCmsSession, a as
|
|
2
|
+
import { l as listQwenpawChats, a as listQwenpawGroups } from '../../../chunks/chats-BjSS83OW.js';
|
|
3
|
+
import { d as QWENPAW_DEFAULT_AGENT_ID } from '../../../chunks/qwenpaw.constant-DHSj9A-0.js';
|
|
4
|
+
import { r as requireCmsSession, a as resolveFreshQwenpawConnection } from '../../../chunks/connection--KUpmDbP.js';
|
|
5
5
|
|
|
6
6
|
const chats_get = defineEventHandler(async (event) => {
|
|
7
7
|
requireCmsSession(event);
|
|
8
|
-
const connection =
|
|
8
|
+
const connection = await resolveFreshQwenpawConnection(event);
|
|
9
9
|
const [chats, groups] = await Promise.all([
|
|
10
10
|
listQwenpawChats(connection),
|
|
11
11
|
listQwenpawGroups(connection)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineEventHandler, getQuery, createError } from 'h3';
|
|
2
|
-
import { f as fetchChatHistory } from '../../../chunks/chats-
|
|
3
|
-
import { r as requireCmsSession, a as
|
|
2
|
+
import { f as fetchChatHistory } from '../../../chunks/chats-BjSS83OW.js';
|
|
3
|
+
import { r as requireCmsSession, a as resolveFreshQwenpawConnection } from '../../../chunks/connection--KUpmDbP.js';
|
|
4
4
|
|
|
5
5
|
const history_get = defineEventHandler(async (event) => {
|
|
6
6
|
requireCmsSession(event);
|
|
@@ -9,7 +9,7 @@ const history_get = defineEventHandler(async (event) => {
|
|
|
9
9
|
if (!chatId) {
|
|
10
10
|
throw createError({ statusCode: 400, message: "Missing chat id." });
|
|
11
11
|
}
|
|
12
|
-
const connection =
|
|
12
|
+
const connection = await resolveFreshQwenpawConnection(event);
|
|
13
13
|
return await fetchChatHistory(connection, chatId);
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler } from 'h3';
|
|
2
|
-
import { r as requireCmsSession,
|
|
2
|
+
import { r as requireCmsSession, c as resolveQwenpawConnection, h as hasQwenpawConnection } from '../../../chunks/connection--KUpmDbP.js';
|
|
3
3
|
|
|
4
4
|
const session_get = defineEventHandler((event) => {
|
|
5
5
|
requireCmsSession(event);
|
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
import { defineEventHandler
|
|
2
|
-
import { r as requireCmsSession, e as exchangeQwenpawSession,
|
|
1
|
+
import { defineEventHandler } from 'h3';
|
|
2
|
+
import { r as requireCmsSession, e as exchangeQwenpawSession, d as handleExchangeError } from '../../../chunks/connection--KUpmDbP.js';
|
|
3
3
|
|
|
4
|
-
const exchangeErrorStatus = (error) => {
|
|
5
|
-
if (error.code === "AI_NOT_AUTHENTICATED") return 401;
|
|
6
|
-
if (error.configurationError) return 403;
|
|
7
|
-
if (error.code === "AI_SESSION_EXCHANGE_FAILED") return 423;
|
|
8
|
-
return 502;
|
|
9
|
-
};
|
|
10
|
-
const handleExchangeError = (error) => {
|
|
11
|
-
if (error instanceof QwenpawExchangeError) {
|
|
12
|
-
throw createError({
|
|
13
|
-
statusCode: exchangeErrorStatus(error),
|
|
14
|
-
message: error.message,
|
|
15
|
-
data: { code: error.code }
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
console.error("qwenpaw-session", error);
|
|
19
|
-
throw createError({ statusCode: 502, message: "The AI agent is unreachable." });
|
|
20
|
-
};
|
|
21
4
|
const session_post = defineEventHandler(async (event) => {
|
|
22
5
|
requireCmsSession(event);
|
|
23
6
|
try {
|
|
@@ -28,4 +11,4 @@ const session_post = defineEventHandler(async (event) => {
|
|
|
28
11
|
}
|
|
29
12
|
});
|
|
30
13
|
|
|
31
|
-
export { session_post as default
|
|
14
|
+
export { session_post as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler, readMultipartFormData, createError } from 'h3';
|
|
2
|
-
import { d as qwenpawUpload, p as postConsoleChatError } from '../../../chunks/client-
|
|
3
|
-
import { g as QWENPAW_MAX_UPLOAD_BYTES } from '../../../chunks/qwenpaw.constant-
|
|
4
|
-
import { r as requireCmsSession, a as
|
|
2
|
+
import { d as qwenpawUpload, p as postConsoleChatError } from '../../../chunks/client-Ac6qgpZ8.js';
|
|
3
|
+
import { g as QWENPAW_MAX_UPLOAD_BYTES } from '../../../chunks/qwenpaw.constant-DHSj9A-0.js';
|
|
4
|
+
import { r as requireCmsSession, a as resolveFreshQwenpawConnection, b as resolveQwenpawServerConfig } from '../../../chunks/connection--KUpmDbP.js';
|
|
5
5
|
|
|
6
6
|
const upload_post = defineEventHandler(async (event) => {
|
|
7
7
|
requireCmsSession(event);
|
|
@@ -13,7 +13,7 @@ const upload_post = defineEventHandler(async (event) => {
|
|
|
13
13
|
if (filePart.data.length > QWENPAW_MAX_UPLOAD_BYTES) {
|
|
14
14
|
throw createError({ statusCode: 413, message: "File too large (max 20 MB)." });
|
|
15
15
|
}
|
|
16
|
-
const connection =
|
|
16
|
+
const connection = await resolveFreshQwenpawConnection(event);
|
|
17
17
|
const form = new FormData();
|
|
18
18
|
form.append(
|
|
19
19
|
"file",
|