tmcp 1.18.0 → 1.18.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 +1 -1
- package/package.json +1 -1
- package/src/types/index.d.ts +135 -1
- package/src/types/index.d.ts.map +1 -1
- package/src/utils/index.js +80 -0
package/README.md
CHANGED
|
@@ -212,7 +212,7 @@ tool.mix(
|
|
|
212
212
|
|
|
213
213
|
- `tool` – build `CallToolResult` objects via `text`, `error`, `media`, `resource`, `resourceLink`, `structured`, and `mix` (merge multiple kind of tool response).
|
|
214
214
|
- `resource` – return `ReadResourceResult` through `text`, `blob`, or `mix` (merge `resource.text` and `resource.blob`).
|
|
215
|
-
- `prompt` – generate `GetPromptResult` using `message` (single string), `messages` (array of strings),
|
|
215
|
+
- `prompt` – generate `GetPromptResult` using `message` (single string), `messages` (array of strings), `text`, `media`, `resource`, `resourceLink` and `mix` (merge multiple kind of tool response).
|
|
216
216
|
- `complete` – create `CompleteResult` payloads with `values(list, hasMore?, total?)`.
|
|
217
217
|
|
|
218
218
|
All helpers are typed, so TypeScript will prevent you from returning malformed payloads while cutting down the repetitive envelopes that used to appear in almost every handler.
|
package/package.json
CHANGED
package/src/types/index.d.ts
CHANGED
|
@@ -1945,17 +1945,151 @@ declare module 'tmcp/utils' {
|
|
|
1945
1945
|
};
|
|
1946
1946
|
}[];
|
|
1947
1947
|
};
|
|
1948
|
+
/**
|
|
1949
|
+
* Alias for message
|
|
1950
|
+
* */
|
|
1951
|
+
function text(text: string): {
|
|
1952
|
+
messages: {
|
|
1953
|
+
role: "user";
|
|
1954
|
+
content: {
|
|
1955
|
+
type: "text";
|
|
1956
|
+
text: string;
|
|
1957
|
+
};
|
|
1958
|
+
}[];
|
|
1959
|
+
};
|
|
1948
1960
|
|
|
1949
|
-
function
|
|
1961
|
+
function media(type: "audio" | "image", data: string, mime_type: string): {
|
|
1950
1962
|
messages: {
|
|
1951
1963
|
role: "user";
|
|
1964
|
+
content: {
|
|
1965
|
+
type: "audio" | "image";
|
|
1966
|
+
data: string;
|
|
1967
|
+
mimeType: string;
|
|
1968
|
+
};
|
|
1969
|
+
}[];
|
|
1970
|
+
};
|
|
1971
|
+
|
|
1972
|
+
function resource(resource: EmbeddedResource["resource"]): {
|
|
1973
|
+
messages: {
|
|
1974
|
+
role: "user";
|
|
1975
|
+
content: {
|
|
1976
|
+
type: "resource";
|
|
1977
|
+
resource: {
|
|
1978
|
+
text: string;
|
|
1979
|
+
uri: string;
|
|
1980
|
+
mimeType?: string | undefined;
|
|
1981
|
+
_meta?: ({} & {
|
|
1982
|
+
[key: string]: unknown;
|
|
1983
|
+
}) | undefined;
|
|
1984
|
+
} | {
|
|
1985
|
+
blob: string;
|
|
1986
|
+
uri: string;
|
|
1987
|
+
mimeType?: string | undefined;
|
|
1988
|
+
_meta?: ({} & {
|
|
1989
|
+
[key: string]: unknown;
|
|
1990
|
+
}) | undefined;
|
|
1991
|
+
};
|
|
1992
|
+
};
|
|
1993
|
+
}[];
|
|
1994
|
+
};
|
|
1995
|
+
|
|
1996
|
+
function resourceLink(resource: Omit<ResourceLink, "type">): {
|
|
1997
|
+
messages: {
|
|
1998
|
+
role: "user";
|
|
1999
|
+
content: {
|
|
2000
|
+
name: string;
|
|
2001
|
+
description?: string | undefined;
|
|
2002
|
+
title?: string | undefined;
|
|
2003
|
+
uri: string;
|
|
2004
|
+
_meta?: ({} & {
|
|
2005
|
+
[key: string]: unknown;
|
|
2006
|
+
}) | undefined;
|
|
2007
|
+
mimeType?: string | undefined;
|
|
2008
|
+
icons?: {
|
|
2009
|
+
src: string;
|
|
2010
|
+
mimeType?: string | undefined;
|
|
2011
|
+
sizes?: string[] | undefined;
|
|
2012
|
+
}[] | undefined;
|
|
2013
|
+
type: "resource_link";
|
|
2014
|
+
};
|
|
2015
|
+
}[];
|
|
2016
|
+
};
|
|
2017
|
+
|
|
2018
|
+
function mix(messages: Array<GetPromptResult>): {
|
|
2019
|
+
messages: {
|
|
2020
|
+
role: "user" | "assistant";
|
|
1952
2021
|
content: {
|
|
1953
2022
|
type: "text";
|
|
1954
2023
|
text: string;
|
|
2024
|
+
_meta?: ({} & {
|
|
2025
|
+
[key: string]: unknown;
|
|
2026
|
+
}) | undefined;
|
|
2027
|
+
} | {
|
|
2028
|
+
type: "image";
|
|
2029
|
+
data: string;
|
|
2030
|
+
mimeType: string;
|
|
2031
|
+
_meta?: ({} & {
|
|
2032
|
+
[key: string]: unknown;
|
|
2033
|
+
}) | undefined;
|
|
2034
|
+
} | {
|
|
2035
|
+
type: "audio";
|
|
2036
|
+
data: string;
|
|
2037
|
+
mimeType: string;
|
|
2038
|
+
_meta?: ({} & {
|
|
2039
|
+
[key: string]: unknown;
|
|
2040
|
+
}) | undefined;
|
|
2041
|
+
} | {
|
|
2042
|
+
type: "resource_link";
|
|
2043
|
+
icons?: {
|
|
2044
|
+
src: string;
|
|
2045
|
+
mimeType?: string | undefined;
|
|
2046
|
+
sizes?: string[] | undefined;
|
|
2047
|
+
}[] | undefined;
|
|
2048
|
+
uri: string;
|
|
2049
|
+
description?: string | undefined;
|
|
2050
|
+
mimeType?: string | undefined;
|
|
2051
|
+
_meta?: ({} & {
|
|
2052
|
+
[key: string]: unknown;
|
|
2053
|
+
}) | undefined;
|
|
2054
|
+
name: string;
|
|
2055
|
+
title?: string | undefined;
|
|
2056
|
+
} | {
|
|
2057
|
+
type: "resource";
|
|
2058
|
+
resource: {
|
|
2059
|
+
text: string;
|
|
2060
|
+
uri: string;
|
|
2061
|
+
mimeType?: string | undefined;
|
|
2062
|
+
_meta?: ({} & {
|
|
2063
|
+
[key: string]: unknown;
|
|
2064
|
+
}) | undefined;
|
|
2065
|
+
} | {
|
|
2066
|
+
blob: string;
|
|
2067
|
+
uri: string;
|
|
2068
|
+
mimeType?: string | undefined;
|
|
2069
|
+
_meta?: ({} & {
|
|
2070
|
+
[key: string]: unknown;
|
|
2071
|
+
}) | undefined;
|
|
2072
|
+
};
|
|
2073
|
+
_meta?: ({} & {
|
|
2074
|
+
[key: string]: unknown;
|
|
2075
|
+
}) | undefined;
|
|
1955
2076
|
};
|
|
1956
2077
|
}[];
|
|
1957
2078
|
};
|
|
1958
2079
|
|
|
2080
|
+
function messages(messages: Array<string>): {
|
|
2081
|
+
messages: {
|
|
2082
|
+
role: "user";
|
|
2083
|
+
content: {
|
|
2084
|
+
type: "text";
|
|
2085
|
+
text: string;
|
|
2086
|
+
};
|
|
2087
|
+
}[];
|
|
2088
|
+
};
|
|
2089
|
+
/**
|
|
2090
|
+
*
|
|
2091
|
+
* @deprecated Use `mix` instead
|
|
2092
|
+
*/
|
|
1959
2093
|
function various(messages: Array<GetPromptResult["messages"][number]["content"]>): {
|
|
1960
2094
|
messages: {
|
|
1961
2095
|
role: "user";
|
package/src/types/index.d.ts.map
CHANGED
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
null,
|
|
79
79
|
null
|
|
80
80
|
],
|
|
81
|
-
"mappings": ";;;;;cAiLaA,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aCg0CyBC,KAAKA;aDn7CFC,aAAaA;;aC08CHC,kBAAkBA;aAGrBC,eAAeA;aAvBZC,kBAAkBA;aAUKC,UAAUA;aAmBzBC,0BAA0BA;aAGjCC,mBAAmBA;aAY9BC,QAAQA;aAYJC,YAAYA;aAlDVC,UAAUA;aAwDZC,YAAYA;aAGRC,gBAAgBA;aAGjBC,eAAeA;aAGbC,iBAAiBA;aAMPC,2BAA2BA;aAHnCC,mBAAmBA;aAhDxBC,cAAcA;MCj/C1DC,UAAUA;;;;;MAyCVC,aAAaA;;;;;;;;;;;;;;MAcbC,WAAWA;;;;;;;MAOlBC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgBtBC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BlBrB,qBAAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyIrBG,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA0iB2BrC,kBAAkBA;MAGrBC,eAAeA;MAyDduD,gBAAgBA;MAGpBC,YAAYA",
|
|
82
82
|
"ignoreList": []
|
|
83
83
|
}
|
package/src/utils/index.js
CHANGED
|
@@ -172,6 +172,85 @@ export const prompt = {
|
|
|
172
172
|
],
|
|
173
173
|
};
|
|
174
174
|
},
|
|
175
|
+
/**
|
|
176
|
+
* Alias for message
|
|
177
|
+
* @param {string} text
|
|
178
|
+
*/
|
|
179
|
+
text(text) {
|
|
180
|
+
return {
|
|
181
|
+
messages: [
|
|
182
|
+
{
|
|
183
|
+
role: 'user',
|
|
184
|
+
content: {
|
|
185
|
+
type: 'text',
|
|
186
|
+
text,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
*
|
|
194
|
+
* @param {"audio" | "image"} type
|
|
195
|
+
* @param {string} data
|
|
196
|
+
* @param {string} mime_type
|
|
197
|
+
*/
|
|
198
|
+
media(type, data, mime_type) {
|
|
199
|
+
return {
|
|
200
|
+
messages: [
|
|
201
|
+
{
|
|
202
|
+
role: 'user',
|
|
203
|
+
content: {
|
|
204
|
+
type,
|
|
205
|
+
data,
|
|
206
|
+
mimeType: mime_type,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
/**
|
|
213
|
+
* @param {EmbeddedResource["resource"]} resource
|
|
214
|
+
*/
|
|
215
|
+
resource(resource) {
|
|
216
|
+
return {
|
|
217
|
+
messages: [
|
|
218
|
+
{
|
|
219
|
+
role: 'user',
|
|
220
|
+
content: {
|
|
221
|
+
type: 'resource',
|
|
222
|
+
resource,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @param {Omit<ResourceLink, "type">} resource
|
|
231
|
+
*/
|
|
232
|
+
resourceLink(resource) {
|
|
233
|
+
return {
|
|
234
|
+
messages: [
|
|
235
|
+
{
|
|
236
|
+
role: 'user',
|
|
237
|
+
content: {
|
|
238
|
+
type: 'resource_link',
|
|
239
|
+
...resource,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
* @param {Array<GetPromptResult>} messages
|
|
248
|
+
*/
|
|
249
|
+
mix(messages) {
|
|
250
|
+
return {
|
|
251
|
+
messages: messages.flatMap((m) => m.messages),
|
|
252
|
+
};
|
|
253
|
+
},
|
|
175
254
|
/**
|
|
176
255
|
*
|
|
177
256
|
* @param {Array<string>} messages
|
|
@@ -194,6 +273,7 @@ export const prompt = {
|
|
|
194
273
|
*
|
|
195
274
|
* @param {Array<GetPromptResult["messages"][number]["content"]>} messages
|
|
196
275
|
* @returns
|
|
276
|
+
* @deprecated Use `mix` instead
|
|
197
277
|
*/
|
|
198
278
|
various(messages) {
|
|
199
279
|
return {
|