Skip to content

Commit 48a6d20

Browse files
authored
Merge pull request #7 from layercodedev/expose-config-in-onconnect
expose config in on connect
2 parents 3bfad74 + 35823e2 commit 48a6d20

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect, useCallback, useRef } from 'react';
2-
import LayercodeClient from '@layercode/js-sdk';
2+
import LayercodeClient, { type AgentConfig } from '@layercode/js-sdk';
33

44
/**
55
* Configuration options for the useLayercodeAgent hook.
@@ -9,7 +9,7 @@ interface UseLayercodeAgentOptions {
99
conversationId?: string;
1010
authorizeSessionEndpoint: string;
1111
metadata?: Record<string, any>;
12-
onConnect?: ({ conversationId }: { conversationId: string | null }) => void;
12+
onConnect?: ({ conversationId, config }: { conversationId: string | null; config?: AgentConfig }) => void;
1313
onDisconnect?: () => void;
1414
onError?: (error: Error) => void;
1515
onDataMessage?: (data: any) => void;
@@ -57,14 +57,14 @@ const useLayercodeAgent = (
5757
conversationId: initialConversationId,
5858
authorizeSessionEndpoint,
5959
metadata,
60-
onConnect: ({ conversationId }: { conversationId: string | null }) => {
60+
onConnect: ({ conversationId, config }: { conversationId: string | null; config?: AgentConfig }) => {
6161
setInternalConversationId((current) => {
6262
if (conversationIdRef.current === undefined) {
6363
return conversationId;
6464
}
6565
return conversationId ?? current ?? null;
6666
});
67-
onConnect?.({ conversationId });
67+
onConnect?.({ conversationId, config });
6868
},
6969
onDisconnect: () => {
7070
onDisconnect?.();

0 commit comments

Comments
 (0)