@alquimia-ai/tools 2.4.0 → 2.7.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.
Files changed (77) hide show
  1. package/README.md +529 -19
  2. package/dist/actions/index.d.mts +2 -2
  3. package/dist/actions/index.d.ts +2 -2
  4. package/dist/actions/index.js +1 -1
  5. package/dist/actions/index.js.map +1 -1
  6. package/dist/actions/index.mjs +1 -1
  7. package/dist/actions/index.mjs.map +1 -1
  8. package/dist/{actions-CZU_GRy5.d.mts → actions-BjDPJdyA.d.mts} +1 -1
  9. package/dist/{actions-B0hfoYRd.d.ts → actions-CP1d4Ye1.d.ts} +1 -1
  10. package/dist/adapters/index.d.mts +2 -2
  11. package/dist/adapters/index.d.ts +2 -2
  12. package/dist/adapters/index.js.map +1 -1
  13. package/dist/genui/index.d.mts +3 -3
  14. package/dist/genui/index.d.ts +3 -3
  15. package/dist/genui/index.js +9 -1
  16. package/dist/genui/index.js.map +1 -1
  17. package/dist/genui/index.mjs +9 -1
  18. package/dist/genui/index.mjs.map +1 -1
  19. package/dist/hooks/index.d.mts +10 -10
  20. package/dist/hooks/index.d.ts +10 -10
  21. package/dist/hooks/index.js +88 -12
  22. package/dist/hooks/index.js.map +1 -1
  23. package/dist/hooks/index.mjs +88 -12
  24. package/dist/hooks/index.mjs.map +1 -1
  25. package/dist/next/index.js +23 -6
  26. package/dist/next/index.js.map +1 -1
  27. package/dist/next/index.mjs +23 -6
  28. package/dist/next/index.mjs.map +1 -1
  29. package/dist/providers/index.d.mts +4 -4
  30. package/dist/providers/index.d.ts +4 -4
  31. package/dist/providers/index.js +111 -110
  32. package/dist/providers/index.js.map +1 -1
  33. package/dist/providers/index.mjs +111 -110
  34. package/dist/providers/index.mjs.map +1 -1
  35. package/dist/{providers-BJTXCtI3.d.ts → providers-B4IOiGfr.d.mts} +8 -8
  36. package/dist/{providers-0Gi78uNQ.d.mts → providers-mx21gNgZ.d.ts} +8 -8
  37. package/dist/proxy.d.mts +4 -4
  38. package/dist/proxy.d.ts +4 -4
  39. package/dist/proxy.js +23 -6
  40. package/dist/proxy.js.map +1 -1
  41. package/dist/proxy.mjs +23 -6
  42. package/dist/proxy.mjs.map +1 -1
  43. package/dist/sdk/index.d.mts +39 -5
  44. package/dist/sdk/index.d.ts +39 -5
  45. package/dist/sdk/index.js +49 -6
  46. package/dist/sdk/index.js.map +1 -1
  47. package/dist/sdk/index.mjs +49 -6
  48. package/dist/sdk/index.mjs.map +1 -1
  49. package/dist/services/index.d.mts +3 -3
  50. package/dist/services/index.d.ts +3 -3
  51. package/dist/services/index.js.map +1 -1
  52. package/dist/services/index.mjs.map +1 -1
  53. package/dist/type-61gaZga-.d.mts +356 -0
  54. package/dist/type-D-JaSMkV.d.ts +356 -0
  55. package/dist/types/index.d.mts +80 -304
  56. package/dist/types/index.d.ts +80 -304
  57. package/dist/types/index.js.map +1 -1
  58. package/dist/types/index.mjs.map +1 -1
  59. package/dist/{types-DnfWUE9V.d.mts → types-CMVbyEv8.d.mts} +3 -2
  60. package/dist/{types-DnfWUE9V.d.ts → types-CMVbyEv8.d.ts} +3 -2
  61. package/dist/types-lOliroPw.d.mts +111 -0
  62. package/dist/types-lOliroPw.d.ts +111 -0
  63. package/dist/utils/index.d.mts +2 -2
  64. package/dist/utils/index.d.ts +2 -2
  65. package/dist/utils/index.js +1 -1
  66. package/dist/utils/index.js.map +1 -1
  67. package/dist/utils/index.mjs +1 -1
  68. package/dist/utils/index.mjs.map +1 -1
  69. package/dist/worklog/index.d.mts +5 -2
  70. package/dist/worklog/index.d.ts +5 -2
  71. package/dist/worklog/index.js +22 -1
  72. package/dist/worklog/index.js.map +1 -1
  73. package/dist/worklog/index.mjs +22 -1
  74. package/dist/worklog/index.mjs.map +1 -1
  75. package/package.json +1 -1
  76. package/dist/types-Dvu9y4WM.d.mts +0 -53
  77. package/dist/types-Dvu9y4WM.d.ts +0 -53
@@ -1,312 +1,88 @@
1
- import { Span } from '@elastic/apm-rum';
2
- import { Message } from 'ai';
3
- import { a as A2uiSurface } from '../types-DnfWUE9V.mjs';
1
+ export { a as AIMessageChunk, b as AIMessageChunkData, c as ActionResponse, d as AlquimiaEventData, e as AlquimiaMessage, f as ApiError, A as ApmSpan, g as AssistantInferenceResponse, h as AssistantResponseData, i as AttachmentPayload, B as BaseAPIConfig, C as CommonAttributes, j as Content, k as ContentPart, l as ConversationsMap, D as DocumentSearchResult, E as ElevenLabsRequestSpecs, m as ElevenLabsVoiceSettings, n as EvaluationStrategy, o as ExpertInferenceResponse, p as ExtraDataContext, G as GenuiSurfaceItem, I as IToolSpec, q as ITooler, r as ImageContentPart, s as InferInitResponse, N as NativeToolsEvaluationStrategy, t as NonStandardContentPart, O as OneShootEvaluationStrategy, R as RatingData, u as RawToolsEvaluationStrategy, v as ResponseMetadata, w as RuntimeBlob, T as TTSResult, x as TextContentPart, y as ThinkingsInferenceResponse, z as TokenUsage, F as ToolEvent, H as ToolFactory, J as ToolOutput, K as ToolSummary, L as Tooler, U as UsageMetadata } from '../type-61gaZga-.mjs';
2
+ import { T as ToolExecutionResponse } from '../types-CMVbyEv8.mjs';
3
+ import { W as WorklogRecord } from '../types-lOliroPw.mjs';
4
+ import '@elastic/apm-rum';
5
+ import 'ai';
4
6
 
5
- interface ITooler {
6
- tooler: Array<{
7
- name: string;
8
- parameters: Record<string, any>;
9
- }>;
10
- }
11
- interface IToolSpec {
12
- name: string;
13
- parameters: Record<string, any>;
14
- }
15
- declare abstract class ToolFactory {
16
- protected toolSpec: IToolSpec | null;
17
- constructor(toolSpec: IToolSpec);
18
- static createTool(toolSpec: IToolSpec): IToolSpec;
19
- abstract execute(): Promise<any>;
20
- }
21
- interface AIMessageChunk {
22
- type: string;
23
- data?: AIMessageChunkData;
24
- answer?: string;
25
- tooler?: ToolEvent[];
26
- error_code?: string;
27
- error_detail?: string;
28
- taskid?: string;
29
- loading?: boolean;
30
- thinkings?: ThinkingsInferenceResponse[];
31
- }
32
- interface AIMessageChunkData {
33
- content: string;
34
- additional_kwargs?: Record<string, unknown>;
35
- response_metadata?: Record<string, unknown>;
36
- type: string;
37
- name?: string | null;
38
- id?: string | null;
39
- example?: boolean;
40
- tool_calls?: ToolCall[];
41
- invalid_tool_calls?: InvalidToolCall[];
42
- usage_metadata?: any;
43
- tool_call_chunks?: unknown[];
44
- error_code?: string;
45
- error_detail?: string;
46
- }
47
- type ToolCall = {
48
- name: string;
49
- args: Record<string, any>;
50
- id?: string | null;
51
- };
52
- type InvalidToolCall = {
53
- name: string | null;
54
- args: string | null;
55
- id: string | null;
56
- error: string | null;
57
- };
58
- interface BaseAPIConfig {
59
- baseUrl: string;
60
- route: string;
61
- token?: string;
62
- headers?: Record<string, string>;
63
- }
64
- interface RatingData {
65
- assistantId: string;
66
- sessionId: string;
67
- topicId: number;
68
- score?: number;
69
- description?: string;
70
- }
71
- interface AttachmentPayload {
72
- filename: string;
73
- content_type: string;
74
- content_size: number;
75
- }
76
- type AlquimiaMessage = Message & {
77
- error_code?: string;
78
- error_detail?: string;
79
- taskid?: string;
80
- loading?: boolean;
81
- created_at?: string;
82
- additionalInfo?: string;
83
- tooler?: Tooler[];
84
- thinkings?: ThinkingsInferenceResponse[];
85
- attachments?: AttachmentPayload[];
86
- };
87
- interface ActionResponse<T = void> {
88
- success: boolean;
89
- data?: T;
90
- error?: {
91
- message: string;
92
- code?: string;
93
- details?: any;
94
- name?: string;
95
- cause?: string;
96
- status?: string;
97
- };
98
- }
99
- type ApmSpan = Span & {
100
- id?: string;
101
- traceId?: string;
102
- } | undefined;
103
- type ApiError = Error & {
104
- message: string;
105
- name: string;
106
- cause: string;
107
- code?: string | number;
108
- status?: string | number;
109
- };
110
- type Tooler = {
111
- control_id: string;
112
- tool_summary?: ToolSummary;
113
- tool_output?: ToolOutput;
114
- };
115
- type ToolSummary = {
116
- name: string;
117
- parameters: Record<string, any>;
118
- };
119
- type ToolOutput = {
120
- result: any;
121
- status: string;
122
- };
123
- type ToolEvent = {
124
- event_class: string;
125
- control_id: string;
126
- data: any;
127
- status: string;
128
- };
129
- interface ConversationsMap {
130
- [topicId: string]: string;
131
- }
132
- interface DocumentSearchResult {
133
- pageContent: string;
134
- metadata: {
135
- source: string;
136
- _id: string;
137
- _collection_name: string;
138
- };
139
- score: number;
140
- }
141
- type ElevenLabsVoiceSettings = {
142
- stability: number;
143
- similarity_boost: number;
144
- style: number;
145
- };
146
- type ElevenLabsRequestSpecs = {
147
- optimize_streaming_latency: string;
148
- output_format: string;
149
- model_id: string;
150
- language: string;
151
- voice_settings: ElevenLabsVoiceSettings;
152
- };
153
- type TTSResult = {
154
- type: 'blob';
155
- data: Blob;
156
- } | {
157
- type: 'url';
158
- data: string;
159
- } | {
160
- type: 'error';
161
- message: string;
162
- };
163
- /** One SSE `data:` JSON frame (`event_class` at top level). */
164
- interface AlquimiaEventData {
165
- taskid?: string;
166
- event_class?: string;
167
- control_id?: string;
168
- date_submitted?: string;
169
- status?: string | null;
170
- data?: unknown;
171
- experts?: ExpertInferenceResponse[];
172
- thinkings?: ThinkingsInferenceResponse[];
173
- tools_output?: ToolEvent[];
174
- agents_output?: any[];
175
- tools_pending_approval?: any[];
176
- tools_pending_execution?: any[];
177
- errors?: any[];
178
- }
179
- interface AssistantInferenceResponse {
180
- event_class: string;
181
- control_id: string;
182
- data: string;
183
- status: string;
184
- date_submitted: string;
185
- message?: string | null;
186
- extras?: Record<string, unknown> | null;
187
- extra_data?: ExtraDataContext | null;
188
- channel?: unknown | null;
189
- depth?: number;
190
- taskid?: string;
191
- }
192
- /**
193
- * Channel-scoped context returned alongside an inference response (was
194
- * `ExtraDataConfig` in v0.2.0). Carries message metadata from the channel
195
- * the inference was triggered from.
196
- */
197
- interface ExtraDataContext {
198
- whatsapp_message_id?: string;
199
- whatsapp_message_from?: string;
200
- email_message_recipient?: string;
201
- email_message_subject?: string;
202
- email_message_id?: string;
203
- email_message_body?: string;
204
- slack_team_id?: string;
205
- slack_user_id?: string;
206
- slack_channel_id?: string;
207
- slack_response_url?: string;
208
- }
209
7
  /**
210
- * JSON body returned by `POST /event/infer/{assistantId}` (and channel
211
- * variants). Keys match the runtime wire format (lowercase, no underscores).
212
- * `taskid` is the id used for the SSE stream.
8
+ * Runtime v0.5.1 event payloads.
9
+ *
10
+ * These types mirror the request/response schemas exposed by the
11
+ * `/event/*` endpoints. Many fields are optional because the runtime accepts
12
+ * sparse payloads and fills in defaults from the controller context.
213
13
  */
214
- interface CommonAttributes {
215
- taskid?: string | null;
216
- parenttaskid?: string | null;
217
- sessionid?: string | null;
218
- userid?: string | null;
219
- assistantid?: string | null;
220
- agentspaceid?: string | null;
221
- channelid?: string | null;
222
- depth?: string;
223
- attachments?: string[];
224
- }
225
- type InferInitResponse = CommonAttributes;
226
- /**
227
- * Native-tools evaluation strategy. Wraps the client-side tool schemas
228
- * the SDK previously sent at the top level of the infer payload.
229
- */
230
- interface NativeToolsEvaluationStrategy {
231
- evaluation_strategy_id: 'native';
232
- tool_schemas?: unknown[];
233
- max_steps?: number;
234
- current_step?: number;
235
- max_concurrent_tools?: number;
236
- decorators?: unknown[];
237
- tool_choice?: unknown;
238
- structured_output?: unknown;
239
- }
240
- interface RawToolsEvaluationStrategy {
241
- evaluation_strategy_id: 'raw';
242
- tool_schemas?: unknown[];
243
- }
244
- interface OneShootEvaluationStrategy {
245
- evaluation_strategy_id: 'one-shoot';
246
- }
247
- type EvaluationStrategy = NativeToolsEvaluationStrategy | RawToolsEvaluationStrategy | OneShootEvaluationStrategy;
248
- interface AssistantResponseData {
249
- content: string;
250
- additional_kwargs: Record<string, any>;
251
- response_metadata: ResponseMetadata;
252
- type: string;
253
- id: string;
254
- example: boolean;
255
- tool_calls: any[];
256
- invalid_tool_calls: any[];
257
- usage_metadata: UsageMetadata;
258
- }
259
- interface ResponseMetadata {
260
- token_usage: TokenUsage;
261
- model_name: string;
262
- system_fingerprint: string;
263
- finish_reason: string;
264
- logprobs: any | null;
265
- }
266
- interface TokenUsage {
267
- completion_tokens: number;
268
- prompt_tokens: number;
269
- total_tokens: number;
270
- completion_time: number;
271
- prompt_time: number;
272
- queue_time: number;
273
- total_time: number;
274
- }
275
- interface UsageMetadata {
276
- input_tokens: number;
277
- output_tokens: number;
278
- total_tokens: number;
279
- }
280
- interface ExpertInferenceResponse {
281
- event_class: string;
14
+ /** Base fields shared by most runtime events. */
15
+ interface RuntimeEventBase {
16
+ task_id?: string;
17
+ session_id?: string;
18
+ user_id?: string;
19
+ assistant_id?: string;
20
+ agentspace_id?: string;
21
+ channel_id?: string;
22
+ control_id?: string | null;
23
+ timestamp?: string;
24
+ /** Resolved registry version tag for versioned assistant refs (runtime v0.5.1). */
25
+ versiontag?: string | null;
26
+ }
27
+ /** POST /event/session-start */
28
+ interface SessionStartEvent extends RuntimeEventBase {
29
+ event_class: "SessionStartEvent";
30
+ session_id: string;
31
+ assistant_id?: string;
32
+ user_id?: string;
33
+ agentspace_id?: string;
34
+ channel_id?: string;
35
+ }
36
+ /** POST /event/session-end */
37
+ interface SessionEndEvent extends RuntimeEventBase {
38
+ event_class: "SessionEndEvent";
39
+ session_id?: string;
40
+ reason?: string;
41
+ }
42
+ /** POST /event/user-message */
43
+ interface UserMessageEvent extends RuntimeEventBase {
44
+ event_class: "UserMessageEvent";
45
+ message: unknown;
46
+ session_id?: string;
47
+ user_id?: string;
48
+ }
49
+ /** POST /event/agent-message */
50
+ interface AgentMessageEvent extends RuntimeEventBase {
51
+ event_class: "AgentMessageEvent";
52
+ content: unknown;
53
+ session_id?: string;
54
+ assistant_id?: string;
55
+ }
56
+ /** POST /event/tool-approval (approval/rejection of a pending human-approval gate). */
57
+ interface ToolApprovalEvent extends RuntimeEventBase {
58
+ event_class: "ToolApprovalEvent";
282
59
  control_id: string;
283
- data: {
284
- label: string;
285
- score: number;
286
- };
287
- status: string;
288
- date_submitted: string;
60
+ /** `true` for approval, `false` for rejection. */
61
+ result: boolean;
62
+ /** Optional reason or note attached to the decision. */
63
+ message?: string;
64
+ }
65
+ /** POST /event/tool-completion (client-side tool execution result). */
66
+ interface ToolCompletionEvent extends ToolExecutionResponse {
67
+ event_class: "ToolCompletionEvent";
68
+ }
69
+ /** POST /event/error */
70
+ interface RuntimeErrorEvent extends RuntimeEventBase {
71
+ event_class: "ErrorEvent";
72
+ error_code?: string;
73
+ message: string;
74
+ details?: unknown;
289
75
  }
290
- interface ThinkingsInferenceResponse {
291
- event_class: string;
292
- control_id: string;
293
- status: string;
294
- date_submitted: string;
295
- data: {
296
- content: AssistantResponseData;
297
- is_complete: boolean;
298
- is_partial: boolean;
299
- };
76
+ /** POST /event/bus-mode (batch of worklog records emitted when streaming in bus mode). */
77
+ interface BusModeEvent extends RuntimeEventBase {
78
+ event_class: "BusModeEvent";
79
+ records?: WorklogRecord[];
300
80
  }
301
- interface GenuiSurfaceItem {
302
- controlId: string;
303
- surface: A2uiSurface;
304
- /** Message-count anchor: the surface renders after this many messages (chronological ordering). */
305
- afterCount: number;
306
- /** True once the user has submitted an interactive surface (disables it + shows a submitted state). */
307
- submitted?: boolean;
308
- /** Set when the user declined the surface and typed a reply */
309
- dismissedWith?: string;
81
+ /** POST /event/heartbeat */
82
+ interface HeartbeatEvent extends RuntimeEventBase {
83
+ event_class: "HeartbeatEvent";
310
84
  }
85
+ /** Discriminated union of all runtime v0.5.1 event payloads. */
86
+ type RuntimeEvent = SessionStartEvent | SessionEndEvent | UserMessageEvent | AgentMessageEvent | ToolApprovalEvent | ToolCompletionEvent | RuntimeErrorEvent | BusModeEvent | HeartbeatEvent;
311
87
 
312
- 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 GenuiSurfaceItem, 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 };
88
+ export type { AgentMessageEvent, BusModeEvent, HeartbeatEvent, RuntimeErrorEvent, RuntimeEvent, RuntimeEventBase, SessionEndEvent, SessionStartEvent, ToolApprovalEvent, ToolCompletionEvent, UserMessageEvent };