@simfinity/constellation-client 1.0.8 → 1.0.10
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/index.cjs +38 -2
- package/dist/index.d.cts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +38 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,39 @@ var WebClient = class {
|
|
|
31
31
|
this.sessionId = null;
|
|
32
32
|
this.config = config;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Retrieve the list of available tools:
|
|
36
|
+
* Tools, or functions, can be exposed to & added to the model's context, allowing it
|
|
37
|
+
* to use them during the session as part of its response creation process. In order to add
|
|
38
|
+
* a tool to the session context, it must be listed (by name) at session creation time
|
|
39
|
+
* (see startSession(...) function)
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Tools are remote functions exposed by MCP servers and integrated by the constellation server
|
|
43
|
+
*
|
|
44
|
+
* @exception
|
|
45
|
+
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
46
|
+
*/
|
|
47
|
+
async fetchSupportedTools() {
|
|
48
|
+
const response = await fetch(`${this.config.sessionEndpoint}/supported_tools`, {
|
|
49
|
+
method: "GET",
|
|
50
|
+
headers: {
|
|
51
|
+
"Authorization": `Bearer ${this.config.key}`,
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
"Accept": "application/json"
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
throw new Error(`Could not fetch the list of available tools
|
|
58
|
+
[${response.status}:${response.statusText}]`);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const result = await response.json();
|
|
62
|
+
return result != null ? result : [];
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw `Failed to read session create response: ${error}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
34
67
|
/**
|
|
35
68
|
* Start a persistent chat room on the server, allowing for re-connection,
|
|
36
69
|
* when the streaming connection is lost. Once a session was started it must
|
|
@@ -41,15 +74,18 @@ var WebClient = class {
|
|
|
41
74
|
*
|
|
42
75
|
* @param audioEnabled whether this session can receive & produce audio as well as text
|
|
43
76
|
* @param voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
77
|
+
* @param tools a list of tool names to be included in this session. These must be matching the
|
|
78
|
+
* names returned by 'fetchAvailableTools()'.
|
|
44
79
|
*
|
|
45
80
|
* @exception
|
|
46
81
|
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
47
82
|
*/
|
|
48
|
-
async startSession(audioEnabled, voiceName) {
|
|
83
|
+
async startSession(audioEnabled, voiceName, tools = []) {
|
|
49
84
|
const prepareBody = {
|
|
50
85
|
llmProvider: this.config.llm,
|
|
51
86
|
audioEnabled,
|
|
52
|
-
voiceName
|
|
87
|
+
voiceName,
|
|
88
|
+
includeTools: tools
|
|
53
89
|
};
|
|
54
90
|
const response = await fetch(`${this.config.sessionEndpoint}/prepare_session`, {
|
|
55
91
|
method: "POST",
|
package/dist/index.d.cts
CHANGED
|
@@ -70,6 +70,16 @@ interface EventHandlers {
|
|
|
70
70
|
onTranscriptResponse?: (transcript: string) => void;
|
|
71
71
|
onTechnicalError?: (error: string) => void;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Description of an available tool that can be added to a session context.
|
|
75
|
+
* Tools included in the session context can be used by the AI model during the session.
|
|
76
|
+
* Tools (or functions) can be many things, for example a calendar manager, allowing
|
|
77
|
+
* the model to manage the user's schedule.
|
|
78
|
+
*/
|
|
79
|
+
interface ToolDescription {
|
|
80
|
+
name: string;
|
|
81
|
+
description: string;
|
|
82
|
+
}
|
|
73
83
|
/**
|
|
74
84
|
* This class is a code wrapper to integrate the Simfinity constellation server.
|
|
75
85
|
* The constellation server is a proxy managing streaming sessions with third party LLMs.
|
|
@@ -83,6 +93,20 @@ declare class WebClient {
|
|
|
83
93
|
private ws;
|
|
84
94
|
private sessionId;
|
|
85
95
|
constructor(config: WebClientConfig);
|
|
96
|
+
/**
|
|
97
|
+
* Retrieve the list of available tools:
|
|
98
|
+
* Tools, or functions, can be exposed to & added to the model's context, allowing it
|
|
99
|
+
* to use them during the session as part of its response creation process. In order to add
|
|
100
|
+
* a tool to the session context, it must be listed (by name) at session creation time
|
|
101
|
+
* (see startSession(...) function)
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* Tools are remote functions exposed by MCP servers and integrated by the constellation server
|
|
105
|
+
*
|
|
106
|
+
* @exception
|
|
107
|
+
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
108
|
+
*/
|
|
109
|
+
fetchSupportedTools(): Promise<ToolDescription[]>;
|
|
86
110
|
/**
|
|
87
111
|
* Start a persistent chat room on the server, allowing for re-connection,
|
|
88
112
|
* when the streaming connection is lost. Once a session was started it must
|
|
@@ -93,11 +117,13 @@ declare class WebClient {
|
|
|
93
117
|
*
|
|
94
118
|
* @param audioEnabled whether this session can receive & produce audio as well as text
|
|
95
119
|
* @param voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
120
|
+
* @param tools a list of tool names to be included in this session. These must be matching the
|
|
121
|
+
* names returned by 'fetchAvailableTools()'.
|
|
96
122
|
*
|
|
97
123
|
* @exception
|
|
98
124
|
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
99
125
|
*/
|
|
100
|
-
startSession(audioEnabled: boolean, voiceName?: string): Promise<void>;
|
|
126
|
+
startSession(audioEnabled: boolean, voiceName?: string, tools?: string[]): Promise<void>;
|
|
101
127
|
/**
|
|
102
128
|
* Close an opened, persistent chat room, effectively killing the streaming as well if still opened.
|
|
103
129
|
* If there is no active session, this method does nothing.
|
|
@@ -206,4 +232,4 @@ declare class WebClient {
|
|
|
206
232
|
private send;
|
|
207
233
|
}
|
|
208
234
|
|
|
209
|
-
export { type EventHandlers, type LlmType, type SessionConfig, WebClient, type WebClientConfig };
|
|
235
|
+
export { type EventHandlers, type LlmType, type SessionConfig, type ToolDescription, WebClient, type WebClientConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,16 @@ interface EventHandlers {
|
|
|
70
70
|
onTranscriptResponse?: (transcript: string) => void;
|
|
71
71
|
onTechnicalError?: (error: string) => void;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Description of an available tool that can be added to a session context.
|
|
75
|
+
* Tools included in the session context can be used by the AI model during the session.
|
|
76
|
+
* Tools (or functions) can be many things, for example a calendar manager, allowing
|
|
77
|
+
* the model to manage the user's schedule.
|
|
78
|
+
*/
|
|
79
|
+
interface ToolDescription {
|
|
80
|
+
name: string;
|
|
81
|
+
description: string;
|
|
82
|
+
}
|
|
73
83
|
/**
|
|
74
84
|
* This class is a code wrapper to integrate the Simfinity constellation server.
|
|
75
85
|
* The constellation server is a proxy managing streaming sessions with third party LLMs.
|
|
@@ -83,6 +93,20 @@ declare class WebClient {
|
|
|
83
93
|
private ws;
|
|
84
94
|
private sessionId;
|
|
85
95
|
constructor(config: WebClientConfig);
|
|
96
|
+
/**
|
|
97
|
+
* Retrieve the list of available tools:
|
|
98
|
+
* Tools, or functions, can be exposed to & added to the model's context, allowing it
|
|
99
|
+
* to use them during the session as part of its response creation process. In order to add
|
|
100
|
+
* a tool to the session context, it must be listed (by name) at session creation time
|
|
101
|
+
* (see startSession(...) function)
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* Tools are remote functions exposed by MCP servers and integrated by the constellation server
|
|
105
|
+
*
|
|
106
|
+
* @exception
|
|
107
|
+
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
108
|
+
*/
|
|
109
|
+
fetchSupportedTools(): Promise<ToolDescription[]>;
|
|
86
110
|
/**
|
|
87
111
|
* Start a persistent chat room on the server, allowing for re-connection,
|
|
88
112
|
* when the streaming connection is lost. Once a session was started it must
|
|
@@ -93,11 +117,13 @@ declare class WebClient {
|
|
|
93
117
|
*
|
|
94
118
|
* @param audioEnabled whether this session can receive & produce audio as well as text
|
|
95
119
|
* @param voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
120
|
+
* @param tools a list of tool names to be included in this session. These must be matching the
|
|
121
|
+
* names returned by 'fetchAvailableTools()'.
|
|
96
122
|
*
|
|
97
123
|
* @exception
|
|
98
124
|
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
99
125
|
*/
|
|
100
|
-
startSession(audioEnabled: boolean, voiceName?: string): Promise<void>;
|
|
126
|
+
startSession(audioEnabled: boolean, voiceName?: string, tools?: string[]): Promise<void>;
|
|
101
127
|
/**
|
|
102
128
|
* Close an opened, persistent chat room, effectively killing the streaming as well if still opened.
|
|
103
129
|
* If there is no active session, this method does nothing.
|
|
@@ -206,4 +232,4 @@ declare class WebClient {
|
|
|
206
232
|
private send;
|
|
207
233
|
}
|
|
208
234
|
|
|
209
|
-
export { type EventHandlers, type LlmType, type SessionConfig, WebClient, type WebClientConfig };
|
|
235
|
+
export { type EventHandlers, type LlmType, type SessionConfig, type ToolDescription, WebClient, type WebClientConfig };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,39 @@ var WebClient = class {
|
|
|
5
5
|
this.sessionId = null;
|
|
6
6
|
this.config = config;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve the list of available tools:
|
|
10
|
+
* Tools, or functions, can be exposed to & added to the model's context, allowing it
|
|
11
|
+
* to use them during the session as part of its response creation process. In order to add
|
|
12
|
+
* a tool to the session context, it must be listed (by name) at session creation time
|
|
13
|
+
* (see startSession(...) function)
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Tools are remote functions exposed by MCP servers and integrated by the constellation server
|
|
17
|
+
*
|
|
18
|
+
* @exception
|
|
19
|
+
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
20
|
+
*/
|
|
21
|
+
async fetchSupportedTools() {
|
|
22
|
+
const response = await fetch(`${this.config.sessionEndpoint}/supported_tools`, {
|
|
23
|
+
method: "GET",
|
|
24
|
+
headers: {
|
|
25
|
+
"Authorization": `Bearer ${this.config.key}`,
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
"Accept": "application/json"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new Error(`Could not fetch the list of available tools
|
|
32
|
+
[${response.status}:${response.statusText}]`);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const result = await response.json();
|
|
36
|
+
return result != null ? result : [];
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw `Failed to read session create response: ${error}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
8
41
|
/**
|
|
9
42
|
* Start a persistent chat room on the server, allowing for re-connection,
|
|
10
43
|
* when the streaming connection is lost. Once a session was started it must
|
|
@@ -15,15 +48,18 @@ var WebClient = class {
|
|
|
15
48
|
*
|
|
16
49
|
* @param audioEnabled whether this session can receive & produce audio as well as text
|
|
17
50
|
* @param voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
51
|
+
* @param tools a list of tool names to be included in this session. These must be matching the
|
|
52
|
+
* names returned by 'fetchAvailableTools()'.
|
|
18
53
|
*
|
|
19
54
|
* @exception
|
|
20
55
|
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
21
56
|
*/
|
|
22
|
-
async startSession(audioEnabled, voiceName) {
|
|
57
|
+
async startSession(audioEnabled, voiceName, tools = []) {
|
|
23
58
|
const prepareBody = {
|
|
24
59
|
llmProvider: this.config.llm,
|
|
25
60
|
audioEnabled,
|
|
26
|
-
voiceName
|
|
61
|
+
voiceName,
|
|
62
|
+
includeTools: tools
|
|
27
63
|
};
|
|
28
64
|
const response = await fetch(`${this.config.sessionEndpoint}/prepare_session`, {
|
|
29
65
|
method: "POST",
|