@alquimia-ai/tools 2.4.0 → 2.5.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 (76) hide show
  1. package/README.md +6 -0
  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 +28 -8
  22. package/dist/hooks/index.js.map +1 -1
  23. package/dist/hooks/index.mjs +28 -8
  24. package/dist/hooks/index.mjs.map +1 -1
  25. package/dist/next/index.js +19 -5
  26. package/dist/next/index.js.map +1 -1
  27. package/dist/next/index.mjs +19 -5
  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-DiR9cgyo.d.mts} +8 -8
  36. package/dist/{providers-0Gi78uNQ.d.mts → providers-b5_yMyMo.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 +19 -5
  40. package/dist/proxy.js.map +1 -1
  41. package/dist/proxy.mjs +19 -5
  42. package/dist/proxy.mjs.map +1 -1
  43. package/dist/sdk/index.d.mts +4 -3
  44. package/dist/sdk/index.d.ts +4 -3
  45. package/dist/sdk/index.js +8 -2
  46. package/dist/sdk/index.js.map +1 -1
  47. package/dist/sdk/index.mjs +8 -2
  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-DqX3-9QS.d.mts +312 -0
  54. package/dist/type-xksRnBUW.d.ts +312 -0
  55. package/dist/types/index.d.mts +78 -304
  56. package/dist/types/index.d.ts +78 -304
  57. package/dist/types/index.js.map +1 -1
  58. package/dist/types-C-6fgK1_.d.mts +111 -0
  59. package/dist/types-C-6fgK1_.d.ts +111 -0
  60. package/dist/{types-DnfWUE9V.d.mts → types-CMVbyEv8.d.mts} +3 -2
  61. package/dist/{types-DnfWUE9V.d.ts → types-CMVbyEv8.d.ts} +3 -2
  62. package/dist/utils/index.d.mts +2 -2
  63. package/dist/utils/index.d.ts +2 -2
  64. package/dist/utils/index.js +1 -1
  65. package/dist/utils/index.js.map +1 -1
  66. package/dist/utils/index.mjs +1 -1
  67. package/dist/utils/index.mjs.map +1 -1
  68. package/dist/worklog/index.d.mts +5 -2
  69. package/dist/worklog/index.d.ts +5 -2
  70. package/dist/worklog/index.js +3 -1
  71. package/dist/worklog/index.js.map +1 -1
  72. package/dist/worklog/index.mjs +3 -1
  73. package/dist/worklog/index.mjs.map +1 -1
  74. package/package.json +1 -1
  75. package/dist/types-Dvu9y4WM.d.mts +0 -53
  76. package/dist/types-Dvu9y4WM.d.ts +0 -53
@@ -1,13 +1,13 @@
1
1
  import * as react from 'react';
2
2
  import { AlquimiaSDK } from '../sdk/index.mjs';
3
3
  import { AlquimiaAdapter } from '../adapters/index.mjs';
4
- import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-0Gi78uNQ.mjs';
5
- import { GenuiSurfaceItem, AlquimiaMessage, ToolEvent, AIMessageChunk, RatingData } from '../types/index.mjs';
4
+ import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-DiR9cgyo.mjs';
5
+ import { G as GenuiSurfaceItem, e as AlquimiaMessage, u as ToolEvent, a as AIMessageChunk, R as RatingData } from '../type-DqX3-9QS.mjs';
6
+ import { T as ToolExecutionResponse } from '../types-CMVbyEv8.mjs';
7
+ import { a as WorklogState } from '../types-C-6fgK1_.mjs';
6
8
  import { createMessageId } from '../utils/index.mjs';
7
- import { W as WorklogState } from '../types-Dvu9y4WM.mjs';
8
- import { T as ToolExecutionResponse } from '../types-DnfWUE9V.mjs';
9
9
  import { C as CatalogManifest } from '../registry-Bcu_ZYL1.mjs';
10
- import { U as UIAction } from '../actions-CZU_GRy5.mjs';
10
+ import { U as UIAction } from '../actions-BjDPJdyA.mjs';
11
11
  import '@elastic/apm-rum';
12
12
  import 'ai';
13
13
  import 'zod';
@@ -74,7 +74,7 @@ declare function useAlquimia(config: UseAlquimiaConfig): {
74
74
  messages: AlquimiaMessage[];
75
75
  populateMessages: (messages: AlquimiaMessage[]) => void;
76
76
  processMessageChunk: (messageId: string, chunk: string, error_code?: string, error_detail?: string, taskid?: string, additionalInfo?: string, loading?: boolean, tooler?: ToolEvent[], thinkings?: any[]) => void;
77
- sendMessage: (message: string, callBack: (chunk: AIMessageChunk) => void, traceParentId?: string, sessionId?: string) => Promise<void>;
77
+ sendMessage: (message: string, callBack: (_chunk: AIMessageChunk) => void, traceParentId?: string, sessionId?: string) => Promise<void>;
78
78
  sessionId: string | null;
79
79
  setActiveTool: react.Dispatch<any>;
80
80
  setSessionId: react.Dispatch<react.SetStateAction<string | null>>;
@@ -93,11 +93,11 @@ declare function useAlquimia(config: UseAlquimiaConfig): {
93
93
  interface UseRatingsParams {
94
94
  assistantId: string;
95
95
  topicId: string;
96
- sendRating: (ratingData: RatingData) => Promise<any>;
97
- onError?: (componentName: string, error: Error) => void;
96
+ sendRating: (_ratingData: RatingData) => Promise<any>;
97
+ onError?: (_componentName: string, _error: Error) => void;
98
98
  }
99
- declare function useRatings({ assistantId, sendRating, topicId }: UseRatingsParams): {
100
- handleRate: (key: string, value: any | string, onHandleRateSuccess: (success: boolean, err?: string) => void) => Promise<void>;
99
+ declare function useRatings({ assistantId, sendRating, topicId, onError }: UseRatingsParams): {
100
+ handleRate: (key: string, value: any | string, onHandleRateSuccess: (_success: boolean, _err?: string) => void) => Promise<void>;
101
101
  ratingStars: number;
102
102
  ratingThumbs: "" | "thumbsUp" | "thumbsDown";
103
103
  ratingComment: string;
@@ -1,13 +1,13 @@
1
1
  import * as react from 'react';
2
2
  import { AlquimiaSDK } from '../sdk/index.js';
3
3
  import { AlquimiaAdapter } from '../adapters/index.js';
4
- import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-BJTXCtI3.js';
5
- import { GenuiSurfaceItem, AlquimiaMessage, ToolEvent, AIMessageChunk, RatingData } from '../types/index.js';
4
+ import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-b5_yMyMo.js';
5
+ import { G as GenuiSurfaceItem, e as AlquimiaMessage, u as ToolEvent, a as AIMessageChunk, R as RatingData } from '../type-xksRnBUW.js';
6
+ import { T as ToolExecutionResponse } from '../types-CMVbyEv8.js';
7
+ import { a as WorklogState } from '../types-C-6fgK1_.js';
6
8
  import { createMessageId } from '../utils/index.js';
7
- import { W as WorklogState } from '../types-Dvu9y4WM.js';
8
- import { T as ToolExecutionResponse } from '../types-DnfWUE9V.js';
9
9
  import { C as CatalogManifest } from '../registry-Bcu_ZYL1.js';
10
- import { U as UIAction } from '../actions-B0hfoYRd.js';
10
+ import { U as UIAction } from '../actions-CP1d4Ye1.js';
11
11
  import '@elastic/apm-rum';
12
12
  import 'ai';
13
13
  import 'zod';
@@ -74,7 +74,7 @@ declare function useAlquimia(config: UseAlquimiaConfig): {
74
74
  messages: AlquimiaMessage[];
75
75
  populateMessages: (messages: AlquimiaMessage[]) => void;
76
76
  processMessageChunk: (messageId: string, chunk: string, error_code?: string, error_detail?: string, taskid?: string, additionalInfo?: string, loading?: boolean, tooler?: ToolEvent[], thinkings?: any[]) => void;
77
- sendMessage: (message: string, callBack: (chunk: AIMessageChunk) => void, traceParentId?: string, sessionId?: string) => Promise<void>;
77
+ sendMessage: (message: string, callBack: (_chunk: AIMessageChunk) => void, traceParentId?: string, sessionId?: string) => Promise<void>;
78
78
  sessionId: string | null;
79
79
  setActiveTool: react.Dispatch<any>;
80
80
  setSessionId: react.Dispatch<react.SetStateAction<string | null>>;
@@ -93,11 +93,11 @@ declare function useAlquimia(config: UseAlquimiaConfig): {
93
93
  interface UseRatingsParams {
94
94
  assistantId: string;
95
95
  topicId: string;
96
- sendRating: (ratingData: RatingData) => Promise<any>;
97
- onError?: (componentName: string, error: Error) => void;
96
+ sendRating: (_ratingData: RatingData) => Promise<any>;
97
+ onError?: (_componentName: string, _error: Error) => void;
98
98
  }
99
- declare function useRatings({ assistantId, sendRating, topicId }: UseRatingsParams): {
100
- handleRate: (key: string, value: any | string, onHandleRateSuccess: (success: boolean, err?: string) => void) => Promise<void>;
99
+ declare function useRatings({ assistantId, sendRating, topicId, onError }: UseRatingsParams): {
100
+ handleRate: (key: string, value: any | string, onHandleRateSuccess: (_success: boolean, _err?: string) => void) => Promise<void>;
101
101
  ratingStars: number;
102
102
  ratingThumbs: "" | "thumbsUp" | "thumbsDown";
103
103
  ratingComment: string;
@@ -46,6 +46,8 @@ var AlquimiaSDK = class {
46
46
  this.sessionId = null;
47
47
  // Internal subscription id from infer (`taskid` on the wire).
48
48
  this.streamId = null;
49
+ // W3C traceparent for the current turn, so infer and stream share one trace.
50
+ this.traceParent = null;
49
51
  this.tools = [];
50
52
  this.extraInstructions = null;
51
53
  this.assistantConfig = null;
@@ -166,11 +168,12 @@ var AlquimiaSDK = class {
166
168
  const result = (await this.axiosInstance.post(inferUrl, initMessage, {
167
169
  headers: {
168
170
  "Content-Type": "application/json",
169
- "x-trace-parent": traceParent || "",
171
+ ...traceParent && { "x-trace-parent": traceParent },
170
172
  ...adapterHeaders,
171
173
  ...this.buildIdentityHeaders()
172
174
  }
173
175
  })).data;
176
+ this.traceParent = traceParent ?? null;
174
177
  this.streamId = result.taskid ?? null;
175
178
  this.attachmentResponses = result.attachments ?? [];
176
179
  this.attachments = [];
@@ -270,7 +273,10 @@ var AlquimiaSDK = class {
270
273
  if (!this.streamId) {
271
274
  throw new Error("Stream ID not initialized. Call sendMessage() first");
272
275
  }
273
- return this.adapter.resolveStreamUrl(this.streamId);
276
+ const url = this.adapter.resolveStreamUrl(this.streamId);
277
+ if (!this.traceParent) return url;
278
+ const separator = url.includes("?") ? "&" : "?";
279
+ return `${url}${separator}trace_parent=${encodeURIComponent(this.traceParent)}`;
274
280
  }
275
281
  getStreamId() {
276
282
  return this.streamId;
@@ -523,7 +529,9 @@ function frameToRecord(frame) {
523
529
  control_id: frame.control_id ?? null,
524
530
  data: frame.data,
525
531
  status,
526
- date_submitted: typeof frame.date_submitted === "string" ? frame.date_submitted : ""
532
+ date_submitted: typeof frame.date_submitted === "string" ? frame.date_submitted : "",
533
+ entry_hash: frame.entry_hash ?? null,
534
+ previous_hash: frame.previous_hash ?? null
527
535
  };
528
536
  }
529
537
 
@@ -732,7 +740,15 @@ var surfaceShape = import_zod3.z.object({
732
740
  });
733
741
  var UAX31_ID = /^[\p{XID_Start}_][\p{XID_Continue}]*$/u;
734
742
  function validateProps(node, def2) {
735
- const { id, component, children, child, binding, action, ...props } = node;
743
+ const {
744
+ id,
745
+ component: _component,
746
+ children: _children,
747
+ child: _child,
748
+ binding: _binding,
749
+ action: _action,
750
+ ...props
751
+ } = node;
736
752
  const parsed = def2.schema.safeParse(props);
737
753
  if (parsed.success) return { ok: true, value: parsed.data, errors: [] };
738
754
  return {
@@ -1395,14 +1411,14 @@ function ratingReducer(state, action) {
1395
1411
  return state;
1396
1412
  }
1397
1413
  }
1398
- function useRatings({ assistantId, sendRating, topicId }) {
1414
+ function useRatings({ assistantId, sendRating, topicId, onError }) {
1399
1415
  const [isLoading, setIsLoading] = (0, import_react3.useState)(false);
1400
1416
  const [hasReviewed, setHasReviewed] = (0, import_react3.useState)(false);
1401
1417
  const [state, dispatch] = (0, import_react3.useReducer)(ratingReducer, initialState);
1402
1418
  const setRatingStars = (rating) => {
1403
1419
  dispatch({ type: "SET_RATING_STARS", payload: rating });
1404
1420
  };
1405
- const setRatingThumbs = (rating) => {
1421
+ const _setRatingThumbs = (rating) => {
1406
1422
  dispatch({ type: "SET_RATING_THUMBS", payload: rating });
1407
1423
  };
1408
1424
  const setRatingComment = (comment) => {
@@ -1425,7 +1441,9 @@ function useRatings({ assistantId, sendRating, topicId }) {
1425
1441
  const response = await sendRating(ratingObj);
1426
1442
  if (!response.success) {
1427
1443
  setIsLoading(false);
1428
- onHandleRateSuccess(false, response.error.message);
1444
+ const error = new Error(response.error?.message ?? "Failed to send rating");
1445
+ onHandleRateSuccess(false, error.message);
1446
+ onError?.("useRatings", error);
1429
1447
  return;
1430
1448
  }
1431
1449
  if (key === "score") {
@@ -1438,7 +1456,9 @@ function useRatings({ assistantId, sendRating, topicId }) {
1438
1456
  onHandleRateSuccess(true);
1439
1457
  } catch (err) {
1440
1458
  setIsLoading(false);
1441
- onHandleRateSuccess(false, String(err));
1459
+ const error = err instanceof Error ? err : new Error(String(err));
1460
+ onHandleRateSuccess(false, error.message);
1461
+ onError?.("useRatings", error);
1442
1462
  }
1443
1463
  };
1444
1464
  return {