@expo/cli 57.0.31 → 57.0.33

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 (75) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/events/index.js +1 -1
  3. package/build/src/export/compileHermesArtifacts.js +28 -0
  4. package/build/src/export/compileHermesArtifacts.js.map +1 -0
  5. package/build/src/export/embed/exportEmbedAsync.js +4 -0
  6. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  7. package/build/src/export/exportApp.js +9 -5
  8. package/build/src/export/exportApp.js.map +1 -1
  9. package/build/src/export/exportDomComponents.js +5 -11
  10. package/build/src/export/exportDomComponents.js.map +1 -1
  11. package/build/src/prebuild/prebuildAsync.js +3 -2
  12. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  13. package/build/src/run/ensureNativeProject.js +3 -2
  14. package/build/src/run/ensureNativeProject.js.map +1 -1
  15. package/build/src/run/ios/appleDevice/ClientManager.js +11 -6
  16. package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
  17. package/build/src/run/ios/runIosAsync.js +12 -4
  18. package/build/src/run/ios/runIosAsync.js.map +1 -1
  19. package/build/src/start/interface/cliExtensionMenuItemHandler.js.map +1 -1
  20. package/build/src/start/interface/commandsTable.js.map +1 -1
  21. package/build/src/start/interface/createDevToolsMenuItems.js.map +1 -1
  22. package/build/src/start/interface/interactiveActions.js.map +1 -1
  23. package/build/src/start/platforms/ios/devicectl.js +2 -5
  24. package/build/src/start/platforms/ios/devicectl.js.map +1 -1
  25. package/build/src/start/server/BundlerDevServer.js +6 -9
  26. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  27. package/build/src/start/server/DevServerManager.js +1 -1
  28. package/build/src/start/server/DevServerManager.js.map +1 -1
  29. package/build/src/start/server/UrlCreator.js +10 -4
  30. package/build/src/start/server/UrlCreator.js.map +1 -1
  31. package/build/src/start/server/{DevToolsPlugin.js → devtools/DevToolsPlugin.js} +14 -5
  32. package/build/src/start/server/devtools/DevToolsPlugin.js.map +1 -0
  33. package/build/src/start/server/devtools/DevToolsPlugin.schema.js +195 -0
  34. package/build/src/start/server/devtools/DevToolsPlugin.schema.js.map +1 -0
  35. package/build/src/start/server/{DevToolsPluginCliExtensionExecutor.js → devtools/DevToolsPluginCliExtensionExecutor.js} +1 -1
  36. package/build/src/start/server/devtools/DevToolsPluginCliExtensionExecutor.js.map +1 -0
  37. package/build/src/start/server/{DevToolsPluginCliExtensionResults.js → devtools/DevToolsPluginCliExtensionResults.js} +24 -12
  38. package/build/src/start/server/devtools/DevToolsPluginCliExtensionResults.js.map +1 -0
  39. package/build/src/start/server/{DevToolsPluginManager.js → devtools/DevToolsPluginManager.js} +2 -2
  40. package/build/src/start/server/devtools/DevToolsPluginManager.js.map +1 -0
  41. package/build/src/start/server/devtools/DevToolsPluginServerHelpers.js.map +1 -0
  42. package/build/src/start/server/{MCP.js → mcp/MCP.js} +25 -15
  43. package/build/src/start/server/mcp/MCP.js.map +1 -0
  44. package/build/src/start/server/{MCPDevToolsPluginCLIExtensions.js → mcp/MCPDevToolsPluginCLIExtensions.js} +14 -27
  45. package/build/src/start/server/mcp/MCPDevToolsPluginCLIExtensions.js.map +1 -0
  46. package/build/src/start/server/{createMCPDevToolsExtensionSchema.js → mcp/createMCPDevToolsExtensionSchema.js} +8 -15
  47. package/build/src/start/server/mcp/createMCPDevToolsExtensionSchema.js.map +1 -0
  48. package/build/src/start/server/metro/MetroBundlerDevServer.js +2 -4
  49. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  50. package/build/src/start/server/metro/instantiateMetro.js +6 -2
  51. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  52. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +1 -1
  53. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -1
  54. package/build/src/start/server/middleware/metroOptions.js +4 -1
  55. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  56. package/build/src/start/server/middleware/openHandlers.js +2 -6
  57. package/build/src/start/server/middleware/openHandlers.js.map +1 -1
  58. package/build/src/start/startAsync.js +2 -4
  59. package/build/src/start/startAsync.js.map +1 -1
  60. package/build/src/utils/open.js +47 -31
  61. package/build/src/utils/open.js.map +1 -1
  62. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  63. package/build/src/utils/telemetry/utils/context.js +1 -1
  64. package/package.json +25 -21
  65. package/build/src/start/server/DevToolsPlugin.js.map +0 -1
  66. package/build/src/start/server/DevToolsPlugin.schema.js +0 -84
  67. package/build/src/start/server/DevToolsPlugin.schema.js.map +0 -1
  68. package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +0 -1
  69. package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +0 -1
  70. package/build/src/start/server/DevToolsPluginManager.js.map +0 -1
  71. package/build/src/start/server/DevToolsPluginServerHelpers.js.map +0 -1
  72. package/build/src/start/server/MCP.js.map +0 -1
  73. package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js.map +0 -1
  74. package/build/src/start/server/createMCPDevToolsExtensionSchema.js.map +0 -1
  75. /package/build/src/start/server/{DevToolsPluginServerHelpers.js → devtools/DevToolsPluginServerHelpers.js} +0 -0
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get DevToolsPluginOutputSchema () {
13
+ return DevToolsPluginOutputSchema;
14
+ },
15
+ get PluginSchema () {
16
+ return PluginSchema;
17
+ }
18
+ });
19
+ const CommandParameterSchema = {
20
+ type: 'object',
21
+ required: [
22
+ 'name',
23
+ 'type'
24
+ ],
25
+ properties: {
26
+ name: {
27
+ type: 'string',
28
+ minLength: 1
29
+ },
30
+ type: {
31
+ enum: [
32
+ 'text',
33
+ 'number',
34
+ 'confirm'
35
+ ]
36
+ },
37
+ description: {
38
+ type: 'string'
39
+ }
40
+ }
41
+ };
42
+ const CommandSchema = {
43
+ type: 'object',
44
+ required: [
45
+ 'name',
46
+ 'title',
47
+ 'environments'
48
+ ],
49
+ properties: {
50
+ name: {
51
+ type: 'string',
52
+ minLength: 1
53
+ },
54
+ title: {
55
+ type: 'string',
56
+ minLength: 1
57
+ },
58
+ environments: {
59
+ type: 'array',
60
+ items: {
61
+ enum: [
62
+ 'cli',
63
+ 'mcp'
64
+ ]
65
+ }
66
+ },
67
+ parameters: {
68
+ type: 'array',
69
+ items: CommandParameterSchema
70
+ }
71
+ }
72
+ };
73
+ const CliExtensionsSchema = {
74
+ type: 'object',
75
+ required: [
76
+ 'description',
77
+ 'commands',
78
+ 'entryPoint'
79
+ ],
80
+ properties: {
81
+ description: {
82
+ type: 'string'
83
+ },
84
+ commands: {
85
+ type: 'array',
86
+ items: CommandSchema,
87
+ minItems: 1
88
+ },
89
+ entryPoint: {
90
+ type: 'string',
91
+ minLength: 1
92
+ }
93
+ }
94
+ };
95
+ const PluginSchema = {
96
+ type: 'object',
97
+ required: [
98
+ 'packageName',
99
+ 'packageRoot'
100
+ ],
101
+ properties: {
102
+ packageName: {
103
+ type: 'string',
104
+ minLength: 1
105
+ },
106
+ packageRoot: {
107
+ type: 'string',
108
+ minLength: 1
109
+ },
110
+ webpageRoot: {
111
+ type: 'string'
112
+ },
113
+ bannerTitle: {
114
+ type: [
115
+ 'boolean',
116
+ 'string'
117
+ ],
118
+ minLength: 1
119
+ },
120
+ serverEntryPoint: {
121
+ type: 'string'
122
+ },
123
+ cliExtensions: CliExtensionsSchema
124
+ }
125
+ };
126
+ const DevToolsPluginOutputSchema = {
127
+ type: 'array',
128
+ items: {
129
+ type: 'object',
130
+ allOf: [
131
+ {
132
+ required: [
133
+ 'type'
134
+ ],
135
+ properties: {
136
+ type: {
137
+ enum: [
138
+ 'text',
139
+ 'audio',
140
+ 'image'
141
+ ]
142
+ }
143
+ }
144
+ },
145
+ {
146
+ if: {
147
+ properties: {
148
+ type: {
149
+ enum: [
150
+ 'text'
151
+ ]
152
+ }
153
+ }
154
+ },
155
+ then: {
156
+ required: [
157
+ 'text',
158
+ 'level'
159
+ ],
160
+ properties: {
161
+ text: {
162
+ type: 'string'
163
+ },
164
+ url: {
165
+ type: 'string'
166
+ },
167
+ level: {
168
+ enum: [
169
+ 'info',
170
+ 'warning',
171
+ 'error'
172
+ ]
173
+ }
174
+ }
175
+ },
176
+ else: {
177
+ required: [
178
+ 'url'
179
+ ],
180
+ properties: {
181
+ url: {
182
+ type: 'string',
183
+ format: 'url'
184
+ },
185
+ text: {
186
+ type: 'string'
187
+ }
188
+ }
189
+ }
190
+ }
191
+ ]
192
+ }
193
+ };
194
+
195
+ //# sourceMappingURL=DevToolsPlugin.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/devtools/DevToolsPlugin.schema.ts"],"sourcesContent":["import type { JSONSchema } from '@expo/schema-utils';\n\nexport type DevToolsPluginCommandParameter = {\n name: string;\n type: 'text' | 'number' | 'confirm';\n description?: string;\n};\n\nconst CommandParameterSchema: JSONSchema<DevToolsPluginCommandParameter> = {\n type: 'object',\n required: ['name', 'type'],\n properties: {\n name: { type: 'string', minLength: 1 },\n type: { enum: ['text', 'number', 'confirm'] },\n description: { type: 'string' },\n },\n};\n\nexport type DevToolsPluginCommand = {\n name: string;\n title: string;\n environments: readonly ('cli' | 'mcp')[];\n parameters?: DevToolsPluginCommandParameter[];\n};\n\nconst CommandSchema: JSONSchema<DevToolsPluginCommand> = {\n type: 'object',\n required: ['name', 'title', 'environments'],\n properties: {\n name: { type: 'string', minLength: 1 },\n title: { type: 'string', minLength: 1 },\n environments: { type: 'array', items: { enum: ['cli', 'mcp'] } },\n parameters: { type: 'array', items: CommandParameterSchema },\n },\n};\n\nexport type DevToolsPluginCliExtensions = {\n description: string;\n commands: DevToolsPluginCommand[];\n entryPoint: string;\n};\n\nconst CliExtensionsSchema: JSONSchema<DevToolsPluginCliExtensions> = {\n type: 'object',\n required: ['description', 'commands', 'entryPoint'],\n properties: {\n description: { type: 'string' },\n commands: { type: 'array', items: CommandSchema, minItems: 1 },\n entryPoint: { type: 'string', minLength: 1 },\n },\n};\n\nexport type DevToolsPluginInfo = {\n packageName: string;\n packageRoot: string;\n webpageRoot?: string;\n bannerTitle?: boolean | string;\n serverEntryPoint?: string;\n cliExtensions?: DevToolsPluginCliExtensions;\n};\n\nexport const PluginSchema: JSONSchema<DevToolsPluginInfo> = {\n type: 'object',\n required: ['packageName', 'packageRoot'],\n properties: {\n packageName: { type: 'string', minLength: 1 },\n packageRoot: { type: 'string', minLength: 1 },\n webpageRoot: { type: 'string' },\n bannerTitle: { type: ['boolean', 'string'], minLength: 1 },\n serverEntryPoint: { type: 'string' },\n cliExtensions: CliExtensionsSchema,\n },\n};\n\nexport type DevToolsPluginOutput = (\n | { type: 'text'; text: string; url?: string; level: 'info' | 'warning' | 'error' }\n | { type: 'audio'; url: string; text?: string }\n | { type: 'image'; url: string; text?: string }\n)[];\n\nexport const DevToolsPluginOutputSchema: JSONSchema<DevToolsPluginOutput> = {\n type: 'array',\n items: {\n type: 'object',\n allOf: [\n {\n required: ['type'],\n properties: { type: { enum: ['text', 'audio', 'image'] } },\n },\n {\n if: { properties: { type: { enum: ['text'] } } },\n then: {\n required: ['text', 'level'],\n properties: {\n text: { type: 'string' },\n url: { type: 'string' },\n level: { enum: ['info', 'warning', 'error'] },\n },\n },\n else: {\n required: ['url'],\n properties: {\n url: { type: 'string', format: 'url' },\n text: { type: 'string' },\n },\n },\n },\n ],\n },\n};\n\nexport type DevToolsPluginExecutorArguments = {\n command: string;\n metroServerOrigin: string;\n args?: Record<string, string | number | boolean> | undefined;\n onOutput?: (output: DevToolsPluginOutput) => void;\n};\n"],"names":["DevToolsPluginOutputSchema","PluginSchema","CommandParameterSchema","type","required","properties","name","minLength","enum","description","CommandSchema","title","environments","items","parameters","CliExtensionsSchema","commands","minItems","entryPoint","packageName","packageRoot","webpageRoot","bannerTitle","serverEntryPoint","cliExtensions","allOf","if","then","text","url","level","else","format"],"mappings":";;;;;;;;;;;QAgFaA;eAAAA;;QAnBAC;eAAAA;;;AArDb,MAAMC,yBAAqE;IACzEC,MAAM;IACNC,UAAU;QAAC;QAAQ;KAAO;IAC1BC,YAAY;QACVC,MAAM;YAAEH,MAAM;YAAUI,WAAW;QAAE;QACrCJ,MAAM;YAAEK,MAAM;gBAAC;gBAAQ;gBAAU;aAAU;QAAC;QAC5CC,aAAa;YAAEN,MAAM;QAAS;IAChC;AACF;AASA,MAAMO,gBAAmD;IACvDP,MAAM;IACNC,UAAU;QAAC;QAAQ;QAAS;KAAe;IAC3CC,YAAY;QACVC,MAAM;YAAEH,MAAM;YAAUI,WAAW;QAAE;QACrCI,OAAO;YAAER,MAAM;YAAUI,WAAW;QAAE;QACtCK,cAAc;YAAET,MAAM;YAASU,OAAO;gBAAEL,MAAM;oBAAC;oBAAO;iBAAM;YAAC;QAAE;QAC/DM,YAAY;YAAEX,MAAM;YAASU,OAAOX;QAAuB;IAC7D;AACF;AAQA,MAAMa,sBAA+D;IACnEZ,MAAM;IACNC,UAAU;QAAC;QAAe;QAAY;KAAa;IACnDC,YAAY;QACVI,aAAa;YAAEN,MAAM;QAAS;QAC9Ba,UAAU;YAAEb,MAAM;YAASU,OAAOH;YAAeO,UAAU;QAAE;QAC7DC,YAAY;YAAEf,MAAM;YAAUI,WAAW;QAAE;IAC7C;AACF;AAWO,MAAMN,eAA+C;IAC1DE,MAAM;IACNC,UAAU;QAAC;QAAe;KAAc;IACxCC,YAAY;QACVc,aAAa;YAAEhB,MAAM;YAAUI,WAAW;QAAE;QAC5Ca,aAAa;YAAEjB,MAAM;YAAUI,WAAW;QAAE;QAC5Cc,aAAa;YAAElB,MAAM;QAAS;QAC9BmB,aAAa;YAAEnB,MAAM;gBAAC;gBAAW;aAAS;YAAEI,WAAW;QAAE;QACzDgB,kBAAkB;YAAEpB,MAAM;QAAS;QACnCqB,eAAeT;IACjB;AACF;AAQO,MAAMf,6BAA+D;IAC1EG,MAAM;IACNU,OAAO;QACLV,MAAM;QACNsB,OAAO;YACL;gBACErB,UAAU;oBAAC;iBAAO;gBAClBC,YAAY;oBAAEF,MAAM;wBAAEK,MAAM;4BAAC;4BAAQ;4BAAS;yBAAQ;oBAAC;gBAAE;YAC3D;YACA;gBACEkB,IAAI;oBAAErB,YAAY;wBAAEF,MAAM;4BAAEK,MAAM;gCAAC;6BAAO;wBAAC;oBAAE;gBAAE;gBAC/CmB,MAAM;oBACJvB,UAAU;wBAAC;wBAAQ;qBAAQ;oBAC3BC,YAAY;wBACVuB,MAAM;4BAAEzB,MAAM;wBAAS;wBACvB0B,KAAK;4BAAE1B,MAAM;wBAAS;wBACtB2B,OAAO;4BAAEtB,MAAM;gCAAC;gCAAQ;gCAAW;6BAAQ;wBAAC;oBAC9C;gBACF;gBACAuB,MAAM;oBACJ3B,UAAU;wBAAC;qBAAM;oBACjBC,YAAY;wBACVwB,KAAK;4BAAE1B,MAAM;4BAAU6B,QAAQ;wBAAM;wBACrCJ,MAAM;4BAAEzB,MAAM;wBAAS;oBACzB;gBACF;YACF;SACD;IACH;AACF"}
@@ -23,7 +23,7 @@ function _path() {
23
23
  return data;
24
24
  }
25
25
  const _DevToolsPluginCliExtensionResults = require("./DevToolsPluginCliExtensionResults");
26
- const _dir = require("../../utils/dir");
26
+ const _dir = require("../../../utils/dir");
27
27
  function _interop_require_default(obj) {
28
28
  return obj && obj.__esModule ? obj : {
29
29
  default: obj
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/devtools/DevToolsPluginCliExtensionExecutor.ts"],"sourcesContent":["import { spawn, type ChildProcessWithoutNullStreams } from 'child_process';\nimport path from 'path';\n\nimport type {\n DevToolsPluginExecutorArguments,\n DevToolsPluginInfo,\n DevToolsPluginOutput,\n} from './DevToolsPlugin.schema';\nimport { DevToolsPluginCliExtensionResults } from './DevToolsPluginCliExtensionResults';\nimport { isPathInside } from '../../../utils/dir';\n\nconst DEFAULT_TIMEOUT_MS = 10_000; // 10 seconds\n\n/**\n * Class that executes CLI Extension commands for a given plugin\n *\n * ## Responsibilities:\n * - Verifies that requested commands exist and have correct parameters\n * - Validates that provided arguments match expected parameter schema\n * - Spawns and manages child processes for command execution\n * - Captures and streams stdout/stderr data from executed commands\n * - Manages process errors, timeouts, and unexpected failures\n * - Enforces execution time limits to prevent hanging processes\n * - Configures proper execution environment with color support\n * - Ensures proper cleanup of processes and timeouts\n * - Provides structured output with exit codes and error states\n */\nexport class DevToolsPluginCliExtensionExecutor {\n private readonly resolvedEntryPoint: string;\n\n constructor(\n private plugin: DevToolsPluginInfo,\n private projectRoot: string,\n private spawnFunc: typeof spawn = spawn, // Used for injection when testing,\n private timeoutMs = DEFAULT_TIMEOUT_MS // Timeout for command execution\n ) {\n // Validate that this is a plugin with cli extensions\n if (!this.plugin.cliExtensions?.entryPoint) {\n throw new Error(`Plugin ${this.plugin.packageName} has no CLI extensions`);\n }\n // Reject entryPoints that escape packageRoot (e.g. \"../../other-pkg/dist/cli.js\").\n const resolved = path.resolve(this.plugin.packageRoot, this.plugin.cliExtensions.entryPoint);\n if (!isPathInside(resolved, this.plugin.packageRoot)) {\n throw new Error(\n `Plugin ${this.plugin.packageName} entryPoint \"${this.plugin.cliExtensions.entryPoint}\" ` +\n `escapes packageRoot (${this.plugin.packageRoot}); must be a relative path inside the package.`\n );\n }\n this.resolvedEntryPoint = resolved;\n }\n\n public validate({ command, args }: Omit<DevToolsPluginExecutorArguments, 'metroServerOrigin'>) {\n const commandElement = this.plugin.cliExtensions?.commands.find((c) => c.name === command);\n if (!commandElement) {\n throw new Error(`Command \"${command}\" not found in plugin ${this.plugin.packageName}`);\n }\n\n const paramLength = commandElement.parameters?.length ?? 0;\n const argsLength = Object.keys(args ?? {}).length;\n if (paramLength !== argsLength) {\n // Quick check to see if the lengths match\n throw new Error(\n `Expected ${paramLength} parameter(s), but got ${argsLength} argument(s) for the command \"${command}\".`\n );\n }\n\n const argsObj = (args ?? {}) as Record<string, unknown>;\n for (const param of commandElement.parameters ?? []) {\n if (!Object.prototype.hasOwnProperty.call(argsObj, param.name)) {\n throw new Error(\n `Parameter \"${param.name}\" not found in command \"${command}\" of plugin ${this.plugin.packageName}`\n );\n }\n // Enforce declared parameter type; don't rely on upstream Zod validation alone.\n const expected =\n param.type === 'confirm' ? 'boolean' : param.type === 'number' ? 'number' : 'string';\n const actual = typeof argsObj[param.name];\n if (actual !== expected) {\n throw new Error(\n `Parameter \"${param.name}\" of \"${command}\" expected ${expected} (declared \"${param.type}\"), got ${actual}.`\n );\n }\n }\n }\n\n /** this function is used for testing and showing the command in UI */\n public getCommandString = ({\n command,\n args,\n }: Omit<DevToolsPluginExecutorArguments, 'metroServerOrigin'>) => {\n return `node ${this.plugin.cliExtensions!.entryPoint} ${command}${Object.keys(args ?? {}).length > 0 ? ' ' + JSON.stringify(args) : ''}`;\n };\n\n public execute = async ({\n command,\n args,\n metroServerOrigin,\n onOutput,\n }: DevToolsPluginExecutorArguments): Promise<DevToolsPluginOutput> => {\n this.validate({ command, args });\n return new Promise<DevToolsPluginOutput>((resolve) => {\n let finished = false;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n const pluginResults = new DevToolsPluginCliExtensionResults(onOutput);\n\n // process.execPath instead of 'node' so the child can't be redirected by a PATH shim.\n let child: ChildProcessWithoutNullStreams;\n try {\n child = this.spawnFunc(\n process.execPath,\n [this.resolvedEntryPoint, command, `${JSON.stringify(args)}`, `${metroServerOrigin}`],\n {\n cwd: this.projectRoot,\n env: { ...process.env },\n }\n );\n } catch (err: any) {\n // spawn can throw synchronously; resolve with an error result instead of hanging.\n pluginResults.append(err?.toString?.() ?? String(err), 'error');\n resolve(pluginResults.getOutput());\n return;\n }\n\n const finishOnTruncation = () => {\n if (pluginResults.isTruncated() && !finished) {\n finished = true;\n if (timeout) clearTimeout(timeout);\n child.kill('SIGKILL');\n resolve(pluginResults.getOutput());\n }\n };\n\n // Collect output/error data\n child.stdout.on('data', (data) => {\n pluginResults.append(data.toString());\n finishOnTruncation();\n });\n child.stderr.on('data', (data) => {\n pluginResults.append(data.toString(), 'error');\n finishOnTruncation();\n });\n\n // Setup timeout\n timeout = setTimeout(() => {\n if (!finished) {\n finished = true;\n child.kill('SIGKILL');\n pluginResults.append('Command timed out', 'error');\n resolve(pluginResults.getOutput());\n }\n }, this.timeoutMs);\n\n child.on('close', (code: number) => {\n if (finished) return;\n if (timeout) clearTimeout(timeout);\n finished = true;\n pluginResults.exit(code);\n resolve(pluginResults.getOutput());\n });\n\n child.on('error', (err: Error) => {\n if (finished) return;\n if (timeout) clearTimeout(timeout);\n finished = true;\n pluginResults.append(err.toString(), 'error');\n resolve(pluginResults.getOutput());\n });\n });\n };\n}\n"],"names":["DevToolsPluginCliExtensionExecutor","DEFAULT_TIMEOUT_MS","plugin","projectRoot","spawnFunc","spawn","timeoutMs","getCommandString","command","args","cliExtensions","entryPoint","Object","keys","length","JSON","stringify","execute","metroServerOrigin","onOutput","validate","Promise","resolve","finished","timeout","pluginResults","DevToolsPluginCliExtensionResults","child","process","execPath","resolvedEntryPoint","cwd","env","err","append","toString","String","getOutput","finishOnTruncation","isTruncated","clearTimeout","kill","stdout","on","data","stderr","setTimeout","code","exit","Error","packageName","resolved","path","packageRoot","isPathInside","commandElement","commands","find","c","name","paramLength","parameters","argsLength","argsObj","param","prototype","hasOwnProperty","call","expected","type","actual"],"mappings":";;;;+BA2BaA;;;eAAAA;;;;yBA3B8C;;;;;;;gEAC1C;;;;;;mDAOiC;qBACrB;;;;;;AAE7B,MAAMC,qBAAqB,OAAQ,aAAa;AAgBzC,MAAMD;IAGX,YACE,AAAQE,MAA0B,EAClC,AAAQC,WAAmB,EAC3B,AAAQC,YAA0BC,sBAAK,EACvC,AAAQC,YAAYL,mBAAmB,gCAAgC;IAAjC,CACtC;YAEK;aANGC,SAAAA;aACAC,cAAAA;aACAC,YAA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AC,wBAAwB,EAAEnD,QAAQ,YAAY,EAAE,IAAI,CAACN,MAAM,CAACgD,WAAW,EAAE;YAEtG;YACA,gFAAgF;YAChF,MAAMkB,WACJJ,MAAMK,IAAI,KAAK,YAAY,YAAYL,MAAMK,IAAI,KAAK,WAAW,WAAW;YAC9E,MAAMC,SAAS,OAAOP,OAAO,CAACC,MAAML,IAAI,CAAC;YACzC,IAAIW,WAAWF,UAAU;gBACvB,MAAM,IAAInB,MACR,CAAC,WAAW,EAAEe,MAAML,IAAI,CAAC,MAAM,EAAEnD,QAAQ,WAAW,EAAE4D,SAAS,YAAY,EAAEJ,MAAMK,IAAI,CAAC,QAAQ,EAAEC,OAAO,CAAC,CAAC;YAE/G;QACF;IACF;AAsFF"}
@@ -8,6 +8,13 @@ Object.defineProperty(exports, "DevToolsPluginCliExtensionResults", {
8
8
  return DevToolsPluginCliExtensionResults;
9
9
  }
10
10
  });
11
+ function _schemautils() {
12
+ const data = require("@expo/schema-utils");
13
+ _schemautils = function() {
14
+ return data;
15
+ };
16
+ return data;
17
+ }
11
18
  function _nodebuffer() {
12
19
  const data = require("node:buffer");
13
20
  _nodebuffer = function() {
@@ -56,19 +63,9 @@ class DevToolsPluginCliExtensionResults {
56
63
  return this._output;
57
64
  }
58
65
  parseOutputText(txt, level = 'info') {
59
- // Validate against schema
66
+ let output;
60
67
  try {
61
- const result = _DevToolsPluginschema.DevToolsPluginOutputSchema.safeParse(JSON.parse(txt));
62
- if (!result.success) {
63
- return [
64
- {
65
- type: 'text',
66
- text: `Invalid JSON: ${result.error.issues.map((issue)=>issue.message).join(', ')}`,
67
- level: 'error'
68
- }
69
- ];
70
- }
71
- return result.data;
68
+ output = JSON.parse(txt);
72
69
  } catch {
73
70
  // Not JSON, treat as plain text
74
71
  const lines = txt.split('\n');
@@ -84,6 +81,21 @@ class DevToolsPluginCliExtensionResults {
84
81
  }
85
82
  return results;
86
83
  }
84
+ try {
85
+ (0, _schemautils().validate)(_DevToolsPluginschema.DevToolsPluginOutputSchema, output);
86
+ return output;
87
+ } catch (error) {
88
+ if (!(error instanceof _schemautils().ValidationError)) throw error;
89
+ // Conditional schemas include a parent error; report the failing field.
90
+ const issue = error.errors[error.errors.length - 1];
91
+ return [
92
+ {
93
+ type: 'text',
94
+ text: `Invalid JSON: ${issue.path || 'output'}: ${issue.message}`,
95
+ level: 'error'
96
+ }
97
+ ];
98
+ }
87
99
  }
88
100
  }
89
101
 
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/devtools/DevToolsPluginCliExtensionResults.ts"],"sourcesContent":["import { validate, ValidationError } from '@expo/schema-utils';\nimport { 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 let output: unknown;\n try {\n output = JSON.parse(txt);\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 try {\n validate(DevToolsPluginOutputSchema, output);\n return output;\n } catch (error) {\n if (!(error instanceof ValidationError)) throw error;\n // Conditional schemas include a parent error; report the failing field.\n const issue = error.errors[error.errors.length - 1]!;\n return [\n {\n type: 'text',\n text: `Invalid JSON: ${issue.path || 'output'}: ${issue.message}`,\n level: 'error',\n },\n ];\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","JSON","parse","lines","split","line","validate","DevToolsPluginOutputSchema","error","ValidationError","issue","errors","path"],"mappings":";;;;+BAmBaA;;;eAAAA;;;;yBAnB6B;;;;;;;yBACG;;;;;;sCAGF;AAE3C,gFAAgF;AAChF,MAAMC,oBAAoBC,uBAAe,CAACC,iBAAiB;AAYpD,MAAMH;IACX,YAAY,AAAQI,QAAiD,CAAE;aAAnDA,WAAAA;aAEZC,UAAgC,EAAE;aAClCC,eAAe;aACfC,aAAa;IAJmD;IAMjEC,OAAOC,MAAc,EAAEC,QAAsC,MAAM,EAAE;QAC1E,IAAI,IAAI,CAACH,UAAU,EAAE;QACrB,IAAI,IAAI,CAACD,YAAY,GAAGG,OAAOE,MAAM,GAAGV,mBAAmB;YACzD,IAAI,CAACM,UAAU,GAAG;YAClB,MAAMK,UAAU;gBACdC,MAAM;gBACNC,MAAM,CAAC,0DAA0D,E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ACnD,OAAO;gBACL;oBACEE,MAAM;oBACNC,MAAM,CAAC,cAAc,EAAEkB,MAAME,IAAI,IAAI,SAAS,EAAE,EAAEF,MAAMpB,OAAO,EAAE;oBACjEF,OAAO;gBACT;aACD;QACH;IACF;AACF"}
@@ -20,8 +20,8 @@ _export(exports, {
20
20
  }
21
21
  });
22
22
  const _DevToolsPlugin = require("./DevToolsPlugin");
23
- const _events = require("../../events");
24
- const _log = require("../../log");
23
+ const _events = require("../../../events");
24
+ const _log = require("../../../log");
25
25
  const debug = require('debug')('expo:start:server:devtools');
26
26
  const DevToolsPluginEndpoint = '/_expo/plugins';
27
27
  const event = (0, _events.events)('expo', (t)=>[
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/devtools/DevToolsPluginManager.ts"],"sourcesContent":["import type { ModuleDescriptorDevTools } from 'expo-modules-autolinking/exports';\n\nimport { DevToolsPlugin } from './DevToolsPlugin';\nimport { events } from '../../../events';\nimport { Log } from '../../../log';\n\nconst debug = require('debug')('expo:start:server:devtools');\n\nexport const DevToolsPluginEndpoint = '/_expo/plugins';\n\nexport const event = events('expo', (t) => [\n t.event<\n 'dev-tools-plugin:load',\n {\n plugins: {\n packageName: string;\n bannerTitle: string;\n cliBanner: boolean;\n webpageEndpoint: string | undefined;\n }[];\n }\n >(),\n]);\n\nexport default class DevToolsPluginManager {\n private plugins: DevToolsPlugin[] | null = null;\n\n constructor(private projectRoot: string) {}\n\n public async queryPluginsAsync(): Promise<DevToolsPlugin[]> {\n if (!this.plugins) {\n this.plugins = await this.queryAutolinkedPluginsAsync(this.projectRoot);\n event('dev-tools-plugin:load', {\n plugins: this.plugins.map((plugin) => ({\n packageName: plugin.packageName,\n bannerTitle: plugin.bannerTitle,\n cliBanner: plugin.cliBanner,\n webpageEndpoint: plugin.webpageEndpoint,\n })),\n });\n }\n return this.plugins;\n }\n\n public async queryPluginAsync(pluginName: string): Promise<DevToolsPlugin | null> {\n const plugins = await this.queryPluginsAsync();\n return plugins.find((p) => p.packageName === pluginName) ?? null;\n }\n\n private async queryAutolinkedPluginsAsync(projectRoot: string): Promise<DevToolsPlugin[]> {\n const autolinking: typeof import('expo/internal/unstable-autolinking-exports') = require('expo/internal/unstable-autolinking-exports');\n const linker = autolinking.makeCachedDependenciesLinker({ projectRoot });\n const revisions = await autolinking.scanExpoModuleResolutionsForPlatform(linker, 'devtools');\n const { resolveModuleAsync } = autolinking.getLinkingImplementationForPlatform('devtools');\n const plugins: ModuleDescriptorDevTools[] = (\n await Promise.all(\n Object.values(revisions).map((revision) => resolveModuleAsync(revision.name, revision))\n )\n ).filter((maybePlugin) => maybePlugin != null);\n debug('Found autolinked plugins', plugins);\n return plugins\n .map((pluginInfo) => {\n try {\n return new DevToolsPlugin(pluginInfo, this.projectRoot);\n } catch (error: any) {\n Log.warn(\n `Skipping plugin \"${pluginInfo.packageName}\": ${error.message ?? 'invalid configuration'}`\n );\n debug('Plugin validation error for %s: %O', pluginInfo.packageName, error);\n return null;\n }\n })\n .filter((p) => p != null) as DevToolsPlugin[];\n }\n}\n"],"names":["DevToolsPluginEndpoint","DevToolsPluginManager","event","debug","require","events","t","projectRoot","plugins","queryPluginsAsync","queryAutolinkedPluginsAsync","map","plugin","packageName","bannerTitle","cliBanner","webpageEndpoint","queryPluginAsync","pluginName","find","p","autolinking","linker","makeCachedDependenciesLinker","revisions","scanExpoModuleResolutionsForPlatform","resolveModuleAsync","getLinkingImplementationForPlatform","Promise","all","Object","values","revision","name","filter","maybePlugin","pluginInfo","DevToolsPlugin","error","Log","warn","message"],"mappings":";;;;;;;;;;;QAQaA;eAAAA;;QAgBb;eAAqBC;;QAdRC;eAAAA;;;gCARkB;wBACR;qBACH;AAEpB,MAAMC,QAAQC,QAAQ,SAAS;AAExB,MAAMJ,yBAAyB;AAE/B,MAAME,QAAQG,IAAAA,cAAM,EAAC,QAAQ,CAACC,IAAM;QACzCA,EAAEJ,KAAK;KAWR;AAEc,MAAMD;IAGnB,YAAY,AAAQM,WAA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CAACC,IAAI,CACN,CAAC,iBAAiB,EAAEJ,WAAWvB,WAAW,CAAC,GAAG,EAAEyB,MAAMG,OAAO,IAAI,yBAAyB;gBAE5FtC,MAAM,sCAAsCiC,WAAWvB,WAAW,EAAEyB;gBACpE,OAAO;YACT;QACF,GACCJ,MAAM,CAAC,CAACd,IAAMA,KAAK;IACxB;AACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/devtools/DevToolsPluginServerHelpers.ts"],"sourcesContent":["import { loadModule } from '@expo/require-utils';\nimport type { IncomingMessage } from 'node:http';\nimport { type WebSocket, WebSocketServer } from 'ws';\n\nconst debug = require('debug')('expo:start:server:devtools') as typeof console.log;\n\n/**\n * Handler default-exported by a plugin's `serverEntryPoint`. Receives a fetch API `Request`\n * with the plugin endpoint prefix stripped from the URL. Returning `null`/`undefined` falls\n * through to static `webpageRoot` serving.\n */\nexport type DevToolsPluginRequestHandler = (\n request: Request\n) => Response | null | undefined | Promise<Response | null | undefined>;\n\n/**\n * Per-connection WebSocket handler exported by a plugin's `serverEntryPoint`. Receives the\n * connected `ws` socket, the upgrade `request`, and the `WebSocketServer` the connection belongs\n * to (use `server.clients` to broadcast). Mirrors the `ws` `'connection'` event so plugin authors\n * use the familiar `socket.on('message', ...)` / `socket.send(...)` API.\n */\nexport type DevToolsPluginWebSocketHandler = (\n socket: WebSocket,\n request: Request,\n server: WebSocketServer\n) => void;\n\nfunction convertUpgradeRequest(request: IncomingMessage, route: string): Request {\n const proto = 'encrypted' in request.socket && !!request.socket.encrypted ? 'https' : 'http';\n const origin = `${proto}://${request.headers.host}`;\n const url = new URL(request.url ?? '/', origin);\n url.pathname = route;\n const headers = new Headers();\n const { rawHeaders } = request;\n for (let index = 0; index < rawHeaders.length; index += 2) {\n const name = rawHeaders[index];\n const value = rawHeaders[index + 1];\n if (name != null && value != null) {\n headers.append(name, value);\n }\n }\n return new Request(url.href, { method: request.method, headers });\n}\n\nexport async function loadRequestHandlerAsync({\n packageName,\n serverEntryPoint,\n}: {\n packageName: string;\n serverEntryPoint: string;\n}): Promise<DevToolsPluginRequestHandler> {\n debug('Loading DevTools plugin server module: %s', serverEntryPoint);\n const serverModule = (await loadModule(serverEntryPoint)) as\n | DevToolsPluginRequestHandler\n | { default?: DevToolsPluginRequestHandler };\n const handler = typeof serverModule === 'function' ? serverModule : serverModule?.default;\n if (typeof handler !== 'function') {\n throw new Error(\n `The serverEntryPoint (${serverEntryPoint}) of plugin ${packageName} ` +\n `must default-export a handler function that takes a Request and returns a Response. ` +\n `Export it as \\`export default function handler(request) {}\\` ` +\n `or \\`exports.default = function handler(request) {}\\`.`\n );\n }\n return handler;\n}\n\nexport async function loadWebSocketServerAsync({\n packageName,\n serverEntryPoint,\n}: {\n packageName: string;\n serverEntryPoint: string;\n}): Promise<Record<string, WebSocketServer>> {\n debug('Loading DevTools plugin WebSocket server module: %s', serverEntryPoint);\n const serverModule = (await loadModule(serverEntryPoint)) as {\n webSocketHandlers?: Record<string, DevToolsPluginWebSocketHandler>;\n };\n const handlers: Record<string, DevToolsPluginWebSocketHandler> =\n serverModule?.webSocketHandlers ?? {};\n\n return Object.fromEntries(\n Object.entries(handlers).map(([route, handler]) => {\n if (typeof handler !== 'function') {\n throw new Error(\n `The webSocketHandlers[\"${route}\"] export of plugin ${packageName} ` +\n `must be a function (socket, request, server) => void.`\n );\n }\n // Routes are mounted relative to the plugin endpoint, so they must be absolute.\n const normalizedRoute = route.startsWith('/') ? route : `/${route}`;\n const server = new WebSocketServer({ noServer: true });\n server.on('connection', (socket, request) =>\n handler(socket, convertUpgradeRequest(request, normalizedRoute), server)\n );\n return [normalizedRoute, server];\n })\n );\n}\n"],"names":["loadRequestHandlerAsync","loadWebSocketServerAsync","debug","require","convertUpgradeRequest","request","route","proto","socket","encrypted","origin","headers","host","url","URL","pathname","Headers","rawHeaders","index","length","name","value","append","Request","href","method","packageName","serverEntryPoint","serverModule","loadModule","handler","default","Error","handlers","webSocketHandlers","Object","fromEntries","entries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A6D,CAAC,GAC/D,CAAC,sDAAsD,CAAC;IAE9D;IACA,OAAOI;AACT;AAEO,eAAe7B,yBAAyB,EAC7CyB,WAAW,EACXC,gBAAgB,EAIjB;IACCzB,MAAM,uDAAuDyB;IAC7D,MAAMC,eAAgB,MAAMC,IAAAA,0BAAU,EAACF;IAGvC,MAAMM,WACJL,CAAAA,gCAAAA,aAAcM,iBAAiB,KAAI,CAAC;IAEtC,OAAOC,OAAOC,WAAW,CACvBD,OAAOE,OAAO,CAACJ,UAAUK,GAAG,CAAC,CAAC,CAAChC,OAAOwB,QAAQ;QAC5C,IAAI,OAAOA,YAAY,YAAY;YACjC,MAAM,IAAIE,MACR,CAAC,uBAAuB,EAAE1B,MAAM,oBAAoB,EAAEoB,YAAY,CAAC,CAAC,GAClE,CAAC,qDAAqD,CAAC;QAE7D;QACA,gFAAgF;QAChF,MAAMa,kBAAkBjC,MAAMkC,UAAU,CAAC,OAAOlC,QAAQ,CAAC,CAAC,EAAEA,OAAO;QACnE,MAAMmC,SAAS,IAAIC,CAAAA,KAAc,iBAAC,CAAC;YAAEC,UAAU;QAAK;QACpDF,OAAOG,EAAE,CAAC,cAAc,CAACpC,QAAQH,UAC/ByB,QAAQtB,QAAQJ,sBAAsBC,SAASkC,kBAAkBE;QAEnE,OAAO;YAACF;YAAiBE;SAAO;IAClC;AAEJ"}
@@ -22,38 +22,46 @@ function _nodepath() {
22
22
  };
23
23
  return data;
24
24
  }
25
- function _resolvefrom() {
26
- const data = /*#__PURE__*/ _interop_require_default(require("resolve-from"));
27
- _resolvefrom = function() {
28
- return data;
29
- };
30
- return data;
31
- }
32
- const _UserSettings = require("../../api/user/UserSettings");
33
- const _log = require("../../log");
34
- const _env = require("../../utils/env");
35
- const _exit = require("../../utils/exit");
25
+ const _UserSettings = require("../../../api/user/UserSettings");
26
+ const _log = require("../../../log");
27
+ const _env = require("../../../utils/env");
28
+ const _exit = require("../../../utils/exit");
29
+ const _MCPDevToolsPluginCLIExtensions = require("./MCPDevToolsPluginCLIExtensions");
36
30
  function _interop_require_default(obj) {
37
31
  return obj && obj.__esModule ? obj : {
38
32
  default: obj
39
33
  };
40
34
  }
41
35
  const debug = require('debug')('expo:start:server:mcp');
42
- async function maybeCreateMCPServerAsync({ projectRoot, devServerUrl }) {
36
+ async function maybeCreateMCPServerAsync({ devServerManager, devServerUrl }) {
43
37
  const mcpServer = _env.env.EXPO_UNSTABLE_MCP_SERVER;
44
38
  if (!mcpServer) {
45
39
  return null;
46
40
  }
47
- const mcpPackagePath = _resolvefrom().default.silent(projectRoot, 'expo-mcp');
48
- if (!mcpPackagePath) {
41
+ const { projectRoot } = devServerManager;
42
+ let mcpPackagePath;
43
+ try {
44
+ mcpPackagePath = require.resolve('expo-mcp', {
45
+ paths: [
46
+ __dirname,
47
+ projectRoot
48
+ ]
49
+ });
50
+ } catch {
49
51
  _log.Log.error('Missing the `expo-mcp` package in the project. To enable the MCP integration, add the `expo-mcp` package to your project.');
50
52
  return null;
51
53
  }
52
- const mcpTunnelPackagePath = _resolvefrom().default.silent(_nodepath().default.dirname(mcpPackagePath), '@expo/mcp-tunnel');
54
+ const mcpTunnelPackagePath = (0, _requireutils().resolveFrom)(_nodepath().default.dirname(mcpPackagePath), '@expo/mcp-tunnel');
53
55
  if (!mcpTunnelPackagePath) {
54
56
  _log.Log.error('Unable to resolve the `@expo/mcp-tunnel` package');
55
57
  return null;
56
58
  }
59
+ // TODO(@kitten): Move the Zod dependency and MCP schema construction into expo-mcp.
60
+ const zodPackagePath = (0, _requireutils().resolveFrom)(_nodepath().default.dirname(mcpPackagePath), 'zod');
61
+ if (!zodPackagePath) {
62
+ _log.Log.error('Unable to resolve Zod from `expo-mcp`. Reinstall your project dependencies to enable MCP.');
63
+ return null;
64
+ }
57
65
  const normalizedServer = /^([a-zA-Z][a-zA-Z\d+\-.]*):\/\//.test(mcpServer) ? mcpServer : `wss://${mcpServer}`;
58
66
  const mcpServerUrlObject = new URL(normalizedServer);
59
67
  const scheme = mcpServerUrlObject.protocol ?? 'wss:';
@@ -63,6 +71,7 @@ async function maybeCreateMCPServerAsync({ projectRoot, devServerUrl }) {
63
71
  debug(`Loading MCP modules: expo-mcp=${mcpPackagePath}, mcp-tunnel=${mcpTunnelPackagePath}`);
64
72
  const { addMcpCapabilities } = await (0, _requireutils().loadModule)(mcpPackagePath);
65
73
  const { TunnelMcpServerProxy } = await (0, _requireutils().loadModule)(mcpTunnelPackagePath);
74
+ const { z } = await (0, _requireutils().loadModule)(zodPackagePath);
66
75
  const logger = {
67
76
  ..._log.Log,
68
77
  debug (...message) {
@@ -79,6 +88,7 @@ async function maybeCreateMCPServerAsync({ projectRoot, devServerUrl }) {
79
88
  devServerUrl
80
89
  });
81
90
  addMcpCapabilities(serverProxy, projectRoot);
91
+ await (0, _MCPDevToolsPluginCLIExtensions.addMcpCapabilities)(serverProxy, devServerManager, z);
82
92
  const removeExitHook = (0, _exit.installExitHooks)(async ()=>{
83
93
  await serverProxy.close();
84
94
  });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/mcp/MCP.ts"],"sourcesContent":["import type {\n McpServerProxy,\n TunnelMcpServerProxy as TunnelMcpServerProxyType,\n} from '@expo/mcp-tunnel' with { 'resolution-mode': 'import' };\nimport { loadModule, resolveFrom } from '@expo/require-utils';\nimport path from 'node:path';\n\nimport { getAccessToken, getSession } from '../../../api/user/UserSettings';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { installExitHooks } from '../../../utils/exit';\nimport type { DevServerManager } from '../DevServerManager';\nimport { addMcpCapabilities as addDevToolsPluginCapabilities } from './MCPDevToolsPluginCLIExtensions';\n\nconst debug = require('debug')('expo:start:server:mcp') as typeof console.log;\n\n/**\n * The MCP server\n */\nexport type McpServer = Omit<McpServerProxy, 'close'> & {\n /**\n * Close the server\n */\n closeAsync: () => Promise<void>;\n};\n\n/**\n * Create the MCP server\n */\nexport async function maybeCreateMCPServerAsync({\n devServerManager,\n devServerUrl,\n}: {\n devServerManager: DevServerManager;\n devServerUrl: string;\n}): Promise<McpServer | null> {\n const mcpServer = env.EXPO_UNSTABLE_MCP_SERVER;\n if (!mcpServer) {\n return null;\n }\n const { projectRoot } = devServerManager;\n let mcpPackagePath: string;\n try {\n mcpPackagePath = require.resolve('expo-mcp', { paths: [__dirname, projectRoot] });\n } catch {\n Log.error(\n 'Missing the `expo-mcp` package in the project. To enable the MCP integration, add the `expo-mcp` package to your project.'\n );\n return null;\n }\n const mcpTunnelPackagePath = resolveFrom(path.dirname(mcpPackagePath), '@expo/mcp-tunnel');\n if (!mcpTunnelPackagePath) {\n Log.error('Unable to resolve the `@expo/mcp-tunnel` package');\n return null;\n }\n\n // TODO(@kitten): Move the Zod dependency and MCP schema construction into expo-mcp.\n const zodPackagePath = resolveFrom(path.dirname(mcpPackagePath), 'zod');\n if (!zodPackagePath) {\n Log.error(\n 'Unable to resolve Zod from `expo-mcp`. Reinstall your project dependencies to enable MCP.'\n );\n return null;\n }\n\n const normalizedServer = /^([a-zA-Z][a-zA-Z\\d+\\-.]*):\\/\\//.test(mcpServer)\n ? mcpServer\n : `wss://${mcpServer}`;\n const mcpServerUrlObject = new URL(normalizedServer);\n const scheme = mcpServerUrlObject.protocol ?? 'wss:';\n const mcpServerUrl = `${scheme}//${mcpServerUrlObject.host}`;\n debug(`Creating MCP tunnel - server URL: ${mcpServerUrl}`);\n\n try {\n debug(`Loading MCP modules: expo-mcp=${mcpPackagePath}, mcp-tunnel=${mcpTunnelPackagePath}`);\n const { addMcpCapabilities } = (await loadModule(mcpPackagePath)) as {\n addMcpCapabilities: (server: McpServerProxy, projectRoot: string) => void;\n };\n const { TunnelMcpServerProxy } = (await loadModule(mcpTunnelPackagePath)) as {\n TunnelMcpServerProxy: typeof TunnelMcpServerProxyType;\n };\n const { z } = (await loadModule(zodPackagePath)) as typeof import('zod');\n\n const logger = {\n ...Log,\n debug(...message: any[]): void {\n debug(...message);\n },\n info(...message: any[]): void {\n Log.log(...message);\n },\n };\n const serverProxy: McpServerProxy = new TunnelMcpServerProxy(mcpServerUrl, {\n logger,\n wsHeaders: createAuthHeaders(),\n projectRoot,\n devServerUrl,\n });\n addMcpCapabilities(serverProxy, projectRoot);\n await addDevToolsPluginCapabilities(serverProxy, devServerManager, z);\n\n const removeExitHook = installExitHooks(async () => {\n await serverProxy.close();\n });\n const server = serverProxy as unknown as McpServer;\n server.closeAsync = async () => {\n removeExitHook();\n await serverProxy.close();\n };\n\n return server;\n } catch (error: unknown) {\n debug(`Error creating MCP tunnel: ${error}`);\n }\n return null;\n}\n\nfunction createAuthHeaders(): Record<string, string> {\n const token = getAccessToken();\n if (token) {\n return {\n authorization: `Bearer ${token}`,\n };\n }\n const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n return {\n 'expo-session': sessionSecret,\n };\n }\n return {};\n}\n"],"names":["maybeCreateMCPServerAsync","debug","require","devServerManager","devServerUrl","mcpServer","env","EXPO_UNSTABLE_MCP_SERVER","projectRoot","mcpPackagePath","resolve","paths","__dirname","Log","error","mcpTunnelPackagePath","resolveFrom","path","dirname","zodPackagePath","normalizedServer","test","mcpServerUrlObject","URL","scheme","protocol","mcpServerUrl","host","addMcpCapabilities","loadModule","TunnelMcpServerProxy","z","logger","message","info","log","serverProxy","wsHeaders","createAuthHeaders","addDevToolsPluginCapabilities","removeExitHook","installExitHooks","close","server","closeAsync","getSession","token","getAccessToken","authorization","sessionSecret"],"mappings":";;;;+BA6BsBA;;;eAAAA;;;;yBAzBkB;;;;;;;gEACvB;;;;;;8BAE0B;qBACvB;qBACA;sBACa;gDAEmC;;;;;;AAEpE,MAAMC,QAAQC,QAAQ,SAAS;AAexB,eAAeF,0BAA0B,EAC9CG,gBAAgB,EAChBC,YAAY,EAIb;IACC,MAAMC,YAAYC,QAAG,CAACC,wBAAwB;IAC9C,IAAI,CAACF,WAAW;QACd,OAAO;IACT;IACA,MAAM,EAAEG,WAAW,EAAE,GAAGL;IACxB,IAAIM;IACJ,IAAI;QACFA,iBAAiB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YACX9B;YACAJ;QACF;QACAwB,mBAAmBQ,aAAa5B;QAChC,MAAM+B,IAAAA,kDAA6B,EAACH,aAAajC,kBAAkB4B;QAEnE,MAAMS,iBAAiBC,IAAAA,sBAAgB,EAAC;YACtC,MAAML,YAAYM,KAAK;QACzB;QACA,MAAMC,SAASP;QACfO,OAAOC,UAAU,GAAG;YAClBJ;YACA,MAAMJ,YAAYM,KAAK;QACzB;QAEA,OAAOC;IACT,EAAE,OAAO7B,OAAgB;QACvBb,MAAM,CAAC,2BAA2B,EAAEa,OAAO;IAC7C;IACA,OAAO;AACT;AAEA,SAASwB;QAOeO;IANtB,MAAMC,QAAQC,IAAAA,4BAAc;IAC5B,IAAID,OAAO;QACT,OAAO;YACLE,eAAe,CAAC,OAAO,EAAEF,OAAO;QAClC;IACF;IACA,MAAMG,iBAAgBJ,cAAAA,IAAAA,wBAAU,wBAAVA,YAAcI,aAAa;IACjD,IAAIA,eAAe;QACjB,OAAO;YACL,gBAAgBA;QAClB;IACF;IACA,OAAO,CAAC;AACV"}
@@ -8,12 +8,11 @@ Object.defineProperty(exports, "addMcpCapabilities", {
8
8
  return addMcpCapabilities;
9
9
  }
10
10
  });
11
- const _DevToolsPluginschema = require("./DevToolsPlugin.schema");
12
- const _DevToolsPluginCliExtensionExecutor = require("./DevToolsPluginCliExtensionExecutor");
11
+ const _log = require("../../../log");
13
12
  const _createMCPDevToolsExtensionSchema = require("./createMCPDevToolsExtensionSchema");
14
- const _log = require("../../log");
13
+ const _DevToolsPluginCliExtensionExecutor = require("../devtools/DevToolsPluginCliExtensionExecutor");
15
14
  const debug = require('debug')('expo:start:server:devtools:mcp');
16
- async function addMcpCapabilities(mcpServer, devServerManager) {
15
+ async function addMcpCapabilities(mcpServer, devServerManager, z) {
17
16
  const plugins = await devServerManager.devtoolsPluginManager.queryPluginsAsync();
18
17
  for (const plugin of plugins){
19
18
  if (plugin.cliExtensions) {
@@ -34,7 +33,7 @@ async function addMcpCapabilities(mcpServer, devServerManager) {
34
33
  commands: mcpCommands
35
34
  }
36
35
  };
37
- const schema = (0, _createMCPDevToolsExtensionSchema.createMCPDevToolsExtensionSchema)(mcpPlugin);
36
+ const schema = (0, _createMCPDevToolsExtensionSchema.createMCPDevToolsExtensionSchema)(mcpPlugin, z);
38
37
  debug(`Installing MCP CLI extension for plugin: ${plugin.packageName} - found ${mcpCommands.length} commands`);
39
38
  mcpServer.registerTool(plugin.packageName, {
40
39
  title: plugin.packageName,
@@ -51,30 +50,18 @@ async function addMcpCapabilities(mcpServer, devServerManager) {
51
50
  args,
52
51
  metroServerOrigin
53
52
  });
54
- const parsedResults = _DevToolsPluginschema.DevToolsPluginOutputSchema.safeParse(results);
55
- if (parsedResults.success === false) {
56
- throw new Error(`Invalid output from CLI command: ${parsedResults.error.issues.map((issue)=>issue.message).join(', ')}`);
57
- }
58
53
  return {
59
- content: parsedResults.data.map((line)=>{
60
- const { type } = line;
61
- if (type === 'text') {
62
- return {
63
- type,
64
- text: line.text,
65
- level: line.level,
66
- url: line.url
67
- };
68
- } else if (line.type === 'image' || line.type === 'audio') {
69
- // We could present this as a resource_link, but it seems not to be well supported in MCP clients,
70
- // so we'll return a text with the link instead.
71
- return {
72
- type: 'text',
73
- text: `${type} resource: ${line.url}${line.text ? ' (' + line.text + ')' : ''}`
74
- };
54
+ content: results.map((line)=>{
55
+ if (line.type === 'text') {
56
+ return line;
75
57
  }
76
- return null;
77
- }).filter((line)=>line !== null)
58
+ // We could present this as a resource_link, but it seems not to be well supported in MCP clients,
59
+ // so we'll return a text with the link instead.
60
+ return {
61
+ type: 'text',
62
+ text: `${line.type} resource: ${line.url}${line.text ? ' (' + line.text + ')' : ''}`
63
+ };
64
+ })
78
65
  };
79
66
  } catch (e) {
80
67
  _log.Log.error('Error executing MCP CLI command:', e);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/mcp/MCPDevToolsPluginCLIExtensions.ts"],"sourcesContent":["import { Log } from '../../../log';\nimport type { DevServerManager } from '../DevServerManager';\nimport type { McpServer } from './MCP';\nimport { createMCPDevToolsExtensionSchema } from './createMCPDevToolsExtensionSchema';\nimport type { DevToolsPluginInfo } from '../devtools/DevToolsPlugin.schema';\nimport { DevToolsPluginCliExtensionExecutor } from '../devtools/DevToolsPluginCliExtensionExecutor';\n\nconst debug = require('debug')('expo:start:server:devtools:mcp');\n\nexport async function addMcpCapabilities(\n mcpServer: Pick<McpServer, 'registerTool'>,\n devServerManager: DevServerManager,\n z: typeof import('zod').z\n) {\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, z);\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 return {\n content: results.map((line) => {\n if (line.type === 'text') {\n return line;\n }\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: `${line.type} resource: ${line.url}${line.text ? ' (' + line.text + ')' : ''}`,\n } as const;\n }),\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","z","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","content","map","line","type","text","url","e","Log","error","toString","isError"],"mappings":";;;;+BASsBA;;;eAAAA;;;qBATF;kDAG6B;oDAEE;AAEnD,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,mBACpBG,SAA0C,EAC1CC,gBAAkC,EAClCC,CAAyB;IAEzB,MAAMC,UAAU,MAAMF,iBAAiBG,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,WAAWb;YAE3DJ,MACE,CAAC,yCAAyC,EAAEQ,OAAOU,WAAW,CAAC,SAAS,EAAER,YAAYM,MAAM,CAAC,SAAS,CAAC;YAGzGd,UAAUoB,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,oBAAoB1B,iBACvB2B,mBAAmB,GACnBC,qBAAqB;oBAExB,MAAMC,UAAU,MAAM,IAAIC,sEAAkC,CAC1DhB,WACAd,iBAAiB+B,WAAW,EAC5BC,OAAO,CAAC;wBAAER;wBAASC;wBAAMC;oBAAkB;oBAE7C,OAAO;wBACLO,SAASJ,QAAQK,GAAG,CAAC,CAACC;4BACpB,IAAIA,KAAKC,IAAI,KAAK,QAAQ;gCACxB,OAAOD;4BACT;4BACA,kGAAkG;4BAClG,gDAAgD;4BAChD,OAAO;gCACLC,MAAM;gCACNC,MAAM,GAAGF,KAAKC,IAAI,CAAC,WAAW,EAAED,KAAKG,GAAG,GAAGH,KAAKE,IAAI,GAAG,OAAOF,KAAKE,IAAI,GAAG,MAAM,IAAI;4BACtF;wBACF;oBACF;gBACF,EAAE,OAAOE,GAAQ;oBACfC,QAAG,CAACC,KAAK,CAAC,oCAAoCF;oBAC9C,OAAO;wBACLN,SAAS;4BAAC;gCAAEG,MAAM;gCAAQC,MAAM,CAAC,yBAAyB,EAAEE,EAAEG,QAAQ,IAAI;4BAAC;yBAAE;wBAC7EC,SAAS;oBACX;gBACF;YACF;QAEJ;IACF;AACF"}
@@ -8,14 +8,7 @@ Object.defineProperty(exports, "createMCPDevToolsExtensionSchema", {
8
8
  return createMCPDevToolsExtensionSchema;
9
9
  }
10
10
  });
11
- function _zod() {
12
- const data = require("zod");
13
- _zod = function() {
14
- return data;
15
- };
16
- return data;
17
- }
18
- function createMCPDevToolsExtensionSchema(plugin) {
11
+ function createMCPDevToolsExtensionSchema(plugin, z) {
19
12
  var _plugin_cliExtensions;
20
13
  if (plugin.cliExtensions == null || ((_plugin_cliExtensions = plugin.cliExtensions) == null ? void 0 : _plugin_cliExtensions.commands.length) === 0) {
21
14
  throw new Error(`Plugin ${plugin.packageName} has no commands defined. Please define at least one command.`);
@@ -55,26 +48,26 @@ function createMCPDevToolsExtensionSchema(plugin) {
55
48
  const commandsUsingParam = commandList.length === commands.length ? 'all commands' : commandList.map((c)=>`"${c}"`).join(', ');
56
49
  // Include command context in the description so LLMs know when to use each parameter
57
50
  const fullDescription = baseDescription ? `${baseDescription} (Used by: ${commandsUsingParam})` : `Parameter for: ${commandsUsingParam}`;
58
- allParameters[paramName] = paramTypeToZod(parameterTypes[paramName]).optional().describe(fullDescription);
51
+ allParameters[paramName] = paramTypeToZod(parameterTypes[paramName], z).optional().describe(fullDescription);
59
52
  }
60
53
  // Build the command description with clear instructions for the LLM
61
54
  const hasParameters = Object.keys(allParameters).length > 0;
62
55
  const commandDescription = hasParameters ? `Required. The command to execute. You must select exactly one command from the enum values. ` + `Each command may require specific parameters - only include parameters that belong to the selected command. ` + `Commands: ${commandDescriptions}.` : `Required. The command to execute. Select exactly one from the available options. ` + `Commands: ${commandDescriptions}.`;
63
56
  // Build the flat schema with additionalProperties: false for LLM compatibility
64
- const schema = _zod().z.object({
65
- command: _zod().z.enum(commandNames).describe(commandDescription),
57
+ const schema = z.object({
58
+ command: z.enum(commandNames).describe(commandDescription),
66
59
  ...allParameters
67
60
  }).strict(); // .strict() adds additionalProperties: false
68
61
  return schema;
69
62
  }
70
- function paramTypeToZod(type) {
63
+ function paramTypeToZod(type, z) {
71
64
  switch(type){
72
65
  case 'number':
73
- return _zod().z.number();
66
+ return z.number();
74
67
  case 'confirm':
75
- return _zod().z.boolean();
68
+ return z.boolean();
76
69
  case 'text':
77
- return _zod().z.string();
70
+ return z.string();
78
71
  }
79
72
  }
80
73
 
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/mcp/createMCPDevToolsExtensionSchema.ts"],"sourcesContent":["import type { z as Zod } from 'zod';\n\nimport type {\n DevToolsPluginCommandParameter,\n DevToolsPluginInfo,\n} from '../devtools/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, z: typeof Zod) {\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, Zod.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]!, z)\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'], z: typeof Zod) {\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","z","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","object","enum","strict","number","boolean","string"],"mappings":";;;;+BAuCgBA;;;eAAAA;;;AAAT,SAASA,iCAAiCC,MAA0B,EAAEC,CAAa;QACpDD;IAApC,IAAIA,OAAOE,aAAa,IAAI,QAAQF,EAAAA,wBAAAA,OAAOE,aAAa,qBAApBF,sBAAsBG,QAAQ,CAACC,MAAM,MAAK,GAAG;QAC/E,MAAM,IAAIC,MACR,CAAC,OAAO,EAAEL,OAAOM,WAAW,CAAC,6DAA6D,CAAC;IAE/F;IAEA,MAAMH,WAAWH,OAAOE,aAAa,CAACC,QAAQ;IAE9C,yEAAyE;IACzE,MAAMI,sBAAsBJ,SACzBK,GAAG,CAAC,CAACC;YACWA;QAAf,MAAMC,UAASD,gBAAAA,EAAEE,UAAU,qBAAZF,cAAcD,GAAG,CAAC,CAACI,IAAMA,EAAEC,IAAI,EAAEC,IAAI,CAAC;QACrD,OAAOJ,SAAS,CAAC,CAAC,EAAED,EAAEI,IAAI,CAAC,GAAG,EAAEJ,EAAEM,KAAK,CAAC,UAAU,EAAEL,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,EAAED,EAAEI,IAAI,CAAC,GAAG,EAAEJ,EAAEM,KAAK,EAAE;IAC3F,GACCD,IAAI,CAAC;IAER,uDAAuD;IACvD,MAAME,eAAeb,SAASK,GAAG,CAAC,CAACC,IAAMA,EAAEI,IAAI;IAE/C,oDAAoD;IACpD,4DAA4D;IAC5D,MAAMI,sBAAgD,CAAC;IACvD,MAAMC,wBAAgD,CAAC;IACvD,MAAMC,iBAAyE,CAAC;IAEhF,KAAK,MAAMC,WAAWjB,SAAU;QAC9B,IAAIiB,QAAQT,UAAU,IAAIS,QAAQT,UAAU,CAACP,MAAM,GAAG,GAAG;YACvD,KAAK,M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