@cocos/cocos-cli-types 0.0.1-alpha.21.1 → 0.0.1-alpha.21.2

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.
Files changed (4) hide show
  1. package/cc.d.ts +76009 -0
  2. package/index.d.ts +104 -30
  3. package/package.json +1 -1
  4. package/service.d.ts +2139 -0
package/index.d.ts CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  import { ChunkInfo } from '@cocos/creator-programming-quick-pack/lib/loader';
4
4
  import { EventEmitter } from 'events';
5
+ import { NextFunction } from 'express';
6
+ import { Request as Request_2 } from 'express';
7
+ import { Response as Response_2 } from 'express';
5
8
 
6
9
  /** 动画剪辑资源的 userData */
7
10
  declare interface AnimationClipAssetUserData {
@@ -669,13 +672,27 @@ declare function getMetadata(): Promise<ICocosConfigurationNode[]>;
669
672
  declare function getProgrammingFacet(): Promise<ProgrammingFacet>;
670
673
 
671
674
  /**
672
- * Get the MCP server status.
675
+ * Get the MCP registration status.
673
676
  */
674
677
  declare function getStatus(): {
678
+ registered: boolean;
679
+ url?: string;
680
+ };
681
+
682
+ /**
683
+ * Get the server running status.
684
+ */
685
+ declare function getStatus_2(): {
675
686
  running: boolean;
676
687
  url?: string;
677
688
  };
678
689
 
690
+ /**
691
+ * Get the current server base URL.
692
+ * Returns undefined if the server is not running.
693
+ */
694
+ declare function getUrl(): string | undefined;
695
+
679
696
  /** glTF 动画资源的 userData */
680
697
  declare interface GltfAnimationAssetUserData {
681
698
  gltfIndex: number;
@@ -1247,6 +1264,11 @@ declare type IFlags = Record<string, boolean | number>;
1247
1264
 
1248
1265
  declare type IFlags_2 = Record<string, boolean | number>;
1249
1266
 
1267
+ declare interface IGetPostConfig {
1268
+ url: string | RegExp;
1269
+ handler: (req: Request_2, res: Response_2, next?: NextFunction) => Promise<void>;
1270
+ }
1271
+
1250
1272
  declare interface IInitEngineInfo {
1251
1273
  importBase: string;
1252
1274
  nativeBase: string;
@@ -1302,6 +1324,13 @@ declare interface ImageMeta {
1302
1324
  remap?: string;
1303
1325
  }
1304
1326
 
1327
+ declare interface IMiddlewareContribution {
1328
+ get?: IGetPostConfig[];
1329
+ post?: IGetPostConfig[];
1330
+ staticFiles?: IStaticFileConfig[];
1331
+ socket?: ISocketConfig;
1332
+ }
1333
+
1305
1334
  declare interface IModuleConfig {
1306
1335
  moduleTreeDump: {
1307
1336
  default: IModules;
@@ -1465,6 +1494,11 @@ declare interface IRedirectInfo {
1465
1494
  uuid: string;
1466
1495
  }
1467
1496
 
1497
+ declare interface ISocketConfig {
1498
+ connection: (socket: any) => void;
1499
+ disconnect: (socket: any) => void;
1500
+ }
1501
+
1468
1502
  declare interface ISplashBackgroundColor {
1469
1503
  x: number;
1470
1504
  y: number;
@@ -1491,6 +1525,11 @@ declare interface ISplashSetting {
1491
1525
  }
1492
1526
  }
1493
1527
 
1528
+ declare interface IStaticFileConfig {
1529
+ url: string;
1530
+ path: string;
1531
+ }
1532
+
1494
1533
  declare type ISupportCreateCCType =
1495
1534
  | 'cc.AnimationClip' // 动画剪辑
1496
1535
  | 'cc.Script' // 脚本(TypeScript/JavaScript)
@@ -1602,8 +1641,8 @@ declare type MakeRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
1602
1641
 
1603
1642
  export declare namespace Mcp {
1604
1643
  export {
1605
- startServer,
1606
- stopServer,
1644
+ register,
1645
+ unregister,
1607
1646
  getStatus
1608
1647
  };
1609
1648
  }
@@ -2118,6 +2157,36 @@ declare function queryUUID(urlOrPath: string): Promise<string | null>;
2118
2157
  */
2119
2158
  declare function refresh(dir: string): Promise<number>;
2120
2159
 
2160
+ /**
2161
+ * MCP Facade Module
2162
+ *
2163
+ * Called by the cocos-code utility process to register MCP middleware
2164
+ * in an already-initialized environment.
2165
+ * Prerequisite: the Server module must be started before calling this module.
2166
+ * This module only handles MCP-specific work: populating the toolRegistry
2167
+ * and registering MCP routes on the running server.
2168
+ */
2169
+ /**
2170
+ * Register MCP middleware on the running server.
2171
+ *
2172
+ * Note: the Express server must already be started via the Server module.
2173
+ * This function only:
2174
+ * 1. Imports API modules to populate the toolRegistry (@tool decorator side-effects)
2175
+ * 2. Creates McpMiddleware and registers routes on the server
2176
+ *
2177
+ * @returns MCP endpoint URL (e.g. http://localhost:9527/mcp)
2178
+ */
2179
+ declare function register(): Promise<string>;
2180
+
2181
+ /**
2182
+ * Register a middleware contribution (routes, static files, sockets)
2183
+ * on the running server.
2184
+ *
2185
+ * @param name Middleware identifier
2186
+ * @param module Middleware contribution config
2187
+ */
2188
+ declare function register_2(name: string, module: IMiddlewareContribution): Promise<void>;
2189
+
2121
2190
  /**
2122
2191
  * Reimport Asset // 重新导入资源
2123
2192
  */
@@ -2188,6 +2257,16 @@ declare interface SerializedAssetFinder {
2188
2257
  scenes?: Array<string | null>;
2189
2258
  }
2190
2259
 
2260
+ export declare namespace Server {
2261
+ export {
2262
+ start_2 as start,
2263
+ stop_2 as stop,
2264
+ getUrl,
2265
+ register_2 as register,
2266
+ getStatus_2 as getStatus
2267
+ };
2268
+ }
2269
+
2191
2270
  declare function set<T>(key: string, value: T, scope?: ConfigurationScope): Promise<boolean>;
2192
2271
 
2193
2272
  declare interface SharedSettings {
@@ -2282,37 +2361,26 @@ declare interface SpriteFrameVertices {
2282
2361
  declare function start(): Promise<void>;
2283
2362
 
2284
2363
  /**
2285
- * 在独立的子进程中运行项目脚本编译
2286
- * 以避免阻塞主进程
2287
- */
2288
- declare function startCompileScript(assetChanges?: AssetChangeInfo[]): Promise<void>;
2289
-
2290
- declare function startEngineCompilation(force?: boolean): Promise<void>;
2291
-
2292
- /**
2293
- * MCP Server Facade Module
2364
+ * Server Facade Module
2294
2365
  *
2295
- * Called by the cocos-code utility process to start the MCP server
2296
- * in an already-initialized environment.
2297
- * Prerequisite: core modules (project/engine/assets/scripting/builder)
2298
- * have been initialized via their respective lib modules.
2299
- * This module only handles MCP-specific work: populating the toolRegistry,
2300
- * starting Express, and registering MCP routes.
2366
+ * Provides a simplified interface for managing the Express HTTP server.
2367
+ * Wraps the core server service with startup guards and status tracking.
2301
2368
  */
2302
2369
  /**
2303
- * Start the MCP server.
2304
- *
2305
- * Note: does NOT call CocosAPI.startup() / Launcher because
2306
- * core modules are already initialized by the utility process.
2307
- * This function only:
2308
- * 1. Imports API modules to populate the toolRegistry (@tool decorator side-effects)
2309
- * 2. Starts the Express HTTP server
2310
- * 3. Creates McpMiddleware and registers routes
2370
+ * Initialize and start the Express HTTP server.
2311
2371
  *
2312
2372
  * @param port Optional port number; auto-selected if omitted
2313
- * @returns MCP server URL (e.g. http://localhost:9527/mcp)
2373
+ * @returns The server base URL (e.g. http://localhost:9527)
2314
2374
  */
2315
- declare function startServer(port?: number): Promise<string>;
2375
+ declare function start_2(port?: number): Promise<string>;
2376
+
2377
+ /**
2378
+ * 在独立的子进程中运行项目脚本编译
2379
+ * 以避免阻塞主进程
2380
+ */
2381
+ declare function startCompileScript(assetChanges?: AssetChangeInfo[]): Promise<void>;
2382
+
2383
+ declare function startEngineCompilation(force?: boolean): Promise<void>;
2316
2384
 
2317
2385
  /**
2318
2386
  * Start the scene worker process.
@@ -2322,9 +2390,9 @@ declare function startServer(port?: number): Promise<string>;
2322
2390
  declare function startupWorker(projectPath: string): Promise<void>;
2323
2391
 
2324
2392
  /**
2325
- * Stop the MCP server.
2393
+ * Stop the Express HTTP server.
2326
2394
  */
2327
- declare function stopServer(): Promise<void>;
2395
+ declare function stop_2(): Promise<void>;
2328
2396
 
2329
2397
  /** 支持创建的资源类型常量数组(用于 Zod enum 和 TypeScript type) */
2330
2398
  declare const SUPPORT_CREATE_TYPES: readonly ['animation-clip', 'typescript', 'auto-atlas', 'effect', 'scene', 'prefab', 'material', 'terrain', 'physics-material', 'label-atlas', 'render-texture', 'directory', 'effect-header'];
@@ -2388,6 +2456,12 @@ declare interface ThumbnailInfo {
2388
2456
  value: string; // 具体 icon 名字或者 image 路径,image 路径支持绝对路径、 db:// 、 project:// 、和 packages:// 下的路径
2389
2457
  }
2390
2458
 
2459
+ /**
2460
+ * Clean up MCP state.
2461
+ * Note: does NOT stop the Express server — use the Server module for that.
2462
+ */
2463
+ declare function unregister(): Promise<void>;
2464
+
2391
2465
  /**
2392
2466
  * Update Asset User Data // 更新资源用户数据
2393
2467
  */
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cocos/cocos-cli-types",
3
3
  "description": "types for cocos cli",
4
4
  "author": "cocos cli",
5
- "version": "0.0.1-alpha.21.1",
5
+ "version": "0.0.1-alpha.21.2",
6
6
  "main": "index.d.ts",
7
7
  "types": "index.d.ts",
8
8
  "exports": {