@wallavi/widget 1.3.7 → 1.3.9
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.js +10 -5
- package/dist/index.mjs +10 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ async function consumeStream(body, handler) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
var API_URL = process.env.NEXT_PUBLIC_API_URL ?? "
|
|
72
|
+
var API_URL = process.env.NEXT_PUBLIC_API_URL ?? "https://wallavi-production.up.railway.app";
|
|
73
73
|
function newId() {
|
|
74
74
|
return Math.random().toString(36).slice(2, 10);
|
|
75
75
|
}
|
|
@@ -148,8 +148,10 @@ function useChat({
|
|
|
148
148
|
{ id: assistantMsgId, role: "assistant", parts: [] }
|
|
149
149
|
]);
|
|
150
150
|
try {
|
|
151
|
-
const
|
|
152
|
-
const
|
|
151
|
+
const isPrivate = Boolean(workspaceId);
|
|
152
|
+
const token = isPrivate && typeof window !== "undefined" ? await window.Clerk?.session?.getToken() : null;
|
|
153
|
+
const url = isPrivate ? `${API_URL}/api/threads/${threadId}/stream` : `${API_URL}/api/public/chat/stream`;
|
|
154
|
+
const res = await fetch(url, {
|
|
153
155
|
method: "POST",
|
|
154
156
|
headers: {
|
|
155
157
|
"Content-Type": "application/json",
|
|
@@ -158,14 +160,17 @@ function useChat({
|
|
|
158
160
|
body: JSON.stringify({
|
|
159
161
|
input: userInput,
|
|
160
162
|
agentId,
|
|
161
|
-
workspaceId,
|
|
163
|
+
// Private endpoint: workspaceId + threadId in URL, playgroundOverrides allowed.
|
|
164
|
+
// Public endpoint: threadId in body (no workspaceId, no playgroundOverrides).
|
|
165
|
+
...isPrivate ? { workspaceId, ...playgroundOverrides ? { playgroundOverrides } : {} } : { threadId },
|
|
162
166
|
source,
|
|
163
|
-
...playgroundOverrides ? { playgroundOverrides } : {},
|
|
164
167
|
...userContext?.userName ? { userName: userContext.userName } : {},
|
|
165
168
|
...userContext?.userEmail ? { userEmail: userContext.userEmail } : {},
|
|
166
169
|
userMetadata: {
|
|
167
170
|
...userContext?.metadata ?? {},
|
|
168
171
|
...userContext?.pageContext ? { pageContext: userContext.pageContext } : {},
|
|
172
|
+
// Forward client auth headers to the pipeline (for action/tool execution).
|
|
173
|
+
// On the private path, also include the Wallavi Clerk token.
|
|
169
174
|
headers: {
|
|
170
175
|
...token ? { Authorization: `Bearer ${token}` } : {},
|
|
171
176
|
...userContext?.headers ?? {}
|
package/dist/index.mjs
CHANGED
|
@@ -43,7 +43,7 @@ async function consumeStream(body, handler) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
var API_URL = process.env.NEXT_PUBLIC_API_URL ?? "
|
|
46
|
+
var API_URL = process.env.NEXT_PUBLIC_API_URL ?? "https://wallavi-production.up.railway.app";
|
|
47
47
|
function newId() {
|
|
48
48
|
return Math.random().toString(36).slice(2, 10);
|
|
49
49
|
}
|
|
@@ -122,8 +122,10 @@ function useChat({
|
|
|
122
122
|
{ id: assistantMsgId, role: "assistant", parts: [] }
|
|
123
123
|
]);
|
|
124
124
|
try {
|
|
125
|
-
const
|
|
126
|
-
const
|
|
125
|
+
const isPrivate = Boolean(workspaceId);
|
|
126
|
+
const token = isPrivate && typeof window !== "undefined" ? await window.Clerk?.session?.getToken() : null;
|
|
127
|
+
const url = isPrivate ? `${API_URL}/api/threads/${threadId}/stream` : `${API_URL}/api/public/chat/stream`;
|
|
128
|
+
const res = await fetch(url, {
|
|
127
129
|
method: "POST",
|
|
128
130
|
headers: {
|
|
129
131
|
"Content-Type": "application/json",
|
|
@@ -132,14 +134,17 @@ function useChat({
|
|
|
132
134
|
body: JSON.stringify({
|
|
133
135
|
input: userInput,
|
|
134
136
|
agentId,
|
|
135
|
-
workspaceId,
|
|
137
|
+
// Private endpoint: workspaceId + threadId in URL, playgroundOverrides allowed.
|
|
138
|
+
// Public endpoint: threadId in body (no workspaceId, no playgroundOverrides).
|
|
139
|
+
...isPrivate ? { workspaceId, ...playgroundOverrides ? { playgroundOverrides } : {} } : { threadId },
|
|
136
140
|
source,
|
|
137
|
-
...playgroundOverrides ? { playgroundOverrides } : {},
|
|
138
141
|
...userContext?.userName ? { userName: userContext.userName } : {},
|
|
139
142
|
...userContext?.userEmail ? { userEmail: userContext.userEmail } : {},
|
|
140
143
|
userMetadata: {
|
|
141
144
|
...userContext?.metadata ?? {},
|
|
142
145
|
...userContext?.pageContext ? { pageContext: userContext.pageContext } : {},
|
|
146
|
+
// Forward client auth headers to the pipeline (for action/tool execution).
|
|
147
|
+
// On the private path, also include the Wallavi Clerk token.
|
|
143
148
|
headers: {
|
|
144
149
|
...token ? { Authorization: `Bearer ${token}` } : {},
|
|
145
150
|
...userContext?.headers ?? {}
|