@simfinity/constellation-client 1.0.12 → 1.0.14
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 +41 -38
- package/dist/index.d.cts +4 -23
- package/dist/index.d.ts +4 -23
- package/dist/index.js +41 -38
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,39 +31,41 @@ var WebClient = class {
|
|
|
31
31
|
this.sessionId = null;
|
|
32
32
|
this.config = config;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[${response.status}:${response.statusText}]`)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
+
public async fetchSupportedTools(): Promise<ToolDescription[]> {
|
|
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
|
+
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
throw new Error(`Could not fetch the list of available tools\n[${response.status}:${response.statusText}]`)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const result: ToolDescription[] = await response.json();
|
|
63
|
+
return result ?? [];
|
|
64
|
+
}
|
|
65
|
+
catch(error) {
|
|
66
|
+
throw `Failed to read session create response: ${error}`;
|
|
67
|
+
}
|
|
68
|
+
}*/
|
|
67
69
|
/**
|
|
68
70
|
* Start a persistent chat room on the server, allowing for re-connection,
|
|
69
71
|
* when the streaming connection is lost. Once a session was started it must
|
|
@@ -72,16 +74,17 @@ var WebClient = class {
|
|
|
72
74
|
* @remarks
|
|
73
75
|
* A session MUST exist first in order to connect the stream next.
|
|
74
76
|
*
|
|
77
|
+
* @param voiceEnabled whether this Model-session can receive & produce audio as well as text
|
|
78
|
+
* @param voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
79
|
+
*
|
|
75
80
|
* @exception
|
|
76
81
|
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
77
82
|
*/
|
|
78
|
-
async startSession() {
|
|
79
|
-
var _a;
|
|
83
|
+
async startSession(voiceEnabled, voiceName) {
|
|
80
84
|
const prepareBody = {
|
|
81
85
|
llmProvider: this.config.llm,
|
|
82
|
-
audioEnabled:
|
|
83
|
-
voiceName
|
|
84
|
-
includeTools: this.config.tools
|
|
86
|
+
audioEnabled: voiceEnabled,
|
|
87
|
+
voiceName
|
|
85
88
|
};
|
|
86
89
|
const response = await fetch(`${this.config.sessionEndpoint}/prepare_session`, {
|
|
87
90
|
method: "POST",
|
package/dist/index.d.cts
CHANGED
|
@@ -10,10 +10,6 @@ type LlmType = "openai";
|
|
|
10
10
|
* @key : Simfinity API secret key granting access to the server API
|
|
11
11
|
* @llm : which LLM service to connect to
|
|
12
12
|
* @model : depends on the LLM service. This is the model name as define by the LLM service
|
|
13
|
-
* @voiceEnabled whether this session can receive & produce audio as well as text. Default is false.
|
|
14
|
-
* @voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
15
|
-
* @tools a list of tool names to be included in this session. These must be matching the
|
|
16
|
-
* names returned by 'fetchAvailableTools()'.
|
|
17
13
|
*
|
|
18
14
|
* @example
|
|
19
15
|
* ```TypeScript
|
|
@@ -23,7 +19,6 @@ type LlmType = "openai";
|
|
|
23
19
|
* key: "some-secret-key"
|
|
24
20
|
* llm: "openai",
|
|
25
21
|
* model: "gpt-4o-realtime-preview-2024-12-17",
|
|
26
|
-
* voiceEnabled: false,
|
|
27
22
|
* }
|
|
28
23
|
* ```
|
|
29
24
|
*/
|
|
@@ -33,9 +28,6 @@ interface WebClientConfig {
|
|
|
33
28
|
key: string;
|
|
34
29
|
llm: LlmType;
|
|
35
30
|
model: string;
|
|
36
|
-
voiceEnabled?: boolean;
|
|
37
|
-
voiceName?: string;
|
|
38
|
-
tools?: string[];
|
|
39
31
|
}
|
|
40
32
|
/**
|
|
41
33
|
* System settings influencing the model behavior:
|
|
@@ -101,20 +93,6 @@ declare class WebClient {
|
|
|
101
93
|
private ws;
|
|
102
94
|
private sessionId;
|
|
103
95
|
constructor(config: WebClientConfig);
|
|
104
|
-
/**
|
|
105
|
-
* Retrieve the list of available tools:
|
|
106
|
-
* Tools, or functions, can be exposed to & added to the model's context, allowing it
|
|
107
|
-
* to use them during the session as part of its response creation process. In order to add
|
|
108
|
-
* a tool to the session context, it must be listed (by name) at session creation time
|
|
109
|
-
* (see startSession(...) function)
|
|
110
|
-
*
|
|
111
|
-
* @remarks
|
|
112
|
-
* Tools are remote functions exposed by MCP servers and integrated by the constellation server
|
|
113
|
-
*
|
|
114
|
-
* @exception
|
|
115
|
-
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
116
|
-
*/
|
|
117
|
-
fetchSupportedTools(): Promise<ToolDescription[]>;
|
|
118
96
|
/**
|
|
119
97
|
* Start a persistent chat room on the server, allowing for re-connection,
|
|
120
98
|
* when the streaming connection is lost. Once a session was started it must
|
|
@@ -123,10 +101,13 @@ declare class WebClient {
|
|
|
123
101
|
* @remarks
|
|
124
102
|
* A session MUST exist first in order to connect the stream next.
|
|
125
103
|
*
|
|
104
|
+
* @param voiceEnabled whether this Model-session can receive & produce audio as well as text
|
|
105
|
+
* @param voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
106
|
+
*
|
|
126
107
|
* @exception
|
|
127
108
|
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
128
109
|
*/
|
|
129
|
-
startSession(): Promise<void>;
|
|
110
|
+
startSession(voiceEnabled: boolean, voiceName?: string): Promise<void>;
|
|
130
111
|
/**
|
|
131
112
|
* Close an opened, persistent chat room, effectively killing the streaming as well if still opened.
|
|
132
113
|
* If there is no active session, this method does nothing.
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,6 @@ type LlmType = "openai";
|
|
|
10
10
|
* @key : Simfinity API secret key granting access to the server API
|
|
11
11
|
* @llm : which LLM service to connect to
|
|
12
12
|
* @model : depends on the LLM service. This is the model name as define by the LLM service
|
|
13
|
-
* @voiceEnabled whether this session can receive & produce audio as well as text. Default is false.
|
|
14
|
-
* @voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
15
|
-
* @tools a list of tool names to be included in this session. These must be matching the
|
|
16
|
-
* names returned by 'fetchAvailableTools()'.
|
|
17
13
|
*
|
|
18
14
|
* @example
|
|
19
15
|
* ```TypeScript
|
|
@@ -23,7 +19,6 @@ type LlmType = "openai";
|
|
|
23
19
|
* key: "some-secret-key"
|
|
24
20
|
* llm: "openai",
|
|
25
21
|
* model: "gpt-4o-realtime-preview-2024-12-17",
|
|
26
|
-
* voiceEnabled: false,
|
|
27
22
|
* }
|
|
28
23
|
* ```
|
|
29
24
|
*/
|
|
@@ -33,9 +28,6 @@ interface WebClientConfig {
|
|
|
33
28
|
key: string;
|
|
34
29
|
llm: LlmType;
|
|
35
30
|
model: string;
|
|
36
|
-
voiceEnabled?: boolean;
|
|
37
|
-
voiceName?: string;
|
|
38
|
-
tools?: string[];
|
|
39
31
|
}
|
|
40
32
|
/**
|
|
41
33
|
* System settings influencing the model behavior:
|
|
@@ -101,20 +93,6 @@ declare class WebClient {
|
|
|
101
93
|
private ws;
|
|
102
94
|
private sessionId;
|
|
103
95
|
constructor(config: WebClientConfig);
|
|
104
|
-
/**
|
|
105
|
-
* Retrieve the list of available tools:
|
|
106
|
-
* Tools, or functions, can be exposed to & added to the model's context, allowing it
|
|
107
|
-
* to use them during the session as part of its response creation process. In order to add
|
|
108
|
-
* a tool to the session context, it must be listed (by name) at session creation time
|
|
109
|
-
* (see startSession(...) function)
|
|
110
|
-
*
|
|
111
|
-
* @remarks
|
|
112
|
-
* Tools are remote functions exposed by MCP servers and integrated by the constellation server
|
|
113
|
-
*
|
|
114
|
-
* @exception
|
|
115
|
-
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
116
|
-
*/
|
|
117
|
-
fetchSupportedTools(): Promise<ToolDescription[]>;
|
|
118
96
|
/**
|
|
119
97
|
* Start a persistent chat room on the server, allowing for re-connection,
|
|
120
98
|
* when the streaming connection is lost. Once a session was started it must
|
|
@@ -123,10 +101,13 @@ declare class WebClient {
|
|
|
123
101
|
* @remarks
|
|
124
102
|
* A session MUST exist first in order to connect the stream next.
|
|
125
103
|
*
|
|
104
|
+
* @param voiceEnabled whether this Model-session can receive & produce audio as well as text
|
|
105
|
+
* @param voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
106
|
+
*
|
|
126
107
|
* @exception
|
|
127
108
|
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
128
109
|
*/
|
|
129
|
-
startSession(): Promise<void>;
|
|
110
|
+
startSession(voiceEnabled: boolean, voiceName?: string): Promise<void>;
|
|
130
111
|
/**
|
|
131
112
|
* Close an opened, persistent chat room, effectively killing the streaming as well if still opened.
|
|
132
113
|
* If there is no active session, this method does nothing.
|
package/dist/index.js
CHANGED
|
@@ -5,39 +5,41 @@ var WebClient = class {
|
|
|
5
5
|
this.sessionId = null;
|
|
6
6
|
this.config = config;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
[${response.status}:${response.statusText}]`)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
public async fetchSupportedTools(): Promise<ToolDescription[]> {
|
|
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
|
+
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(`Could not fetch the list of available tools\n[${response.status}:${response.statusText}]`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const result: ToolDescription[] = await response.json();
|
|
37
|
+
return result ?? [];
|
|
38
|
+
}
|
|
39
|
+
catch(error) {
|
|
40
|
+
throw `Failed to read session create response: ${error}`;
|
|
41
|
+
}
|
|
42
|
+
}*/
|
|
41
43
|
/**
|
|
42
44
|
* Start a persistent chat room on the server, allowing for re-connection,
|
|
43
45
|
* when the streaming connection is lost. Once a session was started it must
|
|
@@ -46,16 +48,17 @@ var WebClient = class {
|
|
|
46
48
|
* @remarks
|
|
47
49
|
* A session MUST exist first in order to connect the stream next.
|
|
48
50
|
*
|
|
51
|
+
* @param voiceEnabled whether this Model-session can receive & produce audio as well as text
|
|
52
|
+
* @param voiceName LLM specific voice name e.g. with OpenAI this could be 'alloy'
|
|
53
|
+
*
|
|
49
54
|
* @exception
|
|
50
55
|
* This method throws new Error(...) if unable to execute successfully for any reason.
|
|
51
56
|
*/
|
|
52
|
-
async startSession() {
|
|
53
|
-
var _a;
|
|
57
|
+
async startSession(voiceEnabled, voiceName) {
|
|
54
58
|
const prepareBody = {
|
|
55
59
|
llmProvider: this.config.llm,
|
|
56
|
-
audioEnabled:
|
|
57
|
-
voiceName
|
|
58
|
-
includeTools: this.config.tools
|
|
60
|
+
audioEnabled: voiceEnabled,
|
|
61
|
+
voiceName
|
|
59
62
|
};
|
|
60
63
|
const response = await fetch(`${this.config.sessionEndpoint}/prepare_session`, {
|
|
61
64
|
method: "POST",
|