@axiom-lattice/client-sdk 1.0.13 → 1.0.15

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.
@@ -0,0 +1,138 @@
1
+ import { Message, MessageChunk } from "@axiom-lattice/protocols";
2
+ import { AgentState, ChatResponse, ChatSendOptions, ChatStreamOptions, ClientConfig, CreateThreadOptions, GetMessagesOptions, ListThreadsOptions, RegisterToolOptions, ResumeStreamOptions, RunOptions, Thread } from "./types";
3
+ /**
4
+ * Abstract client class for interacting with the Axiom Lattice Agent Service API
5
+ * Provides common functionality for different client implementations
6
+ */
7
+ export declare abstract class AbstractClient {
8
+ protected config: ClientConfig;
9
+ protected assistantId: string;
10
+ protected tenantId: string;
11
+ protected registeredTools: Map<string, RegisterToolOptions>;
12
+ /**
13
+ * Creates a new AbstractClient instance
14
+ * @param config - Configuration options for the client
15
+ */
16
+ constructor(config: ClientConfig);
17
+ /**
18
+ * Set tenant ID for multi-tenant environments
19
+ * @param tenantId - Tenant identifier
20
+ */
21
+ abstract setTenantId(tenantId: string): void;
22
+ /**
23
+ * Abstract method for making API requests
24
+ * To be implemented by concrete client classes
25
+ */
26
+ protected abstract makeRequest<T>(url: string, options?: {
27
+ method?: string;
28
+ body?: any;
29
+ headers?: Record<string, string>;
30
+ }): Promise<T>;
31
+ /**
32
+ * Abstract method for streaming API requests
33
+ * To be implemented by concrete client classes
34
+ */
35
+ /**
36
+ * Helper method to build stream request parameters
37
+ * @param options - Options for running the agent
38
+ * @returns The formatted request parameters
39
+ */
40
+ protected buildStreamRequestParams(options: RunOptions): {
41
+ url: string;
42
+ method: string;
43
+ body: any;
44
+ };
45
+ protected abstract streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
46
+ /**
47
+ * Creates a new thread
48
+ * @param options - Options for creating a thread
49
+ * @returns A promise that resolves to the thread ID
50
+ */
51
+ createThread(options: CreateThreadOptions): Promise<string>;
52
+ /**
53
+ * Retrieves thread information
54
+ * @param threadId - Thread identifier
55
+ * @returns A promise that resolves to the thread information
56
+ */
57
+ getThread(threadId: string): Promise<Thread>;
58
+ /**
59
+ * Lists all threads
60
+ * @param options - Options for listing threads
61
+ * @returns A promise that resolves to an array of threads
62
+ */
63
+ listThreads(options?: ListThreadsOptions): Promise<Thread[]>;
64
+ /**
65
+ * Deletes a thread
66
+ * @param threadId - Thread identifier
67
+ * @returns A promise that resolves when the thread is deleted
68
+ */
69
+ deleteThread(threadId: string): Promise<void>;
70
+ /**
71
+ * Retrieves messages from a thread
72
+ * @param options - Options for retrieving messages
73
+ * @returns A promise that resolves to an array of messages
74
+ */
75
+ getMessages(options: GetMessagesOptions): Promise<Message[]>;
76
+ /**
77
+ * Retrieves agent state
78
+ * @param threadId - Thread identifier
79
+ * @returns A promise that resolves to the agent state
80
+ */
81
+ getAgentState(threadId: string): Promise<AgentState>;
82
+ /**
83
+ * Gets agent graph visualization
84
+ * @returns A promise that resolves to the graph visualization data
85
+ */
86
+ getAgentGraph(): Promise<string>;
87
+ /**
88
+ * Run agent with options
89
+ * @param options - Options for running the agent
90
+ * @returns A promise that resolves to the run result
91
+ */
92
+ run(options: RunOptions): Promise<ChatResponse>;
93
+ /**
94
+ * Chat namespace for sending messages and streaming responses
95
+ */
96
+ chat: {
97
+ /**
98
+ * Sends a message to a thread and receives a response
99
+ * @param options - Options for sending a message
100
+ * @returns A promise that resolves to the chat response
101
+ */
102
+ send: (options: ChatSendOptions) => Promise<ChatResponse>;
103
+ /**
104
+ * Sends a message to a thread and streams the response
105
+ * @param options - Options for streaming a message
106
+ * @param onEvent - Callback function that receives stream events
107
+ * @param onComplete - Optional callback function called when streaming completes
108
+ * @param onError - Optional callback function called when an error occurs
109
+ * @returns A function that can be called to stop the stream
110
+ */
111
+ stream: (options: ChatStreamOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void) => (() => void);
112
+ };
113
+ /**
114
+ * Resume streaming from a known position
115
+ * @param options - Options for resuming the stream
116
+ * @param onEvent - Callback function that receives stream events
117
+ * @param onComplete - Optional callback function called when streaming completes
118
+ * @param onError - Optional callback function called when an error occurs
119
+ * @returns A function that can be called to stop the stream
120
+ */
121
+ abstract resumeStream(options: ResumeStreamOptions, onEvent: (event: MessageChunk) => void, onComplete?: () => void, onError?: (error: Error) => void): () => void;
122
+ /**
123
+ * Tools namespace for registering and unregistering client-side tools
124
+ */
125
+ tools: {
126
+ /**
127
+ * Registers a client-side tool
128
+ * @param options - Options for registering a tool
129
+ */
130
+ register: (options: RegisterToolOptions) => void;
131
+ /**
132
+ * Unregisters a client-side tool
133
+ * @param name - Tool name
134
+ */
135
+ unregister: (name: string) => void;
136
+ };
137
+ }
138
+ //# sourceMappingURL=abstract-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-client.d.ts","sourceRoot":"","sources":["../src/abstract-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,UAAU,EAEV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,MAAM,EACP,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,8BAAsB,cAAc;IAClC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC;IAC/B,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAM;IAChC,SAAS,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAa;IAExE;;;OAGG;gBACS,MAAM,EAAE,YAAY;IAShC;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAE5C;;;OAGG;IACH,S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GG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAWtC;;;;OAIG;IACG,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;IA6BrD;;OAEG;IACH,IAAI;QACF;;;;WAIG;wBACmB,eAAe,KAAG,OAAO,CAAC,YAAY,CAAC;QAyB7D;;;;;;;WAOG;0BAEQ,iBAAiB,WACjB,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,eACzB,CAAC,KAAK,CAAC,EAAE,UAAU,KAAK,IAAI,YAC/B,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAC/B,CAAC,MAAM,IAAI,CAAC;MAiCf;IAEF;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,CACnB,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,EACtC,UAAU,CAAC,EAAE,MAAM,IAAI,EACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAC/B,MAAM,IAAI;IAEb;;OAEG;IACH,KAAK;QACH;;;WAGG;4BACiB,mBAAmB,KAAG,IAAI;QAS9C;;;WAGG;2BACgB,MAAM,KAAG,IAAI;MAGhC;CACH"}
@@ -0,0 +1,281 @@
1
+ /**
2
+ * Abstract client class for interacting with the Axiom Lattice Agent Service API
3
+ * Provides common functionality for different client implementations
4
+ */
5
+ export class AbstractClient {
6
+ /**
7
+ * Creates a new AbstractClient instance
8
+ * @param config - Configuration options for the client
9
+ */
10
+ constructor(config) {
11
+ this.tenantId = "";
12
+ this.registeredTools = new Map();
13
+ /**
14
+ * Chat namespace for sending messages and streaming responses
15
+ */
16
+ this.chat = {
17
+ /**
18
+ * Sends a message to a thread and receives a response
19
+ * @param options - Options for sending a message
20
+ * @returns A promise that resolves to the chat response
21
+ */
22
+ send: async (options) => {
23
+ try {
24
+ // Extract the message from the messages array (assuming the last message is the one to send)
25
+ const message = options.messages[options.messages.length - 1];
26
+ const { command, threadId, files, ...rest } = options;
27
+ // Use the run method to send the message
28
+ const result = await this.run({
29
+ threadId: threadId,
30
+ message: typeof message.content === "string"
31
+ ? message.content
32
+ : JSON.stringify(message.content),
33
+ streaming: false,
34
+ command: command,
35
+ files: files,
36
+ ...rest,
37
+ });
38
+ return result;
39
+ }
40
+ catch (error) {
41
+ throw error;
42
+ }
43
+ },
44
+ /**
45
+ * Sends a message to a thread and streams the response
46
+ * @param options - Options for streaming a message
47
+ * @param onEvent - Callback function that receives stream events
48
+ * @param onComplete - Optional callback function called when streaming completes
49
+ * @param onError - Optional callback function called when an error occurs
50
+ * @returns A function that can be called to stop the stream
51
+ */
52
+ stream: (options, onEvent, onComplete, onError) => {
53
+ const { command, threadId, files, background, enableReturnStateWhenSteamCompleted, ...rest } = options;
54
+ // Extract the message from the messages array (assuming the last message is the one to send)
55
+ const message = options.messages[options.messages.length - 1];
56
+ // Use the streamRequest method to stream the response
57
+ return this.streamRequest({
58
+ threadId: options.threadId,
59
+ message: typeof message.content === "string"
60
+ ? message.content
61
+ : JSON.stringify(message.content),
62
+ streaming: true,
63
+ command: command,
64
+ background: background,
65
+ enableReturnStateWhenSteamCompleted: enableReturnStateWhenSteamCompleted,
66
+ ...rest,
67
+ }, onEvent, onComplete, onError);
68
+ },
69
+ };
70
+ /**
71
+ * Tools namespace for registering and unregistering client-side tools
72
+ */
73
+ this.tools = {
74
+ /**
75
+ * Registers a client-side tool
76
+ * @param options - Options for registering a tool
77
+ */
78
+ register: (options) => {
79
+ if (this.config.transport !== "ws") {
80
+ throw new Error("Client-side tools are only supported with WebSocket transport");
81
+ }
82
+ this.registeredTools.set(options.name, options);
83
+ },
84
+ /**
85
+ * Unregisters a client-side tool
86
+ * @param name - Tool name
87
+ */
88
+ unregister: (name) => {
89
+ this.registeredTools.delete(name);
90
+ },
91
+ };
92
+ this.config = {
93
+ timeout: 300000, // Default timeout
94
+ ...config,
95
+ };
96
+ this.assistantId = config.assistantId;
97
+ }
98
+ /**
99
+ * Abstract method for streaming API requests
100
+ * To be implemented by concrete client classes
101
+ */
102
+ /**
103
+ * Helper method to build stream request parameters
104
+ * @param options - Options for running the agent
105
+ * @returns The formatted request parameters
106
+ */
107
+ buildStreamRequestParams(options) {
108
+ const { command, threadId, message, files, background, ...rest } = options;
109
+ return {
110
+ url: "/api/runs",
111
+ method: "POST",
112
+ body: {
113
+ assistant_id: this.assistantId,
114
+ thread_id: threadId,
115
+ message: message,
116
+ files: files,
117
+ command: command,
118
+ streaming: true,
119
+ background: background || false,
120
+ ...rest,
121
+ },
122
+ };
123
+ }
124
+ /**
125
+ * Creates a new thread
126
+ * @param options - Options for creating a thread
127
+ * @returns A promise that resolves to the thread ID
128
+ */
129
+ async createThread(options) {
130
+ try {
131
+ const data = await this.makeRequest("/threads", {
132
+ method: "POST",
133
+ body: {
134
+ ...options,
135
+ assistantId: this.assistantId,
136
+ },
137
+ });
138
+ return data.id;
139
+ }
140
+ catch (error) {
141
+ throw error;
142
+ }
143
+ }
144
+ /**
145
+ * Retrieves thread information
146
+ * @param threadId - Thread identifier
147
+ * @returns A promise that resolves to the thread information
148
+ */
149
+ async getThread(threadId) {
150
+ try {
151
+ const url = `/threads/${threadId}?assistantId=${this.assistantId}`;
152
+ return await this.makeRequest(url);
153
+ }
154
+ catch (error) {
155
+ throw error;
156
+ }
157
+ }
158
+ /**
159
+ * Lists all threads
160
+ * @param options - Options for listing threads
161
+ * @returns A promise that resolves to an array of threads
162
+ */
163
+ async listThreads(options) {
164
+ try {
165
+ let url = `/threads?assistantId=${this.assistantId}`;
166
+ if (options?.limit) {
167
+ url += `&limit=${options.limit}`;
168
+ }
169
+ if (options?.offset !== undefined) {
170
+ url += `&offset=${options.offset}`;
171
+ }
172
+ const data = await this.makeRequest(url);
173
+ return data.threads;
174
+ }
175
+ catch (error) {
176
+ throw error;
177
+ }
178
+ }
179
+ /**
180
+ * Deletes a thread
181
+ * @param threadId - Thread identifier
182
+ * @returns A promise that resolves when the thread is deleted
183
+ */
184
+ async deleteThread(threadId) {
185
+ try {
186
+ const url = `/threads/${threadId}?assistantId=${this.assistantId}`;
187
+ await this.makeRequest(url, { method: "DELETE" });
188
+ }
189
+ catch (error) {
190
+ throw error;
191
+ }
192
+ }
193
+ /**
194
+ * Retrieves messages from a thread
195
+ * @param options - Options for retrieving messages
196
+ * @returns A promise that resolves to an array of messages
197
+ */
198
+ async getMessages(options) {
199
+ try {
200
+ let url = `/api/assistants/${this.assistantId}/${options.threadId}/memory`;
201
+ if (options.limit) {
202
+ url += `?limit=${options.limit}`;
203
+ }
204
+ if (options.after) {
205
+ url += url.includes("?")
206
+ ? `&after=${options.after}`
207
+ : `?after=${options.after}`;
208
+ }
209
+ if (options.reverse !== undefined) {
210
+ url += url.includes("?")
211
+ ? `&reverse=${options.reverse}`
212
+ : `?reverse=${options.reverse}`;
213
+ }
214
+ url += url.includes("?")
215
+ ? `&assistantId=${this.assistantId}`
216
+ : `?assistantId=${this.assistantId}`;
217
+ return await this.makeRequest(url);
218
+ }
219
+ catch (error) {
220
+ throw error;
221
+ }
222
+ }
223
+ /**
224
+ * Retrieves agent state
225
+ * @param threadId - Thread identifier
226
+ * @returns A promise that resolves to the agent state
227
+ */
228
+ async getAgentState(threadId) {
229
+ try {
230
+ return await this.makeRequest(`/api/assistants/${this.assistantId}/${threadId}/state`);
231
+ }
232
+ catch (error) {
233
+ throw error;
234
+ }
235
+ }
236
+ /**
237
+ * Gets agent graph visualization
238
+ * @returns A promise that resolves to the graph visualization data
239
+ */
240
+ async getAgentGraph() {
241
+ try {
242
+ const data = await this.makeRequest(`/api/assistants/${this.assistantId}/graph`);
243
+ return data.image;
244
+ }
245
+ catch (error) {
246
+ throw error;
247
+ }
248
+ }
249
+ /**
250
+ * Run agent with options
251
+ * @param options - Options for running the agent
252
+ * @returns A promise that resolves to the run result
253
+ */
254
+ async run(options) {
255
+ try {
256
+ const { command, threadId, message, files, background, ...rest } = options;
257
+ if (options.streaming) {
258
+ throw new Error("Streaming without callbacks is not supported. Use chat.stream with callbacks instead.");
259
+ }
260
+ else {
261
+ return await this.makeRequest("/api/runs", {
262
+ method: "POST",
263
+ body: {
264
+ assistant_id: this.assistantId,
265
+ thread_id: threadId,
266
+ message: message,
267
+ files: files,
268
+ command: command,
269
+ streaming: false,
270
+ background: background || false,
271
+ ...rest,
272
+ },
273
+ });
274
+ }
275
+ }
276
+ catch (error) {
277
+ throw error;
278
+ }
279
+ }
280
+ }
281
+ //# sourceMappingURL=abstract-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-client.js","sourceRoot":"","sources":["../src/abstract-client.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,MAAM,OAAgB,cAAc;IAMlC;;;OAGG;IACH,YAAY,MAAoB;QAPtB,aAAQ,GAAW,EAAE,CAAC;QACtB,oBAAe,GAAqC,IAAI,GAAG,EAAE,CAAC;QAoPxE;;WAEG;QACH,SAAI,GAAG;YACL;;;;eAIG;YACH,IAAI,EAAE,KAAK,EAAE,OAAwB,EAAyB,EAAE;gBAC9D,IAAI,CAAC;oBACH,6FAA6F;oBAC7F,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;oBAC9D,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;oBAEtD,yCAAyC;oBACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC;wBAC5B,QAAQ,EAAE,QAAQ;wBAClB,OAAO,EACL,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;4BACjC,CAAC,CAAC,OAAO,CAAC,OAAO;4BACjB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;wBACrC,SAAS,EAAE,KAAK;wBAChB,OAAO,EAAE,OAAO;wBAChB,KAAK,EAAE,KAAK;wBACZ,GAAG,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,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CACjC,mBAAmB,IAAI,CAAC,WAAW,QAAQ,CAC5C,CAAC;YACF,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,OAAmB;QAC3B,IAAI,CAAC;YACH,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAC9D,OAAO,CAAC;YAEV,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CACb,uFAAuF,CACxF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,MAAM,IAAI,CAAC,WAAW,CAAe,WAAW,EAAE;oBACvD,MAAM,EAAE,MAAM;oBACd,IAAI,EAAE;wBACJ,YAAY,EAAE,IAAI,CAAC,WAAW;wBAC9B,SAAS,EAAE,QAAQ;wBACnB,OAAO,EAAE,OAAO;wBAChB,KAAK,EAAE,KAAK;wBACZ,OAAO,EAAE,OAAO;wBAChB,SAAS,EAAE,KAAK;wBAChB,UAAU,EAAE,UAAU,IAAI,KAAK;wBAC/B,GAAG,IAAI;qBACR;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CA4HF"}
@@ -0,0 +1,63 @@
1
+ import { MessageChunk } from "@axiom-lattice/protocols";
2
+ import { AgentState, ClientConfig, ResumeStreamOptions, RunOptions } from "./types";
3
+ import { AbstractClient } from "./abstract-client";
4
+ /**
5
+ * Web client class for interacting with the Axiom Lattice Agent Service API
6
+ */
7
+ export declare class Client extends AbstractClient {
8
+ private headers;
9
+ /**
10
+ * Creates a new Client instance
11
+ * @param config - Configuration options for the client
12
+ */
13
+ constructor(config: ClientConfig);
14
+ /**
15
+ * Helper method to handle fetch responses and errors
16
+ * @private
17
+ */
18
+ private handleResponse;
19
+ /**
20
+ * Helper method to make fetch requests
21
+ * @private
22
+ */
23
+ private fetchWithTimeout;
24
+ /**
25
+ * Set tenant ID for multi-tenant environments
26
+ * @param tenantId - Tenant identifier
27
+ */
28
+ setTenantId(tenantId: string): void;
29
+ /**
30
+ * Implementation of the abstract makeRequest method for web clients
31
+ * @param url - The URL to make the request to
32
+ * @param options - Request options
33
+ * @returns A promise that resolves to the response data
34
+ */
35
+ protected makeRequest<T>(url: string, options?: {
36
+ method?: string;
37
+ body?: any;
38
+ headers?: Record<string, string>;
39
+ }): Promise<T>;
40
+ /**
41
+ * Implementation of the abstract streamRequest method for web clients
42
+ */
43
+ protected streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
44
+ /**
45
+ * Resume streaming from a known position
46
+ * @param options - Options for resuming the stream
47
+ * @param onEvent - Callback function that receives stream events
48
+ * @param onComplete - Optional callback function called when streaming completes
49
+ * @param onError - Optional callback function called when an error occurs
50
+ * @returns A function that can be called to stop the stream
51
+ */
52
+ resumeStream(options: ResumeStreamOptions, onEvent: (event: MessageChunk) => void, onComplete?: () => void, onError?: (error: Error) => void): () => void;
53
+ /**
54
+ * Stream run results
55
+ * @param options - Options for streaming run results
56
+ * @param onEvent - Callback function that receives stream events
57
+ * @param onComplete - Optional callback function called when streaming completes
58
+ * @param onError - Optional callback function called when an error occurs
59
+ * @returns A function that can be called to stop the stream
60
+ */
61
+ private streamRun;
62
+ }
63
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,UAAU,EAMV,YAAY,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