@applica-software-guru/persona-sdk 0.1.100 → 0.1.101
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 +360 -20
- package/bitbucket-pipelines.yml +6 -5
- package/dist/bundle.cjs.js +1 -27
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +700 -5086
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +1442 -8
- package/package.json +9 -51
- package/src/agents/agents-api.ts +66 -0
- package/src/agents/types.ts +349 -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/billing/billing-client.ts +182 -0
- package/src/billing/types.ts +166 -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 +43 -0
- package/src/features/features-api.ts +16 -0
- package/src/features/types.ts +25 -0
- package/src/http-api.ts +102 -0
- package/src/index.ts +179 -7
- package/src/knowledges/knowledge-base-documents-api.ts +39 -0
- package/src/knowledges/knowledge-bases-api.ts +48 -0
- package/src/knowledges/types.ts +70 -0
- package/src/known-models/known-models-api.ts +33 -0
- package/src/known-models/types.ts +7 -0
- package/src/missions/missions-api.ts +62 -0
- package/src/missions/types.ts +25 -0
- package/src/paginated.ts +6 -0
- package/src/persona-sdk.ts +104 -0
- package/src/projects/projects-api.ts +90 -0
- package/src/projects/types.ts +52 -0
- package/src/revisions/types.ts +9 -0
- package/src/service-prices/service-prices-api.ts +33 -0
- package/src/service-prices/types.ts +8 -0
- package/src/sessions/sessions-api.ts +90 -0
- package/src/sessions/types.ts +150 -0
- package/src/triggers/trigger-executions-api.ts +28 -0
- package/src/triggers/triggers-api.ts +38 -0
- package/src/triggers/types.ts +50 -0
- package/src/values/values-api.ts +84 -0
- package/src/workflows/types.ts +150 -0
- package/src/workflows/workflow-executions-api.ts +28 -0
- package/src/workflows/workflows-api.ts +52 -0
- package/tsconfig.json +20 -28
- package/vite.config.ts +20 -67
- package/.github/copilot-instructions.md +0 -3
- package/CLAUDE.md +0 -3
- package/GEMINI.md +0 -3
- package/components.json +0 -24
- package/dist/bundle.iife.js +0 -28
- package/dist/bundle.iife.js.map +0 -1
- package/dist/bundle.umd.js +0 -28
- 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 -9
- package/dist/messages.d.ts.map +0 -1
- package/dist/projects.d.ts +0 -17
- package/dist/projects.d.ts.map +0 -1
- package/dist/protocol/base.d.ts +0 -25
- package/dist/protocol/base.d.ts.map +0 -1
- package/dist/protocol/index.d.ts +0 -6
- package/dist/protocol/index.d.ts.map +0 -1
- package/dist/protocol/rest.d.ts +0 -25
- package/dist/protocol/rest.d.ts.map +0 -1
- package/dist/protocol/transaction.d.ts +0 -56
- package/dist/protocol/transaction.d.ts.map +0 -1
- package/dist/protocol/webrtc.d.ts +0 -60
- 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/context.d.ts +0 -34
- package/dist/runtime/context.d.ts.map +0 -1
- package/dist/runtime/file-attachment-adapter.d.ts +0 -15
- package/dist/runtime/file-attachment-adapter.d.ts.map +0 -1
- package/dist/runtime/handlers.d.ts +0 -21
- package/dist/runtime/handlers.d.ts.map +0 -1
- package/dist/runtime/listeners.d.ts +0 -6
- package/dist/runtime/listeners.d.ts.map +0 -1
- package/dist/runtime/protocols.d.ts +0 -17
- package/dist/runtime/protocols.d.ts.map +0 -1
- package/dist/runtime/threads.d.ts +0 -34
- package/dist/runtime/threads.d.ts.map +0 -1
- package/dist/runtime/utils.d.ts +0 -10
- package/dist/runtime/utils.d.ts.map +0 -1
- package/dist/runtime.d.ts +0 -6
- package/dist/runtime.d.ts.map +0 -1
- package/dist/storage/base.d.ts +0 -9
- package/dist/storage/base.d.ts.map +0 -1
- package/dist/storage/index.d.ts +0 -3
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/persona.d.ts +0 -29
- package/dist/storage/persona.d.ts.map +0 -1
- package/dist/tools.d.ts +0 -72
- package/dist/tools.d.ts.map +0 -1
- package/dist/types.d.ts +0 -237
- package/dist/types.d.ts.map +0 -1
- package/docs/README.md +0 -13
- package/docs/api-reference.md +0 -16
- package/docs/contributing.md +0 -21
- package/docs/customization.md +0 -74
- package/docs/features.md +0 -7
- package/docs/installation.md +0 -9
- package/docs/messages.md +0 -214
- package/docs/protocols.md +0 -39
- package/docs/transactions.md +0 -121
- package/docs/usage.md +0 -40
- 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 -117
- package/playground/src/components/assistant-ui/assistant-modal.tsx +0 -57
- package/playground/src/components/assistant-ui/attachment.tsx +0 -197
- package/playground/src/components/assistant-ui/markdown-text.tsx +0 -228
- package/playground/src/components/assistant-ui/thread-list.tsx +0 -91
- package/playground/src/components/assistant-ui/thread.tsx +0 -302
- package/playground/src/components/assistant-ui/threadlist-sidebar.tsx +0 -59
- package/playground/src/components/assistant-ui/tool-fallback.tsx +0 -93
- package/playground/src/components/assistant-ui/tooltip-icon-button.tsx +0 -42
- package/playground/src/components/chat/logging.tsx +0 -53
- package/playground/src/components/ui/avatar.tsx +0 -51
- package/playground/src/components/ui/button.tsx +0 -60
- package/playground/src/components/ui/dialog.tsx +0 -141
- package/playground/src/components/ui/input.tsx +0 -21
- package/playground/src/components/ui/separator.tsx +0 -26
- package/playground/src/components/ui/sheet.tsx +0 -139
- package/playground/src/components/ui/sidebar.tsx +0 -619
- package/playground/src/components/ui/skeleton.tsx +0 -13
- package/playground/src/components/ui/tooltip.tsx +0 -59
- package/playground/src/hooks/theme.ts +0 -70
- package/playground/src/hooks/use-mobile.ts +0 -19
- package/playground/src/lib/utils.ts +0 -6
- package/playground/src/main.tsx +0 -10
- package/playground/src/styles.css +0 -120
- package/playground/src/tools.ts +0 -149
- package/playground/src/vite-env.d.ts +0 -1
- package/preview-build.sh +0 -23
- package/src/logging.ts +0 -34
- package/src/messages.ts +0 -202
- package/src/projects.ts +0 -57
- package/src/protocol/base.ts +0 -73
- package/src/protocol/index.ts +0 -5
- package/src/protocol/rest.ts +0 -107
- package/src/protocol/transaction.ts +0 -182
- package/src/protocol/webrtc.ts +0 -379
- package/src/protocol/websocket.ts +0 -111
- package/src/runtime/context.ts +0 -88
- package/src/runtime/file-attachment-adapter.ts +0 -48
- package/src/runtime/handlers.ts +0 -322
- package/src/runtime/index.ts +0 -6
- package/src/runtime/listeners.ts +0 -79
- package/src/runtime/protocols.ts +0 -169
- package/src/runtime/threads.ts +0 -105
- package/src/runtime/utils.ts +0 -46
- package/src/runtime.tsx +0 -334
- package/src/storage/base.ts +0 -13
- package/src/storage/index.ts +0 -2
- package/src/storage/persona.ts +0 -138
- package/src/tools.ts +0 -211
- package/src/types.ts +0 -284
- package/tsconfig.node.json +0 -15
package/dist/tools.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,aAAa,CAA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M,YAAY,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,cAAc,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;CAAE,CAAC;AAE3F;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,cAAc,GAAG,YAAY,CAKnE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAC3B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC7C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,YAAY,CAYd;AAGD,eAAO,MAAM,OAAO,cAcnB,CAAC;AAGF,eAAO,MAAM,qBAAqB,cAiBhC,CAAC;AAGH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG;IAC3D,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC;CAC1D,CAWA;AAGD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CA2BnG"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { PersonaTools } from 'src/protocol';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import type { ToolInstance } from './tools';
|
|
4
|
-
import type { PersonaLogger } from './logging';
|
|
5
|
-
import type { SessionStorage } from './storage';
|
|
6
|
-
export type { PersonaLogger, SessionStorage };
|
|
7
|
-
export type ReadonlyJSONObject = {
|
|
8
|
-
readonly [key: string]: string | number | boolean | null | ReadonlyJSONObject | ReadonlyArray<ReadonlyJSONObject>;
|
|
9
|
-
};
|
|
10
|
-
export type FunctionCall = {
|
|
11
|
-
id?: string;
|
|
12
|
-
name: string;
|
|
13
|
-
args: ReadonlyJSONObject;
|
|
14
|
-
};
|
|
15
|
-
export type FunctionResponse = {
|
|
16
|
-
name: string;
|
|
17
|
-
result: unknown;
|
|
18
|
-
function_call_id: string;
|
|
19
|
-
};
|
|
20
|
-
export type PersonaFile = {
|
|
21
|
-
name: string;
|
|
22
|
-
url?: string;
|
|
23
|
-
base64?: string;
|
|
24
|
-
contentType: string;
|
|
25
|
-
};
|
|
26
|
-
export type PersonaSession = {
|
|
27
|
-
id: string;
|
|
28
|
-
code: string;
|
|
29
|
-
projectId: string;
|
|
30
|
-
agentId: string;
|
|
31
|
-
currentAgentId: string;
|
|
32
|
-
userId: string;
|
|
33
|
-
status: 'active' | 'finished';
|
|
34
|
-
type: 'realtime' | 'async';
|
|
35
|
-
createdAt: string;
|
|
36
|
-
finishedAt: string | null;
|
|
37
|
-
};
|
|
38
|
-
export type PersonaProjectSubscription = {
|
|
39
|
-
id: string;
|
|
40
|
-
projectId?: string | null;
|
|
41
|
-
owner?: string | null;
|
|
42
|
-
planType: 'free' | 'baby' | 'junior' | 'pro' | 'mentor';
|
|
43
|
-
status: 'creating' | 'active' | 'inactive' | 'cancelled';
|
|
44
|
-
startDate?: string | null;
|
|
45
|
-
planCredits: number;
|
|
46
|
-
extraCredits: number;
|
|
47
|
-
keepCreditsOnRenew: boolean;
|
|
48
|
-
endDate?: string | null;
|
|
49
|
-
createdAt?: string | null;
|
|
50
|
-
updatedAt?: string | null;
|
|
51
|
-
stripeCustomerId?: string | null;
|
|
52
|
-
stripeSubscriptionId?: string | null;
|
|
53
|
-
};
|
|
54
|
-
export type PersonaAgentContext = {
|
|
55
|
-
data: Record<string, unknown>;
|
|
56
|
-
files?: PersonaFile[];
|
|
57
|
-
session?: PersonaSession;
|
|
58
|
-
};
|
|
59
|
-
export type PersonaTransaction = {
|
|
60
|
-
id: string;
|
|
61
|
-
projectId: string;
|
|
62
|
-
sessionId: string;
|
|
63
|
-
status: 'pending' | 'completed' | 'failed';
|
|
64
|
-
error: string | null;
|
|
65
|
-
functionCall: FunctionCall | null;
|
|
66
|
-
context: PersonaAgentContext;
|
|
67
|
-
};
|
|
68
|
-
export type PersonaReasoning = {
|
|
69
|
-
thought: string;
|
|
70
|
-
imageUrl?: string;
|
|
71
|
-
};
|
|
72
|
-
export type PersonaImage = {
|
|
73
|
-
content: string;
|
|
74
|
-
contentType: string;
|
|
75
|
-
};
|
|
76
|
-
export type PersonaSourceChunk = {
|
|
77
|
-
start: number;
|
|
78
|
-
end: number;
|
|
79
|
-
};
|
|
80
|
-
export type PersonaSource = {
|
|
81
|
-
type: 'web' | 'document';
|
|
82
|
-
url?: string;
|
|
83
|
-
documentId?: string;
|
|
84
|
-
pageId?: string;
|
|
85
|
-
pageNumber?: number;
|
|
86
|
-
chunks?: PersonaSourceChunk[];
|
|
87
|
-
mostRelevant?: boolean;
|
|
88
|
-
};
|
|
89
|
-
export type PersonaCommand = {
|
|
90
|
-
command: 'get_mcp_assets' | 'set_initial_context' | 'set_local_tools';
|
|
91
|
-
arguments: Record<string, unknown>;
|
|
92
|
-
};
|
|
93
|
-
export type PersonaRequest = PersonaMessage | Array<PersonaMessage> | string;
|
|
94
|
-
export type PersonaPacketPayload = PersonaRequest | PersonaCommand | PersonaReasoning | PersonaTransaction;
|
|
95
|
-
export type PersonaPacket = {
|
|
96
|
-
type: 'request' | 'message' | 'command' | 'reasoning' | 'mcp_assets' | 'transaction';
|
|
97
|
-
payload?: PersonaPacketPayload;
|
|
98
|
-
};
|
|
99
|
-
export type PersonaMessage = {
|
|
100
|
-
id?: string | null;
|
|
101
|
-
protocol?: string;
|
|
102
|
-
thought?: string;
|
|
103
|
-
text: string;
|
|
104
|
-
image?: PersonaImage;
|
|
105
|
-
type: 'reasoning' | 'text' | 'transaction' | 'command';
|
|
106
|
-
role: 'user' | 'assistant' | 'function';
|
|
107
|
-
file?: PersonaFile;
|
|
108
|
-
sources?: PersonaSource[];
|
|
109
|
-
sessionId?: string;
|
|
110
|
-
finishReason?: 'stop' | 'function_call';
|
|
111
|
-
functionCalls?: FunctionCall[];
|
|
112
|
-
functionResponse?: FunctionResponse;
|
|
113
|
-
status?: {
|
|
114
|
-
type: 'running' | 'complete' | 'incomplete';
|
|
115
|
-
};
|
|
116
|
-
createdAt?: Date;
|
|
117
|
-
metadata?: {
|
|
118
|
-
custom?: Record<string, unknown>;
|
|
119
|
-
[key: string]: unknown;
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
export type ModelResponse = {
|
|
123
|
-
messages: PersonaMessage[];
|
|
124
|
-
};
|
|
125
|
-
export type PersonaResponse = {
|
|
126
|
-
sessionId: string;
|
|
127
|
-
response: ModelResponse;
|
|
128
|
-
};
|
|
129
|
-
export type PersonaBaseConfig = {
|
|
130
|
-
logger?: PersonaLogger;
|
|
131
|
-
};
|
|
132
|
-
export type PersonaWebRTCConfig = PersonaBaseConfig & {
|
|
133
|
-
webrtcUrl: string;
|
|
134
|
-
iceServers?: RTCIceServer[];
|
|
135
|
-
onDataMessage?: (msg: MessageEvent) => void;
|
|
136
|
-
};
|
|
137
|
-
export type Session = string | null | undefined;
|
|
138
|
-
export type TransformMessages = (messages: PersonaMessage[]) => PersonaMessage[];
|
|
139
|
-
export type ThreadData = {
|
|
140
|
-
threadId: string;
|
|
141
|
-
title?: string;
|
|
142
|
-
status: 'regular' | 'archived';
|
|
143
|
-
};
|
|
144
|
-
export type MessageListenerCallback = (message: PersonaPacket) => void;
|
|
145
|
-
export type StatusChangeCallback = (status: ProtocolStatus) => void;
|
|
146
|
-
export type ProtocolStatus = 'disconnected' | 'connecting' | 'connected';
|
|
147
|
-
export type PersonaProtocolBaseConfig = {
|
|
148
|
-
logger?: PersonaLogger;
|
|
149
|
-
apiKey: string;
|
|
150
|
-
agentId: string;
|
|
151
|
-
userId?: string;
|
|
152
|
-
};
|
|
153
|
-
export interface PersonaProtocol {
|
|
154
|
-
status: ProtocolStatus;
|
|
155
|
-
autostart: boolean;
|
|
156
|
-
getName: () => string;
|
|
157
|
-
getPriority: () => number;
|
|
158
|
-
connect: (session?: Session) => Promise<Session>;
|
|
159
|
-
disconnect: () => Promise<void>;
|
|
160
|
-
onTransaction: (transaction: PersonaTransaction) => void;
|
|
161
|
-
setSession: (session: Session) => Promise<void>;
|
|
162
|
-
sendPacket: (packet: PersonaPacket) => Promise<void>;
|
|
163
|
-
setAgentContext: (context: PersonaAgentContext) => Promise<void>;
|
|
164
|
-
clearListeners: () => void;
|
|
165
|
-
addStatusChangeListener: (callback: StatusChangeCallback) => void;
|
|
166
|
-
addPacketListener: (callback: MessageListenerCallback) => void;
|
|
167
|
-
}
|
|
168
|
-
export type PersonaConfig = PersonaBaseConfig & PersonaProtocolBaseConfig & {
|
|
169
|
-
/**
|
|
170
|
-
* In 'dev' mode the endpoint is set to localhost:8000,
|
|
171
|
-
* use it only for development purposes.
|
|
172
|
-
*/
|
|
173
|
-
dev?: boolean;
|
|
174
|
-
/**
|
|
175
|
-
* The base URL of the API.
|
|
176
|
-
* @default 'persona.applica.guru/api'
|
|
177
|
-
*/
|
|
178
|
-
baseUrl?: string;
|
|
179
|
-
session?: Session;
|
|
180
|
-
children: ReactNode;
|
|
181
|
-
context?: PersonaAgentContext;
|
|
182
|
-
protocols: PersonaProtocol[] | {
|
|
183
|
-
rest?: PersonaProtocolBaseConfig | boolean;
|
|
184
|
-
webrtc?: PersonaProtocolBaseConfig | boolean;
|
|
185
|
-
websocket?: PersonaProtocolBaseConfig | boolean;
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* Tools can be provided as an object (legacy) or as an array of { schema, implementation } (recommended)
|
|
189
|
-
*/
|
|
190
|
-
tools?: PersonaTools | ToolInstance[];
|
|
191
|
-
/**
|
|
192
|
-
* Optional message transform function that processes messages before they are displayed
|
|
193
|
-
*/
|
|
194
|
-
transformMessages?: TransformMessages;
|
|
195
|
-
/**
|
|
196
|
-
* Enable thread management support
|
|
197
|
-
*/
|
|
198
|
-
threads?: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Session storage implementation
|
|
201
|
-
* If not provided, defaults to PersonaSessionStorage
|
|
202
|
-
*/
|
|
203
|
-
sessionStorage?: SessionStorage;
|
|
204
|
-
/**
|
|
205
|
-
* Initial thread list (if thread management is enabled)
|
|
206
|
-
*/
|
|
207
|
-
initialThreads?: ThreadData[];
|
|
208
|
-
/**
|
|
209
|
-
* Callback when a new thread is created
|
|
210
|
-
*/
|
|
211
|
-
onThreadCreate?: (threadId: string) => void;
|
|
212
|
-
/**
|
|
213
|
-
* Callback when switching to a thread
|
|
214
|
-
*/
|
|
215
|
-
onThreadSwitch?: (threadId: string) => void;
|
|
216
|
-
/**
|
|
217
|
-
* Callback when a thread is renamed
|
|
218
|
-
*/
|
|
219
|
-
onThreadRename?: (threadId: string, newTitle: string) => void;
|
|
220
|
-
/**
|
|
221
|
-
* Callback when a thread is archived
|
|
222
|
-
*/
|
|
223
|
-
onThreadArchive?: (threadId: string) => void;
|
|
224
|
-
/**
|
|
225
|
-
* Callback when a thread is unarchived
|
|
226
|
-
*/
|
|
227
|
-
onThreadUnarchive?: (threadId: string) => void;
|
|
228
|
-
/**
|
|
229
|
-
* Callback when a thread is deleted
|
|
230
|
-
*/
|
|
231
|
-
onThreadDelete?: (threadId: string) => void;
|
|
232
|
-
/**
|
|
233
|
-
* Enable file attachments (images, PDFs, text files) in the composer
|
|
234
|
-
*/
|
|
235
|
-
enableAttachments?: boolean;
|
|
236
|
-
};
|
|
237
|
-
//# 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":[],"m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CAAC;IAE5C;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9D;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE7C;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE/C;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC"}
|
package/docs/README.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Persona SDK Documentation
|
|
2
|
-
|
|
3
|
-
Welcome to the Persona SDK documentation.
|
|
4
|
-
|
|
5
|
-
- [Features](features.md)
|
|
6
|
-
- [Installation](installation.md)
|
|
7
|
-
- [Usage](usage.md)
|
|
8
|
-
- [Messages and Storage](messages.md)
|
|
9
|
-
- [Protocols](protocols.md)
|
|
10
|
-
- [API Reference](api-reference.md)
|
|
11
|
-
- [Transactions and Tools](transactions.md)
|
|
12
|
-
- [Customization](customization.md)
|
|
13
|
-
- [Contributing](contributing.md)
|
package/docs/api-reference.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# API Reference
|
|
2
|
-
|
|
3
|
-
## Props for `PersonaRuntimeProvider`
|
|
4
|
-
|
|
5
|
-
| Prop | Type | Default Value | Description |
|
|
6
|
-
| --------------- | ------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
7
|
-
| `dev` | boolean | `false` | Enable development mode for local Persona API usage. |
|
|
8
|
-
| `logger` | function | `console.log` | Custom logger for debugging and logging messages. |
|
|
9
|
-
| `protocols` | object | `{ rest: true, webrtc: true, websocket: true }` | Protocols to use for the chat. Can be enabled/disabled using boolean values. |
|
|
10
|
-
| `session` | string | `undefined` | Session ID for the chat. Required for the chat to function. |
|
|
11
|
-
| `apiKey` | string | `toolkit-test` | API key for authentication. Required for the chat to function. |
|
|
12
|
-
| `agentId` | string | `default` | Agent ID for the chat. Required for the chat to function. |
|
|
13
|
-
| `messageFilter` | MessageFilter | `undefined` | Optional function to filter and transform messages before they are displayed in the chat interface. |
|
|
14
|
-
| `messageStorage`| MessageStorage| `InMemoryMessageStorage` | Optional storage implementation for persisting messages. |
|
|
15
|
-
| `threads` | boolean | `false` | Enable thread management. |
|
|
16
|
-
| `tools` | object\|array | `undefined` | Custom tools for the Transaction Protocol. |
|
package/docs/contributing.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
We welcome contributions! To get started:
|
|
4
|
-
|
|
5
|
-
1. Fork the repository.
|
|
6
|
-
2. Create a new branch for your feature or bugfix.
|
|
7
|
-
3. Submit a pull request with a detailed description of your changes.
|
|
8
|
-
|
|
9
|
-
Please ensure your code adheres to the existing style and passes all linting and testing checks.
|
|
10
|
-
|
|
11
|
-
## Support
|
|
12
|
-
|
|
13
|
-
For questions or support, contact us at [info@applica.guru](mailto:info@applica.guru).
|
|
14
|
-
|
|
15
|
-
## License
|
|
16
|
-
|
|
17
|
-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
18
|
-
|
|
19
|
-
## Acknowledgments
|
|
20
|
-
|
|
21
|
-
This SDK is built on top of [assistant-ui](https://www.assistant-ui.com/), a powerful framework for building conversational interfaces.
|
package/docs/customization.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Customization
|
|
2
|
-
|
|
3
|
-
The Persona SDK allows you to extend its functionality by creating custom protocols and loggers.
|
|
4
|
-
|
|
5
|
-
## Custom Protocols
|
|
6
|
-
|
|
7
|
-
You can implement your own protocol by extending the `PersonaProtocolBase` class. For example:
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
import { PersonaProtocolBase } from '@applica-software-guru/persona-sdk';
|
|
11
|
-
|
|
12
|
-
class CustomProtocol extends PersonaProtocolBase {
|
|
13
|
-
// Implement required methods like connect, disconnect, send, etc.
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Example: Custom Protocol Implementation
|
|
18
|
-
|
|
19
|
-
Here’s an example of a custom protocol named `CustomProtocol`:
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { PersonaProtocolBase } from '@applica-software-guru/persona-sdk';
|
|
23
|
-
|
|
24
|
-
class CustomProtocol extends PersonaProtocolBase {
|
|
25
|
-
public getName(): string {
|
|
26
|
-
return 'custom';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public async connect(): Promise<void> {
|
|
30
|
-
console.log('[CustomProtocol] Connecting...');
|
|
31
|
-
this.setStatus('connected');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public async disconnect(): Promise<void> {
|
|
35
|
-
console.log('[CustomProtocol] Disconnecting...');
|
|
36
|
-
this.setStatus('disconnected');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public async send(message: string): Promise<void> {
|
|
40
|
-
console.log(`[CustomProtocol] Sending message: ${message}`);
|
|
41
|
-
this.notifyMessage({ role: 'assistant', type: 'text', text: `Echo: ${message}` });
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Custom Loggers
|
|
47
|
-
|
|
48
|
-
You can create a custom logger by implementing the `PersonaLogger` interface:
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
import { PersonaLogger } from '@applica-software-guru/persona-sdk';
|
|
52
|
-
|
|
53
|
-
class CustomLogger implements PersonaLogger {
|
|
54
|
-
log(message: string, ...args: unknown[]): void {
|
|
55
|
-
console.log(`[CustomLogger] ${message}`, ...args);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
info(message: string, ...args: unknown[]): void {
|
|
59
|
-
console.info(`[CustomLogger] ${message}`, ...args);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
warn(message: string, ...args: unknown[]): void {
|
|
63
|
-
console.warn(`[CustomLogger] ${message}`, ...args);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
error(message: string, ...args: unknown[]): void {
|
|
67
|
-
console.error(`[CustomLogger] ${message}`, ...args);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
debug(message: string, ...args: unknown[]): void {
|
|
71
|
-
console.debug(`[CustomLogger] ${message}`, ...args);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
package/docs/features.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Features
|
|
2
|
-
|
|
3
|
-
- **Custom Runtime Provider**: Easily integrate the Persona API with assistant-ui chat.
|
|
4
|
-
- **Local Runtime Support**: Run the assistant-ui chat locally using the Persona API.
|
|
5
|
-
- **Multiple Protocols**: Supports REST, WebSocket, and WebRTC protocols.
|
|
6
|
-
- **WebRTC Optimization**: Communicate with AI agents in real-time using the fastest protocol available.
|
|
7
|
-
- **Customizable**: Extend functionality with custom protocols and loggers.
|
package/docs/installation.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# Installation
|
|
2
|
-
|
|
3
|
-
To get started, install the Persona SDK using npm or yarn:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm install @applica-software-guru/persona-sdk
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
If you don't already have an assistant-ui-based project, you can create one using the [Assistant UI Getting Started Guide](https://www.assistant-ui.com/docs/getting-started).
|
package/docs/messages.md
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
# Messages and Storage
|
|
2
|
-
|
|
3
|
-
## Accessing Messages
|
|
4
|
-
|
|
5
|
-
### usePersonaRuntimeMessages
|
|
6
|
-
|
|
7
|
-
The `usePersonaRuntimeMessages` hook provides a simple way to access the current list of messages managed by the Persona SDK runtime. This hook returns an array of `PersonaMessage` objects, which represent the conversation history, including user, assistant, and reasoning messages.
|
|
8
|
-
|
|
9
|
-
**Usage Example:**
|
|
10
|
-
|
|
11
|
-
```tsx
|
|
12
|
-
import { usePersonaRuntimeMessages } from '@applica-software-guru/persona-sdk';
|
|
13
|
-
|
|
14
|
-
function MessageLogger() {
|
|
15
|
-
const messages = usePersonaRuntimeMessages();
|
|
16
|
-
return (
|
|
17
|
-
<div>
|
|
18
|
-
<h3>Messages</h3>
|
|
19
|
-
<pre>{JSON.stringify(messages, null, 2)}</pre>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
This hook must be used within a `PersonaRuntimeProvider`.
|
|
26
|
-
|
|
27
|
-
### usePersonaRuntime and getMessages
|
|
28
|
-
|
|
29
|
-
The `usePersonaRuntime` hook gives you access to the Persona runtime context, which now includes a `getMessages` method. This method returns the current array of `PersonaMessage` objects, allowing you to programmatically retrieve the latest messages at any time.
|
|
30
|
-
|
|
31
|
-
**Usage Example:**
|
|
32
|
-
|
|
33
|
-
```tsx
|
|
34
|
-
import { usePersonaRuntime } from '@applica-software-guru/persona-sdk';
|
|
35
|
-
|
|
36
|
-
function MyComponent() {
|
|
37
|
-
const { getMessages } = usePersonaRuntime();
|
|
38
|
-
const messages = getMessages();
|
|
39
|
-
// Use messages as needed
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Both approaches are useful for building custom UI components, analytics, or debugging tools that need access to the chat history.
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## Message Filtering
|
|
48
|
-
|
|
49
|
-
The `messageFilter` prop allows you to process and filter messages before they are displayed in the chat interface. This provides powerful customization capabilities for controlling what messages users see and how they are presented.
|
|
50
|
-
|
|
51
|
-
### Basic Usage
|
|
52
|
-
|
|
53
|
-
Add a `messageFilter` function to your `PersonaRuntimeProvider`:
|
|
54
|
-
|
|
55
|
-
```tsx
|
|
56
|
-
import { PersonaRuntimeProvider, MessageFilter, PersonaMessage } from '@applica-software-guru/persona-sdk';
|
|
57
|
-
|
|
58
|
-
const myMessageFilter: MessageFilter = (messages: PersonaMessage[]) => {
|
|
59
|
-
// Process and return the filtered messages
|
|
60
|
-
return messages.filter((message) => message.type !== 'reasoning');
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
function App() {
|
|
64
|
-
return (
|
|
65
|
-
<PersonaRuntimeProvider apiKey="your-api-key" agentId="your-agent-id" protocols={{ rest: true }} messageFilter={myMessageFilter}>
|
|
66
|
-
{/* Your app content */}
|
|
67
|
-
</PersonaRuntimeProvider>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### MessageFilter Type
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
type MessageFilter = (messages: PersonaMessage[]) => PersonaMessage[];
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
The function receives an array of `PersonaMessage` objects and must return an array of `PersonaMessage` objects.
|
|
79
|
-
|
|
80
|
-
### Common Use Cases
|
|
81
|
-
|
|
82
|
-
#### 1. Hide Reasoning Messages
|
|
83
|
-
|
|
84
|
-
```tsx
|
|
85
|
-
const hideReasoningFilter: MessageFilter = (messages) => {
|
|
86
|
-
return messages.filter((message) => message.type !== 'reasoning');
|
|
87
|
-
};
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
#### 2. Content Filtering
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
const profanityFilter: MessageFilter = (messages) => {
|
|
94
|
-
const bannedWords = ['spam', 'inappropriate'];
|
|
95
|
-
return messages.filter((message) => {
|
|
96
|
-
const text = message.text.toLowerCase();
|
|
97
|
-
return !bannedWords.some((word) => text.includes(word));
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
#### 3. Message Limit
|
|
103
|
-
|
|
104
|
-
```tsx
|
|
105
|
-
const messageLimitFilter: MessageFilter = (messages) => {
|
|
106
|
-
const maxMessages = 50;
|
|
107
|
-
return messages.length > maxMessages ? messages.slice(-maxMessages) : messages;
|
|
108
|
-
};
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
#### 4. Text Transformation
|
|
112
|
-
|
|
113
|
-
```tsx
|
|
114
|
-
const transformTextFilter: MessageFilter = (messages) => {
|
|
115
|
-
return messages.map((message) => ({
|
|
116
|
-
...message,
|
|
117
|
-
text: message.text.replace(/\b(TODO|FIXME)\b/g, '⚠️ $1'),
|
|
118
|
-
}));
|
|
119
|
-
};
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
#### 5. Combining Multiple Filters
|
|
123
|
-
|
|
124
|
-
```tsx
|
|
125
|
-
const combinedFilter: MessageFilter = (messages) => {
|
|
126
|
-
let filtered = hideReasoningFilter(messages);
|
|
127
|
-
filtered = profanityFilter(filtered);
|
|
128
|
-
filtered = messageLimitFilter(filtered);
|
|
129
|
-
return filtered;
|
|
130
|
-
};
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## Message Storage
|
|
136
|
-
|
|
137
|
-
The Persona SDK provides a flexible message storage system that allows you to persist conversation history across sessions. By default, messages are stored in memory, but you can easily switch to localStorage or implement your own custom storage solution.
|
|
138
|
-
|
|
139
|
-
### Storage Implementations
|
|
140
|
-
|
|
141
|
-
#### InMemoryMessageStorage (Default)
|
|
142
|
-
|
|
143
|
-
Messages are stored in memory and lost on page reload. This is the default if no storage is specified.
|
|
144
|
-
|
|
145
|
-
```tsx
|
|
146
|
-
import { PersonaRuntimeProvider, InMemoryMessageStorage } from '@applica-software-guru/persona-sdk';
|
|
147
|
-
|
|
148
|
-
const storage = new InMemoryMessageStorage();
|
|
149
|
-
|
|
150
|
-
<PersonaRuntimeProvider apiKey="your-api-key" agentId="your-agent-id" protocols={{ rest: true }} threads={true} messageStorage={storage}>
|
|
151
|
-
{/* Your app */}
|
|
152
|
-
</PersonaRuntimeProvider>;
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
#### LocalStorageMessageStorage
|
|
156
|
-
|
|
157
|
-
Messages persist across page reloads using browser localStorage.
|
|
158
|
-
|
|
159
|
-
```tsx
|
|
160
|
-
import { PersonaRuntimeProvider, LocalStorageMessageStorage } from '@applica-software-guru/persona-sdk';
|
|
161
|
-
|
|
162
|
-
const storage = new LocalStorageMessageStorage('my_app_messages_');
|
|
163
|
-
|
|
164
|
-
<PersonaRuntimeProvider apiKey="your-api-key" agentId="your-agent-id" protocols={{ rest: true }} threads={true} messageStorage={storage}>
|
|
165
|
-
{/* Your app */}
|
|
166
|
-
</PersonaRuntimeProvider>;
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Custom Storage Implementation
|
|
170
|
-
|
|
171
|
-
You can implement your own storage solution by implementing the `MessageStorage` interface:
|
|
172
|
-
|
|
173
|
-
```tsx
|
|
174
|
-
import { MessageStorage, PersonaMessage, Session } from '@applica-software-guru/persona-sdk';
|
|
175
|
-
|
|
176
|
-
class CustomMessageStorage implements MessageStorage {
|
|
177
|
-
async saveMessages(sessionId: Session, messages: PersonaMessage[]): Promise<void> {
|
|
178
|
-
// Your custom save logic (e.g., IndexedDB, remote API)
|
|
179
|
-
await fetch('/api/save-messages', {
|
|
180
|
-
method: 'POST',
|
|
181
|
-
body: JSON.stringify({ sessionId, messages }),
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async loadMessages(sessionId: Session): Promise<PersonaMessage[]> {
|
|
186
|
-
// Your custom load logic
|
|
187
|
-
const response = await fetch(`/api/load-messages/${sessionId}`);
|
|
188
|
-
return await response.json();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
async deleteMessages(sessionId: Session): Promise<void> {
|
|
192
|
-
// Your custom delete logic
|
|
193
|
-
await fetch(`/api/delete-messages/${sessionId}`, { method: 'DELETE' });
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async clearAll(): Promise<void> {
|
|
197
|
-
// Clear all messages
|
|
198
|
-
await fetch('/api/clear-all-messages', { method: 'DELETE' });
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
async getAllSessionIds(): Promise<Session[]> {
|
|
202
|
-
// Get all session IDs
|
|
203
|
-
const response = await fetch('/api/session-ids');
|
|
204
|
-
return await response.json();
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const customStorage = new CustomMessageStorage();
|
|
209
|
-
|
|
210
|
-
<PersonaRuntimeProvider
|
|
211
|
-
messageStorage={customStorage}
|
|
212
|
-
// ... other props
|
|
213
|
-
/>;
|
|
214
|
-
```
|
package/docs/protocols.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# Protocols
|
|
2
|
-
|
|
3
|
-
The Persona SDK supports multiple communication protocols to provide flexibility and performance. These protocols can work together, sharing the same session and data, to ensure the best possible experience.
|
|
4
|
-
|
|
5
|
-
## Protocols Overview
|
|
6
|
-
|
|
7
|
-
### REST
|
|
8
|
-
|
|
9
|
-
- **Description**: A simple and reliable protocol for sending and receiving data.
|
|
10
|
-
- **Use Case**: Ideal for applications where real-time communication is not critical.
|
|
11
|
-
|
|
12
|
-
### WebSocket
|
|
13
|
-
|
|
14
|
-
- **Description**: A full-duplex communication protocol that enables real-time interaction between the client and server.
|
|
15
|
-
- **Use Case**: Suitable for scenarios requiring low-latency communication, such as live chat applications.
|
|
16
|
-
|
|
17
|
-
### WebRTC
|
|
18
|
-
|
|
19
|
-
- **Description**: A peer-to-peer communication protocol designed primarily for ultra-fast audio sessions, while also supporting high-speed messaging with minimal latency.
|
|
20
|
-
- **Use Case**: Perfect for real-time, interactive applications where rapid audio communication and responsiveness are critical.
|
|
21
|
-
- **Why WebRTC?**: By creating direct peer-to-peer connections, WebRTC eliminates unnecessary server delays, ensuring the fastest possible audio sessions and seamless message exchanges.
|
|
22
|
-
|
|
23
|
-
**Pro Tip**: For optimal audio performance, make sure WebRTC is enabled in the `protocols` configuration of your application.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## How Protocols Work Together
|
|
28
|
-
|
|
29
|
-
The Persona SDK runtime is designed to use multiple protocols simultaneously, ensuring flexibility and reliability. Here’s how it works:
|
|
30
|
-
|
|
31
|
-
1. **Shared Session**: All protocols share the same session and operate on the same data, ensuring consistency across communication channels.
|
|
32
|
-
2. **Protocol Selection**: The runtime automatically selects the fastest and most reliable protocol from the list of enabled protocols. For example:
|
|
33
|
-
- If WebRTC is available and started, it will be prioritized for its ultra-low latency.
|
|
34
|
-
- If WebRTC is not available, WebSocket will be used for real-time communication.
|
|
35
|
-
- REST will act as a fallback for non-real-time communication.
|
|
36
|
-
3. **WebRTC Startup**: WebRTC requires manual startup by the user (e.g., clicking a microphone icon to enable audio/video). Once started, WebRTC participates in the list of reliable protocols and is used for the fastest communication.
|
|
37
|
-
4. **Seamless Integration**: Even if WebRTC is not started, other protocols like WebSocket and REST will continue to function, ensuring uninterrupted communication.
|
|
38
|
-
|
|
39
|
-
This design allows the Persona SDK to adapt dynamically to the available protocols, providing the best possible performance and reliability.
|