@simfinity/constellation-ui 1.0.4 → 1.0.7
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 +5 -10
- package/dist/index.d.cts +7 -14
- package/dist/index.d.ts +7 -14
- package/dist/index.js +5 -10
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -43,15 +43,12 @@ 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 [audioEnabled, setAudioEnabled] = (0, import_react.useState)(false);
|
|
47
46
|
const value = {
|
|
48
47
|
client,
|
|
49
48
|
sessionId,
|
|
50
49
|
connected,
|
|
51
|
-
audioEnabled,
|
|
52
50
|
setSessionId,
|
|
53
|
-
setConnected
|
|
54
|
-
setAudioEnabled
|
|
51
|
+
setConnected
|
|
55
52
|
};
|
|
56
53
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConstellationContext.Provider, { value, children });
|
|
57
54
|
}
|
|
@@ -60,11 +57,10 @@ function useConstellationClient() {
|
|
|
60
57
|
if (!ctx) throw new Error("Must be used inside ConstellationProvider");
|
|
61
58
|
return {
|
|
62
59
|
supportedTools: async () => {
|
|
63
|
-
return await ctx.client.
|
|
60
|
+
return await ctx.client.fetchSupportedTools();
|
|
64
61
|
},
|
|
65
|
-
startSession: async (
|
|
66
|
-
await ctx.client.startSession(
|
|
67
|
-
ctx.setAudioEnabled(audio);
|
|
62
|
+
startSession: async () => {
|
|
63
|
+
await ctx.client.startSession();
|
|
68
64
|
},
|
|
69
65
|
endSession: async () => {
|
|
70
66
|
await ctx.client.endSession();
|
|
@@ -86,8 +82,7 @@ function useConstellationSession() {
|
|
|
86
82
|
if (!ctx) throw new Error("Must be used inside ConstellationProvider");
|
|
87
83
|
return {
|
|
88
84
|
sessionId: ctx.sessionId,
|
|
89
|
-
connected: ctx.connected
|
|
90
|
-
audioEnabled: ctx.audioEnabled
|
|
85
|
+
connected: ctx.connected
|
|
91
86
|
};
|
|
92
87
|
}
|
|
93
88
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -25,7 +25,8 @@ 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
|
+
* voiceEnabled: false,
|
|
29
30
|
* });
|
|
30
31
|
*
|
|
31
32
|
* function App() {
|
|
@@ -51,16 +52,13 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
51
52
|
*
|
|
52
53
|
* IMPORTANT SESSION ORDER:
|
|
53
54
|
*
|
|
54
|
-
* 1) startSession(
|
|
55
|
+
* 1) startSession()
|
|
55
56
|
* → Creates a persistent server-side session (REST)
|
|
56
57
|
* → 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
58
|
*
|
|
61
59
|
* 2) joinSession(audioEnabled, handlers)
|
|
62
60
|
* → Opens WebSocket stream and begins event flow
|
|
63
|
-
* → audioEnabled (along with an audioEnabled
|
|
61
|
+
* → audioEnabled (along with an audioEnabled model connection) to subscribe to audio events
|
|
64
62
|
* → handlers are the callback functions to receive server events
|
|
65
63
|
*
|
|
66
64
|
* 3) configureSession(settings?) (optional)
|
|
@@ -82,12 +80,12 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
82
80
|
* @returns
|
|
83
81
|
* Lifecycle control methods:
|
|
84
82
|
*
|
|
85
|
-
*
|
|
83
|
+
* supportedTools()
|
|
86
84
|
* - Retrieve the list of tool names & descriptions that the server supports
|
|
87
85
|
* - Tools can be selectively added to a session at creation time
|
|
88
86
|
* - Tools included in a session are added to the model's context and available for it to use
|
|
89
87
|
*
|
|
90
|
-
* startSession(
|
|
88
|
+
* startSession()
|
|
91
89
|
* - Creates a new persistent session on the server.
|
|
92
90
|
* - Must be called before joinSession().
|
|
93
91
|
*
|
|
@@ -122,8 +120,7 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
122
120
|
* endSession
|
|
123
121
|
* } = useConstellationClient();
|
|
124
122
|
*
|
|
125
|
-
* await startSession(
|
|
126
|
-
*
|
|
123
|
+
* await startSession();
|
|
127
124
|
* await joinSession(false, {
|
|
128
125
|
* onStreamClosed: console.log,
|
|
129
126
|
* onTranscriptResponse: (text) => console.log(text),
|
|
@@ -143,7 +140,6 @@ declare function useConstellationClient(): any;
|
|
|
143
140
|
* {
|
|
144
141
|
* sessionId: string | null
|
|
145
142
|
* connected: boolean
|
|
146
|
-
* audioEnabled: boolean
|
|
147
143
|
* }
|
|
148
144
|
*
|
|
149
145
|
* sessionId
|
|
@@ -152,9 +148,6 @@ declare function useConstellationClient(): any;
|
|
|
152
148
|
* connected
|
|
153
149
|
* - True after successful joinSession().
|
|
154
150
|
*
|
|
155
|
-
* audioEnabled
|
|
156
|
-
* - Reflects whether session was started in audio mode.
|
|
157
|
-
*
|
|
158
151
|
* @example
|
|
159
152
|
* ```tsx
|
|
160
153
|
* const { connected, sessionId } = useConstellationSession();
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,8 @@ 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
|
+
* voiceEnabled: false,
|
|
29
30
|
* });
|
|
30
31
|
*
|
|
31
32
|
* function App() {
|
|
@@ -51,16 +52,13 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
51
52
|
*
|
|
52
53
|
* IMPORTANT SESSION ORDER:
|
|
53
54
|
*
|
|
54
|
-
* 1) startSession(
|
|
55
|
+
* 1) startSession()
|
|
55
56
|
* → Creates a persistent server-side session (REST)
|
|
56
57
|
* → 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
58
|
*
|
|
61
59
|
* 2) joinSession(audioEnabled, handlers)
|
|
62
60
|
* → Opens WebSocket stream and begins event flow
|
|
63
|
-
* → audioEnabled (along with an audioEnabled
|
|
61
|
+
* → audioEnabled (along with an audioEnabled model connection) to subscribe to audio events
|
|
64
62
|
* → handlers are the callback functions to receive server events
|
|
65
63
|
*
|
|
66
64
|
* 3) configureSession(settings?) (optional)
|
|
@@ -82,12 +80,12 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
82
80
|
* @returns
|
|
83
81
|
* Lifecycle control methods:
|
|
84
82
|
*
|
|
85
|
-
*
|
|
83
|
+
* supportedTools()
|
|
86
84
|
* - Retrieve the list of tool names & descriptions that the server supports
|
|
87
85
|
* - Tools can be selectively added to a session at creation time
|
|
88
86
|
* - Tools included in a session are added to the model's context and available for it to use
|
|
89
87
|
*
|
|
90
|
-
* startSession(
|
|
88
|
+
* startSession()
|
|
91
89
|
* - Creates a new persistent session on the server.
|
|
92
90
|
* - Must be called before joinSession().
|
|
93
91
|
*
|
|
@@ -122,8 +120,7 @@ declare function ConstellationProvider({ client, children, }: {
|
|
|
122
120
|
* endSession
|
|
123
121
|
* } = useConstellationClient();
|
|
124
122
|
*
|
|
125
|
-
* await startSession(
|
|
126
|
-
*
|
|
123
|
+
* await startSession();
|
|
127
124
|
* await joinSession(false, {
|
|
128
125
|
* onStreamClosed: console.log,
|
|
129
126
|
* onTranscriptResponse: (text) => console.log(text),
|
|
@@ -143,7 +140,6 @@ declare function useConstellationClient(): any;
|
|
|
143
140
|
* {
|
|
144
141
|
* sessionId: string | null
|
|
145
142
|
* connected: boolean
|
|
146
|
-
* audioEnabled: boolean
|
|
147
143
|
* }
|
|
148
144
|
*
|
|
149
145
|
* sessionId
|
|
@@ -152,9 +148,6 @@ declare function useConstellationClient(): any;
|
|
|
152
148
|
* connected
|
|
153
149
|
* - True after successful joinSession().
|
|
154
150
|
*
|
|
155
|
-
* audioEnabled
|
|
156
|
-
* - Reflects whether session was started in audio mode.
|
|
157
|
-
*
|
|
158
151
|
* @example
|
|
159
152
|
* ```tsx
|
|
160
153
|
* const { connected, sessionId } = useConstellationSession();
|
package/dist/index.js
CHANGED
|
@@ -5,15 +5,12 @@ 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 [audioEnabled, setAudioEnabled] = useState(false);
|
|
9
8
|
const value = {
|
|
10
9
|
client,
|
|
11
10
|
sessionId,
|
|
12
11
|
connected,
|
|
13
|
-
audioEnabled,
|
|
14
12
|
setSessionId,
|
|
15
|
-
setConnected
|
|
16
|
-
setAudioEnabled
|
|
13
|
+
setConnected
|
|
17
14
|
};
|
|
18
15
|
return /* @__PURE__ */ jsx(ConstellationContext.Provider, { value, children });
|
|
19
16
|
}
|
|
@@ -22,11 +19,10 @@ function useConstellationClient() {
|
|
|
22
19
|
if (!ctx) throw new Error("Must be used inside ConstellationProvider");
|
|
23
20
|
return {
|
|
24
21
|
supportedTools: async () => {
|
|
25
|
-
return await ctx.client.
|
|
22
|
+
return await ctx.client.fetchSupportedTools();
|
|
26
23
|
},
|
|
27
|
-
startSession: async (
|
|
28
|
-
await ctx.client.startSession(
|
|
29
|
-
ctx.setAudioEnabled(audio);
|
|
24
|
+
startSession: async () => {
|
|
25
|
+
await ctx.client.startSession();
|
|
30
26
|
},
|
|
31
27
|
endSession: async () => {
|
|
32
28
|
await ctx.client.endSession();
|
|
@@ -48,8 +44,7 @@ function useConstellationSession() {
|
|
|
48
44
|
if (!ctx) throw new Error("Must be used inside ConstellationProvider");
|
|
49
45
|
return {
|
|
50
46
|
sessionId: ctx.sessionId,
|
|
51
|
-
connected: ctx.connected
|
|
52
|
-
audioEnabled: ctx.audioEnabled
|
|
47
|
+
connected: ctx.connected
|
|
53
48
|
};
|
|
54
49
|
}
|
|
55
50
|
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.7",
|
|
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.11"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "^19.2.11",
|