@ai-sdk/provider-utils 5.0.0-beta.21 → 5.0.0-beta.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 5.0.0-beta.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 083947b: feat(ai): separate toolsContext from context
8
+
3
9
  ## 5.0.0-beta.21
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1604,31 +1604,16 @@ declare function executeTool<TOOL extends Tool>({ tool, input, options, }: {
1604
1604
  */
1605
1605
  type ToolSet = Record<string, (Tool<never, never, any> | Tool<any, any, any> | Tool<any, never, any> | Tool<never, any, any>) & Pick<Tool<any, any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta' | 'needsApproval'>>;
1606
1606
 
1607
- /**
1608
- * Converts a union type `U` into an intersection type.
1609
- *
1610
- * For example:
1611
- * type A = { a: number };
1612
- * type B = { b: string };
1613
- * type Union = A | B;
1614
- * type Intersection = UnionToIntersection<Union>;
1615
- * // Intersection is: { a: number } & { b: string }
1616
- *
1617
- * This is useful when you have a union of object types and need a type with all possible properties.
1618
- */
1619
- type UnionToIntersection<U> = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
1620
-
1621
1607
  /**
1622
1608
  * Infer the context type for a tool set.
1623
1609
  *
1624
- * The inferred type contains all properties required by the contexts of the
1625
- * tools in the set.
1610
+ * The inferred type maps each tool name to its required context type.
1626
1611
  *
1627
- * If there are incompatible properties, they will be of type `never`.
1612
+ * Tools without required context properties are omitted from the result.
1628
1613
  */
1629
- type InferToolSetContext<TOOLS extends ToolSet> = UnionToIntersection<{
1630
- [K in keyof TOOLS]: InferToolContext<NoInfer<TOOLS[K]>>;
1631
- }[keyof TOOLS]>;
1614
+ type InferToolSetContext<TOOLS extends ToolSet> = {
1615
+ [K in keyof TOOLS as InferToolContext<NoInfer<TOOLS[K]>> extends never ? never : K]: InferToolContext<NoInfer<TOOLS[K]>>;
1616
+ };
1632
1617
 
1633
1618
  /**
1634
1619
  * Typed tool call that is returned by generateText and streamText.
package/dist/index.js CHANGED
@@ -566,7 +566,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
566
566
  }
567
567
 
568
568
  // src/version.ts
569
- var VERSION = true ? "5.0.0-beta.21" : "0.0.0-test";
569
+ var VERSION = true ? "5.0.0-beta.22" : "0.0.0-test";
570
570
 
571
571
  // src/get-from-api.ts
572
572
  var getOriginalFetch = () => globalThis.fetch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider-utils",
3
- "version": "5.0.0-beta.21",
3
+ "version": "5.0.0-beta.22",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -1,17 +1,15 @@
1
1
  import type { InferToolContext } from './infer-tool-context';
2
2
  import type { ToolSet } from './tool-set';
3
- import type { UnionToIntersection } from './union-to-intersection';
4
3
 
5
4
  /**
6
5
  * Infer the context type for a tool set.
7
6
  *
8
- * The inferred type contains all properties required by the contexts of the
9
- * tools in the set.
7
+ * The inferred type maps each tool name to its required context type.
10
8
  *
11
- * If there are incompatible properties, they will be of type `never`.
9
+ * Tools without required context properties are omitted from the result.
12
10
  */
13
- export type InferToolSetContext<TOOLS extends ToolSet> = UnionToIntersection<
14
- {
15
- [K in keyof TOOLS]: InferToolContext<NoInfer<TOOLS[K]>>;
16
- }[keyof TOOLS]
17
- >;
11
+ export type InferToolSetContext<TOOLS extends ToolSet> = {
12
+ [K in keyof TOOLS as InferToolContext<NoInfer<TOOLS[K]>> extends never
13
+ ? never
14
+ : K]: InferToolContext<NoInfer<TOOLS[K]>>;
15
+ };
@@ -1,17 +0,0 @@
1
- /**
2
- * Converts a union type `U` into an intersection type.
3
- *
4
- * For example:
5
- * type A = { a: number };
6
- * type B = { b: string };
7
- * type Union = A | B;
8
- * type Intersection = UnionToIntersection<Union>;
9
- * // Intersection is: { a: number } & { b: string }
10
- *
11
- * This is useful when you have a union of object types and need a type with all possible properties.
12
- */
13
- export type UnionToIntersection<U> = (
14
- U extends unknown ? (arg: U) => void : never
15
- ) extends (arg: infer I) => void
16
- ? I
17
- : never;