shokupan 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{analyzer-BkNQHWj4.js → analyzer-B0fMzeIo.js} +2 -2
- package/dist/{analyzer-BkNQHWj4.js.map → analyzer-B0fMzeIo.js.map} +1 -1
- package/dist/{analyzer-DM-OlRq8.cjs → analyzer-BOtveWL-.cjs} +2 -2
- package/dist/{analyzer-DM-OlRq8.cjs.map → analyzer-BOtveWL-.cjs.map} +1 -1
- package/dist/{analyzer.impl-CVJ8zfGQ.cjs → analyzer.impl-CUDO6vpn.cjs} +72 -5
- package/dist/analyzer.impl-CUDO6vpn.cjs.map +1 -0
- package/dist/{analyzer.impl-CsA1bS_s.js → analyzer.impl-DmHe92Oi.js} +72 -5
- package/dist/analyzer.impl-DmHe92Oi.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1849 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1892 -233
- package/dist/index.js.map +1 -1
- package/dist/plugins/application/error-view/index.d.ts +14 -0
- package/dist/plugins/application/error-view/monkeypatch.d.ts +9 -0
- package/dist/plugins/application/error-view/util/source-reader.d.ts +10 -0
- package/dist/plugins/application/error-view/views/error.d.ts +2 -0
- package/dist/plugins/application/error-view/views/status.d.ts +2 -0
- package/dist/plugins/application/htmx/index.d.ts +39 -0
- package/dist/plugins/application/mcp-server/plugin.d.ts +1 -2
- package/dist/plugins/application/openapi/test-setup.d.ts +1 -0
- package/dist/plugins/application/opentelemetry/index.d.ts +33 -0
- package/dist/plugins/middleware/session.d.ts +4 -4
- package/dist/plugins/resilience/decorators.d.ts +23 -0
- package/dist/plugins/resilience/factory.d.ts +5 -0
- package/dist/plugins/resilience/index.d.ts +2 -0
- package/dist/router.d.ts +20 -5
- package/dist/util/decorators.d.ts +38 -0
- package/dist/util/env-loader.d.ts +99 -0
- package/dist/util/mcp-protocol.d.ts +52 -0
- package/dist/util/promise.d.ts +16 -0
- package/dist/util/symbol.d.ts +4 -0
- package/dist/util/types.d.ts +10 -2
- package/package.json +36 -11
- package/dist/analyzer.impl-CVJ8zfGQ.cjs.map +0 -1
- package/dist/analyzer.impl-CsA1bS_s.js.map +0 -1
- package/dist/util/instrumentation.d.ts +0 -9
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Shokupan } from '../../../shokupan';
|
|
2
|
+
import { ShokupanPlugin } from '../../../util/types';
|
|
3
|
+
export interface ErrorViewConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Theme for syntax highlighting (default 'dark')
|
|
6
|
+
*/
|
|
7
|
+
theme?: 'light' | 'dark';
|
|
8
|
+
}
|
|
9
|
+
export declare class ErrorView implements ShokupanPlugin {
|
|
10
|
+
private config;
|
|
11
|
+
name: string;
|
|
12
|
+
constructor(config?: ErrorViewConfig);
|
|
13
|
+
onInit(app: Shokupan): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SourceContext {
|
|
2
|
+
lines: {
|
|
3
|
+
line: number;
|
|
4
|
+
code: string;
|
|
5
|
+
isTarget: boolean;
|
|
6
|
+
}[];
|
|
7
|
+
startLine: number;
|
|
8
|
+
file: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function readSourceContext(filePath: string | undefined, line: number, contextLines?: number): Promise<SourceContext | null>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Shokupan } from '../../../shokupan';
|
|
2
|
+
import { Middleware, ShokupanPlugin } from '../../../util/types';
|
|
3
|
+
/**
|
|
4
|
+
* Extends the ShokupanContext interface with HTMX specific helpers.
|
|
5
|
+
*/
|
|
6
|
+
declare module "../../../context" {
|
|
7
|
+
interface ShokupanContext {
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the request is an HTMX request.
|
|
10
|
+
*/
|
|
11
|
+
isHtmx: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the request is boosting.
|
|
14
|
+
*/
|
|
15
|
+
isHtmxBoosted: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the HX-Trigger header.
|
|
18
|
+
*/
|
|
19
|
+
trigger(event: string | Record<string, any>, options?: {
|
|
20
|
+
after?: 'receive' | 'settle' | 'swap';
|
|
21
|
+
}): void;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the HX-Push-Url header.
|
|
24
|
+
*/
|
|
25
|
+
pushUrl(url: string | false): void;
|
|
26
|
+
/**
|
|
27
|
+
* Sets the HX-Redirect header.
|
|
28
|
+
*/
|
|
29
|
+
htmxRedirect(url: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the HX-Refresh header.
|
|
32
|
+
*/
|
|
33
|
+
refresh(): void;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export declare class HtmxPlugin implements ShokupanPlugin {
|
|
37
|
+
onInit(app: Shokupan): Promise<void>;
|
|
38
|
+
middleware(): Middleware;
|
|
39
|
+
}
|
|
@@ -27,11 +27,10 @@ export interface MCPServerPluginOptions {
|
|
|
27
27
|
export declare class MCPServerPlugin implements ShokupanPlugin {
|
|
28
28
|
private options;
|
|
29
29
|
private router;
|
|
30
|
-
private mcpServer;
|
|
31
|
-
private transport;
|
|
32
30
|
private analyzer;
|
|
33
31
|
constructor(options?: MCPServerPluginOptions);
|
|
34
32
|
onInit(app: Shokupan): void;
|
|
33
|
+
private collectAppMcpItems;
|
|
35
34
|
private setupRoutes;
|
|
36
35
|
private registerTools;
|
|
37
36
|
private registerResources;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSharedSpec(): Promise<any>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Shokupan } from '../../../shokupan';
|
|
2
|
+
import { Middleware, ShokupanHandler, ShokupanPlugin } from '../../../util/types';
|
|
3
|
+
export interface OpenTelemetryOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Service name for traces
|
|
6
|
+
*/
|
|
7
|
+
serviceName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Enable auto-instrumentation
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
enableAutoInstrumentation?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* OTLP Endpoint (e.g. http://localhost:4318)
|
|
15
|
+
*/
|
|
16
|
+
otlpEndpoint?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class OpenTelemetryPlugin implements ShokupanPlugin {
|
|
19
|
+
private options;
|
|
20
|
+
private api;
|
|
21
|
+
private sdk;
|
|
22
|
+
constructor(options?: OpenTelemetryOptions);
|
|
23
|
+
onInit(app: Shokupan): Promise<void>;
|
|
24
|
+
middleware(): Middleware;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Wraps a middleware function with an OpenTelemetry span.
|
|
28
|
+
*/
|
|
29
|
+
export declare function traceMiddleware(fn: Middleware, name?: string): Middleware;
|
|
30
|
+
/**
|
|
31
|
+
* Wraps a route handler with an OpenTelemetry span.
|
|
32
|
+
*/
|
|
33
|
+
export declare function traceHandler(fn: ShokupanHandler | ((...args: any[]) => any), name: string): ShokupanHandler;
|
|
@@ -148,10 +148,10 @@ export declare class MemoryStore extends EventEmitter implements Store {
|
|
|
148
148
|
export interface SessionContext {
|
|
149
149
|
session: SessionData & {
|
|
150
150
|
id: string;
|
|
151
|
-
regenerate(
|
|
152
|
-
destroy(
|
|
153
|
-
reload(
|
|
154
|
-
save(
|
|
151
|
+
regenerate(): Promise<void>;
|
|
152
|
+
destroy(): Promise<void>;
|
|
153
|
+
reload(): Promise<void>;
|
|
154
|
+
save(): Promise<void>;
|
|
155
155
|
touch(): void;
|
|
156
156
|
};
|
|
157
157
|
sessionID: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface RetryOptions {
|
|
2
|
+
attempts?: number;
|
|
3
|
+
backoff?: 'constant' | 'exponential';
|
|
4
|
+
delay?: number;
|
|
5
|
+
maxDelay?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CircuitBreakerOptions {
|
|
8
|
+
threshold?: number;
|
|
9
|
+
windowDuration?: number;
|
|
10
|
+
resetTimeout?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ResilienceConfig {
|
|
13
|
+
retry?: RetryOptions;
|
|
14
|
+
circuitBreaker?: CircuitBreakerOptions;
|
|
15
|
+
timeout?: number;
|
|
16
|
+
bulkhead?: number;
|
|
17
|
+
fallback?: any | ((...args: any[]) => any);
|
|
18
|
+
}
|
|
19
|
+
export declare function Retry(options?: RetryOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
20
|
+
export declare function CircuitBreaker(options?: CircuitBreakerOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
21
|
+
export declare function Timeout(duration: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
22
|
+
export declare function Bulkhead(limit: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
23
|
+
export declare function Fallback(valueOrFn: any): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
package/dist/router.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ShokupanContext } from './context';
|
|
2
2
|
import { Shokupan } from './shokupan';
|
|
3
|
+
import { McpProtocol, McpPrompt } from './util/mcp-protocol';
|
|
3
4
|
import { $appRoot, $childControllers, $childRouters, $isApplication, $isMounted, $isRouter, $mountPath, $parent, $routes } from './util/symbol';
|
|
4
5
|
import { GuardAPISpec, HeadersInit, JSXRenderer, Method, MethodAPISpec, Middleware, OpenAPIOptions, ProcessResult, RequestOptions, RouteMetadata, RouteParams, ShokupanController, ShokupanHandler, ShokupanHooks, ShokupanRoute, ShokupanRouteConfig, StaticServeOptions } from './util/types';
|
|
5
6
|
export declare const RouterRegistry: Map<string, ShokupanRouter<any>>;
|
|
@@ -104,6 +105,7 @@ export declare class ShokupanRouter<T extends Record<string, any> = Record<strin
|
|
|
104
105
|
development: boolean;
|
|
105
106
|
enableAsyncLocalStorage: boolean;
|
|
106
107
|
enableOpenApiGen: boolean;
|
|
108
|
+
enablePromiseMonkeypatch: boolean;
|
|
107
109
|
blockOnOpenApiGen: boolean;
|
|
108
110
|
enableAsyncApiGen: boolean;
|
|
109
111
|
blockOnAsyncApiGen: boolean;
|
|
@@ -173,12 +175,13 @@ export declare class ShokupanRouter<T extends Record<string, any> = Record<strin
|
|
|
173
175
|
spec_url: string;
|
|
174
176
|
}>;
|
|
175
177
|
};
|
|
176
|
-
|
|
178
|
+
defaultSecurityHeaders?: boolean | any;
|
|
177
179
|
}>;
|
|
178
180
|
get root(): Shokupan<any>;
|
|
179
181
|
[$routes]: ShokupanRoute[];
|
|
180
182
|
private trie;
|
|
181
183
|
metadata?: RouteMetadata;
|
|
184
|
+
mcpProtocol: McpProtocol;
|
|
182
185
|
private currentGuards;
|
|
183
186
|
private eventHandlers;
|
|
184
187
|
/**
|
|
@@ -239,6 +242,22 @@ export declare class ShokupanRouter<T extends Record<string, any> = Record<strin
|
|
|
239
242
|
* Registers a lifecycle hook dynamically.
|
|
240
243
|
*/
|
|
241
244
|
hook(name: keyof ShokupanHooks, handler: Function): this;
|
|
245
|
+
/**
|
|
246
|
+
* Registers an MCP Tool.
|
|
247
|
+
*/
|
|
248
|
+
tool(name: string, schema: any, handler: Function): this;
|
|
249
|
+
/**
|
|
250
|
+
* Registers an MCP Prompt.
|
|
251
|
+
*/
|
|
252
|
+
prompt(name: string, args: McpPrompt['arguments'], handler: Function): this;
|
|
253
|
+
/**
|
|
254
|
+
* Registers an MCP Resource.
|
|
255
|
+
*/
|
|
256
|
+
resource(uri: string, options: {
|
|
257
|
+
name?: string;
|
|
258
|
+
description?: string;
|
|
259
|
+
mimeType?: string;
|
|
260
|
+
}, handler: Function): this;
|
|
242
261
|
/**
|
|
243
262
|
* Finds an event handler(s) by name.
|
|
244
263
|
*/
|
|
@@ -324,10 +343,6 @@ export declare class ShokupanRouter<T extends Record<string, any> = Record<strin
|
|
|
324
343
|
requestTimeout?: number;
|
|
325
344
|
renderer?: JSXRenderer;
|
|
326
345
|
controller?: any;
|
|
327
|
-
metadata?: {
|
|
328
|
-
file: string;
|
|
329
|
-
line: number;
|
|
330
|
-
};
|
|
331
346
|
middleware?: Middleware[];
|
|
332
347
|
}): this;
|
|
333
348
|
/**
|
|
@@ -94,3 +94,41 @@ export declare function Event(eventName: string): (target: any, propertyKey: str
|
|
|
94
94
|
* Decorator: Applies a rate limit to a class or method.
|
|
95
95
|
*/
|
|
96
96
|
export declare function RateLimit(options: RateLimitOptions): (target: any, propertyKey?: string, indexOrDescriptor?: PropertyDescriptor | number) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Decorator: Registers a method as an MCP Tool.
|
|
99
|
+
* @param name The name of the tool (defaults to method name if not provided)
|
|
100
|
+
* @param description Optional description
|
|
101
|
+
* @param inputSchema Optional JSON Schema for input arguments
|
|
102
|
+
*/
|
|
103
|
+
export declare function Tool(options?: {
|
|
104
|
+
name?: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
inputSchema?: any;
|
|
107
|
+
}): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Decorator: Registers a method as an MCP Prompt.
|
|
110
|
+
* @param name The name of the prompt
|
|
111
|
+
* @param description Optional description
|
|
112
|
+
* @param args Optional list of arguments
|
|
113
|
+
*/
|
|
114
|
+
export declare function Prompt(options?: {
|
|
115
|
+
name?: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
arguments?: {
|
|
118
|
+
name: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
required?: boolean;
|
|
121
|
+
}[];
|
|
122
|
+
}): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Decorator: Registers a method as an MCP Resource handler.
|
|
125
|
+
* @param uri The URI pattern for the resource
|
|
126
|
+
* @param name Optional name
|
|
127
|
+
* @param description Optional description
|
|
128
|
+
* @param mimeType Optional MIME type
|
|
129
|
+
*/
|
|
130
|
+
export declare function Resource(uri: string, options?: {
|
|
131
|
+
name?: string;
|
|
132
|
+
description?: string;
|
|
133
|
+
mimeType?: string;
|
|
134
|
+
}): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type EnvLoaderOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* If provided, k8s secrets will be loaded from the given paths
|
|
4
|
+
* @default []
|
|
5
|
+
*/
|
|
6
|
+
k8sSecretMountPaths?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* If provided, k8s config maps will be loaded from the given paths
|
|
9
|
+
* @default []
|
|
10
|
+
*/
|
|
11
|
+
k8sConfigMapMountPaths?: string[];
|
|
12
|
+
};
|
|
13
|
+
type Listener<T> = (value: T) => void;
|
|
14
|
+
/**
|
|
15
|
+
* A subject that emits values to listeners.
|
|
16
|
+
*
|
|
17
|
+
* This is used to emit values to listeners when they change.
|
|
18
|
+
*/
|
|
19
|
+
export declare class EmitterSubject<T> {
|
|
20
|
+
private _value;
|
|
21
|
+
private _listeners;
|
|
22
|
+
constructor(initialValue: T);
|
|
23
|
+
get value(): T;
|
|
24
|
+
next(newValue: T): void;
|
|
25
|
+
subscribe(callback: Listener<T>): {
|
|
26
|
+
unsubscribe: () => void;
|
|
27
|
+
};
|
|
28
|
+
toString(): string;
|
|
29
|
+
toJSON(): string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extend this class with a class of your own. The extended class static properties will then
|
|
33
|
+
* be dynamically loaded from environment variables (additionally .env files).
|
|
34
|
+
* Values will be trimmed then parsed to the type of the property.
|
|
35
|
+
*
|
|
36
|
+
* Secrets should be loaded using the getSecret method -- this prevents them from being logged
|
|
37
|
+
* or otherwise leaked, and enables the use of environment variables to load secrets from
|
|
38
|
+
* k8s secrets, vault, etc.
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* class myEnv extends EnvLoader {
|
|
42
|
+
* readonly prop = 123; // loads env variable PROP or PROP (mapped)
|
|
43
|
+
* readonly prop_time = 123; // loads env variable PROP_TIME
|
|
44
|
+
* readonly propTime = 123; // loads env variable PROP_TIME
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare const $secretsCache: unique symbol;
|
|
49
|
+
declare const $secretSubjects: unique symbol;
|
|
50
|
+
declare const $options: unique symbol;
|
|
51
|
+
declare const $watchers: unique symbol;
|
|
52
|
+
declare const $watchersStarted: unique symbol;
|
|
53
|
+
declare const $getSecretValueInternal: unique symbol;
|
|
54
|
+
declare const $getOrCreateSubject: unique symbol;
|
|
55
|
+
declare const $loadSecrets: unique symbol;
|
|
56
|
+
declare const $setupWatchers: unique symbol;
|
|
57
|
+
declare const $updateSubject: unique symbol;
|
|
58
|
+
declare const $updateMappedProperty: unique symbol;
|
|
59
|
+
declare const $mapProperties: unique symbol;
|
|
60
|
+
declare const $assignProperty: unique symbol;
|
|
61
|
+
declare const $toSnakeCase: unique symbol;
|
|
62
|
+
export declare abstract class EnvLoader {
|
|
63
|
+
private [$secretsCache];
|
|
64
|
+
private [$secretSubjects];
|
|
65
|
+
private [$options];
|
|
66
|
+
private [$watchers];
|
|
67
|
+
private [$watchersStarted];
|
|
68
|
+
constructor(options?: EnvLoaderOptions);
|
|
69
|
+
/**
|
|
70
|
+
* Initialize the loader: read secrets.
|
|
71
|
+
* This must be called after the constructor.
|
|
72
|
+
*/
|
|
73
|
+
init(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Loads a secret from the environment asynchronously.
|
|
76
|
+
*/
|
|
77
|
+
getSecret(key: string): Promise<string | undefined>;
|
|
78
|
+
getSecret(key: string, observer: true): Promise<EmitterSubject<string | undefined>>;
|
|
79
|
+
/**
|
|
80
|
+
* Loads a secret from the environment synchronously.
|
|
81
|
+
*/
|
|
82
|
+
getSecretSync(key: string): string | undefined;
|
|
83
|
+
getSecretSync(key: string, observer: true): EmitterSubject<string | undefined>;
|
|
84
|
+
/**
|
|
85
|
+
* Loads a variable from the environment synchronously.
|
|
86
|
+
*/
|
|
87
|
+
getVar(key: string): string | undefined;
|
|
88
|
+
getVar(key: string, observer: true): EmitterSubject<string | undefined>;
|
|
89
|
+
private [$getSecretValueInternal];
|
|
90
|
+
private [$getOrCreateSubject];
|
|
91
|
+
private [$loadSecrets];
|
|
92
|
+
private [$setupWatchers];
|
|
93
|
+
private [$updateSubject];
|
|
94
|
+
private [$updateMappedProperty];
|
|
95
|
+
private [$mapProperties];
|
|
96
|
+
private [$assignProperty];
|
|
97
|
+
private [$toSnakeCase];
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface JsonRpcRequest {
|
|
2
|
+
jsonrpc: "2.0";
|
|
3
|
+
id?: string | number | null;
|
|
4
|
+
method: string;
|
|
5
|
+
params?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface JsonRpcResponse {
|
|
8
|
+
jsonrpc: "2.0";
|
|
9
|
+
id: string | number | null;
|
|
10
|
+
result?: any;
|
|
11
|
+
error?: {
|
|
12
|
+
code: number;
|
|
13
|
+
message: string;
|
|
14
|
+
data?: any;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface McpTool {
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
inputSchema?: any;
|
|
21
|
+
handler: (args: any) => Promise<any> | any;
|
|
22
|
+
}
|
|
23
|
+
export interface McpPrompt {
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
arguments?: {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
required?: boolean;
|
|
30
|
+
}[];
|
|
31
|
+
handler: (args: any) => Promise<any> | any;
|
|
32
|
+
}
|
|
33
|
+
export interface McpResource {
|
|
34
|
+
uri: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
mimeType?: string;
|
|
38
|
+
handler: (uri: string, args?: any) => Promise<any> | any;
|
|
39
|
+
}
|
|
40
|
+
export declare class McpProtocol {
|
|
41
|
+
private tools;
|
|
42
|
+
private prompts;
|
|
43
|
+
private resources;
|
|
44
|
+
constructor(tools?: McpTool[], prompts?: McpPrompt[], resources?: McpResource[]);
|
|
45
|
+
addTool(tool: McpTool): void;
|
|
46
|
+
addPrompt(prompt: McpPrompt): void;
|
|
47
|
+
addResource(resource: McpResource): void;
|
|
48
|
+
merge(other: McpProtocol): void;
|
|
49
|
+
handleMessage(message: JsonRpcRequest): Promise<JsonRpcResponse | null>;
|
|
50
|
+
private success;
|
|
51
|
+
private error;
|
|
52
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequestContextStore } from './async-hooks';
|
|
2
|
+
export declare const kContext: unique symbol;
|
|
3
|
+
export interface PatchedPromise extends Promise<any> {
|
|
4
|
+
[kContext]?: {
|
|
5
|
+
store?: RequestContextStore;
|
|
6
|
+
stack: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Monkeypatches the global Promise constructor to attach the current AsyncLocalStorage store
|
|
11
|
+
* and a snapshot of the stack trace to every new Promise instance.
|
|
12
|
+
*
|
|
13
|
+
* This enables the application to trace unhandled rejections back to the original request
|
|
14
|
+
* and see where the dangling promise was created.
|
|
15
|
+
*/
|
|
16
|
+
export declare function enablePromisePatch(): void;
|
package/dist/util/symbol.d.ts
CHANGED
|
@@ -33,3 +33,7 @@ export declare const $cachedCookies: unique symbol;
|
|
|
33
33
|
export declare const $ws: unique symbol;
|
|
34
34
|
export declare const $socket: unique symbol;
|
|
35
35
|
export declare const $io: unique symbol;
|
|
36
|
+
export declare const $mcpTools: unique symbol;
|
|
37
|
+
export declare const $mcpPrompts: unique symbol;
|
|
38
|
+
export declare const $mcpResources: unique symbol;
|
|
39
|
+
export declare const $resilienceConfig: unique symbol;
|
package/dist/util/types.d.ts
CHANGED
|
@@ -385,6 +385,14 @@ export type ShokupanConfig<T extends Record<string, any> = Record<string, any>>
|
|
|
385
385
|
* @default true
|
|
386
386
|
*/
|
|
387
387
|
enableOpenApiGen: boolean;
|
|
388
|
+
/**
|
|
389
|
+
* Whether to enable monkeypatching of the global Promise constructor.
|
|
390
|
+
* When enabled, Promises created within an async context will carry that context
|
|
391
|
+
* (including `requestId`) and the creation stack trace. This increases memory and
|
|
392
|
+
* cpu usage, but provides richer logging for unhandled rejections.
|
|
393
|
+
* @default false
|
|
394
|
+
*/
|
|
395
|
+
enablePromiseMonkeypatch: boolean;
|
|
388
396
|
/**
|
|
389
397
|
* Whether to block server startup until OpenAPI generation completes.
|
|
390
398
|
* Only applies when enableOpenApiGen is true.
|
|
@@ -635,9 +643,9 @@ export type ShokupanConfig<T extends Record<string, any> = Record<string, any>>
|
|
|
635
643
|
/**
|
|
636
644
|
* Configuration for Security Headers.
|
|
637
645
|
* Can be a boolean to enable/disable defaults, or an object options.
|
|
638
|
-
* @default
|
|
646
|
+
* @default false
|
|
639
647
|
*/
|
|
640
|
-
|
|
648
|
+
defaultSecurityHeaders?: boolean | any;
|
|
641
649
|
/**
|
|
642
650
|
* Any other config options are allowed, but will be ignored.
|
|
643
651
|
* @deprecated
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shokupan",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Shokupan is a low-lift modern web framework for Bun.",
|
|
5
5
|
"author": "Andrew G. Knackstedt",
|
|
6
6
|
"publishConfig": {
|
|
@@ -59,22 +59,16 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@clack/prompts": "^0.11.0",
|
|
62
|
-
"
|
|
63
|
-
"@opentelemetry/api": "^1.9.0",
|
|
64
|
-
"@opentelemetry/exporter-trace-otlp-proto": "^0.208.0",
|
|
65
|
-
"@opentelemetry/resources": "^2.3.0",
|
|
66
|
-
"@opentelemetry/sdk-trace-base": "^2.3.0",
|
|
67
|
-
"@opentelemetry/sdk-trace-node": "^2.3.0",
|
|
68
|
-
"@opentelemetry/semantic-conventions": "^1.38.0",
|
|
69
|
-
"@scalar/openapi-types": "^0.5.3",
|
|
70
|
-
"js-yaml": "^4.1.1",
|
|
62
|
+
"cockatiel": "^3.2.1",
|
|
71
63
|
"nanoid": "^5.1.6",
|
|
72
|
-
"socket.io": "^4.8.3",
|
|
73
64
|
"tslib": "^2.8.1"
|
|
74
65
|
},
|
|
75
66
|
"peerDependencies": {
|
|
76
67
|
"@apollo/server": "^5.2.0",
|
|
68
|
+
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
69
|
+
"@opentelemetry/api": "^1.9.0",
|
|
77
70
|
"@scalar/api-reference": "^1.0.0",
|
|
71
|
+
"@scalar/openapi-types": "^0.5.3",
|
|
78
72
|
"@surrealdb/node": "^2.4.0",
|
|
79
73
|
"ajv": "^8.0.0",
|
|
80
74
|
"ajv-formats": "^3.0.0",
|
|
@@ -85,9 +79,11 @@
|
|
|
85
79
|
"graphql": "^16.12.0",
|
|
86
80
|
"graphql-yoga": "^5.18.0",
|
|
87
81
|
"jose": "^6.0.0",
|
|
82
|
+
"js-yaml": "^4.1.1",
|
|
88
83
|
"parse-json": "^8.0.0",
|
|
89
84
|
"reflect-metadata": "^0.2.0",
|
|
90
85
|
"secure-json-parse": "^4.0.0",
|
|
86
|
+
"socket.io": "^4.8.3",
|
|
91
87
|
"surrealdb": "^2.0.0-alpha.16"
|
|
92
88
|
},
|
|
93
89
|
"peerDependenciesMeta": {
|
|
@@ -138,11 +134,38 @@
|
|
|
138
134
|
},
|
|
139
135
|
"surrealdb": {
|
|
140
136
|
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"@modelcontextprotocol/sdk": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
141
|
+
"@opentelemetry/api": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
144
|
+
"@scalar/openapi-types": {
|
|
145
|
+
"optional": true
|
|
146
|
+
},
|
|
147
|
+
"js-yaml": {
|
|
148
|
+
"optional": true
|
|
149
|
+
},
|
|
150
|
+
"socket.io": {
|
|
151
|
+
"optional": true
|
|
152
|
+
},
|
|
153
|
+
"youch": {
|
|
154
|
+
"optional": true
|
|
141
155
|
}
|
|
142
156
|
},
|
|
143
157
|
"devDependencies": {
|
|
144
158
|
"@apollo/server": "^5.2.0",
|
|
159
|
+
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
160
|
+
"@opentelemetry/api": "^1.9.0",
|
|
161
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.208.0",
|
|
162
|
+
"@opentelemetry/resources": "^2.3.0",
|
|
163
|
+
"@opentelemetry/sdk-trace-base": "^2.3.0",
|
|
164
|
+
"@opentelemetry/sdk-trace-node": "^2.3.0",
|
|
165
|
+
"@opentelemetry/semantic-conventions": "^1.38.0",
|
|
145
166
|
"@scalar/api-reference": "^1.0.0",
|
|
167
|
+
"@scalar/openapi-types": "^0.5.3",
|
|
168
|
+
"@sentry/node": "^10.36.0",
|
|
146
169
|
"@sinclair/typebox": "^0.34.47",
|
|
147
170
|
"@surrealdb/node": "^2.4.0",
|
|
148
171
|
"@tsconfig/bun": "^1.0.10",
|
|
@@ -163,11 +186,13 @@
|
|
|
163
186
|
"graphql": "^16.12.0",
|
|
164
187
|
"graphql-yoga": "^5.18.0",
|
|
165
188
|
"jose": "^6.0.0",
|
|
189
|
+
"js-yaml": "^4.1.1",
|
|
166
190
|
"parse-json": "^8.0.0",
|
|
167
191
|
"preact": "^10.28.2",
|
|
168
192
|
"preact-render-to-string": "^6.6.5",
|
|
169
193
|
"reflect-metadata": "^0.2.0",
|
|
170
194
|
"secure-json-parse": "^4.0.0",
|
|
195
|
+
"socket.io": "^4.8.3",
|
|
171
196
|
"supertest": "^7.2.2",
|
|
172
197
|
"surrealdb": "^2.0.0-alpha.14",
|
|
173
198
|
"typescript": "~5.9.3",
|