ai 7.0.103 → 7.0.105

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 (41) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/index.d.ts +37 -7
  3. package/dist/index.js +523 -298
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal/index.d.ts +1 -0
  6. package/dist/internal/index.js +4 -1
  7. package/dist/internal/index.js.map +1 -1
  8. package/docs/03-ai-sdk-core/18-code-mode.mdx +11 -0
  9. package/docs/03-ai-sdk-core/19-tool-search.mdx +80 -0
  10. package/docs/03-ai-sdk-core/32-evaluation.mdx +171 -7
  11. package/docs/03-ai-sdk-core/45-provider-management.mdx +10 -0
  12. package/docs/03-ai-sdk-core/index.mdx +6 -0
  13. package/docs/07-reference/01-ai-sdk-core/14-evaluate.mdx +22 -9
  14. package/docs/07-reference/01-ai-sdk-core/20-tool.mdx +7 -0
  15. package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +7 -0
  16. package/docs/07-reference/01-ai-sdk-core/23-tool-search.mdx +75 -0
  17. package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +18 -0
  18. package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +18 -0
  19. package/docs/07-reference/01-ai-sdk-core/index.mdx +6 -0
  20. package/docs/07-reference/05-ai-sdk-errors/ai-no-such-model-error.mdx +4 -0
  21. package/docs/07-reference/05-ai-sdk-errors/ai-no-such-provider-error.mdx +4 -0
  22. package/package.json +12 -12
  23. package/src/evaluate/evaluate.ts +4 -10
  24. package/src/evaluate/evaluation-provider.ts +6 -0
  25. package/src/evaluate/evaluation-result.ts +1 -1
  26. package/src/generate-text/generate-text.ts +9 -1
  27. package/src/generate-text/stream-text.ts +9 -1
  28. package/src/generate-text/tool-caller-configuration.ts +1 -1
  29. package/src/global.ts +1 -0
  30. package/src/index.ts +1 -0
  31. package/src/model/resolve-model.ts +53 -10
  32. package/src/prompt/prepare-tools.ts +1 -1
  33. package/src/realtime/browser-realtime-transport.ts +12 -1
  34. package/src/realtime/realtime-event-channel.ts +4 -0
  35. package/src/realtime/realtime-session.ts +9 -4
  36. package/src/registry/custom-provider.ts +37 -0
  37. package/src/registry/index.ts +2 -0
  38. package/src/registry/no-such-provider-error.ts +2 -1
  39. package/src/registry/provider-registry.ts +65 -6
  40. package/src/tool-search/prepare-tool-search.ts +143 -0
  41. package/src/tool-search/tool-search.ts +59 -0
@@ -0,0 +1,59 @@
1
+ import { jsonSchema, tool, type Tool } from '@ai-sdk/provider-utils';
2
+
3
+ const toolSearchSymbol = Symbol.for('vercel.ai.toolSearch');
4
+
5
+ type ToolSearchInput = { query: string };
6
+ type ToolSearchOutput = {
7
+ tools: Array<{ name: string; description?: string }>;
8
+ };
9
+
10
+ /**
11
+ * Search deferred tools by name and description. The surrounding generation
12
+ * binds the search registry and makes matches available on the next step.
13
+ * Use directly or through code mode with `toolDiscovery: 'conversation'`.
14
+ */
15
+ export function toolSearch(): Tool<ToolSearchInput, ToolSearchOutput> & {
16
+ type: 'function';
17
+ } {
18
+ return Object.assign(
19
+ tool({
20
+ description:
21
+ 'Search for tools by keywords in their names and descriptions. Returns up to five matching tools. Matches become available on the next model step, after this execution finishes. Wait for their tool definitions before calling the discovered tools. If no tools match, try different keywords.',
22
+ inputSchema: jsonSchema<ToolSearchInput>({
23
+ type: 'object',
24
+ properties: { query: { type: 'string', minLength: 1 } },
25
+ required: ['query'],
26
+ additionalProperties: false,
27
+ }),
28
+ outputSchema: jsonSchema<ToolSearchOutput>({
29
+ type: 'object',
30
+ properties: {
31
+ tools: {
32
+ type: 'array',
33
+ items: {
34
+ type: 'object',
35
+ properties: {
36
+ name: { type: 'string' },
37
+ description: { type: 'string' },
38
+ },
39
+ required: ['name'],
40
+ additionalProperties: false,
41
+ },
42
+ },
43
+ },
44
+ required: ['tools'],
45
+ additionalProperties: false,
46
+ }),
47
+ execute: () => {
48
+ throw new Error('toolSearch must be bound by an AI SDK generation.');
49
+ },
50
+ }),
51
+ { type: 'function' as const, [toolSearchSymbol]: true },
52
+ );
53
+ }
54
+
55
+ export function isToolSearch(tool: Tool): boolean {
56
+ return (
57
+ (tool as Tool & { [toolSearchSymbol]?: boolean })[toolSearchSymbol] === true
58
+ );
59
+ }