@kya-os/mcp-i 1.5.9-canary.14 → 1.5.9-canary.15

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 CHANGED
@@ -274,7 +274,7 @@ xmcp-i dev
274
274
  mcpi build
275
275
 
276
276
  # Platform-specific builds with identity optimization
277
- mcpi build --vercel
277
+ mcpi build --platform vercel
278
278
  mcpi build --lambda
279
279
  mcpi build --docker
280
280
  ```
@@ -2,5 +2,6 @@ export { type Middleware } from "../types/middleware";
2
2
  export type CompilerMode = "development" | "production";
3
3
  export interface CompileOptions {
4
4
  onBuild?: () => void;
5
+ platform?: 'vercel';
5
6
  }
6
- export declare function compile({ onBuild }?: CompileOptions): Promise<void>;
7
+ export declare function compile({ onBuild, platform }?: CompileOptions): Promise<void>;
@@ -40,26 +40,34 @@ const start_http_server_1 = require("./start-http-server");
40
40
  const path_validation_1 = require("../utils/path-validation");
41
41
  const utils_1 = require("./config/utils");
42
42
  dotenv_1.default.config();
43
- async function compile({ onBuild } = {}) {
43
+ async function compile({ onBuild, platform } = {}) {
44
+ console.log('[COMPILER] compile() called with platform:', platform);
44
45
  // Initialize compiler context if not already set
45
46
  const mode = process.env.NODE_ENV === "production" ? "production" : "development";
47
+ console.log('[COMPILER] Mode determined:', mode);
48
+ console.log('[COMPILER] NODE_ENV:', process.env.NODE_ENV);
46
49
  // Use compiler context provider to set up the context properly
47
50
  return new Promise((resolve, reject) => {
51
+ console.log('[COMPILER] Creating promise for compilation');
48
52
  (0, compiler_context_1.compilerContextProvider)({
49
53
  mode,
50
54
  projectRoot: process.cwd(),
51
55
  platforms: {},
52
56
  }, () => {
53
- compileInternal({ onBuild }).then(resolve).catch(reject);
57
+ console.log('[COMPILER] Calling compileInternal');
58
+ compileInternal({ onBuild, platform }).then(resolve).catch(reject);
54
59
  });
55
60
  });
56
61
  }
57
- async function compileInternal({ onBuild } = {}) {
62
+ async function compileInternal({ onBuild, platform } = {}) {
63
+ console.log('[COMPILER] compileInternal() starting - platform:', platform);
58
64
  const { mode } = compiler_context_1.compilerContext.getContext();
59
65
  const { toolPaths } = compiler_context_1.compilerContext.getContext();
66
+ console.log('[COMPILER] compileInternal() - mode from context:', mode);
60
67
  const startTime = Date.now();
61
68
  let compilerStarted = false;
62
69
  const xmpcConfig = await (0, parse_xmcp_config_1.getConfig)();
70
+ console.log('[COMPILER] Config loaded, http:', !!xmpcConfig.http, 'stdio:', !!xmpcConfig.stdio);
63
71
  compiler_context_1.compilerContext.setContext({
64
72
  xmcpConfig: xmpcConfig,
65
73
  });
@@ -114,6 +122,7 @@ async function compileInternal({ onBuild } = {}) {
114
122
  }
115
123
  // start compiler
116
124
  watcher.onReady(() => {
125
+ console.log('[COMPILER] Watcher ready - initializing compilation');
117
126
  let firstBuild = true;
118
127
  compilerStarted = true;
119
128
  // delete existing runtime folder
@@ -122,6 +131,7 @@ async function compileInternal({ onBuild } = {}) {
122
131
  generateCode();
123
132
  const compiler = (0, webpack_1.webpack)(webpackConfig);
124
133
  const handleCompilation = (err, stats) => {
134
+ console.log('[COMPILER] handleCompilation callback called - err:', !!err, 'stats:', !!stats, 'firstBuild:', firstBuild);
125
135
  if (err) {
126
136
  console.error(err);
127
137
  reject(err);
@@ -143,14 +153,49 @@ async function compileInternal({ onBuild } = {}) {
143
153
  console.log(`${cli_icons_1.greenCheck} Compiled in ${chalk.bold.green(`${duration}ms`)}`);
144
154
  (0, on_first_build_1.onFirstBuild)(mode, xmpcConfig);
145
155
  onBuild?.();
156
+ console.log('[COMPILER] First build completed - mode:', mode, 'platform:', platform);
146
157
  // In production mode, close watcher and compiler, then resolve
147
158
  if (mode === "production") {
148
- watcher.close().then(() => {
159
+ console.log('[COMPILER] Production mode detected - platform:', platform);
160
+ watcher.close().then(async () => {
149
161
  // Close webpack compiler to release all resources
150
162
  compiler.close((compilerCloseErr) => {
151
163
  if (compilerCloseErr) {
152
164
  console.error('Error closing webpack compiler:', compilerCloseErr);
153
165
  reject(compilerCloseErr);
166
+ return;
167
+ }
168
+ console.log('[COMPILER] Compiler closed successfully');
169
+ console.log('[COMPILER] Platform value in callback:', platform);
170
+ console.log('[COMPILER] Checking if platform === "vercel":', platform === 'vercel');
171
+ // Platform-specific post-build steps (must be handled after compiler.close completes)
172
+ if (platform === 'vercel') {
173
+ console.log('[COMPILER] Vercel platform detected! Starting async build...');
174
+ // Wrap async operations in a separate async function
175
+ (async () => {
176
+ try {
177
+ console.log('[COMPILER] Inside async IIFE');
178
+ console.log('\nšŸ“¦ Building Vercel deployment package...');
179
+ // Dynamic import of Vercel build utilities
180
+ // This will be available when @kya-os/mcp-i-vercel is installed
181
+ console.log('[COMPILER] Attempting dynamic import of @kya-os/mcp-i-vercel/build');
182
+ const vercelModule = await import('@kya-os/mcp-i-vercel/build').catch((importErr) => {
183
+ console.error('[COMPILER] Dynamic import failed:', importErr);
184
+ throw new Error(`Cannot find @kya-os/mcp-i-vercel package. ` +
185
+ `Install it with: npm install @kya-os/mcp-i-vercel\n` +
186
+ `Original error: ${importErr instanceof Error ? importErr.message : String(importErr)}`);
187
+ });
188
+ console.log('[COMPILER] Dynamic import successful');
189
+ console.log('[COMPILER] Calling buildVercelOutput()');
190
+ await vercelModule.buildVercelOutput();
191
+ console.log('[COMPILER] buildVercelOutput() completed');
192
+ resolve();
193
+ }
194
+ catch (vercelBuildErr) {
195
+ console.error('[COMPILER] Error building Vercel output:', vercelBuildErr);
196
+ reject(vercelBuildErr);
197
+ }
198
+ })();
154
199
  }
155
200
  else {
156
201
  resolve();