@chanl-ai/sdk 2.0.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/adapters/openai.d.ts +106 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +185 -0
- package/dist/adapters/openai.js.map +1 -0
- package/dist/client.d.ts +74 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +293 -0
- package/dist/client.js.map +1 -0
- package/dist/errors/index.d.ts +179 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +319 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/live/index.d.ts +9 -0
- package/dist/live/index.d.ts.map +1 -0
- package/dist/live/index.js +16 -0
- package/dist/live/index.js.map +1 -0
- package/dist/live/live-call.d.ts +48 -0
- package/dist/live/live-call.d.ts.map +1 -0
- package/dist/live/live-call.js +148 -0
- package/dist/live/live-call.js.map +1 -0
- package/dist/live/live-chat.d.ts +71 -0
- package/dist/live/live-chat.d.ts.map +1 -0
- package/dist/live/live-chat.js +95 -0
- package/dist/live/live-chat.js.map +1 -0
- package/dist/live/live-execution.d.ts +55 -0
- package/dist/live/live-execution.d.ts.map +1 -0
- package/dist/live/live-execution.js +170 -0
- package/dist/live/live-execution.js.map +1 -0
- package/dist/live/typed-emitter.d.ts +15 -0
- package/dist/live/typed-emitter.d.ts.map +1 -0
- package/dist/live/typed-emitter.js +40 -0
- package/dist/live/typed-emitter.js.map +1 -0
- package/dist/live/types.d.ts +24 -0
- package/dist/live/types.d.ts.map +1 -0
- package/dist/live/types.js +6 -0
- package/dist/live/types.js.map +1 -0
- package/dist/modules/agents.d.ts +378 -0
- package/dist/modules/agents.d.ts.map +1 -0
- package/dist/modules/agents.js +259 -0
- package/dist/modules/agents.js.map +1 -0
- package/dist/modules/alerts.d.ts +43 -0
- package/dist/modules/alerts.d.ts.map +1 -0
- package/dist/modules/alerts.js +56 -0
- package/dist/modules/alerts.js.map +1 -0
- package/dist/modules/audio.d.ts +47 -0
- package/dist/modules/audio.d.ts.map +1 -0
- package/dist/modules/audio.js +75 -0
- package/dist/modules/audio.js.map +1 -0
- package/dist/modules/auth.d.ts +76 -0
- package/dist/modules/auth.d.ts.map +1 -0
- package/dist/modules/auth.js +59 -0
- package/dist/modules/auth.js.map +1 -0
- package/dist/modules/calls.d.ts +825 -0
- package/dist/modules/calls.d.ts.map +1 -0
- package/dist/modules/calls.js +398 -0
- package/dist/modules/calls.js.map +1 -0
- package/dist/modules/chat.d.ts +165 -0
- package/dist/modules/chat.d.ts.map +1 -0
- package/dist/modules/chat.js +169 -0
- package/dist/modules/chat.js.map +1 -0
- package/dist/modules/health.d.ts +45 -0
- package/dist/modules/health.d.ts.map +1 -0
- package/dist/modules/health.js +22 -0
- package/dist/modules/health.js.map +1 -0
- package/dist/modules/knowledge.d.ts +202 -0
- package/dist/modules/knowledge.d.ts.map +1 -0
- package/dist/modules/knowledge.js +147 -0
- package/dist/modules/knowledge.js.map +1 -0
- package/dist/modules/mcp.d.ts +140 -0
- package/dist/modules/mcp.d.ts.map +1 -0
- package/dist/modules/mcp.js +110 -0
- package/dist/modules/mcp.js.map +1 -0
- package/dist/modules/memory.d.ts +163 -0
- package/dist/modules/memory.d.ts.map +1 -0
- package/dist/modules/memory.js +208 -0
- package/dist/modules/memory.js.map +1 -0
- package/dist/modules/personas.d.ts +168 -0
- package/dist/modules/personas.d.ts.map +1 -0
- package/dist/modules/personas.js +106 -0
- package/dist/modules/personas.js.map +1 -0
- package/dist/modules/prompts.d.ts +128 -0
- package/dist/modules/prompts.d.ts.map +1 -0
- package/dist/modules/prompts.js +93 -0
- package/dist/modules/prompts.js.map +1 -0
- package/dist/modules/scenarios.d.ts +294 -0
- package/dist/modules/scenarios.d.ts.map +1 -0
- package/dist/modules/scenarios.js +349 -0
- package/dist/modules/scenarios.js.map +1 -0
- package/dist/modules/scorecard.d.ts +642 -0
- package/dist/modules/scorecard.d.ts.map +1 -0
- package/dist/modules/scorecard.js +327 -0
- package/dist/modules/scorecard.js.map +1 -0
- package/dist/modules/tools.d.ts +222 -0
- package/dist/modules/tools.d.ts.map +1 -0
- package/dist/modules/tools.js +302 -0
- package/dist/modules/tools.js.map +1 -0
- package/dist/modules/toolsets.d.ts +173 -0
- package/dist/modules/toolsets.d.ts.map +1 -0
- package/dist/modules/toolsets.js +216 -0
- package/dist/modules/toolsets.js.map +1 -0
- package/dist/modules/transcript.d.ts +60 -0
- package/dist/modules/transcript.d.ts.map +1 -0
- package/dist/modules/transcript.js +69 -0
- package/dist/modules/transcript.js.map +1 -0
- package/dist/modules/workspace.d.ts +48 -0
- package/dist/modules/workspace.d.ts.map +1 -0
- package/dist/modules/workspace.js +49 -0
- package/dist/modules/workspace.js.map +1 -0
- package/dist/types/api.d.ts +8 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +25 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/config.d.ts +70 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/memory.d.ts +243 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +9 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/types/tool-calls.d.ts +61 -0
- package/dist/types/tool-calls.d.ts.map +1 -0
- package/dist/types/tool-calls.js +9 -0
- package/dist/types/tool-calls.js.map +1 -0
- package/dist/types/tools.d.ts +321 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +9 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/toolsets.d.ts +149 -0
- package/dist/types/toolsets.d.ts.map +1 -0
- package/dist/types/toolsets.js +8 -0
- package/dist/types/toolsets.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ChatModule - SDK module for chat session management
|
|
4
|
+
*
|
|
5
|
+
* Provides operations for creating and managing text chat sessions
|
|
6
|
+
* with AI agents via interactions-service. This is the canonical way
|
|
7
|
+
* to test agents via text — it routes through interactions-service
|
|
8
|
+
* which owns the full lifecycle (Interaction, Transcript, billing,
|
|
9
|
+
* evaluation).
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChatModule = void 0;
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// MODULE
|
|
15
|
+
// ============================================================================
|
|
16
|
+
const live_chat_1 = require("../live/live-chat");
|
|
17
|
+
class ChatModule {
|
|
18
|
+
constructor(sdk) {
|
|
19
|
+
this.sdk = sdk;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a new chat session with an agent
|
|
23
|
+
*
|
|
24
|
+
* Creates a session via interactions-service which manages the full
|
|
25
|
+
* lifecycle including transcription, billing, and evaluation.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const { data } = await sdk.chat.createSession('ws_123', 'agent_abc', {
|
|
30
|
+
* internal: true,
|
|
31
|
+
* scorecardId: 'sc_456'
|
|
32
|
+
* });
|
|
33
|
+
* console.log('Session:', data.sessionId);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
async createSession(agentId, options) {
|
|
37
|
+
return this.sdk.request('POST', `/api/v1/interactions/chat?agentId=${encodeURIComponent(agentId)}`, options || {});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Send a message to an active chat session
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const { data } = await sdk.chat.sendMessage('ws_123', 'session_abc', 'Hello!');
|
|
45
|
+
* console.log('Reply:', data.message);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
async sendMessage(sessionId, message) {
|
|
49
|
+
return this.sdk.request('POST', `/api/v1/interactions/${sessionId}/message`, { message });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Send a message and stream the response in real time.
|
|
53
|
+
*
|
|
54
|
+
* The backend uses Vercel AI SDK's `pipeTextStreamToResponse()` which
|
|
55
|
+
* sends raw UTF-8 text chunks (not SSE JSON). Each chunk is forwarded
|
|
56
|
+
* to the `onChunk` callback as it arrives.
|
|
57
|
+
*
|
|
58
|
+
* Note: Streaming returns `{ message, latencyMs }` only — tool calls
|
|
59
|
+
* and usage metadata are not available in the stream. Use `sendMessage()`
|
|
60
|
+
* for full metadata, or fetch message history after streaming completes.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const response = await sdk.chat.streamMessage('ws_123', 'session_abc', 'Hello!', (chunk) => {
|
|
65
|
+
* process.stdout.write(chunk);
|
|
66
|
+
* });
|
|
67
|
+
* console.log('\nFull response:', response.data.message);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
async streamMessage(sessionId, message, onChunk) {
|
|
71
|
+
const startTime = Date.now();
|
|
72
|
+
const response = await this.sdk.requestStream('POST', `/api/v1/interactions/${sessionId}/message?stream=true`, { message });
|
|
73
|
+
const body = response.body;
|
|
74
|
+
if (!body) {
|
|
75
|
+
throw new Error('No response body for stream');
|
|
76
|
+
}
|
|
77
|
+
const reader = body.getReader();
|
|
78
|
+
const decoder = new TextDecoder();
|
|
79
|
+
let fullText = '';
|
|
80
|
+
try {
|
|
81
|
+
for (;;) {
|
|
82
|
+
const { done, value } = await reader.read();
|
|
83
|
+
if (done)
|
|
84
|
+
break;
|
|
85
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
86
|
+
if (chunk) {
|
|
87
|
+
fullText += chunk;
|
|
88
|
+
onChunk(chunk);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
reader.releaseLock();
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
data: {
|
|
98
|
+
sessionId,
|
|
99
|
+
message: fullText,
|
|
100
|
+
latencyMs: Date.now() - startTime,
|
|
101
|
+
},
|
|
102
|
+
message: 'Success',
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get message history for a chat session
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const { data } = await sdk.chat.getMessages('ws_123', 'session_abc');
|
|
112
|
+
* data.messages.forEach(m => console.log(`${m.role}: ${m.content}`));
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
async getMessages(sessionId) {
|
|
116
|
+
return this.sdk.request('GET', `/api/v1/interactions/${sessionId}/messages`);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* End a chat session
|
|
120
|
+
*
|
|
121
|
+
* Finalizes the session, creating a transcript and triggering
|
|
122
|
+
* evaluation if a scorecard is configured.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const { data } = await sdk.chat.endSession('ws_123', 'session_abc');
|
|
127
|
+
* console.log('Ended:', data.success);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
async endSession(sessionId, options) {
|
|
131
|
+
return this.sdk.request('POST', `/api/v1/interactions/${sessionId}/end`, options || {});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Delete a chat session and all associated data
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const { data } = await sdk.chat.deleteSession('ws_123', 'session_abc');
|
|
139
|
+
* console.log('Deleted:', data.deleted);
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
async deleteSession(sessionId) {
|
|
143
|
+
return this.sdk.request('DELETE', `/api/v1/interactions/${sessionId}/chat`);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Create a chat session and return a LiveChat wrapper
|
|
147
|
+
*
|
|
148
|
+
* Combines `createSession()` with event-driven messaging. The returned
|
|
149
|
+
* `LiveChat` emits events for messages and session lifecycle.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const chat = await sdk.chat.session('agent_abc');
|
|
154
|
+
* chat.on('message', (msg) => console.log('Agent:', msg.message));
|
|
155
|
+
*
|
|
156
|
+
* const reply = await chat.send('Hello!');
|
|
157
|
+
* await chat.end();
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
async session(agentId, options) {
|
|
161
|
+
const response = await this.createSession(agentId, options);
|
|
162
|
+
if (!response.success || !response.data) {
|
|
163
|
+
throw new Error(response.message || 'Failed to create chat session');
|
|
164
|
+
}
|
|
165
|
+
return new live_chat_1.LiveChat(this.sdk, response.data);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.ChatModule = ChatModule;
|
|
169
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/modules/chat.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAmEH,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,iDAA6C;AAE7C,MAAa,UAAU;IACrB,YAAoB,GAAa;QAAb,QAAG,GAAH,GAAG,CAAU;IAAG,CAAC;IAErC;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,aAAa,CACjB,OAAe,EACf,OAAgC;QAEhC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CACrB,MAAM,EACN,qCAAqC,kBAAkB,CAAC,OAAO,CAAC,EAAE,EAClE,OAAO,IAAI,EAAE,CACd,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,WAAW,CACf,SAAiB,EACjB,OAAe;QAEf,OAAO,IAAI,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HealthStatus {
|
|
4
|
+
status: 'healthy' | 'unhealthy';
|
|
5
|
+
timestamp: string;
|
|
6
|
+
version: string;
|
|
7
|
+
uptime: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DetailedHealthStatus {
|
|
10
|
+
status: 'healthy' | 'unhealthy';
|
|
11
|
+
timestamp: string;
|
|
12
|
+
version: string;
|
|
13
|
+
uptime: number;
|
|
14
|
+
components: {
|
|
15
|
+
database: {
|
|
16
|
+
status: 'healthy' | 'unhealthy';
|
|
17
|
+
responseTime: number;
|
|
18
|
+
};
|
|
19
|
+
redis?: {
|
|
20
|
+
status: 'healthy' | 'unhealthy';
|
|
21
|
+
responseTime: number;
|
|
22
|
+
};
|
|
23
|
+
deepgram?: {
|
|
24
|
+
status: 'healthy' | 'unhealthy';
|
|
25
|
+
responseTime: number;
|
|
26
|
+
};
|
|
27
|
+
openai?: {
|
|
28
|
+
status: 'healthy' | 'unhealthy';
|
|
29
|
+
responseTime: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare class HealthModule {
|
|
34
|
+
private sdk;
|
|
35
|
+
constructor(sdk: ChanlSDK);
|
|
36
|
+
/**
|
|
37
|
+
* Get basic health status
|
|
38
|
+
*/
|
|
39
|
+
getHealth(): Promise<ApiResponse<HealthStatus>>;
|
|
40
|
+
/**
|
|
41
|
+
* Get detailed health status
|
|
42
|
+
*/
|
|
43
|
+
getDetailedHealth(): Promise<ApiResponse<DetailedHealthStatus>>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/modules/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QACV,QAAQ,EAAE;YACR,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;YAChC,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,KAAK,CAAC,EAAE;YACN,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;YAChC,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,QAAQ,CAAC,EAAE;YACT,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;YAChC,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,MAAM,CAAC,EAAE;YACP,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;YAChC,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;CACH;AAED,qBAAa,YAAY;IACX,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,QAAQ;IAEjC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAIrD;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;CAGtE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HealthModule = void 0;
|
|
4
|
+
class HealthModule {
|
|
5
|
+
constructor(sdk) {
|
|
6
|
+
this.sdk = sdk;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get basic health status
|
|
10
|
+
*/
|
|
11
|
+
async getHealth() {
|
|
12
|
+
return this.sdk.request('GET', '/health');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get detailed health status
|
|
16
|
+
*/
|
|
17
|
+
async getDetailedHealth() {
|
|
18
|
+
return this.sdk.request('GET', '/health/ready');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.HealthModule = HealthModule;
|
|
22
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/modules/health.ts"],"names":[],"mappings":";;;AAmCA,MAAa,YAAY;IACvB,YAAoB,GAAa;QAAb,QAAG,GAAH,GAAG,CAAU;IAAG,CAAC;IAErC;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAClD,CAAC;CACF;AAhBD,oCAgBC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { ChanlSDK } from "../client";
|
|
2
|
+
import { ApiResponse } from "../types/config";
|
|
3
|
+
export type KnowledgeSource = "text" | "url" | "file" | "manual" | "document" | "faq" | "api_docs" | "transcript";
|
|
4
|
+
export type ProcessingStatus = "pending" | "processing" | "completed" | "failed";
|
|
5
|
+
export interface KnowledgeMetadata {
|
|
6
|
+
category?: string;
|
|
7
|
+
tags?: string[];
|
|
8
|
+
url?: string;
|
|
9
|
+
author?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CrawlOptions {
|
|
12
|
+
/** Crawl depth: 0 = single page only, 1 = page + direct links, 2 = two levels deep */
|
|
13
|
+
depth?: number;
|
|
14
|
+
/** Maximum number of pages to crawl (limit: 50) */
|
|
15
|
+
maxPages?: number;
|
|
16
|
+
/** Only follow links on the same domain */
|
|
17
|
+
sameDomainOnly?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ChunkingOptions {
|
|
20
|
+
/** Target chunk size in tokens (default: 512) */
|
|
21
|
+
chunkSizeTokens?: number;
|
|
22
|
+
/** Overlap between chunks in tokens (default: 50) */
|
|
23
|
+
overlapTokens?: number;
|
|
24
|
+
/** Preserve sentence boundaries (default: true) */
|
|
25
|
+
preserveSentences?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface Knowledge {
|
|
28
|
+
id: string;
|
|
29
|
+
_id?: string;
|
|
30
|
+
title: string;
|
|
31
|
+
content?: string;
|
|
32
|
+
source: KnowledgeSource;
|
|
33
|
+
processingStatus: ProcessingStatus;
|
|
34
|
+
processingProgress?: number;
|
|
35
|
+
taskId?: string;
|
|
36
|
+
folderId?: string;
|
|
37
|
+
metadata?: KnowledgeMetadata;
|
|
38
|
+
externalReferenceIds?: Record<string, string>;
|
|
39
|
+
isEnabled?: boolean;
|
|
40
|
+
chunkCount?: number;
|
|
41
|
+
tokenCount?: number;
|
|
42
|
+
createdAt?: string;
|
|
43
|
+
updatedAt?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface KnowledgeChunk {
|
|
46
|
+
id: string;
|
|
47
|
+
_id?: string;
|
|
48
|
+
knowledgeId: string;
|
|
49
|
+
content: string;
|
|
50
|
+
index: number;
|
|
51
|
+
embedding?: number[];
|
|
52
|
+
tokenCount?: number;
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Unified create knowledge data - supports text, URL, and file sources
|
|
57
|
+
*/
|
|
58
|
+
export interface CreateKnowledgeData {
|
|
59
|
+
/** Title of the knowledge entry */
|
|
60
|
+
title: string;
|
|
61
|
+
/** Source type: "text" for direct content, "url" for web fetch, "file" for uploads */
|
|
62
|
+
source: KnowledgeSource;
|
|
63
|
+
/** Content (required for source="text" or legacy sources) */
|
|
64
|
+
content?: string;
|
|
65
|
+
/** URL to fetch (required for source="url") */
|
|
66
|
+
url?: string;
|
|
67
|
+
/** Folder ID to organize the document */
|
|
68
|
+
folderId?: string;
|
|
69
|
+
/** Additional metadata */
|
|
70
|
+
metadata?: KnowledgeMetadata;
|
|
71
|
+
/** Whether the entry is enabled for search */
|
|
72
|
+
isEnabled?: boolean;
|
|
73
|
+
/** External reference IDs for multi-tenant filtering */
|
|
74
|
+
externalReferenceIds?: Record<string, string>;
|
|
75
|
+
/** Chunking options for document processing */
|
|
76
|
+
chunkingOptions?: ChunkingOptions;
|
|
77
|
+
/** URL crawling options (only for source="url") */
|
|
78
|
+
crawlOptions?: CrawlOptions;
|
|
79
|
+
}
|
|
80
|
+
export interface UpdateKnowledgeData {
|
|
81
|
+
title?: string;
|
|
82
|
+
content?: string;
|
|
83
|
+
folderId?: string;
|
|
84
|
+
metadata?: KnowledgeMetadata;
|
|
85
|
+
isEnabled?: boolean;
|
|
86
|
+
externalReferenceIds?: Record<string, string>;
|
|
87
|
+
}
|
|
88
|
+
export interface KnowledgeFilters {
|
|
89
|
+
search?: string;
|
|
90
|
+
source?: KnowledgeSource;
|
|
91
|
+
folderId?: string;
|
|
92
|
+
isEnabled?: boolean;
|
|
93
|
+
processingStatus?: ProcessingStatus;
|
|
94
|
+
externalReferenceIds?: Record<string, string>;
|
|
95
|
+
page?: number;
|
|
96
|
+
limit?: number;
|
|
97
|
+
}
|
|
98
|
+
export interface SearchKnowledgeData {
|
|
99
|
+
query: string;
|
|
100
|
+
/** Search mode: hybrid (default), vector, or text */
|
|
101
|
+
mode?: "hybrid" | "vector" | "text";
|
|
102
|
+
/** Maximum number of results */
|
|
103
|
+
limit?: number;
|
|
104
|
+
/** Filter by external reference IDs */
|
|
105
|
+
externalReferenceIds?: Record<string, string>;
|
|
106
|
+
/** Minimum similarity score (0-1) */
|
|
107
|
+
minScore?: number;
|
|
108
|
+
}
|
|
109
|
+
export interface SearchResult {
|
|
110
|
+
id: string;
|
|
111
|
+
knowledgeId: string;
|
|
112
|
+
title: string;
|
|
113
|
+
content: string;
|
|
114
|
+
score: number;
|
|
115
|
+
metadata?: Record<string, unknown>;
|
|
116
|
+
}
|
|
117
|
+
export interface SearchResponse {
|
|
118
|
+
results: SearchResult[];
|
|
119
|
+
query: string;
|
|
120
|
+
mode: string;
|
|
121
|
+
totalResults: number;
|
|
122
|
+
}
|
|
123
|
+
export interface KnowledgeListResponse {
|
|
124
|
+
items: Knowledge[];
|
|
125
|
+
total: number;
|
|
126
|
+
pagination?: {
|
|
127
|
+
page: number;
|
|
128
|
+
limit: number;
|
|
129
|
+
totalPages: number;
|
|
130
|
+
hasNext: boolean;
|
|
131
|
+
hasPrev: boolean;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export interface ProcessingTaskResponse {
|
|
135
|
+
id: string;
|
|
136
|
+
status: ProcessingStatus;
|
|
137
|
+
progress: number;
|
|
138
|
+
currentStep?: string;
|
|
139
|
+
documentId?: string;
|
|
140
|
+
error?: string;
|
|
141
|
+
result?: {
|
|
142
|
+
chunkCount: number;
|
|
143
|
+
wordCount: number;
|
|
144
|
+
characterCount: number;
|
|
145
|
+
processingTimeMs: number;
|
|
146
|
+
};
|
|
147
|
+
createdAt: string;
|
|
148
|
+
startedAt?: string;
|
|
149
|
+
completedAt?: string;
|
|
150
|
+
}
|
|
151
|
+
export declare class KnowledgeModule {
|
|
152
|
+
private sdk;
|
|
153
|
+
constructor(sdk: ChanlSDK);
|
|
154
|
+
/**
|
|
155
|
+
* List all knowledge entries with optional filters
|
|
156
|
+
*/
|
|
157
|
+
list(filters?: KnowledgeFilters): Promise<ApiResponse<KnowledgeListResponse>>;
|
|
158
|
+
/**
|
|
159
|
+
* Get a single knowledge entry by ID
|
|
160
|
+
*/
|
|
161
|
+
get(id: string): Promise<ApiResponse<Knowledge>>;
|
|
162
|
+
/**
|
|
163
|
+
* Create a new knowledge entry (unified endpoint)
|
|
164
|
+
*
|
|
165
|
+
* Supports three input methods:
|
|
166
|
+
* - source='text': Direct text content (sync, immediate completion)
|
|
167
|
+
* - source='url': Fetch from URL (async, returns taskId)
|
|
168
|
+
* - source='file': Upload file via multipart (async, returns taskId)
|
|
169
|
+
*
|
|
170
|
+
* For file uploads, use createFromFile() method instead.
|
|
171
|
+
*/
|
|
172
|
+
create(data: CreateKnowledgeData): Promise<ApiResponse<Knowledge>>;
|
|
173
|
+
/**
|
|
174
|
+
* Create knowledge from a file upload
|
|
175
|
+
*
|
|
176
|
+
* @param file - File buffer or Blob
|
|
177
|
+
* @param filename - Original filename
|
|
178
|
+
* @param options - Additional options (title, folderId, etc.)
|
|
179
|
+
*/
|
|
180
|
+
createFromFile(file: Buffer | Blob, filename: string, options?: Omit<CreateKnowledgeData, "source" | "content" | "url">): Promise<ApiResponse<Knowledge>>;
|
|
181
|
+
/**
|
|
182
|
+
* Update an existing knowledge entry
|
|
183
|
+
*/
|
|
184
|
+
update(id: string, data: UpdateKnowledgeData): Promise<ApiResponse<Knowledge>>;
|
|
185
|
+
/**
|
|
186
|
+
* Delete a knowledge entry
|
|
187
|
+
*/
|
|
188
|
+
delete(id: string): Promise<ApiResponse<void>>;
|
|
189
|
+
/**
|
|
190
|
+
* Search knowledge base
|
|
191
|
+
*/
|
|
192
|
+
search(data: SearchKnowledgeData): Promise<ApiResponse<SearchResponse>>;
|
|
193
|
+
/**
|
|
194
|
+
* Get processing task status
|
|
195
|
+
*/
|
|
196
|
+
getTaskStatus(taskId: string): Promise<ApiResponse<ProcessingTaskResponse>>;
|
|
197
|
+
/**
|
|
198
|
+
* Get chunks for a knowledge entry
|
|
199
|
+
*/
|
|
200
|
+
getChunks(knowledgeId: string): Promise<ApiResponse<KnowledgeChunk[]>>;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/modules/knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MA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AE,MAAM,GAAG,IAAI,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,SAAS,GAAG,KAAK,CAAC,GAChE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAgDlC;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAIpF;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAIpD;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAI7E;;OAEG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAIjF;;OAEG;IACG,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC;CAG7E"}
|
|
@@ -0,0 +1,147 @@
|
|
|
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.KnowledgeModule = void 0;
|
|
7
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// KNOWLEDGE MODULE
|
|
10
|
+
// ============================================================================
|
|
11
|
+
class KnowledgeModule {
|
|
12
|
+
constructor(sdk) {
|
|
13
|
+
this.sdk = sdk;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* List all knowledge entries with optional filters
|
|
17
|
+
*/
|
|
18
|
+
async list(filters) {
|
|
19
|
+
const queryParams = new URLSearchParams();
|
|
20
|
+
if (filters?.search) {
|
|
21
|
+
queryParams.append("search", filters.search);
|
|
22
|
+
}
|
|
23
|
+
if (filters?.source) {
|
|
24
|
+
queryParams.append("source", filters.source);
|
|
25
|
+
}
|
|
26
|
+
if (filters?.folderId) {
|
|
27
|
+
queryParams.append("folderId", filters.folderId);
|
|
28
|
+
}
|
|
29
|
+
if (filters?.isEnabled !== undefined) {
|
|
30
|
+
queryParams.append("isEnabled", String(filters.isEnabled));
|
|
31
|
+
}
|
|
32
|
+
if (filters?.processingStatus) {
|
|
33
|
+
queryParams.append("processingStatus", filters.processingStatus);
|
|
34
|
+
}
|
|
35
|
+
if (filters?.externalReferenceIds) {
|
|
36
|
+
queryParams.append("externalReferenceIds", JSON.stringify(filters.externalReferenceIds));
|
|
37
|
+
}
|
|
38
|
+
if (filters?.page) {
|
|
39
|
+
queryParams.append("page", filters.page.toString());
|
|
40
|
+
}
|
|
41
|
+
if (filters?.limit) {
|
|
42
|
+
queryParams.append("limit", filters.limit.toString());
|
|
43
|
+
}
|
|
44
|
+
const url = `/api/v1/knowledge${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
45
|
+
return this.sdk.request("GET", url);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get a single knowledge entry by ID
|
|
49
|
+
*/
|
|
50
|
+
async get(id) {
|
|
51
|
+
return this.sdk.request("GET", `/api/v1/knowledge/${id}`);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create a new knowledge entry (unified endpoint)
|
|
55
|
+
*
|
|
56
|
+
* Supports three input methods:
|
|
57
|
+
* - source='text': Direct text content (sync, immediate completion)
|
|
58
|
+
* - source='url': Fetch from URL (async, returns taskId)
|
|
59
|
+
* - source='file': Upload file via multipart (async, returns taskId)
|
|
60
|
+
*
|
|
61
|
+
* For file uploads, use createFromFile() method instead.
|
|
62
|
+
*/
|
|
63
|
+
async create(data) {
|
|
64
|
+
return this.sdk.request("POST", "/api/v1/knowledge", data);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create knowledge from a file upload
|
|
68
|
+
*
|
|
69
|
+
* @param file - File buffer or Blob
|
|
70
|
+
* @param filename - Original filename
|
|
71
|
+
* @param options - Additional options (title, folderId, etc.)
|
|
72
|
+
*/
|
|
73
|
+
async createFromFile(file, filename, options) {
|
|
74
|
+
const formData = new form_data_1.default();
|
|
75
|
+
// Add file - use form-data package for Node.js compatibility
|
|
76
|
+
if (file instanceof Buffer) {
|
|
77
|
+
formData.append("file", file, { filename });
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// For Blob (browser), convert to buffer first
|
|
81
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
82
|
+
formData.append("file", Buffer.from(arrayBuffer), { filename });
|
|
83
|
+
}
|
|
84
|
+
// Add source
|
|
85
|
+
formData.append("source", "file");
|
|
86
|
+
// Add optional fields
|
|
87
|
+
if (options?.title) {
|
|
88
|
+
formData.append("title", options.title);
|
|
89
|
+
}
|
|
90
|
+
if (options?.folderId) {
|
|
91
|
+
formData.append("folderId", options.folderId);
|
|
92
|
+
}
|
|
93
|
+
if (options?.metadata) {
|
|
94
|
+
// Filter out undefined values and only append if there's actual data
|
|
95
|
+
const cleanMetadata = Object.fromEntries(Object.entries(options.metadata).filter(([, v]) => v !== undefined));
|
|
96
|
+
if (Object.keys(cleanMetadata).length > 0) {
|
|
97
|
+
formData.append("metadata", JSON.stringify(cleanMetadata));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (options?.isEnabled !== undefined) {
|
|
101
|
+
formData.append("isEnabled", String(options.isEnabled));
|
|
102
|
+
}
|
|
103
|
+
if (options?.externalReferenceIds) {
|
|
104
|
+
formData.append("externalReferenceIds", JSON.stringify(options.externalReferenceIds));
|
|
105
|
+
}
|
|
106
|
+
if (options?.chunkingOptions) {
|
|
107
|
+
formData.append("chunkingOptions", JSON.stringify(options.chunkingOptions));
|
|
108
|
+
}
|
|
109
|
+
return this.sdk.request("POST", "/api/v1/knowledge", formData, {
|
|
110
|
+
headers: {
|
|
111
|
+
...formData.getHeaders(),
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Update an existing knowledge entry
|
|
117
|
+
*/
|
|
118
|
+
async update(id, data) {
|
|
119
|
+
return this.sdk.request("PATCH", `/api/v1/knowledge/${id}`, data);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Delete a knowledge entry
|
|
123
|
+
*/
|
|
124
|
+
async delete(id) {
|
|
125
|
+
return this.sdk.request("DELETE", `/api/v1/knowledge/${id}`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Search knowledge base
|
|
129
|
+
*/
|
|
130
|
+
async search(data) {
|
|
131
|
+
return this.sdk.request("POST", "/api/v1/knowledge/search", data);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get processing task status
|
|
135
|
+
*/
|
|
136
|
+
async getTaskStatus(taskId) {
|
|
137
|
+
return this.sdk.request("GET", `/api/v1/knowledge/tasks/${taskId}`);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get chunks for a knowledge entry
|
|
141
|
+
*/
|
|
142
|
+
async getChunks(knowledgeId) {
|
|
143
|
+
return this.sdk.request("GET", `/api/v1/knowledge/${knowledgeId}/chunks`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.KnowledgeModule = KnowledgeModule;
|
|
147
|
+
//# sourceMappingURL=knowledge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.js","sourceRoot":"","sources":["../../src/modules/knowledge.ts"],"names":[],"mappings":";;;;;;AAEA,0DAAiC;AAyKjC,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,MAAa,eAAe;IAC1B,YAAoB,GAAa;QAAb,QAAG,GAAH,GAAG,CAAU;IAAG,CAAC;IAEr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