Skip to content

Commit b66f69e

Browse files
committed
Add agent native UI v16.0.0
1 parent 997db38 commit b66f69e

28 files changed

Lines changed: 1977 additions & 17 deletions

build/browser/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/browser/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/cjs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/cjs/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/esm/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

build/esm/index.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/main.js

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
11
const Gleap = window.Gleap;
22

3-
Gleap.setFrameUrl('http://0.0.0.0:3001');
4-
Gleap.setApiUrl('http://0.0.0.0:9000');
5-
Gleap.setWSApiUrl('ws://0.0.0.0:9000');
3+
Gleap.setFrameUrl("http://0.0.0.0:3001");
4+
Gleap.setApiUrl("http://0.0.0.0:9000");
5+
Gleap.setWSApiUrl("ws://0.0.0.0:9000");
66

7-
//Gleap.disableQueryParams(true);
7+
Gleap.setLanguage("en");
88

9-
Gleap.initialize('ody3fTXIIbWfipYNLCeCxJBizXVVaX9J');
9+
Gleap.initialize("GnhEkS8fdwxNVjyn3BnYwKzpCkiHgKWL");
1010

11-
Gleap.on('tool-execution', (tool) => {
12-
console.log(tool);
11+
Gleap.identify("123921943", {
12+
name: "Luca",
13+
1314
});
15+
16+
const userData = Gleap.getIdentity();
17+
18+
// If a userId exists the user is not a Guest
19+
if (userData?.userId) {
20+
const gleapId = userData.gleapId;
21+
const gleapHash = userData.gleapHash;
22+
23+
// Redirect back from url param redirect
24+
const urlParams = new URLSearchParams(window.location.search);
25+
const redirectUrl = urlParams.get('redirect');
26+
if (redirectUrl) {
27+
console.log("Redirecting to:", `${redirectUrl}?gleapId=${gleapId}&gleapHash=${gleapHash}`);
28+
window.location.href = `${redirectUrl}?gleapId=${gleapId}&gleapHash=${gleapHash}`;
29+
}
30+
}
31+
32+
// Gleap.startChecklist("696e16f29debde04cb9c8c4d");
33+
34+
// Gleap.on("checklist-step-completed", (data) => {
35+
// console.log("Step completed:", data);
36+
// });
37+
38+
// Gleap.on("checklist-completed", (data) => {
39+
// console.log("Checklist completed!", data);
40+
// });
41+
42+
// Gleap.trackEvent("Connect payment completed");
43+
// Gleap.trackEvent("Style business page completed");
44+
// Gleap.trackEvent('step 2 completed');

index.d.ts

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,98 @@ export namespace Gleap {
178178
showBackButton?: boolean
179179
): void;
180180
function showSurvey(surveyId: string, format?: string): void;
181-
function on(event: string, callback: (data?: any) => void): void;
181+
function on(
182+
event:
183+
| "initialized"
184+
| "open"
185+
| "close"
186+
| "flow-started"
187+
| "checklist-loaded"
188+
| "checklist-step-completed"
189+
| "checklist-completed"
190+
| "agent-message-sent"
191+
| "agent-reply-received"
192+
| "agent-error"
193+
| "agent-conversation-created"
194+
| string,
195+
callback: (data?: any) => void
196+
): void;
197+
function sendAgentMessage(
198+
agentId: string,
199+
message: string,
200+
options?: {
201+
conversationId?: string;
202+
additionalContext?: Record<string, any>;
203+
}
204+
): Promise<{
205+
runId: string;
206+
status: string;
207+
response: string;
208+
conversationId?: string;
209+
outcome?: { type: string };
210+
}>;
211+
function clearAgentConversation(): void;
212+
213+
interface AgentChatMessage {
214+
id: string;
215+
role: 'user' | 'assistant';
216+
content: string;
217+
createdAt: string;
218+
}
219+
220+
interface AgentChatState {
221+
messages: AgentChatMessage[];
222+
isExecuting: boolean;
223+
error: any;
224+
conversationId: string | null;
225+
}
226+
227+
interface AgentChatOptions {
228+
/** The agent ID to talk to. */
229+
agentId: string;
230+
/** Additional context sent with every message to the AI. */
231+
context?: Record<string, any>;
232+
/** Resume an existing conversation by ID. */
233+
conversationId?: string;
234+
/** Called on every state change (messages, loading, error). */
235+
onChange?: (state: AgentChatState) => void;
236+
/** Called when the agent replies. */
237+
onReplyReceived?: (data: any) => void;
238+
/** Called on error. */
239+
onError?: (error: any) => void;
240+
/** Called when a new conversation is created. */
241+
onConversationCreated?: (conversationId: string) => void;
242+
}
243+
244+
interface AgentChatInstance {
245+
/** Send a message to the agent. */
246+
sendMessage(content: string): Promise<void>;
247+
/** Clear all messages and start a new conversation. */
248+
clearMessages(): void;
249+
/** Update the context sent with future messages. */
250+
setContext(context: Record<string, any>): void;
251+
/** Get the current state snapshot. */
252+
getState(): AgentChatState;
253+
/** Destroy this instance and stop all callbacks. */
254+
destroy(): void;
255+
}
256+
257+
/**
258+
* Create a headless agent chat instance.
259+
* Framework-agnostic — wire onChange to React setState, Vue ref, Svelte store, etc.
260+
*
261+
* @example
262+
* ```js
263+
* const chat = Gleap.createAgentChat({
264+
* agentId: 'abc123',
265+
* context: { page: '/billing' },
266+
* onChange: ({ messages, isExecuting }) => { ... },
267+
* });
268+
* chat.sendMessage('Hello!');
269+
* ```
270+
*/
271+
function createAgentChat(options: AgentChatOptions): AgentChatInstance;
272+
182273
function getIdentity(): any;
183274
function isUserIdentified(): boolean;
184275
function setReplayOptions(options: {
@@ -220,3 +311,37 @@ export namespace Gleap {
220311
}): void;
221312
}
222313
export default Gleap;
314+
315+
// Custom element type declarations — makes <gleap-*> work in JSX without extra setup
316+
// Covers both React 18 (global JSX) and React 19+ (React.JSX)
317+
declare global {
318+
namespace JSX {
319+
interface IntrinsicElements {
320+
'gleap-agent-conversation': any;
321+
'gleap-agent-input': any;
322+
'gleap-agent-profile-image': any;
323+
'gleap-agent-reply-bubble': any;
324+
'gleap-agent-user-bubble': any;
325+
'gleap-agent-typing-indicator': any;
326+
'gleap-agent-send-button': any;
327+
'gleap-agent-message-list': any;
328+
'gleap-checklist': any;
329+
}
330+
}
331+
}
332+
333+
declare module 'react' {
334+
namespace JSX {
335+
interface IntrinsicElements {
336+
'gleap-agent-conversation': any;
337+
'gleap-agent-input': any;
338+
'gleap-agent-profile-image': any;
339+
'gleap-agent-reply-bubble': any;
340+
'gleap-agent-user-bubble': any;
341+
'gleap-agent-typing-indicator': any;
342+
'gleap-agent-send-button': any;
343+
'gleap-agent-message-list': any;
344+
'gleap-checklist': any;
345+
}
346+
}
347+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "15.2.6",
3+
"version": "16.0.0",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {

published/16.0.0/index.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)