@alquimia-ai/tools 1.13.2 → 2.1.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/actions/index.d.mts +2 -17
- package/dist/actions/index.d.ts +2 -17
- package/dist/actions/index.js +47 -152
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/index.mjs +47 -152
- package/dist/actions/index.mjs.map +1 -1
- package/dist/adapters/fetch.d.mts +12 -0
- package/dist/adapters/fetch.d.ts +12 -0
- package/dist/adapters/fetch.js +44 -0
- package/dist/adapters/fetch.js.map +1 -0
- package/dist/adapters/fetch.mjs +23 -0
- package/dist/adapters/fetch.mjs.map +1 -0
- package/dist/adapters/index.d.mts +11 -0
- package/dist/adapters/index.d.ts +11 -0
- package/dist/adapters/index.js +19 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/index.mjs +1 -0
- package/dist/adapters/index.mjs.map +1 -0
- package/dist/adapters/next.d.mts +10 -0
- package/dist/adapters/next.d.ts +10 -0
- package/dist/adapters/next.js +42 -0
- package/dist/adapters/next.js.map +1 -0
- package/dist/adapters/next.mjs +21 -0
- package/dist/adapters/next.mjs.map +1 -0
- package/dist/hooks/index.d.mts +23 -4
- package/dist/hooks/index.d.ts +23 -4
- package/dist/hooks/index.js +292 -57
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +283 -58
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/next/index.d.mts +46 -0
- package/dist/next/index.d.ts +46 -0
- package/dist/next/index.js +337 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/index.mjs +314 -0
- package/dist/next/index.mjs.map +1 -0
- package/dist/providers/index.d.mts +7 -3
- package/dist/providers/index.d.ts +7 -3
- package/dist/providers/index.js +15 -14
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/index.mjs +15 -14
- package/dist/providers/index.mjs.map +1 -1
- package/dist/proxy.d.mts +15 -0
- package/dist/proxy.d.ts +15 -0
- package/dist/proxy.js +170 -0
- package/dist/proxy.js.map +1 -0
- package/dist/proxy.mjs +149 -0
- package/dist/proxy.mjs.map +1 -0
- package/dist/sdk/index.d.mts +22 -20
- package/dist/sdk/index.d.ts +22 -20
- package/dist/sdk/index.js +85 -66
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/index.mjs +85 -66
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/services/index.d.mts +25 -3
- package/dist/services/index.d.ts +25 -3
- package/dist/session.action-DirvOWt0.d.mts +3 -0
- package/dist/session.action-DirvOWt0.d.ts +3 -0
- package/dist/types/index.d.mts +79 -18
- package/dist/types/index.d.ts +79 -18
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/package.json +35 -5
- package/dist/providers/elastic/index.d.mts +0 -23
- package/dist/providers/elastic/index.d.ts +0 -23
- package/dist/providers/elastic/index.js +0 -102
- package/dist/providers/elastic/index.js.map +0 -1
- package/dist/providers/elastic/index.mjs +0 -69
- package/dist/providers/elastic/index.mjs.map +0 -1
- package/dist/services/apm/index.d.mts +0 -26
- package/dist/services/apm/index.d.ts +0 -26
- package/dist/services/apm/index.js +0 -86
- package/dist/services/apm/index.js.map +0 -1
- package/dist/services/apm/index.mjs +0 -63
- package/dist/services/apm/index.mjs.map +0 -1
package/dist/services/index.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '../types/index.js';
|
|
1
|
+
import { Transaction } from '@elastic/apm-rum';
|
|
2
|
+
import { ApmSpan } from '../types/index.js';
|
|
4
3
|
import 'ai';
|
|
4
|
+
|
|
5
|
+
interface APMInitializerProps {
|
|
6
|
+
serviceName: string;
|
|
7
|
+
serverUrl?: string;
|
|
8
|
+
serverUrlPrefix?: string | undefined;
|
|
9
|
+
logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
10
|
+
environment: string;
|
|
11
|
+
ignoreUrls?: Array<string | RegExp>;
|
|
12
|
+
}
|
|
13
|
+
type LabelValue = string | number | boolean | null;
|
|
14
|
+
interface TransactionLabels {
|
|
15
|
+
[key: string]: LabelValue;
|
|
16
|
+
}
|
|
17
|
+
declare function APMInitializer({ serviceName, serverUrl, serverUrlPrefix, logLevel, environment, ignoreUrls }: APMInitializerProps): null;
|
|
18
|
+
declare function handleApmTransaction(name: string, type: string, labels: TransactionLabels, callback: () => Promise<void> | void): Promise<void>;
|
|
19
|
+
declare function traceError(error: string | Error, labels?: TransactionLabels, customMessage?: string): void;
|
|
20
|
+
declare const startManagedTransaction: (name: string, type: string | undefined, spanName: string, spanType?: string) => {
|
|
21
|
+
transaction: Transaction | undefined;
|
|
22
|
+
span: ApmSpan | undefined;
|
|
23
|
+
traceParentId: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { APMInitializer, handleApmTransaction, startManagedTransaction, traceError };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -24,10 +24,9 @@ interface AIMessageChunk {
|
|
|
24
24
|
tooler?: ToolEvent[];
|
|
25
25
|
error_code?: string;
|
|
26
26
|
error_detail?: string;
|
|
27
|
-
|
|
27
|
+
taskid?: string;
|
|
28
28
|
loading?: boolean;
|
|
29
29
|
thinkings?: ThinkingsInferenceResponse[];
|
|
30
|
-
evaluation_strategy?: string;
|
|
31
30
|
}
|
|
32
31
|
interface AIMessageChunkData {
|
|
33
32
|
content: string;
|
|
@@ -76,13 +75,12 @@ interface AttachmentPayload {
|
|
|
76
75
|
type AlquimiaMessage = Message & {
|
|
77
76
|
error_code?: string;
|
|
78
77
|
error_detail?: string;
|
|
79
|
-
|
|
78
|
+
taskid?: string;
|
|
80
79
|
loading?: boolean;
|
|
81
80
|
created_at?: string;
|
|
82
81
|
additionalInfo?: string;
|
|
83
82
|
tooler?: Tooler[];
|
|
84
83
|
thinkings?: ThinkingsInferenceResponse[];
|
|
85
|
-
evaluation_strategy?: string;
|
|
86
84
|
attachments?: AttachmentPayload[];
|
|
87
85
|
};
|
|
88
86
|
interface ActionResponse<T = void> {
|
|
@@ -161,19 +159,21 @@ type TTSResult = {
|
|
|
161
159
|
type: 'error';
|
|
162
160
|
message: string;
|
|
163
161
|
};
|
|
162
|
+
/** One SSE `data:` JSON frame (`event_class` at top level). */
|
|
164
163
|
interface AlquimiaEventData {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
164
|
+
taskid?: string;
|
|
165
|
+
event_class?: string;
|
|
166
|
+
control_id?: string;
|
|
167
|
+
date_submitted?: string;
|
|
168
|
+
status?: string | null;
|
|
169
|
+
data?: unknown;
|
|
170
|
+
experts?: ExpertInferenceResponse[];
|
|
171
|
+
thinkings?: ThinkingsInferenceResponse[];
|
|
172
|
+
tools_output?: ToolEvent[];
|
|
173
|
+
agents_output?: any[];
|
|
174
|
+
tools_pending_approval?: any[];
|
|
175
|
+
tools_pending_execution?: any[];
|
|
176
|
+
errors?: any[];
|
|
177
177
|
}
|
|
178
178
|
interface AssistantInferenceResponse {
|
|
179
179
|
event_class: string;
|
|
@@ -181,8 +181,69 @@ interface AssistantInferenceResponse {
|
|
|
181
181
|
data: string;
|
|
182
182
|
status: string;
|
|
183
183
|
date_submitted: string;
|
|
184
|
-
|
|
184
|
+
message?: string | null;
|
|
185
|
+
extras?: Record<string, unknown> | null;
|
|
186
|
+
extra_data?: ExtraDataContext | null;
|
|
187
|
+
channel?: unknown | null;
|
|
188
|
+
depth?: number;
|
|
189
|
+
taskid?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Channel-scoped context returned alongside an inference response (was
|
|
193
|
+
* `ExtraDataConfig` in v0.2.0). Carries message metadata from the channel
|
|
194
|
+
* the inference was triggered from.
|
|
195
|
+
*/
|
|
196
|
+
interface ExtraDataContext {
|
|
197
|
+
whatsapp_message_id?: string;
|
|
198
|
+
whatsapp_message_from?: string;
|
|
199
|
+
email_message_recipient?: string;
|
|
200
|
+
email_message_subject?: string;
|
|
201
|
+
email_message_id?: string;
|
|
202
|
+
email_message_body?: string;
|
|
203
|
+
slack_team_id?: string;
|
|
204
|
+
slack_user_id?: string;
|
|
205
|
+
slack_channel_id?: string;
|
|
206
|
+
slack_response_url?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* JSON body returned by `POST /event/infer/{assistantId}` (and channel
|
|
210
|
+
* variants). Keys match the runtime wire format (lowercase, no underscores).
|
|
211
|
+
* `taskid` is the id used for the SSE stream.
|
|
212
|
+
*/
|
|
213
|
+
interface CommonAttributes {
|
|
214
|
+
taskid?: string | null;
|
|
215
|
+
parenttaskid?: string | null;
|
|
216
|
+
sessionid?: string | null;
|
|
217
|
+
userid?: string | null;
|
|
218
|
+
assistantid?: string | null;
|
|
219
|
+
agentspaceid?: string | null;
|
|
220
|
+
channelid?: string | null;
|
|
221
|
+
depth?: string;
|
|
222
|
+
attachments?: string[];
|
|
223
|
+
}
|
|
224
|
+
type InferInitResponse = CommonAttributes;
|
|
225
|
+
/**
|
|
226
|
+
* Native-tools evaluation strategy. Wraps the client-side tool schemas
|
|
227
|
+
* the SDK previously sent at the top level of the infer payload.
|
|
228
|
+
*/
|
|
229
|
+
interface NativeToolsEvaluationStrategy {
|
|
230
|
+
evaluation_strategy_id: 'native';
|
|
231
|
+
tool_schemas?: unknown[];
|
|
232
|
+
max_steps?: number;
|
|
233
|
+
current_step?: number;
|
|
234
|
+
max_concurrent_tools?: number;
|
|
235
|
+
decorators?: unknown[];
|
|
236
|
+
tool_choice?: unknown;
|
|
237
|
+
structured_output?: unknown;
|
|
238
|
+
}
|
|
239
|
+
interface RawToolsEvaluationStrategy {
|
|
240
|
+
evaluation_strategy_id: 'raw';
|
|
241
|
+
tool_schemas?: unknown[];
|
|
242
|
+
}
|
|
243
|
+
interface OneShootEvaluationStrategy {
|
|
244
|
+
evaluation_strategy_id: 'one-shoot';
|
|
185
245
|
}
|
|
246
|
+
type EvaluationStrategy = NativeToolsEvaluationStrategy | RawToolsEvaluationStrategy | OneShootEvaluationStrategy;
|
|
186
247
|
interface AssistantResponseData {
|
|
187
248
|
content: string;
|
|
188
249
|
additional_kwargs: Record<string, any>;
|
|
@@ -237,4 +298,4 @@ interface ThinkingsInferenceResponse {
|
|
|
237
298
|
};
|
|
238
299
|
}
|
|
239
300
|
|
|
240
|
-
export { type AIMessageChunk, type AIMessageChunkData, type ActionResponse, type AlquimiaEventData, type AlquimiaMessage, type ApiError, type ApmSpan, type AssistantInferenceResponse, type AssistantResponseData, type AttachmentPayload, type BaseAPIConfig, type ConversationsMap, type DocumentSearchResult, type ElevenLabsRequestSpecs, type ElevenLabsVoiceSettings, type ExpertInferenceResponse, type IToolSpec, type ITooler, type RatingData, type ResponseMetadata, type TTSResult, type ThinkingsInferenceResponse, type TokenUsage, type ToolEvent, ToolFactory, type ToolOutput, type ToolSummary, type Tooler, type UsageMetadata };
|
|
301
|
+
export { type AIMessageChunk, type AIMessageChunkData, type ActionResponse, type AlquimiaEventData, type AlquimiaMessage, type ApiError, type ApmSpan, type AssistantInferenceResponse, type AssistantResponseData, type AttachmentPayload, type BaseAPIConfig, type CommonAttributes, type ConversationsMap, type DocumentSearchResult, type ElevenLabsRequestSpecs, type ElevenLabsVoiceSettings, type EvaluationStrategy, type ExpertInferenceResponse, type ExtraDataContext, type IToolSpec, type ITooler, type InferInitResponse, type NativeToolsEvaluationStrategy, type OneShootEvaluationStrategy, type RatingData, type RawToolsEvaluationStrategy, type ResponseMetadata, type TTSResult, type ThinkingsInferenceResponse, type TokenUsage, type ToolEvent, ToolFactory, type ToolOutput, type ToolSummary, type Tooler, type UsageMetadata };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -24,10 +24,9 @@ interface AIMessageChunk {
|
|
|
24
24
|
tooler?: ToolEvent[];
|
|
25
25
|
error_code?: string;
|
|
26
26
|
error_detail?: string;
|
|
27
|
-
|
|
27
|
+
taskid?: string;
|
|
28
28
|
loading?: boolean;
|
|
29
29
|
thinkings?: ThinkingsInferenceResponse[];
|
|
30
|
-
evaluation_strategy?: string;
|
|
31
30
|
}
|
|
32
31
|
interface AIMessageChunkData {
|
|
33
32
|
content: string;
|
|
@@ -76,13 +75,12 @@ interface AttachmentPayload {
|
|
|
76
75
|
type AlquimiaMessage = Message & {
|
|
77
76
|
error_code?: string;
|
|
78
77
|
error_detail?: string;
|
|
79
|
-
|
|
78
|
+
taskid?: string;
|
|
80
79
|
loading?: boolean;
|
|
81
80
|
created_at?: string;
|
|
82
81
|
additionalInfo?: string;
|
|
83
82
|
tooler?: Tooler[];
|
|
84
83
|
thinkings?: ThinkingsInferenceResponse[];
|
|
85
|
-
evaluation_strategy?: string;
|
|
86
84
|
attachments?: AttachmentPayload[];
|
|
87
85
|
};
|
|
88
86
|
interface ActionResponse<T = void> {
|
|
@@ -161,19 +159,21 @@ type TTSResult = {
|
|
|
161
159
|
type: 'error';
|
|
162
160
|
message: string;
|
|
163
161
|
};
|
|
162
|
+
/** One SSE `data:` JSON frame (`event_class` at top level). */
|
|
164
163
|
interface AlquimiaEventData {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
164
|
+
taskid?: string;
|
|
165
|
+
event_class?: string;
|
|
166
|
+
control_id?: string;
|
|
167
|
+
date_submitted?: string;
|
|
168
|
+
status?: string | null;
|
|
169
|
+
data?: unknown;
|
|
170
|
+
experts?: ExpertInferenceResponse[];
|
|
171
|
+
thinkings?: ThinkingsInferenceResponse[];
|
|
172
|
+
tools_output?: ToolEvent[];
|
|
173
|
+
agents_output?: any[];
|
|
174
|
+
tools_pending_approval?: any[];
|
|
175
|
+
tools_pending_execution?: any[];
|
|
176
|
+
errors?: any[];
|
|
177
177
|
}
|
|
178
178
|
interface AssistantInferenceResponse {
|
|
179
179
|
event_class: string;
|
|
@@ -181,8 +181,69 @@ interface AssistantInferenceResponse {
|
|
|
181
181
|
data: string;
|
|
182
182
|
status: string;
|
|
183
183
|
date_submitted: string;
|
|
184
|
-
|
|
184
|
+
message?: string | null;
|
|
185
|
+
extras?: Record<string, unknown> | null;
|
|
186
|
+
extra_data?: ExtraDataContext | null;
|
|
187
|
+
channel?: unknown | null;
|
|
188
|
+
depth?: number;
|
|
189
|
+
taskid?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Channel-scoped context returned alongside an inference response (was
|
|
193
|
+
* `ExtraDataConfig` in v0.2.0). Carries message metadata from the channel
|
|
194
|
+
* the inference was triggered from.
|
|
195
|
+
*/
|
|
196
|
+
interface ExtraDataContext {
|
|
197
|
+
whatsapp_message_id?: string;
|
|
198
|
+
whatsapp_message_from?: string;
|
|
199
|
+
email_message_recipient?: string;
|
|
200
|
+
email_message_subject?: string;
|
|
201
|
+
email_message_id?: string;
|
|
202
|
+
email_message_body?: string;
|
|
203
|
+
slack_team_id?: string;
|
|
204
|
+
slack_user_id?: string;
|
|
205
|
+
slack_channel_id?: string;
|
|
206
|
+
slack_response_url?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* JSON body returned by `POST /event/infer/{assistantId}` (and channel
|
|
210
|
+
* variants). Keys match the runtime wire format (lowercase, no underscores).
|
|
211
|
+
* `taskid` is the id used for the SSE stream.
|
|
212
|
+
*/
|
|
213
|
+
interface CommonAttributes {
|
|
214
|
+
taskid?: string | null;
|
|
215
|
+
parenttaskid?: string | null;
|
|
216
|
+
sessionid?: string | null;
|
|
217
|
+
userid?: string | null;
|
|
218
|
+
assistantid?: string | null;
|
|
219
|
+
agentspaceid?: string | null;
|
|
220
|
+
channelid?: string | null;
|
|
221
|
+
depth?: string;
|
|
222
|
+
attachments?: string[];
|
|
223
|
+
}
|
|
224
|
+
type InferInitResponse = CommonAttributes;
|
|
225
|
+
/**
|
|
226
|
+
* Native-tools evaluation strategy. Wraps the client-side tool schemas
|
|
227
|
+
* the SDK previously sent at the top level of the infer payload.
|
|
228
|
+
*/
|
|
229
|
+
interface NativeToolsEvaluationStrategy {
|
|
230
|
+
evaluation_strategy_id: 'native';
|
|
231
|
+
tool_schemas?: unknown[];
|
|
232
|
+
max_steps?: number;
|
|
233
|
+
current_step?: number;
|
|
234
|
+
max_concurrent_tools?: number;
|
|
235
|
+
decorators?: unknown[];
|
|
236
|
+
tool_choice?: unknown;
|
|
237
|
+
structured_output?: unknown;
|
|
238
|
+
}
|
|
239
|
+
interface RawToolsEvaluationStrategy {
|
|
240
|
+
evaluation_strategy_id: 'raw';
|
|
241
|
+
tool_schemas?: unknown[];
|
|
242
|
+
}
|
|
243
|
+
interface OneShootEvaluationStrategy {
|
|
244
|
+
evaluation_strategy_id: 'one-shoot';
|
|
185
245
|
}
|
|
246
|
+
type EvaluationStrategy = NativeToolsEvaluationStrategy | RawToolsEvaluationStrategy | OneShootEvaluationStrategy;
|
|
186
247
|
interface AssistantResponseData {
|
|
187
248
|
content: string;
|
|
188
249
|
additional_kwargs: Record<string, any>;
|
|
@@ -237,4 +298,4 @@ interface ThinkingsInferenceResponse {
|
|
|
237
298
|
};
|
|
238
299
|
}
|
|
239
300
|
|
|
240
|
-
export { type AIMessageChunk, type AIMessageChunkData, type ActionResponse, type AlquimiaEventData, type AlquimiaMessage, type ApiError, type ApmSpan, type AssistantInferenceResponse, type AssistantResponseData, type AttachmentPayload, type BaseAPIConfig, type ConversationsMap, type DocumentSearchResult, type ElevenLabsRequestSpecs, type ElevenLabsVoiceSettings, type ExpertInferenceResponse, type IToolSpec, type ITooler, type RatingData, type ResponseMetadata, type TTSResult, type ThinkingsInferenceResponse, type TokenUsage, type ToolEvent, ToolFactory, type ToolOutput, type ToolSummary, type Tooler, type UsageMetadata };
|
|
301
|
+
export { type AIMessageChunk, type AIMessageChunkData, type ActionResponse, type AlquimiaEventData, type AlquimiaMessage, type ApiError, type ApmSpan, type AssistantInferenceResponse, type AssistantResponseData, type AttachmentPayload, type BaseAPIConfig, type CommonAttributes, type ConversationsMap, type DocumentSearchResult, type ElevenLabsRequestSpecs, type ElevenLabsVoiceSettings, type EvaluationStrategy, type ExpertInferenceResponse, type ExtraDataContext, type IToolSpec, type ITooler, type InferInitResponse, type NativeToolsEvaluationStrategy, type OneShootEvaluationStrategy, type RatingData, type RawToolsEvaluationStrategy, type ResponseMetadata, type TTSResult, type ThinkingsInferenceResponse, type TokenUsage, type ToolEvent, ToolFactory, type ToolOutput, type ToolSummary, type Tooler, type UsageMetadata };
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts","../../src/types/type.ts"],"sourcesContent":["export * from './type'","import { Span } from \"@elastic/apm-rum\";\nimport { Message } from \"ai\";\nexport interface ITooler {\n tooler: Array<{\n name: string;\n parameters: Record<string, any>;\n }>;\n}\n\nexport interface IToolSpec {\n name: string;\n parameters: Record<string, any>;\n}\n\nexport abstract class ToolFactory {\n protected toolSpec: IToolSpec | null = null;\n\n constructor(toolSpec: IToolSpec) {\n this.toolSpec = toolSpec;\n }\n\n static createTool(toolSpec: IToolSpec): IToolSpec {\n return toolSpec;\n }\n\n abstract execute(): Promise<any>;\n}\n\nexport interface AIMessageChunk {\n type: string;\n data?: AIMessageChunkData;\n answer?: string;\n tooler?: ToolEvent[];\n error_code?: string;\n error_detail?: string;\n
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts","../../src/types/type.ts"],"sourcesContent":["export * from './type'","import { Span } from \"@elastic/apm-rum\";\nimport { Message } from \"ai\";\nexport interface ITooler {\n tooler: Array<{\n name: string;\n parameters: Record<string, any>;\n }>;\n}\n\nexport interface IToolSpec {\n name: string;\n parameters: Record<string, any>;\n}\n\nexport abstract class ToolFactory {\n protected toolSpec: IToolSpec | null = null;\n\n constructor(toolSpec: IToolSpec) {\n this.toolSpec = toolSpec;\n }\n\n static createTool(toolSpec: IToolSpec): IToolSpec {\n return toolSpec;\n }\n\n abstract execute(): Promise<any>;\n}\n\nexport interface AIMessageChunk {\n type: string;\n data?: AIMessageChunkData;\n answer?: string;\n tooler?: ToolEvent[];\n error_code?: string;\n error_detail?: string;\n taskid?: string;\n loading?: boolean;\n thinkings?: ThinkingsInferenceResponse[];\n}\n\nexport interface AIMessageChunkData {\n content: string;\n additional_kwargs?: Record<string, unknown>;\n response_metadata?: Record<string, unknown>;\n type: string;\n name?: string | null;\n id?: string | null;\n example?: boolean;\n tool_calls?: ToolCall[];\n invalid_tool_calls?: InvalidToolCall[];\n usage_metadata?: any;\n tool_call_chunks?: unknown[];\n error_code?: string;\n error_detail?: string;\n}\n\ntype ToolCall = {\n name: string;\n args: Record<string, any>;\n id?: string | null;\n};\n\ntype InvalidToolCall = {\n name: string | null;\n args: string | null;\n id: string | null;\n error: string | null;\n};\n\nexport interface BaseAPIConfig {\n baseUrl: string;\n route: string;\n token?: string;\n headers?: Record<string, string>;\n}\n\nexport interface RatingData {\n assistantId: string;\n sessionId: string;\n topicId: number;\n score?: number;\n description?: string;\n}\n\nexport interface AttachmentPayload {\n filename: string;\n content_type: string;\n content_size: number;\n}\n\nexport type AlquimiaMessage = Message & {\n error_code?: string;\n error_detail?: string;\n taskid?: string;\n loading?: boolean;\n created_at?: string;\n additionalInfo?: string;\n tooler?: Tooler[];\n thinkings?: ThinkingsInferenceResponse[];\n attachments?: AttachmentPayload[];\n};\n\nexport interface ActionResponse<T = void> {\n success: boolean;\n data?: T;\n error?: {\n message: string;\n code?: string;\n details?: any;\n name?: string;\n cause?: string;\n status?: string;\n };\n}\n\nexport type ApmSpan = Span & {\n id?: string \n traceId?: string\n} | undefined\n\nexport type ApiError = Error & {\n message: string;\n name: string;\n cause: string;\n code?: string | number;\n status?: string | number;\n}\n\nexport type Tooler = {\n control_id: string;\n tool_summary?: ToolSummary;\n tool_output?: ToolOutput;\n}\n\nexport type ToolSummary = {\n name: string;\n parameters: Record<string, any>;\n}\n\nexport type ToolOutput = {\n result: any;\n status: string;\n}\n\nexport type ToolEvent = {\n event_class: string;\n control_id: string;\n data: any;\n status: string;\n}\n\nexport interface ConversationsMap {\n [topicId: string]: string;\n}\n\nexport interface DocumentSearchResult {\n pageContent: string;\n metadata: {\n source: string;\n _id: string;\n _collection_name: string;\n };\n score: number;\n}\n\nexport type ElevenLabsVoiceSettings = {\n stability: number;\n similarity_boost: number;\n style: number;\n};\n\nexport type ElevenLabsRequestSpecs = {\n optimize_streaming_latency: string;\n output_format: string;\n model_id: string;\n language: string;\n voice_settings: ElevenLabsVoiceSettings;\n};\n\nexport type TTSResult =\n | { type: 'blob'; data: Blob }\n | { type: 'url'; data: string }\n | { type: 'error'; message: string };\n\n /** One SSE `data:` JSON frame (`event_class` at top level). */\n export interface AlquimiaEventData {\n taskid?: string;\n event_class?: string;\n control_id?: string;\n date_submitted?: string;\n status?: string | null;\n data?: unknown;\n experts?: ExpertInferenceResponse[];\n thinkings?: ThinkingsInferenceResponse[];\n tools_output?: ToolEvent[];\n agents_output?: any[];\n tools_pending_approval?: any[];\n tools_pending_execution?: any[];\n errors?: any[];\n }\n\n export interface AssistantInferenceResponse {\n event_class: string;\n control_id: string;\n data: string;\n status: string;\n date_submitted: string;\n message?: string | null;\n extras?: Record<string, unknown> | null;\n extra_data?: ExtraDataContext | null;\n channel?: unknown | null;\n depth?: number;\n taskid?: string;\n }\n\n /**\n * Channel-scoped context returned alongside an inference response (was\n * `ExtraDataConfig` in v0.2.0). Carries message metadata from the channel\n * the inference was triggered from.\n */\n export interface ExtraDataContext {\n whatsapp_message_id?: string;\n whatsapp_message_from?: string;\n email_message_recipient?: string;\n email_message_subject?: string;\n email_message_id?: string;\n email_message_body?: string;\n slack_team_id?: string;\n slack_user_id?: string;\n slack_channel_id?: string;\n slack_response_url?: string;\n }\n\n /**\n * JSON body returned by `POST /event/infer/{assistantId}` (and channel\n * variants). Keys match the runtime wire format (lowercase, no underscores).\n * `taskid` is the id used for the SSE stream.\n */\n export interface CommonAttributes {\n taskid?: string | null;\n parenttaskid?: string | null;\n sessionid?: string | null;\n userid?: string | null;\n assistantid?: string | null;\n agentspaceid?: string | null;\n channelid?: string | null;\n depth?: string;\n attachments?: string[];\n }\n\n export type InferInitResponse = CommonAttributes;\n\n /**\n * Native-tools evaluation strategy. Wraps the client-side tool schemas\n * the SDK previously sent at the top level of the infer payload.\n */\n export interface NativeToolsEvaluationStrategy {\n evaluation_strategy_id: 'native';\n tool_schemas?: unknown[];\n max_steps?: number;\n current_step?: number;\n max_concurrent_tools?: number;\n decorators?: unknown[];\n tool_choice?: unknown;\n structured_output?: unknown;\n }\n\n export interface RawToolsEvaluationStrategy {\n evaluation_strategy_id: 'raw';\n tool_schemas?: unknown[];\n }\n\n export interface OneShootEvaluationStrategy {\n evaluation_strategy_id: 'one-shoot';\n }\n\n export type EvaluationStrategy =\n | NativeToolsEvaluationStrategy\n | RawToolsEvaluationStrategy\n | OneShootEvaluationStrategy;\n\n export interface AssistantResponseData {\n content: string;\n additional_kwargs: Record<string, any>;\n response_metadata: ResponseMetadata;\n type: string;\n id: string;\n example: boolean;\n tool_calls: any[];\n invalid_tool_calls: any[];\n usage_metadata: UsageMetadata;\n }\n\n export interface ResponseMetadata {\n token_usage: TokenUsage;\n model_name: string;\n system_fingerprint: string;\n finish_reason: string;\n logprobs: any | null;\n }\n\n export interface TokenUsage {\n completion_tokens: number;\n prompt_tokens: number;\n total_tokens: number;\n completion_time: number;\n prompt_time: number;\n queue_time: number;\n total_time: number;\n }\n\n export interface UsageMetadata {\n input_tokens: number;\n output_tokens: number;\n total_tokens: number;\n }\n\n export interface ExpertInferenceResponse {\n event_class: string;\n control_id: string;\n data: {\n label: string;\n score: number;\n };\n status: string;\n date_submitted: string;\n }\n\n export interface ThinkingsInferenceResponse {\n event_class: string;\n control_id: string;\n status: string;\n date_submitted: string;\n data: {\n content: AssistantResponseData;\n is_complete: boolean;\n is_partial: boolean;\n };\n }"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAe,cAAf,MAA2B;AAAA,EAGhC,YAAY,UAAqB;AAFjC,SAAU,WAA6B;AAGrC,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,OAAO,WAAW,UAAgC;AAChD,WAAO;AAAA,EACT;AAGF;","names":[]}
|
package/dist/types/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/type.ts"],"sourcesContent":["import { Span } from \"@elastic/apm-rum\";\nimport { Message } from \"ai\";\nexport interface ITooler {\n tooler: Array<{\n name: string;\n parameters: Record<string, any>;\n }>;\n}\n\nexport interface IToolSpec {\n name: string;\n parameters: Record<string, any>;\n}\n\nexport abstract class ToolFactory {\n protected toolSpec: IToolSpec | null = null;\n\n constructor(toolSpec: IToolSpec) {\n this.toolSpec = toolSpec;\n }\n\n static createTool(toolSpec: IToolSpec): IToolSpec {\n return toolSpec;\n }\n\n abstract execute(): Promise<any>;\n}\n\nexport interface AIMessageChunk {\n type: string;\n data?: AIMessageChunkData;\n answer?: string;\n tooler?: ToolEvent[];\n error_code?: string;\n error_detail?: string;\n
|
|
1
|
+
{"version":3,"sources":["../../src/types/type.ts"],"sourcesContent":["import { Span } from \"@elastic/apm-rum\";\nimport { Message } from \"ai\";\nexport interface ITooler {\n tooler: Array<{\n name: string;\n parameters: Record<string, any>;\n }>;\n}\n\nexport interface IToolSpec {\n name: string;\n parameters: Record<string, any>;\n}\n\nexport abstract class ToolFactory {\n protected toolSpec: IToolSpec | null = null;\n\n constructor(toolSpec: IToolSpec) {\n this.toolSpec = toolSpec;\n }\n\n static createTool(toolSpec: IToolSpec): IToolSpec {\n return toolSpec;\n }\n\n abstract execute(): Promise<any>;\n}\n\nexport interface AIMessageChunk {\n type: string;\n data?: AIMessageChunkData;\n answer?: string;\n tooler?: ToolEvent[];\n error_code?: string;\n error_detail?: string;\n taskid?: string;\n loading?: boolean;\n thinkings?: ThinkingsInferenceResponse[];\n}\n\nexport interface AIMessageChunkData {\n content: string;\n additional_kwargs?: Record<string, unknown>;\n response_metadata?: Record<string, unknown>;\n type: string;\n name?: string | null;\n id?: string | null;\n example?: boolean;\n tool_calls?: ToolCall[];\n invalid_tool_calls?: InvalidToolCall[];\n usage_metadata?: any;\n tool_call_chunks?: unknown[];\n error_code?: string;\n error_detail?: string;\n}\n\ntype ToolCall = {\n name: string;\n args: Record<string, any>;\n id?: string | null;\n};\n\ntype InvalidToolCall = {\n name: string | null;\n args: string | null;\n id: string | null;\n error: string | null;\n};\n\nexport interface BaseAPIConfig {\n baseUrl: string;\n route: string;\n token?: string;\n headers?: Record<string, string>;\n}\n\nexport interface RatingData {\n assistantId: string;\n sessionId: string;\n topicId: number;\n score?: number;\n description?: string;\n}\n\nexport interface AttachmentPayload {\n filename: string;\n content_type: string;\n content_size: number;\n}\n\nexport type AlquimiaMessage = Message & {\n error_code?: string;\n error_detail?: string;\n taskid?: string;\n loading?: boolean;\n created_at?: string;\n additionalInfo?: string;\n tooler?: Tooler[];\n thinkings?: ThinkingsInferenceResponse[];\n attachments?: AttachmentPayload[];\n};\n\nexport interface ActionResponse<T = void> {\n success: boolean;\n data?: T;\n error?: {\n message: string;\n code?: string;\n details?: any;\n name?: string;\n cause?: string;\n status?: string;\n };\n}\n\nexport type ApmSpan = Span & {\n id?: string \n traceId?: string\n} | undefined\n\nexport type ApiError = Error & {\n message: string;\n name: string;\n cause: string;\n code?: string | number;\n status?: string | number;\n}\n\nexport type Tooler = {\n control_id: string;\n tool_summary?: ToolSummary;\n tool_output?: ToolOutput;\n}\n\nexport type ToolSummary = {\n name: string;\n parameters: Record<string, any>;\n}\n\nexport type ToolOutput = {\n result: any;\n status: string;\n}\n\nexport type ToolEvent = {\n event_class: string;\n control_id: string;\n data: any;\n status: string;\n}\n\nexport interface ConversationsMap {\n [topicId: string]: string;\n}\n\nexport interface DocumentSearchResult {\n pageContent: string;\n metadata: {\n source: string;\n _id: string;\n _collection_name: string;\n };\n score: number;\n}\n\nexport type ElevenLabsVoiceSettings = {\n stability: number;\n similarity_boost: number;\n style: number;\n};\n\nexport type ElevenLabsRequestSpecs = {\n optimize_streaming_latency: string;\n output_format: string;\n model_id: string;\n language: string;\n voice_settings: ElevenLabsVoiceSettings;\n};\n\nexport type TTSResult =\n | { type: 'blob'; data: Blob }\n | { type: 'url'; data: string }\n | { type: 'error'; message: string };\n\n /** One SSE `data:` JSON frame (`event_class` at top level). */\n export interface AlquimiaEventData {\n taskid?: string;\n event_class?: string;\n control_id?: string;\n date_submitted?: string;\n status?: string | null;\n data?: unknown;\n experts?: ExpertInferenceResponse[];\n thinkings?: ThinkingsInferenceResponse[];\n tools_output?: ToolEvent[];\n agents_output?: any[];\n tools_pending_approval?: any[];\n tools_pending_execution?: any[];\n errors?: any[];\n }\n\n export interface AssistantInferenceResponse {\n event_class: string;\n control_id: string;\n data: string;\n status: string;\n date_submitted: string;\n message?: string | null;\n extras?: Record<string, unknown> | null;\n extra_data?: ExtraDataContext | null;\n channel?: unknown | null;\n depth?: number;\n taskid?: string;\n }\n\n /**\n * Channel-scoped context returned alongside an inference response (was\n * `ExtraDataConfig` in v0.2.0). Carries message metadata from the channel\n * the inference was triggered from.\n */\n export interface ExtraDataContext {\n whatsapp_message_id?: string;\n whatsapp_message_from?: string;\n email_message_recipient?: string;\n email_message_subject?: string;\n email_message_id?: string;\n email_message_body?: string;\n slack_team_id?: string;\n slack_user_id?: string;\n slack_channel_id?: string;\n slack_response_url?: string;\n }\n\n /**\n * JSON body returned by `POST /event/infer/{assistantId}` (and channel\n * variants). Keys match the runtime wire format (lowercase, no underscores).\n * `taskid` is the id used for the SSE stream.\n */\n export interface CommonAttributes {\n taskid?: string | null;\n parenttaskid?: string | null;\n sessionid?: string | null;\n userid?: string | null;\n assistantid?: string | null;\n agentspaceid?: string | null;\n channelid?: string | null;\n depth?: string;\n attachments?: string[];\n }\n\n export type InferInitResponse = CommonAttributes;\n\n /**\n * Native-tools evaluation strategy. Wraps the client-side tool schemas\n * the SDK previously sent at the top level of the infer payload.\n */\n export interface NativeToolsEvaluationStrategy {\n evaluation_strategy_id: 'native';\n tool_schemas?: unknown[];\n max_steps?: number;\n current_step?: number;\n max_concurrent_tools?: number;\n decorators?: unknown[];\n tool_choice?: unknown;\n structured_output?: unknown;\n }\n\n export interface RawToolsEvaluationStrategy {\n evaluation_strategy_id: 'raw';\n tool_schemas?: unknown[];\n }\n\n export interface OneShootEvaluationStrategy {\n evaluation_strategy_id: 'one-shoot';\n }\n\n export type EvaluationStrategy =\n | NativeToolsEvaluationStrategy\n | RawToolsEvaluationStrategy\n | OneShootEvaluationStrategy;\n\n export interface AssistantResponseData {\n content: string;\n additional_kwargs: Record<string, any>;\n response_metadata: ResponseMetadata;\n type: string;\n id: string;\n example: boolean;\n tool_calls: any[];\n invalid_tool_calls: any[];\n usage_metadata: UsageMetadata;\n }\n\n export interface ResponseMetadata {\n token_usage: TokenUsage;\n model_name: string;\n system_fingerprint: string;\n finish_reason: string;\n logprobs: any | null;\n }\n\n export interface TokenUsage {\n completion_tokens: number;\n prompt_tokens: number;\n total_tokens: number;\n completion_time: number;\n prompt_time: number;\n queue_time: number;\n total_time: number;\n }\n\n export interface UsageMetadata {\n input_tokens: number;\n output_tokens: number;\n total_tokens: number;\n }\n\n export interface ExpertInferenceResponse {\n event_class: string;\n control_id: string;\n data: {\n label: string;\n score: number;\n };\n status: string;\n date_submitted: string;\n }\n\n export interface ThinkingsInferenceResponse {\n event_class: string;\n control_id: string;\n status: string;\n date_submitted: string;\n data: {\n content: AssistantResponseData;\n is_complete: boolean;\n is_partial: boolean;\n };\n }"],"mappings":";AAcO,IAAe,cAAf,MAA2B;AAAA,EAGhC,YAAY,UAAqB;AAFjC,SAAU,WAA6B;AAGrC,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,OAAO,WAAW,UAAgC;AAChD,WAAO;AAAA,EACT;AAGF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alquimia-ai/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"author": "Alquimia AI",
|
|
5
5
|
"description": "tools for Alquimia SDK",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"exports": {
|
|
9
|
+
"./adapters": {
|
|
10
|
+
"types": "./dist/adapters/index.d.ts",
|
|
11
|
+
"import": "./dist/adapters/index.mjs",
|
|
12
|
+
"require": "./dist/adapters/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./adapters/next": {
|
|
15
|
+
"types": "./dist/adapters/next.d.ts",
|
|
16
|
+
"import": "./dist/adapters/next.mjs",
|
|
17
|
+
"require": "./dist/adapters/next.js"
|
|
18
|
+
},
|
|
19
|
+
"./adapters/fetch": {
|
|
20
|
+
"types": "./dist/adapters/fetch.d.ts",
|
|
21
|
+
"import": "./dist/adapters/fetch.mjs",
|
|
22
|
+
"require": "./dist/adapters/fetch.js"
|
|
23
|
+
},
|
|
24
|
+
"./next": {
|
|
25
|
+
"types": "./dist/next/index.d.ts",
|
|
26
|
+
"import": "./dist/next/index.mjs",
|
|
27
|
+
"require": "./dist/next/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./proxy": {
|
|
30
|
+
"types": "./dist/proxy.d.ts",
|
|
31
|
+
"import": "./dist/proxy.mjs",
|
|
32
|
+
"require": "./dist/proxy.js"
|
|
33
|
+
},
|
|
9
34
|
"./sdk": {
|
|
10
35
|
"types": "./dist/sdk/index.d.ts",
|
|
11
36
|
"import": "./dist/sdk/index.mjs",
|
|
@@ -51,9 +76,9 @@
|
|
|
51
76
|
"scripts": {
|
|
52
77
|
"lint": "eslint . --max-warnings 0",
|
|
53
78
|
"generate:component": "turbo gen react-component",
|
|
54
|
-
"build": "tsup
|
|
79
|
+
"build": "tsup",
|
|
55
80
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
56
|
-
"dev": "tsup
|
|
81
|
+
"dev": "tsup --watch"
|
|
57
82
|
},
|
|
58
83
|
"files": [
|
|
59
84
|
"dist/**",
|
|
@@ -88,8 +113,13 @@
|
|
|
88
113
|
"react": "^18.2.0"
|
|
89
114
|
},
|
|
90
115
|
"peerDependencies": {
|
|
91
|
-
"next": "^14.2.15",
|
|
92
116
|
"react": ">=18.0.0",
|
|
93
|
-
"react-dom": ">=18.0.0"
|
|
117
|
+
"react-dom": ">=18.0.0",
|
|
118
|
+
"next": ">=14.0.0"
|
|
119
|
+
},
|
|
120
|
+
"peerDependenciesMeta": {
|
|
121
|
+
"next": {
|
|
122
|
+
"optional": true
|
|
123
|
+
}
|
|
94
124
|
}
|
|
95
125
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { L as LoggerProvider } from '../../providers-0Gi78uNQ.mjs';
|
|
2
|
-
import '../../types/index.mjs';
|
|
3
|
-
import '@elastic/apm-rum';
|
|
4
|
-
import 'ai';
|
|
5
|
-
|
|
6
|
-
interface ElasticLoggerConfig {
|
|
7
|
-
endpoint: string;
|
|
8
|
-
username: string;
|
|
9
|
-
password: string;
|
|
10
|
-
index?: string;
|
|
11
|
-
esVersion?: number;
|
|
12
|
-
flushBytes?: number;
|
|
13
|
-
}
|
|
14
|
-
declare class ElasticLoggerProvider extends LoggerProvider {
|
|
15
|
-
private logger;
|
|
16
|
-
private constructor();
|
|
17
|
-
static create(config: ElasticLoggerConfig): Promise<ElasticLoggerProvider>;
|
|
18
|
-
private initialize;
|
|
19
|
-
logInfo(message: string, data?: Record<string, any>): void;
|
|
20
|
-
logError(message: string, error: Error, data?: Record<string, any>): void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { ElasticLoggerProvider };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { L as LoggerProvider } from '../../providers-BJTXCtI3.js';
|
|
2
|
-
import '../../types/index.js';
|
|
3
|
-
import '@elastic/apm-rum';
|
|
4
|
-
import 'ai';
|
|
5
|
-
|
|
6
|
-
interface ElasticLoggerConfig {
|
|
7
|
-
endpoint: string;
|
|
8
|
-
username: string;
|
|
9
|
-
password: string;
|
|
10
|
-
index?: string;
|
|
11
|
-
esVersion?: number;
|
|
12
|
-
flushBytes?: number;
|
|
13
|
-
}
|
|
14
|
-
declare class ElasticLoggerProvider extends LoggerProvider {
|
|
15
|
-
private logger;
|
|
16
|
-
private constructor();
|
|
17
|
-
static create(config: ElasticLoggerConfig): Promise<ElasticLoggerProvider>;
|
|
18
|
-
private initialize;
|
|
19
|
-
logInfo(message: string, data?: Record<string, any>): void;
|
|
20
|
-
logError(message: string, error: Error, data?: Record<string, any>): void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { ElasticLoggerProvider };
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/providers/elastic/index.ts
|
|
31
|
-
var elastic_exports = {};
|
|
32
|
-
__export(elastic_exports, {
|
|
33
|
-
ElasticLoggerProvider: () => ElasticLoggerProvider
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(elastic_exports);
|
|
36
|
-
|
|
37
|
-
// src/providers/providers.ts
|
|
38
|
-
var LoggerProvider = class {
|
|
39
|
-
constructor(config) {
|
|
40
|
-
this.config = config;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// src/providers/elastic/elastic-search.ts
|
|
45
|
-
var import_pino = __toESM(require("pino"));
|
|
46
|
-
var ElasticLoggerProvider = class _ElasticLoggerProvider extends LoggerProvider {
|
|
47
|
-
constructor(config) {
|
|
48
|
-
super(config);
|
|
49
|
-
this.logger = console;
|
|
50
|
-
}
|
|
51
|
-
static async create(config) {
|
|
52
|
-
const provider = new _ElasticLoggerProvider(config);
|
|
53
|
-
await provider.initialize(config);
|
|
54
|
-
return provider;
|
|
55
|
-
}
|
|
56
|
-
async initialize(config) {
|
|
57
|
-
if (typeof window === "undefined") {
|
|
58
|
-
const [pinoElastic] = await Promise.all([
|
|
59
|
-
import("pino-elasticsearch")
|
|
60
|
-
]);
|
|
61
|
-
const streamToElastic = pinoElastic.default({
|
|
62
|
-
index: config.index || "logs-index",
|
|
63
|
-
node: config.endpoint,
|
|
64
|
-
esVersion: config.esVersion || 7,
|
|
65
|
-
flushBytes: config.flushBytes || 1e3,
|
|
66
|
-
auth: {
|
|
67
|
-
username: config.username || "",
|
|
68
|
-
password: config.password || ""
|
|
69
|
-
},
|
|
70
|
-
tls: {
|
|
71
|
-
rejectUnauthorized: false
|
|
72
|
-
},
|
|
73
|
-
op_type: "create"
|
|
74
|
-
});
|
|
75
|
-
streamToElastic.on("error", (err) => {
|
|
76
|
-
console.error("Elasticsearch stream error:", err);
|
|
77
|
-
});
|
|
78
|
-
streamToElastic.on("insertError", (err) => {
|
|
79
|
-
console.error("Elasticsearch insert error:", err);
|
|
80
|
-
});
|
|
81
|
-
streamToElastic.on("insert", () => {
|
|
82
|
-
console.log("Successfully sent log to Elasticsearch");
|
|
83
|
-
});
|
|
84
|
-
this.logger = (0, import_pino.default)({
|
|
85
|
-
level: "info",
|
|
86
|
-
timestamp: () => `,"time":"${(/* @__PURE__ */ new Date()).toISOString()}"`
|
|
87
|
-
}, streamToElastic);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
logInfo(message, data) {
|
|
91
|
-
this.logger.info({ ...data }, message);
|
|
92
|
-
}
|
|
93
|
-
logError(message, error, data) {
|
|
94
|
-
const errorDetails = {
|
|
95
|
-
message: error.message,
|
|
96
|
-
name: error.name,
|
|
97
|
-
stack: error.stack
|
|
98
|
-
};
|
|
99
|
-
this.logger.error({ error, ...data, ...errorDetails }, message);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/providers/elastic/index.ts","../../../src/providers/providers.ts","../../../src/providers/elastic/elastic-search.ts"],"sourcesContent":["export * from \"./elastic-search\";","import { TTSResult } from \"../types\";\n\nexport abstract class GenerativeProvider {\n private config: Record<string, any>;\n\n constructor(config: Record<string, any>) {\n this.config = config;\n }\n}\n\nexport abstract class WhisperProvider {\n protected config: Record<string, any>;\n\n constructor(config: Record<string, any>) {\n this.config = config;\n }\n\n abstract textToSpeech(text: string): Promise<TTSResult>\n\n abstract speechToText(audio: string): Promise<string>\n} \n\nexport abstract class StableDiffusionProvider {\n protected config: Record<string, any>;\n\n constructor(config: Record<string, any>) {\n this.config = config;\n }\n\n abstract generateImage(query: string): Promise<string>\n}\n\nexport abstract class CharacterizationProvider {\n protected config: Record<string, any>;\n\n constructor(config: Record<string, any>) {\n this.config = config;\n }\n\n abstract analyzeCharacterization(text: string): Promise<Record<string, any>>\n}\n\nexport abstract class RatingsProvider {\n protected config: Record<string, any>;\n\n constructor(config: Record<string, any>) {\n this.config = config;\n }\n\n abstract rate(data: Record<string, any>): Promise<Record<string, any>>;\n}\n\nexport abstract class LoggerProvider {\n protected config: Record<string, any>;\n\n constructor(config: Record<string, any>) {\n this.config = config;\n }\n\n abstract logInfo(message: string, data?: Record<string, any>): void;\n abstract logError(message: string, error: Error, data?: Record<string, any>): void;\n}\n","import { LoggerProvider } from \"../providers\";\nimport pino from \"pino\";\n\ninterface ElasticLoggerConfig {\n endpoint: string;\n username: string;\n password: string;\n index?: string;\n esVersion?: number;\n flushBytes?: number;\n}\n\nclass ElasticLoggerProvider extends LoggerProvider {\n private logger: pino.Logger;\n\n private constructor(config: ElasticLoggerConfig) {\n super(config);\n this.logger = console as any;\n }\n\n public static async create(config: ElasticLoggerConfig): Promise<ElasticLoggerProvider> {\n const provider = new ElasticLoggerProvider(config);\n await provider.initialize(config);\n return provider;\n }\n\n private async initialize(config: ElasticLoggerConfig) {\n if (typeof window === 'undefined') {\n const [pinoElastic] = await Promise.all([\n import('pino-elasticsearch')\n ]);\n\n const streamToElastic = pinoElastic.default({\n index: config.index || \"logs-index\",\n node: config.endpoint,\n esVersion: config.esVersion || 7,\n flushBytes: config.flushBytes || 1000,\n auth: {\n username: config.username || \"\",\n password: config.password || \"\",\n },\n tls: {\n rejectUnauthorized: false,\n },\n op_type: 'create',\n });\n\n streamToElastic.on('error', (err) => {\n console.error('Elasticsearch stream error:', err);\n });\n\n streamToElastic.on('insertError', (err) => {\n console.error('Elasticsearch insert error:', err);\n });\n\n streamToElastic.on('insert', () => {\n console.log('Successfully sent log to Elasticsearch');\n });\n\n\n this.logger = pino({\n level: 'info',\n timestamp: () => `,\"time\":\"${new Date().toISOString()}\"`,\n }, streamToElastic);\n }\n }\n\n logInfo(message: string, data?: Record<string, any>): void {\n this.logger.info({ ...data }, message);\n }\n\n logError(message: string, error: Error, data?: Record<string, any>): void {\n const errorDetails = {\n message: error.message,\n name: error.name,\n stack: error.stack,\n };\n this.logger.error({ error, ...data, ...errorDetails }, message);\n }\n}\n\nexport { ElasticLoggerProvider };"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoDO,IAAe,iBAAf,MAA8B;AAAA,EAGjC,YAAY,QAA6B;AACrC,SAAK,SAAS;AAAA,EAClB;AAIJ;;;AC5DA,kBAAiB;AAWjB,IAAM,wBAAN,MAAM,+BAA8B,eAAe;AAAA,EAGzC,YAAY,QAA6B;AAC/C,UAAM,MAAM;AACZ,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,aAAoB,OAAO,QAA6D;AACtF,UAAM,WAAW,IAAI,uBAAsB,MAAM;AACjD,UAAM,SAAS,WAAW,MAAM;AAChC,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,WAAW,QAA6B;AACpD,QAAI,OAAO,WAAW,aAAa;AACjC,YAAM,CAAC,WAAW,IAAI,MAAM,QAAQ,IAAI;AAAA,QACtC,OAAO,oBAAoB;AAAA,MAC7B,CAAC;AAED,YAAM,kBAAkB,YAAY,QAAQ;AAAA,QAC1C,OAAO,OAAO,SAAS;AAAA,QACvB,MAAM,OAAO;AAAA,QACb,WAAW,OAAO,aAAa;AAAA,QAC/B,YAAY,OAAO,cAAc;AAAA,QACjC,MAAM;AAAA,UACJ,UAAU,OAAO,YAAY;AAAA,UAC7B,UAAU,OAAO,YAAY;AAAA,QAC/B;AAAA,QACA,KAAK;AAAA,UACH,oBAAoB;AAAA,QACtB;AAAA,QACA,SAAS;AAAA,MACX,CAAC;AAED,sBAAgB,GAAG,SAAS,CAAC,QAAQ;AACnC,gBAAQ,MAAM,+BAA+B,GAAG;AAAA,MAClD,CAAC;AAED,sBAAgB,GAAG,eAAe,CAAC,QAAQ;AACzC,gBAAQ,MAAM,+BAA+B,GAAG;AAAA,MAClD,CAAC;AAED,sBAAgB,GAAG,UAAU,MAAM;AACjC,gBAAQ,IAAI,wCAAwC;AAAA,MACtD,CAAC;AAGD,WAAK,aAAS,YAAAA,SAAK;AAAA,QACjB,OAAO;AAAA,QACP,WAAW,MAAM,aAAY,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MACvD,GAAG,eAAe;AAAA,IACpB;AAAA,EACF;AAAA,EAEA,QAAQ,SAAiB,MAAkC;AACzD,SAAK,OAAO,KAAK,EAAE,GAAG,KAAK,GAAG,OAAO;AAAA,EACvC;AAAA,EAEA,SAAS,SAAiB,OAAc,MAAkC;AACxE,UAAM,eAAe;AAAA,MACnB,SAAS,MAAM;AAAA,MACf,MAAM,MAAM;AAAA,MACZ,OAAO,MAAM;AAAA,IACf;AACA,SAAK,OAAO,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,aAAa,GAAG,OAAO;AAAA,EAChE;AACF;","names":["pino"]}
|