@vibexnpm/talkx 3.1.0 → 3.2.1
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/talkflow-sdk.esm.js +1 -1
- package/dist/talkflow-sdk.esm.js.map +1 -1
- package/dist/talkflow-sdk.standalone.js +1 -1
- package/dist/talkflow-sdk.standalone.js.map +1 -1
- package/dist/talkflow-sdk.umd.js +1 -1
- package/dist/talkflow-sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/chat/ChatClient.js +41 -7
package/package.json
CHANGED
package/src/chat/ChatClient.js
CHANGED
|
@@ -11,6 +11,21 @@ import { WebSocketPaths, LogLevel, RoomListEventType, ChatRoomType, DefaultConfi
|
|
|
11
11
|
|
|
12
12
|
const MAX_FILES_PER_MESSAGE = 20;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* 방 PM 프롬프트 레이어 본문 한도.
|
|
16
|
+
* 서버 도메인 상수(PmPromptLayer.ROOM_CONTENT_MAX)의 미러 — 서버가 바뀌면 여기도 함께 올려야 한다.
|
|
17
|
+
* 값이 뒤처지면 서버는 받아주는데 SDK 가 먼저 막아 "저장이 안 된다"로 보인다.
|
|
18
|
+
*/
|
|
19
|
+
const MAX_ROOM_PM_PROMPT_LENGTH = 20000;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 매직 시그니처가 없는 평문 문서 MIME (txt / md).
|
|
23
|
+
* 서버 도메인 상수(PlainTextDocumentType)의 미러 — 서버가 평문 타입을 늘리면 여기도 함께 늘려야 한다.
|
|
24
|
+
* 빠지면 이 MIME 들이 DOCUMENT 가 아닌 FILE 로 분류돼 그룹 수 예측이 서버와 어긋나고,
|
|
25
|
+
* 결과적으로 다중 파일 전송의 messageId prediction 이 틀어진다.
|
|
26
|
+
*/
|
|
27
|
+
const PLAIN_TEXT_DOCUMENT_MIME_TYPES = new Set(['text/plain', 'text/markdown', 'text/x-markdown']);
|
|
28
|
+
|
|
14
29
|
class ChatClient extends EventEmitter {
|
|
15
30
|
/**
|
|
16
31
|
* @param {Object} options
|
|
@@ -643,11 +658,11 @@ class ChatClient extends EventEmitter {
|
|
|
643
658
|
/**
|
|
644
659
|
* 방 PM 프롬프트 레이어 등록/수정 (upsert) — <b>방 주인(OWNER) 전용</b>.
|
|
645
660
|
*
|
|
646
|
-
* <p>저장 시 새 버전이 자동 기록된다 ({@link #getRoomPmPromptVersions}). 본문 한도
|
|
661
|
+
* <p>저장 시 새 버전이 자동 기록된다 ({@link #getRoomPmPromptVersions}). 본문 한도 20,000자.
|
|
647
662
|
* 비주인 호출은 403 ({@code NOT_ROOM_ADMIN}).</p>
|
|
648
663
|
*
|
|
649
664
|
* @param {string} roomId - 채팅방 ID
|
|
650
|
-
* @param {string} content - 레이어 본문 (1~
|
|
665
|
+
* @param {string} content - 레이어 본문 (1~20,000자). 방의 목적/맥락/금지사항 등 PM 에게 줄 추가 지시문.
|
|
651
666
|
* @returns {Promise<Object>} 저장된 PmPromptLayer
|
|
652
667
|
*
|
|
653
668
|
* @example
|
|
@@ -657,8 +672,8 @@ class ChatClient extends EventEmitter {
|
|
|
657
672
|
if (typeof content !== 'string' || !content.trim()) {
|
|
658
673
|
throw new Error('upsertRoomPmPrompt requires non-blank content');
|
|
659
674
|
}
|
|
660
|
-
if (content.length >
|
|
661
|
-
throw new Error(
|
|
675
|
+
if (content.length > MAX_ROOM_PM_PROMPT_LENGTH) {
|
|
676
|
+
throw new Error(`upsertRoomPmPrompt content exceeds ${MAX_ROOM_PM_PROMPT_LENGTH} characters`);
|
|
662
677
|
}
|
|
663
678
|
|
|
664
679
|
const response = await this.apiClient.put(`/api/v1/rooms/${roomId}/pm-prompt`, { content });
|
|
@@ -1756,7 +1771,7 @@ class ChatClient extends EventEmitter {
|
|
|
1756
1771
|
*
|
|
1757
1772
|
* @param {string} roomId - 채팅방 ID
|
|
1758
1773
|
* @param {string} messageId - 메시지 ID
|
|
1759
|
-
* @param {string} message - 수정할 내용 (max
|
|
1774
|
+
* @param {string} message - 수정할 내용 (max 20000자)
|
|
1760
1775
|
* @returns {Promise<Object>}
|
|
1761
1776
|
*
|
|
1762
1777
|
* @example
|
|
@@ -1780,6 +1795,21 @@ class ChatClient extends EventEmitter {
|
|
|
1780
1795
|
return typeof message === 'string' && message.trim().length > 0;
|
|
1781
1796
|
}
|
|
1782
1797
|
|
|
1798
|
+
/**
|
|
1799
|
+
* Content-Type 의 base MIME — {@code ;} 이후 파라미터(charset 등) 제거 + trim + 소문자.
|
|
1800
|
+
* <p>서버 {@code ChatFileCategory.baseMimeType} mirror. 'text/plain; charset=utf-8' → 'text/plain'.
|
|
1801
|
+
* 'text/plain-invalid' 같은 변형은 그대로 남아 정확 비교에서 걸러진다.</p>
|
|
1802
|
+
*
|
|
1803
|
+
* @private
|
|
1804
|
+
* @param {string} mimeType
|
|
1805
|
+
* @returns {string}
|
|
1806
|
+
*/
|
|
1807
|
+
_baseMimeType(mimeType) {
|
|
1808
|
+
const raw = mimeType || '';
|
|
1809
|
+
const sep = raw.indexOf(';');
|
|
1810
|
+
return (sep >= 0 ? raw.slice(0, sep) : raw).trim().toLowerCase();
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1783
1813
|
/**
|
|
1784
1814
|
* MIME 타입 → 서버 {@code ChatMessageType} 분류 (서버 {@code FileGroupingService.classifyFileType} mirror).
|
|
1785
1815
|
* <p>서버 도메인 규칙과 동일해야 group count 예측이 일치한다. 서버 변경 시 본 메서드도 동기화 필요.</p>
|
|
@@ -1789,11 +1819,15 @@ class ChatClient extends EventEmitter {
|
|
|
1789
1819
|
* @returns {string} 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' | 'FILE'
|
|
1790
1820
|
*/
|
|
1791
1821
|
_classifyFileType(mimeType) {
|
|
1792
|
-
const mime = (mimeType
|
|
1822
|
+
const mime = this._baseMimeType(mimeType);
|
|
1793
1823
|
if (mime.startsWith('image/')) return 'IMAGE';
|
|
1794
1824
|
if (mime.startsWith('video/')) return 'VIDEO';
|
|
1795
1825
|
if (mime.startsWith('audio/')) return 'AUDIO';
|
|
1796
|
-
|
|
1826
|
+
// 평문(txt/md)도 DOCUMENT — 서버가 온디맨드 번역·PM 문서 인식 대상으로 삼는 기준과 동일해야 한다
|
|
1827
|
+
if (mime.includes('pdf') || mime.includes('document')
|
|
1828
|
+
|| PLAIN_TEXT_DOCUMENT_MIME_TYPES.has(mime)) {
|
|
1829
|
+
return 'DOCUMENT';
|
|
1830
|
+
}
|
|
1797
1831
|
return 'FILE';
|
|
1798
1832
|
}
|
|
1799
1833
|
|