@tambo-ai/client 0.0.1
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/LICENSE +21 -0
- package/README.md +100 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/elicitation.d.ts +59 -0
- package/dist/mcp/elicitation.d.ts.map +1 -0
- package/dist/mcp/elicitation.js +27 -0
- package/dist/mcp/elicitation.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +14 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-client.d.ts +185 -0
- package/dist/mcp/mcp-client.d.ts.map +1 -0
- package/dist/mcp/mcp-client.js +219 -0
- package/dist/mcp/mcp-client.js.map +1 -0
- package/dist/mcp/mcp-constants.d.ts +19 -0
- package/dist/mcp/mcp-constants.d.ts.map +1 -0
- package/dist/mcp/mcp-constants.js +21 -0
- package/dist/mcp/mcp-constants.js.map +1 -0
- package/dist/model/component-metadata.d.ts +390 -0
- package/dist/model/component-metadata.d.ts.map +1 -0
- package/dist/model/component-metadata.js +3 -0
- package/dist/model/component-metadata.js.map +1 -0
- package/dist/model/mcp-server-info.d.ts +72 -0
- package/dist/model/mcp-server-info.d.ts.map +1 -0
- package/dist/model/mcp-server-info.js +29 -0
- package/dist/model/mcp-server-info.js.map +1 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +15 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/json-schema.d.ts +42 -0
- package/dist/schema/json-schema.d.ts.map +1 -0
- package/dist/schema/json-schema.js +114 -0
- package/dist/schema/json-schema.js.map +1 -0
- package/dist/schema/schema.d.ts +49 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +129 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/schema/standard-schema.d.ts +22 -0
- package/dist/schema/standard-schema.d.ts.map +1 -0
- package/dist/schema/standard-schema.js +42 -0
- package/dist/schema/standard-schema.js.map +1 -0
- package/dist/schema/validate.d.ts +14 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +148 -0
- package/dist/schema/validate.js.map +1 -0
- package/dist/tambo-client.d.ts +292 -0
- package/dist/tambo-client.d.ts.map +1 -0
- package/dist/tambo-client.js +508 -0
- package/dist/tambo-client.js.map +1 -0
- package/dist/tambo-stream.d.ts +112 -0
- package/dist/tambo-stream.d.ts.map +1 -0
- package/dist/tambo-stream.js +345 -0
- package/dist/tambo-stream.js.map +1 -0
- package/dist/types/auth.d.ts +24 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +3 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/event.d.ts +89 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +57 -0
- package/dist/types/event.js.map +1 -0
- package/dist/types/message.d.ts +122 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +10 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/thread.d.ts +58 -0
- package/dist/types/thread.d.ts.map +1 -0
- package/dist/types/thread.js +9 -0
- package/dist/types/thread.js.map +1 -0
- package/dist/types/tool-choice.d.ts +8 -0
- package/dist/types/tool-choice.d.ts.map +1 -0
- package/dist/types/tool-choice.js +3 -0
- package/dist/types/tool-choice.js.map +1 -0
- package/dist/utils/event-accumulator.d.ts +165 -0
- package/dist/utils/event-accumulator.d.ts.map +1 -0
- package/dist/utils/event-accumulator.js +1278 -0
- package/dist/utils/event-accumulator.js.map +1 -0
- package/dist/utils/json-patch.d.ts +18 -0
- package/dist/utils/json-patch.d.ts.map +1 -0
- package/dist/utils/json-patch.js +35 -0
- package/dist/utils/json-patch.js.map +1 -0
- package/dist/utils/keyed-throttle.d.ts +42 -0
- package/dist/utils/keyed-throttle.d.ts.map +1 -0
- package/dist/utils/keyed-throttle.js +86 -0
- package/dist/utils/keyed-throttle.js.map +1 -0
- package/dist/utils/registry-conversion.d.ts +53 -0
- package/dist/utils/registry-conversion.d.ts.map +1 -0
- package/dist/utils/registry-conversion.js +115 -0
- package/dist/utils/registry-conversion.js.map +1 -0
- package/dist/utils/send-message.d.ts +140 -0
- package/dist/utils/send-message.d.ts.map +1 -0
- package/dist/utils/send-message.js +183 -0
- package/dist/utils/send-message.js.map +1 -0
- package/dist/utils/stream-handler.d.ts +45 -0
- package/dist/utils/stream-handler.d.ts.map +1 -0
- package/dist/utils/stream-handler.js +47 -0
- package/dist/utils/stream-handler.js.map +1 -0
- package/dist/utils/thread-utils.d.ts +16 -0
- package/dist/utils/thread-utils.d.ts.map +1 -0
- package/dist/utils/thread-utils.js +34 -0
- package/dist/utils/thread-utils.js.map +1 -0
- package/dist/utils/tool-call-tracker.d.ts +74 -0
- package/dist/utils/tool-call-tracker.d.ts.map +1 -0
- package/dist/utils/tool-call-tracker.js +181 -0
- package/dist/utils/tool-call-tracker.js.map +1 -0
- package/dist/utils/tool-executor.d.ts +67 -0
- package/dist/utils/tool-executor.d.ts.map +1 -0
- package/dist/utils/tool-executor.js +160 -0
- package/dist/utils/tool-executor.js.map +1 -0
- package/dist/utils/unstrictify.d.ts +32 -0
- package/dist/utils/unstrictify.d.ts.map +1 -0
- package/dist/utils/unstrictify.js +160 -0
- package/dist/utils/unstrictify.js.map +1 -0
- package/esm/index.d.ts +43 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +78 -0
- package/esm/index.js.map +1 -0
- package/esm/mcp/elicitation.d.ts +59 -0
- package/esm/mcp/elicitation.d.ts.map +1 -0
- package/esm/mcp/elicitation.js +27 -0
- package/esm/mcp/elicitation.js.map +1 -0
- package/esm/mcp/index.d.ts +6 -0
- package/esm/mcp/index.d.ts.map +1 -0
- package/esm/mcp/index.js +14 -0
- package/esm/mcp/index.js.map +1 -0
- package/esm/mcp/mcp-client.d.ts +185 -0
- package/esm/mcp/mcp-client.d.ts.map +1 -0
- package/esm/mcp/mcp-client.js +219 -0
- package/esm/mcp/mcp-client.js.map +1 -0
- package/esm/mcp/mcp-constants.d.ts +19 -0
- package/esm/mcp/mcp-constants.d.ts.map +1 -0
- package/esm/mcp/mcp-constants.js +21 -0
- package/esm/mcp/mcp-constants.js.map +1 -0
- package/esm/model/component-metadata.d.ts +390 -0
- package/esm/model/component-metadata.d.ts.map +1 -0
- package/esm/model/component-metadata.js +3 -0
- package/esm/model/component-metadata.js.map +1 -0
- package/esm/model/mcp-server-info.d.ts +72 -0
- package/esm/model/mcp-server-info.d.ts.map +1 -0
- package/esm/model/mcp-server-info.js +29 -0
- package/esm/model/mcp-server-info.js.map +1 -0
- package/esm/schema/index.d.ts +5 -0
- package/esm/schema/index.d.ts.map +1 -0
- package/esm/schema/index.js +15 -0
- package/esm/schema/index.js.map +1 -0
- package/esm/schema/json-schema.d.ts +42 -0
- package/esm/schema/json-schema.d.ts.map +1 -0
- package/esm/schema/json-schema.js +114 -0
- package/esm/schema/json-schema.js.map +1 -0
- package/esm/schema/schema.d.ts +49 -0
- package/esm/schema/schema.d.ts.map +1 -0
- package/esm/schema/schema.js +129 -0
- package/esm/schema/schema.js.map +1 -0
- package/esm/schema/standard-schema.d.ts +22 -0
- package/esm/schema/standard-schema.d.ts.map +1 -0
- package/esm/schema/standard-schema.js +42 -0
- package/esm/schema/standard-schema.js.map +1 -0
- package/esm/schema/validate.d.ts +14 -0
- package/esm/schema/validate.d.ts.map +1 -0
- package/esm/schema/validate.js +148 -0
- package/esm/schema/validate.js.map +1 -0
- package/esm/tambo-client.d.ts +292 -0
- package/esm/tambo-client.d.ts.map +1 -0
- package/esm/tambo-client.js +508 -0
- package/esm/tambo-client.js.map +1 -0
- package/esm/tambo-stream.d.ts +112 -0
- package/esm/tambo-stream.d.ts.map +1 -0
- package/esm/tambo-stream.js +345 -0
- package/esm/tambo-stream.js.map +1 -0
- package/esm/types/auth.d.ts +24 -0
- package/esm/types/auth.d.ts.map +1 -0
- package/esm/types/auth.js +3 -0
- package/esm/types/auth.js.map +1 -0
- package/esm/types/event.d.ts +89 -0
- package/esm/types/event.d.ts.map +1 -0
- package/esm/types/event.js +57 -0
- package/esm/types/event.js.map +1 -0
- package/esm/types/message.d.ts +122 -0
- package/esm/types/message.d.ts.map +1 -0
- package/esm/types/message.js +10 -0
- package/esm/types/message.js.map +1 -0
- package/esm/types/thread.d.ts +58 -0
- package/esm/types/thread.d.ts.map +1 -0
- package/esm/types/thread.js +9 -0
- package/esm/types/thread.js.map +1 -0
- package/esm/types/tool-choice.d.ts +8 -0
- package/esm/types/tool-choice.d.ts.map +1 -0
- package/esm/types/tool-choice.js +3 -0
- package/esm/types/tool-choice.js.map +1 -0
- package/esm/utils/event-accumulator.d.ts +165 -0
- package/esm/utils/event-accumulator.d.ts.map +1 -0
- package/esm/utils/event-accumulator.js +1278 -0
- package/esm/utils/event-accumulator.js.map +1 -0
- package/esm/utils/json-patch.d.ts +18 -0
- package/esm/utils/json-patch.d.ts.map +1 -0
- package/esm/utils/json-patch.js +35 -0
- package/esm/utils/json-patch.js.map +1 -0
- package/esm/utils/keyed-throttle.d.ts +42 -0
- package/esm/utils/keyed-throttle.d.ts.map +1 -0
- package/esm/utils/keyed-throttle.js +86 -0
- package/esm/utils/keyed-throttle.js.map +1 -0
- package/esm/utils/registry-conversion.d.ts +53 -0
- package/esm/utils/registry-conversion.d.ts.map +1 -0
- package/esm/utils/registry-conversion.js +115 -0
- package/esm/utils/registry-conversion.js.map +1 -0
- package/esm/utils/send-message.d.ts +140 -0
- package/esm/utils/send-message.d.ts.map +1 -0
- package/esm/utils/send-message.js +183 -0
- package/esm/utils/send-message.js.map +1 -0
- package/esm/utils/stream-handler.d.ts +45 -0
- package/esm/utils/stream-handler.d.ts.map +1 -0
- package/esm/utils/stream-handler.js +47 -0
- package/esm/utils/stream-handler.js.map +1 -0
- package/esm/utils/thread-utils.d.ts +16 -0
- package/esm/utils/thread-utils.d.ts.map +1 -0
- package/esm/utils/thread-utils.js +34 -0
- package/esm/utils/thread-utils.js.map +1 -0
- package/esm/utils/tool-call-tracker.d.ts +74 -0
- package/esm/utils/tool-call-tracker.d.ts.map +1 -0
- package/esm/utils/tool-call-tracker.js +181 -0
- package/esm/utils/tool-call-tracker.js.map +1 -0
- package/esm/utils/tool-executor.d.ts +67 -0
- package/esm/utils/tool-executor.d.ts.map +1 -0
- package/esm/utils/tool-executor.js +160 -0
- package/esm/utils/tool-executor.js.map +1 -0
- package/esm/utils/unstrictify.d.ts +32 -0
- package/esm/utils/unstrictify.d.ts.map +1 -0
- package/esm/utils/unstrictify.js +160 -0
- package/esm/utils/unstrictify.js.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import type { ToolAnnotations as MCPToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
+
import TamboAI from "@tambo-ai/typescript-sdk";
|
|
4
|
+
import { JSONSchema7 } from "json-schema";
|
|
5
|
+
/**
|
|
6
|
+
* A schema type that accepts either a Standard Schema compliant validator
|
|
7
|
+
* (e.g., Zod, Valibot, ArkType) or a raw JSON Schema object.
|
|
8
|
+
*
|
|
9
|
+
* Standard Schema is a specification that provides a unified interface for
|
|
10
|
+
* TypeScript validation libraries. Libraries like Zod implement this spec,
|
|
11
|
+
* allowing us to accept any compliant validator without depending on a specific library.
|
|
12
|
+
* @see https://standardschema.dev/
|
|
13
|
+
*/
|
|
14
|
+
export type SupportedSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output> | JSONSchema7;
|
|
15
|
+
/**
|
|
16
|
+
* Annotations describing a tool's behavior, aligned with the MCP (Model Context Protocol)
|
|
17
|
+
* specification. These hints help clients understand how tools behave and can be used
|
|
18
|
+
* to optimize tool execution strategies.
|
|
19
|
+
* @see https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations
|
|
20
|
+
*/
|
|
21
|
+
export type ToolAnnotations = MCPToolAnnotations & {
|
|
22
|
+
/**
|
|
23
|
+
* Indicates that the tool is safe to be called repeatedly while a response is
|
|
24
|
+
* being streamed. This is typically used for read-only tools that do not
|
|
25
|
+
* cause side effects.
|
|
26
|
+
*/
|
|
27
|
+
tamboStreamableHint?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */
|
|
30
|
+
export type ParameterSpec = TamboAI.ToolParameters & {
|
|
31
|
+
schema?: JSONSchema7;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Extends the base ContextTool interface from Tambo AI to include schema information
|
|
35
|
+
* for parameter validation.
|
|
36
|
+
*/
|
|
37
|
+
export interface ComponentContextToolMetadata extends TamboAI.ComponentContextToolMetadata {
|
|
38
|
+
parameters: ParameterSpec[];
|
|
39
|
+
/**
|
|
40
|
+
* Optional per-tool call limit. When set, this overrides the project's
|
|
41
|
+
* global tool call limit for this specific tool.
|
|
42
|
+
*
|
|
43
|
+
* This is useful for tools that should only be called once or twice
|
|
44
|
+
* regardless of the project's global limit.
|
|
45
|
+
*/
|
|
46
|
+
maxCalls?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Annotations describing the tool's behavior. See {@link ToolAnnotations}.
|
|
49
|
+
*/
|
|
50
|
+
annotations?: ToolAnnotations;
|
|
51
|
+
}
|
|
52
|
+
export interface ComponentContextTool {
|
|
53
|
+
getComponentContext: (...args: any[]) => Promise<any>;
|
|
54
|
+
definition: ComponentContextToolMetadata;
|
|
55
|
+
}
|
|
56
|
+
export interface RegisteredComponent extends TamboAI.AvailableComponent {
|
|
57
|
+
component: unknown;
|
|
58
|
+
loadingComponent?: unknown;
|
|
59
|
+
}
|
|
60
|
+
export type ComponentRegistry = Record<string, RegisteredComponent>;
|
|
61
|
+
export type TamboToolRegistry = Record<string, TamboTool>;
|
|
62
|
+
/**
|
|
63
|
+
* A JSON Schema that is compatible with the MCP.
|
|
64
|
+
* This is a simplified JSON Schema that is compatible with the MCPClient and the tool's inputSchema.
|
|
65
|
+
*
|
|
66
|
+
* Do not export this type from the SDK.
|
|
67
|
+
*/
|
|
68
|
+
export type JSONSchemaLite = JSONSchema7 & {
|
|
69
|
+
description?: string;
|
|
70
|
+
};
|
|
71
|
+
type MaybeAsync<T> = T | Promise<T>;
|
|
72
|
+
/**
|
|
73
|
+
* TamboTool is a type that represents a tool that can be registered with Tambo.
|
|
74
|
+
*
|
|
75
|
+
* It is preferable to use the `defineTool` helper function to create tools, as
|
|
76
|
+
* it provides better type inference and safety.
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { TamboTool, defineTool } from "@tambo-ai/react";
|
|
80
|
+
* import { z } from "zod";
|
|
81
|
+
*
|
|
82
|
+
* const locationToLatLon = defineTool({
|
|
83
|
+
* name: "location_to_latlon",
|
|
84
|
+
* description:
|
|
85
|
+
* "Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.",
|
|
86
|
+
* tool: async ({ location }) => getLatLonFromLocation(location),
|
|
87
|
+
* inputSchema: z.object({
|
|
88
|
+
* location: z.string(),
|
|
89
|
+
* }),
|
|
90
|
+
* outputSchema: z.object({
|
|
91
|
+
* lat: z.number(),
|
|
92
|
+
* lon: z.number(),
|
|
93
|
+
* }),
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export interface TamboTool<Params = any, Returns = any, Rest extends any[] = []> {
|
|
98
|
+
/**
|
|
99
|
+
* Unique identifier for the tool
|
|
100
|
+
*/
|
|
101
|
+
name: string;
|
|
102
|
+
/**
|
|
103
|
+
* Description of what the tool does - used by AI to determine when to use it
|
|
104
|
+
*/
|
|
105
|
+
description: string;
|
|
106
|
+
/**
|
|
107
|
+
* Optional human-readable name of the tool for display purposes.
|
|
108
|
+
*/
|
|
109
|
+
title?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Optional limit for how many times this tool may be called while
|
|
112
|
+
* generating a single response. If present, this value overrides the
|
|
113
|
+
* project's global `maxToolCallLimit` for this tool.
|
|
114
|
+
* @example 1
|
|
115
|
+
*/
|
|
116
|
+
maxCalls?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Annotations describing the tool's behavior, aligned with the MCP specification.
|
|
119
|
+
* Use `tamboStreamableHint: true` to enable streaming execution of partial tool calls.
|
|
120
|
+
* @see {@link ToolAnnotations}
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const setTextTool: TamboTool<{ text: string }> = {
|
|
124
|
+
* name: "set_text",
|
|
125
|
+
* description: "Set the displayed text",
|
|
126
|
+
* annotations: {
|
|
127
|
+
* tamboStreamableHint: true, // tool is safe for streaming calls
|
|
128
|
+
* },
|
|
129
|
+
* tool: ({ text }) => setText(text),
|
|
130
|
+
* inputSchema: z.object({ text: z.string() }),
|
|
131
|
+
* outputSchema: z.void(),
|
|
132
|
+
* };
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
annotations?: ToolAnnotations;
|
|
136
|
+
/**
|
|
137
|
+
* The function that implements the tool's logic. This function will be called
|
|
138
|
+
* by Tambo when the model decides to invoke the tool.
|
|
139
|
+
* @param params - The input parameters for the tool. These are validated
|
|
140
|
+
* against the inputSchema before being passed so are guaranteed to be correct
|
|
141
|
+
* when called by the model.
|
|
142
|
+
* @returns The result of the tool execution, which can be a value or a
|
|
143
|
+
* Promise resolving to a value
|
|
144
|
+
*/
|
|
145
|
+
tool: (params: Params, ...rest: Rest) => MaybeAsync<Returns>;
|
|
146
|
+
/**
|
|
147
|
+
* The schema for the tool's input parameters. This can be a validator from
|
|
148
|
+
* any Standard Schema compliant library (Zod 3.24+, Zod 4.x) or a
|
|
149
|
+
* raw JSON Schema object.
|
|
150
|
+
*
|
|
151
|
+
* This schema is used to validate and parse the parameters before passing
|
|
152
|
+
* them to the tool function.
|
|
153
|
+
*/
|
|
154
|
+
inputSchema: SupportedSchema<Params>;
|
|
155
|
+
/**
|
|
156
|
+
* The schema for the tool's output/return value. This can be any Standard Schema
|
|
157
|
+
* compliant validator (Zod 3.24+, Zod 4.x) or a raw JSON Schema object.
|
|
158
|
+
*
|
|
159
|
+
* This is used to inform the model about the structure of the tool's return value
|
|
160
|
+
* and is not used for runtime validation at this stage.
|
|
161
|
+
*/
|
|
162
|
+
outputSchema: SupportedSchema<Returns>;
|
|
163
|
+
/**
|
|
164
|
+
* Optional function to transform the tool's return value into an array of content parts.
|
|
165
|
+
* If not provided, the return value will be converted to a string and wrapped in a text content part.
|
|
166
|
+
* @param result - The result returned by the tool function
|
|
167
|
+
* @returns An array of content parts to be sent back to the AI
|
|
168
|
+
*/
|
|
169
|
+
transformToContent?: (result: any) => Promise<TamboAI.Beta.Threads.ChatCompletionContentPart[]> | TamboAI.Beta.Threads.ChatCompletionContentPart[];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A tool that uses JSON Schema compliant input and output schemas.
|
|
173
|
+
* This does not provide type safety for the tool's parameters and return value.
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
export type TamboToolJSONSchema<Args extends unknown[] = unknown[], Returns = unknown> = Omit<TamboTool<Args, Returns>, "tool" | "inputSchema" | "outputSchema"> & {
|
|
177
|
+
tool: (...args: Args) => MaybeAsync<Returns>;
|
|
178
|
+
inputSchema: JSONSchemaLite;
|
|
179
|
+
outputSchema: JSONSchemaLite;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* A tool that could not be matched to any known schema types.
|
|
183
|
+
* This means type safety cannot be guaranteed.
|
|
184
|
+
* @internal
|
|
185
|
+
*/
|
|
186
|
+
export type TamboToolUnknown = Omit<TamboTool, "tool" | "inputSchema" | "outputSchema"> & {
|
|
187
|
+
tool: (...args: unknown[]) => MaybeAsync<unknown>;
|
|
188
|
+
inputSchema: SupportedSchema;
|
|
189
|
+
outputSchema: SupportedSchema;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* A tool that uses Standard Schema compliant input and output schemas.
|
|
193
|
+
* This provides full type safety for the tool's parameters and return value.
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
export type TamboToolStandardSchema<Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1> = Omit<TamboTool<StandardSchemaV1.InferOutput<Input>, StandardSchemaV1.InferOutput<Output>>, "tool" | "inputSchema" | "outputSchema"> & {
|
|
197
|
+
tool: (...args: [StandardSchemaV1.InferOutput<Input>]) => MaybeAsync<StandardSchemaV1.InferOutput<Output>>;
|
|
198
|
+
inputSchema: Input;
|
|
199
|
+
outputSchema: Output;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* If you're seeing this type, it means that you are using a deprecated and now
|
|
203
|
+
* unsupported schema type for defining Tambo tools.
|
|
204
|
+
*
|
|
205
|
+
* Follow the migration guide to update your tool definitions to use
|
|
206
|
+
* inputSchema and outputSchema with either Standard Schema compliant validators
|
|
207
|
+
* (like Zod 3.25.76, Zod 4.x) or raw JSON Schema objects.
|
|
208
|
+
* @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.
|
|
209
|
+
* @see {@link https://docs.tambo.co/reference/react-sdk/migration}
|
|
210
|
+
*/
|
|
211
|
+
export type UnsupportedSchemaTamboTool = Omit<TamboTool, "tool" | "inputSchema" | "outputSchema"> & {
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.
|
|
214
|
+
*/
|
|
215
|
+
toolSchema: any;
|
|
216
|
+
tool: (...args: any[]) => MaybeAsync<any>;
|
|
217
|
+
inputSchema?: never;
|
|
218
|
+
outputSchema?: never;
|
|
219
|
+
};
|
|
220
|
+
export type TamboToolAssociations = Record<string, string[]>;
|
|
221
|
+
/**
|
|
222
|
+
* A component that can be registered with the TamboRegistryProvider.
|
|
223
|
+
*/
|
|
224
|
+
export interface TamboComponent {
|
|
225
|
+
/** The name of the component */
|
|
226
|
+
name: string;
|
|
227
|
+
/** The description of the component */
|
|
228
|
+
description: string;
|
|
229
|
+
/**
|
|
230
|
+
* The component to render.
|
|
231
|
+
*
|
|
232
|
+
* In the React SDK, this should be a React ComponentType.
|
|
233
|
+
* In the client package, this is typed as `unknown` since it is framework-agnostic.
|
|
234
|
+
*/
|
|
235
|
+
component: unknown;
|
|
236
|
+
/**
|
|
237
|
+
* Schema describing the component's props. Accepts any Standard Schema
|
|
238
|
+
* compliant validator (Zod, Valibot, ArkType, etc.) or a raw JSON Schema
|
|
239
|
+
* object.
|
|
240
|
+
*
|
|
241
|
+
* Either this or propsDefinition must be provided, but not both.
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* import { z } from "zod/v4";
|
|
245
|
+
*
|
|
246
|
+
* const component: TamboComponent = {
|
|
247
|
+
* name: "MyComponent",
|
|
248
|
+
* description: "A sample component",
|
|
249
|
+
* component: MyComponent,
|
|
250
|
+
* propsSchema: z.object({
|
|
251
|
+
* title: z.string(),
|
|
252
|
+
* count: z.number().optional()
|
|
253
|
+
* })
|
|
254
|
+
* };
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
propsSchema?: SupportedSchema;
|
|
258
|
+
/**
|
|
259
|
+
* The props definition of the component as a JSON object.
|
|
260
|
+
* Either this or propsSchema must be provided, but not both.
|
|
261
|
+
* @deprecated Use propsSchema instead.
|
|
262
|
+
*/
|
|
263
|
+
propsDefinition?: any;
|
|
264
|
+
/** The loading component to render while the component is loading */
|
|
265
|
+
loadingComponent?: unknown;
|
|
266
|
+
/** The tools that are associated with the component */
|
|
267
|
+
associatedTools?: TamboTool[];
|
|
268
|
+
/** Annotations describing the component's behavior. */
|
|
269
|
+
annotations?: ToolAnnotations;
|
|
270
|
+
}
|
|
271
|
+
type OptionalSchemaProps<T> = Omit<T, "inputSchema" | "outputSchema"> & {
|
|
272
|
+
inputSchema?: T extends {
|
|
273
|
+
inputSchema: infer I;
|
|
274
|
+
} ? I : never;
|
|
275
|
+
outputSchema?: T extends {
|
|
276
|
+
outputSchema: infer O;
|
|
277
|
+
} ? O : never;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Registers one or more Tambo tools.
|
|
281
|
+
* @param tools - An array of Tambo tools to register
|
|
282
|
+
* @param warnOnOverwrite - Whether to warn if any tool is being overwritten
|
|
283
|
+
*/
|
|
284
|
+
export interface RegisterToolsFn {
|
|
285
|
+
/**
|
|
286
|
+
* @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update
|
|
287
|
+
* your tool definitions to use `inputSchema` and `outputSchema` instead.
|
|
288
|
+
*/
|
|
289
|
+
(tools: UnsupportedSchemaTamboTool[], warnOnOverwrite?: boolean): void;
|
|
290
|
+
/**
|
|
291
|
+
* Register one or more Tambo tools. For better type inference, consider registering tools individually using the
|
|
292
|
+
* `registerTool` function or use the `defineTool` helper when defining your tools.
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* import { defineTool } from "@tambo-ai/react";
|
|
296
|
+
* const tools = [
|
|
297
|
+
* defineTool({...});
|
|
298
|
+
* defineTool({...});
|
|
299
|
+
* ];
|
|
300
|
+
* registerTools(tools);
|
|
301
|
+
* @param tools - An array of Tambo tools to register
|
|
302
|
+
* @param warnOnOverwrite - Whether to warn if any tool is being overwritten
|
|
303
|
+
*/
|
|
304
|
+
(tools: TamboTool[], warnOnOverwrite?: boolean): void;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Function interface for registering a Tambo tool with full type inference.
|
|
308
|
+
* This function has multiple overloads to handle different schema types. This
|
|
309
|
+
* is a utility function and does not perform any runtime logic.
|
|
310
|
+
*/
|
|
311
|
+
export interface RegisterToolFn {
|
|
312
|
+
<Args extends StandardSchemaV1, Returns extends StandardSchemaV1>(tool: TamboToolStandardSchema<Args, Returns>, warnOnOverwrite?: boolean): void;
|
|
313
|
+
<Args extends any[], Returns = any>(tool: TamboToolJSONSchema<Args, Returns>, warnOnOverwrite?: boolean): void;
|
|
314
|
+
(tool: TamboToolUnknown, warnOnOverwrite?: boolean): void;
|
|
315
|
+
(tool: TamboTool, warnOnOverwrite?: boolean): void;
|
|
316
|
+
/**
|
|
317
|
+
* @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update
|
|
318
|
+
* your tool definitions to use `inputSchema` and `outputSchema` instead.
|
|
319
|
+
* @param tool - The unsupported schema Tambo tool to register
|
|
320
|
+
* @param warnOnOverwrite - Whether to warn if the tool is being overwritten
|
|
321
|
+
*/
|
|
322
|
+
(tool: UnsupportedSchemaTamboTool, warnOnOverwrite?: boolean): void;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Function interface for defining a Tambo tool with full type inference. This function has multiple overloads to handle
|
|
326
|
+
* different schema types. This is a utility function and does not perform any runtime logic.
|
|
327
|
+
*/
|
|
328
|
+
export interface DefineToolFn {
|
|
329
|
+
/**
|
|
330
|
+
* @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update
|
|
331
|
+
* your tool definitions to use `inputSchema` and `outputSchema` instead.
|
|
332
|
+
* @param tool The tool definition to register
|
|
333
|
+
* @returns The registered tool definition
|
|
334
|
+
*/
|
|
335
|
+
(tool: UnsupportedSchemaTamboTool): typeof tool;
|
|
336
|
+
/**
|
|
337
|
+
* Provides type safety for defining a Tambo Tool.
|
|
338
|
+
*
|
|
339
|
+
* Tambo uses the [standard-schema.dev](https://standard-schema.dev) spec which means you can use any Standard Schema
|
|
340
|
+
* compliant validator (Zod 3.24+, Zod 4.x). This definition ensures the input and output types are correctly
|
|
341
|
+
* inferred from the provided schemas.
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* import { z } from "zod/v4";
|
|
345
|
+
*
|
|
346
|
+
* const myTool = defineTool({
|
|
347
|
+
* name: "myTool",
|
|
348
|
+
* description: "An example tool",
|
|
349
|
+
* inputSchema: z.object({
|
|
350
|
+
* input: z.string().describe("Input description")
|
|
351
|
+
* }),
|
|
352
|
+
* outputSchema: z.number().describe("Result description"),
|
|
353
|
+
* tool: ({ input }) => input.length,
|
|
354
|
+
* });
|
|
355
|
+
* ```
|
|
356
|
+
* @see {@link https://standard-schema.dev/}
|
|
357
|
+
* @param tool The tool definition to register
|
|
358
|
+
* @returns The registered tool definition
|
|
359
|
+
*/
|
|
360
|
+
<Input extends StandardSchemaV1, Output extends StandardSchemaV1>(tool: OptionalSchemaProps<TamboToolStandardSchema<Input, Output>>): TamboToolStandardSchema<Input, Output>;
|
|
361
|
+
/**
|
|
362
|
+
* Provides type safety for defining a Tambo Tool with JSON Schema input and output.
|
|
363
|
+
*
|
|
364
|
+
* This overload is used when providing raw JSON Schema objects instead of StandardSchema validators.
|
|
365
|
+
* Type inference is limited when using raw JSON Schema.
|
|
366
|
+
* @see {@link https://standard-schema.dev/}
|
|
367
|
+
* @param tool The tool definition to register
|
|
368
|
+
* @returns The registered tool definition
|
|
369
|
+
*/
|
|
370
|
+
<I extends any[], O = any>(tool: OptionalSchemaProps<TamboToolJSONSchema<I, O>>): TamboToolJSONSchema<I, O>;
|
|
371
|
+
/**
|
|
372
|
+
* Provides type safety for defining a Tambo Tool.
|
|
373
|
+
*
|
|
374
|
+
* This overload is used when the schema types could not be matched to known types.
|
|
375
|
+
* Type safety cannot be guaranteed.
|
|
376
|
+
* @param tool The tool definition to register
|
|
377
|
+
* @returns The registered tool definition
|
|
378
|
+
*/
|
|
379
|
+
(tool: OptionalSchemaProps<TamboToolUnknown>): TamboToolUnknown;
|
|
380
|
+
/**
|
|
381
|
+
* Provides type safety for defining a Tambo Tool.
|
|
382
|
+
*
|
|
383
|
+
* This overload is used when providing a fully defined TamboTool.
|
|
384
|
+
* @param tool The tool definition to register
|
|
385
|
+
* @returns The registered tool definition
|
|
386
|
+
*/
|
|
387
|
+
(tool: OptionalSchemaProps<TamboTool>): TamboTool;
|
|
388
|
+
}
|
|
389
|
+
export {};
|
|
390
|
+
//# sourceMappingURL=component-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-metadata.d.ts","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,IACvD,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,GAC/B,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG;IACjD;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,+FAA+F;AAC/F,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,cAAc,GAAG;IACnD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,4BACf,SAAQ,OAAO,CAAC,4BAA4B;IAC5C,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,mBAAmB,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACtD,UAAU,EAAE,4BAA4B,CAAC;CAC1C;AAED,MAAM,WAAW,mBAAoB,SAAQ,OAAO,CAAC,kBAAkB;IACrE,SAAS,EAAE,OAAO,CAAC;IACnB,gBA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,IAAI,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACnD,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B;;;;;;;OAOG;IACH,CAAC,IAAI,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;IAChE;;;;;;OAMG;IACH,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;CACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import type { ToolAnnotations as MCPToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { JSONSchema7 } from \"json-schema\";\n\n/**\n * A schema type that accepts either a Standard Schema compliant validator\n * (e.g., Zod, Valibot, ArkType) or a raw JSON Schema object.\n *\n * Standard Schema is a specification that provides a unified interface for\n * TypeScript validation libraries. Libraries like Zod implement this spec,\n * allowing us to accept any compliant validator without depending on a specific library.\n * @see https://standardschema.dev/\n */\nexport type SupportedSchema<Input = unknown, Output = Input> =\n | StandardSchemaV1<Input, Output>\n | JSONSchema7;\n\n/**\n * Annotations describing a tool's behavior, aligned with the MCP (Model Context Protocol)\n * specification. These hints help clients understand how tools behave and can be used\n * to optimize tool execution strategies.\n * @see https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations\n */\nexport type ToolAnnotations = MCPToolAnnotations & {\n /**\n * Indicates that the tool is safe to be called repeatedly while a response is\n * being streamed. This is typically used for read-only tools that do not\n * cause side effects.\n */\n tamboStreamableHint?: boolean;\n};\n\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: JSONSchema7;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n /**\n * Optional per-tool call limit. When set, this overrides the project's\n * global tool call limit for this specific tool.\n *\n * This is useful for tools that should only be called once or twice\n * regardless of the project's global limit.\n */\n maxCalls?: number;\n /**\n * Annotations describing the tool's behavior. See {@link ToolAnnotations}.\n */\n annotations?: ToolAnnotations;\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: unknown;\n loadingComponent?: unknown;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<string, TamboTool>;\n\n/**\n * A JSON Schema that is compatible with the MCP.\n * This is a simplified JSON Schema that is compatible with the MCPClient and the tool's inputSchema.\n *\n * Do not export this type from the SDK.\n */\nexport type JSONSchemaLite = JSONSchema7 & {\n description?: string;\n};\n\ntype MaybeAsync<T> = T | Promise<T>;\n\n/**\n * TamboTool is a type that represents a tool that can be registered with Tambo.\n *\n * It is preferable to use the `defineTool` helper function to create tools, as\n * it provides better type inference and safety.\n * @example\n * ```ts\n * import { TamboTool, defineTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon = defineTool({\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n */\nexport interface TamboTool<\n Params = any,\n Returns = any,\n Rest extends any[] = [],\n> {\n /**\n * Unique identifier for the tool\n */\n name: string;\n /**\n * Description of what the tool does - used by AI to determine when to use it\n */\n description: string;\n /**\n * Optional human-readable name of the tool for display purposes.\n */\n title?: string;\n /**\n * Optional limit for how many times this tool may be called while\n * generating a single response. If present, this value overrides the\n * project's global `maxToolCallLimit` for this tool.\n * @example 1\n */\n maxCalls?: number;\n /**\n * Annotations describing the tool's behavior, aligned with the MCP specification.\n * Use `tamboStreamableHint: true` to enable streaming execution of partial tool calls.\n * @see {@link ToolAnnotations}\n * @example\n * ```ts\n * const setTextTool: TamboTool<{ text: string }> = {\n * name: \"set_text\",\n * description: \"Set the displayed text\",\n * annotations: {\n * tamboStreamableHint: true, // tool is safe for streaming calls\n * },\n * tool: ({ text }) => setText(text),\n * inputSchema: z.object({ text: z.string() }),\n * outputSchema: z.void(),\n * };\n * ```\n */\n annotations?: ToolAnnotations;\n\n /**\n * The function that implements the tool's logic. This function will be called\n * by Tambo when the model decides to invoke the tool.\n * @param params - The input parameters for the tool. These are validated\n * against the inputSchema before being passed so are guaranteed to be correct\n * when called by the model.\n * @returns The result of the tool execution, which can be a value or a\n * Promise resolving to a value\n */\n tool: (params: Params, ...rest: Rest) => MaybeAsync<Returns>;\n\n /**\n * The schema for the tool's input parameters. This can be a validator from\n * any Standard Schema compliant library (Zod 3.24+, Zod 4.x) or a\n * raw JSON Schema object.\n *\n * This schema is used to validate and parse the parameters before passing\n * them to the tool function.\n */\n inputSchema: SupportedSchema<Params>;\n\n /**\n * The schema for the tool's output/return value. This can be any Standard Schema\n * compliant validator (Zod 3.24+, Zod 4.x) or a raw JSON Schema object.\n *\n * This is used to inform the model about the structure of the tool's return value\n * and is not used for runtime validation at this stage.\n */\n outputSchema: SupportedSchema<Returns>;\n\n /**\n * Optional function to transform the tool's return value into an array of content parts.\n * If not provided, the return value will be converted to a string and wrapped in a text content part.\n * @param result - The result returned by the tool function\n * @returns An array of content parts to be sent back to the AI\n */\n transformToContent?: (\n result: any,\n ) =>\n | Promise<TamboAI.Beta.Threads.ChatCompletionContentPart[]>\n | TamboAI.Beta.Threads.ChatCompletionContentPart[];\n}\n\n/**\n * A tool that uses JSON Schema compliant input and output schemas.\n * This does not provide type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolJSONSchema<\n Args extends unknown[] = unknown[],\n Returns = unknown,\n> = Omit<TamboTool<Args, Returns>, \"tool\" | \"inputSchema\" | \"outputSchema\"> & {\n tool: (...args: Args) => MaybeAsync<Returns>;\n inputSchema: JSONSchemaLite;\n outputSchema: JSONSchemaLite;\n};\n\n/**\n * A tool that could not be matched to any known schema types.\n * This means type safety cannot be guaranteed.\n * @internal\n */\nexport type TamboToolUnknown = Omit<\n TamboTool,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (...args: unknown[]) => MaybeAsync<unknown>;\n inputSchema: SupportedSchema;\n outputSchema: SupportedSchema;\n};\n\n/**\n * A tool that uses Standard Schema compliant input and output schemas.\n * This provides full type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolStandardSchema<\n Input extends StandardSchemaV1 = StandardSchemaV1,\n Output extends StandardSchemaV1 = StandardSchemaV1,\n> = Omit<\n TamboTool<\n StandardSchemaV1.InferOutput<Input>,\n StandardSchemaV1.InferOutput<Output>\n >,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (\n ...args: [StandardSchemaV1.InferOutput<Input>]\n ) => MaybeAsync<StandardSchemaV1.InferOutput<Output>>;\n inputSchema: Input;\n outputSchema: Output;\n};\n\n/**\n * If you're seeing this type, it means that you are using a deprecated and now\n * unsupported schema type for defining Tambo tools.\n *\n * Follow the migration guide to update your tool definitions to use\n * inputSchema and outputSchema with either Standard Schema compliant validators\n * (like Zod 3.25.76, Zod 4.x) or raw JSON Schema objects.\n * @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.\n * @see {@link https://docs.tambo.co/reference/react-sdk/migration}\n */\nexport type UnsupportedSchemaTamboTool = Omit<\n TamboTool,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n /**\n * @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.\n */\n toolSchema: any;\n tool: (...args: any[]) => MaybeAsync<any>;\n inputSchema?: never;\n outputSchema?: never;\n};\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /**\n * The component to render.\n *\n * In the React SDK, this should be a React ComponentType.\n * In the client package, this is typed as `unknown` since it is framework-agnostic.\n */\n component: unknown;\n\n /**\n * Schema describing the component's props. Accepts any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.) or a raw JSON Schema\n * object.\n *\n * Either this or propsDefinition must be provided, but not both.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const component: TamboComponent = {\n * name: \"MyComponent\",\n * description: \"A sample component\",\n * component: MyComponent,\n * propsSchema: z.object({\n * title: z.string(),\n * count: z.number().optional()\n * })\n * };\n * ```\n */\n propsSchema?: SupportedSchema;\n /**\n * The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n * @deprecated Use propsSchema instead.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: unknown;\n /** The tools that are associated with the component */\n associatedTools?: TamboTool[];\n /** Annotations describing the component's behavior. */\n annotations?: ToolAnnotations;\n}\n\ntype OptionalSchemaProps<T> = Omit<T, \"inputSchema\" | \"outputSchema\"> & {\n inputSchema?: T extends { inputSchema: infer I } ? I : never;\n outputSchema?: T extends { outputSchema: infer O } ? O : never;\n};\n\n/**\n * Registers one or more Tambo tools.\n * @param tools - An array of Tambo tools to register\n * @param warnOnOverwrite - Whether to warn if any tool is being overwritten\n */\nexport interface RegisterToolsFn {\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n */\n (tools: UnsupportedSchemaTamboTool[], warnOnOverwrite?: boolean): void;\n /**\n * Register one or more Tambo tools. For better type inference, consider registering tools individually using the\n * `registerTool` function or use the `defineTool` helper when defining your tools.\n * @example\n * ```typescript\n * import { defineTool } from \"@tambo-ai/react\";\n * const tools = [\n * defineTool({...});\n * defineTool({...});\n * ];\n * registerTools(tools);\n * @param tools - An array of Tambo tools to register\n * @param warnOnOverwrite - Whether to warn if any tool is being overwritten\n */\n (tools: TamboTool[], warnOnOverwrite?: boolean): void;\n}\n\n/**\n * Function interface for registering a Tambo tool with full type inference.\n * This function has multiple overloads to handle different schema types. This\n * is a utility function and does not perform any runtime logic.\n */\nexport interface RegisterToolFn {\n <Args extends StandardSchemaV1, Returns extends StandardSchemaV1>(\n tool: TamboToolStandardSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n <Args extends any[], Returns = any>(\n tool: TamboToolJSONSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n (tool: TamboToolUnknown, warnOnOverwrite?: boolean): void;\n (tool: TamboTool, warnOnOverwrite?: boolean): void;\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n * @param tool - The unsupported schema Tambo tool to register\n * @param warnOnOverwrite - Whether to warn if the tool is being overwritten\n */\n (tool: UnsupportedSchemaTamboTool, warnOnOverwrite?: boolean): void;\n}\n\n/**\n * Function interface for defining a Tambo tool with full type inference. This function has multiple overloads to handle\n * different schema types. This is a utility function and does not perform any runtime logic.\n */\nexport interface DefineToolFn {\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: UnsupportedSchemaTamboTool): typeof tool;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * Tambo uses the [standard-schema.dev](https://standard-schema.dev) spec which means you can use any Standard Schema\n * compliant validator (Zod 3.24+, Zod 4.x). This definition ensures the input and output types are correctly\n * inferred from the provided schemas.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTool({\n * name: \"myTool\",\n * description: \"An example tool\",\n * inputSchema: z.object({\n * input: z.string().describe(\"Input description\")\n * }),\n * outputSchema: z.number().describe(\"Result description\"),\n * tool: ({ input }) => input.length,\n * });\n * ```\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <Input extends StandardSchemaV1, Output extends StandardSchemaV1>(\n tool: OptionalSchemaProps<TamboToolStandardSchema<Input, Output>>,\n ): TamboToolStandardSchema<Input, Output>;\n /**\n * Provides type safety for defining a Tambo Tool with JSON Schema input and output.\n *\n * This overload is used when providing raw JSON Schema objects instead of StandardSchema validators.\n * Type inference is limited when using raw JSON Schema.\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <I extends any[], O = any>(\n tool: OptionalSchemaProps<TamboToolJSONSchema<I, O>>,\n ): TamboToolJSONSchema<I, O>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This overload is used when the schema types could not be matched to known types.\n * Type safety cannot be guaranteed.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: OptionalSchemaProps<TamboToolUnknown>): TamboToolUnknown;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This overload is used when providing a fully defined TamboTool.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: OptionalSchemaProps<TamboTool>): TamboTool;\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { MCPHandlers } from "../mcp";
|
|
2
|
+
/**
|
|
3
|
+
* The transport protocol to use for MCP connections.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum MCPTransport {
|
|
6
|
+
SSE = "sse",
|
|
7
|
+
HTTP = "http"
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* User-provided configuration for an MCP server.
|
|
11
|
+
*
|
|
12
|
+
* This is the type accepted by `TamboProvider` / `TamboRegistryProvider` in
|
|
13
|
+
* the `mcpServers` prop.
|
|
14
|
+
*
|
|
15
|
+
* The `handlers` field is typed as `Partial<MCPHandlers>` (with
|
|
16
|
+
* `elicitation` / `sampling` callbacks). The `@modelcontextprotocol/sdk` is
|
|
17
|
+
* included automatically with `@tambo-ai/react`. See the React SDK README for
|
|
18
|
+
* any additional optional peer dependencies needed for MCP features.
|
|
19
|
+
*/
|
|
20
|
+
export interface McpServerInfo {
|
|
21
|
+
/** Optional name for the MCP server */
|
|
22
|
+
name?: string;
|
|
23
|
+
/** The URL of the MCP server to connect to */
|
|
24
|
+
url: string;
|
|
25
|
+
/** Optional description of the MCP server */
|
|
26
|
+
description?: string;
|
|
27
|
+
/** The transport type to use (SSE or HTTP). Defaults to HTTP for string URLs */
|
|
28
|
+
transport?: MCPTransport;
|
|
29
|
+
/** Optional custom headers to include in requests */
|
|
30
|
+
customHeaders?: Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Optional short name for namespacing MCP resources, prompts, and tools.
|
|
33
|
+
* When multiple MCP servers are configured, this key is used to prefix:
|
|
34
|
+
* - prompts: `<serverKey>:<promptName>`
|
|
35
|
+
* - resources: `<serverKey>:<resourceUrl>`
|
|
36
|
+
* - tools: `<serverKey>__<toolName>`
|
|
37
|
+
*
|
|
38
|
+
* If not provided, a key will be derived from the URL hostname.
|
|
39
|
+
* For example, "https://mcp.linear.app/mcp" becomes "linear".
|
|
40
|
+
*/
|
|
41
|
+
serverKey?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional handlers for elicitation and sampling requests from the server.
|
|
44
|
+
*
|
|
45
|
+
* Note: These callbacks should be stable (e.g., wrapped in useCallback or
|
|
46
|
+
* defined outside the component) to avoid constant re-registration of the
|
|
47
|
+
* MCP server on every render.
|
|
48
|
+
*/
|
|
49
|
+
handlers?: Partial<MCPHandlers>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Normalized MCP server metadata used internally by the registry and MCP
|
|
53
|
+
* provider.
|
|
54
|
+
*
|
|
55
|
+
* This is equivalent to `McpServerInfo` except that:
|
|
56
|
+
* - `serverKey` is guaranteed to be present
|
|
57
|
+
* - `transport` is resolved to a concrete value (defaults to HTTP)
|
|
58
|
+
*/
|
|
59
|
+
export interface NormalizedMcpServerInfo extends McpServerInfo {
|
|
60
|
+
transport: MCPTransport;
|
|
61
|
+
serverKey: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates a stable identifier for an MCP server based on its connection properties.
|
|
65
|
+
* Two servers with the same URL, transport, and headers will have the same key.
|
|
66
|
+
*
|
|
67
|
+
* This is used by both the registry and MCP provider to deduplicate servers,
|
|
68
|
+
* so it lives alongside the shared server metadata type.
|
|
69
|
+
* @returns A stable string key identifying the server
|
|
70
|
+
*/
|
|
71
|
+
export declare function getMcpServerUniqueKey(serverInfo: Pick<McpServerInfo, "url" | "transport" | "customHeaders">): string;
|
|
72
|
+
//# sourceMappingURL=mcp-server-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server-info.d.ts","sourceRoot":"","sources":["../../src/model/mcp-server-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAwB,SAAQ,aAAa;IAC5D,SAAS,EAAE,YAAY,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,WAAW,GAAG,eAAe,CAAC,GACrE,MAAM,CAUR"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCPTransport = void 0;
|
|
4
|
+
exports.getMcpServerUniqueKey = getMcpServerUniqueKey;
|
|
5
|
+
/**
|
|
6
|
+
* The transport protocol to use for MCP connections.
|
|
7
|
+
*/
|
|
8
|
+
var MCPTransport;
|
|
9
|
+
(function (MCPTransport) {
|
|
10
|
+
MCPTransport["SSE"] = "sse";
|
|
11
|
+
MCPTransport["HTTP"] = "http";
|
|
12
|
+
})(MCPTransport || (exports.MCPTransport = MCPTransport = {}));
|
|
13
|
+
/**
|
|
14
|
+
* Creates a stable identifier for an MCP server based on its connection properties.
|
|
15
|
+
* Two servers with the same URL, transport, and headers will have the same key.
|
|
16
|
+
*
|
|
17
|
+
* This is used by both the registry and MCP provider to deduplicate servers,
|
|
18
|
+
* so it lives alongside the shared server metadata type.
|
|
19
|
+
* @returns A stable string key identifying the server
|
|
20
|
+
*/
|
|
21
|
+
function getMcpServerUniqueKey(serverInfo) {
|
|
22
|
+
const headerStr = serverInfo.customHeaders
|
|
23
|
+
? JSON.stringify(Object.entries(serverInfo.customHeaders)
|
|
24
|
+
.map(([k, v]) => [k.toLowerCase(), v])
|
|
25
|
+
.sort(([a], [b]) => a.localeCompare(b)))
|
|
26
|
+
: "";
|
|
27
|
+
return `${serverInfo.url}|${serverInfo.transport ?? MCPTransport.HTTP}|${headerStr}`;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=mcp-server-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server-info.js","sourceRoot":"","sources":["../../src/model/mcp-server-info.ts"],"names":[],"mappings":";;;AA0EA,sDAYC;AApFD;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AA0DD;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,UAAsE;IAEtE,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa;QACxC,CAAC,CAAC,IAAI,CAAC,SAAS,CACZ,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAU,CAAC;aAC9C,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAC1C;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,GAAG,UAAU,CAAC,GAAG,IAAI,UAAU,CAAC,SAAS,IAAI,YAAY,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC;AACvF,CAAC","sourcesContent":["import { MCPHandlers } from \"../mcp\";\n\n/**\n * The transport protocol to use for MCP connections.\n */\nexport enum MCPTransport {\n SSE = \"sse\",\n HTTP = \"http\",\n}\n\n/**\n * User-provided configuration for an MCP server.\n *\n * This is the type accepted by `TamboProvider` / `TamboRegistryProvider` in\n * the `mcpServers` prop.\n *\n * The `handlers` field is typed as `Partial<MCPHandlers>` (with\n * `elicitation` / `sampling` callbacks). The `@modelcontextprotocol/sdk` is\n * included automatically with `@tambo-ai/react`. See the React SDK README for\n * any additional optional peer dependencies needed for MCP features.\n */\nexport interface McpServerInfo {\n /** Optional name for the MCP server */\n name?: string;\n /** The URL of the MCP server to connect to */\n url: string;\n /** Optional description of the MCP server */\n description?: string;\n /** The transport type to use (SSE or HTTP). Defaults to HTTP for string URLs */\n transport?: MCPTransport;\n /** Optional custom headers to include in requests */\n customHeaders?: Record<string, string>;\n /**\n * Optional short name for namespacing MCP resources, prompts, and tools.\n * When multiple MCP servers are configured, this key is used to prefix:\n * - prompts: `<serverKey>:<promptName>`\n * - resources: `<serverKey>:<resourceUrl>`\n * - tools: `<serverKey>__<toolName>`\n *\n * If not provided, a key will be derived from the URL hostname.\n * For example, \"https://mcp.linear.app/mcp\" becomes \"linear\".\n */\n serverKey?: string;\n /**\n * Optional handlers for elicitation and sampling requests from the server.\n *\n * Note: These callbacks should be stable (e.g., wrapped in useCallback or\n * defined outside the component) to avoid constant re-registration of the\n * MCP server on every render.\n */\n handlers?: Partial<MCPHandlers>;\n}\n\n/**\n * Normalized MCP server metadata used internally by the registry and MCP\n * provider.\n *\n * This is equivalent to `McpServerInfo` except that:\n * - `serverKey` is guaranteed to be present\n * - `transport` is resolved to a concrete value (defaults to HTTP)\n */\nexport interface NormalizedMcpServerInfo extends McpServerInfo {\n transport: MCPTransport;\n serverKey: string;\n}\n\n/**\n * Creates a stable identifier for an MCP server based on its connection properties.\n * Two servers with the same URL, transport, and headers will have the same key.\n *\n * This is used by both the registry and MCP provider to deduplicate servers,\n * so it lives alongside the shared server metadata type.\n * @returns A stable string key identifying the server\n */\nexport function getMcpServerUniqueKey(\n serverInfo: Pick<McpServerInfo, \"url\" | \"transport\" | \"customHeaders\">,\n): string {\n const headerStr = serverInfo.customHeaders\n ? JSON.stringify(\n Object.entries(serverInfo.customHeaders)\n .map(([k, v]) => [k.toLowerCase(), v] as const)\n .sort(([a], [b]) => a.localeCompare(b)),\n )\n : \"\";\n\n return `${serverInfo.url}|${serverInfo.transport ?? MCPTransport.HTTP}|${headerStr}`;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { looksLikeJSONSchema, makeJsonSchemaPartial } from "./json-schema";
|
|
2
|
+
export { getParametersFromToolSchema, safeSchemaToJsonSchema, schemaToJsonSchema, type SupportedSchema, } from "./schema";
|
|
3
|
+
export { isStandardSchema } from "./standard-schema";
|
|
4
|
+
export { assertNoRecordSchema } from "./validate";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertNoRecordSchema = exports.isStandardSchema = exports.schemaToJsonSchema = exports.safeSchemaToJsonSchema = exports.getParametersFromToolSchema = exports.makeJsonSchemaPartial = exports.looksLikeJSONSchema = void 0;
|
|
4
|
+
var json_schema_1 = require("./json-schema");
|
|
5
|
+
Object.defineProperty(exports, "looksLikeJSONSchema", { enumerable: true, get: function () { return json_schema_1.looksLikeJSONSchema; } });
|
|
6
|
+
Object.defineProperty(exports, "makeJsonSchemaPartial", { enumerable: true, get: function () { return json_schema_1.makeJsonSchemaPartial; } });
|
|
7
|
+
var schema_1 = require("./schema");
|
|
8
|
+
Object.defineProperty(exports, "getParametersFromToolSchema", { enumerable: true, get: function () { return schema_1.getParametersFromToolSchema; } });
|
|
9
|
+
Object.defineProperty(exports, "safeSchemaToJsonSchema", { enumerable: true, get: function () { return schema_1.safeSchemaToJsonSchema; } });
|
|
10
|
+
Object.defineProperty(exports, "schemaToJsonSchema", { enumerable: true, get: function () { return schema_1.schemaToJsonSchema; } });
|
|
11
|
+
var standard_schema_1 = require("./standard-schema");
|
|
12
|
+
Object.defineProperty(exports, "isStandardSchema", { enumerable: true, get: function () { return standard_schema_1.isStandardSchema; } });
|
|
13
|
+
var validate_1 = require("./validate");
|
|
14
|
+
Object.defineProperty(exports, "assertNoRecordSchema", { enumerable: true, get: function () { return validate_1.assertNoRecordSchema; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":";;;AAAA,6CAA2E;AAAlE,kHAAA,mBAAmB,OAAA;AAAE,oHAAA,qBAAqB,OAAA;AACnD,mCAKkB;AAJhB,qHAAA,2BAA2B,OAAA;AAC3B,gHAAA,sBAAsB,OAAA;AACtB,4GAAA,kBAAkB,OAAA;AAGpB,qDAAqD;AAA5C,mHAAA,gBAAgB,OAAA;AACzB,uCAAkD;AAAzC,gHAAA,oBAAoB,OAAA","sourcesContent":["export { looksLikeJSONSchema, makeJsonSchemaPartial } from \"./json-schema\";\nexport {\n getParametersFromToolSchema,\n safeSchemaToJsonSchema,\n schemaToJsonSchema,\n type SupportedSchema,\n} from \"./schema\";\nexport { isStandardSchema } from \"./standard-schema\";\nexport { assertNoRecordSchema } from \"./validate\";\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { JSONSchema7 } from "json-schema";
|
|
2
|
+
/**
|
|
3
|
+
* Basic heuristic to check if an object looks like a JSON Schema at the top level.
|
|
4
|
+
*
|
|
5
|
+
* This uses a Zod schema to verify only top-level keys (type, properties, items,
|
|
6
|
+
* etc.). It intentionally does not perform full JSON Schema validation; a more
|
|
7
|
+
* thorough check should be done server-side.
|
|
8
|
+
* @param obj - The value to check
|
|
9
|
+
* @returns True if the value appears to be a JSON Schema
|
|
10
|
+
*/
|
|
11
|
+
export declare function looksLikeJSONSchema(obj: unknown): obj is JSONSchema7;
|
|
12
|
+
/**
|
|
13
|
+
* Extended JSON Schema type that includes draft 2020-12 features like prefixItems.
|
|
14
|
+
* The json-schema package types are from draft-07 and don't include prefixItems.
|
|
15
|
+
*/
|
|
16
|
+
export type JSONSchema7Extended = JSONSchema7 & {
|
|
17
|
+
prefixItems?: JSONSchema7[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a JSON Schema represents a tuple (array with positional items).
|
|
21
|
+
* Supports both draft-07 (items as array) and draft 2020-12 (prefixItems).
|
|
22
|
+
* @param schema - The JSON Schema to check
|
|
23
|
+
* @returns True if the schema represents a tuple
|
|
24
|
+
*/
|
|
25
|
+
export declare function isJsonSchemaTuple(schema: JSONSchema7Extended): schema is JSONSchema7Extended & {
|
|
26
|
+
type: "array";
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Gets the tuple items from a JSON Schema.
|
|
30
|
+
* Supports both draft-07 (items as array) and draft 2020-12 (prefixItems).
|
|
31
|
+
* @param schema - The JSON Schema tuple
|
|
32
|
+
* @returns Array of item schemas, or undefined if not a tuple
|
|
33
|
+
*/
|
|
34
|
+
export declare function getJsonSchemaTupleItems(schema: JSONSchema7Extended): JSONSchema7[] | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a partial version of a JSON Schema by removing required constraints.
|
|
37
|
+
* This allows LLM to provide only the properties it wants to update.
|
|
38
|
+
* @param schema - The JSON Schema to make partial
|
|
39
|
+
* @returns A new JSON Schema with the required constraint removed
|
|
40
|
+
*/
|
|
41
|
+
export declare function makeJsonSchemaPartial(schema: JSONSchema7): JSONSchema7;
|
|
42
|
+
//# sourceMappingURL=json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/schema/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkD1C;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAMpE;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,mBAAmB,GAC1B,MAAM,IAAI,mBAAmB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAgBnD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,GAC1B,WAAW,EAAE,GAAG,SAAS,CAgB3B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAGtE"}
|