@caplets/core 0.18.5 → 0.18.7
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/dist/auth.d.ts +2 -2
- package/dist/caplet-sets.d.ts +1 -1
- package/dist/cli-tools.d.ts +1 -1
- package/dist/{completion-DRPTunQd.js → completion-B9niw4HY.js} +1 -1
- package/dist/downstream.d.ts +1 -1
- package/dist/generated-tool-input-schema.d.ts +4 -4
- package/dist/graphql.d.ts +1 -1
- package/dist/http-actions.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +29 -29
- package/dist/native.js +1 -1
- package/dist/openapi.d.ts +1 -1
- package/dist/{options-BlNyqF_E.js → options-CY6p-C9L.js} +332 -41
- package/dist/result-content.d.ts +25 -5
- package/dist/runtime.d.ts +1 -1
- package/dist/serve/session.d.ts +2 -2
- package/dist/tool-search.d.ts +1 -1
- package/dist/tools.d.ts +3 -2
- package/package.json +4 -4
package/dist/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AuthResult, type OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth
|
|
2
|
-
import type { OAuthClientInformationMixed, OAuthClientMetadata, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth
|
|
1
|
+
import { type AuthResult, type OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth";
|
|
2
|
+
import type { OAuthClientInformationMixed, OAuthClientMetadata, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth";
|
|
3
3
|
import { type StoredOAuthTokenBundle } from "./auth/store";
|
|
4
4
|
import type { CapletServerConfig } from "./config";
|
|
5
5
|
import { CapletsError } from "./errors";
|
package/dist/caplet-sets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types
|
|
1
|
+
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types";
|
|
2
2
|
import { type CapletSetConfig } from "./config";
|
|
3
3
|
import { type CompactTool } from "./downstream";
|
|
4
4
|
import { ServerRegistry } from "./registry";
|
package/dist/cli-tools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types
|
|
1
|
+
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types";
|
|
2
2
|
import type { CliToolsConfig } from "./config";
|
|
3
3
|
import type { CompactTool } from "./downstream";
|
|
4
4
|
import type { ServerRegistry } from "./registry";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as resolveCapletsRoot, Et as resolveProjectConfigPath,
|
|
1
|
+
import { Ct as resolveCapletsRoot, Et as resolveProjectConfigPath, Pt as CapletsError, Rt as __exportAll, St as DEFAULT_COMPLETION_CACHE_DIR, gt as loadConfigWithSources, wt as resolveConfigPath, xt as DEFAULT_AUTH_DIR } from "./options-CY6p-C9L.js";
|
|
2
2
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
package/dist/downstream.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Prompt, type Resource, type ResourceTemplate as McpResourceTemplate, type CompatibilityCallToolResult, type Tool } from "@modelcontextprotocol/sdk/types
|
|
1
|
+
import { type Prompt, type Resource, type ResourceTemplate as McpResourceTemplate, type CompatibilityCallToolResult, type Tool } from "@modelcontextprotocol/sdk/types";
|
|
2
2
|
import type { CapletServerConfig } from "./config";
|
|
3
3
|
import type { ServerRegistry } from "./registry";
|
|
4
4
|
export type CompactTool = {
|
|
@@ -49,11 +49,11 @@ export declare function generatedToolInputSchemaForCaplet(caplet: CapletSchemaBa
|
|
|
49
49
|
arguments: z.ZodOptional<z.ZodObject<{}, z.core.$catchall<z.ZodAny>>>;
|
|
50
50
|
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
51
51
|
operation: z.ZodEnum<{
|
|
52
|
-
get_caplet: "get_caplet";
|
|
53
|
-
check_backend: "check_backend";
|
|
54
52
|
list_tools: "list_tools";
|
|
55
53
|
search_tools: "search_tools";
|
|
56
54
|
get_tool: "get_tool";
|
|
55
|
+
check_backend: "check_backend";
|
|
56
|
+
get_caplet: "get_caplet";
|
|
57
57
|
call_tool: "call_tool";
|
|
58
58
|
}>;
|
|
59
59
|
}, z.core.$strict>;
|
|
@@ -64,11 +64,11 @@ export declare const generatedToolInputSchema: z.ZodObject<{
|
|
|
64
64
|
arguments: z.ZodOptional<z.ZodObject<{}, z.core.$catchall<z.ZodAny>>>;
|
|
65
65
|
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
66
66
|
operation: z.ZodEnum<{
|
|
67
|
-
get_caplet: "get_caplet";
|
|
68
|
-
check_backend: "check_backend";
|
|
69
67
|
list_tools: "list_tools";
|
|
70
68
|
search_tools: "search_tools";
|
|
71
69
|
get_tool: "get_tool";
|
|
70
|
+
check_backend: "check_backend";
|
|
71
|
+
get_caplet: "get_caplet";
|
|
72
72
|
call_tool: "call_tool";
|
|
73
73
|
}>;
|
|
74
74
|
}, z.core.$strict>;
|
package/dist/graphql.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types
|
|
1
|
+
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types";
|
|
2
2
|
import type { GraphQlEndpointConfig } from "./config";
|
|
3
3
|
import type { CompactTool } from "./downstream";
|
|
4
4
|
import type { ServerRegistry } from "./registry";
|
package/dist/http-actions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types
|
|
1
|
+
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types";
|
|
2
2
|
import type { HttpApiConfig } from "./config";
|
|
3
3
|
import type { CompactTool } from "./downstream";
|
|
4
4
|
import type { ServerRegistry } from "./registry";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export { runCli, createProgram } from "./cli";
|
|
|
3
3
|
export { parseConfig, loadConfig } from "./config";
|
|
4
4
|
export { capabilityDescription, ServerRegistry } from "./registry";
|
|
5
5
|
export { generatedToolInputSchema, handleServerTool } from "./tools";
|
|
6
|
+
export { hasRenderableStructuredContent, markdownCallToolResultContent, markdownStructuredContent, } from "./result-content";
|
|
7
|
+
export type { ResultMarkdownContext } from "./result-content";
|
|
6
8
|
export { serveCaplets, serveHttp, serveResolvedCaplets, serveStdio } from "./serve";
|
|
7
9
|
export type { HttpServeOptions, RawServeOptions, ServeOptions, StdioServeOptions } from "./serve";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as assertCompleteRequestPrompt, A as CreateMessageResultSchema, At as
|
|
1
|
+
import { $ as assertCompleteRequestPrompt, A as CreateMessageResultSchema, At as hasRenderableStructuredContent, B as JSONRPCMessageSchema, Bt as __toESM, C as AjvJsonSchemaValidator, Ct as resolveCapletsRoot, D as CallToolRequestSchema, Dt as discoverCapletFiles, E as toJsonSchemaCompat, Et as resolveProjectConfigPath, F as EmptyResultSchema, Ft as redactSecrets, G as ListRootsResultSchema, H as ListPromptsRequestSchema, I as ErrorCode, It as toSafeError, J as McpError, K as ListToolsRequestSchema, L as GetPromptRequestSchema, Lt as __commonJSMin, M as CreateTaskResultSchema, Mt as markdownStructuredContent, Nt as CAPLETS_ERROR_CODES, O as CallToolResultSchema, Ot as validateCapletFile, P as ElicitResultSchema, Pt as CapletsError, R as InitializeRequestSchema, S as assertToolsCallTaskCapability, T as mergeCapabilities, Tt as resolveProjectCapletsRoot, U as ListResourceTemplatesRequestSchema, V as LATEST_PROTOCOL_VERSION, W as ListResourcesRequestSchema, X as SUPPORTED_PROTOCOL_VERSIONS, Y as ReadResourceRequestSchema, Z as SetLevelRequestSchema, _t as loadGlobalConfig, a as resolveCapletsServer, at as getLiteralValue, bt as parseConfig, c as ServerRegistry, ct as getSchemaDescription, d as runOAuthFlow, dt as normalizeObjectSchema, et as assertCompleteRequestResourceTemplate, f as startGenericOAuthFlow, ft as objectFromShape, g as readTokenBundle, gt as loadConfigWithSources, h as isTokenBundleExpired, ht as loadConfig, i as resolveCapletsMode, it as isJSONRPCResultResponse, j as CreateMessageResultWithToolsSchema, jt as markdownCallToolResultContent, k as CompleteRequestSchema, kt as SERVER_ID_PATTERN, l as capabilityDescription, lt as isSchemaOptional, m as deleteTokenBundle, mt as safeParseAsync, nt as isJSONRPCErrorResponse, o as CapletsEngine, ot as getObjectShape, p as startOAuthFlow, pt as safeParse, q as LoggingLevelSchema, r as parseServerBaseUrl, rt as isJSONRPCRequest, s as handleServerTool, st as getParseErrorMessage, t as controlUrlForBase, tt as isInitializeRequest, u as runGenericOAuthFlow, ut as isZ4Schema, v as ReadBuffer, vt as loadLocalOverlayConfigWithSources, w as Protocol, wt as resolveConfigPath, x as assertClientRequestTaskCapability, y as serializeMessage, yt as loadProjectConfig, z as InitializedNotificationSchema, zt as __require } from "./options-CY6p-C9L.js";
|
|
2
2
|
import { A as url, C as object, D as string, b as literal, d as ZodOptional, o as generatedToolInputSchema, s as generatedToolInputSchemaForCaplet } from "./generated-tool-input-schema-BYoyY-l-.js";
|
|
3
|
-
import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-
|
|
3
|
+
import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-B9niw4HY.js";
|
|
4
4
|
import { accessSync, chmodSync, closeSync, constants, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, isAbsolute, join, parse, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
@@ -1320,7 +1320,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
|
|
|
1320
1320
|
} };
|
|
1321
1321
|
//#endregion
|
|
1322
1322
|
//#region package.json
|
|
1323
|
-
var version = "0.18.
|
|
1323
|
+
var version = "0.18.7";
|
|
1324
1324
|
//#endregion
|
|
1325
1325
|
//#region src/serve/session.ts
|
|
1326
1326
|
var CapletsMcpSession = class {
|
|
@@ -5420,7 +5420,7 @@ function redactRemoteMessage(message) {
|
|
|
5420
5420
|
return String(redactSecrets(message)).replace(/\b(authorization\s*:\s*(?:basic|bearer)\s+)[^\s,;]+/giu, "$1[REDACTED]").replace(/\b((?:access_)?token=)[^\s,;]+/giu, "$1[REDACTED]").replace(/\b((?:token|secret|authorization|auth|api[-_]?key|password|credential|clientsecret|client_secret|code|refresh(?:_token)?)\s*[=:]\s*)[^\s,;]+/giu, "$1[REDACTED]");
|
|
5421
5421
|
}
|
|
5422
5422
|
//#endregion
|
|
5423
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
5423
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/compose.js
|
|
5424
5424
|
var compose = (middleware, onError, onNotFound) => {
|
|
5425
5425
|
return (context, next) => {
|
|
5426
5426
|
let index = -1;
|
|
@@ -5451,7 +5451,7 @@ var compose = (middleware, onError, onNotFound) => {
|
|
|
5451
5451
|
};
|
|
5452
5452
|
};
|
|
5453
5453
|
//#endregion
|
|
5454
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
5454
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/http-exception.js
|
|
5455
5455
|
var HTTPException = class extends Error {
|
|
5456
5456
|
res;
|
|
5457
5457
|
status;
|
|
@@ -5479,10 +5479,10 @@ var HTTPException = class extends Error {
|
|
|
5479
5479
|
}
|
|
5480
5480
|
};
|
|
5481
5481
|
//#endregion
|
|
5482
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
5482
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/request/constants.js
|
|
5483
5483
|
var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
|
|
5484
5484
|
//#endregion
|
|
5485
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
5485
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/body.js
|
|
5486
5486
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
5487
5487
|
const { all = false, dot = false } = options;
|
|
5488
5488
|
const contentType = (request instanceof HonoRequest ? request.raw.headers : request.headers).get("Content-Type");
|
|
@@ -5530,7 +5530,7 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
5530
5530
|
});
|
|
5531
5531
|
};
|
|
5532
5532
|
//#endregion
|
|
5533
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
5533
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/url.js
|
|
5534
5534
|
var splitPath = (path) => {
|
|
5535
5535
|
const paths = path.split("/");
|
|
5536
5536
|
if (paths[0] === "") paths.shift();
|
|
@@ -5694,7 +5694,7 @@ var getQueryParams = (url, key) => {
|
|
|
5694
5694
|
};
|
|
5695
5695
|
var decodeURIComponent_ = decodeURIComponent;
|
|
5696
5696
|
//#endregion
|
|
5697
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
5697
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/request.js
|
|
5698
5698
|
var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
|
|
5699
5699
|
var HonoRequest = class {
|
|
5700
5700
|
/**
|
|
@@ -5966,7 +5966,7 @@ var HonoRequest = class {
|
|
|
5966
5966
|
}
|
|
5967
5967
|
};
|
|
5968
5968
|
//#endregion
|
|
5969
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
5969
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/html.js
|
|
5970
5970
|
var HtmlEscapedCallbackPhase = {
|
|
5971
5971
|
Stringify: 1,
|
|
5972
5972
|
BeforeStream: 2,
|
|
@@ -5996,7 +5996,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
5996
5996
|
else return resStr;
|
|
5997
5997
|
};
|
|
5998
5998
|
//#endregion
|
|
5999
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
5999
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/context.js
|
|
6000
6000
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
6001
6001
|
var setDefaultContentType = (contentType, headers) => {
|
|
6002
6002
|
return {
|
|
@@ -6357,7 +6357,7 @@ var Context = class {
|
|
|
6357
6357
|
};
|
|
6358
6358
|
};
|
|
6359
6359
|
//#endregion
|
|
6360
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
6360
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router.js
|
|
6361
6361
|
var METHODS = [
|
|
6362
6362
|
"get",
|
|
6363
6363
|
"post",
|
|
@@ -6369,10 +6369,10 @@ var METHODS = [
|
|
|
6369
6369
|
var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
6370
6370
|
var UnsupportedPathError = class extends Error {};
|
|
6371
6371
|
//#endregion
|
|
6372
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
6372
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/constants.js
|
|
6373
6373
|
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
6374
6374
|
//#endregion
|
|
6375
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
6375
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/hono-base.js
|
|
6376
6376
|
var notFoundHandler = (c) => {
|
|
6377
6377
|
return c.text("404 Not Found", 404);
|
|
6378
6378
|
};
|
|
@@ -6706,7 +6706,7 @@ var Hono$1 = class _Hono {
|
|
|
6706
6706
|
};
|
|
6707
6707
|
};
|
|
6708
6708
|
//#endregion
|
|
6709
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
6709
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
6710
6710
|
var emptyParam = [];
|
|
6711
6711
|
function match(method, path) {
|
|
6712
6712
|
const matchers = this.buildAllMatchers();
|
|
@@ -6723,7 +6723,7 @@ function match(method, path) {
|
|
|
6723
6723
|
return match2(method, path);
|
|
6724
6724
|
}
|
|
6725
6725
|
//#endregion
|
|
6726
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
6726
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
6727
6727
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
6728
6728
|
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
6729
6729
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
@@ -6802,7 +6802,7 @@ var Node$1 = class _Node {
|
|
|
6802
6802
|
}
|
|
6803
6803
|
};
|
|
6804
6804
|
//#endregion
|
|
6805
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
6805
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
6806
6806
|
var Trie = class {
|
|
6807
6807
|
#context = { varIndex: 0 };
|
|
6808
6808
|
#root = new Node$1();
|
|
@@ -6860,7 +6860,7 @@ var Trie = class {
|
|
|
6860
6860
|
}
|
|
6861
6861
|
};
|
|
6862
6862
|
//#endregion
|
|
6863
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
6863
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
6864
6864
|
var nullMatcher = [
|
|
6865
6865
|
/^$/,
|
|
6866
6866
|
[],
|
|
@@ -6991,7 +6991,7 @@ var RegExpRouter = class {
|
|
|
6991
6991
|
}
|
|
6992
6992
|
};
|
|
6993
6993
|
//#endregion
|
|
6994
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
6994
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/smart-router/router.js
|
|
6995
6995
|
var SmartRouter = class {
|
|
6996
6996
|
name = "SmartRouter";
|
|
6997
6997
|
#routers = [];
|
|
@@ -7038,7 +7038,7 @@ var SmartRouter = class {
|
|
|
7038
7038
|
}
|
|
7039
7039
|
};
|
|
7040
7040
|
//#endregion
|
|
7041
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7041
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/trie-router/node.js
|
|
7042
7042
|
var emptyParams = /* @__PURE__ */ Object.create(null);
|
|
7043
7043
|
var hasChildren = (children) => {
|
|
7044
7044
|
for (const _ in children) return true;
|
|
@@ -7191,7 +7191,7 @@ var Node = class _Node {
|
|
|
7191
7191
|
}
|
|
7192
7192
|
};
|
|
7193
7193
|
//#endregion
|
|
7194
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7194
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/trie-router/router.js
|
|
7195
7195
|
var TrieRouter = class {
|
|
7196
7196
|
name = "TrieRouter";
|
|
7197
7197
|
#node;
|
|
@@ -7211,7 +7211,7 @@ var TrieRouter = class {
|
|
|
7211
7211
|
}
|
|
7212
7212
|
};
|
|
7213
7213
|
//#endregion
|
|
7214
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7214
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/hono.js
|
|
7215
7215
|
var Hono = class extends Hono$1 {
|
|
7216
7216
|
/**
|
|
7217
7217
|
* Creates an instance of the Hono class.
|
|
@@ -7252,7 +7252,7 @@ object({
|
|
|
7252
7252
|
client_secret: string().optional()
|
|
7253
7253
|
});
|
|
7254
7254
|
//#endregion
|
|
7255
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7255
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/stream.js
|
|
7256
7256
|
var StreamingApi = class {
|
|
7257
7257
|
writer;
|
|
7258
7258
|
encoder;
|
|
@@ -7325,7 +7325,7 @@ var StreamingApi = class {
|
|
|
7325
7325
|
}
|
|
7326
7326
|
};
|
|
7327
7327
|
//#endregion
|
|
7328
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7328
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/helper/streaming/sse.js
|
|
7329
7329
|
var SSEStreamingApi = class extends StreamingApi {
|
|
7330
7330
|
constructor(writable, readable) {
|
|
7331
7331
|
super(writable, readable);
|
|
@@ -7349,7 +7349,7 @@ var SSEStreamingApi = class extends StreamingApi {
|
|
|
7349
7349
|
}
|
|
7350
7350
|
};
|
|
7351
7351
|
//#endregion
|
|
7352
|
-
//#region ../../node_modules/.pnpm/@hono+mcp@0.3.0_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__hono-rate-limiter@0.5.3_hono@4.12.
|
|
7352
|
+
//#region ../../node_modules/.pnpm/@hono+mcp@0.3.0_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__hono-rate-limiter@0.5.3_hono@4.12.23__hono@4.12.23_zod@4.4.3/node_modules/@hono/mcp/dist/index.js
|
|
7353
7353
|
let isOldBunVersion = () => {
|
|
7354
7354
|
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
7355
7355
|
if (version === void 0) return false;
|
|
@@ -7790,7 +7790,7 @@ var StreamableHTTPTransport = class {
|
|
|
7790
7790
|
}
|
|
7791
7791
|
};
|
|
7792
7792
|
//#endregion
|
|
7793
|
-
//#region ../../node_modules/.pnpm/@hono+node-server@2.0.
|
|
7793
|
+
//#region ../../node_modules/.pnpm/@hono+node-server@2.0.4_hono@4.12.23/node_modules/@hono/node-server/dist/index.mjs
|
|
7794
7794
|
var RequestError = class extends Error {
|
|
7795
7795
|
constructor(message, options) {
|
|
7796
7796
|
super(message, options);
|
|
@@ -8713,7 +8713,7 @@ const serve = (options, listeningListener) => {
|
|
|
8713
8713
|
return server;
|
|
8714
8714
|
};
|
|
8715
8715
|
//#endregion
|
|
8716
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8716
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/utils/color.js
|
|
8717
8717
|
function getColorEnabled() {
|
|
8718
8718
|
const { process, Deno } = globalThis;
|
|
8719
8719
|
return !(typeof Deno?.noColor === "boolean" ? Deno.noColor : process !== void 0 ? "NO_COLOR" in process?.env : false);
|
|
@@ -8730,7 +8730,7 @@ async function getColorEnabledAsync() {
|
|
|
8730
8730
|
})() : !getColorEnabled());
|
|
8731
8731
|
}
|
|
8732
8732
|
//#endregion
|
|
8733
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8733
|
+
//#region ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/middleware/logger/index.js
|
|
8734
8734
|
var humanize = (times) => {
|
|
8735
8735
|
const [delimiter, separator] = [",", "."];
|
|
8736
8736
|
return times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + delimiter)).join(separator);
|
|
@@ -10737,4 +10737,4 @@ function writeAddResult(writeOut, label, result) {
|
|
|
10737
10737
|
writeOut(result.text);
|
|
10738
10738
|
}
|
|
10739
10739
|
//#endregion
|
|
10740
|
-
export { CapletsRuntime, ServerRegistry, capabilityDescription, createProgram, generatedToolInputSchema, handleServerTool, loadConfig, parseConfig, runCli, serveCaplets, serveHttp, serveResolvedCaplets, serveStdio };
|
|
10740
|
+
export { CapletsRuntime, ServerRegistry, capabilityDescription, createProgram, generatedToolInputSchema, handleServerTool, hasRenderableStructuredContent, loadConfig, markdownCallToolResultContent, markdownStructuredContent, parseConfig, runCli, serveCaplets, serveHttp, serveResolvedCaplets, serveStdio };
|
package/dist/native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as ToolListChangedNotificationSchema, _ as StreamableHTTPClientTransport, a as resolveCapletsServer, b as Client, bt as parseConfig, i as resolveCapletsMode,
|
|
1
|
+
import { Pt as CapletsError, Q as ToolListChangedNotificationSchema, _ as StreamableHTTPClientTransport, a as resolveCapletsServer, b as Client, bt as parseConfig, i as resolveCapletsMode, l as capabilityDescription, n as mcpUrlForBase, o as CapletsEngine, vt as loadLocalOverlayConfigWithSources } from "./options-CY6p-C9L.js";
|
|
2
2
|
import { a as generatedToolInputJsonSchemaForCaplet, i as generatedToolInputJsonSchema, l as operations, o as generatedToolInputSchema } from "./generated-tool-input-schema-BYoyY-l-.js";
|
|
3
3
|
//#region src/native/options.ts
|
|
4
4
|
const DEFAULT_POLL_INTERVAL_MS = 3e4;
|
package/dist/openapi.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types
|
|
1
|
+
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types";
|
|
2
2
|
import type { OpenApiEndpointConfig } from "./config";
|
|
3
3
|
import type { CompactTool } from "./downstream";
|
|
4
4
|
import type { ServerRegistry } from "./registry";
|
|
@@ -108,13 +108,26 @@ function toSafeError(error, fallback = "INTERNAL_ERROR") {
|
|
|
108
108
|
}
|
|
109
109
|
function errorResult(error, fallback) {
|
|
110
110
|
const safe = toSafeError(error, fallback);
|
|
111
|
+
const structuredContent = { error: safe };
|
|
111
112
|
return {
|
|
112
113
|
isError: true,
|
|
113
114
|
content: [{
|
|
114
115
|
type: "text",
|
|
115
|
-
text:
|
|
116
|
+
text: [
|
|
117
|
+
"# Error",
|
|
118
|
+
"",
|
|
119
|
+
`## ${safe.code}`,
|
|
120
|
+
"",
|
|
121
|
+
safe.message,
|
|
122
|
+
"",
|
|
123
|
+
"## Details",
|
|
124
|
+
"",
|
|
125
|
+
"```json",
|
|
126
|
+
JSON.stringify(safe, null, 2),
|
|
127
|
+
"```"
|
|
128
|
+
].join("\n")
|
|
116
129
|
}],
|
|
117
|
-
structuredContent
|
|
130
|
+
structuredContent
|
|
118
131
|
};
|
|
119
132
|
}
|
|
120
133
|
//#endregion
|
|
@@ -125,33 +138,277 @@ function textContent(text) {
|
|
|
125
138
|
text
|
|
126
139
|
}] : [];
|
|
127
140
|
}
|
|
128
|
-
function
|
|
129
|
-
return
|
|
141
|
+
function markdownStructuredContent(value, context = {}) {
|
|
142
|
+
return textContent(renderStructuredMarkdown(value, context));
|
|
130
143
|
}
|
|
131
|
-
function
|
|
132
|
-
const
|
|
133
|
-
|
|
144
|
+
function markdownCallToolResultContent(result, context = {}) {
|
|
145
|
+
const downstreamText = textBlocksToString(result.content);
|
|
146
|
+
const structuredContent = result.structuredContent;
|
|
147
|
+
const hasStructured = hasRenderableStructuredContent(structuredContent);
|
|
148
|
+
if (context.backend === "mcp" && hasStructured) {
|
|
149
|
+
const renderedStructured = markdownStructuredContent(structuredContent, context)[0]?.text;
|
|
150
|
+
if (downstreamText && downstreamText === renderedStructured) return textContent(downstreamText);
|
|
151
|
+
return [...result.content ?? [], {
|
|
152
|
+
type: "text",
|
|
153
|
+
text: [
|
|
154
|
+
"## Structured Content",
|
|
155
|
+
"",
|
|
156
|
+
jsonFence(structuredContent)
|
|
157
|
+
].join("\n")
|
|
158
|
+
}];
|
|
159
|
+
}
|
|
160
|
+
if (hasStructured) return markdownStructuredContent(structuredContent, {
|
|
161
|
+
...context,
|
|
162
|
+
isError: context.isError ?? result.isError
|
|
163
|
+
});
|
|
164
|
+
if (downstreamText) return textContent(downstreamText);
|
|
165
|
+
return textContent(renderStructuredMarkdown(result, context));
|
|
166
|
+
}
|
|
167
|
+
function hasRenderableStructuredContent(value) {
|
|
168
|
+
if (!isRecord(value)) return false;
|
|
169
|
+
return Object.keys(value).some((key) => key !== "caplets" && key !== "elapsedMs");
|
|
134
170
|
}
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
171
|
+
function renderStructuredMarkdown(value, context) {
|
|
172
|
+
const title = markdownTitle(context);
|
|
173
|
+
if (isDiscoveryWrapper(value)) return renderDiscoveryWrapper(value, context, title);
|
|
174
|
+
if (context.isError || isErrorStructuredContent(value)) return renderErrorMarkdown(value, title);
|
|
175
|
+
if (context.backend === "cli" || isCliResult(value)) return renderCliMarkdown(value, title);
|
|
176
|
+
if (context.backend === "graphql" && isHttpLikeResult(value) || isGraphQlHttpResult(value)) return renderGraphQlMarkdown(value, title);
|
|
177
|
+
if (isHttpLikeResult(value)) return renderHttpMarkdown(value, title);
|
|
178
|
+
return [
|
|
179
|
+
title,
|
|
180
|
+
"",
|
|
181
|
+
"## Result",
|
|
182
|
+
"",
|
|
183
|
+
jsonFence(value)
|
|
184
|
+
].join("\n");
|
|
185
|
+
}
|
|
186
|
+
function markdownTitle(context) {
|
|
187
|
+
if (context.title) return `# ${context.title}`;
|
|
188
|
+
const parts = [context.operation, context.tool ?? context.uri ?? context.prompt].filter((part) => Boolean(part));
|
|
189
|
+
return parts.length > 0 ? `# ${parts.join(" ")}` : "# Result";
|
|
190
|
+
}
|
|
191
|
+
function renderHttpMarkdown(value, title) {
|
|
192
|
+
const record = asRecord$2(value) ?? {};
|
|
193
|
+
const lines = [
|
|
194
|
+
title,
|
|
195
|
+
"",
|
|
196
|
+
"## Response",
|
|
197
|
+
""
|
|
198
|
+
];
|
|
199
|
+
const status = typeof record.status === "number" ? record.status : void 0;
|
|
200
|
+
const statusText = typeof record.statusText === "string" ? record.statusText : void 0;
|
|
201
|
+
if (status !== void 0 || statusText) lines.push(`- **Status:** \`${[status, statusText].filter(Boolean).join(" ")}\``);
|
|
202
|
+
if (typeof record.elapsedMs === "number") lines.push(`- **Elapsed:** \`${record.elapsedMs} ms\``);
|
|
203
|
+
lines.push("", "## Headers", "", jsonFence(record.headers ?? {}), "", "## Body", "", renderBodyValue(record.body));
|
|
204
|
+
const additional = omitKeys(record, [
|
|
205
|
+
"status",
|
|
206
|
+
"statusText",
|
|
207
|
+
"headers",
|
|
208
|
+
"body",
|
|
209
|
+
"elapsedMs"
|
|
210
|
+
]);
|
|
211
|
+
if (Object.keys(additional).length > 0) lines.push("", "## Additional Fields", "", jsonFence(additional));
|
|
212
|
+
return lines.join("\n");
|
|
213
|
+
}
|
|
214
|
+
function renderGraphQlMarkdown(value, title) {
|
|
215
|
+
const record = asRecord$2(value) ?? {};
|
|
216
|
+
const body = asRecord$2(record.body);
|
|
217
|
+
if (!body || !("data" in body) && !("errors" in body)) return renderHttpMarkdown(value, title);
|
|
218
|
+
const lines = [
|
|
219
|
+
title,
|
|
220
|
+
"",
|
|
221
|
+
"## Response",
|
|
222
|
+
""
|
|
223
|
+
];
|
|
224
|
+
const status = typeof record.status === "number" ? record.status : void 0;
|
|
225
|
+
const statusText = typeof record.statusText === "string" ? record.statusText : void 0;
|
|
226
|
+
if (status !== void 0 || statusText) lines.push(`- **Status:** \`${[status, statusText].filter(Boolean).join(" ")}\``);
|
|
227
|
+
if (typeof record.elapsedMs === "number") lines.push(`- **Elapsed:** \`${record.elapsedMs} ms\``);
|
|
228
|
+
if ("data" in body) lines.push("", "## Data", "", jsonFence(body.data));
|
|
229
|
+
if ("errors" in body) lines.push("", "## Errors", "", jsonFence(body.errors));
|
|
230
|
+
lines.push("", "## Headers", "", jsonFence(record.headers ?? {}), "", "## Full Body", "", jsonFence(record.body));
|
|
231
|
+
const additional = omitKeys(record, [
|
|
232
|
+
"status",
|
|
233
|
+
"statusText",
|
|
234
|
+
"headers",
|
|
235
|
+
"body",
|
|
236
|
+
"elapsedMs"
|
|
237
|
+
]);
|
|
238
|
+
if (Object.keys(additional).length > 0) lines.push("", "## Additional Fields", "", jsonFence(additional));
|
|
239
|
+
return lines.join("\n");
|
|
139
240
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
const
|
|
241
|
+
function renderCliMarkdown(value, title) {
|
|
242
|
+
const record = asRecord$2(value) ?? {};
|
|
243
|
+
const lines = [
|
|
244
|
+
title,
|
|
245
|
+
"",
|
|
246
|
+
"## Command Result",
|
|
247
|
+
""
|
|
248
|
+
];
|
|
249
|
+
if ("exitCode" in record) lines.push(`- **Exit code:** \`${String(record.exitCode)}\``);
|
|
250
|
+
if ("signal" in record) lines.push(`- **Signal:** \`${String(record.signal)}\``);
|
|
251
|
+
if (typeof record.elapsedMs === "number") lines.push(`- **Elapsed:** \`${record.elapsedMs} ms\``);
|
|
252
|
+
lines.push("", "## stdout", "", textFenceOrEmpty(record.stdout, "No stdout."));
|
|
253
|
+
lines.push("", "## stderr", "", textFenceOrEmpty(record.stderr, "No stderr."));
|
|
254
|
+
if ("json" in record) lines.push("", "## Parsed JSON", "", jsonFence(record.json));
|
|
255
|
+
if ("jsonParseError" in record) lines.push("", "## JSON Parse Error", "", jsonFence(record.jsonParseError));
|
|
256
|
+
const additional = omitKeys(record, [
|
|
257
|
+
"exitCode",
|
|
258
|
+
"signal",
|
|
259
|
+
"stdout",
|
|
260
|
+
"stderr",
|
|
261
|
+
"elapsedMs",
|
|
262
|
+
"json",
|
|
263
|
+
"jsonParseError"
|
|
264
|
+
]);
|
|
265
|
+
if (Object.keys(additional).length > 0) lines.push("", "## Additional Fields", "", jsonFence(additional));
|
|
266
|
+
return lines.join("\n");
|
|
267
|
+
}
|
|
268
|
+
function renderDiscoveryWrapper(value, context, title) {
|
|
269
|
+
const result = asRecord$2(value.result);
|
|
270
|
+
const lines = [title, ""];
|
|
271
|
+
if (context.operation === "list_tools" || context.operation === "search_tools") lines.push("## Tools", "", renderNamedList(arrayValue(result?.tools), "tool"), "");
|
|
272
|
+
else if (context.operation === "list_resources" || context.operation === "search_resources") lines.push("## Resources", "", renderNamedList(arrayValue(result?.resources ?? result?.matches), "uri"), "");
|
|
273
|
+
else if (context.operation === "list_resource_templates") lines.push("## Resource Templates", "", renderNamedList(arrayValue(result?.resourceTemplates), "uriTemplate"), "");
|
|
274
|
+
else if (context.operation === "list_prompts" || context.operation === "search_prompts") lines.push("## Prompts", "", renderNamedList(arrayValue(result?.prompts), "prompt"), "");
|
|
275
|
+
else if (context.operation === "get_tool") lines.push("## Tool", "", renderToolSummary(asRecord$2(result?.tool)), "");
|
|
276
|
+
else if (context.operation === "check_backend") lines.push("## Backend Status", "", renderBackendStatus(result), "");
|
|
277
|
+
else if (context.operation === "get_caplet") lines.push("## Caplet", "", renderCapletSummary(result), "");
|
|
278
|
+
lines.push("## Full Result", "", jsonFence(value.result));
|
|
279
|
+
if (value.caplets !== void 0) lines.push("", "## Caplets Metadata", "", jsonFence(value.caplets));
|
|
280
|
+
return lines.join("\n");
|
|
281
|
+
}
|
|
282
|
+
function renderErrorMarkdown(value, title) {
|
|
283
|
+
const error = asRecord$2(asRecord$2(value)?.error) ?? asRecord$2(value);
|
|
284
|
+
const code = typeof error?.code === "string" ? error.code : "Error";
|
|
285
|
+
const message = typeof error?.message === "string" ? error.message : "Tool call failed.";
|
|
143
286
|
return [
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
287
|
+
title === "# Result" || title === "# Error" ? "# Error" : title,
|
|
288
|
+
"",
|
|
289
|
+
`## ${code}`,
|
|
290
|
+
"",
|
|
291
|
+
message,
|
|
292
|
+
"",
|
|
293
|
+
"## Details",
|
|
294
|
+
"",
|
|
295
|
+
jsonFence(error ?? value)
|
|
296
|
+
].join("\n");
|
|
297
|
+
}
|
|
298
|
+
function isDiscoveryWrapper(value) {
|
|
299
|
+
return isRecord(value) && "result" in value;
|
|
300
|
+
}
|
|
301
|
+
function isErrorStructuredContent(value) {
|
|
302
|
+
return isRecord(value) && "error" in value;
|
|
303
|
+
}
|
|
304
|
+
function isHttpLikeResult(value) {
|
|
305
|
+
return isRecord(value) && ("status" in value || "statusText" in value || "body" in value);
|
|
306
|
+
}
|
|
307
|
+
function isGraphQlHttpResult(value) {
|
|
308
|
+
if (!isHttpLikeResult(value)) return false;
|
|
309
|
+
const body = asRecord$2(value.body);
|
|
310
|
+
return Boolean(body && ("data" in body || "errors" in body));
|
|
152
311
|
}
|
|
153
|
-
function
|
|
154
|
-
return
|
|
312
|
+
function isCliResult(value) {
|
|
313
|
+
return isRecord(value) && ("exitCode" in value || "stdout" in value || "stderr" in value);
|
|
314
|
+
}
|
|
315
|
+
function renderBodyValue(value) {
|
|
316
|
+
if (value === void 0) return "_No response body._";
|
|
317
|
+
if (typeof value === "string") return textFenceOrEmpty(value, "No response body.");
|
|
318
|
+
return jsonFence(value);
|
|
319
|
+
}
|
|
320
|
+
function textFenceOrEmpty(value, emptyMessage) {
|
|
321
|
+
if (typeof value !== "string" || value.length === 0) return `_${emptyMessage}_`;
|
|
322
|
+
return [
|
|
323
|
+
"```text",
|
|
324
|
+
escapeCodeFence(value),
|
|
325
|
+
"```"
|
|
326
|
+
].join("\n");
|
|
327
|
+
}
|
|
328
|
+
function jsonFence(value) {
|
|
329
|
+
return [
|
|
330
|
+
"```json",
|
|
331
|
+
escapeCodeFence(JSON.stringify(value, null, 2) ?? "null"),
|
|
332
|
+
"```"
|
|
333
|
+
].join("\n");
|
|
334
|
+
}
|
|
335
|
+
function escapeCodeFence(value) {
|
|
336
|
+
return value.replace(/```/gu, "```");
|
|
337
|
+
}
|
|
338
|
+
function textBlocksToString(content) {
|
|
339
|
+
if (!Array.isArray(content)) return "";
|
|
340
|
+
return content.filter((item) => Boolean(item && typeof item === "object" && item.type === "text" && typeof item.text === "string")).map((item) => item.text).filter(Boolean).join("\n");
|
|
341
|
+
}
|
|
342
|
+
function renderNamedList(items, nameKey) {
|
|
343
|
+
if (items.length === 0) return "_No items._";
|
|
344
|
+
return items.map((item, index) => {
|
|
345
|
+
const record = asRecord$2(item);
|
|
346
|
+
const name = stringValue(record?.[nameKey]) ?? stringValue(record?.name) ?? `Item ${index + 1}`;
|
|
347
|
+
const description = stringValue(record?.description);
|
|
348
|
+
return description ? `${index + 1}. \`${name}\` — ${description}` : `${index + 1}. \`${name}\``;
|
|
349
|
+
}).join("\n");
|
|
350
|
+
}
|
|
351
|
+
function renderToolSummary(tool) {
|
|
352
|
+
if (!tool) return "_Tool details unavailable._";
|
|
353
|
+
const lines = [];
|
|
354
|
+
const name = stringValue(tool.name);
|
|
355
|
+
const description = stringValue(tool.description);
|
|
356
|
+
if (name) lines.push(`- **Name:** \`${name}\``);
|
|
357
|
+
if (description) lines.push(`- **Description:** ${description}`);
|
|
358
|
+
if (tool.inputSchema !== void 0) lines.push("", "### Input Schema", "", jsonFence(tool.inputSchema));
|
|
359
|
+
if (tool.outputSchema !== void 0) lines.push("", "### Output Schema", "", jsonFence(tool.outputSchema));
|
|
360
|
+
if (tool.annotations !== void 0) lines.push("", "### Annotations", "", jsonFence(tool.annotations));
|
|
361
|
+
return lines.length > 0 ? lines.join("\n") : jsonFence(tool);
|
|
362
|
+
}
|
|
363
|
+
function renderBackendStatus(result) {
|
|
364
|
+
if (!result) return "_Backend status unavailable._";
|
|
365
|
+
const lines = [];
|
|
366
|
+
for (const key of [
|
|
367
|
+
"id",
|
|
368
|
+
"status",
|
|
369
|
+
"toolCount",
|
|
370
|
+
"resourceCount",
|
|
371
|
+
"resourceTemplateCount",
|
|
372
|
+
"promptCount",
|
|
373
|
+
"elapsedMs"
|
|
374
|
+
]) if (result[key] !== void 0) {
|
|
375
|
+
const label = key === "elapsedMs" ? "Elapsed" : humanizeKey(key);
|
|
376
|
+
const suffix = key === "elapsedMs" ? " ms" : "";
|
|
377
|
+
lines.push(`- **${label}:** \`${String(result[key])}${suffix}\``);
|
|
378
|
+
}
|
|
379
|
+
if (result.error !== void 0) lines.push("", "### Error", "", jsonFence(result.error));
|
|
380
|
+
return lines.length > 0 ? lines.join("\n") : jsonFence(result);
|
|
381
|
+
}
|
|
382
|
+
function renderCapletSummary(result) {
|
|
383
|
+
if (!result) return "_Caplet details unavailable._";
|
|
384
|
+
const lines = [];
|
|
385
|
+
for (const key of [
|
|
386
|
+
"id",
|
|
387
|
+
"name",
|
|
388
|
+
"description"
|
|
389
|
+
]) if (result[key] !== void 0) lines.push(`- **${humanizeKey(key)}:** ${String(result[key])}`);
|
|
390
|
+
const backend = asRecord$2(result.backend);
|
|
391
|
+
if (backend?.type !== void 0) lines.push(`- **Backend:** \`${String(backend.type)}\``);
|
|
392
|
+
return lines.length > 0 ? lines.join("\n") : jsonFence(result);
|
|
393
|
+
}
|
|
394
|
+
function omitKeys(record, keys) {
|
|
395
|
+
const omitted = new Set(keys);
|
|
396
|
+
return Object.fromEntries(Object.entries(record).filter(([key]) => !omitted.has(key)));
|
|
397
|
+
}
|
|
398
|
+
function arrayValue(value) {
|
|
399
|
+
return Array.isArray(value) ? value : [];
|
|
400
|
+
}
|
|
401
|
+
function stringValue(value) {
|
|
402
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
403
|
+
}
|
|
404
|
+
function humanizeKey(key) {
|
|
405
|
+
return key.replace(/([A-Z])/gu, " $1").replace(/^./u, (char) => char.toUpperCase());
|
|
406
|
+
}
|
|
407
|
+
function asRecord$2(value) {
|
|
408
|
+
return isRecord(value) ? value : void 0;
|
|
409
|
+
}
|
|
410
|
+
function isRecord(value) {
|
|
411
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
155
412
|
}
|
|
156
413
|
//#endregion
|
|
157
414
|
//#region src/tool-search.ts
|
|
@@ -222,7 +479,12 @@ var CliToolsManager = class {
|
|
|
222
479
|
const result = await spawnCommand(execution, controller.signal, () => Date.now() - startedAt);
|
|
223
480
|
const structured = parseStructuredResult(action, result, result.exitCode !== 0);
|
|
224
481
|
return {
|
|
225
|
-
content:
|
|
482
|
+
content: markdownStructuredContent(structured, {
|
|
483
|
+
title: `${config.name} call_tool ${toolName}`,
|
|
484
|
+
backend: "cli",
|
|
485
|
+
operation: "call_tool",
|
|
486
|
+
tool: toolName
|
|
487
|
+
}),
|
|
226
488
|
structuredContent: structured,
|
|
227
489
|
isError: result.exitCode !== 0
|
|
228
490
|
};
|
|
@@ -42654,7 +42916,12 @@ var GraphQLManager = class {
|
|
|
42654
42916
|
body
|
|
42655
42917
|
};
|
|
42656
42918
|
return {
|
|
42657
|
-
content:
|
|
42919
|
+
content: markdownStructuredContent(result, {
|
|
42920
|
+
title: `${endpoint.name} call_tool ${toolName}`,
|
|
42921
|
+
backend: "graphql",
|
|
42922
|
+
operation: "call_tool",
|
|
42923
|
+
tool: toolName
|
|
42924
|
+
}),
|
|
42658
42925
|
structuredContent: result,
|
|
42659
42926
|
isError: !response.ok || Boolean(body && typeof body === "object" && "errors" in body && body.errors)
|
|
42660
42927
|
};
|
|
@@ -43048,7 +43315,12 @@ var HttpActionManager = class {
|
|
|
43048
43315
|
});
|
|
43049
43316
|
const parsed = await readResponse$1(response, api, Date.now() - startedAt);
|
|
43050
43317
|
return {
|
|
43051
|
-
content:
|
|
43318
|
+
content: markdownStructuredContent(parsed, {
|
|
43319
|
+
title: `${api.name} call_tool ${toolName}`,
|
|
43320
|
+
backend: "http",
|
|
43321
|
+
operation: "call_tool",
|
|
43322
|
+
tool: toolName
|
|
43323
|
+
}),
|
|
43052
43324
|
structuredContent: parsed,
|
|
43053
43325
|
isError: !response.ok
|
|
43054
43326
|
};
|
|
@@ -52839,7 +53111,12 @@ var OpenApiManager = class {
|
|
|
52839
53111
|
});
|
|
52840
53112
|
const parsed = await readResponse(response);
|
|
52841
53113
|
return {
|
|
52842
|
-
content:
|
|
53114
|
+
content: markdownStructuredContent(parsed, {
|
|
53115
|
+
title: `${endpoint.name} call_tool ${toolName}`,
|
|
53116
|
+
backend: "openapi",
|
|
53117
|
+
operation: "call_tool",
|
|
53118
|
+
tool: toolName
|
|
53119
|
+
}),
|
|
52843
53120
|
structuredContent: parsed,
|
|
52844
53121
|
isError: response.ok ? false : true
|
|
52845
53122
|
};
|
|
@@ -53476,7 +53753,8 @@ async function handleServerTool(server, request, registry, downstream, openapi,
|
|
|
53476
53753
|
const tool = await backend.getTool(server, parsed.tool);
|
|
53477
53754
|
if (!tool.outputSchema) throw new CapletsError("REQUEST_INVALID", "Field selection requires an output schema");
|
|
53478
53755
|
validateFieldSelection(tool.outputSchema, parsed.fields);
|
|
53479
|
-
|
|
53756
|
+
const metadata = metadataFor(server, "call_tool", parsed.tool, startedAt);
|
|
53757
|
+
return annotateCallToolResult(projectCallToolResult(await backend.callTool(server, parsed.tool, parsed.arguments), tool.outputSchema, parsed.fields, markdownContextFor(metadata)), metadata);
|
|
53480
53758
|
}
|
|
53481
53759
|
case "list_resources": {
|
|
53482
53760
|
const backend = mcpBackendFor(server, downstream);
|
|
@@ -53680,16 +53958,28 @@ function annotateMcpResult(result, metadata) {
|
|
|
53680
53958
|
}
|
|
53681
53959
|
};
|
|
53682
53960
|
}
|
|
53961
|
+
function markdownContextFor(metadata) {
|
|
53962
|
+
return {
|
|
53963
|
+
title: [
|
|
53964
|
+
metadata.name,
|
|
53965
|
+
metadata.operation,
|
|
53966
|
+
metadata.tool ?? metadata.uri ?? metadata.prompt
|
|
53967
|
+
].filter(Boolean).join(" "),
|
|
53968
|
+
backend: metadata.backend,
|
|
53969
|
+
operation: metadata.operation,
|
|
53970
|
+
...metadata.tool ? { tool: metadata.tool } : {},
|
|
53971
|
+
...metadata.uri ? { uri: metadata.uri } : {},
|
|
53972
|
+
...metadata.prompt ? { prompt: metadata.prompt } : {}
|
|
53973
|
+
};
|
|
53974
|
+
}
|
|
53683
53975
|
function jsonResult(value, metadata) {
|
|
53976
|
+
const structuredContent = {
|
|
53977
|
+
...metadata === void 0 ? {} : { caplets: metadata },
|
|
53978
|
+
result: value
|
|
53979
|
+
};
|
|
53684
53980
|
return {
|
|
53685
|
-
content:
|
|
53686
|
-
|
|
53687
|
-
text: JSON.stringify(value, null, 2)
|
|
53688
|
-
}],
|
|
53689
|
-
structuredContent: {
|
|
53690
|
-
...metadata === void 0 ? {} : { caplets: metadata },
|
|
53691
|
-
result: value
|
|
53692
|
-
}
|
|
53981
|
+
content: markdownStructuredContent(structuredContent, metadata ? markdownContextFor(metadata) : { title: "Result" }),
|
|
53982
|
+
structuredContent
|
|
53693
53983
|
};
|
|
53694
53984
|
}
|
|
53695
53985
|
function annotateCallToolResult(result, metadata) {
|
|
@@ -53702,20 +53992,21 @@ function annotateCallToolResult(result, metadata) {
|
|
|
53702
53992
|
};
|
|
53703
53993
|
return {
|
|
53704
53994
|
...result,
|
|
53995
|
+
content: markdownCallToolResultContent(result, markdownContextFor(annotatedMetadata)),
|
|
53705
53996
|
_meta: {
|
|
53706
53997
|
...isPlainObject(existingMeta) ? existingMeta : {},
|
|
53707
53998
|
caplets: annotatedMetadata
|
|
53708
53999
|
}
|
|
53709
54000
|
};
|
|
53710
54001
|
}
|
|
53711
|
-
function projectCallToolResult(result, outputSchema, fields) {
|
|
54002
|
+
function projectCallToolResult(result, outputSchema, fields, context = {}) {
|
|
53712
54003
|
if (result.isError === true) return result;
|
|
53713
54004
|
const structuredContent = result.structuredContent;
|
|
53714
54005
|
if (!isPlainObject(structuredContent)) throw new CapletsError("DOWNSTREAM_PROTOCOL_ERROR", "Field selection requires the downstream tool to return object structuredContent");
|
|
53715
54006
|
const projected = projectStructuredContent(structuredContent, outputSchema, fields);
|
|
53716
54007
|
return {
|
|
53717
54008
|
...result,
|
|
53718
|
-
content:
|
|
54009
|
+
content: markdownStructuredContent(projected, context),
|
|
53719
54010
|
structuredContent: projected
|
|
53720
54011
|
};
|
|
53721
54012
|
}
|
|
@@ -54154,7 +54445,7 @@ var CapletsEngine = class {
|
|
|
54154
54445
|
}
|
|
54155
54446
|
}
|
|
54156
54447
|
async completeCliWords(words) {
|
|
54157
|
-
const { completeCliWords } = await import("./completion-
|
|
54448
|
+
const { completeCliWords } = await import("./completion-B9niw4HY.js").then((n) => n.r);
|
|
54158
54449
|
return await completeCliWords(words, {
|
|
54159
54450
|
config: this.registry.config,
|
|
54160
54451
|
managers: {
|
|
@@ -54494,4 +54785,4 @@ function hasEnv(value) {
|
|
|
54494
54785
|
return value !== void 0 && value.trim() !== "";
|
|
54495
54786
|
}
|
|
54496
54787
|
//#endregion
|
|
54497
|
-
export { assertCompleteRequestPrompt as $, CreateMessageResultSchema as A,
|
|
54788
|
+
export { assertCompleteRequestPrompt as $, CreateMessageResultSchema as A, hasRenderableStructuredContent as At, JSONRPCMessageSchema as B, __toESM as Bt, AjvJsonSchemaValidator as C, resolveCapletsRoot as Ct, CallToolRequestSchema as D, discoverCapletFiles as Dt, toJsonSchemaCompat as E, resolveProjectConfigPath as Et, EmptyResultSchema as F, redactSecrets as Ft, ListRootsResultSchema as G, ListPromptsRequestSchema as H, ErrorCode as I, toSafeError as It, McpError as J, ListToolsRequestSchema as K, GetPromptRequestSchema as L, __commonJSMin as Lt, CreateTaskResultSchema as M, markdownStructuredContent as Mt, DEFAULT_NEGOTIATED_PROTOCOL_VERSION as N, CAPLETS_ERROR_CODES as Nt, CallToolResultSchema as O, validateCapletFile as Ot, ElicitResultSchema as P, CapletsError as Pt, ToolListChangedNotificationSchema as Q, InitializeRequestSchema as R, __exportAll as Rt, assertToolsCallTaskCapability as S, DEFAULT_COMPLETION_CACHE_DIR as St, mergeCapabilities as T, resolveProjectCapletsRoot as Tt, ListResourceTemplatesRequestSchema as U, LATEST_PROTOCOL_VERSION as V, ListResourcesRequestSchema as W, SUPPORTED_PROTOCOL_VERSIONS as X, ReadResourceRequestSchema as Y, SetLevelRequestSchema as Z, StreamableHTTPClientTransport as _, loadGlobalConfig as _t, resolveCapletsServer as a, getLiteralValue as at, Client as b, parseConfig as bt, ServerRegistry as c, getSchemaDescription as ct, runOAuthFlow as d, normalizeObjectSchema as dt, assertCompleteRequestResourceTemplate as et, startGenericOAuthFlow as f, objectFromShape as ft, readTokenBundle as g, loadConfigWithSources as gt, isTokenBundleExpired as h, loadConfig as ht, resolveCapletsMode as i, isJSONRPCResultResponse as it, CreateMessageResultWithToolsSchema as j, markdownCallToolResultContent as jt, CompleteRequestSchema as k, SERVER_ID_PATTERN as kt, capabilityDescription as l, isSchemaOptional as lt, deleteTokenBundle as m, safeParseAsync as mt, mcpUrlForBase as n, isJSONRPCErrorResponse as nt, CapletsEngine as o, getObjectShape as ot, startOAuthFlow as p, safeParse as pt, LoggingLevelSchema as q, parseServerBaseUrl as r, isJSONRPCRequest as rt, handleServerTool as s, getParseErrorMessage as st, controlUrlForBase as t, isInitializeRequest as tt, runGenericOAuthFlow as u, isZ4Schema as ut, ReadBuffer as v, loadLocalOverlayConfigWithSources as vt, Protocol as w, resolveConfigPath as wt, assertClientRequestTaskCapability as x, DEFAULT_AUTH_DIR as xt, serializeMessage as y, loadProjectConfig as yt, InitializedNotificationSchema as z, __require as zt };
|
package/dist/result-content.d.ts
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
|
-
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
1
|
export type TextContentBlock = {
|
|
3
2
|
type: "text";
|
|
4
3
|
text: string;
|
|
5
4
|
};
|
|
5
|
+
type ContentBlockLike = {
|
|
6
|
+
type: string;
|
|
7
|
+
text?: string;
|
|
8
|
+
} & Record<string, unknown>;
|
|
9
|
+
type CallToolResultLike = {
|
|
10
|
+
content?: ContentBlockLike[];
|
|
11
|
+
structuredContent?: unknown;
|
|
12
|
+
isError?: boolean | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type ResultMarkdownContext = {
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
backend?: string | undefined;
|
|
17
|
+
operation?: string | undefined;
|
|
18
|
+
tool?: string | undefined;
|
|
19
|
+
uri?: string | undefined;
|
|
20
|
+
prompt?: string | undefined;
|
|
21
|
+
fields?: string[] | undefined;
|
|
22
|
+
isError?: boolean | undefined;
|
|
23
|
+
};
|
|
6
24
|
export declare function structuredOnlyContent(): [];
|
|
7
25
|
export declare function textContent(text: string): TextContentBlock[];
|
|
8
26
|
export declare function compactJsonText(value: unknown, maxLength?: number): string;
|
|
9
27
|
export declare function compactText(value: string, maxLength?: number): string;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function compactStructuredContent(value: unknown): TextContentBlock[];
|
|
13
|
-
export declare function compactCallToolResultContent(result:
|
|
28
|
+
export declare function markdownStructuredContent(value: unknown, context?: ResultMarkdownContext): TextContentBlock[];
|
|
29
|
+
export declare function markdownCallToolResultContent(result: CallToolResultLike, context?: ResultMarkdownContext): TextContentBlock[];
|
|
30
|
+
export declare function compactStructuredContent(value: unknown, context?: ResultMarkdownContext): TextContentBlock[];
|
|
31
|
+
export declare function compactCallToolResultContent(result: CallToolResultLike, context?: ResultMarkdownContext): TextContentBlock[];
|
|
32
|
+
export declare function hasRenderableStructuredContent(value: unknown): boolean;
|
|
14
33
|
export declare function byteLimitHint(maxBytes: number): string;
|
|
34
|
+
export {};
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport
|
|
1
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport";
|
|
2
2
|
import type { CapletsConfig } from "./config";
|
|
3
3
|
import { type ToolServer } from "./serve/session";
|
|
4
4
|
type CapletsRuntimeOptions = {
|
package/dist/serve/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp
|
|
2
|
-
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp";
|
|
2
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport";
|
|
3
3
|
import type { CapletsEngine } from "../engine";
|
|
4
4
|
export type ToolServer = Pick<McpServer, "registerTool" | "connect" | "close">;
|
|
5
5
|
export type CapletsMcpSessionOptions = {
|
package/dist/tool-search.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Tool } from "@modelcontextprotocol/sdk/types
|
|
1
|
+
import type { Tool } from "@modelcontextprotocol/sdk/types";
|
|
2
2
|
export declare function searchToolList<T>(tools: Tool[], query: string, limit: number, compact: (tool: Tool) => T): T[];
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallToolResult } from "@modelcontextprotocol/sdk/types
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types";
|
|
2
2
|
import type { CapletSetManager } from "./caplet-sets";
|
|
3
3
|
import type { CapletConfig } from "./config";
|
|
4
4
|
import type { CliToolsManager } from "./cli-tools";
|
|
@@ -7,6 +7,7 @@ import type { GraphQLManager } from "./graphql";
|
|
|
7
7
|
import type { HttpActionManager } from "./http-actions";
|
|
8
8
|
import type { OpenApiManager } from "./openapi";
|
|
9
9
|
import type { ServerRegistry } from "./registry";
|
|
10
|
+
import { type ResultMarkdownContext } from "./result-content";
|
|
10
11
|
export { generatedToolInputSchema } from "./generated-tool-input-schema";
|
|
11
12
|
export type GeneratedServerToolRequest = RequiredOperationRequest;
|
|
12
13
|
export declare function handleServerTool(server: CapletConfig, request: unknown, registry: ServerRegistry, downstream: DownstreamManager, openapi?: OpenApiManager, graphql?: GraphQLManager, http?: HttpActionManager, cli?: CliToolsManager, caplets?: CapletSetManager): Promise<any>;
|
|
@@ -81,5 +82,5 @@ export declare function metadataFor(server: CapletConfig, operation: RequiredOpe
|
|
|
81
82
|
export declare function annotateMcpResult<T extends object>(result: T, metadata: CapletResultMetadata): T;
|
|
82
83
|
export declare function jsonResult(value: unknown, metadata?: CapletResultMetadata): CallToolResult;
|
|
83
84
|
export declare function annotateCallToolResult<T extends object>(result: T, metadata: CapletResultMetadata): T & CallToolResult;
|
|
84
|
-
export declare function projectCallToolResult<T extends object>(result: T, outputSchema: unknown, fields: string[]): T & CallToolResult;
|
|
85
|
+
export declare function projectCallToolResult<T extends object>(result: T, outputSchema: unknown, fields: string[], context?: ResultMarkdownContext): T & CallToolResult;
|
|
85
86
|
export declare function extractArtifacts(result: unknown): CapletArtifact[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caplets/core",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.7",
|
|
4
4
|
"description": "Core runtime library for Caplets progressive disclosure gateways.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"caplets",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@apidevtools/swagger-parser": "^12.1.0",
|
|
48
48
|
"@hono/mcp": "^0.3.0",
|
|
49
|
-
"@hono/node-server": "^2.0.
|
|
49
|
+
"@hono/node-server": "^2.0.4",
|
|
50
50
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
51
51
|
"commander": "^14.0.3",
|
|
52
52
|
"graphql": "^16.14.0",
|
|
53
|
-
"hono": "^4.12.
|
|
53
|
+
"hono": "^4.12.23",
|
|
54
54
|
"vfile": "^6.0.3",
|
|
55
55
|
"vfile-matter": "^5.0.1",
|
|
56
56
|
"yaml": "^2.9.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^25.9.1",
|
|
61
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
61
|
+
"@typescript/native-preview": "7.0.0-dev.20260526.1",
|
|
62
62
|
"rolldown": "^1.0.2",
|
|
63
63
|
"typescript": "^6.0.3",
|
|
64
64
|
"vitest": "^4.1.7"
|