@adaptive-ai/sdk 0.1.0 → 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/dist/client/index.d.ts +31 -102
- package/dist/client/index.js +126 -7
- package/dist/server/index.d.ts +84 -378
- package/dist/server/index.js +2 -2
- package/package.json +9 -6
package/dist/server/index.d.ts
CHANGED
|
@@ -1,392 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
import { createTRPCProxyClient } from '@trpc/client';
|
|
3
4
|
|
|
4
|
-
declare const ProductKind: {
|
|
5
|
-
readonly SUBSCRIPTION: "SUBSCRIPTION";
|
|
6
|
-
readonly IN_APP_PURCHASE: "IN_APP_PURCHASE";
|
|
7
|
-
};
|
|
8
|
-
type ProductKind = (typeof ProductKind)[keyof typeof ProductKind];
|
|
9
5
|
declare const AuthProvider: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
type AuthProvider = (typeof AuthProvider)[keyof typeof AuthProvider];
|
|
24
|
-
type CatalogVoice = {
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
description?: string;
|
|
28
|
-
previewUrl: string;
|
|
29
|
-
tier: 'FREE' | 'ONE' | 'TWO';
|
|
6
|
+
readonly GITHUB_USER: "GITHUB_USER";
|
|
7
|
+
readonly GITHUB_BOT: "GITHUB_BOT";
|
|
8
|
+
readonly GOOGLE: "GOOGLE";
|
|
9
|
+
readonly AC1: "AC1";
|
|
10
|
+
readonly SLACK: "SLACK";
|
|
11
|
+
readonly SLACK_BOT: "SLACK_BOT";
|
|
12
|
+
readonly DISCORD: "DISCORD";
|
|
13
|
+
readonly NOTION: "NOTION";
|
|
14
|
+
readonly TWITTER: "TWITTER";
|
|
15
|
+
readonly LINKEDIN: "LINKEDIN";
|
|
16
|
+
readonly YAHOO: "YAHOO";
|
|
17
|
+
readonly FIGMA: "FIGMA";
|
|
30
18
|
};
|
|
31
|
-
type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
export type AuthProvider = (typeof AuthProvider)[keyof typeof AuthProvider];
|
|
20
|
+
export type ProviderInput = {
|
|
21
|
+
provider: AuthProvider;
|
|
22
|
+
scope?: string[];
|
|
23
|
+
redirectUri?: string;
|
|
36
24
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*/
|
|
51
|
-
type: 'pdf_url';
|
|
52
|
-
}
|
|
53
|
-
declare namespace ChatCompletionContentPartPDF {
|
|
54
|
-
interface PDFURL {
|
|
55
|
-
/**
|
|
56
|
-
* The URL of the PDF file.
|
|
57
|
-
*/
|
|
58
|
-
url: string;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
interface ChatCompletionContentPartVideo {
|
|
62
|
-
video_url: ChatCompletionContentPartVideo.VideoURL;
|
|
63
|
-
/**
|
|
64
|
-
* The type of the content part.
|
|
65
|
-
*/
|
|
66
|
-
type: 'video_url';
|
|
67
|
-
}
|
|
68
|
-
declare namespace ChatCompletionContentPartVideo {
|
|
69
|
-
interface VideoURL {
|
|
70
|
-
/**
|
|
71
|
-
* The URL of the video file.
|
|
72
|
-
*/
|
|
73
|
-
url: string;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
interface ChatCompletionContentPartAudio {
|
|
77
|
-
audio_url: ChatCompletionContentPartAudio.AudioURL;
|
|
78
|
-
/**
|
|
79
|
-
* The type of the content part.
|
|
80
|
-
*/
|
|
81
|
-
type: 'audio_url';
|
|
82
|
-
}
|
|
83
|
-
declare namespace ChatCompletionContentPartAudio {
|
|
84
|
-
interface AudioURL {
|
|
85
|
-
/**
|
|
86
|
-
* The URL of the audio file.
|
|
87
|
-
*/
|
|
88
|
-
url: string;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
type ExternalApiMessage = {
|
|
92
|
-
role: Exclude<ChatCompletionMessageParam['role'], 'function'>;
|
|
93
|
-
content?: string | Array<(ChatCompletionContentPart & {
|
|
94
|
-
cache_control?: {
|
|
95
|
-
type: 'ephemeral';
|
|
96
|
-
};
|
|
97
|
-
}) | (ChatCompletionContentPartPDF & {
|
|
98
|
-
cache_control?: {
|
|
99
|
-
type: 'ephemeral';
|
|
100
|
-
};
|
|
101
|
-
}) | (ChatCompletionContentPartVideo & {
|
|
102
|
-
cache_control?: {
|
|
103
|
-
type: 'ephemeral';
|
|
104
|
-
};
|
|
105
|
-
}) | (ChatCompletionContentPartAudio & {
|
|
106
|
-
cache_control?: {
|
|
107
|
-
type: 'ephemeral';
|
|
108
|
-
};
|
|
109
|
-
})>;
|
|
110
|
-
id?: string;
|
|
111
|
-
tool_call_id?: string | null;
|
|
112
|
-
tool_calls?: Array<ChatCompletionMessageFunctionToolCall> | null;
|
|
113
|
-
thinking?: ChatCompletionContentPartThinking;
|
|
114
|
-
name?: 'client' | 'attachments' | keyof typeof AgentDefinitions | null;
|
|
25
|
+
export type RedirectInput = {
|
|
26
|
+
email: string;
|
|
27
|
+
provider: "AC1";
|
|
28
|
+
phoneNumber: null | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
phoneNumber: string;
|
|
31
|
+
provider: "AC1";
|
|
32
|
+
email: null | undefined;
|
|
33
|
+
} | ProviderInput;
|
|
34
|
+
export type RequestContext = {
|
|
35
|
+
requestId: string;
|
|
36
|
+
channelId?: string;
|
|
37
|
+
hasTasks?: boolean;
|
|
115
38
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
fromUserId: string;
|
|
121
|
-
}
|
|
122
|
-
interface Window {
|
|
123
|
-
__VERSION_ID__?: string;
|
|
124
|
-
__APP_ID__: string;
|
|
125
|
-
__IS_TESTING__: boolean;
|
|
126
|
-
__ROOT_URL__: string;
|
|
127
|
-
__BASE_URL__: string;
|
|
128
|
-
__REALTIME_DOMAIN__: string;
|
|
129
|
-
__OPEN_AUTH_DRAWER__: (url: string) => void;
|
|
130
|
-
}
|
|
131
|
-
var env: {
|
|
132
|
-
BASE_URL: string;
|
|
133
|
-
REALTIME_DOMAIN: string;
|
|
134
|
-
GUEST_SERVICES_URL: string;
|
|
135
|
-
};
|
|
39
|
+
export interface EmailHandlerInput {
|
|
40
|
+
subject: string;
|
|
41
|
+
body: string;
|
|
42
|
+
fromUserId: string;
|
|
136
43
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
declare function initializeServerEnvironment({ baseUrl, realtimeDomain, guestServicesUrl, }: {
|
|
144
|
-
baseUrl: string;
|
|
145
|
-
realtimeDomain: string;
|
|
146
|
-
guestServicesUrl: string;
|
|
44
|
+
declare let client: ReturnType<typeof createTRPCProxyClient<GuestServicesRouter>>;
|
|
45
|
+
export declare function initializeServerEnvironment({ baseUrl, realtimeDomain, guestServicesUrl, }: {
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
realtimeDomain: string;
|
|
48
|
+
guestServicesUrl: string;
|
|
147
49
|
}): void;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
50
|
+
export type MutationProxy<TClient> = {
|
|
51
|
+
[K in keyof TClient as TClient[K] extends {
|
|
52
|
+
mutate: (...args: any) => any;
|
|
53
|
+
} ? K : never]: TClient[K] extends {
|
|
54
|
+
mutate: (...args: infer TArgs) => infer TReturn;
|
|
55
|
+
} ? (args: TArgs[0]) => TReturn : never;
|
|
56
|
+
};
|
|
57
|
+
export type MCP = MutationProxy<typeof client>;
|
|
58
|
+
export declare const mcp: MCP;
|
|
59
|
+
export declare function getRequestContext(): RequestContext | undefined;
|
|
60
|
+
export declare function setRequestContext(context: Partial<RequestContext>): void;
|
|
61
|
+
export declare function runWithContext<T>(context: RequestContext, fn: () => Promise<T>): Promise<T>;
|
|
62
|
+
export declare function getBaseUrl(): string;
|
|
63
|
+
export declare function getLastStreamTime(): number | null;
|
|
64
|
+
export declare function getRealtimeStore<T extends object>({ channelId, onUpdate, }: {
|
|
65
|
+
channelId: string;
|
|
66
|
+
onUpdate?: (data: T) => void;
|
|
67
|
+
}): {
|
|
68
|
+
destroy(): void;
|
|
161
69
|
};
|
|
70
|
+
export declare function setRealtimeStore<T extends object>({ channelId, data, }: {
|
|
71
|
+
channelId: string;
|
|
72
|
+
data: T;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
export declare function startRealtimeResponse<T extends object>(): Promise<{
|
|
75
|
+
next(data: T): void;
|
|
76
|
+
end(): T;
|
|
77
|
+
}>;
|
|
162
78
|
declare function signIn(input?: RedirectInput): void;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
userId: string;
|
|
169
|
-
signIn: typeof signIn;
|
|
170
|
-
providers: AuthProvider[];
|
|
79
|
+
export type AuthStatus = {
|
|
80
|
+
status: "authenticated";
|
|
81
|
+
userId: string;
|
|
82
|
+
signIn: typeof signIn;
|
|
83
|
+
providers: AuthProvider[];
|
|
171
84
|
} | {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
85
|
+
status: "unauthenticated";
|
|
86
|
+
userId: null;
|
|
87
|
+
signIn: typeof signIn;
|
|
88
|
+
providers: [
|
|
89
|
+
];
|
|
176
90
|
};
|
|
177
|
-
declare function getAuth(input: {
|
|
178
|
-
|
|
91
|
+
export declare function getAuth(input: {
|
|
92
|
+
required: true;
|
|
179
93
|
}): Promise<AuthStatus>;
|
|
180
|
-
declare function getAuth(input?: {
|
|
181
|
-
|
|
94
|
+
export declare function getAuth(input?: {
|
|
95
|
+
required?: boolean;
|
|
182
96
|
}): Promise<AuthStatus>;
|
|
183
|
-
type TaskStatus = {
|
|
184
|
-
id: string;
|
|
185
|
-
status: 'RUNNING' | 'COMPLETED' | 'FAILED';
|
|
186
|
-
error?: any;
|
|
187
|
-
} | {
|
|
188
|
-
id: string;
|
|
189
|
-
status: 'UNKNOWN';
|
|
190
|
-
};
|
|
191
|
-
declare function queueTask(runner: () => Promise<void>): Promise<TaskStatus>;
|
|
192
|
-
declare function getTaskStatus(taskId: string): Promise<TaskStatus>;
|
|
193
|
-
declare function getStructuredDataFromContent<T>(input: {
|
|
194
|
-
url: string;
|
|
195
|
-
base64?: never;
|
|
196
|
-
schema: z.ZodSchema<T>;
|
|
197
|
-
} | {
|
|
198
|
-
url?: never;
|
|
199
|
-
base64: string;
|
|
200
|
-
schema: z.ZodSchema<T>;
|
|
201
|
-
}): Promise<T>;
|
|
202
|
-
declare function extractTextFromContent(input: {
|
|
203
|
-
url: string;
|
|
204
|
-
base64?: never;
|
|
205
|
-
outputFormat: 'raw' | 'formatted-markdown';
|
|
206
|
-
} | {
|
|
207
|
-
url?: never;
|
|
208
|
-
base64: string;
|
|
209
|
-
outputFormat: 'raw' | 'formatted-markdown';
|
|
210
|
-
}): Promise<string>;
|
|
211
|
-
declare function requestMultimodalModel<T>(input: {
|
|
212
|
-
messages: ExternalApiMessage[];
|
|
213
|
-
system?: string;
|
|
214
|
-
returnType: z.ZodSchema<T>;
|
|
215
|
-
model?: 'small' | 'medium' | 'large';
|
|
216
|
-
temperature?: number;
|
|
217
|
-
stream?: (data: Partial<T>) => void;
|
|
218
|
-
onProgress?: (data: Array<{
|
|
219
|
-
toolName: string;
|
|
220
|
-
inProgressMessage: string;
|
|
221
|
-
status: 'in_progress' | 'done';
|
|
222
|
-
thinking: string;
|
|
223
|
-
}>) => void;
|
|
224
|
-
customTools?: Array<{
|
|
225
|
-
name: string;
|
|
226
|
-
displayName: string;
|
|
227
|
-
description: string;
|
|
228
|
-
inputSchema: z.ZodSchema<any>;
|
|
229
|
-
inProgressMessage: string;
|
|
230
|
-
}>;
|
|
231
|
-
}): Promise<T>;
|
|
232
|
-
declare function textToImage(input: {
|
|
233
|
-
text: string;
|
|
234
|
-
size?: 'square_hd' | 'square' | 'portrait_4_3' | 'portrait_16_9' | 'landscape_4_3' | 'landscape_16_9';
|
|
235
|
-
}): Promise<string | null>;
|
|
236
|
-
declare function textToSpeech(input: {
|
|
237
|
-
text: string;
|
|
238
|
-
voice?: 'Will' | 'Brian' | 'George' | 'Jessica' | 'Liam' | 'Alice' | 'Sarah' | 'Charlotte' | 'Matilda' | 'Eric' | 'Alloy' | 'Ash' | 'Ballad' | 'Coral' | 'Echo' | 'Fable' | 'Nova' | 'Onyx' | 'Sage' | 'Shimmer';
|
|
239
|
-
}): Promise<{
|
|
240
|
-
url: string;
|
|
241
|
-
duration: number | undefined;
|
|
242
|
-
} | null>;
|
|
243
|
-
declare function generateSoundEffect(input: {
|
|
244
|
-
text: string;
|
|
245
|
-
durationInSeconds?: number;
|
|
246
|
-
promptInfluence?: number;
|
|
247
|
-
loop?: boolean;
|
|
248
|
-
}): Promise<any>;
|
|
249
|
-
declare function generateDialogue(input: {
|
|
250
|
-
inputs: {
|
|
251
|
-
character: string;
|
|
252
|
-
text: string;
|
|
253
|
-
}[];
|
|
254
|
-
}): Promise<{
|
|
255
|
-
url: string;
|
|
256
|
-
duration: number | undefined;
|
|
257
|
-
}>;
|
|
258
|
-
declare function generateMusic(input: {
|
|
259
|
-
text: string;
|
|
260
|
-
}): Promise<string>;
|
|
261
|
-
declare function upload(input: {
|
|
262
|
-
bufferOrBase64: Buffer | string;
|
|
263
|
-
fileName: string;
|
|
264
|
-
}): Promise<string>;
|
|
265
|
-
declare function getOAuthToken(input: {
|
|
266
|
-
connectionId: string;
|
|
267
|
-
}): Promise<{
|
|
268
|
-
connectionId: string;
|
|
269
|
-
userId: string | null;
|
|
270
|
-
accessToken: string | null;
|
|
271
|
-
expiresAt: Date | null;
|
|
272
|
-
scope: string[];
|
|
273
|
-
}>;
|
|
274
|
-
declare function getOAuthConnectionForCurrentUser(input: {
|
|
275
|
-
provider: Exclude<AuthProvider, 'AC1'>;
|
|
276
|
-
scope?: string[];
|
|
277
|
-
required?: boolean;
|
|
278
|
-
}): Promise<{
|
|
279
|
-
id: string;
|
|
280
|
-
provider: string;
|
|
281
|
-
userId: string | undefined;
|
|
282
|
-
scope: string[];
|
|
283
|
-
} | null>;
|
|
284
|
-
declare function getOAuthConnection(input: {
|
|
285
|
-
connectionId: string;
|
|
286
|
-
}): Promise<{
|
|
287
|
-
id: string;
|
|
288
|
-
provider: string;
|
|
289
|
-
userId: string | undefined;
|
|
290
|
-
scope: string[];
|
|
291
|
-
}>;
|
|
292
|
-
declare function queryOAuthConnections(input: {
|
|
293
|
-
userId?: string;
|
|
294
|
-
provider?: Exclude<AuthProvider, 'AC1'>;
|
|
295
|
-
scope?: string[];
|
|
296
|
-
}): Promise<{
|
|
297
|
-
id: string;
|
|
298
|
-
provider: string;
|
|
299
|
-
userId: string | undefined;
|
|
300
|
-
scope: string[];
|
|
301
|
-
}[]>;
|
|
302
|
-
declare function deleteOAuthConnection(input: {
|
|
303
|
-
connectionId: string;
|
|
304
|
-
}): Promise<{
|
|
305
|
-
readonly ok: true;
|
|
306
|
-
}>;
|
|
307
|
-
declare function sendEmail(input: {
|
|
308
|
-
markdown: string;
|
|
309
|
-
subject: string;
|
|
310
|
-
toUserId: string;
|
|
311
|
-
}): Promise<void>;
|
|
312
|
-
declare function inviteUser(input: {
|
|
313
|
-
email: string;
|
|
314
|
-
subject?: string;
|
|
315
|
-
markdown: string;
|
|
316
|
-
unauthenticatedLinks?: boolean;
|
|
317
|
-
}): Promise<{
|
|
318
|
-
id: string;
|
|
319
|
-
}>;
|
|
320
|
-
declare function searchWithGoogle(input: {
|
|
321
|
-
query: string;
|
|
322
|
-
}): Promise<{
|
|
323
|
-
answer: string | undefined;
|
|
324
|
-
sources: {
|
|
325
|
-
title: string;
|
|
326
|
-
url: string;
|
|
327
|
-
}[];
|
|
328
|
-
}>;
|
|
329
|
-
declare function isAppOwner(): Promise<boolean>;
|
|
330
|
-
declare function generateCrossAppToken(input: {
|
|
331
|
-
appId: string;
|
|
332
|
-
}): Promise<string>;
|
|
333
|
-
declare function createProduct(input: {
|
|
334
|
-
name: string;
|
|
335
|
-
description: string;
|
|
336
|
-
price: number;
|
|
337
|
-
kind: ProductKind;
|
|
338
|
-
}): Promise<{
|
|
339
|
-
purchaseLink: string;
|
|
340
|
-
id: string;
|
|
341
|
-
description: string;
|
|
342
|
-
name: string;
|
|
343
|
-
kind: ProductKind;
|
|
344
|
-
price: number;
|
|
345
|
-
}>;
|
|
346
|
-
declare function listProducts(): Promise<{
|
|
347
|
-
id: string;
|
|
348
|
-
name: string;
|
|
349
|
-
description: string;
|
|
350
|
-
kind: ProductKind;
|
|
351
|
-
price: number;
|
|
352
|
-
purchaseLink: string;
|
|
353
|
-
}[]>;
|
|
354
|
-
declare function listUserPurchases(input?: {
|
|
355
|
-
userId: string;
|
|
356
|
-
}): Promise<{
|
|
357
|
-
id: string;
|
|
358
|
-
kind: ProductKind;
|
|
359
|
-
description: string;
|
|
360
|
-
name: string;
|
|
361
|
-
price: number;
|
|
362
|
-
}[]>;
|
|
363
|
-
declare function discontinueProduct(input: {
|
|
364
|
-
productId: string;
|
|
365
|
-
}): Promise<void>;
|
|
366
|
-
declare function getRealtimeStore<T extends object>({ channelId, onUpdate, }: {
|
|
367
|
-
channelId: string;
|
|
368
|
-
onUpdate?: (data: T) => void;
|
|
369
|
-
}): {
|
|
370
|
-
destroy(): void;
|
|
371
|
-
};
|
|
372
|
-
declare function setRealtimeStore<T extends object>({ channelId, data, }: {
|
|
373
|
-
channelId: string;
|
|
374
|
-
data: T;
|
|
375
|
-
}): Promise<void>;
|
|
376
|
-
declare function startRealtimeResponse<T extends object>(): Promise<{
|
|
377
|
-
next(data: T): void;
|
|
378
|
-
end(): T;
|
|
379
|
-
}>;
|
|
380
|
-
declare function getTTSVoicesCatalog(input: {
|
|
381
|
-
limit: number;
|
|
382
|
-
}): Promise<CatalogVoice[]>;
|
|
383
|
-
declare function getDialogueVoicesCatalog(input: {
|
|
384
|
-
limit: number;
|
|
385
|
-
}): Promise<CatalogVoice[]>;
|
|
386
|
-
declare function getImageModelsCatalog(input: {
|
|
387
|
-
limit: number;
|
|
388
|
-
}): Promise<CatalogImageModel[]>;
|
|
389
|
-
declare function getBaseUrl(): string;
|
|
390
|
-
declare function getLastStreamTime(): number | null;
|
|
391
97
|
|
|
392
|
-
export {
|
|
98
|
+
export {};
|
package/dist/server/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {createTRPCProxyClient,httpLink}from'@trpc/client';import {AsyncLocalStorage}from'async_hooks';import
|
|
2
|
-
export{
|
|
1
|
+
import {createTRPCProxyClient,httpLink}from'@trpc/client';import {AsyncLocalStorage}from'async_hooks';import g from'superjson';function S(e){let r=Object.create(null);for(let t in e){let n=e[t];r[n]=t;}return r}var w={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};S(w);S(w);typeof window>"u"||"Deno"in window||globalThis.process?.env?.NODE_ENV==="test"||!!globalThis.process?.env?.JEST_WORKER_ID||!!globalThis.process?.env?.VITEST_WORKER_ID;var y=class e extends Error{static prefix="__MISSING AUTH FOR SCOPE";static jsonRpcCode=-32001;constructor({provider:r,scope:t,accountId:n,popup:o=false}){let s=btoa(JSON.stringify({provider:r,scope:t,accountId:n}));super(`${e.prefix}: ${s}${o?" --popup":" end"}`);}jsonRpcError(){return {code:e.jsonRpcCode,message:this.message}}static check(r){return r?.message?.startsWith(e.prefix)}};var C=null;function je({baseUrl:e,realtimeDomain:r,guestServicesUrl:t}){globalThis.env||(globalThis.env={},globalThis.env.BASE_URL=e,globalThis.env.REALTIME_DOMAIN=r,globalThis.env.GUEST_SERVICES_URL=t,C=createTRPCProxyClient({transformer:g,links:[httpLink({url:t,transformer:g,headers:()=>{let n=A();if(!n)throw new Error("Missing request context");return {"x-request-id":n.requestId}}})]}),console.log("Adaptive SDK server environment initialized"));}var z=new AsyncLocalStorage,fe=new Proxy({},{get(e,r){return async t=>{if(!C)throw new Error("Adaptive SDK server environment is not initialized. Please call initializeServerEnvironment first.");let o=C[r];if(!o||typeof o.mutate!="function")throw new Error(`Property "${String(r)}" is not a mutation procedure`);return o.mutate(t)}}});function A(){return z.getStore()}function Le(e){let r=A();r&&Object.assign(r,e);}async function $e(e,r){return z.run(e,r)}function Be(){return globalThis.env.BASE_URL}var N=null;function Ve(){return N}function Ye({channelId:e,onUpdate:r}){let t=new WebSocket(`wss://${globalThis.env.REALTIME_DOMAIN}/${e}`),n=-1;function o(s){r&&(N=Date.now());try{let i=JSON.parse(s.data.toString());if(i?.id&&i.id>n){let d=g.parse(i.payload);r?.(d),n=i.id;}}catch{}}return t.addEventListener("message",o),{destroy(){t.close(),t.removeEventListener("message",o);}}}async function K({channelId:e,data:r}){N=Date.now(),await fetch(`https://${globalThis.env.REALTIME_DOMAIN}/${e}`,{method:"POST",body:g.stringify(r)}).catch(console.error);}async function Ke(){let e,r=A()?.channelId;if(!r)throw new Error("API's using `startRealtimeResponse` must be called via `useRealtimeMutation`.");return {next(t){e=t,K({channelId:r,data:t});},end(){return K({channelId:r,data:e}),e}}}function H(e){throw new y({provider:e?.provider??"AC1",popup:true})}async function He(e){let r=await fe.getCurrentUser();if(r?.error==="SEED")throw new Error('Call to "getAuth" in seed function is not allowed. Seed functions should not depend on user data.');if(r.userId)return {userId:r.userId,status:"authenticated",signIn:H,providers:r.providers};if(e?.required)throw new y({provider:"AC1"});return {userId:null,status:"unauthenticated",signIn:H,providers:[]}}
|
|
2
|
+
export{He as getAuth,Be as getBaseUrl,Ve as getLastStreamTime,Ye as getRealtimeStore,A as getRequestContext,je as initializeServerEnvironment,fe as mcp,$e as runWithContext,K as setRealtimeStore,Le as setRequestContext,Ke as startRealtimeResponse};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptive-ai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -19,14 +19,16 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@tanstack/react-query": ">=
|
|
22
|
+
"@tanstack/react-query": ">=5",
|
|
23
23
|
"@trpc/client": ">=10",
|
|
24
|
+
"@trpc/server": ">=10",
|
|
25
|
+
"typed-rpc": ">=5",
|
|
24
26
|
"lodash": ">=4",
|
|
25
27
|
"nanoid": ">=4",
|
|
26
28
|
"openai": ">=4",
|
|
27
29
|
"react": ">=18",
|
|
28
30
|
"superjson": ">=1",
|
|
29
|
-
"zod": ">=
|
|
31
|
+
"zod": ">=3"
|
|
30
32
|
},
|
|
31
33
|
"peerDependenciesMeta": {
|
|
32
34
|
"@tanstack/react-query": {
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
"browser-image-compression": "^2.0.2",
|
|
55
57
|
"dom-to-image-more": "^3.7.2",
|
|
56
58
|
"eslint": "^8.47.0",
|
|
57
|
-
"eslint-config-next": "15.
|
|
59
|
+
"eslint-config-next": "15.5.6",
|
|
58
60
|
"eslint-config-prettier": "^9.0.0",
|
|
59
61
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
60
62
|
"eslint-plugin-prettier": "^5.0.1",
|
|
@@ -66,8 +68,8 @@
|
|
|
66
68
|
"tsup": "^8.2.4",
|
|
67
69
|
"tsx": "^4.7.1",
|
|
68
70
|
"typescript": "^5.8.2",
|
|
69
|
-
"@ac1/
|
|
70
|
-
"@ac1/
|
|
71
|
+
"@ac1/iso": "0.1.1",
|
|
72
|
+
"@ac1/core": "0.1.1"
|
|
71
73
|
},
|
|
72
74
|
"publishConfig": {
|
|
73
75
|
"access": "public"
|
|
@@ -79,6 +81,7 @@
|
|
|
79
81
|
"lint": "NODE_OPTIONS='--max-old-space-size=8192' eslint --cache .",
|
|
80
82
|
"lint:fix": "eslint --cache --fix .",
|
|
81
83
|
"check": "NODE_OPTIONS='--max-old-space-size=8192' tsc --noEmit",
|
|
84
|
+
"bundle": "./bundle.sh",
|
|
82
85
|
"build": "tsup",
|
|
83
86
|
"clean": "rimraf dist"
|
|
84
87
|
}
|