@expo/cli 56.1.5 → 56.1.6

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 (59) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/events/index.js +1 -1
  3. package/build/src/export/embed/exportEmbedAsync.js +1 -1
  4. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  5. package/build/src/export/embed/exportServer.js +1 -1
  6. package/build/src/export/embed/exportServer.js.map +1 -1
  7. package/build/src/export/exportApp.js +1 -1
  8. package/build/src/export/exportApp.js.map +1 -1
  9. package/build/src/export/publicFolder.js +19 -1
  10. package/build/src/export/publicFolder.js.map +1 -1
  11. package/build/src/login/index.js +25 -5
  12. package/build/src/login/index.js.map +1 -1
  13. package/build/src/run/android/resolveLaunchProps.js +4 -1
  14. package/build/src/run/android/resolveLaunchProps.js.map +1 -1
  15. package/build/src/start/doctor/dependencies/reactNativeTv.js +149 -0
  16. package/build/src/start/doctor/dependencies/reactNativeTv.js.map +1 -0
  17. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +28 -3
  18. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  19. package/build/src/start/server/DevToolsPlugin.js +26 -1
  20. package/build/src/start/server/DevToolsPlugin.js.map +1 -1
  21. package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js +57 -22
  22. package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +1 -1
  23. package/build/src/start/server/DevToolsPluginCliExtensionResults.js +29 -0
  24. package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +1 -1
  25. package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js +15 -5
  26. package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js.map +1 -1
  27. package/build/src/start/server/UrlCreator.js +4 -0
  28. package/build/src/start/server/UrlCreator.js.map +1 -1
  29. package/build/src/start/server/createMCPDevToolsExtensionSchema.js +13 -1
  30. package/build/src/start/server/createMCPDevToolsExtensionSchema.js.map +1 -1
  31. package/build/src/start/server/metro/MetroBundlerDevServer.js +44 -0
  32. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  33. package/build/src/start/server/metro/createServerComponentsMiddleware.js +13 -13
  34. package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
  35. package/build/src/start/server/metro/dev-server/createMessageSocket.js +13 -2
  36. package/build/src/start/server/metro/dev-server/createMessageSocket.js.map +1 -1
  37. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +2 -1
  38. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
  39. package/build/src/start/server/metro/instantiateMetro.js +5 -4
  40. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  41. package/build/src/start/server/metro/router.js +10 -1
  42. package/build/src/start/server/metro/router.js.map +1 -1
  43. package/build/src/start/server/middleware/OpenMiddleware.js +150 -0
  44. package/build/src/start/server/middleware/OpenMiddleware.js.map +1 -0
  45. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +13 -4
  46. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
  47. package/build/src/start/server/middleware/ServeStaticMiddleware.js +2 -9
  48. package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -1
  49. package/build/src/start/server/middleware/openHandlers.js +157 -0
  50. package/build/src/start/server/middleware/openHandlers.js.map +1 -0
  51. package/build/src/start/server/webTemplate.js +3 -5
  52. package/build/src/start/server/webTemplate.js.map +1 -1
  53. package/build/src/utils/net.js +7 -1
  54. package/build/src/utils/net.js.map +1 -1
  55. package/build/src/utils/tar.js +2 -2
  56. package/build/src/utils/tar.js.map +1 -1
  57. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  58. package/build/src/utils/telemetry/utils/context.js +1 -1
  59. package/package.json +14 -14
@@ -8,17 +8,46 @@ Object.defineProperty(exports, "DevToolsPluginCliExtensionResults", {
8
8
  return DevToolsPluginCliExtensionResults;
9
9
  }
10
10
  });
11
+ function _nodebuffer() {
12
+ const data = require("node:buffer");
13
+ _nodebuffer = function() {
14
+ return data;
15
+ };
16
+ return data;
17
+ }
11
18
  const _DevToolsPluginschema = require("./DevToolsPlugin.schema");
19
+ // Cap accumulated output at V8's max single-string length to bound heap growth.
20
+ const MAX_OUTPUT_LENGTH = _nodebuffer().constants.MAX_STRING_LENGTH;
12
21
  class DevToolsPluginCliExtensionResults {
13
22
  constructor(onOutput){
14
23
  this.onOutput = onOutput;
15
24
  this._output = [];
25
+ this._totalLength = 0;
26
+ this._truncated = false;
16
27
  }
17
28
  append(output, level = 'info') {
29
+ if (this._truncated) return;
30
+ if (this._totalLength + output.length > MAX_OUTPUT_LENGTH) {
31
+ this._truncated = true;
32
+ const message = {
33
+ type: 'text',
34
+ text: `Output truncated: plugin exceeded V8's max string length (${MAX_OUTPUT_LENGTH} chars). Reduce output, paginate, or write to a file.`,
35
+ level: 'error'
36
+ };
37
+ this._output.push(message);
38
+ this.onOutput == null ? void 0 : this.onOutput.call(this, [
39
+ message
40
+ ]);
41
+ return;
42
+ }
43
+ this._totalLength += output.length;
18
44
  const results = this.parseOutputText(output, level);
19
45
  this._output.push(...results);
20
46
  this.onOutput == null ? void 0 : this.onOutput.call(this, results);
21
47
  }
48
+ isTruncated() {
49
+ return this._truncated;
50
+ }
22
51
  exit(code) {
23
52
  if (code === 0) return;
24
53
  this.append(`Process exited with code ${code}`, 'error');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevToolsPluginCliExtensionResults.ts"],"sourcesContent":["import type { DevToolsPluginOutput } from './DevToolsPlugin.schema';\nimport { DevToolsPluginOutputSchema } from './DevToolsPlugin.schema';\n\n/**\n * Class that collects and manages output from executed plugin commands\n *\n * Responsibilities:\n * - Collects output data from executed commands\n * - Parses and validates output data against expected schema\n * - Provides methods to append new output entries\n * - Handles exit codes and appends relevant messages\n * - Handles streaming of output via optional callback\n */\nexport class DevToolsPluginCliExtensionResults {\n constructor(private onOutput?: (output: DevToolsPluginOutput) => void) {}\n\n private _output: DevToolsPluginOutput = [];\n\n public append(output: string, level: 'info' | 'warning' | 'error' = 'info') {\n const results = this.parseOutputText(output, level);\n this._output.push(...results);\n this.onOutput?.(results);\n }\n\n public exit(code: number) {\n if (code === 0) return;\n this.append(`Process exited with code ${code}`, 'error');\n }\n\n public getOutput(): DevToolsPluginOutput {\n return this._output;\n }\n\n private parseOutputText(\n txt: string,\n level: 'info' | 'warning' | 'error' = 'info'\n ): DevToolsPluginOutput {\n // Validate against schema\n try {\n const result = DevToolsPluginOutputSchema.safeParse(JSON.parse(txt));\n if (!result.success) {\n return [\n {\n type: 'text',\n text: `Invalid JSON: ${result.error.issues.map((issue) => issue.message).join(', ')}`,\n level: 'error',\n },\n ];\n }\n return result.data;\n } catch {\n // Not JSON, treat as plain text\n const lines = txt.split('\\n');\n const results: DevToolsPluginOutput = [];\n for (const line of lines) {\n if (line) {\n results.push({ type: 'text', text: line, level });\n }\n }\n return results;\n }\n }\n}\n"],"names":["DevToolsPluginCliExtensionResults","onOutput","_output","append","output","level","results","parseOutputText","push","exit","code","getOutput","txt","result","DevToolsPluginOutputSchema","safeParse","JSON","parse","success","type","text","error","issues","map","issue","message","join","data","lines","split","line"],"mappings":";;;;+BAaaA;;;eAAAA;;;sCAZ8B;AAYpC,MAAMA;IACX,YAAY,AAAQC,QAAiD,CAAE;aAAnDA,WAAAA;aAEZC,UAAgC,EAAE;IAF8B;IAIjEC,OAAOC,MAAc,EAAEC,QAAsC,MAAM,EAAE;QAC1E,MAAMC,UAAU,IAAI,CAACC,eAAe,CAACH,QAAQC;QAC7C,IAAI,CAACH,OAAO,CAACM,IAAI,IAAIF;QACrB,IAAI,CAACL,QAAQ,oBAAb,IAAI,CAACA,QAAQ,MAAb,IAAI,EAAYK;IAClB;IAEOG,KAAKC,IAAY,EAAE;QACxB,IAAIA,SAAS,GAAG;QAChB,IAAI,CAACP,MAAM,CAAC,CAAC,yBAAyB,EAAEO,MAAM,EAAE;IAClD;IAEOC,YAAkC;QACvC,OAAO,IAAI,CAACT,OAAO;IACrB;IAEQK,gBACNK,GAAW,EACXP,QAAsC,MAAM,EACtB;QACtB,0BAA0B;QAC1B,IAAI;YACF,MAAMQ,SAASC,gDAA0B,CAACC,SAAS,CAACC,KAAKC,KAAK,CAACL;YAC/D,IAAI,CAACC,OAAOK,OAAO,EAAE;gBACnB,OAAO;oBACL;wBACEC,MAAM;wBACNC,MAAM,CAAC,cAAc,EAAEP,OAAOQ,KAAK,CAACC,MAAM,CAACC,GAAG,CAAC,CAACC,QAAUA,MAAMC,OAAO,EAAEC,IAAI,CAAC,OAAO;wBACrFrB,OAAO;oBACT;iBACD;YACH;YACA,OAAOQ,OAAOc,IAAI;QACpB,EAAE,OAAM;YACN,gCAAgC;YAChC,MAAMC,QAAQhB,IAAIiB,KAAK,CAAC;YACxB,MAAMvB,UAAgC,EAAE;YACxC,KAAK,MAAMwB,QAAQF,MAAO;gBACxB,IAAIE,MAAM;oBACRxB,QAAQE,IAAI,CAAC;wBAAEW,MAAM;wBAAQC,MAAMU;wBAAMzB;oBAAM;gBACjD;YACF;YACA,OAAOC;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../src/start/server/DevToolsPluginCliExtensionResults.ts"],"sourcesContent":["import { constants as bufferConstants } from 'node:buffer';\n\nimport type { DevToolsPluginOutput } from './DevToolsPlugin.schema';\nimport { DevToolsPluginOutputSchema } from './DevToolsPlugin.schema';\n\n// Cap accumulated output at V8's max single-string length to bound heap growth.\nconst MAX_OUTPUT_LENGTH = bufferConstants.MAX_STRING_LENGTH;\n\n/**\n * Class that collects and manages output from executed plugin commands\n *\n * Responsibilities:\n * - Collects output data from executed commands\n * - Parses and validates output data against expected schema\n * - Provides methods to append new output entries\n * - Handles exit codes and appends relevant messages\n * - Handles streaming of output via optional callback\n */\nexport class DevToolsPluginCliExtensionResults {\n constructor(private onOutput?: (output: DevToolsPluginOutput) => void) {}\n\n private _output: DevToolsPluginOutput = [];\n private _totalLength = 0;\n private _truncated = false;\n\n public append(output: string, level: 'info' | 'warning' | 'error' = 'info') {\n if (this._truncated) return;\n if (this._totalLength + output.length > MAX_OUTPUT_LENGTH) {\n this._truncated = true;\n const message = {\n type: 'text' as const,\n text: `Output truncated: plugin exceeded V8's max string length (${MAX_OUTPUT_LENGTH} chars). Reduce output, paginate, or write to a file.`,\n level: 'error' as const,\n };\n this._output.push(message);\n this.onOutput?.([message]);\n return;\n }\n this._totalLength += output.length;\n const results = this.parseOutputText(output, level);\n this._output.push(...results);\n this.onOutput?.(results);\n }\n\n public isTruncated(): boolean {\n return this._truncated;\n }\n\n public exit(code: number) {\n if (code === 0) return;\n this.append(`Process exited with code ${code}`, 'error');\n }\n\n public getOutput(): DevToolsPluginOutput {\n return this._output;\n }\n\n private parseOutputText(\n txt: string,\n level: 'info' | 'warning' | 'error' = 'info'\n ): DevToolsPluginOutput {\n // Validate against schema\n try {\n const result = DevToolsPluginOutputSchema.safeParse(JSON.parse(txt));\n if (!result.success) {\n return [\n {\n type: 'text',\n text: `Invalid JSON: ${result.error.issues.map((issue) => issue.message).join(', ')}`,\n level: 'error',\n },\n ];\n }\n return result.data;\n } catch {\n // Not JSON, treat as plain text\n const lines = txt.split('\\n');\n const results: DevToolsPluginOutput = [];\n for (const line of lines) {\n if (line) {\n results.push({ type: 'text', text: line, level });\n }\n }\n return results;\n }\n }\n}\n"],"names":["DevToolsPluginCliExtensionResults","MAX_OUTPUT_LENGTH","bufferConstants","MAX_STRING_LENGTH","onOutput","_output","_totalLength","_truncated","append","output","level","length","message","type","text","push","results","parseOutputText","isTruncated","exit","code","getOutput","txt","result","DevToolsPluginOutputSchema","safeParse","JSON","parse","success","error","issues","map","issue","join","data","lines","split","line"],"mappings":";;;;+BAkBaA;;;eAAAA;;;;yBAlBgC;;;;;;sCAGF;AAE3C,gFAAgF;AAChF,MAAMC,oBAAoBC,uBAAe,CAACC,iBAAiB;AAYpD,MAAMH;IACX,YAAY,AAAQI,QAAiD,CAAE;aAAnDA,W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MpB,OAAO,EAAEqB,IAAI,CAAC,OAAO;wBACrFvB,OAAO;oBACT;iBACD;YACH;YACA,OAAOa,OAAOW,IAAI;QACpB,EAAE,OAAM;YACN,gCAAgC;YAChC,MAAMC,QAAQb,IAAIc,KAAK,CAAC;YACxB,MAAMpB,UAAgC,EAAE;YACxC,KAAK,MAAMqB,QAAQF,MAAO;gBACxB,IAAIE,MAAM;oBACRrB,QAAQD,IAAI,CAAC;wBAAEF,MAAM;wBAAQC,MAAMuB;wBAAM3B;oBAAM;gBACjD;YACF;YACA,OAAOM;QACT;IACF;AACF"}
@@ -17,15 +17,25 @@ async function addMcpCapabilities(mcpServer, devServerManager) {
17
17
  const plugins = await devServerManager.devtoolsPluginManager.queryPluginsAsync();
18
18
  for (const plugin of plugins){
19
19
  if (plugin.cliExtensions) {
20
- const commands = (plugin.cliExtensions.commands ?? []).filter((p)=>{
20
+ const mcpCommands = (plugin.cliExtensions.commands ?? []).filter((p)=>{
21
21
  var _p_environments;
22
22
  return (_p_environments = p.environments) == null ? void 0 : _p_environments.includes('mcp');
23
23
  });
24
- if (commands.length === 0) {
24
+ if (mcpCommands.length === 0) {
25
25
  continue;
26
26
  }
27
- const schema = (0, _createMCPDevToolsExtensionSchema.createMCPDevToolsExtensionSchema)(plugin);
28
- debug(`Installing MCP CLI extension for plugin: ${plugin.packageName} - found ${commands.length} commands`);
27
+ // Build an MCP-scoped descriptor so the schema enum and the executor's
28
+ // existence check both reject commands that were not declared MCP-enabled.
29
+ const mcpPlugin = {
30
+ packageName: plugin.packageName,
31
+ packageRoot: plugin.packageRoot,
32
+ cliExtensions: {
33
+ ...plugin.cliExtensions,
34
+ commands: mcpCommands
35
+ }
36
+ };
37
+ const schema = (0, _createMCPDevToolsExtensionSchema.createMCPDevToolsExtensionSchema)(mcpPlugin);
38
+ debug(`Installing MCP CLI extension for plugin: ${plugin.packageName} - found ${mcpCommands.length} commands`);
29
39
  mcpServer.registerTool(plugin.packageName, {
30
40
  title: plugin.packageName,
31
41
  description: plugin.description,
@@ -36,7 +46,7 @@ async function addMcpCapabilities(mcpServer, devServerManager) {
36
46
  try {
37
47
  const { command, ...args } = parameters;
38
48
  const metroServerOrigin = devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();
39
- const results = await new _DevToolsPluginCliExtensionExecutor.DevToolsPluginCliExtensionExecutor(plugin, devServerManager.projectRoot).execute({
49
+ const results = await new _DevToolsPluginCliExtensionExecutor.DevToolsPluginCliExtensionExecutor(mcpPlugin, devServerManager.projectRoot).execute({
40
50
  command,
41
51
  args,
42
52
  metroServerOrigin
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/MCPDevToolsPluginCLIExtensions.ts"],"sourcesContent":["import type { DevServerManager } from './DevServerManager';\nimport { DevToolsPluginOutputSchema } from './DevToolsPlugin.schema';\nimport { DevToolsPluginCliExtensionExecutor } from './DevToolsPluginCliExtensionExecutor';\nimport type { McpServer } from './MCP';\nimport { createMCPDevToolsExtensionSchema } from './createMCPDevToolsExtensionSchema';\nimport { Log } from '../../log';\n\nconst debug = require('debug')('expo:start:server:devtools:mcp');\n\nexport async function addMcpCapabilities(mcpServer: McpServer, devServerManager: DevServerManager) {\n const plugins = await devServerManager.devtoolsPluginManager.queryPluginsAsync();\n\n for (const plugin of plugins) {\n if (plugin.cliExtensions) {\n const commands = (plugin.cliExtensions.commands ?? []).filter((p) =>\n p.environments?.includes('mcp')\n );\n if (commands.length === 0) {\n continue;\n }\n\n const schema = createMCPDevToolsExtensionSchema(plugin);\n\n debug(\n `Installing MCP CLI extension for plugin: ${plugin.packageName} - found ${commands.length} commands`\n );\n\n mcpServer.registerTool(\n plugin.packageName,\n {\n title: plugin.packageName,\n description: plugin.description,\n inputSchema: { parameters: schema },\n },\n async ({ parameters }) => {\n try {\n const { command, ...args } = parameters;\n\n const metroServerOrigin = devServerManager\n .getDefaultDevServer()\n .getJsInspectorBaseUrl();\n\n const results = await new DevToolsPluginCliExtensionExecutor(\n plugin,\n devServerManager.projectRoot\n ).execute({ command, args, metroServerOrigin });\n\n const parsedResults = DevToolsPluginOutputSchema.safeParse(results);\n if (parsedResults.success === false) {\n throw new Error(\n `Invalid output from CLI command: ${parsedResults.error.issues\n .map((issue) => issue.message)\n .join(', ')}`\n );\n }\n return {\n content: parsedResults.data\n .map((line) => {\n const { type } = line;\n if (type === 'text') {\n return { type, text: line.text, level: line.level, url: line.url };\n } else if (line.type === 'image' || line.type === 'audio') {\n // We could present this as a resource_link, but it seems not to be well supported in MCP clients,\n // so we'll return a text with the link instead.\n return {\n type: 'text',\n text: `${type} resource: ${line.url}${line.text ? ' (' + line.text + ')' : ''}`,\n } as const;\n }\n return null;\n })\n .filter((line): line is Exclude<typeof line, null> => line !== null),\n };\n } catch (e: any) {\n Log.error('Error executing MCP CLI command:', e);\n return {\n content: [{ type: 'text', text: `Error executing command: ${e.toString()}` }],\n isError: true,\n };\n }\n }\n );\n }\n }\n}\n"],"names":["addMcpCapabilities","debug","require","mcpServer","devServerManager","plugins","devtoolsPluginManager","queryPluginsAsync","plugin","cliExtensions","commands","filter","p","environments","includes","length","schema","createMCPDevToolsExtensionSchema","packageName","registerTool","title","description","inputSchema","parameters","command","args","metroServerOrigin","getDefaultDevServer","getJsInspectorBaseUrl","results","DevToolsPluginCliExtensionExecutor","projectRoot","execute","parsedResults","DevToolsPluginOutputSchema","safeParse","success","Error","error","issues","map","issue","message","join","content","data","line","type","text","level","url","e","Log","toString","isError"],"mappings":";;;;+BASsBA;;;eAAAA;;;sCARqB;oDACQ;kDAEF;qBAC7B;AAEpB,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,mBAAmBG,SAAoB,EAAEC,gBAAkC;IAC/F,MAAMC,UAAU,MAAMD,iBAAiBE,qBAAqB,CAACC,iBAAiB;IAE9E,KAAK,MAAMC,UAAUH,QAAS;QAC5B,IAAIG,OAAOC,aAAa,EAAE;YACxB,MAAMC,WAAW,AAACF,CAAAA,OAAOC,aAAa,CAACC,QAAQ,IAAI,EAAE,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O,IAAIJ,KAAKC,IAAI,KAAK,WAAWD,KAAKC,IAAI,KAAK,SAAS;gCACzD,kGAAkG;gCAClG,gDAAgD;gCAChD,OAAO;oCACLA,MAAM;oCACNC,MAAM,GAAGD,KAAK,WAAW,EAAED,KAAKI,GAAG,GAAGJ,KAAKE,IAAI,GAAG,OAAOF,KAAKE,IAAI,GAAG,MAAM,IAAI;gCACjF;4BACF;4BACA,OAAO;wBACT,GACCrC,MAAM,CAAC,CAACmC,OAA6CA,SAAS;oBACnE;gBACF,EAAE,OAAOK,GAAQ;oBACfC,QAAG,CAACd,KAAK,CAAC,oCAAoCa;oBAC9C,OAAO;wBACLP,SAAS;4BAAC;gCAAEG,MAAM;gCAAQC,MAAM,CAAC,yBAAyB,EAAEG,EAAEE,QAAQ,IAAI;4BAAC;yBAAE;wBAC7EC,SAAS;oBACX;gBACF;YACF;QAEJ;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../src/start/server/MCPDevToolsPluginCLIExtensions.ts"],"sourcesContent":["import type { DevServerManager } from './DevServerManager';\nimport type { DevToolsPluginInfo } from './DevToolsPlugin.schema';\nimport { DevToolsPluginOutputSchema } from './DevToolsPlugin.schema';\nimport { DevToolsPluginCliExtensionExecutor } from './DevToolsPluginCliExtensionExecutor';\nimport type { McpServer } from './MCP';\nimport { createMCPDevToolsExtensionSchema } from './createMCPDevToolsExtensionSchema';\nimport { Log } from '../../log';\n\nconst debug = require('debug')('expo:start:server:devtools:mcp');\n\nexport async function addMcpCapabilities(mcpServer: McpServer, devServerManager: DevServerManager) {\n const plugins = await devServerManager.devtoolsPluginManager.queryPluginsAsync();\n\n for (const plugin of plugins) {\n if (plugin.cliExtensions) {\n const mcpCommands = (plugin.cliExtensions.commands ?? []).filter((p) =>\n p.environments?.includes('mcp')\n );\n if (mcpCommands.length === 0) {\n continue;\n }\n\n // Build an MCP-scoped descriptor so the schema enum and the executor's\n // existence check both reject commands that were not declared MCP-enabled.\n const mcpPlugin: DevToolsPluginInfo = {\n packageName: plugin.packageName,\n packageRoot: plugin.packageRoot,\n cliExtensions: {\n ...plugin.cliExtensions,\n commands: mcpCommands,\n },\n };\n\n const schema = createMCPDevToolsExtensionSchema(mcpPlugin);\n\n debug(\n `Installing MCP CLI extension for plugin: ${plugin.packageName} - found ${mcpCommands.length} commands`\n );\n\n mcpServer.registerTool(\n plugin.packageName,\n {\n title: plugin.packageName,\n description: plugin.description,\n inputSchema: { parameters: schema },\n },\n async ({ parameters }) => {\n try {\n const { command, ...args } = parameters;\n\n const metroServerOrigin = devServerManager\n .getDefaultDevServer()\n .getJsInspectorBaseUrl();\n\n const results = await new DevToolsPluginCliExtensionExecutor(\n mcpPlugin,\n devServerManager.projectRoot\n ).execute({ command, args, metroServerOrigin });\n\n const parsedResults = DevToolsPluginOutputSchema.safeParse(results);\n if (parsedResults.success === false) {\n throw new Error(\n `Invalid output from CLI command: ${parsedResults.error.issues\n .map((issue) => issue.message)\n .join(', ')}`\n );\n }\n return {\n content: parsedResults.data\n .map((line) => {\n const { type } = line;\n if (type === 'text') {\n return { type, text: line.text, level: line.level, url: line.url };\n } else if (line.type === 'image' || line.type === 'audio') {\n // We could present this as a resource_link, but it seems not to be well supported in MCP clients,\n // so we'll return a text with the link instead.\n return {\n type: 'text',\n text: `${type} resource: ${line.url}${line.text ? ' (' + line.text + ')' : ''}`,\n } as const;\n }\n return null;\n })\n .filter((line): line is Exclude<typeof line, null> => line !== null),\n };\n } catch (e: any) {\n Log.error('Error executing MCP CLI command:', e);\n return {\n content: [{ type: 'text', text: `Error executing command: ${e.toString()}` }],\n isError: true,\n };\n }\n }\n );\n }\n }\n}\n"],"names":["addMcpCapabilities","debug","require","mcpServer","devServerManager","plugins","devtoolsPluginManager","queryPluginsAsync","plugin","cliExtensions","mcpCommands","commands","filter","p","environments","includes","length","mcpPlugin","packageName","packageRoot","schema","createMCPDevToolsExtensionSchema","registerTool","title","description","inputSchema","parameters","command","args","metroServerOrigin","getDefaultDevServer","getJsInspectorBaseUrl","results","DevToolsPluginCliExtensionExecutor","projectRoot","execute","parsedResults","DevToolsPluginOutputSchema","safeParse","success","Error","error","issues","map","issue","message","join","content","data","line","type","text","level","url","e","Log","toString","isError"],"mappings":";;;;+BAUsBA;;;eAAAA;;;sCARqB;oDACQ;kDAEF;qBAC7B;AAEpB,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,mBAAmBG,SAAoB,EAAEC,gBAAkC;IAC/F,MAAMC,UAAU,MAAMD,iBAAiBE,qBAAqB,CAACC,iBAAiB;IAE9E,KAAK,MAAMC,UAAUH,QAAS;QAC5B,IAAIG,OAAOC,aAAa,EAAE;YACxB,MAAMC,cAAc,AAACF,CAAAA,OAAOC,aAAa,CAACE,QAAQ,IAAI,EAAE,AAAD,EAAGC,MAAM,CAAC,CAACC;oBAChEA;wBAAAA,kBAAAA,EAAEC,YAAY,qBAAdD,gBAAgBE,QAAQ,CAAC;;YAE3B,IAAIL,YAAYM,MAAM,KAAK,GAAG;gBAC5B;YACF;YAEA,uEAAuE;YACvE,2EAA2E;YAC3E,MAAMC,YAAgC;gBACpCC,aAAaV,OAAOU,WAAW;gBAC/BC,aAAaX,OAAOW,WAAW;gBAC/BV,eAAe;oBACb,GAAGD,OAAOC,aAAa;oBACvBE,UAAUD;gBACZ;YACF;YAEA,MAAMU,SAASC,IAAAA,kEAAgC,EAACJ;YAEhDhB,MACE,CAAC,yCAAyC,EAAEO,OAAOU,WAAW,CAAC,SAAS,EAAER,YAAYM,MAAM,CAAC,SAAS,CAAC;YAGzGb,UAAUmB,YAAY,CACpBd,OAAOU,WAAW,EAClB;gBACEK,OAAOf,OAAOU,WAAW;gBACzBM,aAAahB,OAAOgB,WAAW;gBAC/BC,aAAa;oBAAEC,YAAYN;gBAAO;YACpC,GACA,OAAO,EAAEM,UAAU,EAAE;gBACnB,IAAI;oBACF,MAAM,EAAEC,OAAO,EAAE,GAAGC,MAAM,GAAGF;oBAE7B,MAAMG,oBAAoBzB,iBACvB0B,mBAAmB,GACnBC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
  getDefaultRouteAddress() {
137
137
  return this.gatewayInfo.address;
138
138
  }
139
+ /** URL scheme configured for development-build deep links (e.g. `myapp`). `null` when unset. */ getScheme() {
140
+ var _this_defaults;
141
+ return ((_this_defaults = this.defaults) == null ? void 0 : _this_defaults.scheme) ?? null;
142
+ }
139
143
  /** Get the URL components from the Ngrok server URL. */ getTunnelUrlComponents(options) {
140
144
  const tunnelUrl = this.bundlerInfo.getTunnelUrl == null ? void 0 : this.bundlerInfo.getTunnelUrl.call(this.bundlerInfo);
141
145
  if (!tunnelUrl) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport type { GatewayInfo } from '../../utils/ip';\nimport { getGateway, getGatewayAsync } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\n\ninterface BundlerInfo {\n port: number;\n getTunnelUrl?(): string | null;\n}\n\nexport class UrlCreator {\n constructor(\n public defaults: CreateURLOptions,\n private bundlerInfo: BundlerInfo,\n private gatewayInfo: GatewayInfo = getGateway()\n ) {}\n\n static async init(defaults: CreateURLOptions | undefined | null, bundlerInfo: BundlerInfo) {\n const gatewayInfo = await getGatewayAsync();\n return new UrlCreator(defaults || {}, bundlerInfo, gatewayInfo);\n }\n\n /**\n * Return a URL for the \"loading\" interstitial page that is used to disambiguate which\n * native runtime to open the dev server with.\n *\n * @param options options for creating the URL\n * @param platform when opening the URL from the CLI to a connected device we can specify the platform as a query parameter, otherwise it will be inferred from the unsafe user agent sniffing.\n *\n * @returns URL like `http://localhost:8081/_expo/loading?platform=ios`\n * @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string | null): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n if (platform) {\n url.search = new URLSearchParams({ platform }).toString();\n }\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase()) ||\n // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs\n protocol.includes('_')\n ) {\n debug(`Invalid protocol for dev client URL: ${protocol}`);\n return null;\n }\n\n const manifestUrl = this.constructUrl({\n ...options,\n scheme: this.defaults?.hostType === 'tunnel' ? 'https' : 'http',\n });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n public getDefaultRouteAddress(): string {\n return this.gatewayInfo.address;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options, this.gatewayInfo),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nconst getDefaultHostname = (options: CreateURLOptions, gateway: GatewayInfo) => {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // NOTE: We always convert \"localhost\" as a request to 127.0.0.1,\n // to normalize to an address that's consistent\n return '127.0.0.1';\n } else {\n // Fall back to local address\n return options.hostname || gateway.address;\n }\n};\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n const validProtocol = protocol ? `${protocol}://` : '';\n\n const url = `${validProtocol}${hostname}`;\n\n if (port) {\n return url + `:${port}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["UrlCreator","debug","require","defaults","bundlerInfo","gatewayInfo","getGateway","init","getGatewayAsync","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","hostType","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getDefaultRouteAddress","address","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","components","Log","warn","getDefaultHostname","parsedProxyUrl","gateway","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","assert","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":";;;;+BA6BaA;;;eAAAA;;;;gEA7BM;;;;;;;yBACC;;;;;;6DAEC;oBAEuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5C,MAAMC,QAAQC,QAAQ,SAAS;AAsBxB,MAAMF;IACX,YACE,AAAOG,QAA0B,EACjC,AAAQC,WAAwB,EAChC,AAAQC,cAA2BC,IAAAA,cAAU,GAAE,CAC/C;aAHOH,WAAAA;aACCC,cAAAA;aACAC,cAAAA;IACP;IAEH,aAAaE,KAAKJ,QAA6C,EAAEC,WAAwB,EAAE;QACzF,MAAMC,cAAc,MAAMG,IAAAA,mBAAe;QACzC,OAAO,IAAIR,WAAWG,YAAY,CAAC,GAAGC,aAAaC;IACrD;IAEA;;;;;;;;;GASC,GACD,AAAOI,oBAAoBC,OAAyB,EAAEC,QAAuB,EAAU;QACrF,MAAMC,MAAM,IAAIC,CAAAA,MAAE,KAAC,CAAC,iBAAiB,IAAI,CAACC,YAAY,CAAC;YAAEC,QAAQ;YAAQ,GAAGL,OAAO;QAAC;QACpF,IAAIC,UAAU;YACZC,IAAII,MAAM,GAAG,IAAIC,gBAAgB;gBAAEN;YAAS,GAAGO,QA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A,MAAMwB,qBAAqB,CAACnC,SAA2BqC;IACrD,4CAA4C;IAC5C,IAAIC,QAAQC,GAAG,CAACC,8BAA8B,EAAE;QAC9C,OAAOF,QAAQC,GAAG,CAACC,8BAA8B,CAACC,IAAI;IACxD,OAAO,IAAIzC,QAAQ4B,QAAQ,KAAK,aAAa;QAC3C,iEAAiE;QACjE,+CAA+C;QAC/C,OAAO;IACT,OAAO;QACL,6BAA6B;QAC7B,OAAO5B,QAAQ4B,QAAQ,IAAIS,QAAQf,OAAO;IAC5C;AACF;AAEA,SAASF,kBAAkB,EAAET,QAAQ,EAAEiB,QAAQ,EAAED,IAAI,EAA0B;IAC7Ee,IAAAA,iBAAM,EAACd,UAAU;IACjB,MAAMe,gBAAgBhC,WAAW,GAAGA,SAAS,GAAG,CAAC,GAAG;IAEpD,MAAMT,MAAM,GAAGyC,gBAAgBf,UAAU;IAEzC,IAAID,MAAM;QACR,OAAOzB,MAAM,CAAC,CAAC,EAAEyB,MAAM;IACzB;IAEA,OAAOzB;AACT;AAEA,gBAAgB,GAChB,SAAS4B;IACP,OAAOQ,QAAQC,GAAG,CAACK,uBAAuB;AAC5C,EAEA,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
1
+ {"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport type { GatewayInfo } from '../../utils/ip';\nimport { getGateway, getGatewayAsync } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\n\ninterface BundlerInfo {\n port: number;\n getTunnelUrl?(): string | null;\n}\n\nexport class UrlCreator {\n constructor(\n public defaults: CreateURLOptions,\n private bundlerInfo: BundlerInfo,\n private gatewayInfo: GatewayInfo = getGateway()\n ) {}\n\n static async init(defaults: CreateURLOptions | undefined | null, bundlerInfo: BundlerInfo) {\n const gatewayInfo = await getGatewayAsync();\n return new UrlCreator(defaults || {}, bundlerInfo, gatewayInfo);\n }\n\n /**\n * Return a URL for the \"loading\" interstitial page that is used to disambiguate which\n * native runtime to open the dev server with.\n *\n * @param options options for creating the URL\n * @param platform when opening the URL from the CLI to a connected device we can specify the platform as a query parameter, otherwise it will be inferred from the unsafe user agent sniffing.\n *\n * @returns URL like `http://localhost:8081/_expo/loading?platform=ios`\n * @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string | null): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n if (platform) {\n url.search = new URLSearchParams({ platform }).toString();\n }\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase()) ||\n // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs\n protocol.includes('_')\n ) {\n debug(`Invalid protocol for dev client URL: ${protocol}`);\n return null;\n }\n\n const manifestUrl = this.constructUrl({\n ...options,\n scheme: this.defaults?.hostType === 'tunnel' ? 'https' : 'http',\n });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n public getDefaultRouteAddress(): string {\n return this.gatewayInfo.address;\n }\n\n /** URL scheme configured for development-build deep links (e.g. `myapp`). `null` when unset. */\n public getScheme(): string | null {\n return this.defaults?.scheme ?? null;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options, this.gatewayInfo),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nconst getDefaultHostname = (options: CreateURLOptions, gateway: GatewayInfo) => {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // NOTE: We always convert \"localhost\" as a request to 127.0.0.1,\n // to normalize to an address that's consistent\n return '127.0.0.1';\n } else {\n // Fall back to local address\n return options.hostname || gateway.address;\n }\n};\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n const validProtocol = protocol ? `${protocol}://` : '';\n\n const url = `${validProtocol}${hostname}`;\n\n if (port) {\n return url + `:${port}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["UrlCreator","debug","require","defaults","bundlerInfo","gatewayInfo","getGateway","init","getGatewayAsync","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","hostType","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getDefaultRouteAddress","address","getScheme","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","components","Log","warn","getDefaultHostname","parsedProxyUrl","gateway","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","assert","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":";;;;+BA6BaA;;;eAAAA;;;;gEA7BM;;;;;;;yBACC;;;;;;6DAEC;oBAEuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5C,MAAMC,QAAQC,QAAQ,SAAS;AAsBxB,MAAMF;IACX,YACE,AAAOG,QAA0B,EACjC,AAAQC,WAAwB,EAChC,AAAQC,cAA2BC,IAAA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EA,OAAO1B;AACT;AAEA,gBAAgB,GAChB,SAAS6B;IACP,OAAOQ,QAAQC,GAAG,CAACK,uBAAuB;AAC5C,EAEA,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
@@ -33,6 +33,7 @@ function createMCPDevToolsExtensionSchema(plugin) {
33
33
  // Track which commands use each parameter for documentation
34
34
  const parameterCommandMap = {};
35
35
  const parameterDescriptions = {};
36
+ const parameterTypes = {};
36
37
  for (const command of commands){
37
38
  if (command.parameters && command.parameters.length > 0) {
38
39
  for (const param of command.parameters){
@@ -41,6 +42,7 @@ function createMCPDevToolsExtensionSchema(plugin) {
41
42
  commands = [];
42
43
  parameterCommandMap[param.name] = commands;
43
44
  parameterDescriptions[param.name] = param.description || '';
45
+ parameterTypes[param.name] = param.type;
44
46
  }
45
47
  commands.push(command.name);
46
48
  }
@@ -53,7 +55,7 @@ function createMCPDevToolsExtensionSchema(plugin) {
53
55
  const commandsUsingParam = commandList.length === commands.length ? 'all commands' : commandList.map((c)=>`"${c}"`).join(', ');
54
56
  // Include command context in the description so LLMs know when to use each parameter
55
57
  const fullDescription = baseDescription ? `${baseDescription} (Used by: ${commandsUsingParam})` : `Parameter for: ${commandsUsingParam}`;
56
- allParameters[paramName] = _zod().z.string().optional().describe(fullDescription);
58
+ allParameters[paramName] = paramTypeToZod(parameterTypes[paramName]).optional().describe(fullDescription);
57
59
  }
58
60
  // Build the command description with clear instructions for the LLM
59
61
  const hasParameters = Object.keys(allParameters).length > 0;
@@ -65,5 +67,15 @@ function createMCPDevToolsExtensionSchema(plugin) {
65
67
  }).strict(); // .strict() adds additionalProperties: false
66
68
  return schema;
67
69
  }
70
+ function paramTypeToZod(type) {
71
+ switch(type){
72
+ case 'number':
73
+ return _zod().z.number();
74
+ case 'confirm':
75
+ return _zod().z.boolean();
76
+ case 'text':
77
+ return _zod().z.string();
78
+ }
79
+ }
68
80
 
69
81
  //# sourceMappingURL=createMCPDevToolsExtensionSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/createMCPDevToolsExtensionSchema.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport type { DevToolsPlugin } from './DevToolsPlugin';\n\n/**\n * Creates an MCP-compatible JSON schema for a DevTools plugin's CLI extensions.\n *\n * LLM agents have varying support for complex JSON schema features like `anyOf`/`oneOf`\n * discriminated unions. This implementation uses a flat schema with an enum for the\n * command name, which provides the best compatibility across different LLM providers:\n *\n * - OpenAI: Supports `anyOf` but requires `additionalProperties: false` and all fields `required`\n * - Claude/Anthropic: Works best with simple flat schemas with enums\n * - Other providers: Generally have limited or inconsistent support for discriminated unions\n *\n * To compensate for the lack of discriminated unions, parameter descriptions include\n * which command(s) they belong to, and command descriptions include their parameters.\n *\n * The resulting schema structure is:\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"command\": {\n * \"type\": \"string\",\n * \"enum\": [\"cmd1\", \"cmd2\", ...],\n * \"description\": \"The command to execute. Available commands: \\\"cmd1\\\" - Title 1 (params: foo); ...\"\n * },\n * \"foo\": { \"type\": \"string\", \"description\": \"Foo description (Used by: \\\"cmd1\\\")\" },\n * ...\n * },\n * \"required\": [\"command\"],\n * \"additionalProperties\": false\n * }\n * ```\n */\nexport function createMCPDevToolsExtensionSchema(plugin: DevToolsPlugin) {\n if (plugin.cliExtensions == null || plugin.cliExtensions?.commands.length === 0) {\n throw new Error(\n `Plugin ${plugin.packageName} has no commands defined. Please define at least one command.`\n );\n }\n\n const commands = plugin.cliExtensions.commands;\n\n // Build a rich description that explains each command and its parameters\n const commandDescriptions = commands\n .map((c) => {\n const params = c.parameters?.map((p) => p.name).join(', ');\n return params ? `\"${c.name}\": ${c.title} (params: ${params})` : `\"${c.name}\": ${c.title}`;\n })\n .join('. ');\n\n // Create enum of command names for clear LLM selection\n const commandNames = commands.map((c) => c.name) as [string, ...string[]];\n\n // Collect all unique parameters across all commands\n // Track which commands use each parameter for documentation\n const parameterCommandMap: Record<string, string[]> = {};\n const parameterDescriptions: Record<string, string> = {};\n\n for (const command of commands) {\n if (command.parameters && command.parameters.length > 0) {\n for (const param of command.parameters) {\n let commands = parameterCommandMap[param.name];\n if (!commands) {\n commands = [];\n parameterCommandMap[param.name] = commands;\n parameterDescriptions[param.name] = param.description || '';\n }\n commands.push(command.name);\n }\n }\n }\n\n // Build parameters with descriptions that indicate which command(s) they belong to\n const allParameters: Record<string, z.ZodTypeAny> = {};\n for (const [paramName, commandList] of Object.entries(parameterCommandMap)) {\n const baseDescription = parameterDescriptions[paramName];\n const commandsUsingParam =\n commandList.length === commands.length\n ? 'all commands'\n : commandList.map((c) => `\"${c}\"`).join(', ');\n\n // Include command context in the description so LLMs know when to use each parameter\n const fullDescription = baseDescription\n ? `${baseDescription} (Used by: ${commandsUsingParam})`\n : `Parameter for: ${commandsUsingParam}`;\n\n allParameters[paramName] = z.string().optional().describe(fullDescription);\n }\n\n // Build the command description with clear instructions for the LLM\n const hasParameters = Object.keys(allParameters).length > 0;\n const commandDescription = hasParameters\n ? `Required. The command to execute. You must select exactly one command from the enum values. ` +\n `Each command may require specific parameters - only include parameters that belong to the selected command. ` +\n `Commands: ${commandDescriptions}.`\n : `Required. The command to execute. Select exactly one from the available options. ` +\n `Commands: ${commandDescriptions}.`;\n\n // Build the flat schema with additionalProperties: false for LLM compatibility\n const schema = z\n .object({\n command: z.enum(commandNames).describe(commandDescription),\n ...allParameters,\n })\n .strict(); // .strict() adds additionalProperties: false\n\n return schema;\n}\n"],"names":["createMCPDevToolsExtensionSchema","plugin","cliExtensions","commands","length","Error","packageName","commandDescriptions","map","c","params","parameters","p","name","join","title","commandNames","parameterCommandMap","parameterDescriptions","command","param","description","push","allParameters","paramName","commandList","Object","entries","baseDescription","commandsUsingParam","fullDescription","z","string","optional","describe","hasParameters","keys","commandDescription","schema","object","enum","strict"],"mappings":";;;;+BAoCgBA;;;eAAAA;;;;yBApCE;;;;;;AAoCX,SAASA,iCAAiCC,MAAsB;QACjCA;IAApC,IAAIA,OAAOC,aAAa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F;IACF;IAEA,mFAAmF;IACnF,MAAMU,gBAA8C,CAAC;IACrD,KAAK,MAAM,CAACC,WAAWC,YAAY,IAAIC,OAAOC,OAAO,CAACV,qBAAsB;QAC1E,MAAMW,kBAAkBV,qBAAqB,CAACM,UAAU;QACxD,MAAMK,qBACJJ,YAAYrB,MAAM,KAAKD,SAASC,MAAM,GAClC,iBACAqB,YAAYjB,GAAG,CAAC,CAACC,IAAM,CAAC,CAAC,EAAEA,EAAE,CAAC,CAAC,EAAEK,IAAI,CAAC;QAE5C,qFAAqF;QACrF,MAAMgB,kBAAkBF,kBACpB,GAAGA,gBAAgB,WAAW,EAAEC,mBAAmB,CAAC,CAAC,GACrD,CAAC,eAAe,EAAEA,oBAAoB;QAE1CN,aAAa,CAACC,UAAU,GAAGO,QAAC,CAACC,MAAM,GAAGC,QAAQ,GAAGC,QAAQ,CAACJ;IAC5D;IAEA,oEAAoE;IACpE,MAAMK,gBAAgBT,OAAOU,IAAI,CAACb,eAAenB,MAAM,GAAG;IAC1D,MAAMiC,qBAAqBF,gBACvB,CAAC,4FAA4F,CAAC,GAC9F,CAAC,4GAA4G,CAAC,GAC9G,CAAC,UAAU,EAAE5B,oBAAoB,CAAC,CAAC,GACnC,CAAC,iFAAiF,CAAC,GACnF,CAAC,UAAU,EAAEA,oBAAoB,CAAC,CAAC;IAEvC,+EAA+E;IAC/E,MAAM+B,SAASP,QAAC,CACbQ,MAAM,CAAC;QACNpB,SAASY,QAAC,CAACS,IAAI,CAACxB,cAAckB,QAAQ,CAACG;QACvC,GAAGd,aAAa;IAClB,GACCkB,MAAM,IAAI,6CAA6C;IAE1D,OAAOH;AACT"}
1
+ {"version":3,"sources":["../../../../src/start/server/createMCPDevToolsExtensionSchema.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport type { DevToolsPluginCommandParameter, DevToolsPluginInfo } from './DevToolsPlugin.schema';\n\n/**\n * Creates an MCP-compatible JSON schema for a DevTools plugin's CLI extensions.\n *\n * LLM agents have varying support for complex JSON schema features like `anyOf`/`oneOf`\n * discriminated unions. This implementation uses a flat schema with an enum for the\n * command name, which provides the best compatibility across different LLM providers:\n *\n * - OpenAI: Supports `anyOf` but requires `additionalProperties: false` and all fields `required`\n * - Claude/Anthropic: Works best with simple flat schemas with enums\n * - Other providers: Generally have limited or inconsistent support for discriminated unions\n *\n * To compensate for the lack of discriminated unions, parameter descriptions include\n * which command(s) they belong to, and command descriptions include their parameters.\n *\n * The resulting schema structure is:\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"command\": {\n * \"type\": \"string\",\n * \"enum\": [\"cmd1\", \"cmd2\", ...],\n * \"description\": \"The command to execute. Available commands: \\\"cmd1\\\" - Title 1 (params: foo); ...\"\n * },\n * \"foo\": { \"type\": \"string\", \"description\": \"Foo description (Used by: \\\"cmd1\\\")\" },\n * ...\n * },\n * \"required\": [\"command\"],\n * \"additionalProperties\": false\n * }\n * ```\n */\nexport function createMCPDevToolsExtensionSchema(plugin: DevToolsPluginInfo) {\n if (plugin.cliExtensions == null || plugin.cliExtensions?.commands.length === 0) {\n throw new Error(\n `Plugin ${plugin.packageName} has no commands defined. Please define at least one command.`\n );\n }\n\n const commands = plugin.cliExtensions.commands;\n\n // Build a rich description that explains each command and its parameters\n const commandDescriptions = commands\n .map((c) => {\n const params = c.parameters?.map((p) => p.name).join(', ');\n return params ? `\"${c.name}\": ${c.title} (params: ${params})` : `\"${c.name}\": ${c.title}`;\n })\n .join('. ');\n\n // Create enum of command names for clear LLM selection\n const commandNames = commands.map((c) => c.name) as [string, ...string[]];\n\n // Collect all unique parameters across all commands\n // Track which commands use each parameter for documentation\n const parameterCommandMap: Record<string, string[]> = {};\n const parameterDescriptions: Record<string, string> = {};\n const parameterTypes: Record<string, DevToolsPluginCommandParameter['type']> = {};\n\n for (const command of commands) {\n if (command.parameters && command.parameters.length > 0) {\n for (const param of command.parameters) {\n let commands = parameterCommandMap[param.name];\n if (!commands) {\n commands = [];\n parameterCommandMap[param.name] = commands;\n parameterDescriptions[param.name] = param.description || '';\n parameterTypes[param.name] = param.type;\n }\n commands.push(command.name);\n }\n }\n }\n\n // Build parameters with descriptions that indicate which command(s) they belong to\n const allParameters: Record<string, z.ZodTypeAny> = {};\n for (const [paramName, commandList] of Object.entries(parameterCommandMap)) {\n const baseDescription = parameterDescriptions[paramName];\n const commandsUsingParam =\n commandList.length === commands.length\n ? 'all commands'\n : commandList.map((c) => `\"${c}\"`).join(', ');\n\n // Include command context in the description so LLMs know when to use each parameter\n const fullDescription = baseDescription\n ? `${baseDescription} (Used by: ${commandsUsingParam})`\n : `Parameter for: ${commandsUsingParam}`;\n\n allParameters[paramName] = paramTypeToZod(parameterTypes[paramName]!)\n .optional()\n .describe(fullDescription);\n }\n\n // Build the command description with clear instructions for the LLM\n const hasParameters = Object.keys(allParameters).length > 0;\n const commandDescription = hasParameters\n ? `Required. The command to execute. You must select exactly one command from the enum values. ` +\n `Each command may require specific parameters - only include parameters that belong to the selected command. ` +\n `Commands: ${commandDescriptions}.`\n : `Required. The command to execute. Select exactly one from the available options. ` +\n `Commands: ${commandDescriptions}.`;\n\n // Build the flat schema with additionalProperties: false for LLM compatibility\n const schema = z\n .object({\n command: z.enum(commandNames).describe(commandDescription),\n ...allParameters,\n })\n .strict(); // .strict() adds additionalProperties: false\n\n return schema;\n}\n\nfunction paramTypeToZod(type: DevToolsPluginCommandParameter['type']) {\n switch (type) {\n case 'number':\n return z.number();\n case 'confirm':\n return z.boolean();\n case 'text':\n return z.string();\n }\n}\n"],"names":["createMCPDevToolsExtensionSchema","plugin","cliExtensions","commands","length","Error","packageName","commandDescriptions","map","c","params","parameters","p","name","join","title","commandNames","parameterCommandMap","parameterDescriptions","parameterTypes","command","param","description","type","push","allParameters","paramName","commandList","Object","entries","baseDescription","commandsUsingParam","fullDescription","paramTypeToZod","optional","describe","hasParameters","keys","commandDescription","schema","z","object","enum","strict","number","boolean","string"],"mappings":";;;;+BAoCgBA;;;eAAAA;;;;yBApCE;;;;;;AAo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OAAOiB,QAAC,CAACI,MAAM;QACjB,KAAK;YACH,OAAOJ,QAAC,CAACK,OAAO;QAClB,KAAK;YACH,OAAOL,QAAC,CAACM,MAAM;IACnB;AACF"}
@@ -107,6 +107,8 @@ const _errors = require("../../../utils/errors");
107
107
  const _filePath = require("../../../utils/filePath");
108
108
  const _nodeEnv = require("../../../utils/nodeEnv");
109
109
  const _port = require("../../../utils/port");
110
+ const _AndroidAppIdResolver = require("../../platforms/android/AndroidAppIdResolver");
111
+ const _AppleAppIdResolver = require("../../platforms/ios/AppleAppIdResolver");
110
112
  const _BundlerDevServer = require("../BundlerDevServer");
111
113
  const _getStaticRenderFunctions = require("../getStaticRenderFunctions");
112
114
  const _resolveLoader = require("./resolveLoader");
@@ -117,10 +119,12 @@ const _DomComponentsMiddleware = require("../middleware/DomComponentsMiddleware"
117
119
  const _FaviconMiddleware = require("../middleware/FaviconMiddleware");
118
120
  const _HistoryFallbackMiddleware = require("../middleware/HistoryFallbackMiddleware");
119
121
  const _InterstitialPageMiddleware = require("../middleware/InterstitialPageMiddleware");
122
+ const _OpenMiddleware = require("../middleware/OpenMiddleware");
120
123
  const _RuntimeRedirectMiddleware = require("../middleware/RuntimeRedirectMiddleware");
121
124
  const _ServeStaticMiddleware = require("../middleware/ServeStaticMiddleware");
122
125
  const _metroOptions = require("../middleware/metroOptions");
123
126
  const _mutations = require("../middleware/mutations");
127
+ const _openHandlers = require("../middleware/openHandlers");
124
128
  const _startTypescriptTypeGeneration = require("../type-generation/startTypescriptTypeGeneration");
125
129
  function _interop_require_default(obj) {
126
130
  return obj && obj.__esModule ? obj : {
@@ -959,6 +963,46 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
959
963
  }
960
964
  });
961
965
  middleware.use(deepLinkMiddleware.getHandler());
966
+ const getHostSupport = (platform)=>{
967
+ if (platform === 'ios' && process.platform !== 'darwin') {
968
+ return {
969
+ canOpen: false,
970
+ reason: `iOS simulators require macOS with Xcode installed; this dev server is running on ${process.platform}.`
971
+ };
972
+ }
973
+ return {
974
+ canOpen: true
975
+ };
976
+ };
977
+ // Read all dev-server state live — pressing `s` in the terminal toggles `isDevClient`
978
+ // and the scheme, and `expo-dev-client` can be installed mid-run (re-resolved by
979
+ // isRedirectPageEnabled on every call).
980
+ const openMiddleware = new _OpenMiddleware.OpenMiddleware(this.projectRoot, {
981
+ serverBaseUrl,
982
+ getHostSupport,
983
+ getInfo: (0, _openHandlers.createInfoHandler)({
984
+ urlCreator: this.getUrlCreator(),
985
+ getIsDevClient: ()=>this.isDevClient,
986
+ getIsRedirectPageEnabled: ()=>this.isRedirectPageEnabled(),
987
+ getAppId: async (platform)=>{
988
+ if (platform === 'web') return null;
989
+ const resolver = platform === 'ios' ? new _AppleAppIdResolver.AppleAppIdResolver(this.projectRoot) : new _AndroidAppIdResolver.AndroidAppIdResolver(this.projectRoot);
990
+ try {
991
+ return await resolver.getAppIdAsync();
992
+ } catch {
993
+ // Surfacing the error would block the dry-run; consumers can detect the missing id
994
+ // from `appId: null` and prompt the user to configure ios.bundleIdentifier /
995
+ // android.package.
996
+ return null;
997
+ }
998
+ }
999
+ }),
1000
+ open: (0, _openHandlers.createOpen)({
1001
+ getIsDevClient: ()=>this.isDevClient,
1002
+ openPlatformAsync: (target, resolver)=>this.openPlatformAsync(target, resolver)
1003
+ })
1004
+ });
1005
+ middleware.use(openMiddleware.getHandler());
962
1006
  const domComponentRenderer = (0, _DomComponentsMiddleware.createDomComponentsMiddleware)({
963
1007
  projectRoot: this.projectRoot
964
1008
  }, instanceMetroOptions);