@applica-software-guru/persona-sdk 0.0.1-preview6 → 0.1.2
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/.eslintrc.cjs +6 -5
- package/.nvmrc +1 -1
- package/.prettierignore +3 -5
- package/.prettierrc +3 -5
- package/README.md +247 -2
- package/bitbucket-pipelines.yml +2 -12
- package/dist/bundle.cjs.js +1 -14
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +472 -699
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +1089 -5
- package/package.json +9 -39
- package/src/agents/agents-api.ts +54 -0
- package/src/agents/types.ts +346 -0
- package/src/auth/api-key-auth.ts +13 -0
- package/src/auth/authentication-provider.ts +4 -0
- package/src/auth/bearer-token-auth.ts +13 -0
- package/src/auth/index.ts +3 -0
- package/src/credentials/credentials-api.ts +40 -0
- package/src/credentials/types.ts +67 -0
- package/src/exceptions.ts +10 -0
- package/src/features/feature-templates-api.ts +41 -0
- package/src/features/features-api.ts +16 -0
- package/src/features/types.ts +25 -0
- package/src/http-api.ts +95 -0
- package/src/index.ts +153 -4
- package/src/knowledges/knowledge-base-documents-api.ts +38 -0
- package/src/knowledges/knowledge-bases-api.ts +47 -0
- package/src/knowledges/types.ts +70 -0
- package/src/missions/missions-api.ts +60 -0
- package/src/missions/types.ts +25 -0
- package/src/paginated.ts +6 -0
- package/src/persona-sdk.ts +81 -0
- package/src/projects/projects-api.ts +55 -0
- package/src/projects/types.ts +42 -0
- package/src/revisions/types.ts +9 -0
- package/src/service-prices/service-prices-api.ts +32 -0
- package/src/service-prices/types.ts +8 -0
- package/src/sessions/sessions-api.ts +55 -0
- package/src/sessions/types.ts +129 -0
- package/src/triggers/trigger-executions-api.ts +27 -0
- package/src/triggers/triggers-api.ts +37 -0
- package/src/triggers/types.ts +50 -0
- package/src/workflows/types.ts +150 -0
- package/src/workflows/workflow-executions-api.ts +27 -0
- package/src/workflows/workflows-api.ts +51 -0
- package/tsconfig.json +20 -28
- package/vite.config.ts +20 -62
- package/dist/bundle.iife.js +0 -15
- package/dist/bundle.iife.js.map +0 -1
- package/dist/bundle.umd.js +0 -15
- package/dist/bundle.umd.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logging.d.ts +0 -18
- package/dist/logging.d.ts.map +0 -1
- package/dist/messages.d.ts +0 -7
- package/dist/messages.d.ts.map +0 -1
- package/dist/protocol/base.d.ts +0 -23
- package/dist/protocol/base.d.ts.map +0 -1
- package/dist/protocol/index.d.ts +0 -5
- package/dist/protocol/index.d.ts.map +0 -1
- package/dist/protocol/rest.d.ts +0 -22
- package/dist/protocol/rest.d.ts.map +0 -1
- package/dist/protocol/webrtc.d.ts +0 -56
- package/dist/protocol/webrtc.d.ts.map +0 -1
- package/dist/protocol/websocket.d.ts +0 -22
- package/dist/protocol/websocket.d.ts.map +0 -1
- package/dist/runtime.d.ts +0 -21
- package/dist/runtime.d.ts.map +0 -1
- package/dist/types.d.ts +0 -79
- package/dist/types.d.ts.map +0 -1
- package/jsconfig.node.json +0 -10
- package/playground/index.html +0 -14
- package/playground/src/app.tsx +0 -10
- package/playground/src/chat.tsx +0 -52
- package/playground/src/components/assistant-ui/assistant-modal.tsx +0 -57
- package/playground/src/components/assistant-ui/markdown-text.tsx +0 -119
- package/playground/src/components/assistant-ui/thread-list.tsx +0 -62
- package/playground/src/components/assistant-ui/thread.tsx +0 -249
- package/playground/src/components/assistant-ui/tool-fallback.tsx +0 -33
- package/playground/src/components/assistant-ui/tooltip-icon-button.tsx +0 -38
- package/playground/src/components/ui/avatar.tsx +0 -35
- package/playground/src/components/ui/button.tsx +0 -43
- package/playground/src/components/ui/tooltip.tsx +0 -32
- package/playground/src/lib/utils.ts +0 -6
- package/playground/src/main.tsx +0 -10
- package/playground/src/styles.css +0 -1
- package/playground/src/vite-env.d.ts +0 -1
- package/preview.sh +0 -13
- package/src/logging.ts +0 -34
- package/src/messages.ts +0 -79
- package/src/protocol/base.ts +0 -55
- package/src/protocol/index.ts +0 -4
- package/src/protocol/rest.ts +0 -66
- package/src/protocol/webrtc.ts +0 -339
- package/src/protocol/websocket.ts +0 -108
- package/src/runtime.tsx +0 -217
- package/src/types.ts +0 -98
- package/tsconfig.node.json +0 -15
package/dist/protocol/base.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Message, MessageListenerCallback, PersonaMessage, PersonaProtocol, ProtocolStatus, Session, StatusChangeCallback } from '../types';
|
|
2
|
-
declare abstract class PersonaProtocolBase implements PersonaProtocol {
|
|
3
|
-
abstract status: ProtocolStatus;
|
|
4
|
-
abstract session: Session;
|
|
5
|
-
abstract autostart: boolean;
|
|
6
|
-
private statusChangeCallbacks;
|
|
7
|
-
private messageCallbacks;
|
|
8
|
-
addStatusChangeListener(callback: StatusChangeCallback): void;
|
|
9
|
-
addMessageListener(callback: MessageListenerCallback): void;
|
|
10
|
-
syncSession(session: Session): Promise<void>;
|
|
11
|
-
notifyMessage(message: PersonaMessage): Promise<void>;
|
|
12
|
-
notifyMessages(messages: PersonaMessage[]): Promise<void>;
|
|
13
|
-
setSession(session: Session): Promise<void>;
|
|
14
|
-
setStatus(status: ProtocolStatus): Promise<void>;
|
|
15
|
-
clearListeners(): void;
|
|
16
|
-
abstract getName(): string;
|
|
17
|
-
abstract getPriority(): number;
|
|
18
|
-
abstract connect(session?: Session): Promise<Session>;
|
|
19
|
-
abstract disconnect(): Promise<void>;
|
|
20
|
-
abstract send(message: Message): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export { PersonaProtocolBase };
|
|
23
|
-
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/protocol/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAA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B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/dist/protocol/rest.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { PersonaProtocolBase } from './base';
|
|
2
|
-
import { Message, Session, ProtocolStatus, PersonaProtocolBaseConfig } from '../types';
|
|
3
|
-
type PersonaRESTProtocolConfig = PersonaProtocolBaseConfig & {
|
|
4
|
-
apiUrl: string;
|
|
5
|
-
};
|
|
6
|
-
declare class PersonaRESTProtocol extends PersonaProtocolBase {
|
|
7
|
-
status: ProtocolStatus;
|
|
8
|
-
autostart: boolean;
|
|
9
|
-
session: Session;
|
|
10
|
-
config: PersonaRESTProtocolConfig;
|
|
11
|
-
notify: boolean;
|
|
12
|
-
constructor(config: PersonaRESTProtocolConfig);
|
|
13
|
-
getName(): string;
|
|
14
|
-
getPriority(): number;
|
|
15
|
-
connect(session: Session): Promise<Session>;
|
|
16
|
-
disconnect(): Promise<void>;
|
|
17
|
-
syncSession(session: Session): Promise<void>;
|
|
18
|
-
send(message: Message): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export { PersonaRESTProtocol };
|
|
21
|
-
export type { PersonaRESTProtocolConfig };
|
|
22
|
-
//# sourceMappingURL=rest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../../src/protocol/rest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAmB,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAExG,KAAK,yBAAyB,GAAG,yBAAyB,GAAG;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,cAAM,mBAAoB,SAAQ,mBAAmB;IACnD,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,yBAAyB,CAAC;IAClC,MAAM,EAAE,OAAO,CAAQ;gBAEX,MAAM,EAAE,yBAAyB;IAOtC,OAAO,IAAI,MAAM;IAIjB,WAAW,IAAI,MAAM;IAIf,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBnD;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,YAAY,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { PersonaProtocolBase } from './base';
|
|
2
|
-
import { Message, PersonaProtocolBaseConfig, ProtocolStatus, Session } from '../types';
|
|
3
|
-
type AudioAnalysisData = {
|
|
4
|
-
localAmplitude: number;
|
|
5
|
-
remoteAmplitude: number;
|
|
6
|
-
};
|
|
7
|
-
type AudioVisualizerCallback = (data: AudioAnalysisData) => void;
|
|
8
|
-
type PersonaWebRTCMessageCallback = (data: MessageEvent) => void;
|
|
9
|
-
type PersonaWebRTCConfig = PersonaProtocolBaseConfig & {
|
|
10
|
-
webrtcUrl: string;
|
|
11
|
-
iceServers?: RTCIceServer[];
|
|
12
|
-
};
|
|
13
|
-
declare class PersonaWebRTCClient {
|
|
14
|
-
private config;
|
|
15
|
-
private pc;
|
|
16
|
-
private ws;
|
|
17
|
-
private localStream;
|
|
18
|
-
private remoteStream;
|
|
19
|
-
private audioCtx;
|
|
20
|
-
private localAnalyser;
|
|
21
|
-
private remoteAnalyser;
|
|
22
|
-
private analyzerFrame;
|
|
23
|
-
private dataChannel;
|
|
24
|
-
private isConnected;
|
|
25
|
-
private visualizerCallbacks;
|
|
26
|
-
private messageCallbacks;
|
|
27
|
-
constructor(config: PersonaWebRTCConfig);
|
|
28
|
-
connect(session: Session): Promise<Session>;
|
|
29
|
-
disconnect(): Promise<void>;
|
|
30
|
-
addVisualizerCallback(callback: AudioVisualizerCallback): void;
|
|
31
|
-
addMessageCallback(callback: PersonaWebRTCMessageCallback): void;
|
|
32
|
-
createDataChannel(label?: string): void;
|
|
33
|
-
sendMessage(message: string): void;
|
|
34
|
-
private _startAnalyzers;
|
|
35
|
-
private _stopAnalyzers;
|
|
36
|
-
}
|
|
37
|
-
type PersonaWebRTCProtocolConfig = PersonaWebRTCConfig & {
|
|
38
|
-
autostart?: boolean;
|
|
39
|
-
};
|
|
40
|
-
declare class PersonaWebRTCProtocol extends PersonaProtocolBase {
|
|
41
|
-
status: ProtocolStatus;
|
|
42
|
-
session: Session;
|
|
43
|
-
autostart: boolean;
|
|
44
|
-
config: PersonaWebRTCProtocolConfig;
|
|
45
|
-
webRTCClient: PersonaWebRTCClient;
|
|
46
|
-
constructor(config: PersonaWebRTCProtocolConfig);
|
|
47
|
-
getName(): string;
|
|
48
|
-
getPriority(): number;
|
|
49
|
-
syncSession(session: Session): Promise<void>;
|
|
50
|
-
connect(session?: Session): Promise<Session>;
|
|
51
|
-
disconnect(): Promise<void>;
|
|
52
|
-
send(message: Message): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
export { PersonaWebRTCProtocol };
|
|
55
|
-
export type { PersonaWebRTCProtocolConfig, AudioVisualizerCallback, AudioAnalysisData };
|
|
56
|
-
//# sourceMappingURL=webrtc.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webrtc.d.ts","sourceRoot":"","sources":["../../../src/protocol/webrtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAkB,yBAAyB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEvG,KAAK,iBAAiB,GAAG;IACvB,cAAc,EAA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,OAAO,CAAC;CACrB,CAAC;AAEF,cAAM,qBAAsB,SAAQ,mBAAmB;IACrD,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,2BAA2B,CAAC;IACpC,YAAY,EAAE,mBAAmB,CAAC;gBAEtB,MAAM,EAAE,2BAA2B;IAgBxC,OAAO,IAAI,MAAM;IAGjB,WAAW,IAAI,MAAM;IAIf,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5C,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB5C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAYjC,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7C;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,YAAY,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Message, PersonaProtocolBaseConfig, ProtocolStatus, Session } from '../types';
|
|
2
|
-
import { PersonaProtocolBase } from './base';
|
|
3
|
-
type PersonaWebSocketProtocolConfig = PersonaProtocolBaseConfig & {
|
|
4
|
-
webSocketUrl: string;
|
|
5
|
-
};
|
|
6
|
-
declare class PersonaWebSocketProtocol extends PersonaProtocolBase {
|
|
7
|
-
status: ProtocolStatus;
|
|
8
|
-
autostart: boolean;
|
|
9
|
-
session: Session;
|
|
10
|
-
config: PersonaWebSocketProtocolConfig;
|
|
11
|
-
webSocket: WebSocket | null;
|
|
12
|
-
constructor(config: PersonaWebSocketProtocolConfig);
|
|
13
|
-
getName(): string;
|
|
14
|
-
getPriority(): number;
|
|
15
|
-
syncSession(session: Session): Promise<void>;
|
|
16
|
-
connect(session?: Session): Promise<Session>;
|
|
17
|
-
disconnect(): Promise<void>;
|
|
18
|
-
send(message: Message): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export { PersonaWebSocketProtocol };
|
|
21
|
-
export type { PersonaWebSocketProtocolConfig };
|
|
22
|
-
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../../src/protocol/websocket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,yBAAyB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACvG,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,KAAK,8BAA8B,GAAG,yBAAyB,GAAG;IAChE,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,cAAM,wBAAyB,SAAQ,mBAAmB;IACxD,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,8BAA8B,CAAC;IACvC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;gBAEhB,MAAM,EAAE,8BAA8B;IAS3C,OAAO,IAAI,MAAM;IAIjB,WAAW,IAAI,MAAM;IAIf,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IASlD,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IA4C5C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7C;AAED,OAAO,EAAE,wBAAwB,EAAE,CAAC;AACpC,YAAY,EAAE,8BAA8B,EAAE,CAAC"}
|
package/dist/runtime.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from '../node_modules/react';
|
|
2
|
-
import { PersonaConfig, PersonaMessage, PersonaProtocol, PersonaResponse, ProtocolStatus } from './types';
|
|
3
|
-
import { PersonaWebRTCProtocol } from './protocol';
|
|
4
|
-
type PersonaRuntimeContextType = {
|
|
5
|
-
protocols: PersonaProtocol[];
|
|
6
|
-
protocolsStatus: Map<string, ProtocolStatus>;
|
|
7
|
-
};
|
|
8
|
-
declare function PersonaRuntimeProvider({ children, ...config }: PropsWithChildren<PersonaConfig>): import('../node_modules/react/jsx-runtime').JSX.Element;
|
|
9
|
-
declare function usePersonaRuntime(): PersonaRuntimeContextType;
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves a specific protocol instance from the PersonaRuntimeContext.
|
|
12
|
-
*
|
|
13
|
-
* @param protocol - The name of the protocol to use.
|
|
14
|
-
* @returns {PersonaProtocol | null} - The protocol instance or null if not found.
|
|
15
|
-
* @throws {Error} - If the hook is used outside of a PersonaRuntimeProvider.
|
|
16
|
-
*/
|
|
17
|
-
declare function usePersonaRuntimeProtocol(protocol: string): PersonaProtocol | null;
|
|
18
|
-
declare function usePersonaRuntimeWebRTCProtocol(): PersonaWebRTCProtocol | null;
|
|
19
|
-
export { PersonaRuntimeProvider, usePersonaRuntime, usePersonaRuntimeProtocol, usePersonaRuntimeWebRTCProtocol };
|
|
20
|
-
export type { PersonaMessage, PersonaResponse };
|
|
21
|
-
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAoC,iBAAiB,EAA8C,MAAM,OAAO,CAAC;AAExH,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,EAEf,eAAe,EACf,cAAc,EAEf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAGL,qBAAqB,EAItB,MAAM,YAAY,CAAC;AAEpB,KAAK,yBAAyB,GAAG;IAC/B,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC9C,CAAC;AA0IF,iBAAS,sBAAsB,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,EAAE,iBAAiB,CAAC,aAAa,CAAC,2CAExF;AAED,iBAAS,iBAAiB,IAAI,yBAAyB,CAMtD;AAED;;;;;;GAMG;AACH,iBAAS,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAyB3E;AAED,iBAAS,+BAA+B,IAAI,qBAAqB,GAAG,IAAI,CAEvE;AAED,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,CAAC;AACjH,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { PersonaLogger } from './logging';
|
|
2
|
-
import { ReactNode } from '../node_modules/react';
|
|
3
|
-
export type ReadonlyJSONObject = {
|
|
4
|
-
readonly [key: string]: string | number | boolean | null | ReadonlyJSONObject | ReadonlyArray<ReadonlyJSONObject>;
|
|
5
|
-
};
|
|
6
|
-
export type FunctionCall = {
|
|
7
|
-
id?: string;
|
|
8
|
-
name: string;
|
|
9
|
-
args: ReadonlyJSONObject;
|
|
10
|
-
};
|
|
11
|
-
export type FunctionResponse = {
|
|
12
|
-
name: string;
|
|
13
|
-
result: unknown;
|
|
14
|
-
function_call_id: string;
|
|
15
|
-
};
|
|
16
|
-
export type PersonaMessage = {
|
|
17
|
-
id?: string | null;
|
|
18
|
-
protocol?: string;
|
|
19
|
-
text: string;
|
|
20
|
-
type: 'reasoning' | 'text';
|
|
21
|
-
role: 'user' | 'assistant' | 'function';
|
|
22
|
-
sessionId?: string;
|
|
23
|
-
finishReason?: 'stop' | 'function_call';
|
|
24
|
-
functionCalls?: FunctionCall[];
|
|
25
|
-
functionResponse?: FunctionResponse;
|
|
26
|
-
};
|
|
27
|
-
export type ModelResponse = {
|
|
28
|
-
messages: PersonaMessage[];
|
|
29
|
-
};
|
|
30
|
-
export type PersonaResponse = {
|
|
31
|
-
sessionId: string;
|
|
32
|
-
response: ModelResponse;
|
|
33
|
-
};
|
|
34
|
-
export type PersonaBaseConfig = {
|
|
35
|
-
logger?: PersonaLogger;
|
|
36
|
-
};
|
|
37
|
-
export type PersonaWebRTCConfig = PersonaBaseConfig & {
|
|
38
|
-
webrtcUrl: string;
|
|
39
|
-
iceServers?: RTCIceServer[];
|
|
40
|
-
onDataMessage?: (msg: MessageEvent) => void;
|
|
41
|
-
};
|
|
42
|
-
export type Session = string | null | undefined;
|
|
43
|
-
export type Message = string;
|
|
44
|
-
export type MessageListenerCallback = (message: PersonaMessage) => void;
|
|
45
|
-
export type StatusChangeCallback = (status: ProtocolStatus) => void;
|
|
46
|
-
export type ProtocolStatus = 'disconnected' | 'connecting' | 'connected';
|
|
47
|
-
export type PersonaProtocolBaseConfig = {
|
|
48
|
-
logger?: PersonaLogger;
|
|
49
|
-
apiKey: string;
|
|
50
|
-
agentId: string;
|
|
51
|
-
};
|
|
52
|
-
export interface PersonaProtocol {
|
|
53
|
-
status: ProtocolStatus;
|
|
54
|
-
autostart: boolean;
|
|
55
|
-
getName: () => string;
|
|
56
|
-
getPriority: () => number;
|
|
57
|
-
connect: (session?: Session) => Promise<Session>;
|
|
58
|
-
disconnect: () => Promise<void>;
|
|
59
|
-
setSession: (session: Session) => Promise<void>;
|
|
60
|
-
send: (message: Message) => Promise<void>;
|
|
61
|
-
clearListeners: () => void;
|
|
62
|
-
addStatusChangeListener: (callback: StatusChangeCallback) => void;
|
|
63
|
-
addMessageListener: (callback: MessageListenerCallback) => void;
|
|
64
|
-
}
|
|
65
|
-
export type PersonaConfig = PersonaBaseConfig & PersonaProtocolBaseConfig & {
|
|
66
|
-
/**
|
|
67
|
-
* In 'dev' mode the endpoint is set to localhost:8000,
|
|
68
|
-
* use it only for development purposes.
|
|
69
|
-
*/
|
|
70
|
-
dev?: boolean;
|
|
71
|
-
session?: Session;
|
|
72
|
-
children: ReactNode;
|
|
73
|
-
protocols: PersonaProtocol[] | {
|
|
74
|
-
rest?: PersonaProtocolBaseConfig | true;
|
|
75
|
-
webrtc?: PersonaProtocolBaseConfig | true;
|
|
76
|
-
websocket?: PersonaProtocolBaseConfig | true;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,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,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;IAC3B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;IACxC,SAAS,CAAC,EAAE,MAA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M,MAAM,CAAC;IAC1B,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,uBAAuB,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAClE,kBAAkB,EAAE,CAAC,QAAQ,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACjE;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,yBAAyB,GAAG;IAC1B;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,EACL,eAAe,EAAE,GACjB;QACE,IAAI,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;QACxC,MAAM,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;QAC1C,SAAS,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;KAC9C,CAAC;CACP,CAAC"}
|
package/jsconfig.node.json
DELETED
package/playground/index.html
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/png" href="/favicon.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<link href="/src/styles.css" rel="stylesheet">
|
|
8
|
-
<title>Persona SDK</title>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<div id="app"></div>
|
|
12
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
13
|
-
</body>
|
|
14
|
-
</html>
|
package/playground/src/app.tsx
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
function App() {
|
|
2
|
-
return (
|
|
3
|
-
<div className="flex flex-col items-center justify-center min-h-screen bg-gray-100">
|
|
4
|
-
<h1 className="text-4xl font-bold text-gray-800">Hello, world!</h1>
|
|
5
|
-
<p className="mt-4 text-lg text-gray-600">This is a simple React app.</p>
|
|
6
|
-
</div>
|
|
7
|
-
);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default App;
|
package/playground/src/chat.tsx
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Thread } from '@/components/assistant-ui/thread';
|
|
2
|
-
import { PersonaRuntimeProvider, PersonaConsoleLogger, Session } from '@applica-software-guru/persona-sdk';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
const logger = new PersonaConsoleLogger();
|
|
6
|
-
|
|
7
|
-
function generateSID() {
|
|
8
|
-
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
9
|
-
let sid = '';
|
|
10
|
-
for (let i = 0; i < 16; i++) {
|
|
11
|
-
sid += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
12
|
-
}
|
|
13
|
-
return sid;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getQueryParam(param: string): string | null {
|
|
17
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
18
|
-
return urlParams.get(param);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function Chat() {
|
|
22
|
-
const agent = getQueryParam('agent');
|
|
23
|
-
const sid = getQueryParam('sid');
|
|
24
|
-
|
|
25
|
-
const session = useMemo((): Session => {
|
|
26
|
-
if (sid) {
|
|
27
|
-
return sid;
|
|
28
|
-
}
|
|
29
|
-
return generateSID();
|
|
30
|
-
}, [sid]);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<PersonaRuntimeProvider
|
|
34
|
-
dev
|
|
35
|
-
logger={logger}
|
|
36
|
-
protocols={{
|
|
37
|
-
rest: true,
|
|
38
|
-
webrtc: true,
|
|
39
|
-
websocket: true,
|
|
40
|
-
}}
|
|
41
|
-
session={session}
|
|
42
|
-
apiKey="2398utf8g$9pahwv8#93q8.h8349q*!ty89w4uefghwqh849tg934yg894hq3g89q34h9"
|
|
43
|
-
agentId={(agent as string) || 'default'}
|
|
44
|
-
>
|
|
45
|
-
<div className="h-dvh w-full">
|
|
46
|
-
<Thread />
|
|
47
|
-
</div>
|
|
48
|
-
</PersonaRuntimeProvider>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { Chat };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { BotIcon, ChevronDownIcon } from 'lucide-react';
|
|
4
|
-
|
|
5
|
-
import { type FC, forwardRef } from 'react';
|
|
6
|
-
import { AssistantModalPrimitive } from '@assistant-ui/react';
|
|
7
|
-
|
|
8
|
-
import { Thread } from '@/components/assistant-ui/thread';
|
|
9
|
-
import { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';
|
|
10
|
-
|
|
11
|
-
export const AssistantModal: FC = () => {
|
|
12
|
-
return (
|
|
13
|
-
<AssistantModalPrimitive.Root>
|
|
14
|
-
<AssistantModalPrimitive.Anchor className="fixed bottom-4 right-4 size-11">
|
|
15
|
-
<AssistantModalPrimitive.Trigger asChild>
|
|
16
|
-
<AssistantModalButton />
|
|
17
|
-
</AssistantModalPrimitive.Trigger>
|
|
18
|
-
</AssistantModalPrimitive.Anchor>
|
|
19
|
-
<AssistantModalPrimitive.Content
|
|
20
|
-
sideOffset={16}
|
|
21
|
-
className="bg-popover text-popover-foreground z-50 h-[500px] w-[400px] overflow-clip rounded-xl border p-0 shadow-md outline-none [&>.aui-thread-root]:bg-inherit data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out data-[state=open]:zoom-in data-[state=open]:slide-in-from-bottom-1/2 data-[state=open]:slide-in-from-right-1/2 data-[state=closed]:slide-out-to-bottom-1/2 data-[state=closed]:slide-out-to-right-1/2"
|
|
22
|
-
>
|
|
23
|
-
<Thread />
|
|
24
|
-
</AssistantModalPrimitive.Content>
|
|
25
|
-
</AssistantModalPrimitive.Root>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type AssistantModalButtonProps = { 'data-state'?: 'open' | 'closed' };
|
|
30
|
-
|
|
31
|
-
const AssistantModalButton = forwardRef<HTMLButtonElement, AssistantModalButtonProps>(({ 'data-state': state, ...rest }, ref) => {
|
|
32
|
-
const tooltip = state === 'open' ? 'Close Assistant' : 'Open Assistant';
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<TooltipIconButton
|
|
36
|
-
variant="default"
|
|
37
|
-
tooltip={tooltip}
|
|
38
|
-
side="left"
|
|
39
|
-
{...rest}
|
|
40
|
-
className="size-full rounded-full shadow transition-transform hover:scale-110 active:scale-90"
|
|
41
|
-
ref={ref}
|
|
42
|
-
>
|
|
43
|
-
<BotIcon
|
|
44
|
-
data-state={state}
|
|
45
|
-
className="absolute size-6 transition-all data-[state=closed]:rotate-0 data-[state=open]:rotate-90 data-[state=closed]:scale-100 data-[state=open]:scale-0"
|
|
46
|
-
/>
|
|
47
|
-
|
|
48
|
-
<ChevronDownIcon
|
|
49
|
-
data-state={state}
|
|
50
|
-
className="absolute size-6 transition-all data-[state=closed]:-rotate-90 data-[state=open]:rotate-0 data-[state=closed]:scale-0 data-[state=open]:scale-100"
|
|
51
|
-
/>
|
|
52
|
-
<span className="sr-only">{tooltip}</span>
|
|
53
|
-
</TooltipIconButton>
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
AssistantModalButton.displayName = 'AssistantModalButton';
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import '@assistant-ui/react-markdown/styles/dot.css';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
CodeHeaderProps,
|
|
7
|
-
MarkdownTextPrimitive,
|
|
8
|
-
unstable_memoizeMarkdownComponents as memoizeMarkdownComponents,
|
|
9
|
-
useIsMarkdownCodeBlock,
|
|
10
|
-
} from '@assistant-ui/react-markdown';
|
|
11
|
-
import remarkGfm from 'remark-gfm';
|
|
12
|
-
import { FC, memo, useState } from 'react';
|
|
13
|
-
import { CheckIcon, CopyIcon } from 'lucide-react';
|
|
14
|
-
|
|
15
|
-
import { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';
|
|
16
|
-
import { cn } from '@/lib/utils';
|
|
17
|
-
|
|
18
|
-
const MarkdownTextImpl = () => {
|
|
19
|
-
return <MarkdownTextPrimitive remarkPlugins={[remarkGfm]} className="aui-md" components={defaultComponents} />;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const MarkdownText = memo(MarkdownTextImpl);
|
|
23
|
-
|
|
24
|
-
const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {
|
|
25
|
-
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
26
|
-
const onCopy = () => {
|
|
27
|
-
if (!code || isCopied) return;
|
|
28
|
-
copyToClipboard(code);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className="flex items-center justify-between gap-4 rounded-t-lg bg-zinc-900 px-4 py-2 text-sm font-semibold text-white">
|
|
33
|
-
<span className="lowercase [&>span]:text-xs">{language}</span>
|
|
34
|
-
<TooltipIconButton tooltip="Copy" onClick={onCopy}>
|
|
35
|
-
{!isCopied && <CopyIcon />}
|
|
36
|
-
{isCopied && <CheckIcon />}
|
|
37
|
-
</TooltipIconButton>
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const useCopyToClipboard = ({
|
|
43
|
-
copiedDuration = 3000,
|
|
44
|
-
}: {
|
|
45
|
-
copiedDuration?: number;
|
|
46
|
-
} = {}) => {
|
|
47
|
-
const [isCopied, setIsCopied] = useState<boolean>(false);
|
|
48
|
-
|
|
49
|
-
const copyToClipboard = (value: string) => {
|
|
50
|
-
if (!value) return;
|
|
51
|
-
|
|
52
|
-
navigator.clipboard.writeText(value).then(() => {
|
|
53
|
-
setIsCopied(true);
|
|
54
|
-
setTimeout(() => setIsCopied(false), copiedDuration);
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return { isCopied, copyToClipboard };
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const defaultComponents = memoizeMarkdownComponents({
|
|
62
|
-
h1: ({ className, ...props }) => (
|
|
63
|
-
<h1 className={cn('mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0', className)} {...props} />
|
|
64
|
-
),
|
|
65
|
-
h2: ({ className, ...props }) => (
|
|
66
|
-
<h2 className={cn('mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0', className)} {...props} />
|
|
67
|
-
),
|
|
68
|
-
h3: ({ className, ...props }) => (
|
|
69
|
-
<h3 className={cn('mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0', className)} {...props} />
|
|
70
|
-
),
|
|
71
|
-
h4: ({ className, ...props }) => (
|
|
72
|
-
<h4 className={cn('mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0', className)} {...props} />
|
|
73
|
-
),
|
|
74
|
-
h5: ({ className, ...props }) => <h5 className={cn('my-4 text-lg font-semibold first:mt-0 last:mb-0', className)} {...props} />,
|
|
75
|
-
h6: ({ className, ...props }) => <h6 className={cn('my-4 font-semibold first:mt-0 last:mb-0', className)} {...props} />,
|
|
76
|
-
p: ({ className, ...props }) => <p className={cn('mb-5 mt-5 leading-7 first:mt-0 last:mb-0', className)} {...props} />,
|
|
77
|
-
a: ({ className, ...props }) => <a className={cn('text-primary font-medium underline underline-offset-4', className)} {...props} />,
|
|
78
|
-
blockquote: ({ className, ...props }) => <blockquote className={cn('border-l-2 pl-6 italic', className)} {...props} />,
|
|
79
|
-
ul: ({ className, ...props }) => <ul className={cn('my-5 ml-6 list-disc [&>li]:mt-2', className)} {...props} />,
|
|
80
|
-
ol: ({ className, ...props }) => <ol className={cn('my-5 ml-6 list-decimal [&>li]:mt-2', className)} {...props} />,
|
|
81
|
-
hr: ({ className, ...props }) => <hr className={cn('my-5 border-b', className)} {...props} />,
|
|
82
|
-
table: ({ className, ...props }) => (
|
|
83
|
-
<table className={cn('my-5 w-full border-separate border-spacing-0 overflow-y-auto', className)} {...props} />
|
|
84
|
-
),
|
|
85
|
-
th: ({ className, ...props }) => (
|
|
86
|
-
<th
|
|
87
|
-
className={cn(
|
|
88
|
-
'bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right',
|
|
89
|
-
className,
|
|
90
|
-
)}
|
|
91
|
-
{...props}
|
|
92
|
-
/>
|
|
93
|
-
),
|
|
94
|
-
td: ({ className, ...props }) => (
|
|
95
|
-
<td
|
|
96
|
-
className={cn(
|
|
97
|
-
'border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right',
|
|
98
|
-
className,
|
|
99
|
-
)}
|
|
100
|
-
{...props}
|
|
101
|
-
/>
|
|
102
|
-
),
|
|
103
|
-
tr: ({ className, ...props }) => (
|
|
104
|
-
<tr
|
|
105
|
-
className={cn(
|
|
106
|
-
'm-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg',
|
|
107
|
-
className,
|
|
108
|
-
)}
|
|
109
|
-
{...props}
|
|
110
|
-
/>
|
|
111
|
-
),
|
|
112
|
-
sup: ({ className, ...props }) => <sup className={cn('[&>a]:text-xs [&>a]:no-underline', className)} {...props} />,
|
|
113
|
-
pre: ({ className, ...props }) => <pre className={cn('overflow-x-auto rounded-b-lg bg-black p-4 text-white', className)} {...props} />,
|
|
114
|
-
code: function Code({ className, ...props }) {
|
|
115
|
-
const isCodeBlock = useIsMarkdownCodeBlock();
|
|
116
|
-
return <code className={cn(!isCodeBlock && 'bg-muted rounded border font-semibold', className)} {...props} />;
|
|
117
|
-
},
|
|
118
|
-
CodeHeader,
|
|
119
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
|
-
import { ThreadListItemPrimitive, ThreadListPrimitive } from '@assistant-ui/react';
|
|
3
|
-
import { ArchiveIcon, PlusIcon } from 'lucide-react';
|
|
4
|
-
|
|
5
|
-
import { Button } from '@/components/ui/button';
|
|
6
|
-
import { TooltipIconButton } from '@/components/assistant-ui/tooltip-icon-button';
|
|
7
|
-
|
|
8
|
-
export const ThreadList: FC = () => {
|
|
9
|
-
return (
|
|
10
|
-
<ThreadListPrimitive.Root className="flex flex-col items-stretch gap-1.5">
|
|
11
|
-
<ThreadListNew />
|
|
12
|
-
<ThreadListItems />
|
|
13
|
-
</ThreadListPrimitive.Root>
|
|
14
|
-
);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const ThreadListNew: FC = () => {
|
|
18
|
-
return (
|
|
19
|
-
<ThreadListPrimitive.New asChild>
|
|
20
|
-
<Button
|
|
21
|
-
className="data-[active]:bg-muted hover:bg-muted flex items-center justify-start gap-1 rounded-lg px-2.5 py-2 text-start"
|
|
22
|
-
variant="ghost"
|
|
23
|
-
>
|
|
24
|
-
<PlusIcon />
|
|
25
|
-
New Thread
|
|
26
|
-
</Button>
|
|
27
|
-
</ThreadListPrimitive.New>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const ThreadListItems: FC = () => {
|
|
32
|
-
return <ThreadListPrimitive.Items components={{ ThreadListItem }} />;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const ThreadListItem: FC = () => {
|
|
36
|
-
return (
|
|
37
|
-
<ThreadListItemPrimitive.Root className="data-[active]:bg-muted hover:bg-muted focus-visible:bg-muted focus-visible:ring-ring flex items-center gap-2 rounded-lg transition-all focus-visible:outline-none focus-visible:ring-2">
|
|
38
|
-
<ThreadListItemPrimitive.Trigger className="flex-grow px-3 py-2 text-start">
|
|
39
|
-
<ThreadListItemTitle />
|
|
40
|
-
</ThreadListItemPrimitive.Trigger>
|
|
41
|
-
<ThreadListItemArchive />
|
|
42
|
-
</ThreadListItemPrimitive.Root>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const ThreadListItemTitle: FC = () => {
|
|
47
|
-
return (
|
|
48
|
-
<p className="text-sm">
|
|
49
|
-
<ThreadListItemPrimitive.Title fallback="New Chat" />
|
|
50
|
-
</p>
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const ThreadListItemArchive: FC = () => {
|
|
55
|
-
return (
|
|
56
|
-
<ThreadListItemPrimitive.Archive asChild>
|
|
57
|
-
<TooltipIconButton className="hover:text-primary text-foreground ml-auto mr-3 size-4 p-0" variant="ghost" tooltip="Archive thread">
|
|
58
|
-
<ArchiveIcon />
|
|
59
|
-
</TooltipIconButton>
|
|
60
|
-
</ThreadListItemPrimitive.Archive>
|
|
61
|
-
);
|
|
62
|
-
};
|