nitrostack 1.0.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/CHANGELOG.md +227 -0
- package/CONTRIBUTING.md +182 -0
- package/LICENSE +201 -0
- package/LICENSE_URLS_UPDATE_COMPLETE.md +388 -0
- package/NOTICE +153 -0
- package/README.md +571 -0
- package/dist/auth/api-key.d.ts +118 -0
- package/dist/auth/api-key.d.ts.map +1 -0
- package/dist/auth/api-key.js +168 -0
- package/dist/auth/api-key.js.map +1 -0
- package/dist/auth/client.d.ts +151 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +330 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/index.d.ts +30 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +43 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +95 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +260 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/pkce.d.ts +53 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +105 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/quick-setup.d.ts +94 -0
- package/dist/auth/quick-setup.d.ts.map +1 -0
- package/dist/auth/quick-setup.js +210 -0
- package/dist/auth/quick-setup.js.map +1 -0
- package/dist/auth/server-integration.d.ts +97 -0
- package/dist/auth/server-integration.d.ts.map +1 -0
- package/dist/auth/server-integration.js +182 -0
- package/dist/auth/server-integration.js.map +1 -0
- package/dist/auth/server-metadata.d.ts +51 -0
- package/dist/auth/server-metadata.d.ts.map +1 -0
- package/dist/auth/server-metadata.js +106 -0
- package/dist/auth/server-metadata.js.map +1 -0
- package/dist/auth/simple-jwt.d.ts +88 -0
- package/dist/auth/simple-jwt.d.ts.map +1 -0
- package/dist/auth/simple-jwt.js +152 -0
- package/dist/auth/simple-jwt.js.map +1 -0
- package/dist/auth/token-store.d.ts +104 -0
- package/dist/auth/token-store.d.ts.map +1 -0
- package/dist/auth/token-store.js +205 -0
- package/dist/auth/token-store.js.map +1 -0
- package/dist/auth/token-validation.d.ts +47 -0
- package/dist/auth/token-validation.d.ts.map +1 -0
- package/dist/auth/token-validation.js +237 -0
- package/dist/auth/token-validation.js.map +1 -0
- package/dist/auth/types.d.ts +215 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +6 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli/commands/build.d.ts +6 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +104 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +7 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +312 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/generate-types.d.ts +8 -0
- package/dist/cli/commands/generate-types.d.ts.map +1 -0
- package/dist/cli/commands/generate-types.js +220 -0
- package/dist/cli/commands/generate-types.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +5 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +365 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +7 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +365 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/start.d.ts +6 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +61 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +47 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/mcp-dev-wrapper.d.ts +3 -0
- package/dist/cli/mcp-dev-wrapper.d.ts.map +1 -0
- package/dist/cli/mcp-dev-wrapper.js +116 -0
- package/dist/cli/mcp-dev-wrapper.js.map +1 -0
- package/dist/core/apikey-module.d.ts +69 -0
- package/dist/core/apikey-module.d.ts.map +1 -0
- package/dist/core/apikey-module.js +114 -0
- package/dist/core/apikey-module.js.map +1 -0
- package/dist/core/app-decorator.d.ts +58 -0
- package/dist/core/app-decorator.d.ts.map +1 -0
- package/dist/core/app-decorator.js +261 -0
- package/dist/core/app-decorator.js.map +1 -0
- package/dist/core/builders.d.ts +38 -0
- package/dist/core/builders.d.ts.map +1 -0
- package/dist/core/builders.js +129 -0
- package/dist/core/builders.js.map +1 -0
- package/dist/core/component.d.ts +105 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/component.js +182 -0
- package/dist/core/component.js.map +1 -0
- package/dist/core/config-module.d.ts +55 -0
- package/dist/core/config-module.d.ts.map +1 -0
- package/dist/core/config-module.js +94 -0
- package/dist/core/config-module.js.map +1 -0
- package/dist/core/decorators/cache.decorator.d.ts +61 -0
- package/dist/core/decorators/cache.decorator.d.ts.map +1 -0
- package/dist/core/decorators/cache.decorator.js +115 -0
- package/dist/core/decorators/cache.decorator.js.map +1 -0
- package/dist/core/decorators/health-check.decorator.d.ts +80 -0
- package/dist/core/decorators/health-check.decorator.d.ts.map +1 -0
- package/dist/core/decorators/health-check.decorator.js +153 -0
- package/dist/core/decorators/health-check.decorator.js.map +1 -0
- package/dist/core/decorators/rate-limit.decorator.d.ts +62 -0
- package/dist/core/decorators/rate-limit.decorator.d.ts.map +1 -0
- package/dist/core/decorators/rate-limit.decorator.js +129 -0
- package/dist/core/decorators/rate-limit.decorator.js.map +1 -0
- package/dist/core/decorators.d.ts +151 -0
- package/dist/core/decorators.d.ts.map +1 -0
- package/dist/core/decorators.js +142 -0
- package/dist/core/decorators.js.map +1 -0
- package/dist/core/di/container.d.ts +42 -0
- package/dist/core/di/container.d.ts.map +1 -0
- package/dist/core/di/container.js +76 -0
- package/dist/core/di/container.js.map +1 -0
- package/dist/core/di/injectable.decorator.d.ts +35 -0
- package/dist/core/di/injectable.decorator.d.ts.map +1 -0
- package/dist/core/di/injectable.decorator.js +57 -0
- package/dist/core/di/injectable.decorator.js.map +1 -0
- package/dist/core/errors.d.ts +54 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +87 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events/event-emitter.d.ts +50 -0
- package/dist/core/events/event-emitter.d.ts.map +1 -0
- package/dist/core/events/event-emitter.js +94 -0
- package/dist/core/events/event-emitter.js.map +1 -0
- package/dist/core/events/event.decorator.d.ts +48 -0
- package/dist/core/events/event.decorator.d.ts.map +1 -0
- package/dist/core/events/event.decorator.js +68 -0
- package/dist/core/events/event.decorator.js.map +1 -0
- package/dist/core/filters/exception-filter.decorator.d.ts +40 -0
- package/dist/core/filters/exception-filter.decorator.d.ts.map +1 -0
- package/dist/core/filters/exception-filter.decorator.js +54 -0
- package/dist/core/filters/exception-filter.decorator.js.map +1 -0
- package/dist/core/filters/exception-filter.interface.d.ts +30 -0
- package/dist/core/filters/exception-filter.interface.d.ts.map +1 -0
- package/dist/core/filters/exception-filter.interface.js +2 -0
- package/dist/core/filters/exception-filter.interface.js.map +1 -0
- package/dist/core/guards/apikey.guard.d.ts +22 -0
- package/dist/core/guards/apikey.guard.d.ts.map +1 -0
- package/dist/core/guards/apikey.guard.js +11 -0
- package/dist/core/guards/apikey.guard.js.map +1 -0
- package/dist/core/guards/guard.interface.d.ts +18 -0
- package/dist/core/guards/guard.interface.d.ts.map +1 -0
- package/dist/core/guards/guard.interface.js +2 -0
- package/dist/core/guards/guard.interface.js.map +1 -0
- package/dist/core/guards/jwt.guard.d.ts +18 -0
- package/dist/core/guards/jwt.guard.d.ts.map +1 -0
- package/dist/core/guards/jwt.guard.js +2 -0
- package/dist/core/guards/jwt.guard.js.map +1 -0
- package/dist/core/guards/oauth.guard.d.ts +35 -0
- package/dist/core/guards/oauth.guard.d.ts.map +1 -0
- package/dist/core/guards/oauth.guard.js +2 -0
- package/dist/core/guards/oauth.guard.js.map +1 -0
- package/dist/core/guards/use-guards.decorator.d.ts +25 -0
- package/dist/core/guards/use-guards.decorator.d.ts.map +1 -0
- package/dist/core/guards/use-guards.decorator.js +32 -0
- package/dist/core/guards/use-guards.decorator.js.map +1 -0
- package/dist/core/health/health-checks.resource.d.ts +14 -0
- package/dist/core/health/health-checks.resource.d.ts.map +1 -0
- package/dist/core/health/health-checks.resource.js +29 -0
- package/dist/core/health/health-checks.resource.js.map +1 -0
- package/dist/core/index.d.ts +55 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +57 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/interceptors/interceptor.decorator.d.ts +37 -0
- package/dist/core/interceptors/interceptor.decorator.d.ts.map +1 -0
- package/dist/core/interceptors/interceptor.decorator.js +51 -0
- package/dist/core/interceptors/interceptor.decorator.js.map +1 -0
- package/dist/core/interceptors/interceptor.interface.d.ts +31 -0
- package/dist/core/interceptors/interceptor.interface.d.ts.map +1 -0
- package/dist/core/interceptors/interceptor.interface.js +2 -0
- package/dist/core/interceptors/interceptor.interface.js.map +1 -0
- package/dist/core/jwt-module.d.ts +51 -0
- package/dist/core/jwt-module.d.ts.map +1 -0
- package/dist/core/jwt-module.js +52 -0
- package/dist/core/jwt-module.js.map +1 -0
- package/dist/core/logger.d.ts +18 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +51 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/middleware/middleware.decorator.d.ts +39 -0
- package/dist/core/middleware/middleware.decorator.d.ts.map +1 -0
- package/dist/core/middleware/middleware.decorator.js +53 -0
- package/dist/core/middleware/middleware.decorator.js.map +1 -0
- package/dist/core/middleware/middleware.interface.d.ts +29 -0
- package/dist/core/middleware/middleware.interface.d.ts.map +1 -0
- package/dist/core/middleware/middleware.interface.js +2 -0
- package/dist/core/middleware/middleware.interface.js.map +1 -0
- package/dist/core/module.d.ts +74 -0
- package/dist/core/module.d.ts.map +1 -0
- package/dist/core/module.js +82 -0
- package/dist/core/module.js.map +1 -0
- package/dist/core/oauth-module.d.ts +144 -0
- package/dist/core/oauth-module.d.ts.map +1 -0
- package/dist/core/oauth-module.js +190 -0
- package/dist/core/oauth-module.js.map +1 -0
- package/dist/core/pipes/pipe.decorator.d.ts +55 -0
- package/dist/core/pipes/pipe.decorator.d.ts.map +1 -0
- package/dist/core/pipes/pipe.decorator.js +85 -0
- package/dist/core/pipes/pipe.decorator.js.map +1 -0
- package/dist/core/pipes/pipe.interface.d.ts +36 -0
- package/dist/core/pipes/pipe.interface.d.ts.map +1 -0
- package/dist/core/pipes/pipe.interface.js +2 -0
- package/dist/core/pipes/pipe.interface.js.map +1 -0
- package/dist/core/prompt.d.ts +37 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +76 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/resource.d.ts +42 -0
- package/dist/core/resource.d.ts.map +1 -0
- package/dist/core/resource.js +90 -0
- package/dist/core/resource.js.map +1 -0
- package/dist/core/server.d.ts +72 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +406 -0
- package/dist/core/server.js.map +1 -0
- package/dist/core/tool.d.ts +78 -0
- package/dist/core/tool.d.ts.map +1 -0
- package/dist/core/tool.js +190 -0
- package/dist/core/tool.js.map +1 -0
- package/dist/core/transports/http-server.d.ts +102 -0
- package/dist/core/transports/http-server.d.ts.map +1 -0
- package/dist/core/transports/http-server.js +265 -0
- package/dist/core/transports/http-server.js.map +1 -0
- package/dist/core/types.d.ts +123 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/widgets/widget-examples.resource.d.ts +17 -0
- package/dist/core/widgets/widget-examples.resource.d.ts.map +1 -0
- package/dist/core/widgets/widget-examples.resource.js +28 -0
- package/dist/core/widgets/widget-examples.resource.js.map +1 -0
- package/dist/core/widgets/widget-registry.d.ts +56 -0
- package/dist/core/widgets/widget-registry.d.ts.map +1 -0
- package/dist/core/widgets/widget-registry.js +75 -0
- package/dist/core/widgets/widget-registry.js.map +1 -0
- package/dist/testing/index.d.ts +82 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +164 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/ui-next/index.d.ts +31 -0
- package/dist/ui-next/index.d.ts.map +1 -0
- package/dist/ui-next/index.js +687 -0
- package/dist/ui-next/index.js.map +1 -0
- package/dist/widgets/index.d.ts +9 -0
- package/dist/widgets/index.d.ts.map +1 -0
- package/dist/widgets/index.js +9 -0
- package/dist/widgets/index.js.map +1 -0
- package/dist/widgets/metadata.d.ts +53 -0
- package/dist/widgets/metadata.d.ts.map +1 -0
- package/dist/widgets/metadata.js +29 -0
- package/dist/widgets/metadata.js.map +1 -0
- package/dist/widgets/withToolData.d.ts +19 -0
- package/dist/widgets/withToolData.d.ts.map +1 -0
- package/dist/widgets/withToolData.js +240 -0
- package/dist/widgets/withToolData.js.map +1 -0
- package/jest.config.js +21 -0
- package/package.json +108 -0
- package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +702 -0
- package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-auth/README.md +400 -0
- package/templates/typescript-auth/package.json +44 -0
- package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-auth-api-key/README.md +483 -0
- package/templates/typescript-auth-api-key/package-lock.json +124 -0
- package/templates/typescript-auth-api-key/package.json +29 -0
- package/templates/typescript-oauth/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-oauth/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-oauth/OAUTH_SETUP.md +406 -0
- package/templates/typescript-oauth/README.md +350 -0
- package/templates/typescript-oauth/package.json +30 -0
- package/templates/typescript-starter/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-starter/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-starter/README.md +312 -0
- package/templates/typescript-starter/package.json +32 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
const PIPE_KEY = 'nitrostack:pipe';
|
|
3
|
+
const IS_PIPE_KEY = 'nitrostack:is_pipe';
|
|
4
|
+
const PARAM_PIPES_KEY = 'nitrostack:param_pipes';
|
|
5
|
+
/**
|
|
6
|
+
* Marks a class as a pipe
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* @Pipe()
|
|
11
|
+
* export class ValidationPipe implements PipeInterface {
|
|
12
|
+
* transform(value: any, metadata: ArgumentMetadata) {
|
|
13
|
+
* // Validate and transform
|
|
14
|
+
* return value;
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function Pipe() {
|
|
20
|
+
return (target) => {
|
|
21
|
+
Reflect.defineMetadata(IS_PIPE_KEY, true, target);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Apply pipes to tool input (entire input object)
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* @Tool({ name: 'create_user', ... })
|
|
30
|
+
* @UsePipes(ValidationPipe, TransformPipe)
|
|
31
|
+
* async createUser(input: any) { }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function UsePipes(...pipes) {
|
|
35
|
+
return (target, propertyKey, descriptor) => {
|
|
36
|
+
const existingPipes = Reflect.getMetadata(PIPE_KEY, target, propertyKey) || [];
|
|
37
|
+
Reflect.defineMetadata(PIPE_KEY, [...existingPipes, ...pipes], target, propertyKey);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parameter decorator to apply pipes to specific parameters
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* @Tool({ name: 'create_user', ... })
|
|
46
|
+
* async createUser(@Body(ValidationPipe) input: CreateUserDto) { }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function Body(...pipes) {
|
|
50
|
+
return (target, propertyKey, parameterIndex) => {
|
|
51
|
+
if (!propertyKey)
|
|
52
|
+
return;
|
|
53
|
+
const existingParams = Reflect.getMetadata(PARAM_PIPES_KEY, target, propertyKey) || {};
|
|
54
|
+
existingParams[parameterIndex] = {
|
|
55
|
+
type: 'body',
|
|
56
|
+
pipes,
|
|
57
|
+
};
|
|
58
|
+
Reflect.defineMetadata(PARAM_PIPES_KEY, existingParams, target, propertyKey);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Shorthand for validation pipe
|
|
63
|
+
*/
|
|
64
|
+
export function Validated() {
|
|
65
|
+
return Body(); // Can be enhanced with default validation pipe
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get pipes for a method
|
|
69
|
+
*/
|
|
70
|
+
export function getPipeMetadata(target, propertyKey) {
|
|
71
|
+
return Reflect.getMetadata(PIPE_KEY, target, propertyKey) || [];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get parameter pipes for a method
|
|
75
|
+
*/
|
|
76
|
+
export function getParamPipesMetadata(target, propertyKey) {
|
|
77
|
+
return Reflect.getMetadata(PARAM_PIPES_KEY, target, propertyKey) || {};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Check if a class is marked as a pipe
|
|
81
|
+
*/
|
|
82
|
+
export function isPipe(target) {
|
|
83
|
+
return Reflect.getMetadata(IS_PIPE_KEY, target) === true;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=pipe.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.decorator.js","sourceRoot":"","sources":["../../../src/core/pipes/pipe.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AACnC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AACzC,MAAM,eAAe,GAAG,wBAAwB,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,KAAwB;IAClD,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,UAA8B,EAAE,EAAE;QACnF,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAC/E,OAAO,CAAC,cAAc,CACpB,QAAQ,EACR,CAAC,GAAG,aAAa,EAAE,GAAG,KAAK,CAAC,EAC5B,MAAM,EACN,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAAC,GAAG,KAAwB;IAC9C,OAAO,CAAC,MAAW,EAAE,WAAwC,EAAE,cAAsB,EAAE,EAAE;QACvF,IAAI,CAAC,WAAW;YAAE,OAAO;QAEzB,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QACvF,cAAc,CAAC,cAAc,CAAC,GAAG;YAC/B,IAAI,EAAE,MAAM;YACZ,KAAK;SACN,CAAC;QACF,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,IAAI,EAAE,CAAC,CAAC,+CAA+C;AAChE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAW,EAAE,WAA4B;IACvE,OAAO,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAW,EAAE,WAA4B;IAC7E,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,MAAW;IAChC,OAAO,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
/**
|
|
3
|
+
* Argument metadata for pipe transformation
|
|
4
|
+
*/
|
|
5
|
+
export interface ArgumentMetadata {
|
|
6
|
+
type: 'body' | 'param' | 'query' | 'custom';
|
|
7
|
+
metatype?: any;
|
|
8
|
+
data?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Pipe Interface
|
|
12
|
+
*
|
|
13
|
+
* Pipes are used to transform and validate input data before it reaches the tool handler.
|
|
14
|
+
* Similar to NestJS pipes.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* @Pipe()
|
|
19
|
+
* export class ValidationPipe implements PipeInterface {
|
|
20
|
+
* transform(value: any, metadata: ArgumentMetadata) {
|
|
21
|
+
* if (!this.isValid(value)) {
|
|
22
|
+
* throw new Error('Validation failed');
|
|
23
|
+
* }
|
|
24
|
+
* return value;
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface PipeInterface<T = any, R = any> {
|
|
30
|
+
transform(value: T, metadata: ArgumentMetadata): R | Promise<R>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Pipe constructor type
|
|
34
|
+
*/
|
|
35
|
+
export type PipeConstructor = new (...args: any[]) => PipeInterface;
|
|
36
|
+
//# sourceMappingURL=pipe.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.interface.d.ts","sourceRoot":"","sources":["../../../src/core/pipes/pipe.interface.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG;IAC7C,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.interface.js","sourceRoot":"","sources":["../../../src/core/pipes/pipe.interface.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PromptDefinition, ExecutionContext, PromptMessage } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Prompt class provides a clean abstraction for defining and executing prompts
|
|
4
|
+
*/
|
|
5
|
+
export declare class Prompt {
|
|
6
|
+
private definition;
|
|
7
|
+
constructor(definition: PromptDefinition);
|
|
8
|
+
/**
|
|
9
|
+
* Get prompt name
|
|
10
|
+
*/
|
|
11
|
+
get name(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get prompt description
|
|
14
|
+
*/
|
|
15
|
+
get description(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Get prompt arguments
|
|
18
|
+
*/
|
|
19
|
+
get arguments(): any[];
|
|
20
|
+
/**
|
|
21
|
+
* Execute the prompt with provided arguments
|
|
22
|
+
*/
|
|
23
|
+
execute(args: Record<string, any>, context: ExecutionContext): Promise<PromptMessage[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Validate prompt arguments
|
|
26
|
+
*/
|
|
27
|
+
private validateArguments;
|
|
28
|
+
/**
|
|
29
|
+
* Create prompt metadata for MCP protocol
|
|
30
|
+
*/
|
|
31
|
+
toMcpPrompt(): any;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Helper function to create a prompt
|
|
35
|
+
*/
|
|
36
|
+
export declare function createPrompt(definition: PromptDefinition): Prompt;
|
|
37
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/core/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG/E;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,UAAU,CAAmB;gBAEzB,UAAU,EAAE,gBAAgB;IAIxC;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,GAAG,EAAE,CAErB;IAED;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAoB7F;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAYzB;;OAEG;IACH,WAAW,IAAI,GAAG;CAOnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAEjE"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ValidationError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Prompt class provides a clean abstraction for defining and executing prompts
|
|
4
|
+
*/
|
|
5
|
+
export class Prompt {
|
|
6
|
+
definition;
|
|
7
|
+
constructor(definition) {
|
|
8
|
+
this.definition = definition;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get prompt name
|
|
12
|
+
*/
|
|
13
|
+
get name() {
|
|
14
|
+
return this.definition.name;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get prompt description
|
|
18
|
+
*/
|
|
19
|
+
get description() {
|
|
20
|
+
return this.definition.description;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get prompt arguments
|
|
24
|
+
*/
|
|
25
|
+
get arguments() {
|
|
26
|
+
return this.definition.arguments || [];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Execute the prompt with provided arguments
|
|
30
|
+
*/
|
|
31
|
+
async execute(args, context) {
|
|
32
|
+
// Validate required arguments
|
|
33
|
+
this.validateArguments(args);
|
|
34
|
+
context.logger.info(`Executing prompt: ${this.name}`, { args });
|
|
35
|
+
try {
|
|
36
|
+
const messages = await this.definition.handler(args, context);
|
|
37
|
+
context.logger.info(`Prompt executed successfully: ${this.name}`, {
|
|
38
|
+
messageCount: messages.length,
|
|
39
|
+
});
|
|
40
|
+
return messages;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
context.logger.error(`Error executing prompt: ${this.name}`, error);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Validate prompt arguments
|
|
49
|
+
*/
|
|
50
|
+
validateArguments(args) {
|
|
51
|
+
if (!this.definition.arguments)
|
|
52
|
+
return;
|
|
53
|
+
for (const arg of this.definition.arguments) {
|
|
54
|
+
if (arg.required && !(arg.name in args)) {
|
|
55
|
+
throw new ValidationError(`Missing required argument '${arg.name}' for prompt '${this.name}'`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create prompt metadata for MCP protocol
|
|
61
|
+
*/
|
|
62
|
+
toMcpPrompt() {
|
|
63
|
+
return {
|
|
64
|
+
name: this.name,
|
|
65
|
+
description: this.description,
|
|
66
|
+
arguments: this.arguments,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Helper function to create a prompt
|
|
72
|
+
*/
|
|
73
|
+
export function createPrompt(definition) {
|
|
74
|
+
return new Prompt(definition);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/core/prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAO,MAAM;IACT,UAAU,CAAmB;IAErC,YAAY,UAA4B;QACtC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,IAAI,EAAE,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,IAAyB,EAAE,OAAyB;QAChE,8BAA8B;QAC9B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAE7B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAEhE,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAE9D,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,iCAAiC,IAAI,CAAC,IAAI,EAAE,EAAE;gBAChE,YAAY,EAAE,QAAQ,CAAC,MAAM;aAC9B,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;YACpE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,IAAyB;QACjD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS;YAAE,OAAO;QAEvC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;YAC5C,IAAI,GAAG,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;gBACxC,MAAM,IAAI,eAAe,CACvB,8BAA8B,GAAG,CAAC,IAAI,iBAAiB,IAAI,CAAC,IAAI,GAAG,CACpE,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,UAA4B;IACvD,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ResourceDefinition, ExecutionContext, ResourceContent } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resource class provides a clean abstraction for defining and serving resources
|
|
4
|
+
*/
|
|
5
|
+
export declare class Resource {
|
|
6
|
+
private definition;
|
|
7
|
+
private cache?;
|
|
8
|
+
constructor(definition: ResourceDefinition);
|
|
9
|
+
/**
|
|
10
|
+
* Get resource URI
|
|
11
|
+
*/
|
|
12
|
+
get uri(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get resource name
|
|
15
|
+
*/
|
|
16
|
+
get name(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Get resource description
|
|
19
|
+
*/
|
|
20
|
+
get description(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get resource MIME type
|
|
23
|
+
*/
|
|
24
|
+
get mimeType(): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Fetch the resource content
|
|
27
|
+
*/
|
|
28
|
+
fetch(context: ExecutionContext): Promise<ResourceContent>;
|
|
29
|
+
/**
|
|
30
|
+
* Clear cached content
|
|
31
|
+
*/
|
|
32
|
+
clearCache(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Create resource metadata for MCP protocol
|
|
35
|
+
*/
|
|
36
|
+
toMcpResource(): any;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Helper function to create a resource
|
|
40
|
+
*/
|
|
41
|
+
export declare function createResource(definition: ResourceDefinition): Resource;
|
|
42
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/core/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEnF;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,KAAK,CAAC,CAGZ;gBAEU,UAAU,EAAE,kBAAkB;IAI1C;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,GAAG,SAAS,CAEjC;IAED;;OAEG;IACG,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAkChE;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,aAAa,IAAI,GAAG;CAQrB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,kBAAkB,GAAG,QAAQ,CAEvE"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource class provides a clean abstraction for defining and serving resources
|
|
3
|
+
*/
|
|
4
|
+
export class Resource {
|
|
5
|
+
definition;
|
|
6
|
+
cache;
|
|
7
|
+
constructor(definition) {
|
|
8
|
+
this.definition = definition;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get resource URI
|
|
12
|
+
*/
|
|
13
|
+
get uri() {
|
|
14
|
+
return this.definition.uri;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get resource name
|
|
18
|
+
*/
|
|
19
|
+
get name() {
|
|
20
|
+
return this.definition.name;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get resource description
|
|
24
|
+
*/
|
|
25
|
+
get description() {
|
|
26
|
+
return this.definition.description;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get resource MIME type
|
|
30
|
+
*/
|
|
31
|
+
get mimeType() {
|
|
32
|
+
return this.definition.mimeType;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Fetch the resource content
|
|
36
|
+
*/
|
|
37
|
+
async fetch(context) {
|
|
38
|
+
const cacheable = this.definition.metadata?.cacheable;
|
|
39
|
+
const cacheMaxAge = this.definition.metadata?.cacheMaxAge || 60000; // 1 minute default
|
|
40
|
+
// Check cache
|
|
41
|
+
if (cacheable && this.cache) {
|
|
42
|
+
const age = Date.now() - this.cache.timestamp;
|
|
43
|
+
if (age < cacheMaxAge) {
|
|
44
|
+
context.logger.debug(`Serving cached resource: ${this.uri}`);
|
|
45
|
+
return this.cache.content;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
context.logger.info(`Fetching resource: ${this.uri}`);
|
|
49
|
+
try {
|
|
50
|
+
const content = await this.definition.handler(context);
|
|
51
|
+
// Update cache
|
|
52
|
+
if (cacheable) {
|
|
53
|
+
this.cache = {
|
|
54
|
+
content,
|
|
55
|
+
timestamp: Date.now(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
context.logger.info(`Resource fetched successfully: ${this.uri}`);
|
|
59
|
+
return content;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
context.logger.error(`Error fetching resource: ${this.uri}`, error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Clear cached content
|
|
68
|
+
*/
|
|
69
|
+
clearCache() {
|
|
70
|
+
this.cache = undefined;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create resource metadata for MCP protocol
|
|
74
|
+
*/
|
|
75
|
+
toMcpResource() {
|
|
76
|
+
return {
|
|
77
|
+
uri: this.uri,
|
|
78
|
+
name: this.name,
|
|
79
|
+
description: this.description,
|
|
80
|
+
mimeType: this.mimeType,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Helper function to create a resource
|
|
86
|
+
*/
|
|
87
|
+
export function createResource(definition) {
|
|
88
|
+
return new Resource(definition);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/core/resource.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,QAAQ;IACX,UAAU,CAAqB;IAC/B,KAAK,CAGX;IAEF,YAAY,UAA8B;QACxC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,OAAyB;QACnC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC;QACtD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,IAAI,KAAK,CAAC,CAAC,mBAAmB;QAEvF,cAAc;QACd,IAAI,SAAS,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YAC9C,IAAI,GAAG,GAAG,WAAW,EAAE,CAAC;gBACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;gBAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAEtD,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAEvD,eAAe;YACf,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,CAAC,KAAK,GAAG;oBACX,OAAO;oBACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;iBACtB,CAAC;YACJ,CAAC;YAED,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YAClE,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;YACpE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,UAA8B;IAC3D,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Tool } from './tool.js';
|
|
2
|
+
import { Resource } from './resource.js';
|
|
3
|
+
import { Prompt } from './prompt.js';
|
|
4
|
+
import { McpServerConfig, ServerStats } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* NitroStackServer - Main server class
|
|
7
|
+
*/
|
|
8
|
+
export declare class NitroStackServer {
|
|
9
|
+
private mcpServer;
|
|
10
|
+
private tools;
|
|
11
|
+
private resources;
|
|
12
|
+
private prompts;
|
|
13
|
+
private config;
|
|
14
|
+
private logger;
|
|
15
|
+
private stats;
|
|
16
|
+
private pendingComponentRegistrations;
|
|
17
|
+
constructor(config: McpServerConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Add a tool to the server
|
|
20
|
+
*/
|
|
21
|
+
tool(tool: Tool): this;
|
|
22
|
+
/**
|
|
23
|
+
* Register a component as an MCP resource
|
|
24
|
+
*/
|
|
25
|
+
private registerComponentResource;
|
|
26
|
+
/**
|
|
27
|
+
* Add a resource to the server
|
|
28
|
+
*/
|
|
29
|
+
resource(resource: Resource): this;
|
|
30
|
+
/**
|
|
31
|
+
* Add a prompt to the server
|
|
32
|
+
*/
|
|
33
|
+
prompt(prompt: Prompt): this;
|
|
34
|
+
/**
|
|
35
|
+
* Register a module with all its controllers
|
|
36
|
+
* Automatically extracts and registers all tools, resources, and prompts
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* server.module(AuthModule);
|
|
41
|
+
* server.module(ProductsModule);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
module(moduleClass: any): this;
|
|
45
|
+
/**
|
|
46
|
+
* Get server statistics
|
|
47
|
+
*/
|
|
48
|
+
getStats(): ServerStats;
|
|
49
|
+
/**
|
|
50
|
+
* Create execution context
|
|
51
|
+
*/
|
|
52
|
+
private createContext;
|
|
53
|
+
/**
|
|
54
|
+
* Setup MCP protocol handlers
|
|
55
|
+
*/
|
|
56
|
+
private setupHandlers;
|
|
57
|
+
/**
|
|
58
|
+
* Start the server with specified transport
|
|
59
|
+
* @param transportType - 'stdio', 'http', or 'dual' (default: 'stdio')
|
|
60
|
+
* @param transportOptions - Transport-specific options
|
|
61
|
+
*/
|
|
62
|
+
start(transportType?: 'stdio' | 'http' | 'dual', transportOptions?: any): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Stop the server
|
|
65
|
+
*/
|
|
66
|
+
stop(): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Helper function to create a server
|
|
70
|
+
*/
|
|
71
|
+
export declare function createServer(config: McpServerConfig): NitroStackServer;
|
|
72
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAkB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EACL,eAAe,EAGf,WAAW,EACZ,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAKX;IACF,OAAO,CAAC,6BAA6B,CAAuB;gBAEhD,MAAM,EAAE,eAAe;IA0BnC;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAkBtB;;OAEG;YACW,yBAAyB;IA6BvC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAMlC;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAM5B;;;;;;;;;OASG;IACH,MAAM,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI;IA+C9B;;OAEG;IACH,QAAQ,IAAI,WAAW;IAIvB;;OAEG;IACH,OAAO,CAAC,aAAa;IASrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAyLrB;;;;OAIG;IACG,KAAK,CAAC,aAAa,GAAE,OAAO,GAAG,MAAM,GAAG,MAAgB,EAAE,gBAAgB,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAuDtG;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAiB5B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB,CAEtE"}
|