@decocms/bindings 0.2.4-beta.4 → 1.0.0-test.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/README.md +3 -3
- package/package.json +9 -35
- package/src/core/binder.ts +241 -0
- package/src/core/client/README.md +3 -0
- package/{dist/core/client/http-client-transport.js → src/core/client/http-client-transport.ts} +24 -12
- package/src/core/client/index.ts +1 -0
- package/src/core/client/mcp-client.ts +149 -0
- package/src/core/client/mcp.ts +93 -0
- package/src/core/client/proxy.ts +151 -0
- package/src/core/connection.ts +38 -0
- package/src/core/subset.ts +514 -0
- package/src/index.ts +15 -0
- package/src/well-known/agent.ts +60 -0
- package/src/well-known/collections.ts +416 -0
- package/src/well-known/language-model.ts +383 -0
- package/test/index.test.ts +942 -0
- package/tsconfig.json +11 -0
- package/vitest.config.ts +8 -0
- package/dist/core/binder.d.ts +0 -3
- package/dist/core/binder.js +0 -81
- package/dist/core/binder.js.map +0 -1
- package/dist/core/client/http-client-transport.d.ts +0 -12
- package/dist/core/client/http-client-transport.js.map +0 -1
- package/dist/core/client/index.d.ts +0 -3
- package/dist/core/client/index.js +0 -5
- package/dist/core/client/index.js.map +0 -1
- package/dist/core/client/mcp-client.d.ts +0 -233
- package/dist/core/client/mcp-client.js +0 -99
- package/dist/core/client/mcp-client.js.map +0 -1
- package/dist/core/client/mcp.d.ts +0 -3
- package/dist/core/client/mcp.js +0 -29
- package/dist/core/client/mcp.js.map +0 -1
- package/dist/core/client/proxy.d.ts +0 -10
- package/dist/core/client/proxy.js +0 -104
- package/dist/core/client/proxy.js.map +0 -1
- package/dist/core/connection.d.ts +0 -30
- package/dist/core/connection.js +0 -1
- package/dist/core/connection.js.map +0 -1
- package/dist/core/subset.d.ts +0 -17
- package/dist/core/subset.js +0 -321
- package/dist/core/subset.js.map +0 -1
- package/dist/index-D0aUdNls.d.ts +0 -153
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/well-known/agent.d.ts +0 -903
- package/dist/well-known/agent.js +0 -27
- package/dist/well-known/agent.js.map +0 -1
- package/dist/well-known/collections.d.ts +0 -537
- package/dist/well-known/collections.js +0 -134
- package/dist/well-known/collections.js.map +0 -1
- package/dist/well-known/language-model.d.ts +0 -2836
- package/dist/well-known/language-model.js +0 -209
- package/dist/well-known/language-model.js.map +0 -1
package/dist/index-D0aUdNls.d.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { z, ZodType } from 'zod/v3';
|
|
2
|
-
import { MCPConnection } from './core/connection.js';
|
|
3
|
-
|
|
4
|
-
interface FetchOptions extends RequestInit {
|
|
5
|
-
path?: string;
|
|
6
|
-
segments?: string[];
|
|
7
|
-
}
|
|
8
|
-
declare const MCPClient: {
|
|
9
|
-
forConnection: <TDefinition extends readonly ToolBinder[]>(connection: MCPConnection) => MCPClientFetchStub<TDefinition>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
declare const isStreamableToolBinder: (toolBinder: ToolBinder) => toolBinder is ToolBinder<string, any, any, true>;
|
|
13
|
-
type MCPClientStub<TDefinition extends readonly ToolBinder[]> = {
|
|
14
|
-
[K in TDefinition[number] as K["name"]]: K extends ToolBinder<string, infer TInput, infer TReturn> ? (params: TInput, init?: RequestInit) => Promise<TReturn> : never;
|
|
15
|
-
};
|
|
16
|
-
type MCPClientFetchStub<TDefinition extends readonly ToolBinder[]> = {
|
|
17
|
-
[K in TDefinition[number] as K["name"]]: K["streamable"] extends true ? K extends ToolBinder<string, infer TInput, any, true> ? (params: TInput, init?: RequestInit) => Promise<Response> : never : K extends ToolBinder<string, infer TInput, infer TReturn, any> ? (params: TInput, init?: RequestInit) => Promise<Awaited<TReturn>> : never;
|
|
18
|
-
};
|
|
19
|
-
interface MCPClientRaw {
|
|
20
|
-
callTool: (tool: string, args: unknown) => Promise<unknown>;
|
|
21
|
-
listTools: () => Promise<{
|
|
22
|
-
name: string;
|
|
23
|
-
inputSchema: any;
|
|
24
|
-
outputSchema?: any;
|
|
25
|
-
description: string;
|
|
26
|
-
}[]>;
|
|
27
|
-
}
|
|
28
|
-
type JSONSchemaToZodConverter = (jsonSchema: any) => z.ZodTypeAny;
|
|
29
|
-
interface CreateStubAPIOptions {
|
|
30
|
-
connection: MCPConnection;
|
|
31
|
-
streamable?: Record<string, boolean>;
|
|
32
|
-
debugId?: () => string;
|
|
33
|
-
getErrorByStatusCode?: (statusCode: number, message?: string, traceId?: string, errorObject?: unknown) => Error;
|
|
34
|
-
}
|
|
35
|
-
declare function createMCPFetchStub<TDefinition extends readonly ToolBinder[]>(options: CreateStubAPIOptions): MCPClientFetchStub<TDefinition>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Core Binder Types and Utilities
|
|
39
|
-
*
|
|
40
|
-
* This module provides the core types and utilities for the bindings system.
|
|
41
|
-
* Bindings define standardized interfaces that integrations (MCPs) can implement.
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
type JsonSchema = Record<string, unknown>;
|
|
45
|
-
/**
|
|
46
|
-
* Normalizes a schema to JSON Schema format.
|
|
47
|
-
* Accepts either a Zod schema or a JSON schema and returns a JSON schema.
|
|
48
|
-
*
|
|
49
|
-
* @param schema - A Zod schema or JSON schema
|
|
50
|
-
* @returns The JSON schema representation, or null if input is null/undefined
|
|
51
|
-
*/
|
|
52
|
-
declare function normalizeToJsonSchema(schema: ZodType<any> | JsonSchema | null | undefined): JsonSchema | null;
|
|
53
|
-
/**
|
|
54
|
-
* ToolBinder defines a single tool within a binding.
|
|
55
|
-
* It specifies the tool name, input/output schemas, and whether it's optional.
|
|
56
|
-
*
|
|
57
|
-
* @template TName - The tool name (can be a string or RegExp for pattern matching)
|
|
58
|
-
* @template TInput - The input type (inferred from inputSchema)
|
|
59
|
-
* @template TReturn - The return type (inferred from outputSchema)
|
|
60
|
-
*/
|
|
61
|
-
interface ToolBinder<TName extends string | RegExp = string, TInput = any, TReturn extends object | null | boolean = object, TStreamable extends boolean = boolean> {
|
|
62
|
-
/** The name of the tool (e.g., "DECO_CHAT_CHANNELS_JOIN") */
|
|
63
|
-
name: TName;
|
|
64
|
-
/** Zod schema for validating tool input */
|
|
65
|
-
inputSchema: ZodType<TInput>;
|
|
66
|
-
/** Optional Zod schema for validating tool output */
|
|
67
|
-
outputSchema?: TStreamable extends true ? never : ZodType<TReturn>;
|
|
68
|
-
/**
|
|
69
|
-
* Whether this tool is streamable.
|
|
70
|
-
*/
|
|
71
|
-
streamable?: TStreamable;
|
|
72
|
-
/**
|
|
73
|
-
* Whether this tool is optional in the binding.
|
|
74
|
-
* If true, an implementation doesn't need to provide this tool.
|
|
75
|
-
*/
|
|
76
|
-
opt?: true;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Binder represents a collection of tool definitions that form a binding.
|
|
80
|
-
* A binding is like a TypeScript interface - it defines what tools must be implemented.
|
|
81
|
-
*
|
|
82
|
-
* @template TDefinition - Array of ToolBinder definitions
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* const MY_BINDING = [{
|
|
87
|
-
* name: "MY_TOOL" as const,
|
|
88
|
-
* inputSchema: z.object({ id: z.string() }),
|
|
89
|
-
* outputSchema: z.object({ success: z.boolean() }),
|
|
90
|
-
* }] as const satisfies Binder;
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
type Binder<TDefinition extends readonly ToolBinder[] = readonly ToolBinder[]> = TDefinition;
|
|
94
|
-
/**
|
|
95
|
-
* Tool with schemas for validation
|
|
96
|
-
*/
|
|
97
|
-
interface ToolWithSchemas {
|
|
98
|
-
name: string;
|
|
99
|
-
inputSchema?: ZodType<any> | Record<string, unknown>;
|
|
100
|
-
outputSchema?: ZodType<any> | Record<string, unknown>;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Binding checker interface
|
|
104
|
-
*/
|
|
105
|
-
interface BindingChecker {
|
|
106
|
-
/**
|
|
107
|
-
* Check if a set of tools implements the binding with full schema validation.
|
|
108
|
-
*
|
|
109
|
-
* Validates:
|
|
110
|
-
* - Tool name matches (exact or regex)
|
|
111
|
-
* - Input schema: Tool accepts what binder requires (no removals from binder to tool)
|
|
112
|
-
* - Output schema: Tool provides what binder expects (no removals from tool to binder)
|
|
113
|
-
*
|
|
114
|
-
* @param tools - Array of tools with names and schemas
|
|
115
|
-
* @returns Promise<boolean> - true if all tools implement the binding correctly
|
|
116
|
-
*/
|
|
117
|
-
isImplementedBy: (tools: ToolWithSchemas[]) => boolean;
|
|
118
|
-
}
|
|
119
|
-
declare const bindingClient: <TDefinition extends readonly ToolBinder[]>(binder: TDefinition) => {
|
|
120
|
-
forConnection: (mcpConnection: MCPConnection) => MCPClientFetchStub<TDefinition>;
|
|
121
|
-
/**
|
|
122
|
-
* Check if a set of tools implements the binding with full schema validation.
|
|
123
|
-
*
|
|
124
|
-
* Validates:
|
|
125
|
-
* - Tool name matches (exact or regex)
|
|
126
|
-
* - Input schema: Tool accepts what binder requires (no removals from binder to tool)
|
|
127
|
-
* - Output schema: Tool provides what binder expects (no removals from tool to binder)
|
|
128
|
-
*
|
|
129
|
-
* @param tools - Array of tools with names and schemas
|
|
130
|
-
* @returns Promise<boolean> - true if all tools implement the binding correctly
|
|
131
|
-
*/
|
|
132
|
-
isImplementedBy: (tools: ToolWithSchemas[]) => boolean;
|
|
133
|
-
};
|
|
134
|
-
type MCPBindingClient<T extends ReturnType<typeof bindingClient>> = ReturnType<T["forConnection"]>;
|
|
135
|
-
/**
|
|
136
|
-
* Creates a binding checker with full schema validation using structural subset checking.
|
|
137
|
-
*
|
|
138
|
-
* This performs strict compatibility checking:
|
|
139
|
-
* - For input schemas: Validates that the tool can accept what the binder requires (binder ⊆ tool)
|
|
140
|
-
* - For output schemas: Validates that the tool provides what the binder expects (binder ⊆ tool)
|
|
141
|
-
*
|
|
142
|
-
* @param binderTools - The binding definition to check against
|
|
143
|
-
* @returns A binding checker with an async isImplementedBy method
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```ts
|
|
147
|
-
* const checker = createBindingChecker(MY_BINDING);
|
|
148
|
-
* const isCompatible = await checker.isImplementedBy(availableTools);
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
declare function createBindingChecker<TDefinition extends readonly ToolBinder[]>(binderTools: TDefinition): BindingChecker;
|
|
152
|
-
|
|
153
|
-
export { type Binder as B, type CreateStubAPIOptions as C, type FetchOptions as F, type JSONSchemaToZodConverter as J, type MCPClientFetchStub as M, type ToolWithSchemas as T, type ToolBinder as a, MCPClient as b, type MCPClientStub as c, type MCPClientRaw as d, createMCPFetchStub as e, type BindingChecker as f, bindingClient as g, type MCPBindingClient as h, isStreamableToolBinder as i, createBindingChecker as j, normalizeToJsonSchema as n };
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @decocms/bindings\n *\n * Core type definitions for the bindings system.\n * Bindings define standardized interfaces that integrations (MCPs) can implement.\n */\n\n// Re-export core binder types and utilities\nexport {\n createBindingChecker,\n type Binder,\n type BindingChecker,\n type ToolBinder,\n type ToolWithSchemas,\n} from \"./core/binder\";\n"],"mappings":"AAQA;AAAA,EACE;AAAA,OAKK;","names":[]}
|