ttc-ai-chat-sdk 0.0.1-beta
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/README.md +2 -0
- package/dist/construct.d.ts +8 -0
- package/dist/construct.d.ts.map +1 -0
- package/dist/construct.js +39 -0
- package/dist/construct.js.map +1 -0
- package/dist/core.d.ts +61 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +460 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +53 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +157 -0
- package/dist/internal.js.map +1 -0
- package/dist/ttcAI.d.ts +61 -0
- package/dist/ttcAI.d.ts.map +1 -0
- package/dist/ttcAI.js +132 -0
- package/dist/ttcAI.js.map +1 -0
- package/dist/ttc_server.d.ts +222 -0
- package/dist/ttc_server.d.ts.map +1 -0
- package/dist/ttc_server.js +311 -0
- package/dist/ttc_server.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/eventEmitter.d.ts +17 -0
- package/dist/utils/eventEmitter.d.ts.map +1 -0
- package/dist/utils/eventEmitter.js +47 -0
- package/dist/utils/eventEmitter.js.map +1 -0
- package/dist/utils/zodToTs.d.ts +25 -0
- package/dist/utils/zodToTs.d.ts.map +1 -0
- package/dist/utils/zodToTs.js +85 -0
- package/dist/utils/zodToTs.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { Socket } from "socket.io-client";
|
|
2
|
+
export type callbackType = (method: string, params?: any) => Promise<any>;
|
|
3
|
+
export type mediaCallbackType = (method: string, params?: any, file?: any) => Promise<any>;
|
|
4
|
+
export type rpcResponseType<T = any> = {
|
|
5
|
+
status: 'success' | 'error';
|
|
6
|
+
data?: T;
|
|
7
|
+
};
|
|
8
|
+
export declare const _scid: () => string;
|
|
9
|
+
export declare class RPCClient {
|
|
10
|
+
static token_cb: () => Promise<string>;
|
|
11
|
+
static url: string;
|
|
12
|
+
constructor(url: string, token_cb: () => Promise<string>, socket_cb?: (socket: Socket) => Promise<any>);
|
|
13
|
+
static apiCallback: callbackType;
|
|
14
|
+
static mediaCallback: mediaCallbackType;
|
|
15
|
+
connectSocket(url: string, socket_cb: (socket: Socket) => Promise<any>): Promise<void>;
|
|
16
|
+
ttcCore: {
|
|
17
|
+
/**
|
|
18
|
+
* sends a message to the ai
|
|
19
|
+
*
|
|
20
|
+
* @param {conversation_id: string, message: string}
|
|
21
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
22
|
+
*/
|
|
23
|
+
chatAI(conversation_id: string, message: string): Promise<rpcResponseType<any>>;
|
|
24
|
+
/**
|
|
25
|
+
* sends a function response to the ai
|
|
26
|
+
*
|
|
27
|
+
* @param {conversation_id: string, response: any[], image_urls: any[]}
|
|
28
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
29
|
+
*/
|
|
30
|
+
functionResponse(conversation_id: string, response: any[], image_urls: any[]): Promise<rpcResponseType<any>>;
|
|
31
|
+
/**
|
|
32
|
+
* get chat history
|
|
33
|
+
*
|
|
34
|
+
* @param {conversation_id: string, limit: number, page: number}
|
|
35
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
36
|
+
*/
|
|
37
|
+
fetchChatHistory(conversation_id: string, limit: number, page: number): Promise<rpcResponseType<any>>;
|
|
38
|
+
/**
|
|
39
|
+
* sets a function for the app
|
|
40
|
+
*
|
|
41
|
+
* @param {conversation_id: string, func: Partial<{ }> }
|
|
42
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
43
|
+
*/
|
|
44
|
+
setAppFunctions(conversation_id: string, func: Partial<{}>): Promise<rpcResponseType<any>>;
|
|
45
|
+
/**
|
|
46
|
+
* Generates a chat token
|
|
47
|
+
*
|
|
48
|
+
* @param {uuid: string}
|
|
49
|
+
* @returns {Promise<rpcResponseType<{ chatId: string }>>}
|
|
50
|
+
*/
|
|
51
|
+
createChat(uuid: string): Promise<rpcResponseType<{
|
|
52
|
+
chatId: string;
|
|
53
|
+
}>>;
|
|
54
|
+
/**
|
|
55
|
+
* Updates a chat
|
|
56
|
+
*
|
|
57
|
+
* @param {chatId: string, metadata: Partial<{ }> }
|
|
58
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
59
|
+
*/
|
|
60
|
+
updateChat(chatId: string, metadata: Partial<{}>): Promise<rpcResponseType<any>>;
|
|
61
|
+
/**
|
|
62
|
+
* Fetches all chats for an app
|
|
63
|
+
*
|
|
64
|
+
* @param {page: number, limit: number}
|
|
65
|
+
* @returns {Promise<rpcResponseType<string[]>>}
|
|
66
|
+
*/
|
|
67
|
+
fetchChats(page: number, limit: number): Promise<rpcResponseType<string[]>>;
|
|
68
|
+
/**
|
|
69
|
+
* Fetches a chat
|
|
70
|
+
*
|
|
71
|
+
* @param {chatId: string}
|
|
72
|
+
* @returns {Promise<rpcResponseType<{ id: string; inputTokens: number; outputTokens: number; metadata?: any }>>}
|
|
73
|
+
*/
|
|
74
|
+
fetchChat(chatId: string): Promise<rpcResponseType<{
|
|
75
|
+
id: string;
|
|
76
|
+
inputTokens: number;
|
|
77
|
+
outputTokens: number;
|
|
78
|
+
metadata?: any;
|
|
79
|
+
}>>;
|
|
80
|
+
/**
|
|
81
|
+
* Updates a chat
|
|
82
|
+
*
|
|
83
|
+
* @param {chatId: string}
|
|
84
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
85
|
+
*/
|
|
86
|
+
deleteChat(chatId: string): Promise<rpcResponseType<any>>;
|
|
87
|
+
/**
|
|
88
|
+
* Clears chat history, soft clears messages but retains system prompt and functions, hard clears everything
|
|
89
|
+
*
|
|
90
|
+
* @param {conversation_id: string, mode: string}
|
|
91
|
+
* @returns {Promise<rpcResponseType<string>>}
|
|
92
|
+
*/
|
|
93
|
+
clearChatHistory(conversation_id: string, mode: string): Promise<rpcResponseType<string>>;
|
|
94
|
+
/**
|
|
95
|
+
* fetches an emote
|
|
96
|
+
*
|
|
97
|
+
* @param {}
|
|
98
|
+
* @returns {Promise<rpcResponseType<{ emote: string; modelId?: string }>>}
|
|
99
|
+
*/
|
|
100
|
+
fetchEmote(): Promise<rpcResponseType<{
|
|
101
|
+
emote: string;
|
|
102
|
+
modelId?: string;
|
|
103
|
+
}>>;
|
|
104
|
+
/**
|
|
105
|
+
* Adds a remote origin for an app
|
|
106
|
+
*
|
|
107
|
+
* @param {app_id: string}
|
|
108
|
+
* @returns {Promise<rpcResponseType<{ url: string; name: string }[]>>}
|
|
109
|
+
*/
|
|
110
|
+
fetchOrigins(app_id: string): Promise<rpcResponseType<{
|
|
111
|
+
url: string;
|
|
112
|
+
name: string;
|
|
113
|
+
apikey: string;
|
|
114
|
+
}[]>>;
|
|
115
|
+
};
|
|
116
|
+
AppOAuth: {
|
|
117
|
+
/**
|
|
118
|
+
* Generate OAuth authorization URL for app integration. Platform embeds this URL to start OAuth flow.
|
|
119
|
+
*
|
|
120
|
+
* @param {appId: string, redirectUri: string, scopes: string, state: string}
|
|
121
|
+
* @returns {Promise<rpcResponseType<{ authorizationUrl: string; state: string }>>}
|
|
122
|
+
*/
|
|
123
|
+
generateAuthorizationUrl(appId: string, redirectUri: string, scopes: string, state: string): Promise<rpcResponseType<{
|
|
124
|
+
authorizationUrl: string;
|
|
125
|
+
state: string;
|
|
126
|
+
}>>;
|
|
127
|
+
/**
|
|
128
|
+
* Exchange authorization code for access token. Called by platform backend after receiving code.
|
|
129
|
+
*
|
|
130
|
+
* @param {code: string, appId: string, redirectUri: string}
|
|
131
|
+
* @returns {Promise<rpcResponseType<{ accessToken: string; tokenType: string; expiresIn: number; appUserId: string; emote: any }>>}
|
|
132
|
+
*/
|
|
133
|
+
exchangeCodeForToken(code: string, appId: string, redirectUri: string): Promise<rpcResponseType<{
|
|
134
|
+
accessToken: string;
|
|
135
|
+
tokenType: string;
|
|
136
|
+
expiresIn: number;
|
|
137
|
+
appUserId: string;
|
|
138
|
+
emote: any;
|
|
139
|
+
}>>;
|
|
140
|
+
/**
|
|
141
|
+
* Refresh an expired access token for continued API access.
|
|
142
|
+
*
|
|
143
|
+
* @param {appUserId: string, appId: string}
|
|
144
|
+
* @returns {Promise<rpcResponseType<{ accessToken: string; tokenType: string; expiresIn: number; appUserId: string }>>}
|
|
145
|
+
*/
|
|
146
|
+
refreshToken(appUserId: string, appId: string): Promise<rpcResponseType<{
|
|
147
|
+
accessToken: string;
|
|
148
|
+
tokenType: string;
|
|
149
|
+
expiresIn: number;
|
|
150
|
+
appUserId: string;
|
|
151
|
+
}>>;
|
|
152
|
+
};
|
|
153
|
+
Media: {
|
|
154
|
+
/**
|
|
155
|
+
* Uploads an image to S3 and returns its URL. Replaces any existing image for the conversation.
|
|
156
|
+
*
|
|
157
|
+
* @param {appId: string, conversationId: string, file: any}
|
|
158
|
+
* @returns {Promise<rpcResponseType<{ url: string }>>}
|
|
159
|
+
*/
|
|
160
|
+
uploadImage(appId: string, conversationId: string, file: any): Promise<rpcResponseType<{
|
|
161
|
+
url: string;
|
|
162
|
+
}>>;
|
|
163
|
+
};
|
|
164
|
+
TCC: {
|
|
165
|
+
/**
|
|
166
|
+
* Get current model for a conversation
|
|
167
|
+
*
|
|
168
|
+
* @param {conversation_id: string}
|
|
169
|
+
* @returns {Promise<rpcResponseType<{ emote: string; nlp_model: string; assistant: string }>>}
|
|
170
|
+
*/
|
|
171
|
+
conversation_stats(conversation_id: string): Promise<rpcResponseType<{
|
|
172
|
+
emote: string;
|
|
173
|
+
nlp_model: string;
|
|
174
|
+
assistant: string;
|
|
175
|
+
}>>;
|
|
176
|
+
/**
|
|
177
|
+
* Get list of all models available to you
|
|
178
|
+
*
|
|
179
|
+
* @param {conversation_id: string}
|
|
180
|
+
* @returns {Promise<rpcResponseType<{ id: string; name: string; type: string; provider: string }[]>>}
|
|
181
|
+
*/
|
|
182
|
+
get_models(conversation_id: string): Promise<rpcResponseType<{
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
type: string;
|
|
186
|
+
provider: string;
|
|
187
|
+
}[]>>;
|
|
188
|
+
/**
|
|
189
|
+
* Changes the model for a conversation, use with caution, may discontinue chat if model is not compatible
|
|
190
|
+
*
|
|
191
|
+
* @param {conversation_id: string, model_id: string, type: string}
|
|
192
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
193
|
+
*/
|
|
194
|
+
change_to_model(conversation_id: string, model_id: string, type: string): Promise<rpcResponseType<any>>;
|
|
195
|
+
/**
|
|
196
|
+
* Trigger the ai to act based on a trigger message
|
|
197
|
+
*
|
|
198
|
+
* @param {conversation_id: string, message: string, eta_seconds: number}
|
|
199
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
200
|
+
*/
|
|
201
|
+
trigger(conversation_id: string, message: string, eta_seconds: number): Promise<rpcResponseType<any>>;
|
|
202
|
+
/**
|
|
203
|
+
* This function is used to invoke the llm with a description and instruction
|
|
204
|
+
*
|
|
205
|
+
* @param {conversation_id: string, input: Partial<{ description: string, instruction: string, construct_id: string }> }
|
|
206
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
207
|
+
*/
|
|
208
|
+
invoke_construct(conversation_id: string, input: Partial<{
|
|
209
|
+
description: string;
|
|
210
|
+
instruction: string;
|
|
211
|
+
construct_id: string;
|
|
212
|
+
}>): Promise<rpcResponseType<any>>;
|
|
213
|
+
/**
|
|
214
|
+
* specifies a selected data on the client for the ai to work with
|
|
215
|
+
*
|
|
216
|
+
* @param {conversation_id: string, data: string}
|
|
217
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
218
|
+
*/
|
|
219
|
+
select_context(conversation_id: string, data: string): Promise<rpcResponseType<any>>;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=ttc_server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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B,GAAG,CAAC,CAAC;QAGlK;;;;;WAKG;wCACmC,MAAM,QAAQ,MAAM,GAAG,QAAQ,gBAAgB,GAAG,CAAC,CAAC;MAG7F;CAEJ"}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.RPCClient = exports._scid = void 0;
|
|
5
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
6
|
+
let sid = "";
|
|
7
|
+
const _scid = () => {
|
|
8
|
+
if (sid)
|
|
9
|
+
return sid;
|
|
10
|
+
const key = 'ttc_scid_ai';
|
|
11
|
+
try {
|
|
12
|
+
sid = localStorage ? localStorage.getItem(key) : null;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
sid = null;
|
|
16
|
+
}
|
|
17
|
+
if (!sid) {
|
|
18
|
+
sid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
19
|
+
try {
|
|
20
|
+
localStorage.setItem(key, sid);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return sid;
|
|
26
|
+
};
|
|
27
|
+
exports._scid = _scid;
|
|
28
|
+
class RPCClient {
|
|
29
|
+
constructor(url, token_cb, socket_cb) {
|
|
30
|
+
this.ttcCore = {
|
|
31
|
+
/**
|
|
32
|
+
* sends a message to the ai
|
|
33
|
+
*
|
|
34
|
+
* @param {conversation_id: string, message: string}
|
|
35
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
36
|
+
*/
|
|
37
|
+
async chatAI(conversation_id, message) {
|
|
38
|
+
return await _a.apiCallback('ttcCore.chatAI', [conversation_id, message]);
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* sends a function response to the ai
|
|
42
|
+
*
|
|
43
|
+
* @param {conversation_id: string, response: any[], image_urls: any[]}
|
|
44
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
45
|
+
*/
|
|
46
|
+
async functionResponse(conversation_id, response, image_urls) {
|
|
47
|
+
return await _a.apiCallback('ttcCore.functionResponse', [conversation_id, response, image_urls]);
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* get chat history
|
|
51
|
+
*
|
|
52
|
+
* @param {conversation_id: string, limit: number, page: number}
|
|
53
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
54
|
+
*/
|
|
55
|
+
async fetchChatHistory(conversation_id, limit, page) {
|
|
56
|
+
return await _a.apiCallback('ttcCore.fetchChatHistory', [conversation_id, limit, page]);
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* sets a function for the app
|
|
60
|
+
*
|
|
61
|
+
* @param {conversation_id: string, func: Partial<{ }> }
|
|
62
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
63
|
+
*/
|
|
64
|
+
async setAppFunctions(conversation_id, func) {
|
|
65
|
+
return await _a.apiCallback('ttcCore.setAppFunctions', [conversation_id, func]);
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Generates a chat token
|
|
69
|
+
*
|
|
70
|
+
* @param {uuid: string}
|
|
71
|
+
* @returns {Promise<rpcResponseType<{ chatId: string }>>}
|
|
72
|
+
*/
|
|
73
|
+
async createChat(uuid) {
|
|
74
|
+
return await _a.apiCallback('ttcCore.createChat', [uuid]);
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Updates a chat
|
|
78
|
+
*
|
|
79
|
+
* @param {chatId: string, metadata: Partial<{ }> }
|
|
80
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
81
|
+
*/
|
|
82
|
+
async updateChat(chatId, metadata) {
|
|
83
|
+
return await _a.apiCallback('ttcCore.updateChat', [chatId, metadata]);
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* Fetches all chats for an app
|
|
87
|
+
*
|
|
88
|
+
* @param {page: number, limit: number}
|
|
89
|
+
* @returns {Promise<rpcResponseType<string[]>>}
|
|
90
|
+
*/
|
|
91
|
+
async fetchChats(page, limit) {
|
|
92
|
+
return await _a.apiCallback('ttcCore.fetchChats', [page, limit]);
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Fetches a chat
|
|
96
|
+
*
|
|
97
|
+
* @param {chatId: string}
|
|
98
|
+
* @returns {Promise<rpcResponseType<{ id: string; inputTokens: number; outputTokens: number; metadata?: any }>>}
|
|
99
|
+
*/
|
|
100
|
+
async fetchChat(chatId) {
|
|
101
|
+
return await _a.apiCallback('ttcCore.fetchChat', [chatId]);
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Updates a chat
|
|
105
|
+
*
|
|
106
|
+
* @param {chatId: string}
|
|
107
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
108
|
+
*/
|
|
109
|
+
async deleteChat(chatId) {
|
|
110
|
+
return await _a.apiCallback('ttcCore.deleteChat', [chatId]);
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Clears chat history, soft clears messages but retains system prompt and functions, hard clears everything
|
|
114
|
+
*
|
|
115
|
+
* @param {conversation_id: string, mode: string}
|
|
116
|
+
* @returns {Promise<rpcResponseType<string>>}
|
|
117
|
+
*/
|
|
118
|
+
async clearChatHistory(conversation_id, mode) {
|
|
119
|
+
return await _a.apiCallback('ttcCore.clearChatHistory', [conversation_id, mode]);
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* fetches an emote
|
|
123
|
+
*
|
|
124
|
+
* @param {}
|
|
125
|
+
* @returns {Promise<rpcResponseType<{ emote: string; modelId?: string }>>}
|
|
126
|
+
*/
|
|
127
|
+
async fetchEmote() {
|
|
128
|
+
return await _a.apiCallback('ttcCore.fetchEmote');
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* Adds a remote origin for an app
|
|
132
|
+
*
|
|
133
|
+
* @param {app_id: string}
|
|
134
|
+
* @returns {Promise<rpcResponseType<{ url: string; name: string }[]>>}
|
|
135
|
+
*/
|
|
136
|
+
async fetchOrigins(app_id) {
|
|
137
|
+
return await _a.apiCallback('ttcCore.fetchOrigins', [app_id]);
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
this.AppOAuth = {
|
|
141
|
+
/**
|
|
142
|
+
* Generate OAuth authorization URL for app integration. Platform embeds this URL to start OAuth flow.
|
|
143
|
+
*
|
|
144
|
+
* @param {appId: string, redirectUri: string, scopes: string, state: string}
|
|
145
|
+
* @returns {Promise<rpcResponseType<{ authorizationUrl: string; state: string }>>}
|
|
146
|
+
*/
|
|
147
|
+
async generateAuthorizationUrl(appId, redirectUri, scopes, state) {
|
|
148
|
+
return await _a.apiCallback('AppOAuth.generateAuthorizationUrl', [appId, redirectUri, scopes, state]);
|
|
149
|
+
},
|
|
150
|
+
/**
|
|
151
|
+
* Exchange authorization code for access token. Called by platform backend after receiving code.
|
|
152
|
+
*
|
|
153
|
+
* @param {code: string, appId: string, redirectUri: string}
|
|
154
|
+
* @returns {Promise<rpcResponseType<{ accessToken: string; tokenType: string; expiresIn: number; appUserId: string; emote: any }>>}
|
|
155
|
+
*/
|
|
156
|
+
async exchangeCodeForToken(code, appId, redirectUri) {
|
|
157
|
+
return await _a.apiCallback('AppOAuth.exchangeCodeForToken', [code, appId, redirectUri]);
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* Refresh an expired access token for continued API access.
|
|
161
|
+
*
|
|
162
|
+
* @param {appUserId: string, appId: string}
|
|
163
|
+
* @returns {Promise<rpcResponseType<{ accessToken: string; tokenType: string; expiresIn: number; appUserId: string }>>}
|
|
164
|
+
*/
|
|
165
|
+
async refreshToken(appUserId, appId) {
|
|
166
|
+
return await _a.apiCallback('AppOAuth.refreshToken', [appUserId, appId]);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
this.Media = {
|
|
170
|
+
/**
|
|
171
|
+
* Uploads an image to S3 and returns its URL. Replaces any existing image for the conversation.
|
|
172
|
+
*
|
|
173
|
+
* @param {appId: string, conversationId: string, file: any}
|
|
174
|
+
* @returns {Promise<rpcResponseType<{ url: string }>>}
|
|
175
|
+
*/
|
|
176
|
+
async uploadImage(appId, conversationId, file) {
|
|
177
|
+
return await _a.mediaCallback('Media.uploadImage', [appId, conversationId], file);
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
this.TCC = {
|
|
181
|
+
/**
|
|
182
|
+
* Get current model for a conversation
|
|
183
|
+
*
|
|
184
|
+
* @param {conversation_id: string}
|
|
185
|
+
* @returns {Promise<rpcResponseType<{ emote: string; nlp_model: string; assistant: string }>>}
|
|
186
|
+
*/
|
|
187
|
+
async conversation_stats(conversation_id) {
|
|
188
|
+
return await _a.apiCallback('TCC.conversation_stats', [conversation_id]);
|
|
189
|
+
},
|
|
190
|
+
/**
|
|
191
|
+
* Get list of all models available to you
|
|
192
|
+
*
|
|
193
|
+
* @param {conversation_id: string}
|
|
194
|
+
* @returns {Promise<rpcResponseType<{ id: string; name: string; type: string; provider: string }[]>>}
|
|
195
|
+
*/
|
|
196
|
+
async get_models(conversation_id) {
|
|
197
|
+
return await _a.apiCallback('TCC.get_models', [conversation_id]);
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* Changes the model for a conversation, use with caution, may discontinue chat if model is not compatible
|
|
201
|
+
*
|
|
202
|
+
* @param {conversation_id: string, model_id: string, type: string}
|
|
203
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
204
|
+
*/
|
|
205
|
+
async change_to_model(conversation_id, model_id, type) {
|
|
206
|
+
return await _a.apiCallback('TCC.change_to_model', [conversation_id, model_id, type]);
|
|
207
|
+
},
|
|
208
|
+
/**
|
|
209
|
+
* Trigger the ai to act based on a trigger message
|
|
210
|
+
*
|
|
211
|
+
* @param {conversation_id: string, message: string, eta_seconds: number}
|
|
212
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
213
|
+
*/
|
|
214
|
+
async trigger(conversation_id, message, eta_seconds) {
|
|
215
|
+
return await _a.apiCallback('TCC.trigger', [conversation_id, message, eta_seconds]);
|
|
216
|
+
},
|
|
217
|
+
/**
|
|
218
|
+
* This function is used to invoke the llm with a description and instruction
|
|
219
|
+
*
|
|
220
|
+
* @param {conversation_id: string, input: Partial<{ description: string, instruction: string, construct_id: string }> }
|
|
221
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
222
|
+
*/
|
|
223
|
+
async invoke_construct(conversation_id, input) {
|
|
224
|
+
return await _a.apiCallback('TCC.invoke_construct', [conversation_id, input]);
|
|
225
|
+
},
|
|
226
|
+
/**
|
|
227
|
+
* specifies a selected data on the client for the ai to work with
|
|
228
|
+
*
|
|
229
|
+
* @param {conversation_id: string, data: string}
|
|
230
|
+
* @returns {Promise<rpcResponseType<any>>}
|
|
231
|
+
*/
|
|
232
|
+
async select_context(conversation_id, data) {
|
|
233
|
+
return await _a.apiCallback('TCC.select_context', [conversation_id, data]);
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
_a.token_cb = token_cb;
|
|
237
|
+
_a.url = url;
|
|
238
|
+
if (socket_cb)
|
|
239
|
+
this.connectSocket(url, socket_cb);
|
|
240
|
+
}
|
|
241
|
+
async connectSocket(url, socket_cb) {
|
|
242
|
+
try {
|
|
243
|
+
const socket = (0, socket_io_client_1.io)(url, {
|
|
244
|
+
auth: {
|
|
245
|
+
authorization: await _a.token_cb(),
|
|
246
|
+
_scid: (0, exports._scid)()
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
if (socket_cb)
|
|
250
|
+
socket_cb(socket);
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
console.error('Error initializing socket:', error.message);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.RPCClient = RPCClient;
|
|
258
|
+
_a = RPCClient;
|
|
259
|
+
RPCClient.url = 'https://api.tentarclesai.com';
|
|
260
|
+
RPCClient.apiCallback = async (method, params) => {
|
|
261
|
+
try {
|
|
262
|
+
if (!_a.token_cb)
|
|
263
|
+
throw new Error('RPCClient.token_cb is not set');
|
|
264
|
+
const token = await _a.token_cb();
|
|
265
|
+
const response = await fetch(`${_a.url}/rpc`, {
|
|
266
|
+
method: 'POST',
|
|
267
|
+
headers: {
|
|
268
|
+
'Content-Type': 'application/json',
|
|
269
|
+
Authorization: `Bearer ${token}:${(0, exports._scid)()}`,
|
|
270
|
+
},
|
|
271
|
+
body: JSON.stringify({ method, params })
|
|
272
|
+
});
|
|
273
|
+
if (!response.ok) {
|
|
274
|
+
throw new Error(`API error: ${response.status} ${response.statusText}`);
|
|
275
|
+
}
|
|
276
|
+
return await response.json();
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
console.error("Error calling API:", error);
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
RPCClient.mediaCallback = async (method, params, file) => {
|
|
284
|
+
try {
|
|
285
|
+
if (!_a.token_cb)
|
|
286
|
+
throw new Error('RPCClient.token_cb is not set');
|
|
287
|
+
const token = await _a.token_cb();
|
|
288
|
+
const formData = new FormData();
|
|
289
|
+
formData.append('method', method);
|
|
290
|
+
if (params)
|
|
291
|
+
formData.append('params', JSON.stringify(params));
|
|
292
|
+
if (file)
|
|
293
|
+
formData.append('file', file);
|
|
294
|
+
const response = await fetch(`${_a.url}/rpc`, {
|
|
295
|
+
method: 'POST',
|
|
296
|
+
headers: {
|
|
297
|
+
Authorization: `Bearer ${token}:${(0, exports._scid)()}`,
|
|
298
|
+
},
|
|
299
|
+
body: formData
|
|
300
|
+
});
|
|
301
|
+
if (!response.ok) {
|
|
302
|
+
throw new Error(`Media API error: ${response.status} ${response.statusText}`);
|
|
303
|
+
}
|
|
304
|
+
return await response.json();
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
console.error("Error calling Media API:", error);
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
//# sourceMappingURL=ttc_server.js.map
|
|
@@ -0,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U,EAAE,CAAC,CAAC;SACjF;QACD,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;KAChC;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;KACf;AACL,CAAC,AAxBmB,CAwBnB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ZodSchema } from "zod";
|
|
2
|
+
export type f_call = {
|
|
3
|
+
function: string;
|
|
4
|
+
arguments: Record<string, any>;
|
|
5
|
+
};
|
|
6
|
+
export type f_schema = {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
permission?: boolean;
|
|
10
|
+
input_schema: string;
|
|
11
|
+
output_schema: string;
|
|
12
|
+
};
|
|
13
|
+
export type f_response = {
|
|
14
|
+
function: string;
|
|
15
|
+
response: any;
|
|
16
|
+
};
|
|
17
|
+
export type statusType = 'success' | 'error';
|
|
18
|
+
export type ClassType<T = any> = new (...args: any[]) => T;
|
|
19
|
+
export type rpcResponseType = {
|
|
20
|
+
status: statusType;
|
|
21
|
+
data?: any;
|
|
22
|
+
};
|
|
23
|
+
export type RPCMethodInfo = {
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
permission?: boolean;
|
|
27
|
+
input_schema?: string;
|
|
28
|
+
output_schema?: string;
|
|
29
|
+
};
|
|
30
|
+
export type RegistryEntry = {
|
|
31
|
+
param_index: number;
|
|
32
|
+
params: Record<string, any>;
|
|
33
|
+
inputSchema?: ZodSchema<any>;
|
|
34
|
+
outputSchema?: ZodSchema<any>;
|
|
35
|
+
auth?: boolean;
|
|
36
|
+
doc?: string;
|
|
37
|
+
validate?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type ttc_event = 'message' | 'function_call' | 'permission' | 'sentinel_dispatch' | 'sentinel_terminated' | 'construct' | 'status_change';
|
|
40
|
+
export type callbackType = (method: string, params?: any) => Promise<any>;
|
|
41
|
+
export type mediaCallbackType = (method: string, params?: any, file?: File) => Promise<any>;
|
|
42
|
+
export type rpcResponseTypeGeneric<T = any> = {
|
|
43
|
+
status: 'success' | 'error';
|
|
44
|
+
data?: T;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGhC,MAAM,MAAM,MAAM,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACzB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC;CACjB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAE7C,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAE3D,MAAM,MAAM,eAAe,GAAG;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC;CACd,CAAA;AAED,MAAM,MAAM,aAAa,GAAI;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,eAAe,GAAG,YAAY,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,WAAW,GAAG,eAAe,CAAC;AAGjJ,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAC1E,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAG5F,MAAM,MAAM,sBAAsB,CAAC,CAAC,GAAG,GAAG,IAAI;IAC1C,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,CAAC,CAAC;CACZ,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Always use a lightweight custom EventEmitter implementation for both
|
|
3
|
+
* frontend and backend. This avoids bundler/node-builtins issues and
|
|
4
|
+
* provides a consistent API (on/off/once/emit).
|
|
5
|
+
*/
|
|
6
|
+
type Listener = (...args: any[]) => void;
|
|
7
|
+
declare class BrowserEmitter {
|
|
8
|
+
private listeners;
|
|
9
|
+
on(evt: string, fn: Listener): this;
|
|
10
|
+
off(evt: string, fn?: Listener): this;
|
|
11
|
+
once(evt: string, fn: Listener): this;
|
|
12
|
+
emit(evt: string, ...args: any[]): boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function getEventEmitterClass(): any;
|
|
15
|
+
export declare function createEmitter(): BrowserEmitter;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=eventEmitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventEmitter.d.ts","sourceRoot":"","sources":["../../src/utils/eventEmitter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,KAAK,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAEzC,cAAM,cAAc;IAClB,OAAO,CAAC,SAAS,CAAkC;IAEnD,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ;IAK5B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ;IAS9B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ;IAS9B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;CAMjC;AAED,wBAAgB,oBAAoB,QAEnC;AAED,wBAAgB,aAAa,mBAE5B"}
|