@simfinity/constellation-ui 1.0.6 → 1.0.8
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 +7 -11
- package/dist/index.d.cts +4 -12
- package/dist/index.d.ts +4 -12
- package/dist/index.js +7 -11
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -43,15 +43,15 @@ var ConstellationContext = import_react.default.createContext(null);
|
|
|
43
43
|
function ConstellationProvider({ client, children }) {
|
|
44
44
|
const [sessionId, setSessionId] = (0, import_react.useState)(null);
|
|
45
45
|
const [connected, setConnected] = (0, import_react.useState)(false);
|
|
46
|
-
const [
|
|
46
|
+
const [voiceEnabled, setVoiceEnabled] = (0, import_react.useState)(false);
|
|
47
47
|
const value = {
|
|
48
48
|
client,
|
|
49
49
|
sessionId,
|
|
50
50
|
connected,
|
|
51
|
-
|
|
51
|
+
voiceEnabled,
|
|
52
52
|
setSessionId,
|
|
53
53
|
setConnected,
|
|
54
|
-
|
|
54
|
+
setVoiceEnabled
|
|
55
55
|
};
|
|
56
56
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConstellationContext.Provider, { value, children });
|
|
57
57
|
}
|
|
@@ -59,12 +59,9 @@ function useConstellationClient() {
|
|
|
59
59
|
const ctx = (0, import_react.useContext)(ConstellationContext);
|
|
60
60
|
if (!ctx) throw new Error("Must be used inside ConstellationProvider");
|
|
61
61
|
return {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
startSession: async (audio, voice, tools = []) => {
|
|
66
|
-
await ctx.client.startSession(audio, voice, tools);
|
|
67
|
-
ctx.setAudioEnabled(audio);
|
|
62
|
+
startSession: async (voiceEnabled, voiceName) => {
|
|
63
|
+
await ctx.client.startSession(voiceEnabled, voiceName);
|
|
64
|
+
ctx.setVoiceEnabled(voiceEnabled);
|
|
68
65
|
},
|
|
69
66
|
endSession: async () => {
|
|
70
67
|
await ctx.client.endSession();
|
|
@@ -86,8 +83,7 @@ function useConstellationSession() {
|
|
|
86
83
|
if (!ctx) throw new Error("Must be used inside ConstellationProvider");
|
|
87
84
|
return {
|
|
88
85
|
sessionId: ctx.sessionId,
|
|
89
|
-
connected: ctx.connected
|
|
90
|
-
audioEnabled: ctx.audioEnabled
|
|
86
|
+
connected: ctx.connected
|
|
91
87
|
};
|
|
92
88
|
}
|
|
93
89
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -25,7 +25,7 @@ import { WebClient } from '@simfinity/constellation-client';
|
|
|
25
25
|
* streamingEndpoint: "wss://your-stream",
|
|
26
26
|
* key: "YOUR_SECRET_KEY",
|
|
27
27
|
* llm: "openai",
|
|
28
|
-
* model: "gpt-4o-realtime-preview-2024-12-17"
|
|
28
|
+
* model: "gpt-4o-realtime-preview-2024-12-17",
|
|
29
29
|
* });
|
|
30
30
|
*
|
|
31
31
|
* function App() {
|
|
@@ -51,16 +51,13 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
51
51
|
*
|
|
52
52
|
* IMPORTANT SESSION ORDER:
|
|
53
53
|
*
|
|
54
|
-
* 1) startSession(
|
|
54
|
+
* 1) startSession(voiceEnabled, voiceName)
|
|
55
55
|
* → Creates a persistent server-side session (REST)
|
|
56
56
|
* → A session remains alive and can be re-joined within 5 minutes of inactivity
|
|
57
|
-
* → audioEnabled makes the session capable of receiving and producing audio stream
|
|
58
|
-
* → voice is an LLM specific name of a voice e.g. for OpenAI 'alloy' is a valid value
|
|
59
|
-
* → Once a session has started, audio & voice options cannot be changed
|
|
60
57
|
*
|
|
61
58
|
* 2) joinSession(audioEnabled, handlers)
|
|
62
59
|
* → Opens WebSocket stream and begins event flow
|
|
63
|
-
* → audioEnabled (along with an audioEnabled
|
|
60
|
+
* → audioEnabled (along with an audioEnabled model connection) to subscribe to audio events
|
|
64
61
|
* → handlers are the callback functions to receive server events
|
|
65
62
|
*
|
|
66
63
|
* 3) configureSession(settings?) (optional)
|
|
@@ -87,7 +84,7 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
87
84
|
* - Tools can be selectively added to a session at creation time
|
|
88
85
|
* - Tools included in a session are added to the model's context and available for it to use
|
|
89
86
|
*
|
|
90
|
-
* startSession(
|
|
87
|
+
* startSession()
|
|
91
88
|
* - Creates a new persistent session on the server.
|
|
92
89
|
* - Must be called before joinSession().
|
|
93
90
|
*
|
|
@@ -123,7 +120,6 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
123
120
|
* } = useConstellationClient();
|
|
124
121
|
*
|
|
125
122
|
* await startSession(false);
|
|
126
|
-
*
|
|
127
123
|
* await joinSession(false, {
|
|
128
124
|
* onStreamClosed: console.log,
|
|
129
125
|
* onTranscriptResponse: (text) => console.log(text),
|
|
@@ -143,7 +139,6 @@ declare function useConstellationClient(): any;
|
|
|
143
139
|
* {
|
|
144
140
|
* sessionId: string | null
|
|
145
141
|
* connected: boolean
|
|
146
|
-
* audioEnabled: boolean
|
|
147
142
|
* }
|
|
148
143
|
*
|
|
149
144
|
* sessionId
|
|
@@ -152,9 +147,6 @@ declare function useConstellationClient(): any;
|
|
|
152
147
|
* connected
|
|
153
148
|
* - True after successful joinSession().
|
|
154
149
|
*
|
|
155
|
-
* audioEnabled
|
|
156
|
-
* - Reflects whether session was started in audio mode.
|
|
157
|
-
*
|
|
158
150
|
* @example
|
|
159
151
|
* ```tsx
|
|
160
152
|
* const { connected, sessionId } = useConstellationSession();
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { WebClient } from '@simfinity/constellation-client';
|
|
|
25
25
|
* streamingEndpoint: "wss://your-stream",
|
|
26
26
|
* key: "YOUR_SECRET_KEY",
|
|
27
27
|
* llm: "openai",
|
|
28
|
-
* model: "gpt-4o-realtime-preview-2024-12-17"
|
|
28
|
+
* model: "gpt-4o-realtime-preview-2024-12-17",
|
|
29
29
|
* });
|
|
30
30
|
*
|
|
31
31
|
* function App() {
|
|
@@ -51,16 +51,13 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
51
51
|
*
|
|
52
52
|
* IMPORTANT SESSION ORDER:
|
|
53
53
|
*
|
|
54
|
-
* 1) startSession(
|
|
54
|
+
* 1) startSession(voiceEnabled, voiceName)
|
|
55
55
|
* → Creates a persistent server-side session (REST)
|
|
56
56
|
* → A session remains alive and can be re-joined within 5 minutes of inactivity
|
|
57
|
-
* → audioEnabled makes the session capable of receiving and producing audio stream
|
|
58
|
-
* → voice is an LLM specific name of a voice e.g. for OpenAI 'alloy' is a valid value
|
|
59
|
-
* → Once a session has started, audio & voice options cannot be changed
|
|
60
57
|
*
|
|
61
58
|
* 2) joinSession(audioEnabled, handlers)
|
|
62
59
|
* → Opens WebSocket stream and begins event flow
|
|
63
|
-
* → audioEnabled (along with an audioEnabled
|
|
60
|
+
* → audioEnabled (along with an audioEnabled model connection) to subscribe to audio events
|
|
64
61
|
* → handlers are the callback functions to receive server events
|
|
65
62
|
*
|
|
66
63
|
* 3) configureSession(settings?) (optional)
|
|
@@ -87,7 +84,7 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
87
84
|
* - Tools can be selectively added to a session at creation time
|
|
88
85
|
* - Tools included in a session are added to the model's context and available for it to use
|
|
89
86
|
*
|
|
90
|
-
* startSession(
|
|
87
|
+
* startSession()
|
|
91
88
|
* - Creates a new persistent session on the server.
|
|
92
89
|
* - Must be called before joinSession().
|
|
93
90
|
*
|
|
@@ -123,7 +120,6 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
123
120
|
* } = useConstellationClient();
|
|
124
121
|
*
|
|
125
122
|
* await startSession(false);
|
|
126
|
-
*
|
|
127
123
|
* await joinSession(false, {
|
|
128
124
|
* onStreamClosed: console.log,
|
|
129
125
|
* onTranscriptResponse: (text) => console.log(text),
|
|
@@ -143,7 +139,6 @@ declare function useConstellationClient(): any;
|
|
|
143
139
|
* {
|
|
144
140
|
* sessionId: string | null
|
|
145
141
|
* connected: boolean
|
|
146
|
-
* audioEnabled: boolean
|
|
147
142
|
* }
|
|
148
143
|
*
|
|
149
144
|
* sessionId
|
|
@@ -152,9 +147,6 @@ declare function useConstellationClient(): any;
|
|
|
152
147
|
* connected
|
|
153
148
|
* - True after successful joinSession().
|
|
154
149
|
*
|
|
155
|
-
* audioEnabled
|
|
156
|
-
* - Reflects whether session was started in audio mode.
|
|
157
|
-
*
|
|
158
150
|
* @example
|
|
159
151
|
* ```tsx
|
|
160
152
|
* const { connected, sessionId } = useConstellationSession();
|
package/dist/index.js
CHANGED
|
@@ -5,15 +5,15 @@ var ConstellationContext = React.createContext(null);
|
|
|
5
5
|
function ConstellationProvider({ client, children }) {
|
|
6
6
|
const [sessionId, setSessionId] = useState(null);
|
|
7
7
|
const [connected, setConnected] = useState(false);
|
|
8
|
-
const [
|
|
8
|
+
const [voiceEnabled, setVoiceEnabled] = useState(false);
|
|
9
9
|
const value = {
|
|
10
10
|
client,
|
|
11
11
|
sessionId,
|
|
12
12
|
connected,
|
|
13
|
-
|
|
13
|
+
voiceEnabled,
|
|
14
14
|
setSessionId,
|
|
15
15
|
setConnected,
|
|
16
|
-
|
|
16
|
+
setVoiceEnabled
|
|
17
17
|
};
|
|
18
18
|
return /* @__PURE__ */ jsx(ConstellationContext.Provider, { value, children });
|
|
19
19
|
}
|
|
@@ -21,12 +21,9 @@ function useConstellationClient() {
|
|
|
21
21
|
const ctx = useContext(ConstellationContext);
|
|
22
22
|
if (!ctx) throw new Error("Must be used inside ConstellationProvider");
|
|
23
23
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
startSession: async (audio, voice, tools = []) => {
|
|
28
|
-
await ctx.client.startSession(audio, voice, tools);
|
|
29
|
-
ctx.setAudioEnabled(audio);
|
|
24
|
+
startSession: async (voiceEnabled, voiceName) => {
|
|
25
|
+
await ctx.client.startSession(voiceEnabled, voiceName);
|
|
26
|
+
ctx.setVoiceEnabled(voiceEnabled);
|
|
30
27
|
},
|
|
31
28
|
endSession: async () => {
|
|
32
29
|
await ctx.client.endSession();
|
|
@@ -48,8 +45,7 @@ function useConstellationSession() {
|
|
|
48
45
|
if (!ctx) throw new Error("Must be used inside ConstellationProvider");
|
|
49
46
|
return {
|
|
50
47
|
sessionId: ctx.sessionId,
|
|
51
|
-
connected: ctx.connected
|
|
52
|
-
audioEnabled: ctx.audioEnabled
|
|
48
|
+
connected: ctx.connected
|
|
53
49
|
};
|
|
54
50
|
}
|
|
55
51
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simfinity/constellation-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "Simfinity",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@simfinity/constellation-client": "^1.0.
|
|
28
|
+
"@simfinity/constellation-client": "^1.0.15"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "^19.2.11",
|