@applica-software-guru/persona-sdk 0.1.84 → 0.1.85
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/README.md +104 -0
- package/dist/bundle.cjs.js +18 -18
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +3345 -2891
- package/dist/bundle.es.js.map +1 -1
- package/dist/bundle.iife.js +17 -17
- package/dist/bundle.iife.js.map +1 -1
- package/dist/bundle.umd.js +18 -18
- package/dist/bundle.umd.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/messages.d.ts +2 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/protocol/webrtc.d.ts.map +1 -1
- package/dist/protocol/websocket.d.ts.map +1 -1
- package/dist/runtime/context.d.ts +34 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/handlers.d.ts +21 -0
- package/dist/runtime/handlers.d.ts.map +1 -0
- package/dist/runtime/listeners.d.ts +6 -0
- package/dist/runtime/listeners.d.ts.map +1 -0
- package/dist/runtime/protocols.d.ts +17 -0
- package/dist/runtime/protocols.d.ts.map +1 -0
- package/dist/runtime/threads.d.ts +35 -0
- package/dist/runtime/threads.d.ts.map +1 -0
- package/dist/runtime/utils.d.ts +10 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/runtime.d.ts +4 -22
- package/dist/runtime.d.ts.map +1 -1
- package/dist/storage/base.d.ts +19 -0
- package/dist/storage/base.d.ts.map +1 -0
- package/dist/storage/index.d.ts +3 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/persona.d.ts +30 -0
- package/dist/storage/persona.d.ts.map +1 -0
- package/dist/types.d.ts +51 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
- package/playground/src/chat.tsx +51 -66
- package/playground/src/components/assistant-ui/thread-list.tsx +45 -12
- package/playground/src/components/assistant-ui/thread.tsx +34 -96
- package/playground/src/components/assistant-ui/threadlist-sidebar.tsx +59 -0
- package/playground/src/components/chat/logging.tsx +53 -0
- package/playground/src/components/ui/input.tsx +21 -0
- package/playground/src/components/ui/separator.tsx +26 -0
- package/playground/src/components/ui/sheet.tsx +139 -0
- package/playground/src/components/ui/sidebar.tsx +619 -0
- package/playground/src/components/ui/skeleton.tsx +13 -0
- package/playground/src/components/ui/tooltip.tsx +0 -2
- package/playground/src/hooks/theme.ts +70 -0
- package/playground/src/hooks/use-mobile.ts +19 -0
- package/src/index.ts +1 -0
- package/src/messages.ts +98 -8
- package/src/protocol/webrtc.ts +1 -0
- package/src/protocol/websocket.ts +5 -2
- package/src/runtime/context.ts +88 -0
- package/src/runtime/handlers.ts +276 -0
- package/src/runtime/index.ts +6 -0
- package/src/runtime/listeners.ts +79 -0
- package/src/runtime/protocols.ts +169 -0
- package/src/runtime/threads.ts +120 -0
- package/src/runtime/utils.ts +46 -0
- package/src/runtime.tsx +226 -326
- package/src/storage/base.ts +21 -0
- package/src/storage/index.ts +2 -0
- package/src/storage/persona.ts +132 -0
- package/src/types.ts +64 -2
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
package/dist/messages.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PersonaMessage } from './types';
|
|
2
2
|
import { ThreadMessageLike } from '@assistant-ui/react';
|
|
3
|
+
export declare function generateMessageId(): string;
|
|
4
|
+
export declare function ensureMessageId(message: PersonaMessage): PersonaMessage;
|
|
3
5
|
declare function removeEmptyMessages(messages: PersonaMessage[]): PersonaMessage[];
|
|
4
6
|
declare function parseMessages(messages: PersonaMessage[]): PersonaMessage[];
|
|
5
7
|
declare function convertMessage(message: PersonaMessage): ThreadMessageLike;
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAmB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAmB,iBAAiB,EAAiB,MAAM,qBAAqB,CAAC;AAIxF,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAiBvE;AAED,iBAAS,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAOzE;AACD,iBAAS,aAAa,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAgEnE;AAED,iBAAS,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,iBAAiB,CAsFlE;AAED,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webrtc.d.ts","sourceRoot":"","sources":["../../../src/protocol/webrtc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,aAAa,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O,CAAC;IAiD5C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAQxD;AAED,OAAO,EAAE,wBAAwB,EAAE,CAAC;AACpC,YAAY,EAAE,8BAA8B,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PersonaProtocol, ProtocolStatus } from '../types';
|
|
2
|
+
import { PersonaMessage } from '../types';
|
|
3
|
+
import { PersonaWebRTCProtocol } from '../protocol';
|
|
4
|
+
export type PersonaRuntimeContextType = {
|
|
5
|
+
protocols: PersonaProtocol[];
|
|
6
|
+
protocolsStatus: Map<string, ProtocolStatus>;
|
|
7
|
+
getMessages: () => PersonaMessage[];
|
|
8
|
+
};
|
|
9
|
+
export declare const PersonaRuntimeContext: import("react").Context<PersonaRuntimeContextType | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Hook to access the PersonaRuntime context
|
|
12
|
+
*/
|
|
13
|
+
export declare function usePersonaRuntime(): PersonaRuntimeContextType;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves a specific protocol instance from the PersonaRuntimeContext.
|
|
16
|
+
*
|
|
17
|
+
* @param protocol - The name of the protocol to use.
|
|
18
|
+
* @returns {PersonaProtocol | null} - The protocol instance or null if not found.
|
|
19
|
+
* @throws {Error} - If the hook is used outside of a PersonaRuntimeProvider.
|
|
20
|
+
*/
|
|
21
|
+
export declare function usePersonaRuntimeProtocol(protocol: string): PersonaProtocol | null;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the endpoint URL of the first available protocol
|
|
24
|
+
*/
|
|
25
|
+
export declare function usePersonaRuntimeEndpoint(): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the WebRTC protocol instance
|
|
28
|
+
*/
|
|
29
|
+
export declare function usePersonaRuntimeWebRTCProtocol(): PersonaWebRTCProtocol | null;
|
|
30
|
+
/**
|
|
31
|
+
* Gets all messages from the current conversation
|
|
32
|
+
*/
|
|
33
|
+
export declare function usePersonaRuntimeMessages(): PersonaMessage[];
|
|
34
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/runtime/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,WAAW,EAAE,MAAM,cAAc,EAAE,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,qBAAqB,gEAAkE,CAAC;AAErG;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,yBAAyB,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAyBlF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,GAAG,IAAI,CAOzD;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,qBAAqB,GAAG,IAAI,CAE9E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,cAAc,EAAE,CAM5D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AppendMessage } from '@assistant-ui/react';
|
|
2
|
+
import { StartRunConfig } from '@assistant-ui/react/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore';
|
|
3
|
+
import { PersonaProtocol, PersonaMessage, TransformMessages } from '../types';
|
|
4
|
+
import type { PersonaLogger } from '../logging';
|
|
5
|
+
/**
|
|
6
|
+
* Creates the onNew handler for new messages
|
|
7
|
+
*/
|
|
8
|
+
export declare function createOnNewHandler(protocols: PersonaProtocol[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setIsRunning: React.Dispatch<React.SetStateAction<boolean>>, transformMessages?: TransformMessages, logger?: PersonaLogger): (message: AppendMessage) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates the onEdit handler for editing messages
|
|
11
|
+
*/
|
|
12
|
+
export declare function createOnEditHandler(protocols: PersonaProtocol[], messages: PersonaMessage[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setIsRunning: React.Dispatch<React.SetStateAction<boolean>>, transformMessages?: TransformMessages, logger?: PersonaLogger): (message: AppendMessage) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates the onReload handler for regenerating messages
|
|
15
|
+
*/
|
|
16
|
+
export declare function createOnReloadHandler(protocols: PersonaProtocol[], messages: PersonaMessage[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setIsRunning: React.Dispatch<React.SetStateAction<boolean>>, transformMessages?: TransformMessages, logger?: PersonaLogger): (parentId: string | null, config: StartRunConfig) => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates the onCancel handler for cancelling message generation
|
|
19
|
+
*/
|
|
20
|
+
export declare function createOnCancelHandler(protocols: PersonaProtocol[], setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setIsRunning: React.Dispatch<React.SetStateAction<boolean>>, transformMessages?: TransformMessages): () => Promise<void>;
|
|
21
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/runtime/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,8EAA8E,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC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AAQ,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,EACnE,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAC3D,iBAAiB,CAAC,EAAE,iBAAiB,uBAgCtC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PersonaPacket, PersonaMessage, PersonaProtocol, TransformMessages } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates packet listener for a protocol
|
|
4
|
+
*/
|
|
5
|
+
export declare function createPacketListener(protocol: PersonaProtocol, setMessages: React.Dispatch<React.SetStateAction<PersonaMessage[]>>, setIsRunning: React.Dispatch<React.SetStateAction<boolean>>, protocols: PersonaProtocol[], transformMessages?: TransformMessages): (message: PersonaPacket) => void;
|
|
6
|
+
//# sourceMappingURL=listeners.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../../src/runtime/listeners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAwC,eAAe,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGnI;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EACzB,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,EACnE,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAC3D,SAAS,EAAE,eAAe,EAAE,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,aAEpB,aAAa,UAS/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PersonaProtocol, PersonaConfig } from '../types';
|
|
2
|
+
import type { PersonaLogger } from '../logging';
|
|
3
|
+
type ProtocolsConfig = PersonaConfig['protocols'];
|
|
4
|
+
/**
|
|
5
|
+
* Initializes protocols based on configuration
|
|
6
|
+
*/
|
|
7
|
+
export declare function initializeProtocols(_protocols: ProtocolsConfig, config: {
|
|
8
|
+
dev: boolean;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
agentId: string;
|
|
12
|
+
userId?: string;
|
|
13
|
+
tools?: PersonaConfig['tools'];
|
|
14
|
+
logger?: PersonaLogger;
|
|
15
|
+
}): PersonaProtocol[];
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=protocols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../../../src/runtime/protocols.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA6B,aAAa,EAAE,MAAM,UAAU,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAWhD,KAAK,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;AAElD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE;IACN,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,GACA,eAAe,EAAE,CAiEnB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ThreadData } from '../types';
|
|
2
|
+
import type { PersonaLogger } from '../logging';
|
|
3
|
+
import type { SessionStorage } from '../storage';
|
|
4
|
+
/**
|
|
5
|
+
* Generates a new session ID
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateSessionId(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Creates the thread list adapter for multi-thread support
|
|
10
|
+
*/
|
|
11
|
+
export declare function createThreadListAdapter(currentThreadId: string, threadList: ThreadData[], setCurrentThreadId: (id: string) => void, setThreadList: React.Dispatch<React.SetStateAction<ThreadData[]>>, storage: SessionStorage, onThreadCreate?: (threadId: string) => void, onThreadSwitch?: (threadId: string) => void, onThreadArchive?: (threadId: string) => void, onThreadUnarchive?: (threadId: string) => void, onThreadDelete?: (threadId: string) => void, logger?: PersonaLogger): {
|
|
12
|
+
threadId: string;
|
|
13
|
+
threads: {
|
|
14
|
+
id: string;
|
|
15
|
+
threadId: string;
|
|
16
|
+
title: string;
|
|
17
|
+
status: "regular";
|
|
18
|
+
}[];
|
|
19
|
+
archivedThreads: {
|
|
20
|
+
id: string;
|
|
21
|
+
threadId: string;
|
|
22
|
+
title: string;
|
|
23
|
+
status: "archived";
|
|
24
|
+
}[];
|
|
25
|
+
onSwitchToNewThread: () => void;
|
|
26
|
+
onSwitchToThread: (threadId: string) => void;
|
|
27
|
+
onArchive: (threadId: string) => void;
|
|
28
|
+
onUnarchive: (threadId: string) => void;
|
|
29
|
+
onDelete: (threadId: string) => Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Generates a default thread ID
|
|
33
|
+
*/
|
|
34
|
+
export declare function generateDefaultThreadId(): string;
|
|
35
|
+
//# sourceMappingURL=threads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../src/runtime/threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,UAAU,EAAE,EACxB,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,EACxC,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC,EACjE,OAAO,EAAE,cAAc,EACvB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAC3C,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAC3C,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAC5C,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAC9C,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAC3C,MAAM,CAAC,EAAE,aAAa;;;;;;;;;;;;;;;iCAqCS,MAAM;0BAQb,MAAM;4BAOJ,MAAM;yBAOH,MAAM;EAuBpC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PersonaProtocol } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a File object to a base64 string
|
|
4
|
+
*/
|
|
5
|
+
export declare function fileToBase64(file: File): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Extracts the first available protocol endpoint URL
|
|
8
|
+
*/
|
|
9
|
+
export declare function getFirstAvailableProtocolEndpoint(protocols: PersonaProtocol[]): string | null;
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhD;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAexD;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,MAAM,GAAG,IAAI,CAmB7F"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { PersonaConfig, PersonaMessage,
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
protocolsStatus: Map<string, ProtocolStatus>;
|
|
7
|
-
getMessages: () => PersonaMessage[];
|
|
8
|
-
};
|
|
9
|
-
declare function PersonaRuntimeProvider({ children, ...config }: PropsWithChildren<PersonaConfig>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
declare function usePersonaRuntime(): PersonaRuntimeContextType;
|
|
11
|
-
/**
|
|
12
|
-
* Retrieves a specific protocol instance from the PersonaRuntimeContext.
|
|
13
|
-
*
|
|
14
|
-
* @param protocol - The name of the protocol to use.
|
|
15
|
-
* @returns {PersonaProtocol | null} - The protocol instance or null if not found.
|
|
16
|
-
* @throws {Error} - If the hook is used outside of a PersonaRuntimeProvider.
|
|
17
|
-
*/
|
|
18
|
-
declare function usePersonaRuntimeProtocol(protocol: string): PersonaProtocol | null;
|
|
19
|
-
declare function usePersonaRuntimeEndpoint(): string | null;
|
|
20
|
-
declare function usePersonaRuntimeWebRTCProtocol(): PersonaWebRTCProtocol | null;
|
|
21
|
-
declare function usePersonaRuntimeMessages(): PersonaMessage[];
|
|
22
|
-
export { PersonaRuntimeProvider, usePersonaRuntimeEndpoint, usePersonaRuntime, usePersonaRuntimeProtocol, usePersonaRuntimeWebRTCProtocol, usePersonaRuntimeMessages, };
|
|
23
|
-
export type { PersonaMessage, PersonaResponse };
|
|
2
|
+
import { PersonaConfig, PersonaMessage, PersonaResponse, ThreadData } from './types';
|
|
3
|
+
export { usePersonaRuntime, usePersonaRuntimeProtocol, usePersonaRuntimeEndpoint, usePersonaRuntimeWebRTCProtocol, usePersonaRuntimeMessages, } from './runtime/context';
|
|
4
|
+
export type { PersonaMessage, PersonaResponse, ThreadData };
|
|
5
|
+
export declare function PersonaRuntimeProvider({ children, ...config }: PropsWithChildren<PersonaConfig>): import("react/jsx-runtime").JSX.Element;
|
|
24
6
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,iBAAiB,EAAmB,MAAM,OAAO,CAAC;AAO7F,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAA2B,UAAU,EAAE,MAAM,SAAS,CAAC;AAS9G,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EACzB,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;AAoR5D,wBAAgB,sBAAsB,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,EAAE,iBAAiB,CAAC,aAAa,CAAC,2CAE/F"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PersonaMessage, Session, ThreadData } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Storage interface for messages with thread management support.
|
|
4
|
+
*/
|
|
5
|
+
export interface SessionStorage {
|
|
6
|
+
/**
|
|
7
|
+
* Sync messages for a specific session (load existing messages)
|
|
8
|
+
*/
|
|
9
|
+
sync(sessionId: Session): Promise<PersonaMessage[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Remove messages for a specific session (if supported)
|
|
12
|
+
*/
|
|
13
|
+
remove(sessionId: Session): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* List all threads for a specific user
|
|
16
|
+
*/
|
|
17
|
+
list(agentId: string, userId?: string): Promise<ThreadData[]>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/storage/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAEpD;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PersonaMessage, Session, ThreadData } from '../types';
|
|
2
|
+
import type { SessionStorage } from './base';
|
|
3
|
+
import type { PersonaLogger } from '../logging';
|
|
4
|
+
type PersonaSessionStorageOptions = {
|
|
5
|
+
endpoint: string;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
logger?: PersonaLogger;
|
|
9
|
+
};
|
|
10
|
+
export declare class PersonaSessionStorage implements SessionStorage {
|
|
11
|
+
private endpoint;
|
|
12
|
+
private apiKey?;
|
|
13
|
+
private pageSize;
|
|
14
|
+
private logger?;
|
|
15
|
+
constructor(opts: PersonaSessionStorageOptions);
|
|
16
|
+
private buildHeaders;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch messages for a session from the Persona REST API
|
|
19
|
+
*/
|
|
20
|
+
sync(sessionId: Session): Promise<PersonaMessage[]>;
|
|
21
|
+
remove(sessionId: Session): Promise<void>;
|
|
22
|
+
clearAll(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* List all threads for a specific user from the Persona REST API
|
|
25
|
+
* GET /sessions?userId={userId}&page=1&size=100
|
|
26
|
+
*/
|
|
27
|
+
list(agentId: string, userId?: string): Promise<ThreadData[]>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=persona.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona.d.ts","sourceRoot":"","sources":["../../../src/storage/persona.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,KAAK,4BAA4B,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,qBAAa,qBAAsB,YAAW,cAAc;IAC1D,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAC,CAAgB;gBAEnB,IAAI,EAAE,4BAA4B;IAO9C,OAAO,CAAC,YAAY;IAMpB;;OAEG;IACG,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA8CnD,MAAM,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBzC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B;;;OAGG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CA2BpE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { PersonaTools } from 'src/protocol';
|
|
2
|
-
import { PersonaLogger } from './logging';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
3
|
import type { ToolInstance } from './tools';
|
|
4
|
+
import type { PersonaLogger } from './logging';
|
|
5
|
+
import type { SessionStorage } from './storage';
|
|
6
|
+
export type { PersonaLogger, SessionStorage };
|
|
5
7
|
export type ReadonlyJSONObject = {
|
|
6
8
|
readonly [key: string]: string | number | boolean | null | ReadonlyJSONObject | ReadonlyArray<ReadonlyJSONObject>;
|
|
7
9
|
};
|
|
@@ -94,6 +96,11 @@ export type PersonaMessage = {
|
|
|
94
96
|
status?: {
|
|
95
97
|
type: 'running' | 'complete' | 'incomplete';
|
|
96
98
|
};
|
|
99
|
+
createdAt?: Date;
|
|
100
|
+
metadata?: {
|
|
101
|
+
custom?: Record<string, unknown>;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
};
|
|
97
104
|
};
|
|
98
105
|
export type ModelResponse = {
|
|
99
106
|
messages: PersonaMessage[];
|
|
@@ -112,6 +119,11 @@ export type PersonaWebRTCConfig = PersonaBaseConfig & {
|
|
|
112
119
|
};
|
|
113
120
|
export type Session = string | null | undefined;
|
|
114
121
|
export type TransformMessages = (messages: PersonaMessage[]) => PersonaMessage[];
|
|
122
|
+
export type ThreadData = {
|
|
123
|
+
threadId: string;
|
|
124
|
+
title?: string;
|
|
125
|
+
status: 'regular' | 'archived';
|
|
126
|
+
};
|
|
115
127
|
export type MessageListenerCallback = (message: PersonaPacket) => void;
|
|
116
128
|
export type StatusChangeCallback = (status: ProtocolStatus) => void;
|
|
117
129
|
export type ProtocolStatus = 'disconnected' | 'connecting' | 'connected';
|
|
@@ -119,6 +131,7 @@ export type PersonaProtocolBaseConfig = {
|
|
|
119
131
|
logger?: PersonaLogger;
|
|
120
132
|
apiKey: string;
|
|
121
133
|
agentId: string;
|
|
134
|
+
userId?: string;
|
|
122
135
|
};
|
|
123
136
|
export interface PersonaProtocol {
|
|
124
137
|
status: ProtocolStatus;
|
|
@@ -161,5 +174,42 @@ export type PersonaConfig = PersonaBaseConfig & PersonaProtocolBaseConfig & {
|
|
|
161
174
|
* Optional message transform function that processes messages before they are displayed
|
|
162
175
|
*/
|
|
163
176
|
transformMessages?: TransformMessages;
|
|
177
|
+
/**
|
|
178
|
+
* Enable thread management support
|
|
179
|
+
*/
|
|
180
|
+
enableThreads?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Session storage implementation
|
|
183
|
+
* If not provided, defaults to PersonaSessionStorage
|
|
184
|
+
*/
|
|
185
|
+
sessionStorage?: SessionStorage;
|
|
186
|
+
/**
|
|
187
|
+
* Initial thread list (if thread management is enabled)
|
|
188
|
+
*/
|
|
189
|
+
initialThreads?: ThreadData[];
|
|
190
|
+
/**
|
|
191
|
+
* Callback when a new thread is created
|
|
192
|
+
*/
|
|
193
|
+
onThreadCreate?: (threadId: string) => void;
|
|
194
|
+
/**
|
|
195
|
+
* Callback when switching to a thread
|
|
196
|
+
*/
|
|
197
|
+
onThreadSwitch?: (threadId: string) => void;
|
|
198
|
+
/**
|
|
199
|
+
* Callback when a thread is renamed
|
|
200
|
+
*/
|
|
201
|
+
onThreadRename?: (threadId: string, newTitle: string) => void;
|
|
202
|
+
/**
|
|
203
|
+
* Callback when a thread is archived
|
|
204
|
+
*/
|
|
205
|
+
onThreadArchive?: (threadId: string) => void;
|
|
206
|
+
/**
|
|
207
|
+
* Callback when a thread is unarchived
|
|
208
|
+
*/
|
|
209
|
+
onThreadUnarchive?: (threadId: string) => void;
|
|
210
|
+
/**
|
|
211
|
+
* Callback when a thread is deleted
|
|
212
|
+
*/
|
|
213
|
+
onThreadDelete?: (threadId: string) => void;
|
|
164
214
|
};
|
|
165
215
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACnH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,kBAAkB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;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
|
|
1
1
|
{
|
|
2
2
|
"name": "@applica-software-guru/persona-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.85",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"@assistant-ui/react-markdown": "^0.11.6",
|
|
16
16
|
"@radix-ui/react-avatar": "^1.1.11",
|
|
17
17
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
18
|
+
"@radix-ui/react-separator": "^1.1.8",
|
|
18
19
|
"@tailwindcss/vite": "^4.0.17",
|
|
19
20
|
"@types/inflection": "^1.13.2",
|
|
20
21
|
"@types/lodash": "^4.17.15",
|
|
@@ -57,11 +58,11 @@
|
|
|
57
58
|
"vitest": "^1.6.0"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
|
-
"react": "^18 || ^19 || ^19.0.0-rc",
|
|
61
|
-
"react-dom": "^18 || ^19 || ^19.0.0-rc",
|
|
62
61
|
"@assistant-ui/react": "^0.11.47",
|
|
63
62
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
64
63
|
"@radix-ui/react-slot": "^1.2.4",
|
|
64
|
+
"react": "^18 || ^19 || ^19.0.0-rc",
|
|
65
|
+
"react-dom": "^18 || ^19 || ^19.0.0-rc",
|
|
65
66
|
"rehype-raw": "^7.0.0",
|
|
66
67
|
"zustand": "^5.0.9"
|
|
67
68
|
},
|
package/playground/src/chat.tsx
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { Thread } from '@/components/assistant-ui/thread';
|
|
2
|
-
import {
|
|
3
|
-
PersonaRuntimeProvider,
|
|
4
|
-
PersonaConsoleLogger,
|
|
5
|
-
Session,
|
|
6
|
-
usePersonaRuntimeMessages,
|
|
7
|
-
usePersonaRuntimeEndpoint,
|
|
8
|
-
} from '@applica-software-guru/persona-sdk';
|
|
2
|
+
import { PersonaRuntimeProvider, PersonaConsoleLogger, Session } from '@applica-software-guru/persona-sdk';
|
|
9
3
|
import { useMemo } from 'react';
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
4
|
+
import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar';
|
|
5
|
+
import { ThreadListSidebar } from '@/components/assistant-ui/threadlist-sidebar';
|
|
6
|
+
import { SunIcon, MoonIcon, RefreshCcwDot } from 'lucide-react';
|
|
7
|
+
import { useColorScheme } from './hooks/theme';
|
|
12
8
|
|
|
13
9
|
const logger = new PersonaConsoleLogger();
|
|
14
10
|
|
|
@@ -26,56 +22,9 @@ function getQueryParam(param: string): string | null {
|
|
|
26
22
|
return urlParams.get(param);
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
function EndpointLogger() {
|
|
30
|
-
const endpoint = usePersonaRuntimeEndpoint();
|
|
31
|
-
return (
|
|
32
|
-
<div className="absolute top-0 right-0 w-50 h-40 overflow-y-auto m-2 box-border border-gray-300 rounded-lg shadow-lg p-2">
|
|
33
|
-
<h3 className="text-md font-bold mb-2">Endpoint</h3>
|
|
34
|
-
<p className="top-0 left-0 bg-white text-black text-sm">{endpoint || 'No endpoint available'}</p>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function MessageLogger() {
|
|
40
|
-
const messages = usePersonaRuntimeMessages();
|
|
41
|
-
const { reasoning, user, assistant, sources } = useMemo(() => {
|
|
42
|
-
const reasoning = _.filter(messages, (message) => message.role === 'assistant' && message.type === 'reasoning').length;
|
|
43
|
-
const user = _.filter(messages, (message) => message.role === 'user').length;
|
|
44
|
-
const assistant = _.filter(messages, (message) => message.role === 'assistant').length;
|
|
45
|
-
const sources = _.filter(messages, (message) => message.role === 'assistant' && message.sources).length;
|
|
46
|
-
return { reasoning, user, assistant, sources };
|
|
47
|
-
}, [messages]);
|
|
48
|
-
return (
|
|
49
|
-
<div className="absolute top-0 left-0 w-30 h-40 overflow-y-auto m-2 box-border border-gray-300 rounded-lg shadow-lg p-2">
|
|
50
|
-
<h3 className="text-md font-bold mb-2">Messages</h3>
|
|
51
|
-
<p className="top-0 left-0 bg-white text-black text-sm">
|
|
52
|
-
<span className="text-gray-500">
|
|
53
|
-
User: <span className="font-bold">{user}</span>
|
|
54
|
-
</span>
|
|
55
|
-
<br />
|
|
56
|
-
<span className="text-gray-500">
|
|
57
|
-
Assistant: <span className="font-bold">{assistant}</span>
|
|
58
|
-
</span>
|
|
59
|
-
<br />
|
|
60
|
-
<span className="text-gray-500">
|
|
61
|
-
Reasoning: <span className="font-bold">{reasoning}</span>
|
|
62
|
-
</span>
|
|
63
|
-
<br />
|
|
64
|
-
<span className="text-gray-500">
|
|
65
|
-
Sources: <span className="font-bold">{sources}</span>
|
|
66
|
-
</span>
|
|
67
|
-
<br />
|
|
68
|
-
<span className="text-gray-500">
|
|
69
|
-
Total: <span className="font-bold">{messages.length}</span>
|
|
70
|
-
</span>
|
|
71
|
-
<br />
|
|
72
|
-
</p>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
25
|
function Chat() {
|
|
78
26
|
const agentId = getQueryParam('agentId');
|
|
27
|
+
const userId = getQueryParam('userId') || 'anonymous';
|
|
79
28
|
const apiKey = getQueryParam('apiKey');
|
|
80
29
|
const sid = getQueryParam('sid');
|
|
81
30
|
|
|
@@ -88,7 +37,6 @@ function Chat() {
|
|
|
88
37
|
|
|
89
38
|
return (
|
|
90
39
|
<PersonaRuntimeProvider
|
|
91
|
-
dev={false}
|
|
92
40
|
logger={logger}
|
|
93
41
|
context={{
|
|
94
42
|
data: {
|
|
@@ -98,23 +46,60 @@ function Chat() {
|
|
|
98
46
|
}}
|
|
99
47
|
tools={[]}
|
|
100
48
|
protocols={{
|
|
101
|
-
rest:
|
|
49
|
+
rest: true,
|
|
102
50
|
webrtc: false,
|
|
103
51
|
websocket: true,
|
|
104
52
|
}}
|
|
105
53
|
session={session}
|
|
106
54
|
apiKey={apiKey!}
|
|
55
|
+
userId={userId}
|
|
107
56
|
agentId={agentId!}
|
|
57
|
+
enableThreads={true}
|
|
58
|
+
onThreadCreate={(threadId) => {
|
|
59
|
+
logger.info('Thread created:', threadId);
|
|
60
|
+
}}
|
|
61
|
+
onThreadSwitch={(threadId) => {
|
|
62
|
+
logger.info('Switched to thread:', threadId);
|
|
63
|
+
}}
|
|
64
|
+
onThreadRename={(threadId, newTitle) => {
|
|
65
|
+
logger.info('Thread renamed:', threadId, newTitle);
|
|
66
|
+
}}
|
|
67
|
+
onThreadArchive={(threadId) => {
|
|
68
|
+
logger.info('Thread archived:', threadId);
|
|
69
|
+
}}
|
|
70
|
+
onThreadDelete={(threadId) => {
|
|
71
|
+
logger.info('Thread deleted:', threadId);
|
|
72
|
+
}}
|
|
108
73
|
>
|
|
109
|
-
<
|
|
110
|
-
<
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
74
|
+
<SidebarProvider>
|
|
75
|
+
<div className="flex h-dvh w-full">
|
|
76
|
+
<ThreadListSidebar />
|
|
77
|
+
<SidebarInset>
|
|
78
|
+
<SidebarTrigger className="absolute top-4 left-4" />
|
|
79
|
+
<ThemeToggle />
|
|
80
|
+
<Thread />
|
|
81
|
+
</SidebarInset>
|
|
82
|
+
</div>
|
|
83
|
+
</SidebarProvider>
|
|
116
84
|
</PersonaRuntimeProvider>
|
|
117
85
|
);
|
|
118
86
|
}
|
|
119
87
|
|
|
88
|
+
function ThemeToggle() {
|
|
89
|
+
const { theme, toggle } = useColorScheme();
|
|
90
|
+
const title = theme === 'auto' ? 'System theme (auto)' : theme === 'dark' ? 'Dark mode' : 'Light mode';
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<button
|
|
94
|
+
onClick={toggle}
|
|
95
|
+
aria-label={`Toggle theme, current: ${title}`}
|
|
96
|
+
title={`Toggle theme, current: ${title}`}
|
|
97
|
+
type="button"
|
|
98
|
+
className="absolute top-4 right-4 z-50 pointer-events-auto inline-flex h-10 w-10 items-center justify-center rounded-full border border-border bg-card p-2 text-foreground shadow-sm hover:cursor-pointer"
|
|
99
|
+
>
|
|
100
|
+
{theme === 'dark' ? <MoonIcon /> : theme === 'light' ? <SunIcon /> : <RefreshCcwDot />}
|
|
101
|
+
</button>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
120
105
|
export { Chat };
|