kizunajs 2.0.0-beta.2 → 2.0.0-beta.21
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 -2
- package/dist/{adapter-CZW-unqX.mjs → adapter-BSqNrxhq.mjs} +522 -104
- package/dist/adapter-C3WYdSfx.d.cts +2754 -0
- package/dist/{adapter-DDR_yo9L.cjs → adapter-ClaFZoab.cjs} +638 -196
- package/dist/adapter-D4bTPElA.d.mts +2754 -0
- package/dist/adapter.cjs +37 -29
- package/dist/adapter.d.cts +3 -5
- package/dist/adapter.d.mts +3 -5
- package/dist/adapter.mjs +5 -5
- package/dist/{error-response-C8Ragjcd.cjs → error-response-C9ymqSU4.cjs} +25 -5
- package/dist/{error-response-C839d8By.mjs → error-response-CNQaKVYd.mjs} +20 -6
- package/dist/{security-scheme-BrszwGD5.d.cts → error-response-NoOGdh8H.d.mts} +151 -24
- package/dist/{security-scheme-D3nb4XKj.d.mts → error-response-YbkRMKno.d.cts} +151 -24
- package/dist/generator.cjs +190 -95
- package/dist/generator.d.cts +189 -28
- package/dist/generator.d.mts +189 -28
- package/dist/generator.mjs +151 -60
- package/dist/index.cjs +159 -84
- package/dist/index.d.cts +193 -253
- package/dist/index.d.mts +193 -253
- package/dist/index.mjs +112 -38
- package/dist/jobs-entry.cjs +12 -11
- package/dist/jobs-entry.d.cts +1 -1
- package/dist/jobs-entry.d.mts +1 -1
- package/dist/jobs-entry.mjs +3 -2
- package/dist/plugin-Dw-yCjTY.cjs +233 -0
- package/dist/{cache-CLN5y0Xp.mjs → plugin-server-BztlE1fz.mjs} +188 -49
- package/dist/{cache-BgohRj0i.cjs → plugin-server-kUsK7thV.cjs} +238 -93
- package/dist/plugin-xxCxibmu.mjs +138 -0
- package/dist/plugin.cjs +8 -72
- package/dist/plugin.d.cts +3 -3
- package/dist/plugin.d.mts +3 -3
- package/dist/plugin.mjs +2 -68
- package/dist/{protected-resource-metadata-CA0v5cjg.d.mts → protected-resource-metadata-B9hMFQ9N.d.cts} +1 -1
- package/dist/{protected-resource-metadata-Cprrv0mt.d.cts → protected-resource-metadata-CfBVsqIk.d.mts} +1 -1
- package/dist/{schemas-C56no6bv.cjs → schemas-DNPVDvkd.cjs} +28 -1
- package/dist/{schemas-CJQcc97N.mjs → schemas-HW2FDsvz.mjs} +23 -2
- package/dist/schemas.cjs +3 -2
- package/dist/schemas.d.cts +24 -3
- package/dist/schemas.d.mts +24 -3
- package/dist/schemas.mjs +3 -3
- package/package.json +1 -1
- package/src/adapter.ts +245 -29
- package/src/api-definition.ts +12 -16
- package/src/api.ts +7 -3
- package/src/brand.ts +29 -0
- package/src/config.ts +51 -10
- package/src/configured.ts +13 -6
- package/src/define-config.ts +118 -39
- package/src/generator.ts +363 -46
- package/src/group-routes.ts +106 -0
- package/src/groups.ts +140 -0
- package/src/handler-pipeline.ts +78 -19
- package/src/index.ts +15 -6
- package/src/job-runner.ts +5 -0
- package/src/job-transport.ts +3 -3
- package/src/job.ts +8 -6
- package/src/jobs-dev-runner.ts +6 -0
- package/src/jobs.ts +61 -8
- package/src/kizuna.ts +56 -33
- package/src/plugin-server.ts +129 -19
- package/src/plugin.ts +269 -127
- package/src/routes.ts +80 -32
- package/src/schemas.ts +1 -0
- package/src/tool-answer.ts +21 -0
- package/src/tool-definitions.ts +166 -0
- package/src/tool-events.ts +90 -18
- package/src/tool-records.ts +11 -3
- package/src/tool-runner.ts +298 -0
- package/src/types.ts +90 -24
- package/src/zod-internals.ts +22 -5
- package/src/zod-meta.ts +7 -2
- package/dist/adapter-BGfMqEkM.d.cts +0 -563
- package/dist/adapter-Ci3cfcoT.d.mts +0 -563
- package/dist/api-definition-BHnh15zD.d.mts +0 -803
- package/dist/api-definition-DQj-ewHy.d.cts +0 -803
- package/dist/error-response-BBGSdgYw.d.mts +0 -67
- package/dist/error-response-Do38sr-9.d.cts +0 -67
- package/dist/plugin-Cz0kn6Lk.d.mts +0 -830
- package/dist/plugin-DhKvx_T0.d.cts +0 -830
- package/src/tags.ts +0 -67
package/dist/adapter.cjs
CHANGED
|
@@ -1,78 +1,86 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
2
|
+
const require_plugin = require("./plugin-Dw-yCjTY.cjs");
|
|
3
|
+
const require_plugin_server = require("./plugin-server-kUsK7thV.cjs");
|
|
4
|
+
const require_schemas = require("./schemas-DNPVDvkd.cjs");
|
|
5
|
+
const require_adapter = require("./adapter-ClaFZoab.cjs");
|
|
6
6
|
exports.API_META = require_adapter.API_META;
|
|
7
|
-
exports.AUTO_GUARD_BRAND =
|
|
8
|
-
exports.AUTO_RESPONSES_BRAND =
|
|
7
|
+
exports.AUTO_GUARD_BRAND = require_plugin.AUTO_GUARD_BRAND;
|
|
8
|
+
exports.AUTO_RESPONSES_BRAND = require_plugin.AUTO_RESPONSES_BRAND;
|
|
9
9
|
exports.DISPATCH_ROUTE_KEY = require_adapter.DISPATCH_ROUTE_KEY;
|
|
10
10
|
exports.GUARDS_META = require_adapter.GUARDS_META;
|
|
11
11
|
exports.GUARD_SCHEMA_META = require_adapter.GUARD_SCHEMA_META;
|
|
12
12
|
exports.HANDLER_ARG_KEYS = require_adapter.HANDLER_ARG_KEYS;
|
|
13
|
-
exports.HANDLER_CONTEXT_BRAND =
|
|
13
|
+
exports.HANDLER_CONTEXT_BRAND = require_plugin.HANDLER_CONTEXT_BRAND;
|
|
14
14
|
exports.JOBS_META = require_adapter.JOBS_META;
|
|
15
15
|
exports.JobDispatchError = require_adapter.JobDispatchError;
|
|
16
16
|
exports.JobInputError = require_adapter.JobInputError;
|
|
17
17
|
exports.REQUEST_CONTEXT_META = require_adapter.REQUEST_CONTEXT_META;
|
|
18
18
|
exports.ROUTER_META = require_adapter.ROUTER_META;
|
|
19
|
-
exports.
|
|
19
|
+
exports.ROUTES_GROUP = require_plugin.ROUTES_GROUP;
|
|
20
20
|
exports.RUN_ROUTE_KEY = require_adapter.RUN_ROUTE_KEY;
|
|
21
21
|
exports.ResponseError = require_adapter.ResponseError;
|
|
22
22
|
exports.ResponseValidationError = require_adapter.ResponseValidationError;
|
|
23
23
|
exports.SCHEMES_META = require_adapter.SCHEMES_META;
|
|
24
24
|
exports.adapterContextOf = require_adapter.adapterContextOf;
|
|
25
|
-
exports.allowedMethodsForPath =
|
|
25
|
+
exports.allowedMethodsForPath = require_plugin_server.allowedMethodsForPath;
|
|
26
26
|
exports.assembleApi = require_adapter.assembleApi;
|
|
27
27
|
exports.authenticationChallenge = require_schemas.authenticationChallenge;
|
|
28
28
|
exports.bearerChallenge = require_adapter.bearerChallenge;
|
|
29
29
|
exports.boundJobKeys = require_adapter.boundJobKeys;
|
|
30
|
-
exports.buildPath =
|
|
30
|
+
exports.buildPath = require_plugin_server.buildPath;
|
|
31
|
+
exports.buildToolDefinitions = require_adapter.buildToolDefinitions;
|
|
32
|
+
exports.buildToolInputSchema = require_adapter.buildToolInputSchema;
|
|
31
33
|
exports.contractOf = require_adapter.contractOf;
|
|
32
|
-
exports.
|
|
34
|
+
exports.createApiReference = require_plugin_server.createApiReference;
|
|
33
35
|
exports.createJobRunner = require_adapter.createJobRunner;
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
+
exports.defineAdapter = require_adapter.defineAdapter;
|
|
37
|
+
exports.defineJobTransport = require_adapter.defineJobTransport;
|
|
38
|
+
exports.definePlugin = require_plugin.definePlugin;
|
|
39
|
+
exports.describeTool = require_adapter.describeTool;
|
|
36
40
|
exports.dispatchHandler = require_adapter.dispatchHandler;
|
|
37
41
|
exports.dispatchRoute = require_adapter.dispatchRoute;
|
|
38
|
-
exports.encodeStreamBody =
|
|
42
|
+
exports.encodeStreamBody = require_plugin_server.encodeStreamBody;
|
|
39
43
|
exports.extractCredential = require_adapter.extractCredential;
|
|
40
|
-
exports.flattenJobs =
|
|
41
|
-
exports.flattenRoutes =
|
|
42
|
-
exports.formatValidationError =
|
|
44
|
+
exports.flattenJobs = require_plugin_server.flattenJobs;
|
|
45
|
+
exports.flattenRoutes = require_plugin_server.flattenRoutes;
|
|
46
|
+
exports.formatValidationError = require_plugin_server.formatValidationError;
|
|
43
47
|
exports.getHeaderValue = require_adapter.getHeaderValue;
|
|
48
|
+
exports.groupRoutes = require_adapter.groupRoutes;
|
|
44
49
|
exports.guardDenyFor = require_adapter.guardDenyFor;
|
|
45
50
|
exports.headersToObject = require_adapter.headersToObject;
|
|
46
51
|
exports.insufficientScope = require_adapter.insufficientScope;
|
|
47
|
-
exports.isCompiledJob =
|
|
52
|
+
exports.isCompiledJob = require_plugin_server.isCompiledJob;
|
|
53
|
+
exports.isGroupSet = require_adapter.isGroupSet;
|
|
48
54
|
exports.isGuardDenial = require_adapter.isGuardDenial;
|
|
49
55
|
exports.isRawResponse = require_adapter.isRawResponse;
|
|
50
|
-
exports.isRouteDefinition =
|
|
51
|
-
exports.isStreamResponse =
|
|
52
|
-
exports.
|
|
53
|
-
exports.jobAt = require_cache.jobAt;
|
|
56
|
+
exports.isRouteDefinition = require_plugin_server.isRouteDefinition;
|
|
57
|
+
exports.isStreamResponse = require_plugin_server.isStreamResponse;
|
|
58
|
+
exports.jobAt = require_plugin_server.jobAt;
|
|
54
59
|
exports.jobFnAt = require_adapter.jobFnAt;
|
|
55
60
|
exports.jobRouter = require_adapter.jobRouter;
|
|
56
61
|
exports.jobRoutes = require_adapter.jobRoutes;
|
|
57
62
|
exports.jobRunnerFrom = require_adapter.jobRunnerFrom;
|
|
58
63
|
exports.matchRoute = require_adapter.matchRoute;
|
|
64
|
+
exports.parseBodyText = require_adapter.parseBodyText;
|
|
59
65
|
exports.parseFetchBody = require_adapter.parseFetchBody;
|
|
60
|
-
exports.parsePath =
|
|
61
|
-
exports.pluginExportsOf =
|
|
66
|
+
exports.parsePath = require_plugin_server.parsePath;
|
|
67
|
+
exports.pluginExportsOf = require_plugin_server.pluginExportsOf;
|
|
62
68
|
exports.pluginRouteTree = require_plugin.pluginRouteTree;
|
|
63
|
-
exports.pluginRouterOf =
|
|
64
|
-
exports.pluginRoutesOf =
|
|
69
|
+
exports.pluginRouterOf = require_plugin_server.pluginRouterOf;
|
|
70
|
+
exports.pluginRoutesOf = require_plugin_server.pluginRoutesOf;
|
|
65
71
|
exports.problemDetails = require_adapter.problemDetails;
|
|
66
72
|
exports.rawResponse = require_adapter.rawResponse;
|
|
67
73
|
exports.renderJsonResult = require_adapter.renderJsonResult;
|
|
68
74
|
exports.requiresDenial = require_adapter.requiresDenial;
|
|
69
|
-
exports.
|
|
75
|
+
exports.resolvePlugins = require_plugin_server.resolvePlugins;
|
|
70
76
|
exports.resolveSecurityRequirements = require_schemas.resolveSecurityRequirements;
|
|
71
77
|
exports.routerFromRoutes = require_adapter.routerFromRoutes;
|
|
72
78
|
exports.runHandler = require_adapter.runHandler;
|
|
73
79
|
exports.runRoute = require_adapter.runRoute;
|
|
80
|
+
exports.selectToolRoutes = require_adapter.selectToolRoutes;
|
|
74
81
|
exports.sortFlattenedRoutes = require_adapter.sortFlattenedRoutes;
|
|
75
|
-
exports.
|
|
76
|
-
exports.
|
|
82
|
+
exports.toolOptionsOf = require_adapter.toolOptionsOf;
|
|
83
|
+
exports.toolRefusal = require_adapter.toolRefusal;
|
|
84
|
+
exports.validateRequest = require_plugin_server.validateRequest;
|
|
77
85
|
exports.warnUnsupportedJobOptions = require_adapter.warnUnsupportedJobOptions;
|
|
78
86
|
exports.withPermissions = require_adapter.withPermissions;
|
package/dist/adapter.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as
|
|
3
|
-
|
|
4
|
-
import { Ct as ScheduledJob, K as JobHandlers, St as JobWorkerContext, U as JobHandler, V as FlattenedJob, X as Jobs, _ as isTagSet, _t as JobMessage, b as isStreamResponse, dt as JobRunner, et as flattenJobs, f as NormalizeTags, ft as JobRunnerOptions, gt as JobDispatchError, ht as JobDescriptor, it as JobErrorHandler, mt as jobFnAt, ot as JobFnByKey, pt as createJobRunner, rt as jobAt, st as JobInputError, tt as isCompiledJob, vt as JobTransport, wt as createJobTransport, xt as JobWorker, z as CompiledJob } from "./api-definition-DQj-ewHy.cjs";
|
|
5
|
-
export { ADAPTER_CONTEXT, API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, AccessCheckInput, Adapter, AdapterDefinition, AdapterRequest, AdapterResult, AnyAdapter, ApiBrand, ApiParts, ApiPlugins, ApiRouter, ApiWithRouter, AutoResponsesBrand, BrandedHandlerContext, CompiledJob, ContextFromAuth, DISPATCH_ROUTE_KEY, EncodeStreamOptions, ErrorFormatter, FlattenedJob, FlattenedRoute, GUARDS_META, GUARD_SCHEMA_META, GuardDenial, GuardDenialBody, GuardDeny, GuardMap, GuardParams, GuardRun, GuardedParamNames, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, HandleArgs, HandlerContextBrand, HandlerContextOf, HandlersFromRoutes, JOBS_META, JobDescriptor, JobDispatchError, JobErrorHandler, JobFnByKey, JobHandler, JobHandlers, JobInputError, JobMessage, JobRunner, JobRunnerOptions, JobTransport, JobWorker, JobWorkerContext, Jobs, JobsMeta, MatchResult, Method, MountArgsOf, MountedOf, NormalizeTags, PathSegment, PluginArgs, PluginDeclaration, PluginDefinition, PluginExportValues, PluginExportsOf, PluginPropsOf, PluginRouter, PluginRoutes, PluginRoutesOf, ProblemDetails, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_TAG, RUN_ROUTE_KEY, RawInputs, RawResponse, RenderedResult, RequestContextMap, RequestContextRun, RequestContextValues, RequestPipeline, ResponseError, ResponseHeaders, ResponseValidationError, RouteDefinition, RouteHandler, RouteMatch, RouteMatcher, RoutePath, Router, Routes, RoutesWithHandlerContext, SCHEMES_META, ScheduledJob, ServerOptions, StreamContext, ValidationFailure, ValidationStage, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, contractOf, createAdapter, createJobRunner, createJobTransport, createPlugin, dispatchHandler, dispatchRoute, encodeStreamBody, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, isTagSet, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePluginServers, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, sortFlattenedRoutes, tagRoutes, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
|
1
|
+
import { A as AutoResponsesBrand, B as ROUTES_GROUP, D as AUTO_RESPONSES_BRAND, I as HANDLER_CONTEXT_BRAND, K as RouteDefinition, L as HandlerContextBrand, T as AUTO_GUARD_BRAND, W as ResponseHeaders, Y as RoutePath, Z as Routes, at as ProblemDetails, c as authenticationChallenge, f as resolveSecurityRequirements, st as problemDetails, z as Method } from "./error-response-YbkRMKno.cjs";
|
|
2
|
+
import { $ as jobRunnerFrom, $i as StreamContext, $n as jobAt, $r as BrandedHandlerContext, $t as ResolvedPlugin, A as RenderedResult, B as bearerChallenge, Bt as PluginArgs, C as JOBS_META, Ca as requiresDenial, Ci as validateRequest, D as REQUEST_CONTEXT_META, E as MountedOf, F as RouteMatcher, Fi as describeTool, Fn as FlattenedJob, Ft as ApiPlugins, G as dispatchRoute, Gi as buildPath, Gr as rawResponse, H as contractOf, Hn as JobHandlers, Hr as isGroupSet, Ht as PluginDefinition, I as SCHEMES_META, Ii as selectToolRoutes, J as guardDenyFor, Ji as EncodeStreamOptions, Jr as MatchResult, Jt as PluginRoutes, K as extractCredential, Ki as parsePath, Kn as Jobs, L as ServerOptions, Li as toolOptionsOf, M as RequestContextRun, Mi as ToolInputSchema, N as RequestPipeline, Ni as buildToolDefinitions, Nn as CompiledJob, O as ROUTER_META, P as ResponseValidationError, Pi as buildToolInputSchema, Q as jobRoutes, R as adapterContextOf, Ri as toolRefusal, S as HandlerContextOf, Sa as insufficientScope, Si as isRouteDefinition, T as MountArgsOf, U as defineAdapter, Ui as PathSegment, Ur as RawResponse, Ut as PluginExportValues, V as boundJobKeys, Vt as PluginDeclaration, W as dispatchHandler, Wr as isRawResponse, Wt as PluginExportsOf, X as isGuardDenial, Xn as flattenJobs, Xr as matchRoute, Y as headersToObject, Yr as RouteMatch, Yt as PluginRoutesOf, Z as jobRouter, Zn as isCompiledJob, Zr as sortFlattenedRoutes, _ as GuardDeny, _i as ValidationFailure, _r as JobWorker, _t as isStreamResponse, a as AdapterRequest, at as runRoute, b as HANDLER_ARG_KEYS, bi as flattenRoutes, br as defineJobTransport, c as ApiBrand, cr as JobRunnerOptions, ct as ResponseError, d as DISPATCH_ROUTE_KEY, di as RequestContextValues, dr as JobDescriptor, dt as pluginExportsOf, ei as ContextFromAuth, er as JobErrorHandler, et as parseBodyText, f as ErrorFormatter, fr as JobDispatchError, ft as pluginRouterOf, g as GuardDenialBody, h as GuardDenial, hi as RoutesWithHandlerContext, i as AdapterDefinition, ia as encodeStreamBody, in as pluginRouteTree, it as runHandler, j as RequestContextMap, ji as ToolDefinition, k as RUN_ROUTE_KEY, l as ApiParts, li as HandlersFromRoutes, lr as createJobRunner, lt as groupRoutes, m as GUARD_SCHEMA_META, mi as Router, mr as JobTransport, mt as resolvePlugins, n as API_META, nr as JobFnByKey, nt as renderJsonResult, o as AdapterResult, oi as GuardedParamNames, ot as warnUnsupportedJobOptions, p as GUARDS_META, pi as RouteHandler, pr as JobMessage, pt as pluginRoutesOf, q as getHeaderValue, r as Adapter, ri as GuardParams, rn as definePlugin, rr as JobInputError, rt as routerFromRoutes, s as AnyAdapter, sr as JobRunner, st as ApiRouter, t as ADAPTER_CONTEXT, ti as FlattenedRoute, tt as parseFetchBody, u as ApiWithRouter, ui as RawInputs, ur as jobFnAt, ut as createApiReference, v as GuardMap, vi as ValidationStage, vr as JobWorkerContext, w as JobsMeta, wa as withPermissions, x as HandleArgs, xa as AccessCheckInput, xi as formatValidationError, y as GuardRun, yi as allowedMethodsForPath, yr as ScheduledJob, z as assembleApi, zn as JobHandler } from "./adapter-C3WYdSfx.cjs";
|
|
3
|
+
export { ADAPTER_CONTEXT, API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, AccessCheckInput, Adapter, AdapterDefinition, AdapterRequest, AdapterResult, AnyAdapter, ApiBrand, ApiParts, ApiPlugins, ApiRouter, ApiWithRouter, AutoResponsesBrand, BrandedHandlerContext, CompiledJob, ContextFromAuth, DISPATCH_ROUTE_KEY, EncodeStreamOptions, ErrorFormatter, FlattenedJob, FlattenedRoute, GUARDS_META, GUARD_SCHEMA_META, GuardDenial, GuardDenialBody, GuardDeny, GuardMap, GuardParams, GuardRun, GuardedParamNames, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, HandleArgs, HandlerContextBrand, HandlerContextOf, HandlersFromRoutes, JOBS_META, JobDescriptor, JobDispatchError, JobErrorHandler, JobFnByKey, JobHandler, JobHandlers, JobInputError, JobMessage, JobRunner, JobRunnerOptions, JobTransport, JobWorker, JobWorkerContext, Jobs, JobsMeta, MatchResult, Method, MountArgsOf, MountedOf, PathSegment, PluginArgs, PluginDeclaration, PluginDefinition, PluginExportValues, PluginExportsOf, PluginRoutes, PluginRoutesOf, ProblemDetails, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, RawInputs, RawResponse, RenderedResult, RequestContextMap, RequestContextRun, RequestContextValues, RequestPipeline, ResolvedPlugin, ResponseError, ResponseHeaders, ResponseValidationError, RouteDefinition, RouteHandler, RouteMatch, RouteMatcher, RoutePath, Router, Routes, RoutesWithHandlerContext, SCHEMES_META, ScheduledJob, ServerOptions, StreamContext, ToolDefinition, ToolInputSchema, ValidationFailure, ValidationStage, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
package/dist/adapter.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as
|
|
3
|
-
|
|
4
|
-
import { Ct as ScheduledJob, K as JobHandlers, St as JobWorkerContext, U as JobHandler, V as FlattenedJob, X as Jobs, _ as isTagSet, _t as JobMessage, b as isStreamResponse, dt as JobRunner, et as flattenJobs, f as NormalizeTags, ft as JobRunnerOptions, gt as JobDispatchError, ht as JobDescriptor, it as JobErrorHandler, mt as jobFnAt, ot as JobFnByKey, pt as createJobRunner, rt as jobAt, st as JobInputError, tt as isCompiledJob, vt as JobTransport, wt as createJobTransport, xt as JobWorker, z as CompiledJob } from "./api-definition-BHnh15zD.mjs";
|
|
5
|
-
export { ADAPTER_CONTEXT, API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, AccessCheckInput, Adapter, AdapterDefinition, AdapterRequest, AdapterResult, AnyAdapter, ApiBrand, ApiParts, ApiPlugins, ApiRouter, ApiWithRouter, AutoResponsesBrand, BrandedHandlerContext, CompiledJob, ContextFromAuth, DISPATCH_ROUTE_KEY, EncodeStreamOptions, ErrorFormatter, FlattenedJob, FlattenedRoute, GUARDS_META, GUARD_SCHEMA_META, GuardDenial, GuardDenialBody, GuardDeny, GuardMap, GuardParams, GuardRun, GuardedParamNames, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, HandleArgs, HandlerContextBrand, HandlerContextOf, HandlersFromRoutes, JOBS_META, JobDescriptor, JobDispatchError, JobErrorHandler, JobFnByKey, JobHandler, JobHandlers, JobInputError, JobMessage, JobRunner, JobRunnerOptions, JobTransport, JobWorker, JobWorkerContext, Jobs, JobsMeta, MatchResult, Method, MountArgsOf, MountedOf, NormalizeTags, PathSegment, PluginArgs, PluginDeclaration, PluginDefinition, PluginExportValues, PluginExportsOf, PluginPropsOf, PluginRouter, PluginRoutes, PluginRoutesOf, ProblemDetails, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_TAG, RUN_ROUTE_KEY, RawInputs, RawResponse, RenderedResult, RequestContextMap, RequestContextRun, RequestContextValues, RequestPipeline, ResponseError, ResponseHeaders, ResponseValidationError, RouteDefinition, RouteHandler, RouteMatch, RouteMatcher, RoutePath, Router, Routes, RoutesWithHandlerContext, SCHEMES_META, ScheduledJob, ServerOptions, StreamContext, ValidationFailure, ValidationStage, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, contractOf, createAdapter, createJobRunner, createJobTransport, createPlugin, dispatchHandler, dispatchRoute, encodeStreamBody, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, isTagSet, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePluginServers, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, sortFlattenedRoutes, tagRoutes, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
|
1
|
+
import { A as AutoResponsesBrand, B as ROUTES_GROUP, D as AUTO_RESPONSES_BRAND, I as HANDLER_CONTEXT_BRAND, K as RouteDefinition, L as HandlerContextBrand, T as AUTO_GUARD_BRAND, W as ResponseHeaders, Y as RoutePath, Z as Routes, at as ProblemDetails, c as authenticationChallenge, f as resolveSecurityRequirements, st as problemDetails, z as Method } from "./error-response-NoOGdh8H.mjs";
|
|
2
|
+
import { $ as jobRunnerFrom, $i as StreamContext, $n as jobAt, $r as BrandedHandlerContext, $t as ResolvedPlugin, A as RenderedResult, B as bearerChallenge, Bt as PluginArgs, C as JOBS_META, Ca as requiresDenial, Ci as validateRequest, D as REQUEST_CONTEXT_META, E as MountedOf, F as RouteMatcher, Fi as describeTool, Fn as FlattenedJob, Ft as ApiPlugins, G as dispatchRoute, Gi as buildPath, Gr as rawResponse, H as contractOf, Hn as JobHandlers, Hr as isGroupSet, Ht as PluginDefinition, I as SCHEMES_META, Ii as selectToolRoutes, J as guardDenyFor, Ji as EncodeStreamOptions, Jr as MatchResult, Jt as PluginRoutes, K as extractCredential, Ki as parsePath, Kn as Jobs, L as ServerOptions, Li as toolOptionsOf, M as RequestContextRun, Mi as ToolInputSchema, N as RequestPipeline, Ni as buildToolDefinitions, Nn as CompiledJob, O as ROUTER_META, P as ResponseValidationError, Pi as buildToolInputSchema, Q as jobRoutes, R as adapterContextOf, Ri as toolRefusal, S as HandlerContextOf, Sa as insufficientScope, Si as isRouteDefinition, T as MountArgsOf, U as defineAdapter, Ui as PathSegment, Ur as RawResponse, Ut as PluginExportValues, V as boundJobKeys, Vt as PluginDeclaration, W as dispatchHandler, Wr as isRawResponse, Wt as PluginExportsOf, X as isGuardDenial, Xn as flattenJobs, Xr as matchRoute, Y as headersToObject, Yr as RouteMatch, Yt as PluginRoutesOf, Z as jobRouter, Zn as isCompiledJob, Zr as sortFlattenedRoutes, _ as GuardDeny, _i as ValidationFailure, _r as JobWorker, _t as isStreamResponse, a as AdapterRequest, at as runRoute, b as HANDLER_ARG_KEYS, bi as flattenRoutes, br as defineJobTransport, c as ApiBrand, cr as JobRunnerOptions, ct as ResponseError, d as DISPATCH_ROUTE_KEY, di as RequestContextValues, dr as JobDescriptor, dt as pluginExportsOf, ei as ContextFromAuth, er as JobErrorHandler, et as parseBodyText, f as ErrorFormatter, fr as JobDispatchError, ft as pluginRouterOf, g as GuardDenialBody, h as GuardDenial, hi as RoutesWithHandlerContext, i as AdapterDefinition, ia as encodeStreamBody, in as pluginRouteTree, it as runHandler, j as RequestContextMap, ji as ToolDefinition, k as RUN_ROUTE_KEY, l as ApiParts, li as HandlersFromRoutes, lr as createJobRunner, lt as groupRoutes, m as GUARD_SCHEMA_META, mi as Router, mr as JobTransport, mt as resolvePlugins, n as API_META, nr as JobFnByKey, nt as renderJsonResult, o as AdapterResult, oi as GuardedParamNames, ot as warnUnsupportedJobOptions, p as GUARDS_META, pi as RouteHandler, pr as JobMessage, pt as pluginRoutesOf, q as getHeaderValue, r as Adapter, ri as GuardParams, rn as definePlugin, rr as JobInputError, rt as routerFromRoutes, s as AnyAdapter, sr as JobRunner, st as ApiRouter, t as ADAPTER_CONTEXT, ti as FlattenedRoute, tt as parseFetchBody, u as ApiWithRouter, ui as RawInputs, ur as jobFnAt, ut as createApiReference, v as GuardMap, vi as ValidationStage, vr as JobWorkerContext, w as JobsMeta, wa as withPermissions, x as HandleArgs, xa as AccessCheckInput, xi as formatValidationError, y as GuardRun, yi as allowedMethodsForPath, yr as ScheduledJob, z as assembleApi, zn as JobHandler } from "./adapter-D4bTPElA.mjs";
|
|
3
|
+
export { ADAPTER_CONTEXT, API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, AccessCheckInput, Adapter, AdapterDefinition, AdapterRequest, AdapterResult, AnyAdapter, ApiBrand, ApiParts, ApiPlugins, ApiRouter, ApiWithRouter, AutoResponsesBrand, BrandedHandlerContext, CompiledJob, ContextFromAuth, DISPATCH_ROUTE_KEY, EncodeStreamOptions, ErrorFormatter, FlattenedJob, FlattenedRoute, GUARDS_META, GUARD_SCHEMA_META, GuardDenial, GuardDenialBody, GuardDeny, GuardMap, GuardParams, GuardRun, GuardedParamNames, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, HandleArgs, HandlerContextBrand, HandlerContextOf, HandlersFromRoutes, JOBS_META, JobDescriptor, JobDispatchError, JobErrorHandler, JobFnByKey, JobHandler, JobHandlers, JobInputError, JobMessage, JobRunner, JobRunnerOptions, JobTransport, JobWorker, JobWorkerContext, Jobs, JobsMeta, MatchResult, Method, MountArgsOf, MountedOf, PathSegment, PluginArgs, PluginDeclaration, PluginDefinition, PluginExportValues, PluginExportsOf, PluginRoutes, PluginRoutesOf, ProblemDetails, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, RawInputs, RawResponse, RenderedResult, RequestContextMap, RequestContextRun, RequestContextValues, RequestPipeline, ResolvedPlugin, ResponseError, ResponseHeaders, ResponseValidationError, RouteDefinition, RouteHandler, RouteMatch, RouteMatcher, RoutePath, Router, Routes, RoutesWithHandlerContext, SCHEMES_META, ScheduledJob, ServerOptions, StreamContext, ToolDefinition, ToolInputSchema, ValidationFailure, ValidationStage, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
package/dist/adapter.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { c as
|
|
5
|
-
export { API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, DISPATCH_ROUTE_KEY, GUARDS_META, GUARD_SCHEMA_META, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, JOBS_META, JobDispatchError, JobInputError, REQUEST_CONTEXT_META, ROUTER_META,
|
|
1
|
+
import { a as definePlugin, d as AUTO_RESPONSES_BRAND, g as ROUTES_GROUP, l as AUTO_GUARD_BRAND, m as HANDLER_CONTEXT_BRAND, o as pluginRouteTree } from "./plugin-xxCxibmu.mjs";
|
|
2
|
+
import { N as encodeStreamBody, U as isStreamResponse, _ as jobAt, a as pluginRoutesOf, ct as allowedMethodsForPath, dt as isRouteDefinition, ft as validateRequest, h as isCompiledJob, i as pluginRouterOf, lt as flattenRoutes, m as flattenJobs, o as resolvePlugins, ot as buildPath, r as pluginExportsOf, st as parsePath, t as createApiReference, ut as formatValidationError } from "./plugin-server-BztlE1fz.mjs";
|
|
3
|
+
import { l as authenticationChallenge, p as resolveSecurityRequirements } from "./schemas-HW2FDsvz.mjs";
|
|
4
|
+
import { A as renderJsonResult, B as sortFlattenedRoutes, C as headersToObject, D as jobRunnerFrom, E as jobRoutes, F as isRawResponse, G as defineJobTransport, H as requiresDenial, I as rawResponse, J as jobFnAt, K as JobInputError, M as runHandler, N as runRoute, O as parseBodyText, P as warnUnsupportedJobOptions, S as guardDenyFor, St as toolRefusal, T as jobRouter, U as withPermissions, V as insufficientScope, W as JobDispatchError, Y as ResponseError, _ as defineAdapter, _t as buildToolDefinitions, a as HANDLER_ARG_KEYS, b as extractCredential, bt as selectToolRoutes, c as ROUTER_META, d as SCHEMES_META, f as adapterContextOf, ft as isGroupSet, g as contractOf, h as boundJobKeys, i as GUARD_SCHEMA_META, j as routerFromRoutes, k as parseFetchBody, l as RUN_ROUTE_KEY, m as bearerChallenge, mt as groupRoutes, n as DISPATCH_ROUTE_KEY, nt as problemDetails, o as JOBS_META, p as assembleApi, q as createJobRunner, r as GUARDS_META, s as REQUEST_CONTEXT_META, t as API_META, u as ResponseValidationError, v as dispatchHandler, vt as buildToolInputSchema, w as isGuardDenial, x as getHeaderValue, xt as toolOptionsOf, y as dispatchRoute, yt as describeTool, z as matchRoute } from "./adapter-BSqNrxhq.mjs";
|
|
5
|
+
export { API_META, AUTO_GUARD_BRAND, AUTO_RESPONSES_BRAND, DISPATCH_ROUTE_KEY, GUARDS_META, GUARD_SCHEMA_META, HANDLER_ARG_KEYS, HANDLER_CONTEXT_BRAND, JOBS_META, JobDispatchError, JobInputError, REQUEST_CONTEXT_META, ROUTER_META, ROUTES_GROUP, RUN_ROUTE_KEY, ResponseError, ResponseValidationError, SCHEMES_META, adapterContextOf, allowedMethodsForPath, assembleApi, authenticationChallenge, bearerChallenge, boundJobKeys, buildPath, buildToolDefinitions, buildToolInputSchema, contractOf, createApiReference, createJobRunner, defineAdapter, defineJobTransport, definePlugin, describeTool, dispatchHandler, dispatchRoute, encodeStreamBody, extractCredential, flattenJobs, flattenRoutes, formatValidationError, getHeaderValue, groupRoutes, guardDenyFor, headersToObject, insufficientScope, isCompiledJob, isGroupSet, isGuardDenial, isRawResponse, isRouteDefinition, isStreamResponse, jobAt, jobFnAt, jobRouter, jobRoutes, jobRunnerFrom, matchRoute, parseBodyText, parseFetchBody, parsePath, pluginExportsOf, pluginRouteTree, pluginRouterOf, pluginRoutesOf, problemDetails, rawResponse, renderJsonResult, requiresDenial, resolvePlugins, resolveSecurityRequirements, routerFromRoutes, runHandler, runRoute, selectToolRoutes, sortFlattenedRoutes, toolOptionsOf, toolRefusal, validateRequest, warnUnsupportedJobOptions, withPermissions };
|
|
@@ -59,23 +59,30 @@ const resolveBaseType = (schema) => {
|
|
|
59
59
|
return def.type ?? "";
|
|
60
60
|
};
|
|
61
61
|
/**
|
|
62
|
-
* Removes optional/nullable/default wrappers, returning the inner schema
|
|
63
|
-
* whether
|
|
62
|
+
* Removes optional/nullable/default wrappers, returning the inner schema,
|
|
63
|
+
* whether the key may be absent, and whether the value may be null. A
|
|
64
|
+
* `z.string().nullable()` field is required, so it reports `optional: false`.
|
|
64
65
|
*/
|
|
65
66
|
const unwrapOptionalWrappers = (schema) => {
|
|
66
67
|
let current = schema;
|
|
67
68
|
let optional = false;
|
|
69
|
+
let nullable = false;
|
|
68
70
|
while (true) {
|
|
69
71
|
const def = readDef(current);
|
|
70
|
-
if (def.type
|
|
71
|
-
|
|
72
|
+
if (def.type === "optional" || def.type === "default") optional = true;
|
|
73
|
+
else if (def.type === "nullable") nullable = true;
|
|
74
|
+
else if (def.type === "nullish") {
|
|
75
|
+
optional = true;
|
|
76
|
+
nullable = true;
|
|
77
|
+
} else break;
|
|
72
78
|
const next = def.innerType;
|
|
73
79
|
if (!next) break;
|
|
74
80
|
current = next;
|
|
75
81
|
}
|
|
76
82
|
return {
|
|
77
83
|
inner: current,
|
|
78
|
-
optional
|
|
84
|
+
optional,
|
|
85
|
+
nullable
|
|
79
86
|
};
|
|
80
87
|
};
|
|
81
88
|
/**
|
|
@@ -230,6 +237,13 @@ const readMetaDescription = (schema) => {
|
|
|
230
237
|
return typeof description === "string" ? description : void 0;
|
|
231
238
|
};
|
|
232
239
|
/**
|
|
240
|
+
* Returns a schema's `brand` metadata, set by `Kizuna.brand`, or undefined.
|
|
241
|
+
*/
|
|
242
|
+
const readMetaBrand = (schema) => {
|
|
243
|
+
const brand = readMeta(schema)?.brand;
|
|
244
|
+
return typeof brand === "string" ? brand : void 0;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
233
247
|
* The `Kizuna.model` schemas in the global registry, keyed by their `id`.
|
|
234
248
|
*/
|
|
235
249
|
const globalRegistrySchemas = () => {
|
|
@@ -460,6 +474,12 @@ Object.defineProperty(exports, "readMeta", {
|
|
|
460
474
|
return readMeta;
|
|
461
475
|
}
|
|
462
476
|
});
|
|
477
|
+
Object.defineProperty(exports, "readMetaBrand", {
|
|
478
|
+
enumerable: true,
|
|
479
|
+
get: function() {
|
|
480
|
+
return readMetaBrand;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
463
483
|
Object.defineProperty(exports, "readMetaDescription", {
|
|
464
484
|
enumerable: true,
|
|
465
485
|
get: function() {
|
|
@@ -59,23 +59,30 @@ const resolveBaseType = (schema) => {
|
|
|
59
59
|
return def.type ?? "";
|
|
60
60
|
};
|
|
61
61
|
/**
|
|
62
|
-
* Removes optional/nullable/default wrappers, returning the inner schema
|
|
63
|
-
* whether
|
|
62
|
+
* Removes optional/nullable/default wrappers, returning the inner schema,
|
|
63
|
+
* whether the key may be absent, and whether the value may be null. A
|
|
64
|
+
* `z.string().nullable()` field is required, so it reports `optional: false`.
|
|
64
65
|
*/
|
|
65
66
|
const unwrapOptionalWrappers = (schema) => {
|
|
66
67
|
let current = schema;
|
|
67
68
|
let optional = false;
|
|
69
|
+
let nullable = false;
|
|
68
70
|
while (true) {
|
|
69
71
|
const def = readDef(current);
|
|
70
|
-
if (def.type
|
|
71
|
-
|
|
72
|
+
if (def.type === "optional" || def.type === "default") optional = true;
|
|
73
|
+
else if (def.type === "nullable") nullable = true;
|
|
74
|
+
else if (def.type === "nullish") {
|
|
75
|
+
optional = true;
|
|
76
|
+
nullable = true;
|
|
77
|
+
} else break;
|
|
72
78
|
const next = def.innerType;
|
|
73
79
|
if (!next) break;
|
|
74
80
|
current = next;
|
|
75
81
|
}
|
|
76
82
|
return {
|
|
77
83
|
inner: current,
|
|
78
|
-
optional
|
|
84
|
+
optional,
|
|
85
|
+
nullable
|
|
79
86
|
};
|
|
80
87
|
};
|
|
81
88
|
/**
|
|
@@ -230,6 +237,13 @@ const readMetaDescription = (schema) => {
|
|
|
230
237
|
return typeof description === "string" ? description : void 0;
|
|
231
238
|
};
|
|
232
239
|
/**
|
|
240
|
+
* Returns a schema's `brand` metadata, set by `Kizuna.brand`, or undefined.
|
|
241
|
+
*/
|
|
242
|
+
const readMetaBrand = (schema) => {
|
|
243
|
+
const brand = readMeta(schema)?.brand;
|
|
244
|
+
return typeof brand === "string" ? brand : void 0;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
233
247
|
* The `Kizuna.model` schemas in the global registry, keyed by their `id`.
|
|
234
248
|
*/
|
|
235
249
|
const globalRegistrySchemas = () => {
|
|
@@ -340,4 +354,4 @@ function isProblemDetails(body) {
|
|
|
340
354
|
return typeof candidate.type === "string" && typeof candidate.title === "string" && typeof candidate.status === "number" && typeof candidate.detail === "string";
|
|
341
355
|
}
|
|
342
356
|
//#endregion
|
|
343
|
-
export {
|
|
357
|
+
export { readMetaExamples as C, unwrapOptionalWrappers as D, resolveBaseType as E, readMetaDescription as S, readObjectShape as T, readDiscriminatedUnion as _, WRAPPER_TYPES as a, readMeta as b, isBinarySchema as c, isIntegerSchema as d, isObjectSchema as f, readDeprecation as g, readDefType as h, FILE_PROBE as i, isDiscriminatedUnionSchema as l, readDef as m, isProblemDetails as n, findCoercedSchemaPath as o, isVoidSchema as p, createModel as r, globalRegistrySchemas as s, ProblemDetailsSchema as t, isFileSchema as u, readDiscriminatorLiteral as v, readMetaId as w, readMetaBrand as x, readDiscriminatorStringLiteral as y };
|
|
@@ -287,6 +287,18 @@ type RouteAuth<Names extends string = string> = false | Names | readonly Names[]
|
|
|
287
287
|
roles?: string | readonly string[];
|
|
288
288
|
requires?: RequiredPermissions;
|
|
289
289
|
};
|
|
290
|
+
/**
|
|
291
|
+
* Rejects a route that is both `hidden` and a `tool`: a hidden route is left out
|
|
292
|
+
* of everything that publishes routes, MCP included.
|
|
293
|
+
*/
|
|
294
|
+
type RouteHiddenToolCheck<Route> = Route extends {
|
|
295
|
+
hidden: true;
|
|
296
|
+
tool: true | RouteToolOptions;
|
|
297
|
+
} ? {
|
|
298
|
+
tool: {
|
|
299
|
+
'kizuna: a hidden route cannot publish as a tool. Remove `tool`, or `hidden`': true;
|
|
300
|
+
};
|
|
301
|
+
} : unknown;
|
|
290
302
|
/**
|
|
291
303
|
* Response headers keyed by name.
|
|
292
304
|
*/
|
|
@@ -310,7 +322,7 @@ declare const HANDLER: unique symbol;
|
|
|
310
322
|
type RouteHandlerFunction = (args: never) => unknown;
|
|
311
323
|
/**
|
|
312
324
|
* What a route publishes as, over MCP. `description`, `title` and the four
|
|
313
|
-
* hints are MCP's own, field for field; `
|
|
325
|
+
* hints are MCP's own, field for field; `needsApproval` is kizuna's.
|
|
314
326
|
*
|
|
315
327
|
* Each hint defaults from the route's method, so a `GET` is already marked read
|
|
316
328
|
* only and a `DELETE` already destructive. Set one to say what the method
|
|
@@ -348,16 +360,18 @@ interface RouteToolOptions {
|
|
|
348
360
|
*/
|
|
349
361
|
openWorldHint?: boolean;
|
|
350
362
|
/**
|
|
351
|
-
*
|
|
352
|
-
* decline, and declining leaves the handler uncalled.
|
|
363
|
+
* The person approves each call before it runs as a tool.
|
|
353
364
|
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```ts
|
|
367
|
+
* tool: {
|
|
368
|
+
* needsApproval: true,
|
|
369
|
+
* },
|
|
370
|
+
* ```
|
|
357
371
|
*/
|
|
358
|
-
|
|
372
|
+
needsApproval?: boolean;
|
|
359
373
|
}
|
|
360
|
-
interface RouteDefinition<
|
|
374
|
+
interface RouteDefinition<GroupPaths extends string = string, SchemeNames extends string = string> {
|
|
361
375
|
method: Method;
|
|
362
376
|
/**
|
|
363
377
|
* What this route requires of its caller. See {@link RouteAuth}.
|
|
@@ -386,6 +400,59 @@ interface RouteDefinition<TagKeys extends string = string, SchemeNames extends s
|
|
|
386
400
|
* },
|
|
387
401
|
*/
|
|
388
402
|
tool?: boolean | RouteToolOptions;
|
|
403
|
+
/**
|
|
404
|
+
* Keep this route out of the generated clients, the OpenAPI document and
|
|
405
|
+
* MCP. It is still served.
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* ```ts
|
|
409
|
+
* check: k
|
|
410
|
+
* .route({
|
|
411
|
+
* method: 'GET',
|
|
412
|
+
* path: '/health',
|
|
413
|
+
* hidden: true,
|
|
414
|
+
* responses: {
|
|
415
|
+
* 200: HealthSchema,
|
|
416
|
+
* },
|
|
417
|
+
* })
|
|
418
|
+
* .handler(() => ({
|
|
419
|
+
* status: 200,
|
|
420
|
+
* body: {
|
|
421
|
+
* status: 'ok',
|
|
422
|
+
* },
|
|
423
|
+
* })),
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
hidden?: boolean;
|
|
427
|
+
/**
|
|
428
|
+
* Receive the body exactly as it was sent, as `rawBody`, beside the
|
|
429
|
+
* validated `body`. Check a sender's signature against `rawBody`, since
|
|
430
|
+
* re-serialising the JSON can change a byte and break it.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* resendEvents: k
|
|
435
|
+
* .route({
|
|
436
|
+
* method: 'POST',
|
|
437
|
+
* path: '/webhooks/resend',
|
|
438
|
+
* auth: false,
|
|
439
|
+
* hidden: true,
|
|
440
|
+
* rawBody: true,
|
|
441
|
+
* body: ResendEventSchema,
|
|
442
|
+
* responses: {
|
|
443
|
+
* 204: z.void(),
|
|
444
|
+
* },
|
|
445
|
+
* })
|
|
446
|
+
* .handler(({ rawBody, headers }) => {
|
|
447
|
+
* verifySignature(rawBody, headers);
|
|
448
|
+
*
|
|
449
|
+
* return {
|
|
450
|
+
* status: 204,
|
|
451
|
+
* };
|
|
452
|
+
* }),
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
rawBody?: true;
|
|
389
456
|
/**
|
|
390
457
|
* Deprecates the route. Pass a message to tell callers what to use instead,
|
|
391
458
|
* or the object form to announce the deprecation in response headers.
|
|
@@ -439,11 +506,9 @@ interface RouteDefinition<TagKeys extends string = string, SchemeNames extends s
|
|
|
439
506
|
link?: string;
|
|
440
507
|
};
|
|
441
508
|
/**
|
|
442
|
-
*
|
|
443
|
-
* declared with `k.tags`; `k.routes` stamps the group's tag onto every
|
|
444
|
-
* route, and the generator resolves each key to its `title` for the spec.
|
|
509
|
+
* More groups to list this route under, as dotted paths.
|
|
445
510
|
*/
|
|
446
|
-
|
|
511
|
+
groups?: readonly GroupPaths[];
|
|
447
512
|
/**
|
|
448
513
|
* The security schemes this route requires, referencing identities named
|
|
449
514
|
* under `identities` on `defineConfig`. Each entry is a scheme name or a
|
|
@@ -507,11 +572,9 @@ interface RouteDefinition<TagKeys extends string = string, SchemeNames extends s
|
|
|
507
572
|
[HANDLER]?: RouteHandlerFunction;
|
|
508
573
|
}
|
|
509
574
|
/**
|
|
510
|
-
*
|
|
511
|
-
* `flattenRoutes` and the generator use to apply the group's tag to every route
|
|
512
|
-
* in it. Stamped by `k.routes`.
|
|
575
|
+
* Where a tree from `k.routes` carries its group's dotted path.
|
|
513
576
|
*/
|
|
514
|
-
declare const
|
|
577
|
+
declare const ROUTES_GROUP: unique symbol;
|
|
515
578
|
/**
|
|
516
579
|
* Type-only key under which `defineConfig` brands each route with its resolved
|
|
517
580
|
* handler context. Never written at runtime.
|
|
@@ -541,16 +604,16 @@ interface AutoResponsesBrand<Statuses extends number, Body = ProblemDetails, Wri
|
|
|
541
604
|
* The statuses a route's `auth` puts on it once it names an identity.
|
|
542
605
|
*/
|
|
543
606
|
type GuardStatus = Extract<KnownStatus, 401 | 403>;
|
|
544
|
-
interface Routes<
|
|
545
|
-
[
|
|
546
|
-
[key: string]: RouteDefinition<
|
|
607
|
+
interface Routes<GroupPaths extends string = string, SchemeNames extends string = string> {
|
|
608
|
+
[ROUTES_GROUP]?: string;
|
|
609
|
+
[key: string]: RouteDefinition<GroupPaths, SchemeNames> | Routes<GroupPaths, SchemeNames>;
|
|
547
610
|
}
|
|
548
611
|
/**
|
|
549
612
|
* A route as authored in `k.route` and `k.routes`: the route shape minus
|
|
550
613
|
* `security`, `roles` and `requires`, which `defineConfig` resolves from its
|
|
551
614
|
* `auth`. Writing any of them on a route is a type error.
|
|
552
615
|
*/
|
|
553
|
-
type AuthoredRouteDefinition<
|
|
616
|
+
type AuthoredRouteDefinition<GroupPaths extends string = string, Names extends string = string> = Omit<RouteDefinition<GroupPaths>, 'security' | 'roles' | 'requires' | 'auth'> & {
|
|
554
617
|
security?: never;
|
|
555
618
|
roles?: never;
|
|
556
619
|
requires?: never;
|
|
@@ -562,9 +625,9 @@ type AuthoredRouteDefinition<TagKeys extends string = string, Names extends stri
|
|
|
562
625
|
/**
|
|
563
626
|
* A tree of {@link AuthoredRouteDefinition}s, the shape `k.routes` accepts.
|
|
564
627
|
*/
|
|
565
|
-
interface AuthoredRoutes<
|
|
566
|
-
[
|
|
567
|
-
[key: string]: AuthoredRouteDefinition<
|
|
628
|
+
interface AuthoredRoutes<GroupPaths extends string = string, Names extends string = string> {
|
|
629
|
+
[ROUTES_GROUP]?: string;
|
|
630
|
+
[key: string]: AuthoredRouteDefinition<GroupPaths, Names> | AuthoredRoutes<GroupPaths, Names>;
|
|
568
631
|
}
|
|
569
632
|
//#endregion
|
|
570
633
|
//#region src/permissions.d.ts
|
|
@@ -794,4 +857,68 @@ declare const resolveSecurityRequirements: (route: RouteDefinition) => Array<{
|
|
|
794
857
|
scopes: string[];
|
|
795
858
|
}>;
|
|
796
859
|
//#endregion
|
|
797
|
-
|
|
860
|
+
//#region src/error-response.d.ts
|
|
861
|
+
/**
|
|
862
|
+
* RFC 9457 Problem Details, the single error schema used across kizuna.
|
|
863
|
+
*
|
|
864
|
+
* Matches the shape returned by `deny()` in guards, validation errors,
|
|
865
|
+
* and all built-in error responses (404, 405, 415, etc.).
|
|
866
|
+
*
|
|
867
|
+
* ```ts
|
|
868
|
+
* import { ProblemDetailsSchema } from 'kizunajs/schemas';
|
|
869
|
+
*
|
|
870
|
+
* const routes = k.routes({
|
|
871
|
+
* getUser: {
|
|
872
|
+
* method: 'GET',
|
|
873
|
+
* path: '/users/:id',
|
|
874
|
+
* responses: {
|
|
875
|
+
* 200: UserSchema,
|
|
876
|
+
* 404: ProblemDetailsSchema,
|
|
877
|
+
* },
|
|
878
|
+
* },
|
|
879
|
+
* });
|
|
880
|
+
* ```
|
|
881
|
+
*
|
|
882
|
+
* Add domain fields as RFC 9457 **extension members** with native `.extend`, inline:
|
|
883
|
+
*
|
|
884
|
+
* ```ts
|
|
885
|
+
* responses: {
|
|
886
|
+
* 409: ProblemDetailsSchema.extend({
|
|
887
|
+
* conflictingId: z.string(),
|
|
888
|
+
* }),
|
|
889
|
+
* }
|
|
890
|
+
* ```
|
|
891
|
+
*
|
|
892
|
+
* or as a named component (appears in the OpenAPI spec) via `Kizuna.model`:
|
|
893
|
+
*
|
|
894
|
+
* ```ts
|
|
895
|
+
* export const ConflictError = Kizuna.model({
|
|
896
|
+
* title: 'ConflictError',
|
|
897
|
+
* schema: ProblemDetailsSchema.extend({
|
|
898
|
+
* conflictingId: z.string(),
|
|
899
|
+
* }),
|
|
900
|
+
* });
|
|
901
|
+
* ```
|
|
902
|
+
*
|
|
903
|
+
* The handler supplies `detail` plus any extensions; `type`/`title`/`status` are
|
|
904
|
+
* auto-filled. Extension members are also how an API migrating onto kizuna keeps its
|
|
905
|
+
* existing error fields (e.g. `errorCode`, `requestId`), old clients still read them.
|
|
906
|
+
*/
|
|
907
|
+
declare const ProblemDetailsSchema: z.ZodObject<{
|
|
908
|
+
type: z.ZodString;
|
|
909
|
+
title: z.ZodString;
|
|
910
|
+
status: z.ZodNumber;
|
|
911
|
+
detail: z.ZodString;
|
|
912
|
+
}, z.core.$strip>;
|
|
913
|
+
/**
|
|
914
|
+
* Type guard for an RFC 9457 Problem Details body, the shared shape behind every kizuna
|
|
915
|
+
* error response (validation failures, guards, handler errors, built-in 404/405/415, …).
|
|
916
|
+
*/
|
|
917
|
+
declare function isProblemDetails(body: unknown): body is {
|
|
918
|
+
type: string;
|
|
919
|
+
title: string;
|
|
920
|
+
status: number;
|
|
921
|
+
detail: string;
|
|
922
|
+
};
|
|
923
|
+
//#endregion
|
|
924
|
+
export { SecurityRequirement as $, AutoResponsesBrand as A, ROUTES_GROUP as B, isPermissions as C, AUTO_RESPONSES_BRAND as D, AUTO_GUARD_WRITTEN_BRAND as E, HANDLER as F, RouteAuth as G, ResponseContentType as H, HANDLER_CONTEXT_BRAND as I, RouteHiddenToolCheck as J, RouteDefinition as K, HandlerContextBrand as L, DECLARATION as M, DeclarationKind as N, AuthoredRouteDefinition as O, GuardStatus as P, SchemeNameOf as Q, METHODS as R, createRoles as S, AUTO_GUARD_BRAND as T, ResponseDefinition as U, RequiredPermissions as V, ResponseHeaders as W, RouteToolOptions as X, RoutePath as Y, Routes as Z, PermissionSet as _, OAuthFlows as a, ProblemDetails as at, RoleNamesOf as b, authenticationChallenge as c, problemFromBody as ct, isSecurityScheme as d, StreamDefinition as et, resolveSecurityRequirements as f, PermissionName as g, PermissionCatalog as h, OAuthFlow as i, GuardSchemaCheck as it, CachePolicy as j, AuthoredRoutes as k, authorizationServerIssuer as l, STATUS_TITLES as lt, GrantNamesOf as m, isProblemDetails as n, GuardBody as nt, OpenApiSecuritySchemeObject as o, StripProblemEnvelope as ot, CatalogOf as p, RouteHandlerFunction as q, ContextOf as r, GuardOutput as rt, SecurityScheme as s, problemDetails as st, ProblemDetailsSchema as t, StreamResponseDefinition as tt, declaredScopes as u, getStatusText as ut, Permissions as v, isRoles as w, Roles as x, RoleDefinition as y, Method as z };
|