@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Fractal Dynamics Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @tambo-ai/client
|
|
2
|
+
|
|
3
|
+
Framework-agnostic client for [Tambo AI](https://tambo.co). Provides streaming, tool execution, and thread management without React dependencies.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @tambo-ai/client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { TamboClient } from "@tambo-ai/client";
|
|
15
|
+
|
|
16
|
+
const client = new TamboClient({ apiKey: "your-api-key" });
|
|
17
|
+
|
|
18
|
+
// Send a message and await the final thread state
|
|
19
|
+
const stream = client.run("Hello!");
|
|
20
|
+
const thread = await stream.thread;
|
|
21
|
+
console.log(thread.messages);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Streaming with async iteration
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const stream = client.run("What is 2 + 2?");
|
|
30
|
+
|
|
31
|
+
for await (const { event, snapshot } of stream) {
|
|
32
|
+
console.log(event.type, snapshot.messages.length);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Thread management
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
// Start a new thread
|
|
40
|
+
const threadId = client.startNewThread();
|
|
41
|
+
|
|
42
|
+
// Switch to an existing thread
|
|
43
|
+
await client.switchThread("thread_abc123");
|
|
44
|
+
|
|
45
|
+
// List all threads
|
|
46
|
+
const threads = await client.listThreads();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Tool registration
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
client.registerTool({
|
|
53
|
+
name: "get_weather",
|
|
54
|
+
description: "Get the current weather for a location",
|
|
55
|
+
tool: async ({ location }) => {
|
|
56
|
+
return { temp: 72, condition: "sunny" };
|
|
57
|
+
},
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: {
|
|
61
|
+
location: { type: "string" },
|
|
62
|
+
},
|
|
63
|
+
required: ["location"],
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### React integration
|
|
69
|
+
|
|
70
|
+
For React applications, use `@tambo-ai/react` which wraps this package with hooks and providers:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
npm install @tambo-ai/react
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See [@tambo-ai/react](https://tambo.co/docs) for React-specific documentation.
|
|
77
|
+
|
|
78
|
+
## API
|
|
79
|
+
|
|
80
|
+
### `TamboClient`
|
|
81
|
+
|
|
82
|
+
The main client class. Implements `getState()` and `subscribe()` for use with `useSyncExternalStore` or similar framework bindings.
|
|
83
|
+
|
|
84
|
+
### `TamboStream`
|
|
85
|
+
|
|
86
|
+
Returned by `client.run()`. Two consumption modes:
|
|
87
|
+
|
|
88
|
+
- **Async iteration**: `for await (const { event, snapshot } of stream) { ... }`
|
|
89
|
+
- **Promise**: `const thread = await stream.thread`
|
|
90
|
+
|
|
91
|
+
### Key types
|
|
92
|
+
|
|
93
|
+
- `TamboThread` - Thread state with messages, status, and metadata
|
|
94
|
+
- `StreamEvent` - Event/snapshot pair yielded during streaming
|
|
95
|
+
- `TamboClientOptions` - Configuration for client creation
|
|
96
|
+
- `ClientState` - Full client state (thread map, current thread, streaming state)
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@tambo-ai/client` - Framework-agnostic client for Tambo AI
|
|
3
|
+
*
|
|
4
|
+
* Provides streaming, tool execution, and thread management
|
|
5
|
+
* without React dependencies.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/** Client version constant. */
|
|
9
|
+
export declare const CLIENT_VERSION = "1.0.0";
|
|
10
|
+
export { TamboClient } from "./tambo-client";
|
|
11
|
+
export type { TamboClientOptions, RunOptions, ClientState, BeforeRunContext, ContextHelperFn, } from "./tambo-client";
|
|
12
|
+
export { TamboStream } from "./tambo-stream";
|
|
13
|
+
export type { StreamEvent, TamboStreamOptions } from "./tambo-stream";
|
|
14
|
+
export { createRunStream, dispatchUserMessage, dispatchToolResults, executeToolsAndContinue, } from "./utils/send-message";
|
|
15
|
+
export type { SendMessageOptions, CreateRunStreamParams, CreateRunStreamResult, ExecuteToolsParams, ExecuteToolsResult, RunStream, CreateStream, } from "./utils/send-message";
|
|
16
|
+
export type { TamboThread, StreamingState, RunStatus } from "./types/thread";
|
|
17
|
+
export type { TamboThreadMessage, TamboComponentContent, TamboToolUseContent, TamboToolDisplayProps, Content, MessageRole, ComponentStreamingState, InitialInputMessage, } from "./types/message";
|
|
18
|
+
export type { ComponentStartEvent, ComponentPropsDeltaEvent, ComponentStateDeltaEvent, ComponentEndEvent, RunAwaitingInputEvent, MessageParentEvent, TamboCustomEvent, PendingToolCall as PendingToolCallEvent, } from "./types/event";
|
|
19
|
+
export { isTamboCustomEvent, asTamboCustomEvent } from "./types/event";
|
|
20
|
+
export type { TamboAuthState } from "./types/auth";
|
|
21
|
+
export type { ToolChoice } from "./types/tool-choice";
|
|
22
|
+
export type { TextContent, ToolResultContent, ResourceContent, InputMessage, MessageListResponse, MessageGetResponse, } from "./types/message";
|
|
23
|
+
export type { ThreadCreateResponse, ThreadRetrieveResponse, ThreadListResponse, } from "./types/thread";
|
|
24
|
+
export type { SupportedSchema, ToolAnnotations, ParameterSpec, ComponentContextToolMetadata, ComponentContextTool, RegisteredComponent, ComponentRegistry, TamboToolRegistry, JSONSchemaLite, TamboTool, TamboToolJSONSchema, TamboToolUnknown, TamboToolStandardSchema, UnsupportedSchemaTamboTool, TamboToolAssociations, TamboComponent, RegisterToolsFn, RegisterToolFn, DefineToolFn, } from "./model/component-metadata";
|
|
25
|
+
export type { McpServerInfo, NormalizedMcpServerInfo, } from "./model/mcp-server-info";
|
|
26
|
+
export { MCPTransport, getMcpServerUniqueKey } from "./model/mcp-server-info";
|
|
27
|
+
export { looksLikeJSONSchema, makeJsonSchemaPartial, getParametersFromToolSchema, safeSchemaToJsonSchema, schemaToJsonSchema, isStandardSchema, assertNoRecordSchema, } from "./schema/index";
|
|
28
|
+
export { MCPClient, ServerType, REGISTRY_SERVER_KEY, toElicitationRequestedSchema, hasRequestedSchema, } from "./mcp/index";
|
|
29
|
+
export type { MCPToolCallResult, MCPToolSpec, MCPElicitationHandler, MCPSamplingHandler, MCPHandlers, ElicitationRequestedSchema, TamboElicitationRequest, TamboElicitationResponse, ElicitationContextState, PrimitiveSchemaDefinition, } from "./mcp/index";
|
|
30
|
+
export { streamReducer, createInitialState, createInitialStateWithMessages, createInitialThreadState, isPlaceholderThreadId, PLACEHOLDER_THREAD_ID, UnreachableCaseError, } from "./utils/event-accumulator";
|
|
31
|
+
export type { ThreadState, StreamState, StreamAction, EventAction, InitThreadAction, SetCurrentThreadAction, StartNewThreadAction, LoadThreadMessagesAction, SetLastCompletedRunIdAction, UpdateThreadNameAction, } from "./utils/event-accumulator";
|
|
32
|
+
export { executeStreamableToolCall, createThrottledStreamableExecutor, executeClientTool, executeAllPendingTools, } from "./utils/tool-executor";
|
|
33
|
+
export type { PendingToolCall } from "./utils/tool-executor";
|
|
34
|
+
export { ToolCallTracker } from "./utils/tool-call-tracker";
|
|
35
|
+
export { handleEventStream } from "./utils/stream-handler";
|
|
36
|
+
export type { StreamHandlerOptions } from "./utils/stream-handler";
|
|
37
|
+
export { findComponentContent } from "./utils/thread-utils";
|
|
38
|
+
export { createKeyedThrottle } from "./utils/keyed-throttle";
|
|
39
|
+
export type { KeyedThrottle } from "./utils/keyed-throttle";
|
|
40
|
+
export { applyJsonPatch } from "./utils/json-patch";
|
|
41
|
+
export { unstrictifyToolCallParamsFromSchema, canBeNull, } from "./utils/unstrictify";
|
|
42
|
+
export { toAvailableComponent, toAvailableComponents, toAvailableTool, toAvailableTools, } from "./utils/registry-conversion";
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+BAA+B;AAC/B,eAAO,MAAM,cAAc,UAAU,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGtE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACT,YAAY,GACb,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7E,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,OAAO,EACP,WAAW,EACX,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,IAAI,oBAAoB,GACxC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,eAAe,EACf,eAAe,EACf,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,aAAa,EACb,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAG9E,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,8BAA8B,EAC9B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,yBAAyB,EACzB,iCAAiC,EACjC,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,mCAAmC,EACnC,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,GACjB,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `@tambo-ai/client` - Framework-agnostic client for Tambo AI
|
|
4
|
+
*
|
|
5
|
+
* Provides streaming, tool execution, and thread management
|
|
6
|
+
* without React dependencies.
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.toAvailableTools = exports.toAvailableTool = exports.toAvailableComponents = exports.toAvailableComponent = exports.canBeNull = exports.unstrictifyToolCallParamsFromSchema = exports.applyJsonPatch = exports.createKeyedThrottle = exports.findComponentContent = exports.handleEventStream = exports.ToolCallTracker = exports.executeAllPendingTools = exports.executeClientTool = exports.createThrottledStreamableExecutor = exports.executeStreamableToolCall = exports.UnreachableCaseError = exports.PLACEHOLDER_THREAD_ID = exports.isPlaceholderThreadId = exports.createInitialThreadState = exports.createInitialStateWithMessages = exports.createInitialState = exports.streamReducer = exports.hasRequestedSchema = exports.toElicitationRequestedSchema = exports.REGISTRY_SERVER_KEY = exports.ServerType = exports.MCPClient = exports.assertNoRecordSchema = exports.isStandardSchema = exports.schemaToJsonSchema = exports.safeSchemaToJsonSchema = exports.getParametersFromToolSchema = exports.makeJsonSchemaPartial = exports.looksLikeJSONSchema = exports.getMcpServerUniqueKey = exports.MCPTransport = exports.asTamboCustomEvent = exports.isTamboCustomEvent = exports.executeToolsAndContinue = exports.dispatchToolResults = exports.dispatchUserMessage = exports.createRunStream = exports.TamboStream = exports.TamboClient = exports.CLIENT_VERSION = void 0;
|
|
11
|
+
/** Client version constant. */
|
|
12
|
+
exports.CLIENT_VERSION = "1.0.0";
|
|
13
|
+
// -- Core classes --
|
|
14
|
+
var tambo_client_1 = require("./tambo-client");
|
|
15
|
+
Object.defineProperty(exports, "TamboClient", { enumerable: true, get: function () { return tambo_client_1.TamboClient; } });
|
|
16
|
+
var tambo_stream_1 = require("./tambo-stream");
|
|
17
|
+
Object.defineProperty(exports, "TamboStream", { enumerable: true, get: function () { return tambo_stream_1.TamboStream; } });
|
|
18
|
+
// -- Send message utilities --
|
|
19
|
+
var send_message_1 = require("./utils/send-message");
|
|
20
|
+
Object.defineProperty(exports, "createRunStream", { enumerable: true, get: function () { return send_message_1.createRunStream; } });
|
|
21
|
+
Object.defineProperty(exports, "dispatchUserMessage", { enumerable: true, get: function () { return send_message_1.dispatchUserMessage; } });
|
|
22
|
+
Object.defineProperty(exports, "dispatchToolResults", { enumerable: true, get: function () { return send_message_1.dispatchToolResults; } });
|
|
23
|
+
Object.defineProperty(exports, "executeToolsAndContinue", { enumerable: true, get: function () { return send_message_1.executeToolsAndContinue; } });
|
|
24
|
+
var event_1 = require("./types/event");
|
|
25
|
+
Object.defineProperty(exports, "isTamboCustomEvent", { enumerable: true, get: function () { return event_1.isTamboCustomEvent; } });
|
|
26
|
+
Object.defineProperty(exports, "asTamboCustomEvent", { enumerable: true, get: function () { return event_1.asTamboCustomEvent; } });
|
|
27
|
+
var mcp_server_info_1 = require("./model/mcp-server-info");
|
|
28
|
+
Object.defineProperty(exports, "MCPTransport", { enumerable: true, get: function () { return mcp_server_info_1.MCPTransport; } });
|
|
29
|
+
Object.defineProperty(exports, "getMcpServerUniqueKey", { enumerable: true, get: function () { return mcp_server_info_1.getMcpServerUniqueKey; } });
|
|
30
|
+
// -- Schema --
|
|
31
|
+
var index_1 = require("./schema/index");
|
|
32
|
+
Object.defineProperty(exports, "looksLikeJSONSchema", { enumerable: true, get: function () { return index_1.looksLikeJSONSchema; } });
|
|
33
|
+
Object.defineProperty(exports, "makeJsonSchemaPartial", { enumerable: true, get: function () { return index_1.makeJsonSchemaPartial; } });
|
|
34
|
+
Object.defineProperty(exports, "getParametersFromToolSchema", { enumerable: true, get: function () { return index_1.getParametersFromToolSchema; } });
|
|
35
|
+
Object.defineProperty(exports, "safeSchemaToJsonSchema", { enumerable: true, get: function () { return index_1.safeSchemaToJsonSchema; } });
|
|
36
|
+
Object.defineProperty(exports, "schemaToJsonSchema", { enumerable: true, get: function () { return index_1.schemaToJsonSchema; } });
|
|
37
|
+
Object.defineProperty(exports, "isStandardSchema", { enumerable: true, get: function () { return index_1.isStandardSchema; } });
|
|
38
|
+
Object.defineProperty(exports, "assertNoRecordSchema", { enumerable: true, get: function () { return index_1.assertNoRecordSchema; } });
|
|
39
|
+
// -- MCP --
|
|
40
|
+
var index_2 = require("./mcp/index");
|
|
41
|
+
Object.defineProperty(exports, "MCPClient", { enumerable: true, get: function () { return index_2.MCPClient; } });
|
|
42
|
+
Object.defineProperty(exports, "ServerType", { enumerable: true, get: function () { return index_2.ServerType; } });
|
|
43
|
+
Object.defineProperty(exports, "REGISTRY_SERVER_KEY", { enumerable: true, get: function () { return index_2.REGISTRY_SERVER_KEY; } });
|
|
44
|
+
Object.defineProperty(exports, "toElicitationRequestedSchema", { enumerable: true, get: function () { return index_2.toElicitationRequestedSchema; } });
|
|
45
|
+
Object.defineProperty(exports, "hasRequestedSchema", { enumerable: true, get: function () { return index_2.hasRequestedSchema; } });
|
|
46
|
+
// -- Utils --
|
|
47
|
+
var event_accumulator_1 = require("./utils/event-accumulator");
|
|
48
|
+
Object.defineProperty(exports, "streamReducer", { enumerable: true, get: function () { return event_accumulator_1.streamReducer; } });
|
|
49
|
+
Object.defineProperty(exports, "createInitialState", { enumerable: true, get: function () { return event_accumulator_1.createInitialState; } });
|
|
50
|
+
Object.defineProperty(exports, "createInitialStateWithMessages", { enumerable: true, get: function () { return event_accumulator_1.createInitialStateWithMessages; } });
|
|
51
|
+
Object.defineProperty(exports, "createInitialThreadState", { enumerable: true, get: function () { return event_accumulator_1.createInitialThreadState; } });
|
|
52
|
+
Object.defineProperty(exports, "isPlaceholderThreadId", { enumerable: true, get: function () { return event_accumulator_1.isPlaceholderThreadId; } });
|
|
53
|
+
Object.defineProperty(exports, "PLACEHOLDER_THREAD_ID", { enumerable: true, get: function () { return event_accumulator_1.PLACEHOLDER_THREAD_ID; } });
|
|
54
|
+
Object.defineProperty(exports, "UnreachableCaseError", { enumerable: true, get: function () { return event_accumulator_1.UnreachableCaseError; } });
|
|
55
|
+
var tool_executor_1 = require("./utils/tool-executor");
|
|
56
|
+
Object.defineProperty(exports, "executeStreamableToolCall", { enumerable: true, get: function () { return tool_executor_1.executeStreamableToolCall; } });
|
|
57
|
+
Object.defineProperty(exports, "createThrottledStreamableExecutor", { enumerable: true, get: function () { return tool_executor_1.createThrottledStreamableExecutor; } });
|
|
58
|
+
Object.defineProperty(exports, "executeClientTool", { enumerable: true, get: function () { return tool_executor_1.executeClientTool; } });
|
|
59
|
+
Object.defineProperty(exports, "executeAllPendingTools", { enumerable: true, get: function () { return tool_executor_1.executeAllPendingTools; } });
|
|
60
|
+
var tool_call_tracker_1 = require("./utils/tool-call-tracker");
|
|
61
|
+
Object.defineProperty(exports, "ToolCallTracker", { enumerable: true, get: function () { return tool_call_tracker_1.ToolCallTracker; } });
|
|
62
|
+
var stream_handler_1 = require("./utils/stream-handler");
|
|
63
|
+
Object.defineProperty(exports, "handleEventStream", { enumerable: true, get: function () { return stream_handler_1.handleEventStream; } });
|
|
64
|
+
var thread_utils_1 = require("./utils/thread-utils");
|
|
65
|
+
Object.defineProperty(exports, "findComponentContent", { enumerable: true, get: function () { return thread_utils_1.findComponentContent; } });
|
|
66
|
+
var keyed_throttle_1 = require("./utils/keyed-throttle");
|
|
67
|
+
Object.defineProperty(exports, "createKeyedThrottle", { enumerable: true, get: function () { return keyed_throttle_1.createKeyedThrottle; } });
|
|
68
|
+
var json_patch_1 = require("./utils/json-patch");
|
|
69
|
+
Object.defineProperty(exports, "applyJsonPatch", { enumerable: true, get: function () { return json_patch_1.applyJsonPatch; } });
|
|
70
|
+
var unstrictify_1 = require("./utils/unstrictify");
|
|
71
|
+
Object.defineProperty(exports, "unstrictifyToolCallParamsFromSchema", { enumerable: true, get: function () { return unstrictify_1.unstrictifyToolCallParamsFromSchema; } });
|
|
72
|
+
Object.defineProperty(exports, "canBeNull", { enumerable: true, get: function () { return unstrictify_1.canBeNull; } });
|
|
73
|
+
var registry_conversion_1 = require("./utils/registry-conversion");
|
|
74
|
+
Object.defineProperty(exports, "toAvailableComponent", { enumerable: true, get: function () { return registry_conversion_1.toAvailableComponent; } });
|
|
75
|
+
Object.defineProperty(exports, "toAvailableComponents", { enumerable: true, get: function () { return registry_conversion_1.toAvailableComponents; } });
|
|
76
|
+
Object.defineProperty(exports, "toAvailableTool", { enumerable: true, get: function () { return registry_conversion_1.toAvailableTool; } });
|
|
77
|
+
Object.defineProperty(exports, "toAvailableTools", { enumerable: true, get: function () { return registry_conversion_1.toAvailableTools; } });
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+BAA+B;AAClB,QAAA,cAAc,GAAG,OAAO,CAAC;AAEtC,qBAAqB;AACrB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAQpB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAGpB,+BAA+B;AAC/B,qDAK8B;AAJ5B,+GAAA,eAAe,OAAA;AACf,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAAA;AACnB,uHAAA,uBAAuB,OAAA;AAkCzB,uCAAuE;AAA9D,2GAAA,kBAAkB,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AA6C/C,2DAA8E;AAArE,+GAAA,YAAY,OAAA;AAAE,wHAAA,qBAAqB,OAAA;AAE5C,eAAe;AACf,wCAQwB;AAPtB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,oHAAA,2BAA2B,OAAA;AAC3B,+GAAA,sBAAsB,OAAA;AACtB,2GAAA,kBAAkB,OAAA;AAClB,yGAAA,gBAAgB,OAAA;AAChB,6GAAA,oBAAoB,OAAA;AAGtB,YAAY;AACZ,qCAMqB;AALnB,kGAAA,SAAS,OAAA;AACT,mGAAA,UAAU,OAAA;AACV,4GAAA,mBAAmB,OAAA;AACnB,qHAAA,4BAA4B,OAAA;AAC5B,2GAAA,kBAAkB,OAAA;AAepB,cAAc;AACd,+DAQmC;AAPjC,kHAAA,aAAa,OAAA;AACb,uHAAA,kBAAkB,OAAA;AAClB,mIAAA,8BAA8B,OAAA;AAC9B,6HAAA,wBAAwB,OAAA;AACxB,0HAAA,qBAAqB,OAAA;AACrB,0HAAA,qBAAqB,OAAA;AACrB,yHAAA,oBAAoB,OAAA;AAetB,uDAK+B;AAJ7B,0HAAA,yBAAyB,OAAA;AACzB,kIAAA,iCAAiC,OAAA;AACjC,kHAAA,iBAAiB,OAAA;AACjB,uHAAA,sBAAsB,OAAA;AAIxB,+DAA4D;AAAnD,oHAAA,eAAe,OAAA;AACxB,yDAA2D;AAAlD,mHAAA,iBAAiB,OAAA;AAE1B,qDAA4D;AAAnD,oHAAA,oBAAoB,OAAA;AAC7B,yDAA6D;AAApD,qHAAA,mBAAmB,OAAA;AAE5B,iDAAoD;AAA3C,4GAAA,cAAc,OAAA;AACvB,mDAG6B;AAF3B,kIAAA,mCAAmC,OAAA;AACnC,wGAAA,SAAS,OAAA;AAEX,mEAKqC;AAJnC,2HAAA,oBAAoB,OAAA;AACpB,4HAAA,qBAAqB,OAAA;AACrB,sHAAA,eAAe,OAAA;AACf,uHAAA,gBAAgB,OAAA","sourcesContent":["/**\n * `@tambo-ai/client` - Framework-agnostic client for Tambo AI\n *\n * Provides streaming, tool execution, and thread management\n * without React dependencies.\n * @packageDocumentation\n */\n\n/** Client version constant. */\nexport const CLIENT_VERSION = \"1.0.0\";\n\n// -- Core classes --\nexport { TamboClient } from \"./tambo-client\";\nexport type {\n TamboClientOptions,\n RunOptions,\n ClientState,\n BeforeRunContext,\n ContextHelperFn,\n} from \"./tambo-client\";\nexport { TamboStream } from \"./tambo-stream\";\nexport type { StreamEvent, TamboStreamOptions } from \"./tambo-stream\";\n\n// -- Send message utilities --\nexport {\n createRunStream,\n dispatchUserMessage,\n dispatchToolResults,\n executeToolsAndContinue,\n} from \"./utils/send-message\";\nexport type {\n SendMessageOptions,\n CreateRunStreamParams,\n CreateRunStreamResult,\n ExecuteToolsParams,\n ExecuteToolsResult,\n RunStream,\n CreateStream,\n} from \"./utils/send-message\";\n\n// -- Types --\nexport type { TamboThread, StreamingState, RunStatus } from \"./types/thread\";\nexport type {\n TamboThreadMessage,\n TamboComponentContent,\n TamboToolUseContent,\n TamboToolDisplayProps,\n Content,\n MessageRole,\n ComponentStreamingState,\n InitialInputMessage,\n} from \"./types/message\";\nexport type {\n ComponentStartEvent,\n ComponentPropsDeltaEvent,\n ComponentStateDeltaEvent,\n ComponentEndEvent,\n RunAwaitingInputEvent,\n MessageParentEvent,\n TamboCustomEvent,\n PendingToolCall as PendingToolCallEvent,\n} from \"./types/event\";\nexport { isTamboCustomEvent, asTamboCustomEvent } from \"./types/event\";\nexport type { TamboAuthState } from \"./types/auth\";\nexport type { ToolChoice } from \"./types/tool-choice\";\n\n// Re-export SDK types that are part of the public API\nexport type {\n TextContent,\n ToolResultContent,\n ResourceContent,\n InputMessage,\n MessageListResponse,\n MessageGetResponse,\n} from \"./types/message\";\nexport type {\n ThreadCreateResponse,\n ThreadRetrieveResponse,\n ThreadListResponse,\n} from \"./types/thread\";\n\n// -- Model --\nexport type {\n SupportedSchema,\n ToolAnnotations,\n ParameterSpec,\n ComponentContextToolMetadata,\n ComponentContextTool,\n RegisteredComponent,\n ComponentRegistry,\n TamboToolRegistry,\n JSONSchemaLite,\n TamboTool,\n TamboToolJSONSchema,\n TamboToolUnknown,\n TamboToolStandardSchema,\n UnsupportedSchemaTamboTool,\n TamboToolAssociations,\n TamboComponent,\n RegisterToolsFn,\n RegisterToolFn,\n DefineToolFn,\n} from \"./model/component-metadata\";\nexport type {\n McpServerInfo,\n NormalizedMcpServerInfo,\n} from \"./model/mcp-server-info\";\nexport { MCPTransport, getMcpServerUniqueKey } from \"./model/mcp-server-info\";\n\n// -- Schema --\nexport {\n looksLikeJSONSchema,\n makeJsonSchemaPartial,\n getParametersFromToolSchema,\n safeSchemaToJsonSchema,\n schemaToJsonSchema,\n isStandardSchema,\n assertNoRecordSchema,\n} from \"./schema/index\";\n\n// -- MCP --\nexport {\n MCPClient,\n ServerType,\n REGISTRY_SERVER_KEY,\n toElicitationRequestedSchema,\n hasRequestedSchema,\n} from \"./mcp/index\";\nexport type {\n MCPToolCallResult,\n MCPToolSpec,\n MCPElicitationHandler,\n MCPSamplingHandler,\n MCPHandlers,\n ElicitationRequestedSchema,\n TamboElicitationRequest,\n TamboElicitationResponse,\n ElicitationContextState,\n PrimitiveSchemaDefinition,\n} from \"./mcp/index\";\n\n// -- Utils --\nexport {\n streamReducer,\n createInitialState,\n createInitialStateWithMessages,\n createInitialThreadState,\n isPlaceholderThreadId,\n PLACEHOLDER_THREAD_ID,\n UnreachableCaseError,\n} from \"./utils/event-accumulator\";\nexport type {\n ThreadState,\n StreamState,\n StreamAction,\n EventAction,\n InitThreadAction,\n SetCurrentThreadAction,\n StartNewThreadAction,\n LoadThreadMessagesAction,\n SetLastCompletedRunIdAction,\n UpdateThreadNameAction,\n} from \"./utils/event-accumulator\";\n\nexport {\n executeStreamableToolCall,\n createThrottledStreamableExecutor,\n executeClientTool,\n executeAllPendingTools,\n} from \"./utils/tool-executor\";\nexport type { PendingToolCall } from \"./utils/tool-executor\";\n\nexport { ToolCallTracker } from \"./utils/tool-call-tracker\";\nexport { handleEventStream } from \"./utils/stream-handler\";\nexport type { StreamHandlerOptions } from \"./utils/stream-handler\";\nexport { findComponentContent } from \"./utils/thread-utils\";\nexport { createKeyedThrottle } from \"./utils/keyed-throttle\";\nexport type { KeyedThrottle } from \"./utils/keyed-throttle\";\nexport { applyJsonPatch } from \"./utils/json-patch\";\nexport {\n unstrictifyToolCallParamsFromSchema,\n canBeNull,\n} from \"./utils/unstrictify\";\nexport {\n toAvailableComponent,\n toAvailableComponents,\n toAvailableTool,\n toAvailableTools,\n} from \"./utils/registry-conversion\";\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ElicitRequestFormParams, PrimitiveSchemaDefinition } from "@modelcontextprotocol/sdk/spec.types.js";
|
|
2
|
+
import type { ElicitRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Schema type for elicitation request fields
|
|
5
|
+
*/
|
|
6
|
+
export type ElicitationRequestedSchema = ElicitRequestFormParams["requestedSchema"];
|
|
7
|
+
/**
|
|
8
|
+
* Elicitation request from MCP server
|
|
9
|
+
*/
|
|
10
|
+
export interface TamboElicitationRequest {
|
|
11
|
+
message: string;
|
|
12
|
+
requestedSchema: ElicitationRequestedSchema;
|
|
13
|
+
/** AbortSignal that fires when the server cancels the request (e.g., timeout) */
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Re-export PrimitiveSchemaDefinition for consumers that need to work with schema fields
|
|
18
|
+
*/
|
|
19
|
+
export type { PrimitiveSchemaDefinition };
|
|
20
|
+
type ElicitRequestParamsWithRequestedSchema = Extract<ElicitRequest["params"], {
|
|
21
|
+
requestedSchema: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Elicitation response to be sent back
|
|
25
|
+
*/
|
|
26
|
+
export interface TamboElicitationResponse {
|
|
27
|
+
action: "accept" | "decline" | "cancel";
|
|
28
|
+
content?: Record<string, unknown>;
|
|
29
|
+
[x: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Elicitation context state - read-only interface for consumers.
|
|
33
|
+
* State management is handled internally by useElicitation hook.
|
|
34
|
+
*/
|
|
35
|
+
export interface ElicitationContextState {
|
|
36
|
+
/** Current elicitation request, or null if none active */
|
|
37
|
+
elicitation: TamboElicitationRequest | null;
|
|
38
|
+
/** Function to call when user responds to elicitation (clears state automatically) */
|
|
39
|
+
resolveElicitation: ((response: TamboElicitationResponse) => void) | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Narrow the runtime ElicitRequest requestedSchema into the public
|
|
43
|
+
* ElicitationRequestedSchema type.
|
|
44
|
+
*
|
|
45
|
+
* The MCP SDK guarantees that the runtime
|
|
46
|
+
* `ElicitRequest["params"]["requestedSchema"]` shape stays aligned with the
|
|
47
|
+
* spec-defined `ElicitRequestFormParams["requestedSchema"]`. This helper
|
|
48
|
+
* centralizes the cast based on that contract so that if a future SDK version
|
|
49
|
+
* ever diverges, we have a single place to tighten the implementation (for
|
|
50
|
+
* example with structural validation or normalization).
|
|
51
|
+
* @returns requestedSchema as ElicitationRequestedSchema
|
|
52
|
+
*/
|
|
53
|
+
export declare function toElicitationRequestedSchema(value: ElicitRequestParamsWithRequestedSchema["requestedSchema"]): ElicitationRequestedSchema;
|
|
54
|
+
/**
|
|
55
|
+
* Type guard for the elicitation form params shape.
|
|
56
|
+
* @returns true when params include requestedSchema
|
|
57
|
+
*/
|
|
58
|
+
export declare function hasRequestedSchema(params: ElicitRequest["params"]): params is ElicitRequestParamsWithRequestedSchema;
|
|
59
|
+
//# sourceMappingURL=elicitation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACpC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,0BAA0B,CAAC;IAC5C,iFAAiF;IACjF,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;GAEG;AACH,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAE1C,KAAK,sCAAsC,GAAG,OAAO,CACnD,aAAa,CAAC,QAAQ,CAAC,EACvB;IAAE,eAAe,EAAE,OAAO,CAAA;CAAE,CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,0DAA0D;IAC1D,WAAW,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAC5C,sFAAsF;IACtF,kBAAkB,EAAE,CAAC,CAAC,QAAQ,EAAE,wBAAwB,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,sCAAsC,CAAC,iBAAiB,CAAC,GAC/D,0BAA0B,CAE5B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,GAC9B,MAAM,IAAI,sCAAsC,CAElD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toElicitationRequestedSchema = toElicitationRequestedSchema;
|
|
4
|
+
exports.hasRequestedSchema = hasRequestedSchema;
|
|
5
|
+
/**
|
|
6
|
+
* Narrow the runtime ElicitRequest requestedSchema into the public
|
|
7
|
+
* ElicitationRequestedSchema type.
|
|
8
|
+
*
|
|
9
|
+
* The MCP SDK guarantees that the runtime
|
|
10
|
+
* `ElicitRequest["params"]["requestedSchema"]` shape stays aligned with the
|
|
11
|
+
* spec-defined `ElicitRequestFormParams["requestedSchema"]`. This helper
|
|
12
|
+
* centralizes the cast based on that contract so that if a future SDK version
|
|
13
|
+
* ever diverges, we have a single place to tighten the implementation (for
|
|
14
|
+
* example with structural validation or normalization).
|
|
15
|
+
* @returns requestedSchema as ElicitationRequestedSchema
|
|
16
|
+
*/
|
|
17
|
+
function toElicitationRequestedSchema(value) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard for the elicitation form params shape.
|
|
22
|
+
* @returns true when params include requestedSchema
|
|
23
|
+
*/
|
|
24
|
+
function hasRequestedSchema(params) {
|
|
25
|
+
return "requestedSchema" in params;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=elicitation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicitation.js","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":";;AAgEA,oEAIC;AAMD,gDAIC;AA1BD;;;;;;;;;;;GAWG;AACH,SAAgB,4BAA4B,CAC1C,KAAgE;IAEhE,OAAO,KAAmC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAChC,MAA+B;IAE/B,OAAO,iBAAiB,IAAI,MAAM,CAAC;AACrC,CAAC","sourcesContent":["import type {\n ElicitRequestFormParams,\n PrimitiveSchemaDefinition,\n} from \"@modelcontextprotocol/sdk/spec.types.js\";\nimport type { ElicitRequest } from \"@modelcontextprotocol/sdk/types.js\";\n\n/**\n * Schema type for elicitation request fields\n */\nexport type ElicitationRequestedSchema =\n ElicitRequestFormParams[\"requestedSchema\"];\n\n/**\n * Elicitation request from MCP server\n */\nexport interface TamboElicitationRequest {\n message: string;\n requestedSchema: ElicitationRequestedSchema;\n /** AbortSignal that fires when the server cancels the request (e.g., timeout) */\n signal?: AbortSignal;\n}\n\n/**\n * Re-export PrimitiveSchemaDefinition for consumers that need to work with schema fields\n */\nexport type { PrimitiveSchemaDefinition };\n\ntype ElicitRequestParamsWithRequestedSchema = Extract<\n ElicitRequest[\"params\"],\n { requestedSchema: unknown }\n>;\n\n/**\n * Elicitation response to be sent back\n */\nexport interface TamboElicitationResponse {\n action: \"accept\" | \"decline\" | \"cancel\";\n content?: Record<string, unknown>;\n [x: string]: unknown;\n}\n\n/**\n * Elicitation context state - read-only interface for consumers.\n * State management is handled internally by useElicitation hook.\n */\nexport interface ElicitationContextState {\n /** Current elicitation request, or null if none active */\n elicitation: TamboElicitationRequest | null;\n /** Function to call when user responds to elicitation (clears state automatically) */\n resolveElicitation: ((response: TamboElicitationResponse) => void) | null;\n}\n\n/**\n * Narrow the runtime ElicitRequest requestedSchema into the public\n * ElicitationRequestedSchema type.\n *\n * The MCP SDK guarantees that the runtime\n * `ElicitRequest[\"params\"][\"requestedSchema\"]` shape stays aligned with the\n * spec-defined `ElicitRequestFormParams[\"requestedSchema\"]`. This helper\n * centralizes the cast based on that contract so that if a future SDK version\n * ever diverges, we have a single place to tighten the implementation (for\n * example with structural validation or normalization).\n * @returns requestedSchema as ElicitationRequestedSchema\n */\nexport function toElicitationRequestedSchema(\n value: ElicitRequestParamsWithRequestedSchema[\"requestedSchema\"],\n): ElicitationRequestedSchema {\n return value as ElicitationRequestedSchema;\n}\n\n/**\n * Type guard for the elicitation form params shape.\n * @returns true when params include requestedSchema\n */\nexport function hasRequestedSchema(\n params: ElicitRequest[\"params\"],\n): params is ElicitRequestParamsWithRequestedSchema {\n return \"requestedSchema\" in params;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { MCPClient, type MCPToolCallResult, type MCPToolSpec, type MCPElicitationHandler, type MCPSamplingHandler, type MCPHandlers, } from "./mcp-client";
|
|
2
|
+
export { MCPTransport } from "./mcp-client";
|
|
3
|
+
export { ServerType, REGISTRY_SERVER_KEY } from "./mcp-constants";
|
|
4
|
+
export type { ElicitationRequestedSchema, TamboElicitationRequest, TamboElicitationResponse, ElicitationContextState, PrimitiveSchemaDefinition, } from "./elicitation";
|
|
5
|
+
export { toElicitationRequestedSchema, hasRequestedSchema, } from "./elicitation";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EACV,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasRequestedSchema = exports.toElicitationRequestedSchema = exports.REGISTRY_SERVER_KEY = exports.ServerType = exports.MCPTransport = exports.MCPClient = void 0;
|
|
4
|
+
var mcp_client_1 = require("./mcp-client");
|
|
5
|
+
Object.defineProperty(exports, "MCPClient", { enumerable: true, get: function () { return mcp_client_1.MCPClient; } });
|
|
6
|
+
var mcp_client_2 = require("./mcp-client");
|
|
7
|
+
Object.defineProperty(exports, "MCPTransport", { enumerable: true, get: function () { return mcp_client_2.MCPTransport; } });
|
|
8
|
+
var mcp_constants_1 = require("./mcp-constants");
|
|
9
|
+
Object.defineProperty(exports, "ServerType", { enumerable: true, get: function () { return mcp_constants_1.ServerType; } });
|
|
10
|
+
Object.defineProperty(exports, "REGISTRY_SERVER_KEY", { enumerable: true, get: function () { return mcp_constants_1.REGISTRY_SERVER_KEY; } });
|
|
11
|
+
var elicitation_1 = require("./elicitation");
|
|
12
|
+
Object.defineProperty(exports, "toElicitationRequestedSchema", { enumerable: true, get: function () { return elicitation_1.toElicitationRequestedSchema; } });
|
|
13
|
+
Object.defineProperty(exports, "hasRequestedSchema", { enumerable: true, get: function () { return elicitation_1.hasRequestedSchema; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";;;AAAA,2CAOsB;AANpB,uGAAA,SAAS,OAAA;AAOX,2CAA4C;AAAnC,0GAAA,YAAY,OAAA;AACrB,iDAAkE;AAAzD,2GAAA,UAAU,OAAA;AAAE,oHAAA,mBAAmB,OAAA;AAQxC,6CAGuB;AAFrB,2HAAA,4BAA4B,OAAA;AAC5B,iHAAA,kBAAkB,OAAA","sourcesContent":["export {\n MCPClient,\n type MCPToolCallResult,\n type MCPToolSpec,\n type MCPElicitationHandler,\n type MCPSamplingHandler,\n type MCPHandlers,\n} from \"./mcp-client\";\nexport { MCPTransport } from \"./mcp-client\";\nexport { ServerType, REGISTRY_SERVER_KEY } from \"./mcp-constants\";\nexport type {\n ElicitationRequestedSchema,\n TamboElicitationRequest,\n TamboElicitationResponse,\n ElicitationContextState,\n PrimitiveSchemaDefinition,\n} from \"./elicitation\";\nexport {\n toElicitationRequestedSchema,\n hasRequestedSchema,\n} from \"./elicitation\";\n"]}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { type OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
|
+
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
4
|
+
import { ClientNotification, ClientRequest, CreateMessageRequest, CreateMessageResult, ElicitRequest, ElicitResult } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { JSONSchema7 } from "json-schema";
|
|
6
|
+
import { MCPTransport } from "../model/mcp-server-info";
|
|
7
|
+
export { MCPTransport };
|
|
8
|
+
/**
|
|
9
|
+
* Handler for MCP elicitation requests.
|
|
10
|
+
* Receives the elicit request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.
|
|
11
|
+
* @param request - The elicitation request from the server
|
|
12
|
+
* @param extra - Additional context including AbortSignal for cancellation
|
|
13
|
+
* @returns Promise resolving to the elicitation result
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const handler: MCPElicitationHandler = async (request, extra) => {
|
|
17
|
+
* // Listen for cancellation
|
|
18
|
+
* extra.signal.addEventListener('abort', () => {
|
|
19
|
+
* console.log('Request cancelled');
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Return user's response
|
|
23
|
+
* return {
|
|
24
|
+
* action: 'accept',
|
|
25
|
+
* content: { name: 'John' }
|
|
26
|
+
* };
|
|
27
|
+
* };
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export type MCPElicitationHandler = (e: ElicitRequest, extra: RequestHandlerExtra<ClientRequest, ClientNotification>) => Promise<ElicitResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Handler for MCP sampling requests (create_message).
|
|
33
|
+
* Receives the sampling request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.
|
|
34
|
+
* @param request - The sampling/create_message request from the server
|
|
35
|
+
* @param extra - Additional context including AbortSignal for cancellation
|
|
36
|
+
* @returns Promise resolving to the sampling result
|
|
37
|
+
*/
|
|
38
|
+
export type MCPSamplingHandler = (e: CreateMessageRequest, extra: RequestHandlerExtra<ClientRequest, ClientNotification>) => Promise<CreateMessageResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Handlers for MCP requests - these are only used if the server supports the corresponding capabilities
|
|
41
|
+
* @param elicitation - Handler for elicitation requests (receives request and RequestHandlerExtra with AbortSignal)
|
|
42
|
+
* @param sampling - Handler for sampling requests (receives request and RequestHandlerExtra with AbortSignal)
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const mcp = await MCPClient.create(
|
|
46
|
+
* 'https://api.example.com/mcp',
|
|
47
|
+
* MCPTransport.HTTP,
|
|
48
|
+
* {},
|
|
49
|
+
* undefined,
|
|
50
|
+
* undefined,
|
|
51
|
+
* {
|
|
52
|
+
* elicitation: (e, extra) => Promise.resolve({...}),
|
|
53
|
+
* },
|
|
54
|
+
* );
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export interface MCPHandlers {
|
|
58
|
+
elicitation: MCPElicitationHandler;
|
|
59
|
+
sampling: MCPSamplingHandler;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A client for interacting with MCP (Model Context Protocol) servers.
|
|
63
|
+
* Provides a simple interface for listing and calling tools exposed by the server.
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const mcp = await MCPClient.create('https://api.example.com/mcp');
|
|
67
|
+
* const tools = await mcp.listTools();
|
|
68
|
+
* const result = await mcp.callTool('toolName', { arg1: 'value1' });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare class MCPClient {
|
|
72
|
+
/**
|
|
73
|
+
* The underlying MCP client
|
|
74
|
+
*
|
|
75
|
+
* Be careful not to mutate the client directly, use the methods provided instead.
|
|
76
|
+
*/
|
|
77
|
+
client: Client;
|
|
78
|
+
private transport;
|
|
79
|
+
private transportType;
|
|
80
|
+
sessionId?: string;
|
|
81
|
+
private endpoint;
|
|
82
|
+
private headers;
|
|
83
|
+
private authProvider?;
|
|
84
|
+
private handlers;
|
|
85
|
+
/**
|
|
86
|
+
* Private constructor to enforce using the static create method.
|
|
87
|
+
* @param endpoint - The URL of the MCP server to connect to
|
|
88
|
+
* @param transportType - The transport to use for the MCP client
|
|
89
|
+
* @param headers - Optional custom headers to include in requests
|
|
90
|
+
*/
|
|
91
|
+
private constructor();
|
|
92
|
+
/**
|
|
93
|
+
* Creates and initializes a new MCPClient instance. This is the recommended
|
|
94
|
+
* way to create an MCPClient as it handles both instantiation and connection
|
|
95
|
+
* setup.
|
|
96
|
+
* @param endpoint - The URL of the MCP server to connect to
|
|
97
|
+
* @param transportType - The transport type to use for the MCP client. Defaults to HTTP.
|
|
98
|
+
* @param headers - Optional custom headers to include in requests
|
|
99
|
+
* @param authProvider - Optional auth provider to use for authentication
|
|
100
|
+
* @param sessionId - Optional session id to use for the MCP client - if not
|
|
101
|
+
* provided, a new session will be created
|
|
102
|
+
* @returns A connected MCPClient instance ready for use
|
|
103
|
+
* @throws {Error} Will throw an error if connection fails
|
|
104
|
+
*/
|
|
105
|
+
static create(endpoint: string, transportType: MCPTransport | undefined, headers: Record<string, string> | undefined, authProvider: OAuthClientProvider | undefined, sessionId: string | undefined, handlers?: Partial<MCPHandlers>): Promise<MCPClient>;
|
|
106
|
+
private initializeTransport;
|
|
107
|
+
/**
|
|
108
|
+
* Initializes the MCP client with the appropriate capabilities and handlers
|
|
109
|
+
* @returns The initialized MCP client
|
|
110
|
+
*/
|
|
111
|
+
private initializeClient;
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves a complete list of all available tools from the MCP server.
|
|
114
|
+
* Handles pagination automatically by following cursors until all tools are fetched.
|
|
115
|
+
* @returns A complete list of all available tools and their descriptions
|
|
116
|
+
* @throws {Error} Will throw an error if any server request fails during pagination
|
|
117
|
+
*/
|
|
118
|
+
listTools(): Promise<MCPToolSpec[]>;
|
|
119
|
+
getServerCapabilities(): {
|
|
120
|
+
experimental?: {
|
|
121
|
+
[x: string]: object;
|
|
122
|
+
} | undefined;
|
|
123
|
+
logging?: object | undefined;
|
|
124
|
+
completions?: object | undefined;
|
|
125
|
+
prompts?: {
|
|
126
|
+
listChanged?: boolean | undefined;
|
|
127
|
+
} | undefined;
|
|
128
|
+
resources?: {
|
|
129
|
+
subscribe?: boolean | undefined;
|
|
130
|
+
listChanged?: boolean | undefined;
|
|
131
|
+
} | undefined;
|
|
132
|
+
tools?: {
|
|
133
|
+
listChanged?: boolean | undefined;
|
|
134
|
+
} | undefined;
|
|
135
|
+
tasks?: {
|
|
136
|
+
[x: string]: unknown;
|
|
137
|
+
list?: object | undefined;
|
|
138
|
+
cancel?: object | undefined;
|
|
139
|
+
requests?: {
|
|
140
|
+
[x: string]: unknown;
|
|
141
|
+
tools?: {
|
|
142
|
+
[x: string]: unknown;
|
|
143
|
+
call?: object | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
} | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
} | undefined;
|
|
148
|
+
getServerVersion(): {
|
|
149
|
+
version: string;
|
|
150
|
+
name: string;
|
|
151
|
+
websiteUrl?: string | undefined;
|
|
152
|
+
description?: string | undefined;
|
|
153
|
+
icons?: {
|
|
154
|
+
src: string;
|
|
155
|
+
mimeType?: string | undefined;
|
|
156
|
+
sizes?: string[] | undefined;
|
|
157
|
+
theme?: "light" | "dark" | undefined;
|
|
158
|
+
}[] | undefined;
|
|
159
|
+
title?: string | undefined;
|
|
160
|
+
} | undefined;
|
|
161
|
+
getInstructions(): string | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* Calls a specific tool on the MCP server with the provided arguments.
|
|
164
|
+
* @param name - The name of the tool to call
|
|
165
|
+
* @param args - Arguments to pass to the tool, must match the tool's expected schema
|
|
166
|
+
* @returns The result from the tool execution
|
|
167
|
+
* @throws {Error} Will throw an error if the tool call fails or if arguments are invalid
|
|
168
|
+
*/
|
|
169
|
+
callTool(name: string, args: Record<string, unknown>, _meta?: Record<string, unknown>): Promise<MCPToolCallResult>;
|
|
170
|
+
updateElicitationHandler(handler: MCPElicitationHandler | undefined): void;
|
|
171
|
+
updateSamplingHandler(handler: MCPSamplingHandler | undefined): void;
|
|
172
|
+
close(): Promise<void>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The result of a tool call.
|
|
176
|
+
* This is the same as the result of a tool call in the OpenAI SDK, but is reified here
|
|
177
|
+
*/
|
|
178
|
+
export type MCPToolCallResult = Awaited<ReturnType<typeof Client.prototype.callTool>>;
|
|
179
|
+
export interface MCPToolSpec {
|
|
180
|
+
name: string;
|
|
181
|
+
description?: string;
|
|
182
|
+
inputSchema?: JSONSchema7;
|
|
183
|
+
maxCalls?: number;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=mcp-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"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"}
|