ai 7.0.120 → 7.0.122

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.
@@ -18,6 +18,11 @@ export type ToUIMessageChunkOptions<
18
18
  sendSources?: boolean;
19
19
  sendStart?: boolean;
20
20
  sendFinish?: boolean;
21
+ /**
22
+ * Formats stream errors, invalid tool calls, and application-executed tool
23
+ * errors. Provider-executed tool execution errors bypass this callback so
24
+ * their original error data survives model-message round trips.
25
+ */
21
26
  onError?: (error: unknown) => string;
22
27
  messageMetadata?: InferUIMessageMetadata<UI_MESSAGE>;
23
28
  responseMessageId?: string;
@@ -40,7 +45,7 @@ export function toUIMessageChunk<
40
45
  sendSources = false,
41
46
  sendStart = true,
42
47
  sendFinish = true,
43
- onError = () => 'An error occurred.', // prevent leaking server error details to the client by default
48
+ onError = () => 'An error occurred.', // masks errors except provider-executed tool execution errors
44
49
  messageMetadata,
45
50
  responseMessageId,
46
51
  }: ToUIMessageChunkOptions<TOOLS, UI_MESSAGE> = {},
@@ -305,6 +310,9 @@ export function toUIMessageChunk<
305
310
  case 'tool-error': {
306
311
  const dynamic = isDynamic(part);
307
312
 
313
+ // Preserve provider error codes for model-message round trips and harness
314
+ // runtime error messages. These execution errors intentionally bypass
315
+ // onError; invalid tool calls and stream errors still go through it.
308
316
  return {
309
317
  type: 'tool-output-error',
310
318
  toolCallId: part.toolCallId,
@@ -26,7 +26,7 @@ export function toUIMessageStream<
26
26
  sendSources = false,
27
27
  sendStart = true,
28
28
  sendFinish = true,
29
- onError = () => 'An error occurred.', // prevent leaking server error details to the client by default
29
+ onError = () => 'An error occurred.', // masks errors except provider-executed tool execution errors
30
30
  messageMetadata,
31
31
  originalMessages,
32
32
  generateMessageId,
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Writes an enumerable own property without invoking inherited setters such as
3
+ * `Object.prototype.__proto__`. Keeps the target object's prototype unchanged.
4
+ */
5
+ export function setOwn<T>(
6
+ object: Record<string, T>,
7
+ key: string,
8
+ value: T,
9
+ ): void {
10
+ Object.defineProperty(object, key, {
11
+ value,
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ });
16
+ }