@elizaos/api-client 1.4.2 → 1.4.3-alpha.0
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/api-client/src/client.d.ts +25 -0
- package/dist/api-client/src/client.d.ts.map +1 -0
- package/dist/api-client/src/index.d.ts +20 -0
- package/dist/api-client/src/index.d.ts.map +1 -0
- package/dist/api-client/src/lib/base-client.d.ts +31 -0
- package/dist/api-client/src/lib/base-client.d.ts.map +1 -0
- package/dist/api-client/src/services/agents.d.ts +107 -0
- package/dist/api-client/src/services/agents.d.ts.map +1 -0
- package/dist/api-client/src/services/audio.d.ts +48 -0
- package/dist/api-client/src/services/audio.d.ts.map +1 -0
- package/dist/api-client/src/services/media.d.ts +14 -0
- package/dist/api-client/src/services/media.d.ts.map +1 -0
- package/dist/api-client/src/services/memory.d.ts +107 -0
- package/dist/api-client/src/services/memory.d.ts.map +1 -0
- package/dist/api-client/src/services/messaging.d.ts +164 -0
- package/dist/api-client/src/services/messaging.d.ts.map +1 -0
- package/dist/api-client/src/services/server.d.ts +47 -0
- package/dist/api-client/src/services/server.d.ts.map +1 -0
- package/dist/api-client/src/services/sessions.d.ts +52 -0
- package/dist/api-client/src/services/sessions.d.ts.map +1 -0
- package/dist/api-client/src/services/system.d.ts +56 -0
- package/dist/api-client/src/services/system.d.ts.map +1 -0
- package/dist/api-client/src/types/agents.d.ts +67 -0
- package/dist/api-client/src/types/agents.d.ts.map +1 -0
- package/dist/api-client/src/types/audio.d.ts +42 -0
- package/dist/api-client/src/types/audio.d.ts.map +1 -0
- package/dist/api-client/src/types/base.d.ts +30 -0
- package/dist/api-client/src/types/base.d.ts.map +1 -0
- package/dist/api-client/src/types/media.d.ts +21 -0
- package/dist/api-client/src/types/media.d.ts.map +1 -0
- package/dist/api-client/src/types/memory.d.ts +43 -0
- package/dist/api-client/src/types/memory.d.ts.map +1 -0
- package/dist/api-client/src/types/messaging.d.ts +186 -0
- package/dist/api-client/src/types/messaging.d.ts.map +1 -0
- package/dist/api-client/src/types/server.d.ts +44 -0
- package/dist/api-client/src/types/server.d.ts.map +1 -0
- package/dist/api-client/src/types/sessions.d.ts +134 -0
- package/dist/api-client/src/types/sessions.d.ts.map +1 -0
- package/dist/api-client/src/types/system.d.ts +16 -0
- package/dist/api-client/src/types/system.d.ts.map +1 -0
- package/dist/core/src/actions.d.ts +23 -0
- package/dist/core/src/actions.d.ts.map +1 -0
- package/dist/core/src/database.d.ts +481 -0
- package/dist/core/src/database.d.ts.map +1 -0
- package/dist/core/src/entities.d.ts +49 -0
- package/dist/core/src/entities.d.ts.map +1 -0
- package/dist/core/src/index.d.ts +27 -0
- package/dist/core/src/index.d.ts.map +1 -0
- package/dist/core/src/logger.d.ts +47 -0
- package/dist/core/src/logger.d.ts.map +1 -0
- package/dist/core/src/prompts.d.ts +8 -0
- package/dist/core/src/prompts.d.ts.map +1 -0
- package/dist/core/src/roles.d.ts +30 -0
- package/dist/core/src/roles.d.ts.map +1 -0
- package/dist/core/src/runtime.d.ts +328 -0
- package/dist/core/src/runtime.d.ts.map +1 -0
- package/dist/core/src/schemas/character.d.ts +228 -0
- package/dist/core/src/schemas/character.d.ts.map +1 -0
- package/dist/core/src/search.d.ts +317 -0
- package/dist/core/src/search.d.ts.map +1 -0
- package/dist/core/src/sentry/instrument.d.ts +12 -0
- package/dist/core/src/sentry/instrument.d.ts.map +1 -0
- package/dist/core/src/services.d.ts +49 -0
- package/dist/core/src/services.d.ts.map +1 -0
- package/dist/core/src/settings.d.ts +87 -0
- package/dist/core/src/settings.d.ts.map +1 -0
- package/dist/core/src/types/agent.d.ts +98 -0
- package/dist/core/src/types/agent.d.ts.map +1 -0
- package/dist/core/src/types/browser.d.ts +127 -0
- package/dist/core/src/types/browser.d.ts.map +1 -0
- package/dist/core/src/types/components.d.ts +135 -0
- package/dist/core/src/types/components.d.ts.map +1 -0
- package/dist/core/src/types/database.d.ts +278 -0
- package/dist/core/src/types/database.d.ts.map +1 -0
- package/dist/core/src/types/email.d.ts +143 -0
- package/dist/core/src/types/email.d.ts.map +1 -0
- package/dist/core/src/types/environment.d.ts +109 -0
- package/dist/core/src/types/environment.d.ts.map +1 -0
- package/dist/core/src/types/events.d.ts +207 -0
- package/dist/core/src/types/events.d.ts.map +1 -0
- package/dist/core/src/types/index.d.ts +30 -0
- package/dist/core/src/types/index.d.ts.map +1 -0
- package/dist/core/src/types/knowledge.d.ts +60 -0
- package/dist/core/src/types/knowledge.d.ts.map +1 -0
- package/dist/core/src/types/lp.d.ts +115 -0
- package/dist/core/src/types/lp.d.ts.map +1 -0
- package/dist/core/src/types/memory.d.ts +165 -0
- package/dist/core/src/types/memory.d.ts.map +1 -0
- package/dist/core/src/types/message.d.ts +202 -0
- package/dist/core/src/types/message.d.ts.map +1 -0
- package/dist/core/src/types/messaging.d.ts +45 -0
- package/dist/core/src/types/messaging.d.ts.map +1 -0
- package/dist/core/src/types/model.d.ts +319 -0
- package/dist/core/src/types/model.d.ts.map +1 -0
- package/dist/core/src/types/pdf.d.ts +68 -0
- package/dist/core/src/types/pdf.d.ts.map +1 -0
- package/dist/core/src/types/plugin.d.ts +64 -0
- package/dist/core/src/types/plugin.d.ts.map +1 -0
- package/dist/core/src/types/post.d.ts +242 -0
- package/dist/core/src/types/post.d.ts.map +1 -0
- package/dist/core/src/types/primitives.d.ts +72 -0
- package/dist/core/src/types/primitives.d.ts.map +1 -0
- package/dist/core/src/types/runtime.d.ts +106 -0
- package/dist/core/src/types/runtime.d.ts.map +1 -0
- package/dist/core/src/types/service.d.ts +147 -0
- package/dist/core/src/types/service.d.ts.map +1 -0
- package/dist/core/src/types/settings.d.ts +30 -0
- package/dist/core/src/types/settings.d.ts.map +1 -0
- package/dist/core/src/types/state.d.ts +59 -0
- package/dist/core/src/types/state.d.ts.map +1 -0
- package/dist/core/src/types/task.d.ts +68 -0
- package/dist/core/src/types/task.d.ts.map +1 -0
- package/dist/core/src/types/tee.d.ts +97 -0
- package/dist/core/src/types/tee.d.ts.map +1 -0
- package/dist/core/src/types/testing.d.ts +29 -0
- package/dist/core/src/types/testing.d.ts.map +1 -0
- package/dist/core/src/types/token.d.ts +73 -0
- package/dist/core/src/types/token.d.ts.map +1 -0
- package/dist/core/src/types/transcription.d.ts +108 -0
- package/dist/core/src/types/transcription.d.ts.map +1 -0
- package/dist/core/src/types/video.d.ts +93 -0
- package/dist/core/src/types/video.d.ts.map +1 -0
- package/dist/core/src/types/wallet.d.ts +49 -0
- package/dist/core/src/types/wallet.d.ts.map +1 -0
- package/dist/core/src/types/web-search.d.ts +112 -0
- package/dist/core/src/types/web-search.d.ts.map +1 -0
- package/dist/core/src/utils/buffer.d.ts +105 -0
- package/dist/core/src/utils/buffer.d.ts.map +1 -0
- package/dist/core/src/utils/environment.d.ts +106 -0
- package/dist/core/src/utils/environment.d.ts.map +1 -0
- package/dist/core/src/utils/server-health.d.ts +23 -0
- package/dist/core/src/utils/server-health.d.ts.map +1 -0
- package/dist/core/src/utils.d.ts +177 -0
- package/dist/core/src/utils.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1102
- package/dist/index.js +144 -449
- package/dist/index.js.map +19 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +5 -6
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Service } from './service';
|
|
2
|
+
export interface SearchOptions {
|
|
3
|
+
limit?: number;
|
|
4
|
+
offset?: number;
|
|
5
|
+
language?: string;
|
|
6
|
+
region?: string;
|
|
7
|
+
dateRange?: {
|
|
8
|
+
start?: Date;
|
|
9
|
+
end?: Date;
|
|
10
|
+
};
|
|
11
|
+
fileType?: string;
|
|
12
|
+
site?: string;
|
|
13
|
+
sortBy?: 'relevance' | 'date' | 'popularity';
|
|
14
|
+
safeSearch?: 'strict' | 'moderate' | 'off';
|
|
15
|
+
}
|
|
16
|
+
export interface SearchResult {
|
|
17
|
+
title: string;
|
|
18
|
+
url: string;
|
|
19
|
+
description: string;
|
|
20
|
+
displayUrl?: string;
|
|
21
|
+
thumbnail?: string;
|
|
22
|
+
publishedDate?: Date;
|
|
23
|
+
source?: string;
|
|
24
|
+
relevanceScore?: number;
|
|
25
|
+
snippet?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SearchResponse {
|
|
28
|
+
query: string;
|
|
29
|
+
results: SearchResult[];
|
|
30
|
+
totalResults?: number;
|
|
31
|
+
searchTime?: number;
|
|
32
|
+
suggestions?: string[];
|
|
33
|
+
nextPageToken?: string;
|
|
34
|
+
relatedSearches?: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface NewsSearchOptions extends SearchOptions {
|
|
37
|
+
category?: 'general' | 'business' | 'entertainment' | 'health' | 'science' | 'sports' | 'technology';
|
|
38
|
+
freshness?: 'day' | 'week' | 'month';
|
|
39
|
+
}
|
|
40
|
+
export interface ImageSearchOptions extends SearchOptions {
|
|
41
|
+
size?: 'small' | 'medium' | 'large' | 'wallpaper' | 'any';
|
|
42
|
+
color?: 'color' | 'monochrome' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'pink' | 'brown' | 'black' | 'gray' | 'white';
|
|
43
|
+
type?: 'photo' | 'clipart' | 'line' | 'animated';
|
|
44
|
+
layout?: 'square' | 'wide' | 'tall' | 'any';
|
|
45
|
+
license?: 'any' | 'public' | 'share' | 'sharecommercially' | 'modify';
|
|
46
|
+
}
|
|
47
|
+
export interface VideoSearchOptions extends SearchOptions {
|
|
48
|
+
duration?: 'short' | 'medium' | 'long' | 'any';
|
|
49
|
+
resolution?: 'high' | 'standard' | 'any';
|
|
50
|
+
quality?: 'high' | 'standard' | 'any';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Interface for web search services
|
|
54
|
+
*/
|
|
55
|
+
export declare abstract class IWebSearchService extends Service {
|
|
56
|
+
static readonly serviceType: "web_search";
|
|
57
|
+
readonly capabilityDescription = "Web search and content discovery capabilities";
|
|
58
|
+
/**
|
|
59
|
+
* Perform a general web search
|
|
60
|
+
* @param query - Search query
|
|
61
|
+
* @param options - Search options
|
|
62
|
+
* @returns Promise resolving to search results
|
|
63
|
+
*/
|
|
64
|
+
abstract search(query: string, options?: SearchOptions): Promise<SearchResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Search for news articles
|
|
67
|
+
* @param query - Search query
|
|
68
|
+
* @param options - News search options
|
|
69
|
+
* @returns Promise resolving to news search results
|
|
70
|
+
*/
|
|
71
|
+
abstract searchNews(query: string, options?: NewsSearchOptions): Promise<SearchResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* Search for images
|
|
74
|
+
* @param query - Search query
|
|
75
|
+
* @param options - Image search options
|
|
76
|
+
* @returns Promise resolving to image search results
|
|
77
|
+
*/
|
|
78
|
+
abstract searchImages(query: string, options?: ImageSearchOptions): Promise<SearchResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* Search for videos
|
|
81
|
+
* @param query - Search query
|
|
82
|
+
* @param options - Video search options
|
|
83
|
+
* @returns Promise resolving to video search results
|
|
84
|
+
*/
|
|
85
|
+
abstract searchVideos(query: string, options?: VideoSearchOptions): Promise<SearchResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* Get search suggestions for a query
|
|
88
|
+
* @param query - Partial search query
|
|
89
|
+
* @returns Promise resolving to array of suggestions
|
|
90
|
+
*/
|
|
91
|
+
abstract getSuggestions(query: string): Promise<string[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Get trending searches
|
|
94
|
+
* @param region - Optional region code
|
|
95
|
+
* @returns Promise resolving to trending search queries
|
|
96
|
+
*/
|
|
97
|
+
abstract getTrendingSearches(region?: string): Promise<string[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Get detailed information about a specific URL
|
|
100
|
+
* @param url - URL to analyze
|
|
101
|
+
* @returns Promise resolving to page information
|
|
102
|
+
*/
|
|
103
|
+
abstract getPageInfo(url: string): Promise<{
|
|
104
|
+
title: string;
|
|
105
|
+
description: string;
|
|
106
|
+
content: string;
|
|
107
|
+
metadata: Record<string, string>;
|
|
108
|
+
images: string[];
|
|
109
|
+
links: string[];
|
|
110
|
+
}>;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=web-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../../../../core/src/types/web-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,WAAW,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QACV,KAAK,CAAC,EAAE,IAAI,CAAC;QACb,GAAG,CAAC,EAAE,IAAI,CAAC;KACZ,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,YAAY,CAAC;IAC7C,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACp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IACH,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAEhF;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;IAExF;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAE3F;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAE3F;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEzD;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhE;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QACzC,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;CACH"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser and Node.js compatible buffer abstraction
|
|
3
|
+
* This module provides a unified interface for buffer operations
|
|
4
|
+
* that works in both browser and Node.js environments.
|
|
5
|
+
*
|
|
6
|
+
* In browsers, we use Uint8Array as a Buffer replacement.
|
|
7
|
+
* In Node.js, we use the native Buffer.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Type representing a buffer-like object that works in both environments
|
|
11
|
+
*/
|
|
12
|
+
export type BufferLike = Buffer | Uint8Array;
|
|
13
|
+
/**
|
|
14
|
+
* Convert a hex string to a buffer-like object
|
|
15
|
+
* @param hex - The hexadecimal string to convert
|
|
16
|
+
* @returns A BufferLike object
|
|
17
|
+
*/
|
|
18
|
+
export declare function fromHex(hex: string): BufferLike;
|
|
19
|
+
/**
|
|
20
|
+
* Convert a string to a buffer-like object
|
|
21
|
+
* @param str - The string to convert
|
|
22
|
+
* @param encoding - The encoding to use (default: 'utf8')
|
|
23
|
+
* @returns A BufferLike object
|
|
24
|
+
*/
|
|
25
|
+
export declare function fromString(str: string, encoding?: 'utf8' | 'utf-8' | 'base64'): BufferLike;
|
|
26
|
+
/**
|
|
27
|
+
* Convert a buffer-like object to a hexadecimal string
|
|
28
|
+
* @param buffer - The buffer to convert
|
|
29
|
+
* @returns A hexadecimal string
|
|
30
|
+
*/
|
|
31
|
+
export declare function toHex(buffer: BufferLike): string;
|
|
32
|
+
/**
|
|
33
|
+
* Convert a buffer-like object to a string
|
|
34
|
+
* @param buffer - The buffer to convert
|
|
35
|
+
* @param encoding - The encoding to use (default: 'utf8')
|
|
36
|
+
* @returns A string
|
|
37
|
+
*/
|
|
38
|
+
export declare function toString(buffer: BufferLike, encoding?: 'utf8' | 'utf-8' | 'base64' | 'hex'): string;
|
|
39
|
+
/**
|
|
40
|
+
* Check if an object is a Buffer or buffer-like object
|
|
41
|
+
* @param obj - The object to check
|
|
42
|
+
* @returns True if the object is buffer-like
|
|
43
|
+
*/
|
|
44
|
+
export declare function isBuffer(obj: any): obj is BufferLike;
|
|
45
|
+
/**
|
|
46
|
+
* Create a buffer of a specific size filled with zeros
|
|
47
|
+
* @param size - The size of the buffer
|
|
48
|
+
* @returns A BufferLike object
|
|
49
|
+
*/
|
|
50
|
+
export declare function alloc(size: number): BufferLike;
|
|
51
|
+
/**
|
|
52
|
+
* Create a buffer from an array of bytes
|
|
53
|
+
* @param bytes - Array of byte values
|
|
54
|
+
* @returns A BufferLike object
|
|
55
|
+
*/
|
|
56
|
+
export declare function fromBytes(bytes: number[] | Uint8Array): BufferLike;
|
|
57
|
+
/**
|
|
58
|
+
* Concatenate multiple buffers
|
|
59
|
+
* @param buffers - Array of buffers to concatenate
|
|
60
|
+
* @returns A new BufferLike object
|
|
61
|
+
*/
|
|
62
|
+
export declare function concat(buffers: BufferLike[]): BufferLike;
|
|
63
|
+
/**
|
|
64
|
+
* Slice a buffer to create a new buffer
|
|
65
|
+
* @param buffer - The buffer to slice
|
|
66
|
+
* @param start - Start index
|
|
67
|
+
* @param end - End index (optional)
|
|
68
|
+
* @returns A new BufferLike object
|
|
69
|
+
*/
|
|
70
|
+
export declare function slice(buffer: BufferLike, start: number, end?: number): BufferLike;
|
|
71
|
+
/**
|
|
72
|
+
* Compare two buffers for equality
|
|
73
|
+
* @param a - First buffer
|
|
74
|
+
* @param b - Second buffer
|
|
75
|
+
* @returns True if buffers are equal
|
|
76
|
+
*/
|
|
77
|
+
export declare function equals(a: BufferLike, b: BufferLike): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Get the byte length of a buffer
|
|
80
|
+
* @param buffer - The buffer
|
|
81
|
+
* @returns The byte length
|
|
82
|
+
*/
|
|
83
|
+
export declare function byteLength(buffer: BufferLike): number;
|
|
84
|
+
/**
|
|
85
|
+
* Create a random buffer of specified size
|
|
86
|
+
* @param size - The size of the buffer
|
|
87
|
+
* @returns A BufferLike object filled with random bytes
|
|
88
|
+
*/
|
|
89
|
+
export declare function randomBytes(size: number): BufferLike;
|
|
90
|
+
export declare const BufferUtils: {
|
|
91
|
+
fromHex: typeof fromHex;
|
|
92
|
+
fromString: typeof fromString;
|
|
93
|
+
fromBytes: typeof fromBytes;
|
|
94
|
+
toHex: typeof toHex;
|
|
95
|
+
toString: typeof toString;
|
|
96
|
+
isBuffer: typeof isBuffer;
|
|
97
|
+
alloc: typeof alloc;
|
|
98
|
+
concat: typeof concat;
|
|
99
|
+
slice: typeof slice;
|
|
100
|
+
equals: typeof equals;
|
|
101
|
+
byteLength: typeof byteLength;
|
|
102
|
+
randomBytes: typeof randomBytes;
|
|
103
|
+
};
|
|
104
|
+
export type { BufferLike as Buffer };
|
|
105
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../../../core/src/utils/buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;AAS7C;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAiB/C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,MAAM,GAAG,OAAO,GAAG,QAAiB,GAC7C,UAAU,CAqBZ;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAchD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,UAAU,EAClB,QAAQ,GAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAc,GACrD,MAAM,CA0BR;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,UAAU,CAkBpD;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAM9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,GAAG,UAAU,CAMlE;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,CAsBxD;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAOjF;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAe5D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAwBpD;AAGD,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAavB,CAAC;AAGF,YAAY,EAAE,UAAU,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser and Node.js compatible environment variable abstraction
|
|
3
|
+
* This module provides a unified interface for accessing environment variables
|
|
4
|
+
* that works in both browser and Node.js environments.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Type representing the runtime environment
|
|
8
|
+
*/
|
|
9
|
+
export type RuntimeEnvironment = 'node' | 'browser' | 'unknown';
|
|
10
|
+
/**
|
|
11
|
+
* Interface for environment configuration
|
|
12
|
+
*/
|
|
13
|
+
export interface EnvironmentConfig {
|
|
14
|
+
[key: string]: string | boolean | number | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Detect the current runtime environment
|
|
18
|
+
*/
|
|
19
|
+
export declare function detectEnvironment(): RuntimeEnvironment;
|
|
20
|
+
/**
|
|
21
|
+
* Environment abstraction class
|
|
22
|
+
*/
|
|
23
|
+
declare class Environment {
|
|
24
|
+
private runtime;
|
|
25
|
+
private browserStore?;
|
|
26
|
+
private cache;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Get the current runtime environment
|
|
30
|
+
*/
|
|
31
|
+
getRuntime(): RuntimeEnvironment;
|
|
32
|
+
/**
|
|
33
|
+
* Check if running in Node.js
|
|
34
|
+
*/
|
|
35
|
+
isNode(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Check if running in browser
|
|
38
|
+
*/
|
|
39
|
+
isBrowser(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get an environment variable
|
|
42
|
+
*/
|
|
43
|
+
get(key: string, defaultValue?: string): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Set an environment variable (mainly for browser/testing)
|
|
46
|
+
*/
|
|
47
|
+
set(key: string, value: string | boolean | number): void;
|
|
48
|
+
/**
|
|
49
|
+
* Check if an environment variable exists
|
|
50
|
+
*/
|
|
51
|
+
has(key: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get all environment variables (filtered for safety)
|
|
54
|
+
*/
|
|
55
|
+
getAll(): EnvironmentConfig;
|
|
56
|
+
/**
|
|
57
|
+
* Get a boolean environment variable
|
|
58
|
+
*/
|
|
59
|
+
getBoolean(key: string, defaultValue?: boolean): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Get a number environment variable
|
|
62
|
+
*/
|
|
63
|
+
getNumber(key: string, defaultValue?: number): number | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Clear the cache (useful for testing)
|
|
66
|
+
*/
|
|
67
|
+
clearCache(): void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the singleton Environment instance
|
|
71
|
+
*/
|
|
72
|
+
export declare function getEnvironment(): Environment;
|
|
73
|
+
/**
|
|
74
|
+
* Convenience function to get an environment variable
|
|
75
|
+
*/
|
|
76
|
+
export declare function getEnv(key: string, defaultValue?: string): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Convenience function to set an environment variable
|
|
79
|
+
*/
|
|
80
|
+
export declare function setEnv(key: string, value: string | boolean | number): void;
|
|
81
|
+
/**
|
|
82
|
+
* Convenience function to check if an environment variable exists
|
|
83
|
+
*/
|
|
84
|
+
export declare function hasEnv(key: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Convenience function to get a boolean environment variable
|
|
87
|
+
*/
|
|
88
|
+
export declare function getBooleanEnv(key: string, defaultValue?: boolean): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Convenience function to get a number environment variable
|
|
91
|
+
*/
|
|
92
|
+
export declare function getNumberEnv(key: string, defaultValue?: number): number | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Initialize browser environment with config
|
|
95
|
+
* This should be called early in browser apps to set up environment
|
|
96
|
+
*/
|
|
97
|
+
export declare function initBrowserEnvironment(config: EnvironmentConfig): void;
|
|
98
|
+
/**
|
|
99
|
+
* Export the current runtime for convenience
|
|
100
|
+
*/
|
|
101
|
+
export declare const currentRuntime: RuntimeEnvironment;
|
|
102
|
+
/**
|
|
103
|
+
* Re-export the Environment class for advanced usage
|
|
104
|
+
*/
|
|
105
|
+
export { Environment };
|
|
106
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../../../core/src/utils/environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;CACtD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,CAgBtD;AA0CD;;GAEG;AACH,cAAM,WAAW;IACf,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,YAAY,CAAC,CAA0B;IAC/C,OAAO,CAAC,KAAK,CAA8C;;IAU3D;;OAEG;IACH,UAAU,IAAI,kBAAkB;IAIhC;;OAEG;IACH,MAAM,IAAI,OAAO;IAIjB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;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sB,CAAC;AAElD;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server health check utilities for waiting for servers to be ready
|
|
3
|
+
*/
|
|
4
|
+
export interface ServerHealthOptions {
|
|
5
|
+
port: number;
|
|
6
|
+
endpoint?: string;
|
|
7
|
+
maxWaitTime?: number;
|
|
8
|
+
pollInterval?: number;
|
|
9
|
+
requestTimeout?: number;
|
|
10
|
+
host?: string;
|
|
11
|
+
protocol?: 'http' | 'https';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wait for server to be ready by polling health endpoint
|
|
15
|
+
* @param options - Configuration options for server health check
|
|
16
|
+
*/
|
|
17
|
+
export declare function waitForServerReady(options: ServerHealthOptions): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Simple ping check for server availability (no stabilization wait)
|
|
20
|
+
* @param options - Configuration options for server ping
|
|
21
|
+
*/
|
|
22
|
+
export declare function pingServer(options: ServerHealthOptions): Promise<boolean>;
|
|
23
|
+
//# sourceMappingURL=server-health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-health.d.ts","sourceRoot":"","sources":["../../../../../core/src/utils/server-health.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDpF;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAuC/E"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { Entity, IAgentRuntime, Memory, State, TemplateType } from './types';
|
|
2
|
+
import { UUID, ContentType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Composes a context string by replacing placeholders in a template with corresponding values from the state.
|
|
5
|
+
*
|
|
6
|
+
* This function takes a template string with placeholders in the format `{{placeholder}}` and a state object.
|
|
7
|
+
* It replaces each placeholder with the value from the state object that matches the placeholder's name.
|
|
8
|
+
* If a matching key is not found in the state object for a given placeholder, the placeholder is replaced with an empty string.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} params - The parameters for composing the context.
|
|
11
|
+
* @param {State} params.state - The state object containing values to replace the placeholders in the template.
|
|
12
|
+
* @param {TemplateType} params.template - The template string or function containing placeholders to be replaced with state values.
|
|
13
|
+
* @returns {string} The composed context string with placeholders replaced by corresponding state values.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Given a state object and a template
|
|
17
|
+
* const state = { userName: "Alice", userAge: 30 };
|
|
18
|
+
* const template = "Hello, {{userName}}! You are {{userAge}} years old";
|
|
19
|
+
*
|
|
20
|
+
* // Composing the context with simple string replacement will result in:
|
|
21
|
+
* // "Hello, Alice! You are 30 years old."
|
|
22
|
+
* const contextSimple = composePromptFromState({ state, template });
|
|
23
|
+
*
|
|
24
|
+
* // Using composePromptFromState with a template function for dynamic template
|
|
25
|
+
* const template = ({ state }) => {
|
|
26
|
+
* const tone = Math.random() > 0.5 ? "kind" : "rude";
|
|
27
|
+
* return `Hello, {{userName}}! You are {{userAge}} years old. Be ${tone}`;
|
|
28
|
+
* };
|
|
29
|
+
* const contextSimple = composePromptFromState({ state, template });
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Function to compose a prompt using a provided template and state.
|
|
33
|
+
* It compiles the template (upgrading double braces to triple braces for non-HTML escaping)
|
|
34
|
+
* and then populates it with values from the state. Additionally, it processes the
|
|
35
|
+
* resulting string with `composeRandomUser` to replace placeholders like `{{nameX}}`.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} options - Object containing state and template information.
|
|
38
|
+
* @param {State} options.state - The state object containing values to fill the template.
|
|
39
|
+
* @param {TemplateType} options.template - The template string or function to be used for composing the prompt.
|
|
40
|
+
* @returns {string} The composed prompt output, with state values and random user names populated.
|
|
41
|
+
*/
|
|
42
|
+
export declare const composePrompt: ({ state, template, }: {
|
|
43
|
+
state: {
|
|
44
|
+
[key: string]: string;
|
|
45
|
+
};
|
|
46
|
+
template: TemplateType;
|
|
47
|
+
}) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Function to compose a prompt using a provided template and state.
|
|
50
|
+
*
|
|
51
|
+
* @param {Object} options - Object containing state and template information.
|
|
52
|
+
* @param {State} options.state - The state object containing values to fill the template.
|
|
53
|
+
* @param {TemplateType} options.template - The template to be used for composing the prompt.
|
|
54
|
+
* @returns {string} The composed prompt output.
|
|
55
|
+
*/
|
|
56
|
+
export declare const composePromptFromState: ({ state, template, }: {
|
|
57
|
+
state: State;
|
|
58
|
+
template: TemplateType;
|
|
59
|
+
}) => string;
|
|
60
|
+
/**
|
|
61
|
+
* Adds a header to a body of text.
|
|
62
|
+
*
|
|
63
|
+
* This function takes a header string and a body string and returns a new string with the header prepended to the body.
|
|
64
|
+
* If the body string is empty, the header is returned as is.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} header - The header to add to the body.
|
|
67
|
+
* @param {string} body - The body to which to add the header.
|
|
68
|
+
* @returns {string} The body with the header prepended.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // Given a header and a body
|
|
72
|
+
* const header = "Header";
|
|
73
|
+
* const body = "Body";
|
|
74
|
+
*
|
|
75
|
+
* // Adding the header to the body will result in:
|
|
76
|
+
* // "Header\nBody"
|
|
77
|
+
* const text = addHeader(header, body);
|
|
78
|
+
*/
|
|
79
|
+
export declare const addHeader: (header: string, body: string) => string;
|
|
80
|
+
export declare const formatPosts: ({ messages, entities, conversationHeader, }: {
|
|
81
|
+
messages: Memory[];
|
|
82
|
+
entities: Entity[];
|
|
83
|
+
conversationHeader?: boolean;
|
|
84
|
+
}) => string;
|
|
85
|
+
/**
|
|
86
|
+
* Format messages into a string
|
|
87
|
+
* @param {Object} params - The formatting parameters
|
|
88
|
+
* @param {Memory[]} params.messages - List of messages to format
|
|
89
|
+
* @param {Entity[]} params.entities - List of entities for name resolution
|
|
90
|
+
* @returns {string} Formatted message string with timestamps and user information
|
|
91
|
+
*/
|
|
92
|
+
export declare const formatMessages: ({ messages, entities, }: {
|
|
93
|
+
messages: Memory[];
|
|
94
|
+
entities: Entity[];
|
|
95
|
+
}) => string;
|
|
96
|
+
export declare const formatTimestamp: (messageDate: number) => string;
|
|
97
|
+
/**
|
|
98
|
+
* Parses key-value pairs from a simple XML structure within a given text.
|
|
99
|
+
* It looks for an XML block (e.g., <response>...</response>) and extracts
|
|
100
|
+
* text content from direct child elements (e.g., <key>value</key>).
|
|
101
|
+
*
|
|
102
|
+
* Note: This uses regex and is suitable for simple, predictable XML structures.
|
|
103
|
+
* For complex XML, a proper parsing library is recommended.
|
|
104
|
+
*
|
|
105
|
+
* @param text - The input text containing the XML structure.
|
|
106
|
+
* @returns An object with key-value pairs extracted from the XML, or null if parsing fails.
|
|
107
|
+
*/
|
|
108
|
+
export declare function parseKeyValueXml(text: string): Record<string, any> | null;
|
|
109
|
+
/**
|
|
110
|
+
* Parses a JSON object from a given text. The function looks for a JSON block wrapped in triple backticks
|
|
111
|
+
* with `json` language identifier, and if not found, it searches for an object pattern within the text.
|
|
112
|
+
* It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
|
|
113
|
+
* is an object (but not an array), it returns the object; otherwise, it tries to parse an array if the result
|
|
114
|
+
* is an array, or returns null if parsing is unsuccessful or the result is neither an object nor an array.
|
|
115
|
+
*
|
|
116
|
+
* @param text - The input text from which to extract and parse the JSON object.
|
|
117
|
+
* @returns An object parsed from the JSON string if successful; otherwise, null or the result of parsing an array.
|
|
118
|
+
*/
|
|
119
|
+
export declare function parseJSONObjectFromText(text: string): Record<string, any> | null;
|
|
120
|
+
/**
|
|
121
|
+
* Normalizes a JSON-like string by correcting formatting issues:
|
|
122
|
+
* - Removes extra spaces after '{' and before '}'.
|
|
123
|
+
* - Wraps unquoted values in double quotes.
|
|
124
|
+
* - Converts single-quoted values to double-quoted.
|
|
125
|
+
* - Ensures consistency in key-value formatting.
|
|
126
|
+
* - Normalizes mixed adjacent quote pairs.
|
|
127
|
+
*
|
|
128
|
+
* This is useful for cleaning up improperly formatted JSON strings
|
|
129
|
+
* before parsing them into valid JSON.
|
|
130
|
+
*
|
|
131
|
+
* @param str - The JSON-like string to normalize.
|
|
132
|
+
* @returns A properly formatted JSON string.
|
|
133
|
+
*/
|
|
134
|
+
export declare const normalizeJsonString: (str: string) => string;
|
|
135
|
+
/**
|
|
136
|
+
* Truncate text to fit within the character limit, ensuring it ends at a complete sentence.
|
|
137
|
+
*/
|
|
138
|
+
export declare function truncateToCompleteSentence(text: string, maxLength: number): string;
|
|
139
|
+
export declare function splitChunks(content: string, chunkSize?: number, bleed?: number): Promise<string[]>;
|
|
140
|
+
/**
|
|
141
|
+
* Trims the provided text prompt to a specified token limit using a tokenizer model and type.
|
|
142
|
+
*/
|
|
143
|
+
export declare function trimTokens(prompt: string, maxTokens: number, runtime: IAgentRuntime): Promise<string>;
|
|
144
|
+
export declare function safeReplacer(): (_key: string, value: any) => any;
|
|
145
|
+
/**
|
|
146
|
+
* Parses a string to determine its boolean equivalent.
|
|
147
|
+
*
|
|
148
|
+
* Recognized affirmative values: "YES", "Y", "TRUE", "T", "1", "ON", "ENABLE"
|
|
149
|
+
* Recognized negative values: "NO", "N", "FALSE", "F", "0", "OFF", "DISABLE"
|
|
150
|
+
*
|
|
151
|
+
* @param {string | undefined | null} value - The input text to parse
|
|
152
|
+
* @returns {boolean} - Returns `true` for affirmative inputs, `false` for negative or unrecognized inputs
|
|
153
|
+
*/
|
|
154
|
+
export declare function parseBooleanFromText(value: string | undefined | null): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Validates a UUID value.
|
|
157
|
+
*
|
|
158
|
+
* @param {unknown} value - The value to validate.
|
|
159
|
+
* @returns {UUID | null} Returns the validated UUID value or null if validation fails.
|
|
160
|
+
*/
|
|
161
|
+
export declare function validateUuid(value: unknown): UUID | null;
|
|
162
|
+
/**
|
|
163
|
+
* Converts a string or number to a UUID.
|
|
164
|
+
*
|
|
165
|
+
* @param {string | number} target - The string or number to convert to a UUID.
|
|
166
|
+
* @returns {UUID} The UUID generated from the input target.
|
|
167
|
+
* @throws {TypeError} Throws an error if the input target is not a string.
|
|
168
|
+
*/
|
|
169
|
+
export declare function stringToUuid(target: string | number): UUID;
|
|
170
|
+
/**
|
|
171
|
+
* Pre-warm the SHA-1 cache with common values using WebCrypto
|
|
172
|
+
* Call this during initialization to improve performance
|
|
173
|
+
*/
|
|
174
|
+
export declare function prewarmUuidCache(values: string[]): Promise<void>;
|
|
175
|
+
export declare const getContentTypeFromMimeType: (mimeType: string) => ContentType | undefined;
|
|
176
|
+
export declare function getLocalServerUrl(path: string): string;
|
|
177
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../core/src/utils.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAW,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAa,IAAI,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA8BvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAI,sBAG3B;IACD,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG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