@elizaos/api-client 1.3.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/README.md +19 -0
- 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 -919
- package/dist/index.js +210 -408
- package/dist/index.js.map +19 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +5 -6
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Character } from '../types/agent';
|
|
3
|
+
export declare const characterSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodOptional<z.ZodString>;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
username: z.ZodOptional<z.ZodString>;
|
|
7
|
+
system: z.ZodOptional<z.ZodString>;
|
|
8
|
+
templates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>]>>>;
|
|
9
|
+
bio: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
10
|
+
messageExamples: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
content: z.ZodObject<{
|
|
13
|
+
text: z.ZodOptional<z.ZodString>;
|
|
14
|
+
thought: z.ZodOptional<z.ZodString>;
|
|
15
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
16
|
+
providers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
source: z.ZodOptional<z.ZodString>;
|
|
18
|
+
target: z.ZodOptional<z.ZodString>;
|
|
19
|
+
url: z.ZodOptional<z.ZodString>;
|
|
20
|
+
inReplyTo: z.ZodOptional<z.ZodString>;
|
|
21
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
22
|
+
channelType: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
24
|
+
text: z.ZodOptional<z.ZodString>;
|
|
25
|
+
thought: z.ZodOptional<z.ZodString>;
|
|
26
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
27
|
+
providers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
28
|
+
source: z.ZodOptional<z.ZodString>;
|
|
29
|
+
target: z.ZodOptional<z.ZodString>;
|
|
30
|
+
url: z.ZodOptional<z.ZodString>;
|
|
31
|
+
inReplyTo: z.ZodOptional<z.ZodString>;
|
|
32
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
33
|
+
channelType: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
35
|
+
text: z.ZodOptional<z.ZodString>;
|
|
36
|
+
thought: z.ZodOptional<z.ZodString>;
|
|
37
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
38
|
+
providers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
39
|
+
source: z.ZodOptional<z.ZodString>;
|
|
40
|
+
target: z.ZodOptional<z.ZodString>;
|
|
41
|
+
url: z.ZodOptional<z.ZodString>;
|
|
42
|
+
inReplyTo: z.ZodOptional<z.ZodString>;
|
|
43
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
44
|
+
channelType: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
content: {
|
|
48
|
+
thought?: string | undefined;
|
|
49
|
+
text?: string | undefined;
|
|
50
|
+
actions?: string[] | undefined;
|
|
51
|
+
providers?: string[] | undefined;
|
|
52
|
+
source?: string | undefined;
|
|
53
|
+
target?: string | undefined;
|
|
54
|
+
url?: string | undefined;
|
|
55
|
+
inReplyTo?: string | undefined;
|
|
56
|
+
attachments?: any[] | undefined;
|
|
57
|
+
channelType?: string | undefined;
|
|
58
|
+
} & {
|
|
59
|
+
[k: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
name: string;
|
|
62
|
+
}, {
|
|
63
|
+
content: {
|
|
64
|
+
thought?: string | undefined;
|
|
65
|
+
text?: string | undefined;
|
|
66
|
+
actions?: string[] | undefined;
|
|
67
|
+
providers?: string[] | undefined;
|
|
68
|
+
source?: string | undefined;
|
|
69
|
+
target?: string | undefined;
|
|
70
|
+
url?: string | undefined;
|
|
71
|
+
inReplyTo?: string | undefined;
|
|
72
|
+
attachments?: any[] | undefined;
|
|
73
|
+
channelType?: string | undefined;
|
|
74
|
+
} & {
|
|
75
|
+
[k: string]: unknown;
|
|
76
|
+
};
|
|
77
|
+
name: string;
|
|
78
|
+
}>, "many">, "many">>;
|
|
79
|
+
postExamples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
80
|
+
topics: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
81
|
+
adjectives: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
82
|
+
knowledge: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
83
|
+
path: z.ZodString;
|
|
84
|
+
shared: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
path: string;
|
|
87
|
+
shared?: boolean | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
path: string;
|
|
90
|
+
shared?: boolean | undefined;
|
|
91
|
+
}>, z.ZodObject<{
|
|
92
|
+
directory: z.ZodString;
|
|
93
|
+
shared: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
directory: string;
|
|
96
|
+
shared?: boolean | undefined;
|
|
97
|
+
}, {
|
|
98
|
+
directory: string;
|
|
99
|
+
shared?: boolean | undefined;
|
|
100
|
+
}>]>, "many">>;
|
|
101
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
102
|
+
settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodAny]>>>;
|
|
103
|
+
secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean, z.ZodNumber]>>>;
|
|
104
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
all: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
106
|
+
chat: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
107
|
+
post: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
post?: string[] | undefined;
|
|
110
|
+
all?: string[] | undefined;
|
|
111
|
+
chat?: string[] | undefined;
|
|
112
|
+
}, {
|
|
113
|
+
post?: string[] | undefined;
|
|
114
|
+
all?: string[] | undefined;
|
|
115
|
+
chat?: string[] | undefined;
|
|
116
|
+
}>>;
|
|
117
|
+
}, "strict", z.ZodTypeAny, {
|
|
118
|
+
name: string;
|
|
119
|
+
bio: string | string[];
|
|
120
|
+
knowledge?: (string | {
|
|
121
|
+
directory: string;
|
|
122
|
+
shared?: boolean | undefined;
|
|
123
|
+
} | {
|
|
124
|
+
path: string;
|
|
125
|
+
shared?: boolean | undefined;
|
|
126
|
+
})[] | undefined;
|
|
127
|
+
username?: string | undefined;
|
|
128
|
+
id?: string | undefined;
|
|
129
|
+
system?: string | undefined;
|
|
130
|
+
templates?: Record<string, string | ((...args: unknown[]) => unknown) | undefined> | undefined;
|
|
131
|
+
messageExamples?: {
|
|
132
|
+
content: {
|
|
133
|
+
thought?: string | undefined;
|
|
134
|
+
text?: string | undefined;
|
|
135
|
+
actions?: string[] | undefined;
|
|
136
|
+
providers?: string[] | undefined;
|
|
137
|
+
source?: string | undefined;
|
|
138
|
+
target?: string | undefined;
|
|
139
|
+
url?: string | undefined;
|
|
140
|
+
inReplyTo?: string | undefined;
|
|
141
|
+
attachments?: any[] | undefined;
|
|
142
|
+
channelType?: string | undefined;
|
|
143
|
+
} & {
|
|
144
|
+
[k: string]: unknown;
|
|
145
|
+
};
|
|
146
|
+
name: string;
|
|
147
|
+
}[][] | undefined;
|
|
148
|
+
postExamples?: string[] | undefined;
|
|
149
|
+
topics?: string[] | undefined;
|
|
150
|
+
adjectives?: string[] | undefined;
|
|
151
|
+
plugins?: string[] | undefined;
|
|
152
|
+
settings?: Record<string, any> | undefined;
|
|
153
|
+
secrets?: Record<string, string | number | boolean> | undefined;
|
|
154
|
+
style?: {
|
|
155
|
+
post?: string[] | undefined;
|
|
156
|
+
all?: string[] | undefined;
|
|
157
|
+
chat?: string[] | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
}, {
|
|
160
|
+
name: string;
|
|
161
|
+
bio: string | string[];
|
|
162
|
+
knowledge?: (string | {
|
|
163
|
+
directory: string;
|
|
164
|
+
shared?: boolean | undefined;
|
|
165
|
+
} | {
|
|
166
|
+
path: string;
|
|
167
|
+
shared?: boolean | undefined;
|
|
168
|
+
})[] | undefined;
|
|
169
|
+
username?: string | undefined;
|
|
170
|
+
id?: string | undefined;
|
|
171
|
+
system?: string | undefined;
|
|
172
|
+
templates?: Record<string, string | ((...args: unknown[]) => unknown) | undefined> | undefined;
|
|
173
|
+
messageExamples?: {
|
|
174
|
+
content: {
|
|
175
|
+
thought?: string | undefined;
|
|
176
|
+
text?: string | undefined;
|
|
177
|
+
actions?: string[] | undefined;
|
|
178
|
+
providers?: string[] | undefined;
|
|
179
|
+
source?: string | undefined;
|
|
180
|
+
target?: string | undefined;
|
|
181
|
+
url?: string | undefined;
|
|
182
|
+
inReplyTo?: string | undefined;
|
|
183
|
+
attachments?: any[] | undefined;
|
|
184
|
+
channelType?: string | undefined;
|
|
185
|
+
} & {
|
|
186
|
+
[k: string]: unknown;
|
|
187
|
+
};
|
|
188
|
+
name: string;
|
|
189
|
+
}[][] | undefined;
|
|
190
|
+
postExamples?: string[] | undefined;
|
|
191
|
+
topics?: string[] | undefined;
|
|
192
|
+
adjectives?: string[] | undefined;
|
|
193
|
+
plugins?: string[] | undefined;
|
|
194
|
+
settings?: Record<string, any> | undefined;
|
|
195
|
+
secrets?: Record<string, string | number | boolean> | undefined;
|
|
196
|
+
style?: {
|
|
197
|
+
post?: string[] | undefined;
|
|
198
|
+
all?: string[] | undefined;
|
|
199
|
+
chat?: string[] | undefined;
|
|
200
|
+
} | undefined;
|
|
201
|
+
}>;
|
|
202
|
+
export interface CharacterValidationResult {
|
|
203
|
+
success: boolean;
|
|
204
|
+
data?: Character;
|
|
205
|
+
error?: {
|
|
206
|
+
message: string;
|
|
207
|
+
issues?: z.ZodIssue[];
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Safely validates character data using Zod schema
|
|
212
|
+
* @param data - Raw character data to validate
|
|
213
|
+
* @returns Validation result with success flag and either data or error
|
|
214
|
+
*/
|
|
215
|
+
export declare function validateCharacter(data: unknown): CharacterValidationResult;
|
|
216
|
+
/**
|
|
217
|
+
* Safely parses JSON string and validates as character
|
|
218
|
+
* @param jsonString - JSON string to parse and validate
|
|
219
|
+
* @returns Validation result with success flag and either data or error
|
|
220
|
+
*/
|
|
221
|
+
export declare function parseAndValidateCharacter(jsonString: string): CharacterValidationResult;
|
|
222
|
+
/**
|
|
223
|
+
* Type guard to check if data is a valid Character
|
|
224
|
+
* @param data - Data to check
|
|
225
|
+
* @returns True if data is a valid Character
|
|
226
|
+
*/
|
|
227
|
+
export declare function isValidCharacter(data: unknown): data is Character;
|
|
228
|
+
//# sourceMappingURL=character.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character.d.ts","sourceRoot":"","sources":["../../../../../core/src/schemas/character.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAmEhD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBjB,CAAC;AAGZ,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;KACvB,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,yBAAyB,CAiB1E;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,yBAAyB,CAYvF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAEjE"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for tokenization statistics.
|
|
3
|
+
*/
|
|
4
|
+
interface TokenizationStats {
|
|
5
|
+
/** Number of words in the original text before any processing. */
|
|
6
|
+
originalWordCount: number;
|
|
7
|
+
/** Number of words removed because they were identified as stop words. */
|
|
8
|
+
stopWordsRemoved: number;
|
|
9
|
+
/** Number of words that were stemmed (only if stemming is enabled). */
|
|
10
|
+
stemmedWords: number;
|
|
11
|
+
/** Time taken for tokenization in milliseconds. */
|
|
12
|
+
processingTimeMs: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Interface for the result of tokenization.
|
|
16
|
+
*/
|
|
17
|
+
interface TokenizationResult {
|
|
18
|
+
/** Array of processed tokens (words). */
|
|
19
|
+
tokens: string[];
|
|
20
|
+
/** Optional statistics about the tokenization process. */
|
|
21
|
+
stats?: TokenizationStats;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface for stemming rules.
|
|
25
|
+
*/
|
|
26
|
+
interface StemmingRule {
|
|
27
|
+
/** A RegExp pattern or string to match suffixes. */
|
|
28
|
+
pattern: RegExp | string;
|
|
29
|
+
/** The replacement string or function. */
|
|
30
|
+
replacement: string | ((substring: string, ...args: any[]) => string);
|
|
31
|
+
/** Optional minimum measure (complexity) of the word stem for the rule to apply. */
|
|
32
|
+
minMeasure?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Options for configuring the Tokenizer.
|
|
36
|
+
*/
|
|
37
|
+
interface TokenizerOptions {
|
|
38
|
+
/** A set of words to be ignored during tokenization. Defaults to an empty set. */
|
|
39
|
+
stopWords?: Set<string>;
|
|
40
|
+
/** The minimum length for a token to be kept. Defaults to 2. Numeric tokens are always kept. */
|
|
41
|
+
minLength?: number;
|
|
42
|
+
/** Whether to apply stemming to tokens. Defaults to false. */
|
|
43
|
+
stemming?: boolean;
|
|
44
|
+
/** Custom stemming rules to apply before the default Porter2 stemmer. Defaults to an empty array. */
|
|
45
|
+
stemmingRules?: StemmingRule[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Flexible text tokenizer with support for stop words, minimum token length,
|
|
49
|
+
* Unicode normalization, and optional Porter2 stemming with custom rules.
|
|
50
|
+
*/
|
|
51
|
+
declare class Tokenizer {
|
|
52
|
+
/** Set of stop words to ignore. */
|
|
53
|
+
readonly stopWords: Set<string>;
|
|
54
|
+
/** Minimum length of tokens to keep. */
|
|
55
|
+
readonly minLength: number;
|
|
56
|
+
/** Flag indicating if stemming is enabled. */
|
|
57
|
+
readonly stemming: boolean;
|
|
58
|
+
/** Custom stemming rules. */
|
|
59
|
+
readonly stemmingRules: {
|
|
60
|
+
pattern: RegExp;
|
|
61
|
+
replacement: string | ((substring: string, ...args: any[]) => string);
|
|
62
|
+
minMeasure?: number;
|
|
63
|
+
}[];
|
|
64
|
+
/** Default options for the Tokenizer. */
|
|
65
|
+
static readonly DEFAULT_OPTIONS: Required<TokenizerOptions>;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new tokenizer instance.
|
|
68
|
+
* @param options - Tokenization options including stop words, min length, stemming, and custom rules.
|
|
69
|
+
*/
|
|
70
|
+
constructor(options?: TokenizerOptions);
|
|
71
|
+
/**
|
|
72
|
+
* Tokenizes input text into an array of processed terms.
|
|
73
|
+
* Steps:
|
|
74
|
+
* 1. Cleans the text (lowercase, normalize, remove punctuation/symbols).
|
|
75
|
+
* 2. Splits the text into potential tokens.
|
|
76
|
+
* 3. Filters tokens based on `minLength` and `stopWords`.
|
|
77
|
+
* 4. Applies stemming if `stemming` is true (custom rules first, then Porter2).
|
|
78
|
+
* 5. Optionally calculates statistics.
|
|
79
|
+
*
|
|
80
|
+
* @param text - The input text string to tokenize.
|
|
81
|
+
* @param includeStats - If true, returns tokenization statistics along with tokens. Defaults to false.
|
|
82
|
+
* @returns A `TokenizationResult` object containing the array of tokens and optional stats.
|
|
83
|
+
* @throws {Error} If the input text is null, undefined, or empty.
|
|
84
|
+
*/
|
|
85
|
+
tokenize(text: string, includeStats?: boolean): TokenizationResult;
|
|
86
|
+
/**
|
|
87
|
+
* Cleans and normalizes text for tokenization.
|
|
88
|
+
* - Converts to lowercase.
|
|
89
|
+
* - Normalizes Unicode characters (NFKD).
|
|
90
|
+
* - Removes control characters and zero-width spaces.
|
|
91
|
+
* - Removes diacritical marks (accents).
|
|
92
|
+
* - Removes emojis and pictographs.
|
|
93
|
+
* - Removes common symbols (™, ®, ©, ℠, ‼).
|
|
94
|
+
* - Replaces Unicode punctuation with spaces.
|
|
95
|
+
* - Removes characters not matching basic Latin, CJK, Hangul, or whitespace.
|
|
96
|
+
* - Collapses multiple spaces into single spaces.
|
|
97
|
+
* - Trims leading/trailing whitespace.
|
|
98
|
+
*
|
|
99
|
+
* @param text - Input text to clean.
|
|
100
|
+
* @returns Cleaned and normalized text, ready for splitting into tokens.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* cleanText("Hello, World™!") // "hello world"
|
|
104
|
+
* cleanText("héllo 👋") // "hello"
|
|
105
|
+
* cleanText("Hello 世界!") // "hello 世界"
|
|
106
|
+
* cleanText("I'm don't") // "i'm don't" (apostrophes kept by replacing punctuation with space)
|
|
107
|
+
* cleanText("test©2023") // "test 2023"
|
|
108
|
+
*/
|
|
109
|
+
cleanText(text: string): string;
|
|
110
|
+
/**
|
|
111
|
+
* Checks if a token is valid (meets `minLength` criteria and is not a stop word).
|
|
112
|
+
* Numeric tokens are always considered valid regardless of length.
|
|
113
|
+
* @param token - The token string to validate.
|
|
114
|
+
* @returns `true` if the token is valid, `false` otherwise.
|
|
115
|
+
*/
|
|
116
|
+
isValidToken(token: string): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Applies stemming to a single word.
|
|
119
|
+
* First, tries to apply custom stemming rules defined in `stemmingRules`.
|
|
120
|
+
* If no custom rule matches, applies the default Porter2 stemming algorithm.
|
|
121
|
+
* Words shorter than 3 characters are not stemmed.
|
|
122
|
+
* @param word - The word to stem.
|
|
123
|
+
* @returns The stemmed word.
|
|
124
|
+
*/
|
|
125
|
+
stemWord(word: string): string;
|
|
126
|
+
/**
|
|
127
|
+
* Checks if the character at a given index in a word is a consonant.
|
|
128
|
+
* Treats 'y' as a consonant if it's the first letter or follows a consonant.
|
|
129
|
+
* @param word - The word string.
|
|
130
|
+
* @param i - The index of the character to check.
|
|
131
|
+
* @returns `true` if the character is a consonant, `false` otherwise.
|
|
132
|
+
*/
|
|
133
|
+
isConsonant(word: string, i: number): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Calculates the "measure" of a word stem (approximates syllable count).
|
|
136
|
+
* The measure (m) is the number of times a sequence of vowels is followed by a
|
|
137
|
+
* sequence of consonants (VC). Used in some stemming rules.
|
|
138
|
+
* Example: measure("tree") = 0, measure("trouble") = 1, measure("private") = 2
|
|
139
|
+
* @param word - The word (or stem) to measure.
|
|
140
|
+
* @returns The measure (m) of the word.
|
|
141
|
+
*/
|
|
142
|
+
measure(word: string): number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* BM25 Options Interface.
|
|
146
|
+
* Extends TokenizerOptions and adds BM25 specific parameters.
|
|
147
|
+
*/
|
|
148
|
+
interface BM25Options extends TokenizerOptions {
|
|
149
|
+
/**
|
|
150
|
+
* Term frequency saturation parameter (k1). Controls how quickly term frequency
|
|
151
|
+
* saturates. Higher values mean TF contributes more significantly even for high counts.
|
|
152
|
+
* Typical values are between 1.2 and 2.0. Default: 1.2.
|
|
153
|
+
*/
|
|
154
|
+
k1?: number;
|
|
155
|
+
/**
|
|
156
|
+
* Document length normalization parameter (b). Controls the influence of document
|
|
157
|
+
* length. 0 means no length normalization, 1 means full normalization.
|
|
158
|
+
* Typical values are around 0.75. Default: 0.75.
|
|
159
|
+
*/
|
|
160
|
+
b?: number;
|
|
161
|
+
/**
|
|
162
|
+
* A dictionary defining boost factors for specific document fields.
|
|
163
|
+
* Terms found in fields with higher boost factors will contribute more to the score.
|
|
164
|
+
* Example: `{ title: 2, body: 1 }`. Default: `{}` (no boosts).
|
|
165
|
+
*/
|
|
166
|
+
fieldBoosts?: {
|
|
167
|
+
[key: string]: number;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Represents a search result item.
|
|
172
|
+
*/
|
|
173
|
+
interface SearchResult {
|
|
174
|
+
/** The index of the matching document in the original document array. */
|
|
175
|
+
index: number;
|
|
176
|
+
/** The BM25 relevance score for the document. Higher scores indicate better relevance. */
|
|
177
|
+
score: number;
|
|
178
|
+
/** The actual document object (optional, depends on how results are retrieved). */
|
|
179
|
+
doc?: any;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Implements the Okapi BM25 (Best Matching 25) ranking function for information retrieval.
|
|
183
|
+
*
|
|
184
|
+
* BM25 ranks documents based on the query terms appearing in each document,
|
|
185
|
+
* considering term frequency (TF) and inverse document frequency (IDF).
|
|
186
|
+
* It improves upon basic TF-IDF by incorporating:
|
|
187
|
+
* - Term Frequency Saturation (k1): Prevents overly frequent terms from dominating the score.
|
|
188
|
+
* - Document Length Normalization (b): Penalizes documents that are longer than average,
|
|
189
|
+
* assuming longer documents are more likely to contain query terms by chance.
|
|
190
|
+
*
|
|
191
|
+
* Key Components:
|
|
192
|
+
* - Tokenizer: Processes text into terms (words), handles stop words and stemming.
|
|
193
|
+
* - Document Indexing: Stores document lengths, term frequencies per document,
|
|
194
|
+
* and overall document frequency for each term.
|
|
195
|
+
* - IDF Calculation: Measures the informativeness of a term based on how many documents contain it.
|
|
196
|
+
* - Scoring: Combines TF, IDF, document length, and parameters k1/b to calculate relevance.
|
|
197
|
+
*/
|
|
198
|
+
export declare class BM25 {
|
|
199
|
+
/** Term frequency saturation parameter (k1). */
|
|
200
|
+
readonly termFrequencySaturation: number;
|
|
201
|
+
/** Document length normalization factor (b). */
|
|
202
|
+
readonly lengthNormalizationFactor: number;
|
|
203
|
+
/** Tokenizer instance used for processing text. */
|
|
204
|
+
readonly tokenizer: Tokenizer;
|
|
205
|
+
/** Array storing the length (number of tokens, adjusted by field boosts) of each document. */
|
|
206
|
+
documentLengths: Uint32Array;
|
|
207
|
+
/** Average length of all documents in the index. */
|
|
208
|
+
averageDocLength: number;
|
|
209
|
+
/** Map from term (string) to its unique integer index. */
|
|
210
|
+
termToIndex: Map<string, number>;
|
|
211
|
+
/** Array storing the document frequency (number of docs containing the term) for each term index. */
|
|
212
|
+
documentFrequency: Uint32Array;
|
|
213
|
+
/** Map from term index to another map storing `docIndex: termFrequencyInDoc`. */
|
|
214
|
+
termFrequencies: Map<number, Map<number, number>>;
|
|
215
|
+
/** Boost factors for different fields within documents. */
|
|
216
|
+
readonly fieldBoosts: {
|
|
217
|
+
[key: string]: number;
|
|
218
|
+
};
|
|
219
|
+
/** Array storing the original documents added to the index. */
|
|
220
|
+
documents: any[];
|
|
221
|
+
/**
|
|
222
|
+
* Creates a new BM25 search instance.
|
|
223
|
+
* @param docs - Optional array of initial documents (objects with string fields) to index.
|
|
224
|
+
* @param options - Configuration options for BM25 parameters (k1, b), tokenizer (stopWords, stemming, minLength), and field boosts.
|
|
225
|
+
*/
|
|
226
|
+
constructor(docs?: any[], options?: BM25Options);
|
|
227
|
+
/**
|
|
228
|
+
* Processes an array of documents to build the initial index structures.
|
|
229
|
+
* Calculates document lengths, term frequencies, document frequencies, and average document length.
|
|
230
|
+
* @param docs - Array of documents to process.
|
|
231
|
+
* @returns An object containing the calculated index data.
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
234
|
+
private processDocuments;
|
|
235
|
+
/**
|
|
236
|
+
* Recalculates the average document length based on the current `documentLengths`.
|
|
237
|
+
* @internal
|
|
238
|
+
*/
|
|
239
|
+
private recalculateAverageLength;
|
|
240
|
+
/**
|
|
241
|
+
* Searches the indexed documents for a given query string using the BM25 ranking formula.
|
|
242
|
+
*
|
|
243
|
+
* @param query - The search query text.
|
|
244
|
+
* @param topK - The maximum number of top-scoring results to return. Defaults to 10.
|
|
245
|
+
* @returns An array of `SearchResult` objects, sorted by descending BM25 score.
|
|
246
|
+
*/
|
|
247
|
+
search(query: string, topK?: number): SearchResult[];
|
|
248
|
+
/**
|
|
249
|
+
* Searches for an exact phrase within the indexed documents.
|
|
250
|
+
* Ranks documents containing the exact sequence of tokens higher.
|
|
251
|
+
* Note: This is a basic implementation. More sophisticated phrase search might consider proximity.
|
|
252
|
+
*
|
|
253
|
+
* @param phrase - The exact phrase to search for.
|
|
254
|
+
* @param topK - The maximum number of results to return. Defaults to 10.
|
|
255
|
+
* @returns An array of `SearchResult` objects, sorted by score, for documents containing the phrase.
|
|
256
|
+
*/
|
|
257
|
+
searchPhrase(phrase: string, topK?: number): SearchResult[];
|
|
258
|
+
/**
|
|
259
|
+
* Calculates a BM25-like score for a sequence of phrase tokens within a specific document.
|
|
260
|
+
* Sums the individual BM25 scores of the terms in the phrase for that document.
|
|
261
|
+
* @param phraseTokens - The tokenized phrase.
|
|
262
|
+
* @param docIndex - The index of the document to score against.
|
|
263
|
+
* @returns The calculated phrase score for the document.
|
|
264
|
+
* @internal
|
|
265
|
+
*/
|
|
266
|
+
private calculatePhraseScore;
|
|
267
|
+
/**
|
|
268
|
+
* Adds a single new document to the index.
|
|
269
|
+
* Updates all internal index structures incrementally.
|
|
270
|
+
* Note: For adding many documents, `addDocumentsParallel` is generally more efficient.
|
|
271
|
+
*
|
|
272
|
+
* @param doc - The document object (with string fields) to add.
|
|
273
|
+
* @throws {Error} If the document is null or undefined.
|
|
274
|
+
*/
|
|
275
|
+
addDocument(doc: any): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Calculates the Inverse Document Frequency (IDF) for a given term index.
|
|
278
|
+
* Uses the BM25 IDF formula: log(1 + (N - n + 0.5) / (n + 0.5))
|
|
279
|
+
* where N is the total number of documents and n is the number of documents
|
|
280
|
+
* containing the term. The +1 smooths the logarithm.
|
|
281
|
+
*
|
|
282
|
+
* @param termIndex - The integer index of the term.
|
|
283
|
+
* @returns The IDF score for the term. Returns 0 if the term is not found or has 0 DF.
|
|
284
|
+
*/
|
|
285
|
+
calculateIdf(termIndex: number): number;
|
|
286
|
+
/**
|
|
287
|
+
* Retrieves the term frequency (TF) for a specific term in a specific document.
|
|
288
|
+
* @param termIndex - The integer index of the term.
|
|
289
|
+
* @param docIndex - The index of the document.
|
|
290
|
+
* @returns The term frequency, or 0 if the term is not in the document or indices are invalid.
|
|
291
|
+
*/
|
|
292
|
+
getTermFrequency(termIndex: number, docIndex: number): number;
|
|
293
|
+
/**
|
|
294
|
+
* Retrieves the original document object stored at a given index.
|
|
295
|
+
* @param index - The index of the document to retrieve.
|
|
296
|
+
* @returns The document object.
|
|
297
|
+
* @throws {Error} If the index is out of bounds.
|
|
298
|
+
*/
|
|
299
|
+
getDocument(index: number): any;
|
|
300
|
+
/**
|
|
301
|
+
* Clears all indexed documents and resets the BM25 instance to its initial state.
|
|
302
|
+
*/
|
|
303
|
+
clearDocuments(): void;
|
|
304
|
+
/**
|
|
305
|
+
* Gets the total number of documents currently indexed.
|
|
306
|
+
* @returns The document count.
|
|
307
|
+
*/
|
|
308
|
+
getDocumentCount(): number;
|
|
309
|
+
/**
|
|
310
|
+
* Adds multiple documents sequentially by calling `addDocument` for each.
|
|
311
|
+
* This method processes documents sequentially in the main thread.
|
|
312
|
+
* @param docs - An array of documents to add.
|
|
313
|
+
*/
|
|
314
|
+
addDocuments(docs: any[]): Promise<void[]>;
|
|
315
|
+
}
|
|
316
|
+
export {};
|
|
317
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../core/src/search.ts"],"names":[],"mappings":"AAwtBA;;GAEG;AACH,UAAU,iBAAiB;IACzB,kEAAkE;IAClE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0EAA0E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;IAI7D;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG;IAQ/B;;OAEG;IACH,cAAc,IAAI,IAAI;IAStB;;;OAGG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;;;OAIG;IACG,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAQjD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type SentryModule = {
|
|
2
|
+
init: (options: Record<string, any>) => void;
|
|
3
|
+
captureException: (error: unknown) => void;
|
|
4
|
+
flush?: (timeout?: number) => Promise<boolean>;
|
|
5
|
+
onLoad?: (cb: () => void) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const Sentry: {
|
|
8
|
+
captureException(error: unknown): Promise<void>;
|
|
9
|
+
flush(timeout?: number): Promise<boolean>;
|
|
10
|
+
};
|
|
11
|
+
export type { SentryModule };
|
|
12
|
+
//# sourceMappingURL=instrument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.d.ts","sourceRoot":"","sources":["../../../../../core/src/sentry/instrument.ts"],"names":[],"mappings":"AAEA,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC7C,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACnC,CAAC;AA0DF,eAAO,MAAM,MAAM;4BACa,OAAO;oBAMf,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAOhD,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Service } from './types';
|
|
2
|
+
import type { IAgentRuntime, ServiceTypeName } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Service builder class that provides type-safe service creation
|
|
5
|
+
* with automatic type inference
|
|
6
|
+
*/
|
|
7
|
+
export declare class ServiceBuilder<TService extends Service = Service> {
|
|
8
|
+
protected serviceType: ServiceTypeName | string;
|
|
9
|
+
protected startFn: (runtime: IAgentRuntime) => Promise<TService>;
|
|
10
|
+
protected stopFn?: () => Promise<void>;
|
|
11
|
+
protected description: string;
|
|
12
|
+
constructor(serviceType: ServiceTypeName | string);
|
|
13
|
+
/**
|
|
14
|
+
* Set the service description
|
|
15
|
+
*/
|
|
16
|
+
withDescription(description: string): this;
|
|
17
|
+
/**
|
|
18
|
+
* Set the start function for the service
|
|
19
|
+
*/
|
|
20
|
+
withStart(startFn: (runtime: IAgentRuntime) => Promise<TService>): this;
|
|
21
|
+
/**
|
|
22
|
+
* Set the stop function for the service
|
|
23
|
+
*/
|
|
24
|
+
withStop(stopFn: () => Promise<void>): this;
|
|
25
|
+
/**
|
|
26
|
+
* Build the service class with all configured properties
|
|
27
|
+
*/
|
|
28
|
+
build(): new (runtime?: IAgentRuntime) => TService;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a type-safe service builder
|
|
32
|
+
* @param serviceType - The service type name
|
|
33
|
+
* @returns A new ServiceBuilder instance
|
|
34
|
+
*/
|
|
35
|
+
export declare function createService<TService extends Service = Service>(serviceType: ServiceTypeName | string): ServiceBuilder<TService>;
|
|
36
|
+
/**
|
|
37
|
+
* Type-safe service definition helper
|
|
38
|
+
*/
|
|
39
|
+
export interface ServiceDefinition<T extends Service = Service> {
|
|
40
|
+
serviceType: ServiceTypeName;
|
|
41
|
+
description: string;
|
|
42
|
+
start: (runtime: IAgentRuntime) => Promise<T>;
|
|
43
|
+
stop?: () => Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Define a service with type safety
|
|
47
|
+
*/
|
|
48
|
+
export declare function defineService<T extends Service = Service>(definition: ServiceDefinition<T>): new (runtime?: IAgentRuntime) => T;
|
|
49
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../core/src/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9D;;;GAGG;AACH,qBAAa,cAAc,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IAC5D,SAAS,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAAC;IAChD,SAAS,CAAC,OAAO,EAAG,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClE,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;gBAElB,WAAW,EAAE,eAAe,GAAG,MAAM;IAKjD;;OAEG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAK1C;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI;IAKvE;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAK3C;;OAEG;IACH,KAAK,IAAI,KAAK,OAAO,CAAC,EAAE,aAAa,KAAK,QAAQ;CAyBnD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO,EAC9D,WAAW,EAAE,eAAe,GAAG,MAAM,GACpC,cAAc,CAAC,QAAQ,CAAC,CAE1B;AAED;;GAEG;AACH,MAAM,W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